@tencentcloud/sdk-mcp 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/@tencent/aegis-node-sdk/lib/aegis.min.js +1 -1
- package/README.md +8 -9
- package/package.json +13 -2
- package/server.js +1 -1
- package/server.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("url"),require("querystring"),require("axios")):"function"==typeof define&&define.amd?define(["url","querystring","axios"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).Aegis=t(e.url,e.querystring,e.axios)}(this,(function(e,t,n){"use strict";function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function o(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var i=o(e),s=o(t),l=r(n),c=function(e,t){return(c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)};function a(e,t){function n(){this.constructor=e}c(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var u=function(){return(u=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function f(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function l(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,l)}c((r=r.apply(e,t||[])).next())}))}function p(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(i){return function(l){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,l])}}}function h(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),o=0;for(t=0;t<n;t++)for(var i=arguments[t],s=0,l=i.length;s<l;s++,o++)r[o]=i[s];return r}Object.assign||Object.defineProperty(Object,"assign",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(null==e)throw new TypeError("Cannot convert first argument to object");for(var t=Object(e),n=1;n<arguments.length;n++){var r=arguments[n];if(null!=r){r=Object(r);for(var o=Object.keys(Object(r)),i=0,s=o.length;i<s;i++){var l=o[i],c=Object.getOwnPropertyDescriptor(r,l);(null==c?void 0:c.enumerable)&&(t[l]=r[l])}}}return t}});var d,g=["ext1","ext2","ext3","level","trace","tag","seq","code"],v=function(){function e(){var e=this;this.emit=function(t,n){if(e){var r,o=e.eventsList[t];if(null==o?void 0:o.length){o=o.slice();for(var i=0;i<o.length;i++){r=o[i];try{var s=r.callback.apply(e,[n]);if(1===r.type&&e.remove(t,r.callback),!1===s)break}catch(e){throw e}}}return e}},this.eventsList={}}return e.prototype.indexOf=function(e,t){for(var n=0;n<e.length;n++)if(e[n].callback===t)return n;return-1},e.prototype.on=function(e,t,n){if(void 0===n&&(n=0),this){var r=this.eventsList[e];if(r||(this.eventsList[e]=[],r=this.eventsList[e]),-1===this.indexOf(r,t)){var o={name:e,type:n||0,callback:t};return r.push(o),this}return this}},e.prototype.one=function(e,t){this.on(e,t,1)},e.prototype.remove=function(e,t){if(this){var n=this.eventsList[e];if(!n)return null;if(!t){try{delete this.eventsList[e]}catch(e){}return null}if(n.length){var r=this.indexOf(n,t);n.splice(r,1)}return this}},e.prototype.clear=function(){this.eventsList={}},e}(),m=function(e){if(!e||0===e.length)return"{}";e=Array.isArray(e)?e:[e];var t=Object.keys(e[0]),n={};return t.forEach((function(t){n[t]=e.map((function(e){return e[t]}))})),n.count=e.length,S(n)};!function(e){e[e.number=-1]="number",e.string=""}(d||(d={}));var y,O,b,R,E,w=function(){var e=new WeakSet;return function(t,n){if(n instanceof Error)return"Error.message: "+n.message+" \n Error.stack: "+n.stack;if("object"==typeof n&&null!==n){if(e.has(n))return"[Circular "+(t||"root")+"]";e.add(n)}return n}},P=function(e){if("string"==typeof e)return e;try{return e instanceof Error?(JSON.stringify(e,w(),4)||"undefined").replace(/"/gim,""):JSON.stringify(e,w(),4)||"undefined"}catch(e){return"error happen when aegis stringify: \n "+e.message+" \n "+e.stack}},S=function(e){if("string"==typeof e)return e;try{return JSON.stringify(e,w())||"undefined"}catch(e){return"error happen when aegis stringify: \n "+e.message+" \n "+e.stack}};!function(e){e.INFO_ALL="-1",e.API_RESPONSE="1",e.INFO="2",e.ERROR="4",e.PROMISE_ERROR="8",e.AJAX_ERROR="16",e.SCRIPT_ERROR="32",e.IMAGE_ERROR="64",e.CSS_ERROR="128",e.CONSOLE_ERROR="256",e.MEDIA_ERROR="512",e.RET_ERROR="1024",e.PAGE_LOAD="1025",e.SLOW_PAGE_LOAD="1026",e.SLOW_NET_REQUEST="1027",e.ASSERT_REQUEST="1028",e.SLOW_ASSET_REQUEST="1029",e.CLICK_EVENT="1030",e.true="1031",e.REPORT="2048",e.PV="4096",e.EVENT="8192",e.SPEED_EVENT="8193",e.PAGE_NOT_FOUND_ERROR="16384",e.WEBSOCKET_ERROR="32768",e.BRIDGE_ERROR="65536",e.LAZY_LOAD_ERROR="131072"}(y||(y={})),function(e){e[e.android=1]="android",e[e.ios=2]="ios",e[e.windows=3]="windows",e[e.macos=4]="macos",e[e.linux=5]="linux",e[e.devtools=6]="devtools",e[e.other=100]="other"}(O||(O={})),function(e){e[e.unknown=100]="unknown",e[e.wifi=1]="wifi",e[e.net2g=2]="net2g",e[e.net3g=3]="net3g",e[e.net4g=4]="net4g",e[e.net5g=5]="net5g",e[e.net6g=6]="net6g"}(b||(b={})),function(e){e.LOG="log",e.SPEED="speed",e.PERFORMANCE="performance",e.OFFLINE="offline",e.WHITE_LIST="whiteList",e.VITALS="vitals",e.PV="pv",e.CUSTOM_PV="customPV",e.EVENT="event",e.CUSTOM="custom",e.SDK_ERROR="sdkError",e.SET_DATA="setData",e.LOAD_PACKAGE="loadPackage"}(R||(R={})),function(e){e.production="production",e.development="development",e.gray="gray",e.pre="pre",e.daily="daily",e.local="local",e.test="test",e.others="others"}(E||(E={}));var T=function(e,t){return function(n,r){var o=t.logCreated;if("function"==typeof o){var i=n.filter((function(e){return!1!==o(e)}));return e("beforeWrite",i),r(i)}return e("beforeWrite",n),r(n)}},_=function(e){return e.filter((function(t,n){return"static"!==t.type||!e.find((function(e,r){return t.url===e.url&&200===t.status&&r>n}))}))},x=function(e,t){var n,r=[],o=e.config;return e.lifeCycle.on("destroy",(function(){r.length=0})),function(i,s){if(Array.isArray(i)?r=r.concat(i):r.push(i),t&&r.length>=t||e.sendNow&&r.length>0)return r=_(r),s(r.splice(0,r.length)),void(n&&clearTimeout(n));n&&clearTimeout(n),n=setTimeout((function(){n=null,(r=_(r)).length>0&&s(r.splice(0,r.length))}),o.delay)}},U=function(e,t){return Array.isArray(e)?t(e.map((function(e){return function(e){return g.forEach((function(t){e[t]||delete e[t]})),e}(u(u({},e),{msg:"string"==typeof e.msg?e.msg:[].concat(e.msg).map(P).join(" ")}))}))):t([u(u({},e),{msg:"string"==typeof e.msg?e.msg:P(e.msg)})])},C=function(e){e.level===y.INFO_ALL&&(e.level=y.INFO)},L=function(e){var t,n=!1,r=!1,o=!1,i=[];return e.lifeCycle.on("onConfigChange",(function(){t&&clearTimeout(t),t=setTimeout((function(){if(!o&&e.config){o=!0;var t=e.config.whiteListUrl,s=void 0===t?"":t;s&&e.sendPipeline([function(t,o){o({url:s,type:R.WHITE_LIST,success:function(t){r=!0;try{var o=t.data?t.data:JSON.parse(t),s=o.retcode,l=o.result,c=void 0===l?{}:l;0===s&&(n=c.is_in_white_list,e.isWhiteList=n,c.rate>=0&&c.rate<=1&&(e.config.random=c.rate,e.isGetSample=!1)),e.isWhiteList&&i.length?D(e)(i.splice(0),(function(){})):!e.isWhiteList&&i.length&&(i.length=0);var a=e.config.onWhitelist;"function"==typeof a&&a(n)}catch(e){}},fail:function(){r=!0}})}],R.WHITE_LIST)(null),o=!1}}),e.config.uin?50:500)})),e.lifeCycle.on("destroy",(function(){i.length=0})),function(t,o){var s,l;if(n||(null===(l=null===(s=e.config)||void 0===s?void 0:s.api)||void 0===l?void 0:l.reportRequest))o(t.concat(i.splice(0)).map((function(e){return C(e),e})));else{var c=t.filter((function(e){return e.level!==y.INFO&&e.level!==y.API_RESPONSE?(C(e),!0):(r||(i.push(e),i.length>=200&&(i.length=200)),!1)}));c.length&&o(c)}}},I=function(e){return setTimeout((function(){var t=e.config,n=t.pvUrl,r=void 0===n?"":n,o=t.spa,i=["web-sdk","mp-sdk"].indexOf("node-sdk")>-1;r&&(i&&!o||!i)&&e.sendPipeline([function(e,t){t({url:r,type:R.PV})}],R.PV)(null)}),100),function(e,t){t(e)}},A={},k={},j=function(e){return function(t,n){var r="number"==typeof e.repeat?e.repeat:60;if(r<=0)return n(t);var o=(null==e?void 0:e.id)+"_error",i=k[o]||{};n(t.filter((function(e){if(e.level===y.ERROR||e.level===y.PROMISE_ERROR||e.level===y.AJAX_ERROR||e.level===y.SCRIPT_ERROR||e.level===y.IMAGE_ERROR||e.level===y.CSS_ERROR||e.level===y.MEDIA_ERROR||e.level===y.RET_ERROR||e.level===y.BRIDGE_ERROR||e.level===y.PAGE_NOT_FOUND_ERROR||e.level===y.WEBSOCKET_ERROR||e.level===y.LAZY_LOAD_ERROR){var t=e.msg.slice(0,200);if(i[t]>r)return A[o]||(A[n=o]||(A[n]=setTimeout((function(){k[n]={},A[n]=null}),6e4)),A[n]),!1;i[t]=1+~~i[t],k[o]=i}var n;return!0})))}},N=function(e){return(Array.isArray(e)?e:[e]).map((function(e){return Object.getOwnPropertyNames(e).reduce((function(t,n){return"ctx"!==n&&(t[n]=e[n]),t}),{level:y.INFO,msg:""})}))},D=function(e){return function(t){return e.sendPipeline([function(t,n){return n({url:e.config.url||"",data:m(N(t)),method:"post",contentType:"application/json",type:R.LOG,log:t,requestConfig:{timeout:5e3},success:function(){var r=e.config.onReport;"function"==typeof r&&t.forEach((function(e){r(e)})),"function"==typeof n&&n([])}})}],R.LOG)(t)}},B=function(e){return function(t){e.sendPipeline([function(t,n){var r=t.map((function(t){return{name:t.name,ext1:t.ext1||e.config.ext1||"",ext2:t.ext2||e.config.ext2||"",ext3:t.ext3||e.config.ext3||""}}));n({url:e.config.eventUrl+"?payload="+encodeURIComponent(JSON.stringify(r)),type:R.EVENT,log:t})}],R.EVENT)(t)}},q=function(e){return function(t){return e.sendPipeline([function(t,n){n({url:e.config.customTimeUrl+"?payload="+encodeURIComponent(JSON.stringify({custom:t})),type:R.CUSTOM,log:t})}],R.CUSTOM)(t)}},M=function(e,t){return function(n,r){var o=Array.isArray(n),i=o?n:[n];e.lifeCycle.emit("beforeRequest",n);var s=e.config.beforeRequest;"function"==typeof s&&(i=i.map((function(e){try{var n=s({logs:e,logType:t});return(null==n?void 0:n.logType)===t&&(null==n?void 0:n.logs)?n.logs:!1!==n&&e}catch(t){return e}})).filter((function(e){return!1!==e}))),i.length&&(i=function(e,t){if(!Array.isArray(e)||e.length<=1)return e;var n=[],r=[];return!(r="string"==typeof t?[t]:t)||r.length<=0||(r.forEach((function(t){e.forEach((function(e){(null==e?void 0:e[t])&&n.push(t)}))})),n.length>0&&(e=e.map((function(e){var t={};return n.forEach((function(e){t[e]=""})),u(u({},t),e)})))),e}(i,g),r(o?i:i[0]))}},H=function(e){return function(t,n){e.lifeCycle.emit("modifyRequest",t);var r=e.config.modifyRequest;if("function"==typeof r)try{var o=r(t);"object"==typeof o&&"url"in o&&(t=o)}catch(e){console.error(e)}n(t)}},F=function(e){return function(t,n){var r;null===(r=e.lifeCycle)||void 0===r||r.emit("afterRequest",t);var o=(e.config||{}).afterRequest;"function"==typeof o&&!1===o(t)||n(t)}};Array(32);var V,G=function(){},W=function(e){if(!e||!e.reduce||!e.length)throw new TypeError("createPipeline need at least one function param");return 1===e.length?function(t,n){e[0](t,n||G)}:e.reduce((function(e,t){return function(n,r){return void 0===r&&(r=G),e(n,(function(e){return null==t?void 0:t(e,r)}))}}))},J=function(e,t){Object.getOwnPropertyNames(e).forEach((function(n){"function"==typeof e[n]&&"constructor"!==n&&(t?t[n]="sendPipeline"===n?function(){return function(){}}:function(){}:e[n]=function(){})}))},K=function(){function e(t){var n,r=this;this.isGetSample=!1,this.isHidden=!1,this.config={version:0,delay:1e3,onError:!0,repeat:60,random:1,aid:!0,device:!0,pagePerformance:!0,webVitals:!0,speedSample:!0,onClose:!0,reportLoadPackageSpeed:!0,hostUrl:"https://rumt-zh.com",env:"production",url:"",offlineUrl:"",whiteListUrl:"",pvUrl:"",speedUrl:"",customTimeUrl:"",performanceUrl:"",performanceUrlForHippy:"",webVitalsUrl:"",eventUrl:"",setDataReportUrl:"",reportImmediately:!0},this.isWhiteList=!1,this.lifeCycle=new v,this.bean={},this.normalLogPipeline=W([x(this,5),U,(n=this,function(e,t){var r=n.config;t(e=e.map((function(e){var t,n=r.maxLength||102400;try{if(!e.msg||e.msg.length<=n)return e;e.msg=null===(t=e.msg)||void 0===t?void 0:t.substring(0,n)}catch(t){e.msg=P(e.msg).substring(0,r.maxLength)}return e})))}),j(this.config),T(this.lifeCycle.emit,this.config),I(this),L(this),function(e,t){try{var n=JSON.parse(JSON.stringify(e));r.lifeCycle.emit("beforeReport",n);var o=r.config.beforeReport;"function"==typeof o&&(e=e.filter((function(e){return!1!==o(e)}))),e.length&&t(e)}catch(e){}},D(this)]),this.eventPipeline=W([x(this,10),B(this)]),this.customTimePipeline=W([x(this,10),q(this)]),this.timeMap={},this.failRequestCount=0,this.config=function(e,t){return void 0===t&&(t="https://rumt-zh.com"),"string"!=typeof t&&(t="https://rumt-zh.com"),e.url=e.url||t+"/collect",e.offlineUrl=e.offlineUrl||t+"/offline",e.whiteListUrl=e.whiteListUrl||t+"/collect/whitelist",e.pvUrl=e.pvUrl||t+"/collect/pv",e.eventUrl=e.eventUrl||t+"/collect/events",e.speedUrl=e.speedUrl||t+"/speed",e.customTimeUrl=e.customTimeUrl||t+"/speed/custom",e.performanceUrl=e.performanceUrl||t+"/speed/performance",e.performanceUrlForHippy=e.performanceUrlForHippy||t+"/speed/hippyPerformance",e.webVitalsUrl=e.webVitalsUrl||t+"/speed/webvitals",e.setDataReportUrl=e.SetDataReportUrl||t+"/speed/miniProgramData",e}(this.config,t.hostUrl),e.instances.push(this)}return e.use=function(t){-1===e.installedPlugins.indexOf(t)&&t.aegisPlugin&&e.installedPlugins.push(t)},e.unuse=function(t){var n=e.installedPlugins.indexOf(t);-1!==n&&e.installedPlugins.splice(n,1)},e.prototype.init=function(t){this.setConfig(t);for(var n=0;n<e.installedPlugins.length;n++)try{e.installedPlugins[n].patch(this)}catch(e){this.sendSDKError(e)}this.lifeCycle.emit("onInited")},e.prototype.destroy=function(t){void 0===t&&(t=!1);var n,r,o,i=e.instances.indexOf(this);-1!==i&&e.instances.splice(i,1);for(var s=e.installedPlugins.length-1;s>=0;s--)try{e.installedPlugins[s].unpatch(this)}catch(e){this.sendSDKError(e)}if(this.lifeCycle.emit("destroy"),this.lifeCycle.clear(),t)n=this,o=Object.getOwnPropertyDescriptors(n),Object.keys(o).forEach((function(e){o[e].writable&&(r?r[e]=null:n[e]=null)})),Object.setPrototypeOf(this,null);else{var l=this;do{l.constructor!==Object&&J(l,this)}while(l=Object.getPrototypeOf(l));if(0===e.instances.length){var c=Object.getPrototypeOf(this).constructor;J(c),J(e)}}},e.prototype.setConfig=function(e){Object.assign(this.config,e);var t=this.config,n=t.id,r=t.uin,o=t.version,i=t.ext1,s=t.ext2,l=t.ext3,c=t.aid,a=t.env,u=void 0===a?"production":a,f=t.pageUrl,p=this.bean.id!==n||this.bean.uin!==r||this.bean.aid!==c;return this.bean.id=n||"",this.bean.uin=r||"",this.bean.version=o||"1.43.25",this.bean.aid=c||"",this.bean.env=function(e){switch(e){case E.production:case E.development:case E.gray:case E.pre:case E.daily:case E.local:case E.test:case E.others:return!0;default:return!1}}(u)?u:E.others,f&&this.extendBean("from",encodeURIComponent(f.slice(0,2048))),i&&this.extendBean("ext1",encodeURIComponent(i)),s&&this.extendBean("ext2",encodeURIComponent(s)),l&&this.extendBean("ext3",encodeURIComponent(l)),p&&this.lifeCycle.emit("onConfigChange",this.config),this.config},e.prototype.extendBean=function(e,t){this.bean[e]=t},e.prototype.send=function(e,t,n){var r=this;return W([H(this),function(e,o){r.request(e,(function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];o({isErr:!1,result:n,logType:e.type,logs:e.log}),null==t||t.apply(void 0,n)}),(function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];o({isErr:!0,result:t,logType:e.type,logs:e.log}),null==n||n.apply(void 0,t)}))},F(this)])(e)},e.prototype.sendSDKError=function(e){var t=this;this.sendPipeline([function(e,n){n({url:t.config.url+"?id=1085&msg[0]="+encodeURIComponent(P(e))+"&level[0]=2&from="+t.config.id+"&count=1&version="+t.config.id+"(1.43.25)",addBean:!1,method:"get",type:R.SDK_ERROR,log:e})}],R.SDK_ERROR)(e)},e.prototype.sendPipeline=function(e,t){var n,r=this;return W(h([(n=this,function(e,t){if("number"!=typeof n.config.random&&(console.warn("random must in [0, 1], default is 1."),n.config.random=1),!n.isHidden||!n.isGetSample)if(n.isGetSample)!n.isHidden&&t(e);else{if(n.isGetSample=!0,Math.random()<n.config.random)return n.isHidden=!1,t(e);n.isHidden=!0}}),M(this,t)],e,[H(this),function(e,t){r.request(e,(function(){for(var n,o=[],i=0;i<arguments.length;i++)o[i]=arguments[i];r.failRequestCount=0;var s=!1,l=o[0];(""+l).indexOf("403 forbidden")>-1&&(s=!0,r.destroy()),t({isErr:s,result:o,logType:null==e?void 0:e.type,logs:null==e?void 0:e.log}),null===(n=null==e?void 0:e.success)||void 0===n||n.call.apply(n,h([e],o))}),(function(){for(var n,o=[],i=0;i<arguments.length;i++)o[i]=arguments[i];++r.failRequestCount>=60&&r.destroy();var s=o[0];(""+s).indexOf("403 forbidden")>-1&&r.destroy(),t({isErr:!0,result:o,logType:null==e?void 0:e.type,logs:null==e?void 0:e.log}),null===(n=null==e?void 0:e.fail)||void 0===n||n.call.apply(n,h([e],o))}))},F(this)]))},e.prototype.info=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n={level:y.INFO,msg:e};1===e.length&&e[0].msg&&Object.assign(n,u({},e[0]),{level:y.INFO}),this.normalLogPipeline(n)},e.prototype.infoAll=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n={level:y.INFO_ALL,msg:e};1===e.length&&e[0].msg&&Object.assign(n,u({},e[0]),{level:y.INFO_ALL}),this.normalLogPipeline(n)},e.prototype.report=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n={level:y.REPORT,msg:e};1===e.length&&e[0].msg&&Object.assign(n,u({},e[0])),this.normalLogPipeline(n)},e.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n={level:y.ERROR,msg:e};1===e.length&&e[0].msg&&Object.assign(n,u({},e[0]),{level:y.ERROR}),this.normalLogPipeline(n)},e.prototype.reportEvent=function(e){if(e){var t="string"==typeof e?{name:e,ext1:this.config.ext1||"",ext2:this.config.ext2||"",ext3:this.config.ext3||""}:e;t.name?("string"!=typeof t.name&&(console.warn("reportEvent params name must be string"),t.name=String(t.name)),this.eventPipeline(t)):console.warn("reportEvent params error")}},e.prototype.reportT=function(e){var t=e.name,n=e.duration,r=e.ext1,o=void 0===r?"":r,i=e.ext2,s=void 0===i?"":i,l=e.ext3,c=void 0===l?"":l,a=e.from,u=void 0===a?"":a;if("string"==typeof t&&"number"==typeof n&&"string"==typeof o&&"string"==typeof s&&"string"==typeof c){if(!(n<0||n>2147483646))return this.submitCustomTime(t,n,o,s,c,u);console.warn("reportTime: duration must between 0 and 2147483646")}else console.warn("reportTime: params error")},e.prototype.reportTime=function(e,t){if("object"==typeof e)return this.reportT(e);"string"==typeof e?"number"==typeof t?t<0||t>2147483646?console.warn("reportTime: duration must between 0 and 2147483646"):(this.submitCustomTime(e,t),this.normalLogPipeline({level:y.SPEED_EVENT,msg:"key:"+e+"\n duration:"+t,errorMsg:""})):console.warn("reportTime: second param must be number"):console.warn("reportTime: first param must be a string")},e.prototype.time=function(e){"string"==typeof e?this.timeMap[e]?console.warn("Timer "+e+" already exists"):this.timeMap[e]=Date.now():console.warn("time: first param must be a string")},e.prototype.timeEnd=function(e){"string"==typeof e?this.timeMap[e]?(this.submitCustomTime(e,Date.now()-this.timeMap[e]),delete this.timeMap[e]):console.warn("Timer "+e+" does not exist"):console.warn("timeEnd: first param must be a string")},e.prototype.ready=function(e,t,n){throw new Error('You need to override "ready" method')},e.prototype.request=function(e,t,n){throw new Error('You need to override "request" method')},e.prototype.speedLogPipeline=function(e){throw new Error('You need to override "speedLogPipeline" method')},Object.defineProperty(e.prototype,"__version__",{get:function(){return"1.43.25"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"LogType",{get:function(){return y},enumerable:!1,configurable:!0}),e.prototype.reportPv=function(e){e&&console.warn("reportPv is deprecated, please use reportEvent")},e.prototype.submitCustomTime=function(e,t,n,r,o,i){this.customTimePipeline({name:e,duration:t,ext1:n||this.config.ext1,ext2:r||this.config.ext2,ext3:o||this.config.ext3,from:i||void 0})},e.version="1.43.25",e.instances=[],e.logType=y,e.environment=E,e.installedPlugins=[],e}();!function(e){e[e.IP=0]="IP",e[e.HOST=1]="HOST",e[e.L5=2]="L5",e[e.POLARIS=3]="POLARIS"}(V||(V={}));var z=function(){function e(e){this.selectorConf=e,this.defaultSpeedBaseUrl="rumt-zh.com/speed",this.defaultLogBaseurl="rumt-zh.com"}return e.prototype.replaceUrl=function(e,t,n){return e.replace(/(^http[s]?:\/\/)?/,"").replace(this.defaultSpeedBaseUrl,t).replace(this.defaultLogBaseurl,n)},e}(),Y=function(e){function t(t){var n=e.call(this,t)||this;if("host"===n.selectorConf.type)n.selectorConf.logBaseUrl=n.selectorConf.logBaseUrl||n.defaultLogBaseurl,n.selectorConf.speedBaseUrl=n.selectorConf.speedBaseUrl||n.defaultSpeedBaseUrl;else if(!("ip"!==n.selectorConf.type||n.selectorConf.logBaseUrl&&n.selectorConf.speedBaseUrl))throw new Error("logBaseUrl or speedBaseUrl required");return n}return a(t,e),t.prototype.select=function(e){var t=null;"host"===this.selectorConf.type?t=V.HOST:"ip"===this.selectorConf.type&&(t=V.IP);var n=this.replaceUrl(e,this.selectorConf.speedBaseUrl,this.selectorConf.logBaseUrl);return Promise.resolve([{type:t,url:n,ctx:null},null])},t.prototype.update=function(){},t}(z),Q=require("@tencent/polaris").Consumer,X=function(e){function t(t){var n=e.call(this,t)||this;n.namespace="Production";var r="polaris://"+(n.selectorConf.logBaseUrl||"tam_log_svr?ns=Production"),o="polaris://"+(n.selectorConf.speedBaseUrl||"tam_speed_svr?ns=Production");return n.logPolarisInfo=n.parseUrlToPolarisInfo(r),n.speedPolarisInfo=n.parseUrlToPolarisInfo(o),n}return a(t,e),t.prototype.select=function(e){return f(this,void 0,void 0,(function(){var n,r,o,i,s,l,c,a;return p(this,(function(u){switch(u.label){case 0:n=e.indexOf(this.defaultSpeedBaseUrl)>-1?this.speedPolarisInfo:this.logPolarisInfo,u.label=1;case 1:return u.trys.push([1,3,,4]),[4,t.consumer.select(n.namespace,n.service)];case 2:return r=u.sent(),[3,4];case 3:return o=u.sent(),[2,[null,new Error("polaris exception with "+o.message)]];case 4:return r?(i=r.instance,s=i.host,l=i.port,c=s+":"+l,a="http://"+(a=this.replaceUrl(e,c+"/speed",c)),[2,[{type:V.POLARIS,url:a,ctx:r},null]]):[2,[null,new Error("polaris select no response")]]}}))}))},t.prototype.update=function(e,t){e&&"function"==typeof e.update&&e.update(t.success,t.cost,"number"==typeof t.code?t.code.toString():void 0)},t.prototype.parseUrlToPolarisInfo=function(e){var t=i.parse(e),n=t.host;return{namespace:s.parse(t.query||"").ns||"",service:n}},t.consumer=new Q({},{logVerbosity:0}),t}(z),Z=function(e){this.keepalive=!1,this.selector=e.selector,this.protocol=e.protocol,this.keepalive=e.keepalive},$=require("agentkeepalive"),ee=function(e){function t(t){var n=e.call(this,t)||this;if(n.isHttps=!1,"https"===n.protocol&&(n.isHttps=!0),n.keepalive){var r={keepAlive:!0,keepAliveMsecs:2e3,freeSocketTimeout:5e3,maxSockets:20,maxFreeSockets:10};n.isHttps?n.agent=new $.HttpsAgent(r):n.agent=new $(r)}return n}return a(t,e),t.prototype.send=function(e,t){var n;return f(this,void 0,void 0,(function(){var r,o,i,s,c,a,u=this;return p(this,(function(f){switch(f.label){case 0:return r=e.url,[4,this.selector.select(r)];case 1:if(o=f.sent(),i=o[0],s=o[1])return console.error("[service selector err] "+s.message),[2];if(r=/^http[s]?:\/\//.test(i.url||"")?i.url:(this.isHttps?"https://":"http://")+i.url,!1!==e.addBean&&t.bean&&(r=r+(-1===r.indexOf("?")?"?":"&")+t.bean),"post"===(null===(n=e.method)||void 0===n?void 0:n.toLowerCase())&&"string"==typeof e.data)try{e.data=JSON.parse(e.data)}catch(e){}return c=Date.now(),a={url:r,method:"post",data:e.data,timeout:3e3},this.agent&&(this.isHttps?a.httpsAgent=this.agent:a.httpAgent=this.agent),l.default(a).then((function(e){var n,r={success:!0,code:0,cost:Date.now()-c};u.selector.update(i.ctx,r),null===(n=t.success)||void 0===n||n.call(t,JSON.stringify(e.data))})).catch((function(n){var o,s;if(console.error("[aegis server access err] url = "+r+"; message = "+(null==n?void 0:n.message)),(null===(o=null==n?void 0:n.request)||void 0===o?void 0:o.reusedSocket)&&"ECONNRESET"===n.code)return console.error("[aegis connection retry] reason: connection reset on reused socket"),void u.send(e,t);var l={success:!1,code:-1,cost:Date.now()-c};u.selector.update(i.ctx,l),null===(s=t.fail)||void 0===s||s.call(t,n)})),[2]}}))}))},t}(Z),te=function(e,t){var n,r=[],o=t||{},i=o.maxLength,s=o.batchNum;return function(o,l){if(r.push(o),i&&r.length>=i&&l(r.splice(0,r.length)),void 0===n){var c=function(){var o,i=null===(o=null==t?void 0:t.allowNextRound)||void 0===o?void 0:o.call(t);if(void 0===i&&(i=!0),!i)return clearTimeout(n),void(n=void 0);n=setTimeout((function(){var e=r.splice(0,s||10);e.length>0&&l(e),r.length>0?c():n=void 0}),(null==e?void 0:e.batchReportInterval)||1e3)};c()}}},ne={host:"ip_selector",ip:"ip_selector",polaris:"polaris_selector"},re={http:"protocol_http",https:"protocol_http"};return function(e){function t(n){var r=e.call(this,n)||this;r.reportSpeedLog=W([te(r.config,{batchNum:5,maxLength:50}),function(e,t){r.lifeCycle.emit("beforeReportSpeed",e);var n=r.config.beforeReportSpeed;if("function"==typeof n&&(e=e.filter((function(e){return!1!==n(e)}))),e.length)return t(e)},M(r,R.SPEED),function(e){var t={fetch:[]};e.forEach((function(e){return t.fetch.push(e)})),r.send({url:""+r.config.speedUrl,method:"post",data:"payload="+encodeURIComponent(JSON.stringify({duration:t}))})}]),r.config.repeat=0;try{r.init(n),r.bean.sessionId=t.sessionID,r.bean.from=n.pageUrl||"",r.initSelector(),r.initProtocol()}catch(e){console.warn(e),console.log("%cThe above error occurred in the process of initializing Aegis, which will affect your normal use of Aegis.\nIt is recommended that you contact us for feedback and thank you for your support.","color: red"),r.sendSDKError(e)}return r}return a(t,e),t.prototype.request=function(e,t,n){if(e&&"string"==typeof e.url&&this.bean.id)return"string"==typeof e.url?~e.url.indexOf("/whitelist")?null==t?void 0:t('{"retcode":0,"result":{"is_in_white_list":true}}'):void this.reqProtocol.send(e,{success:t,fail:n,bean:this.getBean}):void 0},t.prototype.setSessionID=function(e){this.extendBean("sessionId",e||"session-"+Date.now())},t.prototype.initSelector=function(){if(this.config.selector=this.config.selector||{type:"polaris"},!this.config.selector.type)throw new Error("selector type 不能为空");var e;switch(this.config.selector.type){case"host":case"ip":e=Y;break;case"polaris":e=X;break;default:throw new Error("selector 类型非法,可选值: "+Object.keys(ne).toString())}this.selector=new e(this.config.selector)},t.prototype.initProtocol=function(){var e,t;if(this.config.protocol||("host"===(null===(e=this.config.selector)||void 0===e?void 0:e.type)?this.config.protocol="https":this.config.protocol="http"),-1===Object.keys(re).indexOf(this.config.protocol))throw new Error("unknown protocol");switch(this.config.protocol){case"http":case"https":t=ee;break;default:throw new Error("selector 类型非法,可选值: "+Object.keys(re).toString())}this.reqProtocol=new t({selector:this.selector,protocol:this.config.protocol,keepalive:"boolean"==typeof this.config.keepalive&&this.config.keepalive})},Object.defineProperty(t.prototype,"getBean",{get:function(){var e=this;return Object.getOwnPropertyNames(this.bean||{}).map((function(t){return t+"="+e.bean[t]})).join("&")},enumerable:!1,configurable:!0}),t.sessionID="session-"+Date.now(),t}(K)}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("url"),require("querystring"),require("axios")):"function"==typeof define&&define.amd?define(["url","querystring","axios"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).Aegis=t(e.url,e.querystring,e.axios)}(this,(function(e,t,n){"use strict";function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function o(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var i=o(e),s=o(t),l=r(n),c=function(e,t){return(c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)};function a(e,t){function n(){this.constructor=e}c(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var u=function(){return(u=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function f(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function l(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,l)}c((r=r.apply(e,t||[])).next())}))}function p(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(i){return function(l){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,l])}}}function h(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),o=0;for(t=0;t<n;t++)for(var i=arguments[t],s=0,l=i.length;s<l;s++,o++)r[o]=i[s];return r}Object.assign||Object.defineProperty(Object,"assign",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(null==e)throw new TypeError("Cannot convert first argument to object");for(var t=Object(e),n=1;n<arguments.length;n++){var r=arguments[n];if(null!=r){r=Object(r);for(var o=Object.keys(Object(r)),i=0,s=o.length;i<s;i++){var l=o[i],c=Object.getOwnPropertyDescriptor(r,l);(null==c?void 0:c.enumerable)&&(t[l]=r[l])}}}return t}});var d,g=["ext1","ext2","ext3","level","trace","tag","seq","code"],v=function(){function e(){var e=this;this.emit=function(t,n){if(e){var r,o=e.eventsList[t];if(null==o?void 0:o.length){o=o.slice();for(var i=0;i<o.length;i++){r=o[i];try{var s=r.callback.apply(e,[n]);if(1===r.type&&e.remove(t,r.callback),!1===s)break}catch(e){throw e}}}return e}},this.eventsList={}}return e.prototype.indexOf=function(e,t){for(var n=0;n<e.length;n++)if(e[n].callback===t)return n;return-1},e.prototype.on=function(e,t,n){if(void 0===n&&(n=0),this){var r=this.eventsList[e];if(r||(this.eventsList[e]=[],r=this.eventsList[e]),-1===this.indexOf(r,t)){var o={name:e,type:n||0,callback:t};return r.push(o),this}return this}},e.prototype.one=function(e,t){this.on(e,t,1)},e.prototype.remove=function(e,t){if(this){var n=this.eventsList[e];if(!n)return null;if(!t){try{delete this.eventsList[e]}catch(e){}return null}if(n.length){var r=this.indexOf(n,t);n.splice(r,1)}return this}},e.prototype.clear=function(){this.eventsList={}},e}(),m=function(e){if(!e||0===e.length)return"{}";e=Array.isArray(e)?e:[e];var t=Object.keys(e[0]),n={};return t.forEach((function(t){n[t]=e.map((function(e){return e[t]}))})),n.count=e.length,S(n)};!function(e){e[e.number=-1]="number",e.string=""}(d||(d={}));var y,O,b,R,E,w=function(){var e=new WeakSet;return function(t,n){if(n instanceof Error)return"Error.message: "+n.message+" \n Error.stack: "+n.stack;if("object"==typeof n&&null!==n){if(e.has(n))return"[Circular "+(t||"root")+"]";e.add(n)}return n}},P=function(e){if("string"==typeof e)return e;try{return e instanceof Error?(JSON.stringify(e,w(),4)||"undefined").replace(/"/gim,""):JSON.stringify(e,w(),4)||"undefined"}catch(e){return"error happen when aegis stringify: \n "+e.message+" \n "+e.stack}},S=function(e){if("string"==typeof e)return e;try{return JSON.stringify(e,w())||"undefined"}catch(e){return"error happen when aegis stringify: \n "+e.message+" \n "+e.stack}};!function(e){e.INFO_ALL="-1",e.API_RESPONSE="1",e.INFO="2",e.ERROR="4",e.PROMISE_ERROR="8",e.AJAX_ERROR="16",e.SCRIPT_ERROR="32",e.IMAGE_ERROR="64",e.CSS_ERROR="128",e.CONSOLE_ERROR="256",e.MEDIA_ERROR="512",e.RET_ERROR="1024",e.PAGE_LOAD="1025",e.SLOW_PAGE_LOAD="1026",e.SLOW_NET_REQUEST="1027",e.ASSERT_REQUEST="1028",e.SLOW_ASSET_REQUEST="1029",e.CLICK_EVENT="1030",e.true="1031",e.REPORT="2048",e.PV="4096",e.EVENT="8192",e.SPEED_EVENT="8193",e.PAGE_NOT_FOUND_ERROR="16384",e.WEBSOCKET_ERROR="32768",e.BRIDGE_ERROR="65536",e.LAZY_LOAD_ERROR="131072"}(y||(y={})),function(e){e[e.android=1]="android",e[e.ios=2]="ios",e[e.windows=3]="windows",e[e.macos=4]="macos",e[e.linux=5]="linux",e[e.devtools=6]="devtools",e[e.other=100]="other"}(O||(O={})),function(e){e[e.unknown=100]="unknown",e[e.wifi=1]="wifi",e[e.net2g=2]="net2g",e[e.net3g=3]="net3g",e[e.net4g=4]="net4g",e[e.net5g=5]="net5g",e[e.net6g=6]="net6g"}(b||(b={})),function(e){e.LOG="log",e.SPEED="speed",e.PERFORMANCE="performance",e.OFFLINE="offline",e.WHITE_LIST="whiteList",e.VITALS="vitals",e.PV="pv",e.CUSTOM_PV="customPV",e.EVENT="event",e.CUSTOM="custom",e.SDK_ERROR="sdkError",e.SET_DATA="setData",e.LOAD_PACKAGE="loadPackage"}(R||(R={})),function(e){e.production="production",e.development="development",e.gray="gray",e.pre="pre",e.daily="daily",e.local="local",e.test="test",e.others="others"}(E||(E={}));var T=function(e,t){return function(n,r){var o=t.logCreated;if("function"==typeof o){var i=n.filter((function(e){return!1!==o(e)}));return e("beforeWrite",i),r(i)}return e("beforeWrite",n),r(n)}},_=function(e){return e.filter((function(t,n){return"static"!==t.type||!e.find((function(e,r){return t.url===e.url&&200===t.status&&r>n}))}))},x=function(e,t){var n,r=[],o=e.config;return e.lifeCycle.on("destroy",(function(){r.length=0})),function(i,s){if(Array.isArray(i)?r=r.concat(i):r.push(i),t&&r.length>=t||e.sendNow&&r.length>0)return r=_(r),s(r.splice(0,r.length)),void(n&&clearTimeout(n));n&&clearTimeout(n),n=setTimeout((function(){n=null,(r=_(r)).length>0&&s(r.splice(0,r.length))}),o.delay)}},U=function(e,t){return Array.isArray(e)?t(e.map((function(e){return function(e){return g.forEach((function(t){e[t]||delete e[t]})),e}(u(u({},e),{msg:"string"==typeof e.msg?e.msg:[].concat(e.msg).map(P).join(" ")}))}))):t([u(u({},e),{msg:"string"==typeof e.msg?e.msg:P(e.msg)})])},C=function(e){e.level===y.INFO_ALL&&(e.level=y.INFO)},L=function(e){var t,n=!1,r=!1,o=!1,i=[];return e.lifeCycle.on("onConfigChange",(function(){t&&clearTimeout(t),t=setTimeout((function(){if(!o&&e.config){o=!0;var t=e.config.whiteListUrl,s=void 0===t?"":t;s&&e.sendPipeline([function(t,o){o({url:s,type:R.WHITE_LIST,success:function(t){r=!0;try{var o=t.data?t.data:JSON.parse(t),s=o.retcode,l=o.result,c=void 0===l?{}:l;0===s&&(n=c.is_in_white_list,e.isWhiteList=n,c.rate>=0&&c.rate<=1&&(e.config.random=c.rate,e.isGetSample=!1)),e.isWhiteList&&i.length?D(e)(i.splice(0),(function(){})):!e.isWhiteList&&i.length&&(i.length=0);var a=e.config.onWhitelist;"function"==typeof a&&a(n)}catch(e){}},fail:function(){r=!0}})}],R.WHITE_LIST)(null),o=!1}}),e.config.uin?50:500)})),e.lifeCycle.on("destroy",(function(){i.length=0})),function(t,o){var s,l;if(n||(null===(l=null===(s=e.config)||void 0===s?void 0:s.api)||void 0===l?void 0:l.reportRequest))o(t.concat(i.splice(0)).map((function(e){return C(e),e})));else{var c=t.filter((function(e){return e.level!==y.INFO&&e.level!==y.API_RESPONSE?(C(e),!0):(r||(i.push(e),i.length>=200&&(i.length=200)),!1)}));c.length&&o(c)}}},I=function(e){return setTimeout((function(){var t=e.config,n=t.pvUrl,r=void 0===n?"":n,o=t.spa,i=["web-sdk","mp-sdk"].indexOf("node-sdk")>-1;r&&(i&&!o||!i)&&e.sendPipeline([function(e,t){t({url:r,type:R.PV})}],R.PV)(null)}),100),function(e,t){t(e)}},A={},k={},j=function(e){return function(t,n){var r="number"==typeof e.repeat?e.repeat:60;if(r<=0)return n(t);var o=(null==e?void 0:e.id)+"_error",i=k[o]||{};n(t.filter((function(e){if(e.level===y.ERROR||e.level===y.PROMISE_ERROR||e.level===y.AJAX_ERROR||e.level===y.SCRIPT_ERROR||e.level===y.IMAGE_ERROR||e.level===y.CSS_ERROR||e.level===y.MEDIA_ERROR||e.level===y.RET_ERROR||e.level===y.BRIDGE_ERROR||e.level===y.PAGE_NOT_FOUND_ERROR||e.level===y.WEBSOCKET_ERROR||e.level===y.LAZY_LOAD_ERROR){var t=e.msg.slice(0,200);if(i[t]>r)return A[o]||(A[n=o]||(A[n]=setTimeout((function(){k[n]={},A[n]=null}),6e4)),A[n]),!1;i[t]=1+~~i[t],k[o]=i}var n;return!0})))}},N=function(e){return(Array.isArray(e)?e:[e]).map((function(e){return Object.getOwnPropertyNames(e).reduce((function(t,n){return"ctx"!==n&&(t[n]=e[n]),t}),{level:y.INFO,msg:""})}))},D=function(e){return function(t){return e.sendPipeline([function(t,n){return n({url:e.config.url||"",data:m(N(t)),method:"post",contentType:"application/json",type:R.LOG,log:t,requestConfig:{timeout:5e3},success:function(){var r=e.config.onReport;"function"==typeof r&&t.forEach((function(e){r(e)})),"function"==typeof n&&n([])}})}],R.LOG)(t)}},B=function(e){return function(t){e.sendPipeline([function(t,n){var r=t.map((function(t){return{name:t.name,ext1:t.ext1||e.config.ext1||"",ext2:t.ext2||e.config.ext2||"",ext3:t.ext3||e.config.ext3||""}}));n({url:e.config.eventUrl+"?payload="+encodeURIComponent(JSON.stringify(r)),type:R.EVENT,log:t})}],R.EVENT)(t)}},q=function(e){return function(t){return e.sendPipeline([function(t,n){n({url:e.config.customTimeUrl+"?payload="+encodeURIComponent(JSON.stringify({custom:t})),type:R.CUSTOM,log:t})}],R.CUSTOM)(t)}},M=function(e,t){return function(n,r){var o=Array.isArray(n),i=o?n:[n];e.lifeCycle.emit("beforeRequest",n);var s=e.config.beforeRequest;"function"==typeof s&&(i=i.map((function(e){try{var n=s({logs:e,logType:t});return(null==n?void 0:n.logType)===t&&(null==n?void 0:n.logs)?n.logs:!1!==n&&e}catch(t){return e}})).filter((function(e){return!1!==e}))),i.length&&(i=function(e,t){if(!Array.isArray(e)||e.length<=1)return e;var n=[],r=[];return!(r="string"==typeof t?[t]:t)||r.length<=0||(r.forEach((function(t){e.forEach((function(e){(null==e?void 0:e[t])&&n.push(t)}))})),n.length>0&&(e=e.map((function(e){var t={};return n.forEach((function(e){t[e]=""})),u(u({},t),e)})))),e}(i,g),r(o?i:i[0]))}},H=function(e){return function(t,n){e.lifeCycle.emit("modifyRequest",t);var r=e.config.modifyRequest;if("function"==typeof r)try{var o=r(t);"object"==typeof o&&"url"in o&&(t=o)}catch(e){console.error(e)}n(t)}},F=function(e){return function(t,n){var r;null===(r=e.lifeCycle)||void 0===r||r.emit("afterRequest",t);var o=(e.config||{}).afterRequest;"function"==typeof o&&!1===o(t)||n(t)}};Array(32);var V,G=function(){},W=function(e){if(!e||!e.reduce||!e.length)throw new TypeError("createPipeline need at least one function param");return 1===e.length?function(t,n){e[0](t,n||G)}:e.reduce((function(e,t){return function(n,r){return void 0===r&&(r=G),e(n,(function(e){return null==t?void 0:t(e,r)}))}}))},J=function(e,t){Object.getOwnPropertyNames(e).forEach((function(n){"function"==typeof e[n]&&"constructor"!==n&&(t?t[n]="sendPipeline"===n?function(){return function(){}}:function(){}:e[n]=function(){})}))},K=function(){function e(t){var n,r=this;this.isGetSample=!1,this.isHidden=!1,this.config={version:0,delay:1e3,onError:!0,repeat:60,random:1,aid:!0,device:!0,pagePerformance:!0,webVitals:!0,speedSample:!0,onClose:!0,reportLoadPackageSpeed:!0,hostUrl:"https://rumt-zh.com",env:"production",url:"",offlineUrl:"",whiteListUrl:"",pvUrl:"",speedUrl:"",customTimeUrl:"",performanceUrl:"",performanceUrlForHippy:"",webVitalsUrl:"",eventUrl:"",setDataReportUrl:"",reportImmediately:!0},this.isWhiteList=!1,this.lifeCycle=new v,this.bean={},this.normalLogPipeline=W([x(this,5),U,(n=this,function(e,t){var r=n.config;t(e=e.map((function(e){var t,n=r.maxLength||102400;try{if(!e.msg||e.msg.length<=n)return e;e.msg=null===(t=e.msg)||void 0===t?void 0:t.substring(0,n)}catch(t){e.msg=P(e.msg).substring(0,r.maxLength)}return e})))}),j(this.config),T(this.lifeCycle.emit,this.config),I(this),L(this),function(e,t){try{var n=JSON.parse(JSON.stringify(e));r.lifeCycle.emit("beforeReport",n);var o=r.config.beforeReport;"function"==typeof o&&(e=e.filter((function(e){return!1!==o(e)}))),e.length&&t(e)}catch(e){}},D(this)]),this.eventPipeline=W([x(this,10),B(this)]),this.customTimePipeline=W([x(this,10),q(this)]),this.timeMap={},this.failRequestCount=0,this.config=function(e,t){return void 0===t&&(t="https://rumt-zh.com"),"string"!=typeof t&&(t="https://rumt-zh.com"),e.url=e.url||t+"/collect",e.offlineUrl=e.offlineUrl||t+"/offline",e.whiteListUrl=e.whiteListUrl||t+"/collect/whitelist",e.pvUrl=e.pvUrl||t+"/collect/pv",e.eventUrl=e.eventUrl||t+"/collect/events",e.speedUrl=e.speedUrl||t+"/speed",e.customTimeUrl=e.customTimeUrl||t+"/speed/custom",e.performanceUrl=e.performanceUrl||t+"/speed/performance",e.performanceUrlForHippy=e.performanceUrlForHippy||t+"/speed/hippyPerformance",e.webVitalsUrl=e.webVitalsUrl||t+"/speed/webvitals",e.setDataReportUrl=e.SetDataReportUrl||t+"/speed/miniProgramData",e}(this.config,t.hostUrl),e.instances.push(this)}return e.use=function(t){-1===e.installedPlugins.indexOf(t)&&t.aegisPlugin&&e.installedPlugins.push(t)},e.unuse=function(t){var n=e.installedPlugins.indexOf(t);-1!==n&&e.installedPlugins.splice(n,1)},e.prototype.init=function(t){this.setConfig(t);for(var n=0;n<e.installedPlugins.length;n++)try{e.installedPlugins[n].patch(this)}catch(e){this.sendSDKError(e)}this.lifeCycle.emit("onInited")},e.prototype.destroy=function(t){void 0===t&&(t=!1);var n,r,o,i=e.instances.indexOf(this);-1!==i&&e.instances.splice(i,1);for(var s=e.installedPlugins.length-1;s>=0;s--)try{e.installedPlugins[s].unpatch(this)}catch(e){this.sendSDKError(e)}if(this.lifeCycle.emit("destroy"),this.lifeCycle.clear(),t)n=this,o=Object.getOwnPropertyDescriptors(n),Object.keys(o).forEach((function(e){o[e].writable&&(r?r[e]=null:n[e]=null)})),Object.setPrototypeOf(this,null);else{var l=this;do{l.constructor!==Object&&J(l,this)}while(l=Object.getPrototypeOf(l));if(0===e.instances.length){var c=Object.getPrototypeOf(this).constructor;J(c),J(e)}}},e.prototype.setConfig=function(e){Object.assign(this.config,e);var t=this.config,n=t.id,r=t.uin,o=t.version,i=t.ext1,s=t.ext2,l=t.ext3,c=t.aid,a=t.env,u=void 0===a?"production":a,f=t.pageUrl,p=this.bean.id!==n||this.bean.uin!==r||this.bean.aid!==c;return this.bean.id=n||"",this.bean.uin=r||"",this.bean.version=o||"1.43.25",this.bean.aid=c||"",this.bean.env=function(e){switch(e){case E.production:case E.development:case E.gray:case E.pre:case E.daily:case E.local:case E.test:case E.others:return!0;default:return!1}}(u)?u:E.others,f&&this.extendBean("from",encodeURIComponent(f.slice(0,2048))),i&&this.extendBean("ext1",encodeURIComponent(i)),s&&this.extendBean("ext2",encodeURIComponent(s)),l&&this.extendBean("ext3",encodeURIComponent(l)),p&&this.lifeCycle.emit("onConfigChange",this.config),this.config},e.prototype.extendBean=function(e,t){this.bean[e]=t},e.prototype.send=function(e,t,n){var r=this;return W([H(this),function(e,o){r.request(e,(function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];o({isErr:!1,result:n,logType:e.type,logs:e.log}),null==t||t.apply(void 0,n)}),(function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];o({isErr:!0,result:t,logType:e.type,logs:e.log}),null==n||n.apply(void 0,t)}))},F(this)])(e)},e.prototype.sendSDKError=function(e){var t=this;this.sendPipeline([function(e,n){n({url:t.config.url+"?id=1085&msg[0]="+encodeURIComponent(P(e))+"&level[0]=2&from="+t.config.id+"&count=1&version="+t.config.id+"(1.43.25)",addBean:!1,method:"get",type:R.SDK_ERROR,log:e})}],R.SDK_ERROR)(e)},e.prototype.sendPipeline=function(e,t){var n,r=this;return W(h([(n=this,function(e,t){if("number"!=typeof n.config.random&&(console.warn("random must in [0, 1], default is 1."),n.config.random=1),!n.isHidden||!n.isGetSample)if(n.isGetSample)!n.isHidden&&t(e);else{if(n.isGetSample=!0,Math.random()<n.config.random)return n.isHidden=!1,t(e);n.isHidden=!0}}),M(this,t)],e,[H(this),function(e,t){r.request(e,(function(){for(var n,o=[],i=0;i<arguments.length;i++)o[i]=arguments[i];r.failRequestCount=0;var s=!1,l=o[0];(""+l).indexOf("403 forbidden")>-1&&(s=!0,r.destroy()),t({isErr:s,result:o,logType:null==e?void 0:e.type,logs:null==e?void 0:e.log}),null===(n=null==e?void 0:e.success)||void 0===n||n.call.apply(n,h([e],o))}),(function(){for(var n,o=[],i=0;i<arguments.length;i++)o[i]=arguments[i];++r.failRequestCount>=60&&r.destroy();var s=o[0];(""+s).indexOf("403 forbidden")>-1&&r.destroy(),t({isErr:!0,result:o,logType:null==e?void 0:e.type,logs:null==e?void 0:e.log}),null===(n=null==e?void 0:e.fail)||void 0===n||n.call.apply(n,h([e],o))}))},F(this)]))},e.prototype.info=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n={level:y.INFO,msg:e};1===e.length&&e[0].msg&&Object.assign(n,u({},e[0]),{level:y.INFO}),this.normalLogPipeline(n)},e.prototype.infoAll=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n={level:y.INFO_ALL,msg:e};1===e.length&&e[0].msg&&Object.assign(n,u({},e[0]),{level:y.INFO_ALL}),this.normalLogPipeline(n)},e.prototype.report=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n={level:y.REPORT,msg:e};1===e.length&&e[0].msg&&Object.assign(n,u({},e[0])),this.normalLogPipeline(n)},e.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n={level:y.ERROR,msg:e};1===e.length&&e[0].msg&&Object.assign(n,u({},e[0]),{level:y.ERROR}),this.normalLogPipeline(n)},e.prototype.reportEvent=function(e){if(e){var t="string"==typeof e?{name:e,ext1:this.config.ext1||"",ext2:this.config.ext2||"",ext3:this.config.ext3||""}:e;t.name?("string"!=typeof t.name&&(console.warn("reportEvent params name must be string"),t.name=String(t.name)),this.eventPipeline(t)):console.warn("reportEvent params error")}},e.prototype.reportT=function(e){var t=e.name,n=e.duration,r=e.ext1,o=void 0===r?"":r,i=e.ext2,s=void 0===i?"":i,l=e.ext3,c=void 0===l?"":l,a=e.from,u=void 0===a?"":a;if("string"==typeof t&&"number"==typeof n&&"string"==typeof o&&"string"==typeof s&&"string"==typeof c){if(!(n<0||n>2147483646))return this.submitCustomTime(t,n,o,s,c,u);console.warn("reportTime: duration must between 0 and 2147483646")}else console.warn("reportTime: params error")},e.prototype.reportTime=function(e,t){if("object"==typeof e)return this.reportT(e);"string"==typeof e?"number"==typeof t?t<0||t>2147483646?console.warn("reportTime: duration must between 0 and 2147483646"):(this.submitCustomTime(e,t),this.normalLogPipeline({level:y.SPEED_EVENT,msg:"key:"+e+"\n duration:"+t,errorMsg:""})):console.warn("reportTime: second param must be number"):console.warn("reportTime: first param must be a string")},e.prototype.time=function(e){"string"==typeof e?this.timeMap[e]?console.warn("Timer "+e+" already exists"):this.timeMap[e]=Date.now():console.warn("time: first param must be a string")},e.prototype.timeEnd=function(e){"string"==typeof e?this.timeMap[e]?(this.submitCustomTime(e,Date.now()-this.timeMap[e]),delete this.timeMap[e]):console.warn("Timer "+e+" does not exist"):console.warn("timeEnd: first param must be a string")},e.prototype.ready=function(e,t,n){throw new Error('You need to override "ready" method')},e.prototype.request=function(e,t,n){throw new Error('You need to override "request" method')},e.prototype.speedLogPipeline=function(e){throw new Error('You need to override "speedLogPipeline" method')},Object.defineProperty(e.prototype,"__version__",{get:function(){return"1.43.25"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"LogType",{get:function(){return y},enumerable:!1,configurable:!0}),e.prototype.reportPv=function(e){e&&console.warn("reportPv is deprecated, please use reportEvent")},e.prototype.submitCustomTime=function(e,t,n,r,o,i){this.customTimePipeline({name:e,duration:t,ext1:n||this.config.ext1,ext2:r||this.config.ext2,ext3:o||this.config.ext3,from:i||void 0})},e.version="1.43.25",e.instances=[],e.logType=y,e.environment=E,e.installedPlugins=[],e}();!function(e){e[e.IP=0]="IP",e[e.HOST=1]="HOST",e[e.L5=2]="L5",e[e.POLARIS=3]="POLARIS"}(V||(V={}));var z=function(){function e(e){this.selectorConf=e,this.defaultSpeedBaseUrl="rumt-zh.com/speed",this.defaultLogBaseurl="rumt-zh.com"}return e.prototype.replaceUrl=function(e,t,n){return e.replace(/(^http[s]?:\/\/)?/,"").replace(this.defaultSpeedBaseUrl,t).replace(this.defaultLogBaseurl,n)},e}(),Y=function(e){function t(t){var n=e.call(this,t)||this;if("host"===n.selectorConf.type)n.selectorConf.logBaseUrl=n.selectorConf.logBaseUrl||n.defaultLogBaseurl,n.selectorConf.speedBaseUrl=n.selectorConf.speedBaseUrl||n.defaultSpeedBaseUrl;else if(!("ip"!==n.selectorConf.type||n.selectorConf.logBaseUrl&&n.selectorConf.speedBaseUrl))throw new Error("logBaseUrl or speedBaseUrl required");return n}return a(t,e),t.prototype.select=function(e){var t=null;"host"===this.selectorConf.type?t=V.HOST:"ip"===this.selectorConf.type&&(t=V.IP);var n=this.replaceUrl(e,this.selectorConf.speedBaseUrl,this.selectorConf.logBaseUrl);return Promise.resolve([{type:t,url:n,ctx:null},null])},t.prototype.update=function(){},t}(z),Q=require("../../polaris/dist/index.js").Consumer,X=function(e){function t(t){var n=e.call(this,t)||this;n.namespace="Production";var r="polaris://"+(n.selectorConf.logBaseUrl||"tam_log_svr?ns=Production"),o="polaris://"+(n.selectorConf.speedBaseUrl||"tam_speed_svr?ns=Production");return n.logPolarisInfo=n.parseUrlToPolarisInfo(r),n.speedPolarisInfo=n.parseUrlToPolarisInfo(o),n}return a(t,e),t.prototype.select=function(e){return f(this,void 0,void 0,(function(){var n,r,o,i,s,l,c,a;return p(this,(function(u){switch(u.label){case 0:n=e.indexOf(this.defaultSpeedBaseUrl)>-1?this.speedPolarisInfo:this.logPolarisInfo,u.label=1;case 1:return u.trys.push([1,3,,4]),[4,t.consumer.select(n.namespace,n.service)];case 2:return r=u.sent(),[3,4];case 3:return o=u.sent(),[2,[null,new Error("polaris exception with "+o.message)]];case 4:return r?(i=r.instance,s=i.host,l=i.port,c=s+":"+l,a="http://"+(a=this.replaceUrl(e,c+"/speed",c)),[2,[{type:V.POLARIS,url:a,ctx:r},null]]):[2,[null,new Error("polaris select no response")]]}}))}))},t.prototype.update=function(e,t){e&&"function"==typeof e.update&&e.update(t.success,t.cost,"number"==typeof t.code?t.code.toString():void 0)},t.prototype.parseUrlToPolarisInfo=function(e){var t=i.parse(e),n=t.host;return{namespace:s.parse(t.query||"").ns||"",service:n}},t.consumer=new Q({},{logVerbosity:0}),t}(z),Z=function(e){this.keepalive=!1,this.selector=e.selector,this.protocol=e.protocol,this.keepalive=e.keepalive},$=require("agentkeepalive"),ee=function(e){function t(t){var n=e.call(this,t)||this;if(n.isHttps=!1,"https"===n.protocol&&(n.isHttps=!0),n.keepalive){var r={keepAlive:!0,keepAliveMsecs:2e3,freeSocketTimeout:5e3,maxSockets:20,maxFreeSockets:10};n.isHttps?n.agent=new $.HttpsAgent(r):n.agent=new $(r)}return n}return a(t,e),t.prototype.send=function(e,t){var n;return f(this,void 0,void 0,(function(){var r,o,i,s,c,a,u=this;return p(this,(function(f){switch(f.label){case 0:return r=e.url,[4,this.selector.select(r)];case 1:if(o=f.sent(),i=o[0],s=o[1])return console.error("[service selector err] "+s.message),[2];if(r=/^http[s]?:\/\//.test(i.url||"")?i.url:(this.isHttps?"https://":"http://")+i.url,!1!==e.addBean&&t.bean&&(r=r+(-1===r.indexOf("?")?"?":"&")+t.bean),"post"===(null===(n=e.method)||void 0===n?void 0:n.toLowerCase())&&"string"==typeof e.data)try{e.data=JSON.parse(e.data)}catch(e){}return c=Date.now(),a={url:r,method:"post",data:e.data,timeout:3e3},this.agent&&(this.isHttps?a.httpsAgent=this.agent:a.httpAgent=this.agent),l.default(a).then((function(e){var n,r={success:!0,code:0,cost:Date.now()-c};u.selector.update(i.ctx,r),null===(n=t.success)||void 0===n||n.call(t,JSON.stringify(e.data))})).catch((function(n){var o,s;if(console.error("[aegis server access err] url = "+r+"; message = "+(null==n?void 0:n.message)),(null===(o=null==n?void 0:n.request)||void 0===o?void 0:o.reusedSocket)&&"ECONNRESET"===n.code)return console.error("[aegis connection retry] reason: connection reset on reused socket"),void u.send(e,t);var l={success:!1,code:-1,cost:Date.now()-c};u.selector.update(i.ctx,l),null===(s=t.fail)||void 0===s||s.call(t,n)})),[2]}}))}))},t}(Z),te=function(e,t){var n,r=[],o=t||{},i=o.maxLength,s=o.batchNum;return function(o,l){if(r.push(o),i&&r.length>=i&&l(r.splice(0,r.length)),void 0===n){var c=function(){var o,i=null===(o=null==t?void 0:t.allowNextRound)||void 0===o?void 0:o.call(t);if(void 0===i&&(i=!0),!i)return clearTimeout(n),void(n=void 0);n=setTimeout((function(){var e=r.splice(0,s||10);e.length>0&&l(e),r.length>0?c():n=void 0}),(null==e?void 0:e.batchReportInterval)||1e3)};c()}}},ne={host:"ip_selector",ip:"ip_selector",polaris:"polaris_selector"},re={http:"protocol_http",https:"protocol_http"};return function(e){function t(n){var r=e.call(this,n)||this;r.reportSpeedLog=W([te(r.config,{batchNum:5,maxLength:50}),function(e,t){r.lifeCycle.emit("beforeReportSpeed",e);var n=r.config.beforeReportSpeed;if("function"==typeof n&&(e=e.filter((function(e){return!1!==n(e)}))),e.length)return t(e)},M(r,R.SPEED),function(e){var t={fetch:[]};e.forEach((function(e){return t.fetch.push(e)})),r.send({url:""+r.config.speedUrl,method:"post",data:"payload="+encodeURIComponent(JSON.stringify({duration:t}))})}]),r.config.repeat=0;try{r.init(n),r.bean.sessionId=t.sessionID,r.bean.from=n.pageUrl||"",r.initSelector(),r.initProtocol()}catch(e){console.warn(e),console.log("%cThe above error occurred in the process of initializing Aegis, which will affect your normal use of Aegis.\nIt is recommended that you contact us for feedback and thank you for your support.","color: red"),r.sendSDKError(e)}return r}return a(t,e),t.prototype.request=function(e,t,n){if(e&&"string"==typeof e.url&&this.bean.id)return"string"==typeof e.url?~e.url.indexOf("/whitelist")?null==t?void 0:t('{"retcode":0,"result":{"is_in_white_list":true}}'):void this.reqProtocol.send(e,{success:t,fail:n,bean:this.getBean}):void 0},t.prototype.setSessionID=function(e){this.extendBean("sessionId",e||"session-"+Date.now())},t.prototype.initSelector=function(){if(this.config.selector=this.config.selector||{type:"polaris"},!this.config.selector.type)throw new Error("selector type 不能为空");var e;switch(this.config.selector.type){case"host":case"ip":e=Y;break;case"polaris":e=X;break;default:throw new Error("selector 类型非法,可选值: "+Object.keys(ne).toString())}this.selector=new e(this.config.selector)},t.prototype.initProtocol=function(){var e,t;if(this.config.protocol||("host"===(null===(e=this.config.selector)||void 0===e?void 0:e.type)?this.config.protocol="https":this.config.protocol="http"),-1===Object.keys(re).indexOf(this.config.protocol))throw new Error("unknown protocol");switch(this.config.protocol){case"http":case"https":t=ee;break;default:throw new Error("selector 类型非法,可选值: "+Object.keys(re).toString())}this.reqProtocol=new t({selector:this.selector,protocol:this.config.protocol,keepalive:"boolean"==typeof this.config.keepalive&&this.config.keepalive})},Object.defineProperty(t.prototype,"getBean",{get:function(){var e=this;return Object.getOwnPropertyNames(this.bean||{}).map((function(t){return t+"="+e.bean[t]})).join("&")},enumerable:!1,configurable:!0}),t.sessionID="session-"+Date.now(),t}(K)}));
|
package/README.md
CHANGED
|
@@ -27,24 +27,23 @@ This improves the LLM AI Agent's ability to understand and interact with Tencent
|
|
|
27
27
|
## How To Use
|
|
28
28
|
To set up the @tencentcloud/sdk-mcp MCP Server, follow these steps:
|
|
29
29
|
|
|
30
|
-
- Step1:
|
|
30
|
+
- Step1: Installation.
|
|
31
31
|
|
|
32
32
|
```
|
|
33
|
-
|
|
33
|
+
npx -y @tencentcloud/sdk-mcp
|
|
34
34
|
```
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
- Step2: In your Cursor project, create or open the `.cursor/mcp.json` or `~/.cursor/mcp.json` files and add your config.
|
|
38
38
|
|
|
39
|
-
```
|
|
39
|
+
```javascript
|
|
40
40
|
{
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"args": ["./node_modules/@tencentcloud/sdk-mcp/index.js"]
|
|
41
|
+
"mcpServers": {
|
|
42
|
+
"tencentcloud-sdk-mcp": {
|
|
43
|
+
"command": "npx",
|
|
44
|
+
"args": ["-y", "rg-mcp"]
|
|
46
45
|
}
|
|
47
|
-
|
|
46
|
+
}
|
|
48
47
|
}
|
|
49
48
|
```
|
|
50
49
|
When you save the file, a notification is displayed. In the prompt, click **Enable**.
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tencentcloud/sdk-mcp",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Tencent Cloud MCP Server for SDK",
|
|
5
5
|
"main": "index.js",
|
|
6
|
+
"bin": "index.js",
|
|
6
7
|
"repository": {
|
|
7
8
|
"type": "git",
|
|
8
9
|
"url": "xx"
|
|
@@ -14,7 +15,17 @@
|
|
|
14
15
|
"express": "^5.1.0",
|
|
15
16
|
"shx": "^0.3.4",
|
|
16
17
|
"typescript": "^5.8.2",
|
|
17
|
-
"zod": "^3.24.2"
|
|
18
|
+
"zod": "^3.24.2",
|
|
19
|
+
"agentkeepalive": "^4.1.4",
|
|
20
|
+
"@grpc/grpc-js": "^1.5.1",
|
|
21
|
+
"@grpc/proto-loader": "^0.6.6",
|
|
22
|
+
"@types/hashring": "^3.2.1",
|
|
23
|
+
"axios": "^0.25.0",
|
|
24
|
+
"debug": "^4.3.1",
|
|
25
|
+
"hashring": "^3.2.0",
|
|
26
|
+
"protobufjs": "^6.11.2",
|
|
27
|
+
"semver": "^7.3.5",
|
|
28
|
+
"uuid": "^8.3.2"
|
|
18
29
|
},
|
|
19
30
|
"author": "Tencent Cloud Terminal R&D Center",
|
|
20
31
|
"keywords": [
|
package/server.js
CHANGED
|
@@ -9,7 +9,7 @@ const zod_1 = require("zod");
|
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
10
10
|
const fs_1 = require("fs");
|
|
11
11
|
// @ts-ignore
|
|
12
|
-
const aegis_min_js_1 = __importDefault(require("
|
|
12
|
+
const aegis_min_js_1 = __importDefault(require("./@tencent/aegis-node-sdk/lib/aegis.min.js"));
|
|
13
13
|
const aegis = new aegis_min_js_1.default({
|
|
14
14
|
id: 'iHWefAYqIWHIdEyFhR',
|
|
15
15
|
uin: '82382',
|
package/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";;;;;AAYA,oCAyFC;AArGD,oEAAoE;AACpE,6BAAwB;AACxB,gDAAwB;AACxB,2BAAoC;AAEpC,aAAa;AACb,
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"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"}
|