mcp-use 1.2.3-canary.0 → 1.2.3-canary.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/dist/.tsbuildinfo +1 -1
- package/dist/{chunk-3RJENWH4.js → chunk-34R6SIER.js} +62 -30
- package/dist/{chunk-RSGKBEHH.js → chunk-37MPZ3D6.js} +2 -2
- package/dist/chunk-3GQAWCBQ.js +13 -0
- package/dist/{chunk-UP63KLTQ.js → chunk-73SH52J2.js} +4 -4
- package/dist/{chunk-H3ACYEVW.js → chunk-EW4MJSHA.js} +1 -1
- package/dist/{chunk-KLIBVJ3Z.js → chunk-X2HJQBDI.js} +2 -2
- package/dist/{chunk-MZLETWQQ.js → chunk-YURRUCIM.js} +2 -2
- package/dist/index.cjs +61 -30
- package/dist/index.js +7 -7
- package/dist/{langfuse-LCJ6VJEP.js → langfuse-C4HKZ3NL.js} +3 -3
- package/dist/src/agents/index.cjs +61 -30
- package/dist/src/agents/index.js +4 -4
- package/dist/src/browser.cjs +61 -30
- package/dist/src/browser.js +6 -6
- package/dist/src/logging.d.ts.map +1 -1
- package/dist/src/react/index.cjs +60 -29
- package/dist/src/react/index.js +4 -4
- package/dist/src/server/index.js +1 -1
- package/package.json +3 -3
- package/dist/chunk-SHUYVCID.js +0 -6
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
-
__name
|
|
3
|
-
|
|
2
|
+
__name,
|
|
3
|
+
__require
|
|
4
|
+
} from "./chunk-3GQAWCBQ.js";
|
|
4
5
|
|
|
5
6
|
// src/logging.ts
|
|
6
|
-
import { createLogger, format, transports } from "winston";
|
|
7
7
|
async function getNodeModules() {
|
|
8
8
|
if (typeof process !== "undefined" && process.platform) {
|
|
9
9
|
try {
|
|
@@ -17,7 +17,23 @@ async function getNodeModules() {
|
|
|
17
17
|
return { fs: null, path: null };
|
|
18
18
|
}
|
|
19
19
|
__name(getNodeModules, "getNodeModules");
|
|
20
|
-
var
|
|
20
|
+
var winston = null;
|
|
21
|
+
function loadWinstonSync() {
|
|
22
|
+
if (typeof __require !== "undefined") {
|
|
23
|
+
try {
|
|
24
|
+
winston = __require("winston");
|
|
25
|
+
} catch {
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
__name(loadWinstonSync, "loadWinstonSync");
|
|
30
|
+
async function getWinston() {
|
|
31
|
+
if (!winston) {
|
|
32
|
+
winston = await import("winston");
|
|
33
|
+
}
|
|
34
|
+
return winston;
|
|
35
|
+
}
|
|
36
|
+
__name(getWinston, "getWinston");
|
|
21
37
|
var DEFAULT_LOGGER_NAME = "mcp-use";
|
|
22
38
|
function isNodeJSEnvironment() {
|
|
23
39
|
try {
|
|
@@ -28,8 +44,7 @@ function isNodeJSEnvironment() {
|
|
|
28
44
|
return false;
|
|
29
45
|
}
|
|
30
46
|
const hasNodeGlobals = typeof process !== "undefined" && typeof process.platform !== "undefined" && typeof __dirname !== "undefined";
|
|
31
|
-
|
|
32
|
-
return hasNodeGlobals && hasNodeModules;
|
|
47
|
+
return hasNodeGlobals;
|
|
33
48
|
} catch {
|
|
34
49
|
return false;
|
|
35
50
|
}
|
|
@@ -60,8 +75,8 @@ var SimpleConsoleLogger = class {
|
|
|
60
75
|
return messageIndex <= currentIndex;
|
|
61
76
|
}
|
|
62
77
|
formatMessage(level, message) {
|
|
63
|
-
const
|
|
64
|
-
return `${
|
|
78
|
+
const timestamp = (/* @__PURE__ */ new Date()).toLocaleTimeString("en-US", { hour12: false });
|
|
79
|
+
return `${timestamp} [${this.name}] ${level}: ${message}`;
|
|
65
80
|
}
|
|
66
81
|
error(message) {
|
|
67
82
|
if (this.shouldLog("error")) {
|
|
@@ -118,15 +133,6 @@ function resolveLevel(env) {
|
|
|
118
133
|
}
|
|
119
134
|
}
|
|
120
135
|
__name(resolveLevel, "resolveLevel");
|
|
121
|
-
var minimalFormatter = printf(({ level, message, label: label2, timestamp: timestamp2 }) => {
|
|
122
|
-
return `${timestamp2} [${label2}] ${level}: ${message}`;
|
|
123
|
-
});
|
|
124
|
-
var detailedFormatter = printf(({ level, message, label: label2, timestamp: timestamp2 }) => {
|
|
125
|
-
return `${timestamp2} [${label2}] ${level.toUpperCase()}: ${message}`;
|
|
126
|
-
});
|
|
127
|
-
var emojiFormatter = printf(({ level, message, label: label2, timestamp: timestamp2 }) => {
|
|
128
|
-
return `${timestamp2} [${label2}] ${level.toUpperCase()}: ${message}`;
|
|
129
|
-
});
|
|
130
136
|
var Logger = class {
|
|
131
137
|
static {
|
|
132
138
|
__name(this, "Logger");
|
|
@@ -146,6 +152,11 @@ var Logger = class {
|
|
|
146
152
|
return this.simpleInstances[name];
|
|
147
153
|
}
|
|
148
154
|
if (!this.instances[name]) {
|
|
155
|
+
if (!winston) {
|
|
156
|
+
throw new Error("Winston not loaded - call Logger.configure() first");
|
|
157
|
+
}
|
|
158
|
+
const { createLogger, format } = winston;
|
|
159
|
+
const { combine, timestamp, label, colorize, splat } = format;
|
|
149
160
|
this.instances[name] = createLogger({
|
|
150
161
|
level: resolveLevel(process.env.DEBUG),
|
|
151
162
|
format: combine(
|
|
@@ -161,6 +172,20 @@ var Logger = class {
|
|
|
161
172
|
return this.instances[name];
|
|
162
173
|
}
|
|
163
174
|
static getFormatter() {
|
|
175
|
+
if (!winston) {
|
|
176
|
+
throw new Error("Winston not loaded");
|
|
177
|
+
}
|
|
178
|
+
const { format } = winston;
|
|
179
|
+
const { printf } = format;
|
|
180
|
+
const minimalFormatter = printf(({ level, message, label, timestamp }) => {
|
|
181
|
+
return `${timestamp} [${label}] ${level}: ${message}`;
|
|
182
|
+
});
|
|
183
|
+
const detailedFormatter = printf(({ level, message, label, timestamp }) => {
|
|
184
|
+
return `${timestamp} [${label}] ${level.toUpperCase()}: ${message}`;
|
|
185
|
+
});
|
|
186
|
+
const emojiFormatter = printf(({ level, message, label, timestamp }) => {
|
|
187
|
+
return `${timestamp} [${label}] ${level.toUpperCase()}: ${message}`;
|
|
188
|
+
});
|
|
164
189
|
switch (this.currentFormat) {
|
|
165
190
|
case "minimal":
|
|
166
191
|
return minimalFormatter;
|
|
@@ -173,22 +198,26 @@ var Logger = class {
|
|
|
173
198
|
}
|
|
174
199
|
}
|
|
175
200
|
static async configure(options = {}) {
|
|
176
|
-
const { level, console: console2 = true, file, format
|
|
201
|
+
const { level, console: console2 = true, file, format = "minimal" } = options;
|
|
177
202
|
const debugEnv = typeof process !== "undefined" && process.env?.DEBUG || void 0;
|
|
178
203
|
const resolvedLevel = level ?? resolveLevel(debugEnv);
|
|
179
|
-
this.currentFormat =
|
|
180
|
-
const root = this.get();
|
|
181
|
-
root.level = resolvedLevel;
|
|
182
|
-
const winstonRoot = root;
|
|
204
|
+
this.currentFormat = format;
|
|
183
205
|
if (!isNodeJSEnvironment()) {
|
|
184
206
|
Object.values(this.simpleInstances).forEach((logger2) => {
|
|
185
207
|
logger2.level = resolvedLevel;
|
|
186
208
|
});
|
|
187
209
|
return;
|
|
188
210
|
}
|
|
211
|
+
await getWinston();
|
|
212
|
+
if (!winston) {
|
|
213
|
+
throw new Error("Failed to load winston");
|
|
214
|
+
}
|
|
215
|
+
const root = this.get();
|
|
216
|
+
root.level = resolvedLevel;
|
|
217
|
+
const winstonRoot = root;
|
|
189
218
|
winstonRoot.clear();
|
|
190
219
|
if (console2) {
|
|
191
|
-
winstonRoot.add(new transports.Console());
|
|
220
|
+
winstonRoot.add(new winston.transports.Console());
|
|
192
221
|
}
|
|
193
222
|
if (file) {
|
|
194
223
|
const { fs: nodeFs, path: nodePath } = await getNodeModules();
|
|
@@ -197,9 +226,11 @@ var Logger = class {
|
|
|
197
226
|
if (!nodeFs.existsSync(dir)) {
|
|
198
227
|
nodeFs.mkdirSync(dir, { recursive: true });
|
|
199
228
|
}
|
|
200
|
-
winstonRoot.add(new transports.File({ filename: file }));
|
|
229
|
+
winstonRoot.add(new winston.transports.File({ filename: file }));
|
|
201
230
|
}
|
|
202
231
|
}
|
|
232
|
+
const { format: winstonFormat } = winston;
|
|
233
|
+
const { combine, timestamp, label, colorize, splat } = winstonFormat;
|
|
203
234
|
Object.values(this.instances).forEach((logger2) => {
|
|
204
235
|
if (logger2 && "format" in logger2) {
|
|
205
236
|
logger2.level = resolvedLevel;
|
|
@@ -230,15 +261,16 @@ var Logger = class {
|
|
|
230
261
|
process.env.DEBUG = enabled ? enabled === true ? "2" : String(enabled) : "0";
|
|
231
262
|
}
|
|
232
263
|
}
|
|
233
|
-
static setFormat(
|
|
234
|
-
this.currentFormat =
|
|
235
|
-
this.configure({ format
|
|
264
|
+
static setFormat(format) {
|
|
265
|
+
this.currentFormat = format;
|
|
266
|
+
this.configure({ format });
|
|
236
267
|
}
|
|
237
268
|
};
|
|
238
269
|
if (isNodeJSEnvironment()) {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
270
|
+
loadWinstonSync();
|
|
271
|
+
if (winston) {
|
|
272
|
+
Logger.configure();
|
|
273
|
+
}
|
|
242
274
|
}
|
|
243
275
|
var logger = Logger.get();
|
|
244
276
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
4
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
5
|
+
}) : x)(function(x) {
|
|
6
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
7
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export {
|
|
11
|
+
__name,
|
|
12
|
+
__require
|
|
13
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
logger
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-34R6SIER.js";
|
|
4
4
|
import {
|
|
5
5
|
__name
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-3GQAWCBQ.js";
|
|
7
7
|
|
|
8
8
|
// src/adapters/base.ts
|
|
9
9
|
var BaseAdapter = class {
|
|
@@ -531,9 +531,9 @@ var ObservabilityManager = class {
|
|
|
531
531
|
return;
|
|
532
532
|
}
|
|
533
533
|
try {
|
|
534
|
-
const { langfuseHandler: langfuseHandler2, langfuseInitPromise: langfuseInitPromise2 } = await import("./langfuse-
|
|
534
|
+
const { langfuseHandler: langfuseHandler2, langfuseInitPromise: langfuseInitPromise2 } = await import("./langfuse-C4HKZ3NL.js");
|
|
535
535
|
if (this.agentId || this.metadata || this.metadataProvider || this.tagsProvider) {
|
|
536
|
-
const { initializeLangfuse } = await import("./langfuse-
|
|
536
|
+
const { initializeLangfuse } = await import("./langfuse-C4HKZ3NL.js");
|
|
537
537
|
await initializeLangfuse(
|
|
538
538
|
this.agentId,
|
|
539
539
|
this.metadata,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BrowserMCPClient,
|
|
3
3
|
BrowserOAuthClientProvider
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-37MPZ3D6.js";
|
|
5
5
|
import {
|
|
6
6
|
__name
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-3GQAWCBQ.js";
|
|
8
8
|
|
|
9
9
|
// src/react/useMcp.ts
|
|
10
10
|
import { useCallback, useEffect, useRef, useState } from "react";
|
package/dist/index.cjs
CHANGED
|
@@ -44,6 +44,20 @@ async function getNodeModules() {
|
|
|
44
44
|
}
|
|
45
45
|
return { fs: null, path: null };
|
|
46
46
|
}
|
|
47
|
+
function loadWinstonSync() {
|
|
48
|
+
if (typeof require !== "undefined") {
|
|
49
|
+
try {
|
|
50
|
+
winston = require("winston");
|
|
51
|
+
} catch {
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
async function getWinston() {
|
|
56
|
+
if (!winston) {
|
|
57
|
+
winston = await import("winston");
|
|
58
|
+
}
|
|
59
|
+
return winston;
|
|
60
|
+
}
|
|
47
61
|
function isNodeJSEnvironment() {
|
|
48
62
|
try {
|
|
49
63
|
if (typeof navigator !== "undefined" && navigator.userAgent?.includes("Cloudflare-Workers")) {
|
|
@@ -53,8 +67,7 @@ function isNodeJSEnvironment() {
|
|
|
53
67
|
return false;
|
|
54
68
|
}
|
|
55
69
|
const hasNodeGlobals = typeof process !== "undefined" && typeof process.platform !== "undefined" && typeof __dirname !== "undefined";
|
|
56
|
-
|
|
57
|
-
return hasNodeGlobals && hasNodeModules;
|
|
70
|
+
return hasNodeGlobals;
|
|
58
71
|
} catch {
|
|
59
72
|
return false;
|
|
60
73
|
}
|
|
@@ -70,13 +83,14 @@ function resolveLevel(env) {
|
|
|
70
83
|
return "info";
|
|
71
84
|
}
|
|
72
85
|
}
|
|
73
|
-
var
|
|
86
|
+
var winston, DEFAULT_LOGGER_NAME, SimpleConsoleLogger, Logger, logger;
|
|
74
87
|
var init_logging = __esm({
|
|
75
88
|
"src/logging.ts"() {
|
|
76
89
|
"use strict";
|
|
77
|
-
import_winston = require("winston");
|
|
78
90
|
__name(getNodeModules, "getNodeModules");
|
|
79
|
-
|
|
91
|
+
winston = null;
|
|
92
|
+
__name(loadWinstonSync, "loadWinstonSync");
|
|
93
|
+
__name(getWinston, "getWinston");
|
|
80
94
|
DEFAULT_LOGGER_NAME = "mcp-use";
|
|
81
95
|
__name(isNodeJSEnvironment, "isNodeJSEnvironment");
|
|
82
96
|
SimpleConsoleLogger = class {
|
|
@@ -104,8 +118,8 @@ var init_logging = __esm({
|
|
|
104
118
|
return messageIndex <= currentIndex;
|
|
105
119
|
}
|
|
106
120
|
formatMessage(level, message) {
|
|
107
|
-
const
|
|
108
|
-
return `${
|
|
121
|
+
const timestamp = (/* @__PURE__ */ new Date()).toLocaleTimeString("en-US", { hour12: false });
|
|
122
|
+
return `${timestamp} [${this.name}] ${level}: ${message}`;
|
|
109
123
|
}
|
|
110
124
|
error(message) {
|
|
111
125
|
if (this.shouldLog("error")) {
|
|
@@ -151,15 +165,6 @@ var init_logging = __esm({
|
|
|
151
165
|
}
|
|
152
166
|
};
|
|
153
167
|
__name(resolveLevel, "resolveLevel");
|
|
154
|
-
minimalFormatter = printf(({ level, message, label: label2, timestamp: timestamp2 }) => {
|
|
155
|
-
return `${timestamp2} [${label2}] ${level}: ${message}`;
|
|
156
|
-
});
|
|
157
|
-
detailedFormatter = printf(({ level, message, label: label2, timestamp: timestamp2 }) => {
|
|
158
|
-
return `${timestamp2} [${label2}] ${level.toUpperCase()}: ${message}`;
|
|
159
|
-
});
|
|
160
|
-
emojiFormatter = printf(({ level, message, label: label2, timestamp: timestamp2 }) => {
|
|
161
|
-
return `${timestamp2} [${label2}] ${level.toUpperCase()}: ${message}`;
|
|
162
|
-
});
|
|
163
168
|
Logger = class {
|
|
164
169
|
static {
|
|
165
170
|
__name(this, "Logger");
|
|
@@ -179,7 +184,12 @@ var init_logging = __esm({
|
|
|
179
184
|
return this.simpleInstances[name];
|
|
180
185
|
}
|
|
181
186
|
if (!this.instances[name]) {
|
|
182
|
-
|
|
187
|
+
if (!winston) {
|
|
188
|
+
throw new Error("Winston not loaded - call Logger.configure() first");
|
|
189
|
+
}
|
|
190
|
+
const { createLogger, format } = winston;
|
|
191
|
+
const { combine, timestamp, label, colorize, splat } = format;
|
|
192
|
+
this.instances[name] = createLogger({
|
|
183
193
|
level: resolveLevel(process.env.DEBUG),
|
|
184
194
|
format: combine(
|
|
185
195
|
colorize(),
|
|
@@ -194,6 +204,20 @@ var init_logging = __esm({
|
|
|
194
204
|
return this.instances[name];
|
|
195
205
|
}
|
|
196
206
|
static getFormatter() {
|
|
207
|
+
if (!winston) {
|
|
208
|
+
throw new Error("Winston not loaded");
|
|
209
|
+
}
|
|
210
|
+
const { format } = winston;
|
|
211
|
+
const { printf } = format;
|
|
212
|
+
const minimalFormatter = printf(({ level, message, label, timestamp }) => {
|
|
213
|
+
return `${timestamp} [${label}] ${level}: ${message}`;
|
|
214
|
+
});
|
|
215
|
+
const detailedFormatter = printf(({ level, message, label, timestamp }) => {
|
|
216
|
+
return `${timestamp} [${label}] ${level.toUpperCase()}: ${message}`;
|
|
217
|
+
});
|
|
218
|
+
const emojiFormatter = printf(({ level, message, label, timestamp }) => {
|
|
219
|
+
return `${timestamp} [${label}] ${level.toUpperCase()}: ${message}`;
|
|
220
|
+
});
|
|
197
221
|
switch (this.currentFormat) {
|
|
198
222
|
case "minimal":
|
|
199
223
|
return minimalFormatter;
|
|
@@ -206,22 +230,26 @@ var init_logging = __esm({
|
|
|
206
230
|
}
|
|
207
231
|
}
|
|
208
232
|
static async configure(options = {}) {
|
|
209
|
-
const { level, console: console2 = true, file, format
|
|
233
|
+
const { level, console: console2 = true, file, format = "minimal" } = options;
|
|
210
234
|
const debugEnv = typeof process !== "undefined" && process.env?.DEBUG || void 0;
|
|
211
235
|
const resolvedLevel = level ?? resolveLevel(debugEnv);
|
|
212
|
-
this.currentFormat =
|
|
213
|
-
const root = this.get();
|
|
214
|
-
root.level = resolvedLevel;
|
|
215
|
-
const winstonRoot = root;
|
|
236
|
+
this.currentFormat = format;
|
|
216
237
|
if (!isNodeJSEnvironment()) {
|
|
217
238
|
Object.values(this.simpleInstances).forEach((logger2) => {
|
|
218
239
|
logger2.level = resolvedLevel;
|
|
219
240
|
});
|
|
220
241
|
return;
|
|
221
242
|
}
|
|
243
|
+
await getWinston();
|
|
244
|
+
if (!winston) {
|
|
245
|
+
throw new Error("Failed to load winston");
|
|
246
|
+
}
|
|
247
|
+
const root = this.get();
|
|
248
|
+
root.level = resolvedLevel;
|
|
249
|
+
const winstonRoot = root;
|
|
222
250
|
winstonRoot.clear();
|
|
223
251
|
if (console2) {
|
|
224
|
-
winstonRoot.add(new
|
|
252
|
+
winstonRoot.add(new winston.transports.Console());
|
|
225
253
|
}
|
|
226
254
|
if (file) {
|
|
227
255
|
const { fs: nodeFs, path: nodePath } = await getNodeModules();
|
|
@@ -230,9 +258,11 @@ var init_logging = __esm({
|
|
|
230
258
|
if (!nodeFs.existsSync(dir)) {
|
|
231
259
|
nodeFs.mkdirSync(dir, { recursive: true });
|
|
232
260
|
}
|
|
233
|
-
winstonRoot.add(new
|
|
261
|
+
winstonRoot.add(new winston.transports.File({ filename: file }));
|
|
234
262
|
}
|
|
235
263
|
}
|
|
264
|
+
const { format: winstonFormat } = winston;
|
|
265
|
+
const { combine, timestamp, label, colorize, splat } = winstonFormat;
|
|
236
266
|
Object.values(this.instances).forEach((logger2) => {
|
|
237
267
|
if (logger2 && "format" in logger2) {
|
|
238
268
|
logger2.level = resolvedLevel;
|
|
@@ -263,15 +293,16 @@ var init_logging = __esm({
|
|
|
263
293
|
process.env.DEBUG = enabled ? enabled === true ? "2" : String(enabled) : "0";
|
|
264
294
|
}
|
|
265
295
|
}
|
|
266
|
-
static setFormat(
|
|
267
|
-
this.currentFormat =
|
|
268
|
-
this.configure({ format
|
|
296
|
+
static setFormat(format) {
|
|
297
|
+
this.currentFormat = format;
|
|
298
|
+
this.configure({ format });
|
|
269
299
|
}
|
|
270
300
|
};
|
|
271
301
|
if (isNodeJSEnvironment()) {
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
302
|
+
loadWinstonSync();
|
|
303
|
+
if (winston) {
|
|
304
|
+
Logger.configure();
|
|
305
|
+
}
|
|
275
306
|
}
|
|
276
307
|
logger = Logger.get();
|
|
277
308
|
}
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
createReadableStreamFromGenerator,
|
|
3
3
|
streamEventsToAISDK,
|
|
4
4
|
streamEventsToAISDKWithTools
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-EW4MJSHA.js";
|
|
6
6
|
import {
|
|
7
7
|
AcquireActiveMCPServerTool,
|
|
8
8
|
AddMCPServerFromConfigTool,
|
|
@@ -17,14 +17,14 @@ import {
|
|
|
17
17
|
ServerManager,
|
|
18
18
|
Telemetry,
|
|
19
19
|
setTelemetrySource
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-73SH52J2.js";
|
|
21
21
|
import {
|
|
22
22
|
useMcp,
|
|
23
23
|
useWidget,
|
|
24
24
|
useWidgetProps,
|
|
25
25
|
useWidgetState,
|
|
26
26
|
useWidgetTheme
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-X2HJQBDI.js";
|
|
28
28
|
import {
|
|
29
29
|
BaseConnector,
|
|
30
30
|
BaseMCPClient,
|
|
@@ -34,15 +34,15 @@ import {
|
|
|
34
34
|
MCPSession,
|
|
35
35
|
WebSocketConnector,
|
|
36
36
|
onMcpAuthorization
|
|
37
|
-
} from "./chunk-
|
|
38
|
-
import "./chunk-
|
|
37
|
+
} from "./chunk-37MPZ3D6.js";
|
|
38
|
+
import "./chunk-YURRUCIM.js";
|
|
39
39
|
import {
|
|
40
40
|
Logger,
|
|
41
41
|
logger
|
|
42
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-34R6SIER.js";
|
|
43
43
|
import {
|
|
44
44
|
__name
|
|
45
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-3GQAWCBQ.js";
|
|
46
46
|
|
|
47
47
|
// src/client.ts
|
|
48
48
|
import fs from "fs";
|
|
@@ -3,9 +3,9 @@ import {
|
|
|
3
3
|
langfuseClient,
|
|
4
4
|
langfuseHandler,
|
|
5
5
|
langfuseInitPromise
|
|
6
|
-
} from "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
6
|
+
} from "./chunk-YURRUCIM.js";
|
|
7
|
+
import "./chunk-34R6SIER.js";
|
|
8
|
+
import "./chunk-3GQAWCBQ.js";
|
|
9
9
|
export {
|
|
10
10
|
initializeLangfuse,
|
|
11
11
|
langfuseClient,
|
|
@@ -44,6 +44,20 @@ async function getNodeModules() {
|
|
|
44
44
|
}
|
|
45
45
|
return { fs: null, path: null };
|
|
46
46
|
}
|
|
47
|
+
function loadWinstonSync() {
|
|
48
|
+
if (typeof require !== "undefined") {
|
|
49
|
+
try {
|
|
50
|
+
winston = require("winston");
|
|
51
|
+
} catch {
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
async function getWinston() {
|
|
56
|
+
if (!winston) {
|
|
57
|
+
winston = await import("winston");
|
|
58
|
+
}
|
|
59
|
+
return winston;
|
|
60
|
+
}
|
|
47
61
|
function isNodeJSEnvironment() {
|
|
48
62
|
try {
|
|
49
63
|
if (typeof navigator !== "undefined" && navigator.userAgent?.includes("Cloudflare-Workers")) {
|
|
@@ -53,8 +67,7 @@ function isNodeJSEnvironment() {
|
|
|
53
67
|
return false;
|
|
54
68
|
}
|
|
55
69
|
const hasNodeGlobals = typeof process !== "undefined" && typeof process.platform !== "undefined" && typeof __dirname !== "undefined";
|
|
56
|
-
|
|
57
|
-
return hasNodeGlobals && hasNodeModules;
|
|
70
|
+
return hasNodeGlobals;
|
|
58
71
|
} catch {
|
|
59
72
|
return false;
|
|
60
73
|
}
|
|
@@ -70,13 +83,14 @@ function resolveLevel(env) {
|
|
|
70
83
|
return "info";
|
|
71
84
|
}
|
|
72
85
|
}
|
|
73
|
-
var
|
|
86
|
+
var winston, DEFAULT_LOGGER_NAME, SimpleConsoleLogger, Logger, logger;
|
|
74
87
|
var init_logging = __esm({
|
|
75
88
|
"src/logging.ts"() {
|
|
76
89
|
"use strict";
|
|
77
|
-
import_winston = require("winston");
|
|
78
90
|
__name(getNodeModules, "getNodeModules");
|
|
79
|
-
|
|
91
|
+
winston = null;
|
|
92
|
+
__name(loadWinstonSync, "loadWinstonSync");
|
|
93
|
+
__name(getWinston, "getWinston");
|
|
80
94
|
DEFAULT_LOGGER_NAME = "mcp-use";
|
|
81
95
|
__name(isNodeJSEnvironment, "isNodeJSEnvironment");
|
|
82
96
|
SimpleConsoleLogger = class {
|
|
@@ -104,8 +118,8 @@ var init_logging = __esm({
|
|
|
104
118
|
return messageIndex <= currentIndex;
|
|
105
119
|
}
|
|
106
120
|
formatMessage(level, message) {
|
|
107
|
-
const
|
|
108
|
-
return `${
|
|
121
|
+
const timestamp = (/* @__PURE__ */ new Date()).toLocaleTimeString("en-US", { hour12: false });
|
|
122
|
+
return `${timestamp} [${this.name}] ${level}: ${message}`;
|
|
109
123
|
}
|
|
110
124
|
error(message) {
|
|
111
125
|
if (this.shouldLog("error")) {
|
|
@@ -151,15 +165,6 @@ var init_logging = __esm({
|
|
|
151
165
|
}
|
|
152
166
|
};
|
|
153
167
|
__name(resolveLevel, "resolveLevel");
|
|
154
|
-
minimalFormatter = printf(({ level, message, label: label2, timestamp: timestamp2 }) => {
|
|
155
|
-
return `${timestamp2} [${label2}] ${level}: ${message}`;
|
|
156
|
-
});
|
|
157
|
-
detailedFormatter = printf(({ level, message, label: label2, timestamp: timestamp2 }) => {
|
|
158
|
-
return `${timestamp2} [${label2}] ${level.toUpperCase()}: ${message}`;
|
|
159
|
-
});
|
|
160
|
-
emojiFormatter = printf(({ level, message, label: label2, timestamp: timestamp2 }) => {
|
|
161
|
-
return `${timestamp2} [${label2}] ${level.toUpperCase()}: ${message}`;
|
|
162
|
-
});
|
|
163
168
|
Logger = class {
|
|
164
169
|
static {
|
|
165
170
|
__name(this, "Logger");
|
|
@@ -179,7 +184,12 @@ var init_logging = __esm({
|
|
|
179
184
|
return this.simpleInstances[name];
|
|
180
185
|
}
|
|
181
186
|
if (!this.instances[name]) {
|
|
182
|
-
|
|
187
|
+
if (!winston) {
|
|
188
|
+
throw new Error("Winston not loaded - call Logger.configure() first");
|
|
189
|
+
}
|
|
190
|
+
const { createLogger, format } = winston;
|
|
191
|
+
const { combine, timestamp, label, colorize, splat } = format;
|
|
192
|
+
this.instances[name] = createLogger({
|
|
183
193
|
level: resolveLevel(process.env.DEBUG),
|
|
184
194
|
format: combine(
|
|
185
195
|
colorize(),
|
|
@@ -194,6 +204,20 @@ var init_logging = __esm({
|
|
|
194
204
|
return this.instances[name];
|
|
195
205
|
}
|
|
196
206
|
static getFormatter() {
|
|
207
|
+
if (!winston) {
|
|
208
|
+
throw new Error("Winston not loaded");
|
|
209
|
+
}
|
|
210
|
+
const { format } = winston;
|
|
211
|
+
const { printf } = format;
|
|
212
|
+
const minimalFormatter = printf(({ level, message, label, timestamp }) => {
|
|
213
|
+
return `${timestamp} [${label}] ${level}: ${message}`;
|
|
214
|
+
});
|
|
215
|
+
const detailedFormatter = printf(({ level, message, label, timestamp }) => {
|
|
216
|
+
return `${timestamp} [${label}] ${level.toUpperCase()}: ${message}`;
|
|
217
|
+
});
|
|
218
|
+
const emojiFormatter = printf(({ level, message, label, timestamp }) => {
|
|
219
|
+
return `${timestamp} [${label}] ${level.toUpperCase()}: ${message}`;
|
|
220
|
+
});
|
|
197
221
|
switch (this.currentFormat) {
|
|
198
222
|
case "minimal":
|
|
199
223
|
return minimalFormatter;
|
|
@@ -206,22 +230,26 @@ var init_logging = __esm({
|
|
|
206
230
|
}
|
|
207
231
|
}
|
|
208
232
|
static async configure(options = {}) {
|
|
209
|
-
const { level, console: console2 = true, file, format
|
|
233
|
+
const { level, console: console2 = true, file, format = "minimal" } = options;
|
|
210
234
|
const debugEnv = typeof process !== "undefined" && process.env?.DEBUG || void 0;
|
|
211
235
|
const resolvedLevel = level ?? resolveLevel(debugEnv);
|
|
212
|
-
this.currentFormat =
|
|
213
|
-
const root = this.get();
|
|
214
|
-
root.level = resolvedLevel;
|
|
215
|
-
const winstonRoot = root;
|
|
236
|
+
this.currentFormat = format;
|
|
216
237
|
if (!isNodeJSEnvironment()) {
|
|
217
238
|
Object.values(this.simpleInstances).forEach((logger2) => {
|
|
218
239
|
logger2.level = resolvedLevel;
|
|
219
240
|
});
|
|
220
241
|
return;
|
|
221
242
|
}
|
|
243
|
+
await getWinston();
|
|
244
|
+
if (!winston) {
|
|
245
|
+
throw new Error("Failed to load winston");
|
|
246
|
+
}
|
|
247
|
+
const root = this.get();
|
|
248
|
+
root.level = resolvedLevel;
|
|
249
|
+
const winstonRoot = root;
|
|
222
250
|
winstonRoot.clear();
|
|
223
251
|
if (console2) {
|
|
224
|
-
winstonRoot.add(new
|
|
252
|
+
winstonRoot.add(new winston.transports.Console());
|
|
225
253
|
}
|
|
226
254
|
if (file) {
|
|
227
255
|
const { fs: nodeFs, path: nodePath } = await getNodeModules();
|
|
@@ -230,9 +258,11 @@ var init_logging = __esm({
|
|
|
230
258
|
if (!nodeFs.existsSync(dir)) {
|
|
231
259
|
nodeFs.mkdirSync(dir, { recursive: true });
|
|
232
260
|
}
|
|
233
|
-
winstonRoot.add(new
|
|
261
|
+
winstonRoot.add(new winston.transports.File({ filename: file }));
|
|
234
262
|
}
|
|
235
263
|
}
|
|
264
|
+
const { format: winstonFormat } = winston;
|
|
265
|
+
const { combine, timestamp, label, colorize, splat } = winstonFormat;
|
|
236
266
|
Object.values(this.instances).forEach((logger2) => {
|
|
237
267
|
if (logger2 && "format" in logger2) {
|
|
238
268
|
logger2.level = resolvedLevel;
|
|
@@ -263,15 +293,16 @@ var init_logging = __esm({
|
|
|
263
293
|
process.env.DEBUG = enabled ? enabled === true ? "2" : String(enabled) : "0";
|
|
264
294
|
}
|
|
265
295
|
}
|
|
266
|
-
static setFormat(
|
|
267
|
-
this.currentFormat =
|
|
268
|
-
this.configure({ format
|
|
296
|
+
static setFormat(format) {
|
|
297
|
+
this.currentFormat = format;
|
|
298
|
+
this.configure({ format });
|
|
269
299
|
}
|
|
270
300
|
};
|
|
271
301
|
if (isNodeJSEnvironment()) {
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
302
|
+
loadWinstonSync();
|
|
303
|
+
if (winston) {
|
|
304
|
+
Logger.configure();
|
|
305
|
+
}
|
|
275
306
|
}
|
|
276
307
|
logger = Logger.get();
|
|
277
308
|
}
|