mcp-use 1.7.0-canary.1 → 1.7.0-canary.3
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-PE7UMCVO.js → chunk-3R5PDYIN.js} +27 -1
- package/dist/{chunk-XN2PU4PS.js → chunk-BBEY6HHN.js} +59 -7
- package/dist/{chunk-YURRUCIM.js → chunk-CPG2WZUL.js} +9 -11
- package/dist/{chunk-R5DJJ4IV.js → chunk-F4UHAA5L.js} +3 -91
- package/dist/chunk-MTHLLDCX.js +97 -0
- package/dist/{chunk-QSLJXXMG.js → chunk-PSO6HYXH.js} +4 -4
- package/dist/{chunk-GVVPUU5K.js → chunk-S6K5QZBJ.js} +739 -29
- package/dist/{display-YIYC6WJE.js → display-A5IEINAP.js} +79 -17
- package/dist/index.cjs +952 -107
- package/dist/index.js +6 -5
- package/dist/{langfuse-C4HKZ3NL.js → langfuse-N5Y5BSXK.js} +1 -1
- package/dist/{oauth-CNGBFOZW.js → oauth-U4NNKN4B.js} +2 -1
- package/dist/src/agents/display.d.ts.map +1 -1
- package/dist/src/agents/index.cjs +854 -78
- package/dist/src/agents/index.js +3 -2
- package/dist/src/auth/index.cjs +30 -5
- package/dist/src/auth/index.js +1 -1
- package/dist/src/browser.cjs +888 -90
- package/dist/src/browser.js +5 -4
- package/dist/src/connectors/base.d.ts +53 -391
- package/dist/src/connectors/base.d.ts.map +1 -1
- package/dist/src/managers/server_manager.d.ts.map +1 -1
- package/dist/src/managers/tools/acquire_active_mcp_server.d.ts +2 -2
- package/dist/src/managers/tools/acquire_active_mcp_server.d.ts.map +1 -1
- package/dist/src/managers/tools/add_server_from_config.d.ts +1 -7
- package/dist/src/managers/tools/add_server_from_config.d.ts.map +1 -1
- package/dist/src/managers/tools/connect_mcp_server.d.ts +2 -10
- package/dist/src/managers/tools/connect_mcp_server.d.ts.map +1 -1
- package/dist/src/managers/tools/list_mcp_servers.d.ts +2 -2
- package/dist/src/managers/tools/list_mcp_servers.d.ts.map +1 -1
- package/dist/src/managers/tools/release_mcp_server_connection.d.ts +2 -2
- package/dist/src/managers/tools/release_mcp_server_connection.d.ts.map +1 -1
- package/dist/src/observability/langfuse.d.ts +4 -0
- package/dist/src/observability/langfuse.d.ts.map +1 -1
- package/dist/src/react/McpUseProvider.d.ts.map +1 -1
- package/dist/src/react/index.cjs +86 -12
- package/dist/src/react/index.js +4 -3
- package/dist/src/server/connect-adapter.d.ts.map +1 -1
- package/dist/src/server/index.cjs +28 -17
- package/dist/src/server/index.js +38 -25
- package/dist/src/server/mcp-server.d.ts.map +1 -1
- package/dist/src/utils/json-schema-to-zod/JSONSchemaToZod.d.ts +270 -0
- package/dist/src/utils/json-schema-to-zod/JSONSchemaToZod.d.ts.map +1 -0
- package/dist/src/utils/json-schema-to-zod/Type.d.ts +24 -0
- package/dist/src/utils/json-schema-to-zod/Type.d.ts.map +1 -0
- package/dist/src/utils/json-schema-to-zod/index.d.ts +3 -0
- package/dist/src/utils/json-schema-to-zod/index.d.ts.map +1 -0
- package/dist/src/utils/url-sanitize.d.ts +17 -0
- package/dist/src/utils/url-sanitize.d.ts.map +1 -0
- package/dist/tsup.config.d.ts.map +1 -1
- package/package.json +20 -37
|
@@ -2,8 +2,33 @@ import {
|
|
|
2
2
|
__name
|
|
3
3
|
} from "./chunk-3GQAWCBQ.js";
|
|
4
4
|
|
|
5
|
+
// src/utils/url-sanitize.ts
|
|
6
|
+
function sanitizeUrl(raw) {
|
|
7
|
+
const abort = /* @__PURE__ */ __name(() => {
|
|
8
|
+
throw new Error(`Invalid url to pass to open(): ${raw}`);
|
|
9
|
+
}, "abort");
|
|
10
|
+
let url;
|
|
11
|
+
try {
|
|
12
|
+
url = new URL(raw);
|
|
13
|
+
} catch (_) {
|
|
14
|
+
abort();
|
|
15
|
+
}
|
|
16
|
+
if (url.protocol !== "https:" && url.protocol !== "http:") abort();
|
|
17
|
+
if (url.hostname !== encodeURIComponent(url.hostname)) abort();
|
|
18
|
+
if (url.username) url.username = encodeURIComponent(url.username);
|
|
19
|
+
if (url.password) url.password = encodeURIComponent(url.password);
|
|
20
|
+
url.pathname = url.pathname.slice(0, 1) + encodeURIComponent(url.pathname.slice(1)).replace(/%2f/gi, "/");
|
|
21
|
+
url.search = url.search.slice(0, 1) + Array.from(url.searchParams.entries()).map(sanitizeParam).join("&");
|
|
22
|
+
url.hash = url.hash.slice(0, 1) + encodeURIComponent(url.hash.slice(1));
|
|
23
|
+
return url.href;
|
|
24
|
+
}
|
|
25
|
+
__name(sanitizeUrl, "sanitizeUrl");
|
|
26
|
+
function sanitizeParam([k, v]) {
|
|
27
|
+
return `${encodeURIComponent(k)}${v.length > 0 ? `=${encodeURIComponent(v)}` : ""}`;
|
|
28
|
+
}
|
|
29
|
+
__name(sanitizeParam, "sanitizeParam");
|
|
30
|
+
|
|
5
31
|
// src/auth/browser-provider.ts
|
|
6
|
-
import { sanitizeUrl } from "strict-url-sanitise";
|
|
7
32
|
var BrowserOAuthClientProvider = class {
|
|
8
33
|
static {
|
|
9
34
|
__name(this, "BrowserOAuthClientProvider");
|
|
@@ -372,6 +397,7 @@ async function onMcpAuthorization() {
|
|
|
372
397
|
__name(onMcpAuthorization, "onMcpAuthorization");
|
|
373
398
|
|
|
374
399
|
export {
|
|
400
|
+
sanitizeUrl,
|
|
375
401
|
BrowserOAuthClientProvider,
|
|
376
402
|
onMcpAuthorization
|
|
377
403
|
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BrowserMCPClient
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-PSO6HYXH.js";
|
|
4
4
|
import {
|
|
5
|
-
BrowserOAuthClientProvider
|
|
6
|
-
|
|
5
|
+
BrowserOAuthClientProvider,
|
|
6
|
+
sanitizeUrl
|
|
7
|
+
} from "./chunk-3R5PDYIN.js";
|
|
7
8
|
import {
|
|
8
9
|
__name
|
|
9
10
|
} from "./chunk-3GQAWCBQ.js";
|
|
10
11
|
|
|
11
12
|
// src/react/useMcp.ts
|
|
12
13
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
13
|
-
import { sanitizeUrl } from "strict-url-sanitise";
|
|
14
14
|
|
|
15
15
|
// src/utils/assert.ts
|
|
16
16
|
function assert(condition, message) {
|
|
@@ -1490,8 +1490,25 @@ function WidgetControls({
|
|
|
1490
1490
|
__name(WidgetControls, "WidgetControls");
|
|
1491
1491
|
|
|
1492
1492
|
// src/react/McpUseProvider.tsx
|
|
1493
|
-
import React5, {
|
|
1494
|
-
|
|
1493
|
+
import React5, {
|
|
1494
|
+
StrictMode,
|
|
1495
|
+
useCallback as useCallback3,
|
|
1496
|
+
useEffect as useEffect5,
|
|
1497
|
+
useRef as useRef3,
|
|
1498
|
+
useState as useState5
|
|
1499
|
+
} from "react";
|
|
1500
|
+
var BrowserRouter = null;
|
|
1501
|
+
var routerError = null;
|
|
1502
|
+
(async () => {
|
|
1503
|
+
try {
|
|
1504
|
+
const routerModule = await import("react-router-dom");
|
|
1505
|
+
BrowserRouter = routerModule.BrowserRouter;
|
|
1506
|
+
} catch (error) {
|
|
1507
|
+
routerError = new Error(
|
|
1508
|
+
"\u274C react-router-dom not installed!\n\nTo use MCP widgets with McpUseProvider, you need to install:\n\n npm install react-router-dom\n # or\n pnpm add react-router-dom\n\nThis dependency is automatically included in projects created with 'create-mcp-use-app'."
|
|
1509
|
+
);
|
|
1510
|
+
}
|
|
1511
|
+
})();
|
|
1495
1512
|
function getBasename() {
|
|
1496
1513
|
if (typeof window === "undefined") return "/";
|
|
1497
1514
|
const path = window.location.pathname;
|
|
@@ -1515,6 +1532,33 @@ function McpUseProvider({
|
|
|
1515
1532
|
const lastHeightRef = useRef3(0);
|
|
1516
1533
|
const debounceTimeoutRef = useRef3(null);
|
|
1517
1534
|
const notificationInProgressRef = useRef3(false);
|
|
1535
|
+
const [BrowserRouter2, setBrowserRouter] = useState5(null);
|
|
1536
|
+
const [routerError2, setRouterError] = useState5(null);
|
|
1537
|
+
const [isRouterLoading, setIsRouterLoading] = useState5(true);
|
|
1538
|
+
useEffect5(() => {
|
|
1539
|
+
let mounted = true;
|
|
1540
|
+
(async () => {
|
|
1541
|
+
try {
|
|
1542
|
+
const routerModule = await import("react-router-dom");
|
|
1543
|
+
if (mounted) {
|
|
1544
|
+
setBrowserRouter(() => routerModule.BrowserRouter);
|
|
1545
|
+
setIsRouterLoading(false);
|
|
1546
|
+
}
|
|
1547
|
+
} catch (error) {
|
|
1548
|
+
if (mounted) {
|
|
1549
|
+
setRouterError(
|
|
1550
|
+
new Error(
|
|
1551
|
+
"\u274C react-router-dom not installed!\n\nTo use MCP widgets with McpUseProvider, you need to install:\n\n npm install react-router-dom\n # or\n pnpm add react-router-dom\n\nThis dependency is automatically included in projects created with 'create-mcp-use-app'."
|
|
1552
|
+
)
|
|
1553
|
+
);
|
|
1554
|
+
setIsRouterLoading(false);
|
|
1555
|
+
}
|
|
1556
|
+
}
|
|
1557
|
+
})();
|
|
1558
|
+
return () => {
|
|
1559
|
+
mounted = false;
|
|
1560
|
+
};
|
|
1561
|
+
}, []);
|
|
1518
1562
|
const notifyHeight = useCallback3((height) => {
|
|
1519
1563
|
if (typeof window !== "undefined" && window.openai?.notifyIntrinsicHeight) {
|
|
1520
1564
|
notificationInProgressRef.current = true;
|
|
@@ -1580,12 +1624,20 @@ function McpUseProvider({
|
|
|
1580
1624
|
notificationInProgressRef.current = false;
|
|
1581
1625
|
};
|
|
1582
1626
|
}, [autoSize, debouncedNotifyHeight]);
|
|
1627
|
+
if (isRouterLoading) {
|
|
1628
|
+
return /* @__PURE__ */ React5.createElement(StrictMode, null, /* @__PURE__ */ React5.createElement(ThemeProvider, null, /* @__PURE__ */ React5.createElement("div", { style: { padding: "20px", textAlign: "center" } }, "Loading...")));
|
|
1629
|
+
}
|
|
1630
|
+
if (routerError2) {
|
|
1631
|
+
throw routerError2;
|
|
1632
|
+
}
|
|
1583
1633
|
let content = children;
|
|
1584
1634
|
content = /* @__PURE__ */ React5.createElement(ErrorBoundary, null, content);
|
|
1585
1635
|
if (enableDebugger || viewControls) {
|
|
1586
1636
|
content = /* @__PURE__ */ React5.createElement(WidgetControls, { debugger: enableDebugger, viewControls }, content);
|
|
1587
1637
|
}
|
|
1588
|
-
|
|
1638
|
+
if (BrowserRouter2) {
|
|
1639
|
+
content = /* @__PURE__ */ React5.createElement(BrowserRouter2, { basename }, content);
|
|
1640
|
+
}
|
|
1589
1641
|
content = /* @__PURE__ */ React5.createElement(ThemeProvider, null, content);
|
|
1590
1642
|
if (autoSize) {
|
|
1591
1643
|
const containerStyle = {
|
|
@@ -6,8 +6,6 @@ import {
|
|
|
6
6
|
} from "./chunk-3GQAWCBQ.js";
|
|
7
7
|
|
|
8
8
|
// src/observability/langfuse.ts
|
|
9
|
-
import { config } from "dotenv";
|
|
10
|
-
config();
|
|
11
9
|
var langfuseDisabled = process.env.MCP_USE_LANGFUSE?.toLowerCase() === "false";
|
|
12
10
|
var langfuseState = {
|
|
13
11
|
handler: null,
|
|
@@ -33,13 +31,13 @@ async function initializeLangfuse(agentId, metadata, metadataProvider, tagsProvi
|
|
|
33
31
|
metadataProvider;
|
|
34
32
|
tagsProvider;
|
|
35
33
|
verbose;
|
|
36
|
-
constructor(
|
|
37
|
-
super(
|
|
34
|
+
constructor(config2, agentId2, metadata2, metadataProvider2, tagsProvider2) {
|
|
35
|
+
super(config2);
|
|
38
36
|
this.agentId = agentId2;
|
|
39
37
|
this.metadata = metadata2;
|
|
40
38
|
this.metadataProvider = metadataProvider2;
|
|
41
39
|
this.tagsProvider = tagsProvider2;
|
|
42
|
-
this.verbose =
|
|
40
|
+
this.verbose = config2?.verbose ?? false;
|
|
43
41
|
}
|
|
44
42
|
// Override to add custom metadata to traces
|
|
45
43
|
async handleChainStart(chain, inputs, runId, parentRunId, tags, metadata2, name, kwargs) {
|
|
@@ -164,7 +162,7 @@ async function initializeLangfuse(agentId, metadata, metadataProvider, tagsProvi
|
|
|
164
162
|
}
|
|
165
163
|
const initialMetadata = metadata || (metadataProvider ? metadataProvider() : {});
|
|
166
164
|
const initialTags = tagsProvider ? tagsProvider() : [];
|
|
167
|
-
const
|
|
165
|
+
const config = {
|
|
168
166
|
publicKey: process.env.LANGFUSE_PUBLIC_KEY,
|
|
169
167
|
secretKey: process.env.LANGFUSE_SECRET_KEY,
|
|
170
168
|
baseUrl: process.env.LANGFUSE_HOST || process.env.LANGFUSE_BASEURL || "https://cloud.langfuse.com",
|
|
@@ -189,17 +187,17 @@ async function initializeLangfuse(agentId, metadata, metadataProvider, tagsProvi
|
|
|
189
187
|
"Langfuse handler config:",
|
|
190
188
|
JSON.stringify(
|
|
191
189
|
{
|
|
192
|
-
traceName:
|
|
193
|
-
sessionId:
|
|
194
|
-
userId:
|
|
195
|
-
tags:
|
|
190
|
+
traceName: config.traceName,
|
|
191
|
+
sessionId: config.sessionId,
|
|
192
|
+
userId: config.userId,
|
|
193
|
+
tags: config.tags
|
|
196
194
|
},
|
|
197
195
|
null,
|
|
198
196
|
2
|
|
199
197
|
)
|
|
200
198
|
);
|
|
201
199
|
langfuseState.handler = new LoggingCallbackHandler(
|
|
202
|
-
|
|
200
|
+
config,
|
|
203
201
|
agentId,
|
|
204
202
|
metadata,
|
|
205
203
|
metadataProvider,
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getEnv
|
|
3
|
+
} from "./chunk-MTHLLDCX.js";
|
|
1
4
|
import {
|
|
2
5
|
__name
|
|
3
6
|
} from "./chunk-3GQAWCBQ.js";
|
|
@@ -425,91 +428,6 @@ var CustomOAuthProvider = class {
|
|
|
425
428
|
}
|
|
426
429
|
};
|
|
427
430
|
|
|
428
|
-
// src/server/utils/runtime.ts
|
|
429
|
-
var isDeno = typeof globalThis.Deno !== "undefined";
|
|
430
|
-
function getEnv(key) {
|
|
431
|
-
if (isDeno) {
|
|
432
|
-
return globalThis.Deno.env.get(key);
|
|
433
|
-
}
|
|
434
|
-
return process.env[key];
|
|
435
|
-
}
|
|
436
|
-
__name(getEnv, "getEnv");
|
|
437
|
-
function getCwd() {
|
|
438
|
-
if (isDeno) {
|
|
439
|
-
return globalThis.Deno.cwd();
|
|
440
|
-
}
|
|
441
|
-
return process.cwd();
|
|
442
|
-
}
|
|
443
|
-
__name(getCwd, "getCwd");
|
|
444
|
-
var fsHelpers = {
|
|
445
|
-
async readFileSync(path, encoding = "utf8") {
|
|
446
|
-
if (isDeno) {
|
|
447
|
-
return await globalThis.Deno.readTextFile(path);
|
|
448
|
-
}
|
|
449
|
-
const { readFileSync } = await import("fs");
|
|
450
|
-
const result = readFileSync(path, encoding);
|
|
451
|
-
return typeof result === "string" ? result : result.toString(encoding);
|
|
452
|
-
},
|
|
453
|
-
async readFile(path) {
|
|
454
|
-
if (isDeno) {
|
|
455
|
-
const data = await globalThis.Deno.readFile(path);
|
|
456
|
-
return data.buffer;
|
|
457
|
-
}
|
|
458
|
-
const { readFileSync } = await import("fs");
|
|
459
|
-
const buffer = readFileSync(path);
|
|
460
|
-
return buffer.buffer.slice(
|
|
461
|
-
buffer.byteOffset,
|
|
462
|
-
buffer.byteOffset + buffer.byteLength
|
|
463
|
-
);
|
|
464
|
-
},
|
|
465
|
-
async existsSync(path) {
|
|
466
|
-
if (isDeno) {
|
|
467
|
-
try {
|
|
468
|
-
await globalThis.Deno.stat(path);
|
|
469
|
-
return true;
|
|
470
|
-
} catch {
|
|
471
|
-
return false;
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
const { existsSync } = await import("fs");
|
|
475
|
-
return existsSync(path);
|
|
476
|
-
},
|
|
477
|
-
async readdirSync(path) {
|
|
478
|
-
if (isDeno) {
|
|
479
|
-
const entries = [];
|
|
480
|
-
for await (const entry of globalThis.Deno.readDir(path)) {
|
|
481
|
-
entries.push(entry.name);
|
|
482
|
-
}
|
|
483
|
-
return entries;
|
|
484
|
-
}
|
|
485
|
-
const { readdirSync } = await import("fs");
|
|
486
|
-
return readdirSync(path);
|
|
487
|
-
}
|
|
488
|
-
};
|
|
489
|
-
var pathHelpers = {
|
|
490
|
-
join(...paths) {
|
|
491
|
-
if (isDeno) {
|
|
492
|
-
return paths.join("/").replace(/\/+/g, "/");
|
|
493
|
-
}
|
|
494
|
-
return paths.join("/").replace(/\/+/g, "/");
|
|
495
|
-
},
|
|
496
|
-
relative(from, to) {
|
|
497
|
-
const fromParts = from.split("/").filter((p) => p);
|
|
498
|
-
const toParts = to.split("/").filter((p) => p);
|
|
499
|
-
let i = 0;
|
|
500
|
-
while (i < fromParts.length && i < toParts.length && fromParts[i] === toParts[i]) {
|
|
501
|
-
i++;
|
|
502
|
-
}
|
|
503
|
-
const upCount = fromParts.length - i;
|
|
504
|
-
const relativeParts = [...Array(upCount).fill(".."), ...toParts.slice(i)];
|
|
505
|
-
return relativeParts.join("/");
|
|
506
|
-
}
|
|
507
|
-
};
|
|
508
|
-
function generateUUID() {
|
|
509
|
-
return globalThis.crypto.randomUUID();
|
|
510
|
-
}
|
|
511
|
-
__name(generateUUID, "generateUUID");
|
|
512
|
-
|
|
513
431
|
// src/server/oauth/providers.ts
|
|
514
432
|
function oauthSupabaseProvider(config = {}) {
|
|
515
433
|
const projectId = config.projectId ?? getEnv("MCP_USE_OAUTH_SUPABASE_PROJECT_ID");
|
|
@@ -921,12 +839,6 @@ function requireAnyScope(needed) {
|
|
|
921
839
|
__name(requireAnyScope, "requireAnyScope");
|
|
922
840
|
|
|
923
841
|
export {
|
|
924
|
-
isDeno,
|
|
925
|
-
getEnv,
|
|
926
|
-
getCwd,
|
|
927
|
-
fsHelpers,
|
|
928
|
-
pathHelpers,
|
|
929
|
-
generateUUID,
|
|
930
842
|
oauthSupabaseProvider,
|
|
931
843
|
oauthAuth0Provider,
|
|
932
844
|
oauthKeycloakProvider,
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__name
|
|
3
|
+
} from "./chunk-3GQAWCBQ.js";
|
|
4
|
+
|
|
5
|
+
// src/server/utils/runtime.ts
|
|
6
|
+
var isDeno = typeof globalThis.Deno !== "undefined";
|
|
7
|
+
function getEnv(key) {
|
|
8
|
+
if (isDeno) {
|
|
9
|
+
return globalThis.Deno.env.get(key);
|
|
10
|
+
}
|
|
11
|
+
return process.env[key];
|
|
12
|
+
}
|
|
13
|
+
__name(getEnv, "getEnv");
|
|
14
|
+
function getCwd() {
|
|
15
|
+
if (isDeno) {
|
|
16
|
+
return globalThis.Deno.cwd();
|
|
17
|
+
}
|
|
18
|
+
return process.cwd();
|
|
19
|
+
}
|
|
20
|
+
__name(getCwd, "getCwd");
|
|
21
|
+
var fsHelpers = {
|
|
22
|
+
async readFileSync(path, encoding = "utf8") {
|
|
23
|
+
if (isDeno) {
|
|
24
|
+
return await globalThis.Deno.readTextFile(path);
|
|
25
|
+
}
|
|
26
|
+
const { readFileSync } = await import("fs");
|
|
27
|
+
const result = readFileSync(path, encoding);
|
|
28
|
+
return typeof result === "string" ? result : result.toString(encoding);
|
|
29
|
+
},
|
|
30
|
+
async readFile(path) {
|
|
31
|
+
if (isDeno) {
|
|
32
|
+
const data = await globalThis.Deno.readFile(path);
|
|
33
|
+
return data.buffer;
|
|
34
|
+
}
|
|
35
|
+
const { readFileSync } = await import("fs");
|
|
36
|
+
const buffer = readFileSync(path);
|
|
37
|
+
return buffer.buffer.slice(
|
|
38
|
+
buffer.byteOffset,
|
|
39
|
+
buffer.byteOffset + buffer.byteLength
|
|
40
|
+
);
|
|
41
|
+
},
|
|
42
|
+
async existsSync(path) {
|
|
43
|
+
if (isDeno) {
|
|
44
|
+
try {
|
|
45
|
+
await globalThis.Deno.stat(path);
|
|
46
|
+
return true;
|
|
47
|
+
} catch {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const { existsSync } = await import("fs");
|
|
52
|
+
return existsSync(path);
|
|
53
|
+
},
|
|
54
|
+
async readdirSync(path) {
|
|
55
|
+
if (isDeno) {
|
|
56
|
+
const entries = [];
|
|
57
|
+
for await (const entry of globalThis.Deno.readDir(path)) {
|
|
58
|
+
entries.push(entry.name);
|
|
59
|
+
}
|
|
60
|
+
return entries;
|
|
61
|
+
}
|
|
62
|
+
const { readdirSync } = await import("fs");
|
|
63
|
+
return readdirSync(path);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
var pathHelpers = {
|
|
67
|
+
join(...paths) {
|
|
68
|
+
if (isDeno) {
|
|
69
|
+
return paths.join("/").replace(/\/+/g, "/");
|
|
70
|
+
}
|
|
71
|
+
return paths.join("/").replace(/\/+/g, "/");
|
|
72
|
+
},
|
|
73
|
+
relative(from, to) {
|
|
74
|
+
const fromParts = from.split("/").filter((p) => p);
|
|
75
|
+
const toParts = to.split("/").filter((p) => p);
|
|
76
|
+
let i = 0;
|
|
77
|
+
while (i < fromParts.length && i < toParts.length && fromParts[i] === toParts[i]) {
|
|
78
|
+
i++;
|
|
79
|
+
}
|
|
80
|
+
const upCount = fromParts.length - i;
|
|
81
|
+
const relativeParts = [...Array(upCount).fill(".."), ...toParts.slice(i)];
|
|
82
|
+
return relativeParts.join("/");
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
function generateUUID() {
|
|
86
|
+
return globalThis.crypto.randomUUID();
|
|
87
|
+
}
|
|
88
|
+
__name(generateUUID, "generateUUID");
|
|
89
|
+
|
|
90
|
+
export {
|
|
91
|
+
isDeno,
|
|
92
|
+
getEnv,
|
|
93
|
+
getCwd,
|
|
94
|
+
fsHelpers,
|
|
95
|
+
pathHelpers,
|
|
96
|
+
generateUUID
|
|
97
|
+
};
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BaseConnector
|
|
3
3
|
} from "./chunk-2JBWOW4S.js";
|
|
4
|
+
import {
|
|
5
|
+
generateUUID
|
|
6
|
+
} from "./chunk-MTHLLDCX.js";
|
|
4
7
|
import {
|
|
5
8
|
logger
|
|
6
9
|
} from "./chunk-34R6SIER.js";
|
|
@@ -509,9 +512,6 @@ var HttpConnector = class extends BaseConnector {
|
|
|
509
512
|
}
|
|
510
513
|
};
|
|
511
514
|
|
|
512
|
-
// src/connectors/websocket.ts
|
|
513
|
-
import { v4 as uuidv4 } from "uuid";
|
|
514
|
-
|
|
515
515
|
// src/task_managers/websocket.ts
|
|
516
516
|
import WS from "ws";
|
|
517
517
|
var WebSocketConnectionManager = class extends ConnectionManager {
|
|
@@ -630,7 +630,7 @@ var WebSocketConnector = class extends BaseConnector {
|
|
|
630
630
|
}
|
|
631
631
|
sendRequest(method, params = null) {
|
|
632
632
|
if (!this.ws) throw new Error("WebSocket is not connected");
|
|
633
|
-
const id =
|
|
633
|
+
const id = generateUUID();
|
|
634
634
|
const payload = JSON.stringify({ id, method, params: params ?? {} });
|
|
635
635
|
return new Promise((resolve, reject) => {
|
|
636
636
|
this.pending.set(id, { resolve, reject });
|