mcp-use 1.2.1-canary.0 → 1.2.2-canary.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/.tsbuildinfo +1 -1
- package/dist/chunk-C3SRZK7H.js +1339 -0
- package/dist/{chunk-JV7HAYUT.js → chunk-CPV4QNHD.js} +126 -293
- package/dist/{chunk-ZUEQQ6YK.js → chunk-EYAIJPBH.js} +3 -235
- package/dist/{chunk-MGUO7HXB.js → chunk-UVUM35MV.js} +3 -957
- package/dist/chunk-VPPILX7B.js +239 -0
- package/dist/index.cjs +223 -303
- package/dist/index.js +11 -10
- package/dist/{langfuse-6AJGHMAV.js → langfuse-MO3AMDBE.js} +2 -1
- package/dist/src/agents/prompts/system_prompt_builder.d.ts.map +1 -1
- package/dist/src/browser.cjs +67 -20
- package/dist/src/browser.js +10 -45
- package/dist/src/client/browser.d.ts.map +1 -1
- package/dist/src/connectors/base.d.ts +46 -4
- package/dist/src/connectors/base.d.ts.map +1 -1
- package/dist/src/connectors/http.d.ts.map +1 -1
- package/dist/src/connectors/websocket.d.ts +2 -5
- package/dist/src/connectors/websocket.d.ts.map +1 -1
- package/dist/src/react/index.cjs +1394 -285
- package/dist/src/react/index.js +3 -2
- package/dist/src/react/types.d.ts +22 -0
- package/dist/src/react/types.d.ts.map +1 -1
- package/dist/src/react/useMcp.d.ts +31 -0
- package/dist/src/react/useMcp.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-62GFHYCL.js +0 -300
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__name
|
|
3
|
+
} from "./chunk-SHUYVCID.js";
|
|
4
|
+
|
|
5
|
+
// src/logging.ts
|
|
6
|
+
import { createLogger, format, transports } from "winston";
|
|
7
|
+
async function getNodeModules() {
|
|
8
|
+
if (typeof process !== "undefined" && process.platform) {
|
|
9
|
+
try {
|
|
10
|
+
const fs = await import("fs");
|
|
11
|
+
const path = await import("path");
|
|
12
|
+
return { fs: fs.default, path: path.default };
|
|
13
|
+
} catch {
|
|
14
|
+
return { fs: null, path: null };
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return { fs: null, path: null };
|
|
18
|
+
}
|
|
19
|
+
__name(getNodeModules, "getNodeModules");
|
|
20
|
+
var { combine, timestamp, label, printf, colorize, splat } = format;
|
|
21
|
+
var DEFAULT_LOGGER_NAME = "mcp-use";
|
|
22
|
+
function isNodeJSEnvironment() {
|
|
23
|
+
try {
|
|
24
|
+
if (typeof navigator !== "undefined" && navigator.userAgent?.includes("Cloudflare-Workers")) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
if (typeof globalThis.EdgeRuntime !== "undefined" || typeof globalThis.Deno !== "undefined") {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
const hasNodeGlobals = typeof process !== "undefined" && typeof process.platform !== "undefined" && typeof __dirname !== "undefined";
|
|
31
|
+
const hasNodeModules = typeof createLogger === "function";
|
|
32
|
+
return hasNodeGlobals && hasNodeModules;
|
|
33
|
+
} catch {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
__name(isNodeJSEnvironment, "isNodeJSEnvironment");
|
|
38
|
+
var SimpleConsoleLogger = class {
|
|
39
|
+
static {
|
|
40
|
+
__name(this, "SimpleConsoleLogger");
|
|
41
|
+
}
|
|
42
|
+
_level;
|
|
43
|
+
name;
|
|
44
|
+
constructor(name = DEFAULT_LOGGER_NAME, level = "info") {
|
|
45
|
+
this.name = name;
|
|
46
|
+
this._level = level;
|
|
47
|
+
}
|
|
48
|
+
shouldLog(level) {
|
|
49
|
+
const levels = ["error", "warn", "info", "http", "verbose", "debug", "silly"];
|
|
50
|
+
const currentIndex = levels.indexOf(this._level);
|
|
51
|
+
const messageIndex = levels.indexOf(level);
|
|
52
|
+
return messageIndex <= currentIndex;
|
|
53
|
+
}
|
|
54
|
+
formatMessage(level, message) {
|
|
55
|
+
const timestamp2 = (/* @__PURE__ */ new Date()).toLocaleTimeString("en-US", { hour12: false });
|
|
56
|
+
return `${timestamp2} [${this.name}] ${level}: ${message}`;
|
|
57
|
+
}
|
|
58
|
+
error(message) {
|
|
59
|
+
if (this.shouldLog("error")) {
|
|
60
|
+
console.error(this.formatMessage("error", message));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
warn(message) {
|
|
64
|
+
if (this.shouldLog("warn")) {
|
|
65
|
+
console.warn(this.formatMessage("warn", message));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
info(message) {
|
|
69
|
+
if (this.shouldLog("info")) {
|
|
70
|
+
console.info(this.formatMessage("info", message));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
debug(message) {
|
|
74
|
+
if (this.shouldLog("debug")) {
|
|
75
|
+
console.debug(this.formatMessage("debug", message));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
http(message) {
|
|
79
|
+
if (this.shouldLog("http")) {
|
|
80
|
+
console.log(this.formatMessage("http", message));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
verbose(message) {
|
|
84
|
+
if (this.shouldLog("verbose")) {
|
|
85
|
+
console.log(this.formatMessage("verbose", message));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
silly(message) {
|
|
89
|
+
if (this.shouldLog("silly")) {
|
|
90
|
+
console.log(this.formatMessage("silly", message));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
// Make it compatible with Winston interface
|
|
94
|
+
get level() {
|
|
95
|
+
return this._level;
|
|
96
|
+
}
|
|
97
|
+
set level(newLevel) {
|
|
98
|
+
this._level = newLevel;
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
function resolveLevel(env) {
|
|
102
|
+
const envValue = typeof process !== "undefined" && process.env ? env : void 0;
|
|
103
|
+
switch (envValue?.trim()) {
|
|
104
|
+
case "2":
|
|
105
|
+
return "debug";
|
|
106
|
+
case "1":
|
|
107
|
+
return "info";
|
|
108
|
+
default:
|
|
109
|
+
return "info";
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
__name(resolveLevel, "resolveLevel");
|
|
113
|
+
var minimalFormatter = printf(({ level, message, label: label2, timestamp: timestamp2 }) => {
|
|
114
|
+
return `${timestamp2} [${label2}] ${level}: ${message}`;
|
|
115
|
+
});
|
|
116
|
+
var detailedFormatter = printf(({ level, message, label: label2, timestamp: timestamp2 }) => {
|
|
117
|
+
return `${timestamp2} [${label2}] ${level.toUpperCase()}: ${message}`;
|
|
118
|
+
});
|
|
119
|
+
var emojiFormatter = printf(({ level, message, label: label2, timestamp: timestamp2 }) => {
|
|
120
|
+
return `${timestamp2} [${label2}] ${level.toUpperCase()}: ${message}`;
|
|
121
|
+
});
|
|
122
|
+
var Logger = class {
|
|
123
|
+
static {
|
|
124
|
+
__name(this, "Logger");
|
|
125
|
+
}
|
|
126
|
+
static instances = {};
|
|
127
|
+
static simpleInstances = {};
|
|
128
|
+
static currentFormat = "minimal";
|
|
129
|
+
static get(name = DEFAULT_LOGGER_NAME) {
|
|
130
|
+
if (!isNodeJSEnvironment()) {
|
|
131
|
+
if (!this.simpleInstances[name]) {
|
|
132
|
+
const debugEnv = typeof process !== "undefined" && process.env?.DEBUG || void 0;
|
|
133
|
+
this.simpleInstances[name] = new SimpleConsoleLogger(name, resolveLevel(debugEnv));
|
|
134
|
+
}
|
|
135
|
+
return this.simpleInstances[name];
|
|
136
|
+
}
|
|
137
|
+
if (!this.instances[name]) {
|
|
138
|
+
this.instances[name] = createLogger({
|
|
139
|
+
level: resolveLevel(process.env.DEBUG),
|
|
140
|
+
format: combine(
|
|
141
|
+
colorize(),
|
|
142
|
+
splat(),
|
|
143
|
+
label({ label: name }),
|
|
144
|
+
timestamp({ format: "HH:mm:ss" }),
|
|
145
|
+
this.getFormatter()
|
|
146
|
+
),
|
|
147
|
+
transports: []
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
return this.instances[name];
|
|
151
|
+
}
|
|
152
|
+
static getFormatter() {
|
|
153
|
+
switch (this.currentFormat) {
|
|
154
|
+
case "minimal":
|
|
155
|
+
return minimalFormatter;
|
|
156
|
+
case "detailed":
|
|
157
|
+
return detailedFormatter;
|
|
158
|
+
case "emoji":
|
|
159
|
+
return emojiFormatter;
|
|
160
|
+
default:
|
|
161
|
+
return minimalFormatter;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
static async configure(options = {}) {
|
|
165
|
+
const { level, console: console2 = true, file, format: format2 = "minimal" } = options;
|
|
166
|
+
const debugEnv = typeof process !== "undefined" && process.env?.DEBUG || void 0;
|
|
167
|
+
const resolvedLevel = level ?? resolveLevel(debugEnv);
|
|
168
|
+
this.currentFormat = format2;
|
|
169
|
+
const root = this.get();
|
|
170
|
+
root.level = resolvedLevel;
|
|
171
|
+
const winstonRoot = root;
|
|
172
|
+
if (!isNodeJSEnvironment()) {
|
|
173
|
+
Object.values(this.simpleInstances).forEach((logger2) => {
|
|
174
|
+
logger2.level = resolvedLevel;
|
|
175
|
+
});
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
winstonRoot.clear();
|
|
179
|
+
if (console2) {
|
|
180
|
+
winstonRoot.add(new transports.Console());
|
|
181
|
+
}
|
|
182
|
+
if (file) {
|
|
183
|
+
const { fs: nodeFs, path: nodePath } = await getNodeModules();
|
|
184
|
+
if (nodeFs && nodePath) {
|
|
185
|
+
const dir = nodePath.dirname(nodePath.resolve(file));
|
|
186
|
+
if (!nodeFs.existsSync(dir)) {
|
|
187
|
+
nodeFs.mkdirSync(dir, { recursive: true });
|
|
188
|
+
}
|
|
189
|
+
winstonRoot.add(new transports.File({ filename: file }));
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
Object.values(this.instances).forEach((logger2) => {
|
|
193
|
+
if (logger2 && "format" in logger2) {
|
|
194
|
+
logger2.level = resolvedLevel;
|
|
195
|
+
logger2.format = combine(
|
|
196
|
+
colorize(),
|
|
197
|
+
splat(),
|
|
198
|
+
label({ label: DEFAULT_LOGGER_NAME }),
|
|
199
|
+
timestamp({ format: "HH:mm:ss" }),
|
|
200
|
+
this.getFormatter()
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
static setDebug(enabled) {
|
|
206
|
+
let level;
|
|
207
|
+
if (enabled === 2 || enabled === true)
|
|
208
|
+
level = "debug";
|
|
209
|
+
else if (enabled === 1)
|
|
210
|
+
level = "info";
|
|
211
|
+
else level = "info";
|
|
212
|
+
Object.values(this.simpleInstances).forEach((logger2) => {
|
|
213
|
+
logger2.level = level;
|
|
214
|
+
});
|
|
215
|
+
Object.values(this.instances).forEach((logger2) => {
|
|
216
|
+
if (logger2) {
|
|
217
|
+
logger2.level = level;
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
if (typeof process !== "undefined" && process.env) {
|
|
221
|
+
process.env.DEBUG = enabled ? enabled === true ? "2" : String(enabled) : "0";
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
static setFormat(format2) {
|
|
225
|
+
this.currentFormat = format2;
|
|
226
|
+
this.configure({ format: format2 });
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
if (isNodeJSEnvironment()) {
|
|
230
|
+
Logger.configure();
|
|
231
|
+
} else {
|
|
232
|
+
Logger.configure({ console: true });
|
|
233
|
+
}
|
|
234
|
+
var logger = Logger.get();
|
|
235
|
+
|
|
236
|
+
export {
|
|
237
|
+
Logger,
|
|
238
|
+
logger
|
|
239
|
+
};
|