xmcp 0.4.0 → 0.4.1-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +2 -2
- package/dist/detached-flush.js +2 -0
- package/package.json +9 -2
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(this,()=>(()=>{var e={853:(e,t,n)=>{var r=n(6971);t.operation=function(e){var n=t.timeouts(e);return new r(n,{forever:e&&(e.forever||e.retries===1/0),unref:e&&e.unref,maxRetryTime:e&&e.maxRetryTime})},t.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1e3,maxTimeout:1/0,randomize:!1};for(var n in e)t[n]=e[n];if(t.minTimeout>t.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var r=[],o=0;o<t.retries;o++)r.push(this.createTimeout(o,t));return e&&e.forever&&!r.length&&r.push(this.createTimeout(o,t)),r.sort(function(e,t){return e-t}),r},t.createTimeout=function(e,t){var n=t.randomize?Math.random()+1:1,r=Math.round(n*Math.max(t.minTimeout,1)*Math.pow(t.factor,e));return Math.min(r,t.maxTimeout)},t.wrap=function(e,n,r){if(n instanceof Array&&(r=n,n=null),!r)for(var o in r=[],e)"function"==typeof e[o]&&r.push(o);for(var s=0;s<r.length;s++){var i=r[s],a=e[i];e[i]=function(r){var o=t.operation(n),s=Array.prototype.slice.call(arguments,1),i=s.pop();s.push(function(e){o.retry(e)||(e&&(arguments[0]=o.mainError()),i.apply(this,arguments))}),o.attempt(function(){r.apply(e,s)})}.bind(e,a),e[i].options=n}}},3389:(e,t,n)=>{"use strict";const r=n(9858),o=process.env;function s(e){return"string"==typeof e?!!o[e]:"env"in e?o[e.env]&&o[e.env].includes(e.includes):"any"in e?e.any.some(function(e){return!!o[e]}):Object.keys(e).every(function(t){return o[t]===e[t]})}Object.defineProperty(t,"_vendors",{value:r.map(function(e){return e.constant})}),t.name=null,t.isPR=null,t.id=null,"false"!==o.CI&&r.forEach(function(e){const n=(Array.isArray(e.env)?e.env:[e.env]).every(function(e){return s(e)});t[e.constant]=n,n&&(t.name=e.name,t.isPR=function(e){switch(typeof e.pr){case"string":return!!o[e.pr];case"object":return"env"in e.pr?"any"in e.pr?e.pr.any.some(function(t){return o[e.pr.env]===t}):e.pr.env in o&&o[e.pr.env]!==e.pr.ne:"any"in e.pr?e.pr.any.some(function(e){return!!o[e]}):s(e.pr);default:return null}}(e),t.id=e.constant)}),t.isCI=!("false"===o.CI||!(o.BUILD_ID||o.BUILD_NUMBER||o.CI||o.CI_APP_ID||o.CI_BUILD_ID||o.CI_BUILD_NUMBER||o.CI_NAME||o.CONTINUOUS_INTEGRATION||o.RUN_ID||t.name))},3985:(e,t,n)=>{var r=n(9627);e.exports=function(e,t){return new Promise(function(n,o){var s,i=t||{};function a(e){o(e||new Error("Aborted"))}function c(e,t){e.bail?a(e):s.retry(e)?i.onRetry&&i.onRetry(e,t):o(s.mainError())}"randomize"in i||(i.randomize=!0),(s=r.operation(i)).attempt(function(t){var r;try{r=e(a,t)}catch(e){return void c(e,t)}Promise.resolve(r).then(n).catch(function(e){c(e,t)})})})}},6971:e=>{function t(e,t){"boolean"==typeof t&&(t={forever:t}),this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._timer=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}e.exports=t,t.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts.slice(0)},t.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timer&&clearTimeout(this._timer),this._timeouts=[],this._cachedTimeouts=null},t.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var t=(new Date).getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.push(e),this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(e);var n=this._timeouts.shift();if(void 0===n){if(!this._cachedTimeouts)return!1;this._errors.splice(0,this._errors.length-1),n=this._cachedTimeouts.slice(-1)}var r=this;return this._timer=setTimeout(function(){r._attempts++,r._operationTimeoutCb&&(r._timeout=setTimeout(function(){r._operationTimeoutCb(r._attempts)},r._operationTimeout),r._options.unref&&r._timeout.unref()),r._fn(r._attempts)},n),this._options.unref&&this._timer.unref(),!0},t.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var n=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){n._operationTimeoutCb()},n._operationTimeout)),this._operationStart=(new Date).getTime(),this._fn(this._attempts)},t.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)},t.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)},t.prototype.start=t.prototype.try,t.prototype.errors=function(){return this._errors},t.prototype.attempts=function(){return this._attempts},t.prototype.mainError=function(){if(0===this._errors.length)return null;for(var e={},t=null,n=0,r=0;r<this._errors.length;r++){var o=this._errors[r],s=o.message,i=(e[s]||0)+1;e[s]=i,i>=n&&(t=o,n=i)}return t}},9627:(e,t,n)=>{e.exports=n(853)},9858:e=>{"use strict";e.exports=JSON.parse('[{"name":"Agola CI","constant":"AGOLA","env":"AGOLA_GIT_REF","pr":"AGOLA_PULL_REQUEST_ID"},{"name":"Appcircle","constant":"APPCIRCLE","env":"AC_APPCIRCLE","pr":{"env":"AC_GIT_PR","ne":"false"}},{"name":"AppVeyor","constant":"APPVEYOR","env":"APPVEYOR","pr":"APPVEYOR_PULL_REQUEST_NUMBER"},{"name":"AWS CodeBuild","constant":"CODEBUILD","env":"CODEBUILD_BUILD_ARN","pr":{"env":"CODEBUILD_WEBHOOK_EVENT","any":["PULL_REQUEST_CREATED","PULL_REQUEST_UPDATED","PULL_REQUEST_REOPENED"]}},{"name":"Azure Pipelines","constant":"AZURE_PIPELINES","env":"TF_BUILD","pr":{"BUILD_REASON":"PullRequest"}},{"name":"Bamboo","constant":"BAMBOO","env":"bamboo_planKey"},{"name":"Bitbucket Pipelines","constant":"BITBUCKET","env":"BITBUCKET_COMMIT","pr":"BITBUCKET_PR_ID"},{"name":"Bitrise","constant":"BITRISE","env":"BITRISE_IO","pr":"BITRISE_PULL_REQUEST"},{"name":"Buddy","constant":"BUDDY","env":"BUDDY_WORKSPACE_ID","pr":"BUDDY_EXECUTION_PULL_REQUEST_ID"},{"name":"Buildkite","constant":"BUILDKITE","env":"BUILDKITE","pr":{"env":"BUILDKITE_PULL_REQUEST","ne":"false"}},{"name":"CircleCI","constant":"CIRCLE","env":"CIRCLECI","pr":"CIRCLE_PULL_REQUEST"},{"name":"Cirrus CI","constant":"CIRRUS","env":"CIRRUS_CI","pr":"CIRRUS_PR"},{"name":"Cloudflare Pages","constant":"CLOUDFLARE_PAGES","env":"CF_PAGES"},{"name":"Cloudflare Workers","constant":"CLOUDFLARE_WORKERS","env":"WORKERS_CI"},{"name":"Codefresh","constant":"CODEFRESH","env":"CF_BUILD_ID","pr":{"any":["CF_PULL_REQUEST_NUMBER","CF_PULL_REQUEST_ID"]}},{"name":"Codemagic","constant":"CODEMAGIC","env":"CM_BUILD_ID","pr":"CM_PULL_REQUEST"},{"name":"Codeship","constant":"CODESHIP","env":{"CI_NAME":"codeship"}},{"name":"Drone","constant":"DRONE","env":"DRONE","pr":{"DRONE_BUILD_EVENT":"pull_request"}},{"name":"dsari","constant":"DSARI","env":"DSARI"},{"name":"Earthly","constant":"EARTHLY","env":"EARTHLY_CI"},{"name":"Expo Application Services","constant":"EAS","env":"EAS_BUILD"},{"name":"Gerrit","constant":"GERRIT","env":"GERRIT_PROJECT"},{"name":"Gitea Actions","constant":"GITEA_ACTIONS","env":"GITEA_ACTIONS"},{"name":"GitHub Actions","constant":"GITHUB_ACTIONS","env":"GITHUB_ACTIONS","pr":{"GITHUB_EVENT_NAME":"pull_request"}},{"name":"GitLab CI","constant":"GITLAB","env":"GITLAB_CI","pr":"CI_MERGE_REQUEST_ID"},{"name":"GoCD","constant":"GOCD","env":"GO_PIPELINE_LABEL"},{"name":"Google Cloud Build","constant":"GOOGLE_CLOUD_BUILD","env":"BUILDER_OUTPUT"},{"name":"Harness CI","constant":"HARNESS","env":"HARNESS_BUILD_ID"},{"name":"Heroku","constant":"HEROKU","env":{"env":"NODE","includes":"/app/.heroku/node/bin/node"}},{"name":"Hudson","constant":"HUDSON","env":"HUDSON_URL"},{"name":"Jenkins","constant":"JENKINS","env":["JENKINS_URL","BUILD_ID"],"pr":{"any":["ghprbPullId","CHANGE_ID"]}},{"name":"LayerCI","constant":"LAYERCI","env":"LAYERCI","pr":"LAYERCI_PULL_REQUEST"},{"name":"Magnum CI","constant":"MAGNUM","env":"MAGNUM"},{"name":"Netlify CI","constant":"NETLIFY","env":"NETLIFY","pr":{"env":"PULL_REQUEST","ne":"false"}},{"name":"Nevercode","constant":"NEVERCODE","env":"NEVERCODE","pr":{"env":"NEVERCODE_PULL_REQUEST","ne":"false"}},{"name":"Prow","constant":"PROW","env":"PROW_JOB_ID"},{"name":"ReleaseHub","constant":"RELEASEHUB","env":"RELEASE_BUILD_ID"},{"name":"Render","constant":"RENDER","env":"RENDER","pr":{"IS_PULL_REQUEST":"true"}},{"name":"Sail CI","constant":"SAIL","env":"SAILCI","pr":"SAIL_PULL_REQUEST_NUMBER"},{"name":"Screwdriver","constant":"SCREWDRIVER","env":"SCREWDRIVER","pr":{"env":"SD_PULL_REQUEST","ne":"false"}},{"name":"Semaphore","constant":"SEMAPHORE","env":"SEMAPHORE","pr":"PULL_REQUEST_NUMBER"},{"name":"Sourcehut","constant":"SOURCEHUT","env":{"CI_NAME":"sourcehut"}},{"name":"Strider CD","constant":"STRIDER","env":"STRIDER"},{"name":"TaskCluster","constant":"TASKCLUSTER","env":["TASK_ID","RUN_ID"]},{"name":"TeamCity","constant":"TEAMCITY","env":"TEAMCITY_VERSION"},{"name":"Travis CI","constant":"TRAVIS","env":"TRAVIS","pr":{"env":"TRAVIS_PULL_REQUEST","ne":"false"}},{"name":"Vela","constant":"VELA","env":"VELA","pr":{"VELA_PULL_REQUEST":"1"}},{"name":"Vercel","constant":"VERCEL","env":{"any":["NOW_BUILDER","VERCEL"]},"pr":"VERCEL_GIT_PULL_REQUEST_ID"},{"name":"Visual Studio App Center","constant":"APPCENTER","env":"APPCENTER_BUILD_ID"},{"name":"Woodpecker","constant":"WOODPECKER","env":{"CI":"woodpecker"},"pr":{"CI_BUILD_EVENT":"pull_request"}},{"name":"Xcode Cloud","constant":"XCODE_CLOUD","env":"CI_XCODE_PROJECT","pr":"CI_PULL_REQUEST_NUMBER"},{"name":"Xcode Server","constant":"XCODE_SERVER","env":"XCS"}]')}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var s=t[r]={exports:{}};return e[r](s,s.exports,n),s.exports}return n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";const e=require("fs"),t=require("path");var r=n.n(t);const o=require("crypto"),s=require("os");var i=n.n(s);const a=require("node:fs");let c;function u(){return c??=function(){try{return a.statSync("/.dockerenv"),!0}catch{return!1}}()||function(){try{return a.readFileSync("/proc/self/cgroup","utf8").includes("docker")}catch{return!1}}()||function(){try{return a.readFileSync("/proc/self/mountinfo","utf8").includes("/docker/containers/")}catch{return!1}}(),c}var l=n(3389),m=n.n(l);const{isCI:p,name:E}=m(),_=p;function f(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const h="telemetry.enabled",d="telemetry.notifiedAt",I="telemetry.anonymousId",y="telemetry.salt";class R{ensureConfig(){try{const t=r().dirname(this.configPath);if((0,e.existsSync)(t)||(0,e.mkdirSync)(t,{recursive:!0}),(0,e.existsSync)(this.configPath)){const t=(0,e.readFileSync)(this.configPath,"utf-8");this.config=JSON.parse(t)}else this.config={}}catch(e){this.config={}}}get(e,t){if(!this.config)return t;const n=this.config[e];return void 0!==n?n:t}set(t,n){if(this.config){this.config[t]=n;try{(0,e.writeFileSync)(this.configPath,JSON.stringify(this.config,null,2),"utf-8")}catch(e){}}}notify(){!this.isDisabled&&this.config&&(this.get(d,"")||(this.set(d,Date.now().toString()),_||(console.log(""),console.log("xmcp collects anonymous usage data to improve the framework."),console.log(" No personal information is collected."),console.log(" You can learn more and opt-out by visiting: https://xmcp.dev/telemetry"),console.log(" Or disable with: npx xmcp telemetry disable"),console.log(""))))}get anonymousId(){this.notify();const e=this.get(I);if(e)return e;const t=(0,o.randomBytes)(32).toString("hex");return this.set(I,t),t}get salt(){const e=this.get(y);if(e)return e;const t=(0,o.randomBytes)(16).toString("hex");return this.set(y,t),t}get isDisabled(){return!(!this.XMCP_TELEMETRY_DISABLED&&this.config)||!1===this.get(h,!0)}get isEnabled(){return!this.XMCP_TELEMETRY_DISABLED&&!!this.config&&!1!==this.get(h,!0)}setEnabled(e){return this.set(h,!!e),this.configPath}oneWayHash(e){const t=(0,o.createHash)("sha256");return t.update(this.salt),t.update(e),t.digest("hex")}clear(){try{(0,e.existsSync)(this.configPath)&&(0,e.unlinkSync)(this.configPath)}catch(e){}}get configFilePath(){return this.configPath}constructor(){f(this,"configPath",void 0),f(this,"config",null),f(this,"XMCP_TELEMETRY_DISABLED",void 0),this.configPath=function(){if(_||u())return r().join(i().tmpdir(),".xmcp-cache","telemetry.json");const e=r().join(i().homedir(),"win32"===process.platform?"AppData/Local/xmcp":".config/xmcp");return r().join(e,"telemetry.json")}(),this.XMCP_TELEMETRY_DISABLED=process.env.XMCP_TELEMETRY_DISABLED,this.ensureConfig()}}const T=require("node:process"),v=require("node:os");let S,C;function L(){return void 0===C&&(C=(()=>{try{return a.statSync("/run/.containerenv"),!0}catch{return!1}})()||(void 0===S&&(S=function(){try{return a.statSync("/.dockerenv"),!0}catch{return!1}}()||function(){try{return a.readFileSync("/proc/self/cgroup","utf8").includes("docker")}catch{return!1}}()),S)),C}const U=()=>{if("linux"!==T.platform)return!1;if(v.release().toLowerCase().includes("microsoft"))return!L();try{return!!a.readFileSync("/proc/version","utf8").toLowerCase().includes("microsoft")&&!L()}catch{return!1}},D=T.env.__IS_WSL_TEST__?U:U(),{isCI:g,name:A}=m();let P;var O=n(3985),N=n.n(O);(async function(){console.error("[detached-flush] Starting with args:",process.argv.slice(2));const[t,n]=process.argv.slice(2);t&&n||(console.error("Usage: detached-flush <mode> <distDir>"),process.exit(1));const s=r().join(n,"_events.json");if(console.error("[detached-flush] Looking for events file:",s),(0,e.existsSync)(s))try{const t=(0,e.readFileSync)(s,"utf-8"),n=JSON.parse(t);if(console.error("[detached-flush] Found",n.length,"events"),0===n.length)return;const a=new R;if(a.isDisabled)return void console.error("[detached-flush] Telemetry is disabled, skipping");const c=await async function(t){return t(await async function(){try{const t=r().join(process.cwd(),"package.json"),n=JSON.parse((0,e.readFileSync)(t,"utf-8"));return`${n.name||"unknown"}@${n.version||"0.0.0"}`}catch(e){return process.cwd()}}())}(a.oneWayHash.bind(a)),l=function(){if(P)return P;const e=i().cpus()||[];return P={systemPlatform:i().platform(),systemRelease:i().release(),systemArchitecture:i().arch(),cpuCount:e.length,cpuModel:e.length?e[0].model:null,cpuSpeed:e.length?e[0].speed:null,memoryInMb:Math.trunc(i().totalmem()/Math.pow(1024,2)),isDocker:u(),isWsl:D,isCI:g,ciName:g&&A||null},P}(),m=(0,o.randomBytes)(32).toString("hex"),p=function(e,t,n){return{context:e,meta:t,events:n}}({anonymousId:a.anonymousId,projectHash:c,sessionId:m},l,n.map(e=>({eventName:e.eventName,timestamp:(new Date).toISOString(),fields:e.fields})));console.error("[detached-flush] Sending payload:",JSON.stringify(p,null,2)),await function(e,t){return!t&&"timeout"in AbortSignal&&(t=AbortSignal.timeout(5e3)),console.error("[telemetry] Posting payload:",JSON.stringify(e,null,2)),N()(async()=>{const n=await fetch("https://xmcp-telemetry.vercel.app/api/telemetry/events",{method:"POST",body:JSON.stringify(e),headers:{"content-type":"application/json"},signal:t});console.error("[telemetry] Response status:",n.status),console.error("[telemetry] Response statusText:",n.statusText);const r=await n.text();let o;try{o=JSON.parse(r),console.error("[telemetry] Response body:",JSON.stringify(o,null,2))}catch(e){console.error("[telemetry] Response text:",r)}if(!n.ok){const e=new Error(`HTTP ${n.status}: ${n.statusText}`);throw e.response=n,e.responseData=o,console.error("[telemetry] Request failed:",e.message),e}console.error("[telemetry] Telemetry sent successfully")},{minTimeout:500,retries:1,factor:1}).catch(e=>{console.error("[telemetry] Final error after retries:",e)}).then(()=>{},()=>{})}(p),console.error("[detached-flush] Payload sent successfully"),(0,e.unlinkSync)(s),console.error("[detached-flush] Cleaned up events file")}catch(e){console.error("[detached-flush] Error:",e)}else console.error("[detached-flush] No events file found")})().catch(e=>{console.error("[detached-flush] Unhandled error:",e)})})(),{}})());
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xmcp",
|
|
3
3
|
"description": "The MCP framework",
|
|
4
|
-
"version": "0.4.0",
|
|
4
|
+
"version": "0.4.1-alpha.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "xmcp",
|
|
7
7
|
"email": "support@xmcp.dev",
|
|
@@ -42,15 +42,19 @@
|
|
|
42
42
|
],
|
|
43
43
|
"scripts": {
|
|
44
44
|
"dev": "cross-env NODE_ENV=development tsx --watch --tsconfig ./bundler.tsconfig.json ./bundler/index.ts",
|
|
45
|
-
"build": "cross-env NODE_ENV=production tsx --tsconfig ./bundler.tsconfig.json ./bundler/index.ts"
|
|
45
|
+
"build": "cross-env NODE_ENV=production tsx --tsconfig ./bundler.tsconfig.json ./bundler/index.ts",
|
|
46
|
+
"test:telemetry": "tsx src/telemetry/test-api.ts",
|
|
47
|
+
"test:telemetry:debug": "XMCP_TELEMETRY_DEBUG=1 tsx src/telemetry/test-api.ts"
|
|
46
48
|
},
|
|
47
49
|
"dependencies": {
|
|
48
50
|
"@modelcontextprotocol/sdk": "^1.17.4",
|
|
49
51
|
"@swc/core": "1.11.24",
|
|
50
52
|
"@types/express": "^5.0.1",
|
|
51
53
|
"@types/webpack-node-externals": "^3.0.4",
|
|
54
|
+
"async-retry": "^1.3.3",
|
|
52
55
|
"chalk": "^5.3.0",
|
|
53
56
|
"chokidar": "^3.6.0",
|
|
57
|
+
"ci-info": "^4.3.1",
|
|
54
58
|
"clean-webpack-plugin": "^4.0.0",
|
|
55
59
|
"commander": "^11.1.0",
|
|
56
60
|
"content-type": "^1.0.5",
|
|
@@ -61,6 +65,8 @@
|
|
|
61
65
|
"fork-ts-checker-webpack-plugin": "^8.0.0",
|
|
62
66
|
"fs-extra": "^11.3.0",
|
|
63
67
|
"glob": "^11.0.2",
|
|
68
|
+
"is-docker": "^4.0.0",
|
|
69
|
+
"is-wsl": "^3.1.0",
|
|
64
70
|
"json5": "^2.2.3",
|
|
65
71
|
"jsonwebtoken": "^9.0.2",
|
|
66
72
|
"memfs": "^4.17.2",
|
|
@@ -72,6 +78,7 @@
|
|
|
72
78
|
"webpack-virtual-modules": "^0.5.0"
|
|
73
79
|
},
|
|
74
80
|
"devDependencies": {
|
|
81
|
+
"@types/async-retry": "^1.4.9",
|
|
75
82
|
"@types/content-type": "^1.1.9",
|
|
76
83
|
"@types/fs-extra": "^11.0.4",
|
|
77
84
|
"@types/jsonwebtoken": "^9.0.9",
|