xmcp 0.7.1 → 0.8.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 +1 -484
- package/dist/cloudflare.js +3 -3
- package/dist/{compiler/config → config}/index.d.ts +1 -0
- package/dist/config.js +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +26 -26
- package/dist/runtime/adapter-express.js +17 -17
- package/dist/runtime/adapter-fastify.js +17 -17
- package/dist/runtime/adapter-nestjs.js +19 -19
- package/dist/runtime/adapter-nextjs.js +17 -17
- package/dist/runtime/http.js +25 -25
- package/dist/runtime/transports/http/base-streamable-http.d.ts +1 -1
- package/dist/runtime/transports/http/cors/defaults.d.ts +8 -0
- package/package.json +28 -11
- package/dist/detached-flush.js +0 -1
- /package/dist/{compiler/config → config}/schemas/bundler.d.ts +0 -0
- /package/dist/{compiler/config → config}/schemas/experimental/index.d.ts +0 -0
- /package/dist/{compiler/config → config}/schemas/index.d.ts +0 -0
- /package/dist/{compiler/config → config}/schemas/paths.d.ts +0 -0
- /package/dist/{compiler/config → config}/schemas/template.d.ts +0 -0
- /package/dist/{compiler/config → config}/schemas/transport/http.d.ts +0 -0
- /package/dist/{compiler/config → config}/schemas/transport/stdio.d.ts +0 -0
- /package/dist/{compiler/config → config}/schemas/typescript.d.ts +0 -0
- /package/dist/{compiler/config → config}/utils.d.ts +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TemplateConfig } from "@/
|
|
1
|
+
import type { TemplateConfig } from "@/config/schemas";
|
|
2
2
|
import { AuthInfo } from "@modelcontextprotocol/sdk/server/auth/types";
|
|
3
3
|
import { Transport } from "@modelcontextprotocol/sdk/shared/transport";
|
|
4
4
|
import { MessageExtraInfo } from "@modelcontextprotocol/sdk/types";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xmcp",
|
|
3
3
|
"description": "The MCP framework",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.8.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "xmcp",
|
|
7
7
|
"email": "support@xmcp.dev",
|
|
@@ -61,6 +61,12 @@
|
|
|
61
61
|
"require": "./dist/cloudflare.js",
|
|
62
62
|
"default": "./dist/cloudflare.js"
|
|
63
63
|
},
|
|
64
|
+
"./config": {
|
|
65
|
+
"types": "./dist/config/index.d.ts",
|
|
66
|
+
"import": "./dist/config.js",
|
|
67
|
+
"require": "./dist/config.js",
|
|
68
|
+
"default": "./dist/config.js"
|
|
69
|
+
},
|
|
64
70
|
"./package.json": "./package.json"
|
|
65
71
|
},
|
|
66
72
|
"typesVersions": {
|
|
@@ -73,22 +79,20 @@
|
|
|
73
79
|
],
|
|
74
80
|
"cloudflare": [
|
|
75
81
|
"dist/cloudflare.d.ts"
|
|
82
|
+
],
|
|
83
|
+
"config": [
|
|
84
|
+
"dist/config/index.d.ts"
|
|
76
85
|
]
|
|
77
86
|
}
|
|
78
87
|
},
|
|
79
88
|
"files": [
|
|
80
89
|
"dist"
|
|
81
90
|
],
|
|
82
|
-
"dependencies": {
|
|
83
|
-
"@modelcontextprotocol/sdk": "^1.26.0",
|
|
84
|
-
"@rspack/core": "^1.6.7",
|
|
85
|
-
"jose": "^6.1.3",
|
|
86
|
-
"postcss-loader": "^8.2.0",
|
|
87
|
-
"ts-checker-rspack-plugin": "^1.2.1",
|
|
88
|
-
"typescript": "^5.9.3"
|
|
89
|
-
},
|
|
91
|
+
"dependencies": {},
|
|
90
92
|
"devDependencies": {
|
|
91
93
|
"@nestjs/common": "^11.1.12",
|
|
94
|
+
"@modelcontextprotocol/sdk": "^1.26.0",
|
|
95
|
+
"@rspack/core": "^1.6.7",
|
|
92
96
|
"@types/async-retry": "^1.4.9",
|
|
93
97
|
"@types/content-type": "^1.1.9",
|
|
94
98
|
"@types/express": "^5.0.6",
|
|
@@ -114,18 +118,30 @@
|
|
|
114
118
|
"is-wsl": "^3.1.0",
|
|
115
119
|
"json5": "^2.2.3",
|
|
116
120
|
"jsonwebtoken": "^9.0.3",
|
|
121
|
+
"jose": "^6.1.3",
|
|
117
122
|
"memfs": "^4.51.1",
|
|
123
|
+
"postcss-loader": "^8.2.0",
|
|
118
124
|
"raw-body": "^3.0.2",
|
|
119
125
|
"reflect-metadata": "^0.2.2",
|
|
120
126
|
"rxjs": "^7.8.2",
|
|
121
|
-
"
|
|
127
|
+
"ts-checker-rspack-plugin": "^1.2.1",
|
|
128
|
+
"tsx": "^4.21.0",
|
|
129
|
+
"typescript": "^5.9.3"
|
|
122
130
|
},
|
|
123
131
|
"peerDependencies": {
|
|
132
|
+
"@modelcontextprotocol/sdk": "^1.26.0",
|
|
133
|
+
"jose": "^6.1.3",
|
|
124
134
|
"react": ">=19.0.0",
|
|
125
135
|
"react-dom": ">=19.0.0",
|
|
126
136
|
"zod": "^3.25.76 || ^4.0.0"
|
|
127
137
|
},
|
|
128
138
|
"peerDependenciesMeta": {
|
|
139
|
+
"@modelcontextprotocol/sdk": {
|
|
140
|
+
"optional": true
|
|
141
|
+
},
|
|
142
|
+
"jose": {
|
|
143
|
+
"optional": true
|
|
144
|
+
},
|
|
129
145
|
"react": {
|
|
130
146
|
"optional": true
|
|
131
147
|
},
|
|
@@ -137,7 +153,8 @@
|
|
|
137
153
|
"dev": "cross-env NODE_ENV=development tsx --watch --tsconfig ./bundler.tsconfig.json ./bundler/index.ts",
|
|
138
154
|
"build": "cross-env NODE_ENV=production tsx --tsconfig ./bundler.tsconfig.json ./bundler/index.ts",
|
|
139
155
|
"analyze": "cross-env GENERATE_STATS=true pnpm build && pnpm tsx scripts/analyze-rspack-stats.ts",
|
|
140
|
-
"
|
|
156
|
+
"bench": "tsx bench/run.mts",
|
|
157
|
+
"test:config": "pnpm --dir ../compiler test:config",
|
|
141
158
|
"test:adapters": "node --import tsx --test src/runtime/adapters/fastify/__tests__/*.test.ts"
|
|
142
159
|
}
|
|
143
160
|
}
|
package/dist/detached-flush.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
!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={3985(e,t,n){var r=n(9627);e.exports=function(e,t){return new Promise(function(n,o){var i,s=t||{};function a(e){o(e||Error("Aborted"))}function c(e,t){e.bail?a(e):i.retry(e)?s.onRetry&&s.onRetry(e,t):o(i.mainError())}"randomize"in s||(s.randomize=!0),(i=r.operation(s)).attempt(function(t){var r;try{r=e(a,t)}catch(e){c(e,t);return}Promise.resolve(r).then(n).catch(function(e){c(e,t)})})})}},9627(e,t,n){e.exports=n(853)},853(e,t,n){var r=n(6971);t.operation=function(e){return new r(t.timeouts(e),{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 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=Math.round((t.randomize?Math.random()+1:1)*Math.max(t.minTimeout,1)*Math.pow(t.factor,e));return Math.min(n,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 i=0;i<r.length;i++){var s=r[i],a=e[s];e[s]=(function(r){var o=t.operation(n),i=Array.prototype.slice.call(arguments,1),s=i.pop();i.push(function(e){o.retry(e)||(e&&(arguments[0]=o.mainError()),s.apply(this,arguments))}),o.attempt(function(){r.apply(e,i)})}).bind(e,a),e[s].options=n}}},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(Error("RetryOperation timeout occurred")),!1;this._errors.push(e);var n=this._timeouts.shift();if(void 0===n)if(!this._cachedTimeouts)return!1;else 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],i=o.message,s=(e[i]||0)+1;e[i]=s,s>=n&&(t=o,n=s)}return t}},3389(e,t,n){"use strict";let r=n(9858),o=process.env;function i(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){let n=(Array.isArray(e.env)?e.env:[e.env]).every(function(e){return i(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":if("env"in e.pr)if("any"in e.pr)return e.pr.any.some(function(t){return o[e.pr.env]===t});else return e.pr.env in o&&o[e.pr.env]!==e.pr.ne;if("any"in e.pr)return e.pr.any.some(function(e){return!!o[e]});return i(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))},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 i=t[r]={exports:{}};return e[r](i,i.exports,n),i.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";let e,t,r,o,i=require("fs"),s=require("path");var a=n.n(s);let c=require("crypto"),u=require("os");var l=n.n(u);let m=require("node:fs");function E(){return e??=function(){try{return m.statSync("/.dockerenv"),!0}catch{return!1}}()||function(){try{return m.readFileSync("/proc/self/cgroup","utf8").includes("docker")}catch{return!1}}()||function(){try{return m.readFileSync("/proc/self/mountinfo","utf8").includes("/docker/containers/")}catch{return!1}}()}var p=n(3389),_=n.n(p);let{isCI:f,name:h}=_();function I(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}let T="telemetry.enabled",y="telemetry.notifiedAt",R="telemetry.anonymousId",v="telemetry.salt";class d{isEnvTelemetryDisabled(){let e=this.XMCP_TELEMETRY_DISABLED;return"string"==typeof e&&"true"===e.toLowerCase()}ensureConfig(){try{let e=a().dirname(this.configPath);if((0,i.existsSync)(e)||(0,i.mkdirSync)(e,{recursive:!0}),(0,i.existsSync)(this.configPath)){let e=(0,i.readFileSync)(this.configPath,"utf-8");this.config=JSON.parse(e)}else this.config={}}catch(e){this.config={}}}get(e,t){if(!this.config)return t;let n=this.config[e];return void 0!==n?n:t}set(e,t){if(this.config){this.config[e]=t;try{(0,i.writeFileSync)(this.configPath,JSON.stringify(this.config,null,2),"utf-8")}catch(e){}}}notify(){this.isDisabled||!this.config||!this.get(y,"")&&(this.set(y,Date.now().toString()),f||(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();let e=this.get(R);if(e)return e;let t=(0,c.randomBytes)(32).toString("hex");return this.set(R,t),t}get salt(){let e=this.get(v);if(e)return e;let t=(0,c.randomBytes)(16).toString("hex");return this.set(v,t),t}get isDisabled(){return!!(!this.config||this.isEnvTelemetryDisabled())||!1===this.get(T,!0)}get isEnabled(){return!this.isEnvTelemetryDisabled()&&!!this.config&&!1!==this.get(T,!0)}setEnabled(e){return this.set(T,!!e),this.configPath}oneWayHash(e){let t=(0,c.createHash)("sha256");return t.update(this.salt),t.update(e),t.digest("hex")}clear(){try{(0,i.existsSync)(this.configPath)&&(0,i.unlinkSync)(this.configPath)}catch(e){}}get configFilePath(){return this.configPath}constructor(){I(this,"configPath",void 0),I(this,"config",null),I(this,"XMCP_TELEMETRY_DISABLED",void 0),this.configPath=function(){if(f||E())return a().join(l().tmpdir(),".xmcp-cache","telemetry.json");let e=a().join(l().homedir(),"win32"===process.platform?"AppData/Local/xmcp":".config/xmcp");return a().join(e,"telemetry.json")}(),this.XMCP_TELEMETRY_DISABLED=process.env.XMCP_TELEMETRY_DISABLED,this.ensureConfig()}}let S=require("node:process"),C=require("node:os");function L(){return void 0===r&&(r=(()=>{try{return m.statSync("/run/.containerenv"),!0}catch{return!1}})()||(void 0===t&&(t=function(){try{return m.statSync("/.dockerenv"),!0}catch{return!1}}()||function(){try{return m.readFileSync("/proc/self/cgroup","utf8").includes("docker")}catch{return!1}}()),t)),r}let U=()=>{if("linux"!==S.platform)return!1;if(C.release().toLowerCase().includes("microsoft"))return!L();try{return!!m.readFileSync("/proc/version","utf8").toLowerCase().includes("microsoft")&&!L()}catch{return!1}},D=S.env.__IS_WSL_TEST__?U:U(),{isCI:g,name:A}=_();var P=n(3985),O=n.n(P);async function N(e,t){let n=t?.signal,r=t?.swallowErrors??!0;!n&&"timeout"in AbortSignal&&(n=AbortSignal.timeout(5e3));try{let t;if(t=process.env?.XMCP_DEBUG_TELEMETRY,"string"==typeof t&&"true"===t.toLowerCase())try{console.log("[telemetry] Sending payload",JSON.stringify(e,null,2))}catch(e){console.log("[telemetry] Sending payload (unable to stringify)")}await O()(async()=>{let t,r=await fetch("https://telemetry.xmcp.dev/api/telemetry/events",{method:"POST",body:JSON.stringify(e),headers:{"content-type":"application/json"},signal:n}),o=await r.text();try{t=JSON.parse(o)}catch(e){}if(!r.ok){let e=Error(`HTTP ${r.status}: ${r.statusText}`);throw e.response=r,e.responseData=t,e}},{minTimeout:500,retries:1,factor:1})}catch(e){if(!r)throw e}}async function B(){try{let e=a().join(process.cwd(),"package.json"),t=JSON.parse((0,i.readFileSync)(e,"utf-8"));return`${t.name||"unknown"}@${t.version||"0.0.0"}`}catch(e){return process.cwd()}}async function b(e){return e(await B())}!async function(){let[e,t]=process.argv.slice(2);e&&t||(console.error("Usage: detached-flush <mode> <distDir>"),process.exit(1));let n=a().join(t,"_events.json");if((0,i.existsSync)(n))try{var r,s;let e=(0,i.readFileSync)(n,"utf-8"),{sessionId:t,events:a}=JSON.parse(e);if(0===a.length)return;let c=new d;if(c.isDisabled){try{(0,i.unlinkSync)(n)}catch(e){}return}let u=await b(c.oneWayHash.bind(c)),m=function(){if(o)return o;let e=l().cpus()||[];return o={platform:l().platform(),systemRelease:l().release(),arch:l().arch(),cpuCores:e.length,cpuModel:e.length?e[0].model:null,cpuSpeed:e.length?e[0].speed:null,memoryTotal:Math.trunc(l().totalmem()/1048576),isDocker:E(),isWsl:D,isCI:g,ciName:g&&A||null}}(),p=(r={anonymousId:c.anonymousId,projectHash:u,sessionId:t},s=a.map(e=>({eventName:e.eventName,timestamp:e.timestamp??new Date().toISOString(),fields:e.fields})),{context:r,meta:m,events:s});await N(p,{swallowErrors:!1}),(0,i.unlinkSync)(n)}catch(e){}}()})(),{}})());
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|