@dexto/core 1.6.17 → 1.6.18
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/agent/DextoAgent.cjs +63 -9
- package/dist/agent/DextoAgent.d.ts +11 -1
- package/dist/agent/DextoAgent.d.ts.map +1 -1
- package/dist/agent/DextoAgent.js +56 -2
- package/dist/agent/runtime-config.d.ts +2 -0
- package/dist/agent/runtime-config.d.ts.map +1 -1
- package/dist/llm/executor/stream-processor.cjs +2 -2
- package/dist/llm/executor/stream-processor.d.ts +1 -0
- package/dist/llm/executor/stream-processor.d.ts.map +1 -1
- package/dist/llm/executor/stream-processor.js +2 -2
- package/dist/llm/executor/turn-executor.cjs +3 -0
- package/dist/llm/executor/turn-executor.d.ts +1 -0
- package/dist/llm/executor/turn-executor.d.ts.map +1 -1
- package/dist/llm/executor/turn-executor.js +3 -0
- package/dist/llm/services/factory.cjs +3 -1
- package/dist/llm/services/factory.d.ts +7 -3
- package/dist/llm/services/factory.d.ts.map +1 -1
- package/dist/llm/services/factory.js +3 -1
- package/dist/llm/services/vercel.cjs +4 -1
- package/dist/llm/services/vercel.d.ts +2 -1
- package/dist/llm/services/vercel.d.ts.map +1 -1
- package/dist/llm/services/vercel.js +4 -1
- package/dist/llm/usage-scope.cjs +4 -13
- package/dist/llm/usage-scope.d.ts +3 -2
- package/dist/llm/usage-scope.d.ts.map +1 -1
- package/dist/llm/usage-scope.js +3 -11
- package/dist/mcp/bundled-config.cjs +206 -0
- package/dist/mcp/bundled-config.d.ts +10 -0
- package/dist/mcp/bundled-config.d.ts.map +1 -0
- package/dist/mcp/bundled-config.js +173 -0
- package/dist/mcp/index.cjs +43 -15
- package/dist/mcp/index.d.ts +11 -7
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +35 -7
- package/dist/prompts/providers/config-prompt-provider.cjs +15 -1
- package/dist/prompts/providers/config-prompt-provider.d.ts.map +1 -1
- package/dist/prompts/providers/config-prompt-provider.js +15 -1
- package/dist/session/chat-session.cjs +9 -4
- package/dist/session/chat-session.d.ts.map +1 -1
- package/dist/session/chat-session.js +9 -4
- package/dist/session/session-manager.cjs +140 -67
- package/dist/session/session-manager.d.ts +8 -1
- package/dist/session/session-manager.d.ts.map +1 -1
- package/dist/session/session-manager.js +142 -67
- package/dist/systemPrompt/manager.cjs +7 -1
- package/dist/systemPrompt/manager.d.ts.map +1 -1
- package/dist/systemPrompt/manager.js +7 -1
- package/dist/systemPrompt/schemas.cjs +7 -0
- package/dist/systemPrompt/schemas.d.ts +14 -0
- package/dist/systemPrompt/schemas.d.ts.map +1 -1
- package/dist/systemPrompt/schemas.js +6 -0
- package/dist/systemPrompt/types.d.ts +2 -0
- package/dist/systemPrompt/types.d.ts.map +1 -1
- package/dist/tools/tool-manager.cjs +20 -1
- package/dist/tools/tool-manager.d.ts.map +1 -1
- package/dist/tools/tool-manager.js +21 -2
- package/package.json +2 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export declare
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const UsageScopeIdSchema: z.ZodString;
|
|
3
|
+
export type UsageScopeId = z.output<typeof UsageScopeIdSchema>;
|
|
3
4
|
//# sourceMappingURL=usage-scope.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usage-scope.d.ts","sourceRoot":"","sources":["../../src/llm/usage-scope.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"usage-scope.d.ts","sourceRoot":"","sources":["../../src/llm/usage-scope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,kBAAkB,aAA2B,CAAC;AAE3D,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,kBAAkB,CAAC,CAAC"}
|
package/dist/llm/usage-scope.js
CHANGED
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
import "../chunk-PTJYTZNU.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const value = process.env[DEXTO_USAGE_SCOPE_ID_ENV];
|
|
5
|
-
if (!value) {
|
|
6
|
-
return void 0;
|
|
7
|
-
}
|
|
8
|
-
const trimmedValue = value.trim();
|
|
9
|
-
return trimmedValue.length > 0 ? trimmedValue : void 0;
|
|
10
|
-
}
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
const UsageScopeIdSchema = z.string().trim().min(1);
|
|
11
4
|
export {
|
|
12
|
-
|
|
13
|
-
getConfiguredUsageScopeId
|
|
5
|
+
UsageScopeIdSchema
|
|
14
6
|
};
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var bundled_config_exports = {};
|
|
30
|
+
__export(bundled_config_exports, {
|
|
31
|
+
loadBundledMcpConfigFromDirectory: () => loadBundledMcpConfigFromDirectory
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(bundled_config_exports);
|
|
34
|
+
var import_fs = require("fs");
|
|
35
|
+
var path = __toESM(require("path"), 1);
|
|
36
|
+
var import_schemas = require("./schemas.js");
|
|
37
|
+
function normalizeServerEntries(servers, inferTransportType) {
|
|
38
|
+
const normalized = {};
|
|
39
|
+
for (const [serverName, serverConfig] of Object.entries(servers)) {
|
|
40
|
+
if (typeof serverConfig !== "object" || serverConfig === null || Array.isArray(serverConfig)) {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
const config = serverConfig;
|
|
44
|
+
if ("type" in config || !inferTransportType) {
|
|
45
|
+
normalized[serverName] = config;
|
|
46
|
+
} else if ("command" in config) {
|
|
47
|
+
normalized[serverName] = {
|
|
48
|
+
type: "stdio",
|
|
49
|
+
...config
|
|
50
|
+
};
|
|
51
|
+
} else if ("url" in config) {
|
|
52
|
+
const url = String(config.url || "");
|
|
53
|
+
normalized[serverName] = {
|
|
54
|
+
type: url.includes("/sse") ? "sse" : "http",
|
|
55
|
+
...config
|
|
56
|
+
};
|
|
57
|
+
} else {
|
|
58
|
+
normalized[serverName] = config;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return normalized;
|
|
62
|
+
}
|
|
63
|
+
function normalizeParsedMcpServers(parsed, ownerName, sourceLabel, warnings) {
|
|
64
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
65
|
+
warnings.push(`[${ownerName}] Invalid ${sourceLabel}: expected an object`);
|
|
66
|
+
return void 0;
|
|
67
|
+
}
|
|
68
|
+
const parsedRecord = parsed;
|
|
69
|
+
const candidate = parsedRecord.mcpServers;
|
|
70
|
+
if (candidate !== void 0) {
|
|
71
|
+
if (!candidate || typeof candidate !== "object" || Array.isArray(candidate)) {
|
|
72
|
+
warnings.push(`[${ownerName}] Invalid ${sourceLabel}: mcpServers must be an object`);
|
|
73
|
+
return void 0;
|
|
74
|
+
}
|
|
75
|
+
return normalizeServerEntries(candidate, true);
|
|
76
|
+
}
|
|
77
|
+
if (Object.values(parsedRecord).some(
|
|
78
|
+
(value) => typeof value === "object" && value !== null && !Array.isArray(value) && ("type" in value || "command" in value || "url" in value)
|
|
79
|
+
)) {
|
|
80
|
+
return normalizeServerEntries(parsedRecord, true);
|
|
81
|
+
}
|
|
82
|
+
warnings.push(`[${ownerName}] Invalid ${sourceLabel}: no MCP servers found`);
|
|
83
|
+
return void 0;
|
|
84
|
+
}
|
|
85
|
+
function resolveSkillRelativeValue(bundleDirectory, value) {
|
|
86
|
+
if (value.length === 0 || path.isAbsolute(value)) {
|
|
87
|
+
return value;
|
|
88
|
+
}
|
|
89
|
+
const candidate = path.resolve(bundleDirectory, value);
|
|
90
|
+
return (0, import_fs.existsSync)(candidate) ? candidate : value;
|
|
91
|
+
}
|
|
92
|
+
function resolveServerRelativePaths(bundleDirectory, serverConfig) {
|
|
93
|
+
if (serverConfig.type !== "stdio") {
|
|
94
|
+
return serverConfig;
|
|
95
|
+
}
|
|
96
|
+
const resolvedConfig = { ...serverConfig };
|
|
97
|
+
if (typeof resolvedConfig.command === "string") {
|
|
98
|
+
resolvedConfig.command = resolveSkillRelativeValue(bundleDirectory, resolvedConfig.command);
|
|
99
|
+
}
|
|
100
|
+
if (Array.isArray(resolvedConfig.args)) {
|
|
101
|
+
resolvedConfig.args = resolvedConfig.args.map(
|
|
102
|
+
(arg) => typeof arg === "string" ? resolveSkillRelativeValue(bundleDirectory, arg) : arg
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
return resolvedConfig;
|
|
106
|
+
}
|
|
107
|
+
function validateBundledMcpServers(bundleDirectory, parsedServers, ownerName, sourceLabel, warnings) {
|
|
108
|
+
const resolvedServers = Object.fromEntries(
|
|
109
|
+
Object.entries(parsedServers).map(([serverName, serverConfig]) => {
|
|
110
|
+
if (typeof serverConfig !== "object" || serverConfig === null || Array.isArray(serverConfig)) {
|
|
111
|
+
return [serverName, serverConfig];
|
|
112
|
+
}
|
|
113
|
+
return [
|
|
114
|
+
serverName,
|
|
115
|
+
resolveServerRelativePaths(
|
|
116
|
+
bundleDirectory,
|
|
117
|
+
serverConfig
|
|
118
|
+
)
|
|
119
|
+
];
|
|
120
|
+
})
|
|
121
|
+
);
|
|
122
|
+
const result = import_schemas.ServersConfigSchema.safeParse(resolvedServers);
|
|
123
|
+
if (!result.success) {
|
|
124
|
+
const issues = result.error.issues.map((issue) => issue.message).join(", ");
|
|
125
|
+
warnings.push(`[${ownerName}] Invalid ${sourceLabel}: ${issues}`);
|
|
126
|
+
return void 0;
|
|
127
|
+
}
|
|
128
|
+
return result.data;
|
|
129
|
+
}
|
|
130
|
+
function mergeBundledMcpServers(current, incoming) {
|
|
131
|
+
if (!incoming) {
|
|
132
|
+
return current;
|
|
133
|
+
}
|
|
134
|
+
if (!current) {
|
|
135
|
+
return incoming;
|
|
136
|
+
}
|
|
137
|
+
return {
|
|
138
|
+
...current,
|
|
139
|
+
...incoming
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
function loadBundledMcpConfigFile(filePath, bundleDirectory, ownerName, sourceLabel, warnings) {
|
|
143
|
+
if (!(0, import_fs.existsSync)(filePath)) {
|
|
144
|
+
return void 0;
|
|
145
|
+
}
|
|
146
|
+
try {
|
|
147
|
+
const content = (0, import_fs.readFileSync)(filePath, "utf-8");
|
|
148
|
+
const parsed = JSON.parse(content);
|
|
149
|
+
const parsedServers = normalizeParsedMcpServers(parsed, ownerName, sourceLabel, warnings);
|
|
150
|
+
if (!parsedServers) {
|
|
151
|
+
return void 0;
|
|
152
|
+
}
|
|
153
|
+
return validateBundledMcpServers(
|
|
154
|
+
bundleDirectory,
|
|
155
|
+
parsedServers,
|
|
156
|
+
ownerName,
|
|
157
|
+
sourceLabel,
|
|
158
|
+
warnings
|
|
159
|
+
);
|
|
160
|
+
} catch (error) {
|
|
161
|
+
if (error instanceof SyntaxError) {
|
|
162
|
+
warnings.push(`[${ownerName}] Failed to parse ${sourceLabel}: invalid JSON`);
|
|
163
|
+
} else {
|
|
164
|
+
warnings.push(`[${ownerName}] Failed to load ${sourceLabel}: ${String(error)}`);
|
|
165
|
+
}
|
|
166
|
+
return void 0;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
function loadBundledMcpConfigFromDirectory(bundleDirectory, ownerName, options = {}) {
|
|
170
|
+
const warnings = [];
|
|
171
|
+
let mcpServers = loadBundledMcpConfigFile(
|
|
172
|
+
path.join(bundleDirectory, ".mcp.json"),
|
|
173
|
+
bundleDirectory,
|
|
174
|
+
ownerName,
|
|
175
|
+
".mcp.json",
|
|
176
|
+
warnings
|
|
177
|
+
);
|
|
178
|
+
if (options.scanNestedMcps) {
|
|
179
|
+
const mcpsDirectory = path.join(bundleDirectory, "mcps");
|
|
180
|
+
if ((0, import_fs.existsSync)(mcpsDirectory)) {
|
|
181
|
+
try {
|
|
182
|
+
const entries = (0, import_fs.readdirSync)(mcpsDirectory, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).sort((left, right) => left.name.localeCompare(right.name));
|
|
183
|
+
for (const entry of entries) {
|
|
184
|
+
const nestedServers = loadBundledMcpConfigFile(
|
|
185
|
+
path.join(mcpsDirectory, entry.name),
|
|
186
|
+
bundleDirectory,
|
|
187
|
+
ownerName,
|
|
188
|
+
`mcps/${entry.name}`,
|
|
189
|
+
warnings
|
|
190
|
+
);
|
|
191
|
+
mcpServers = mergeBundledMcpServers(mcpServers, nestedServers);
|
|
192
|
+
}
|
|
193
|
+
} catch (error) {
|
|
194
|
+
warnings.push(`[${ownerName}] Failed to read mcps/: ${String(error)}`);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
return {
|
|
199
|
+
...mcpServers ? { mcpServers } : {},
|
|
200
|
+
warnings
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
204
|
+
0 && (module.exports = {
|
|
205
|
+
loadBundledMcpConfigFromDirectory
|
|
206
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ValidatedServersConfig } from './schemas.js';
|
|
2
|
+
export interface LoadBundledMcpConfigOptions {
|
|
3
|
+
scanNestedMcps?: boolean | undefined;
|
|
4
|
+
}
|
|
5
|
+
export interface LoadBundledMcpConfigResult {
|
|
6
|
+
mcpServers?: ValidatedServersConfig | undefined;
|
|
7
|
+
warnings: string[];
|
|
8
|
+
}
|
|
9
|
+
export declare function loadBundledMcpConfigFromDirectory(bundleDirectory: string, ownerName: string, options?: LoadBundledMcpConfigOptions): LoadBundledMcpConfigResult;
|
|
10
|
+
//# sourceMappingURL=bundled-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundled-config.d.ts","sourceRoot":"","sources":["../../src/mcp/bundled-config.ts"],"names":[],"mappings":"AAEA,OAAO,EAAuB,KAAK,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAEhF,MAAM,WAAW,2BAA2B;IACxC,cAAc,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CACxC;AAED,MAAM,WAAW,0BAA0B;IACvC,UAAU,CAAC,EAAE,sBAAsB,GAAG,SAAS,CAAC;IAChD,QAAQ,EAAE,MAAM,EAAE,CAAC;CACtB;AAwMD,wBAAgB,iCAAiC,CAC7C,eAAe,EAAE,MAAM,EACvB,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,2BAAgC,GAC1C,0BAA0B,CAsC5B"}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import "../chunk-PTJYTZNU.js";
|
|
2
|
+
import { existsSync, readFileSync, readdirSync } from "fs";
|
|
3
|
+
import * as path from "path";
|
|
4
|
+
import { ServersConfigSchema } from "./schemas.js";
|
|
5
|
+
function normalizeServerEntries(servers, inferTransportType) {
|
|
6
|
+
const normalized = {};
|
|
7
|
+
for (const [serverName, serverConfig] of Object.entries(servers)) {
|
|
8
|
+
if (typeof serverConfig !== "object" || serverConfig === null || Array.isArray(serverConfig)) {
|
|
9
|
+
continue;
|
|
10
|
+
}
|
|
11
|
+
const config = serverConfig;
|
|
12
|
+
if ("type" in config || !inferTransportType) {
|
|
13
|
+
normalized[serverName] = config;
|
|
14
|
+
} else if ("command" in config) {
|
|
15
|
+
normalized[serverName] = {
|
|
16
|
+
type: "stdio",
|
|
17
|
+
...config
|
|
18
|
+
};
|
|
19
|
+
} else if ("url" in config) {
|
|
20
|
+
const url = String(config.url || "");
|
|
21
|
+
normalized[serverName] = {
|
|
22
|
+
type: url.includes("/sse") ? "sse" : "http",
|
|
23
|
+
...config
|
|
24
|
+
};
|
|
25
|
+
} else {
|
|
26
|
+
normalized[serverName] = config;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return normalized;
|
|
30
|
+
}
|
|
31
|
+
function normalizeParsedMcpServers(parsed, ownerName, sourceLabel, warnings) {
|
|
32
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
33
|
+
warnings.push(`[${ownerName}] Invalid ${sourceLabel}: expected an object`);
|
|
34
|
+
return void 0;
|
|
35
|
+
}
|
|
36
|
+
const parsedRecord = parsed;
|
|
37
|
+
const candidate = parsedRecord.mcpServers;
|
|
38
|
+
if (candidate !== void 0) {
|
|
39
|
+
if (!candidate || typeof candidate !== "object" || Array.isArray(candidate)) {
|
|
40
|
+
warnings.push(`[${ownerName}] Invalid ${sourceLabel}: mcpServers must be an object`);
|
|
41
|
+
return void 0;
|
|
42
|
+
}
|
|
43
|
+
return normalizeServerEntries(candidate, true);
|
|
44
|
+
}
|
|
45
|
+
if (Object.values(parsedRecord).some(
|
|
46
|
+
(value) => typeof value === "object" && value !== null && !Array.isArray(value) && ("type" in value || "command" in value || "url" in value)
|
|
47
|
+
)) {
|
|
48
|
+
return normalizeServerEntries(parsedRecord, true);
|
|
49
|
+
}
|
|
50
|
+
warnings.push(`[${ownerName}] Invalid ${sourceLabel}: no MCP servers found`);
|
|
51
|
+
return void 0;
|
|
52
|
+
}
|
|
53
|
+
function resolveSkillRelativeValue(bundleDirectory, value) {
|
|
54
|
+
if (value.length === 0 || path.isAbsolute(value)) {
|
|
55
|
+
return value;
|
|
56
|
+
}
|
|
57
|
+
const candidate = path.resolve(bundleDirectory, value);
|
|
58
|
+
return existsSync(candidate) ? candidate : value;
|
|
59
|
+
}
|
|
60
|
+
function resolveServerRelativePaths(bundleDirectory, serverConfig) {
|
|
61
|
+
if (serverConfig.type !== "stdio") {
|
|
62
|
+
return serverConfig;
|
|
63
|
+
}
|
|
64
|
+
const resolvedConfig = { ...serverConfig };
|
|
65
|
+
if (typeof resolvedConfig.command === "string") {
|
|
66
|
+
resolvedConfig.command = resolveSkillRelativeValue(bundleDirectory, resolvedConfig.command);
|
|
67
|
+
}
|
|
68
|
+
if (Array.isArray(resolvedConfig.args)) {
|
|
69
|
+
resolvedConfig.args = resolvedConfig.args.map(
|
|
70
|
+
(arg) => typeof arg === "string" ? resolveSkillRelativeValue(bundleDirectory, arg) : arg
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
return resolvedConfig;
|
|
74
|
+
}
|
|
75
|
+
function validateBundledMcpServers(bundleDirectory, parsedServers, ownerName, sourceLabel, warnings) {
|
|
76
|
+
const resolvedServers = Object.fromEntries(
|
|
77
|
+
Object.entries(parsedServers).map(([serverName, serverConfig]) => {
|
|
78
|
+
if (typeof serverConfig !== "object" || serverConfig === null || Array.isArray(serverConfig)) {
|
|
79
|
+
return [serverName, serverConfig];
|
|
80
|
+
}
|
|
81
|
+
return [
|
|
82
|
+
serverName,
|
|
83
|
+
resolveServerRelativePaths(
|
|
84
|
+
bundleDirectory,
|
|
85
|
+
serverConfig
|
|
86
|
+
)
|
|
87
|
+
];
|
|
88
|
+
})
|
|
89
|
+
);
|
|
90
|
+
const result = ServersConfigSchema.safeParse(resolvedServers);
|
|
91
|
+
if (!result.success) {
|
|
92
|
+
const issues = result.error.issues.map((issue) => issue.message).join(", ");
|
|
93
|
+
warnings.push(`[${ownerName}] Invalid ${sourceLabel}: ${issues}`);
|
|
94
|
+
return void 0;
|
|
95
|
+
}
|
|
96
|
+
return result.data;
|
|
97
|
+
}
|
|
98
|
+
function mergeBundledMcpServers(current, incoming) {
|
|
99
|
+
if (!incoming) {
|
|
100
|
+
return current;
|
|
101
|
+
}
|
|
102
|
+
if (!current) {
|
|
103
|
+
return incoming;
|
|
104
|
+
}
|
|
105
|
+
return {
|
|
106
|
+
...current,
|
|
107
|
+
...incoming
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
function loadBundledMcpConfigFile(filePath, bundleDirectory, ownerName, sourceLabel, warnings) {
|
|
111
|
+
if (!existsSync(filePath)) {
|
|
112
|
+
return void 0;
|
|
113
|
+
}
|
|
114
|
+
try {
|
|
115
|
+
const content = readFileSync(filePath, "utf-8");
|
|
116
|
+
const parsed = JSON.parse(content);
|
|
117
|
+
const parsedServers = normalizeParsedMcpServers(parsed, ownerName, sourceLabel, warnings);
|
|
118
|
+
if (!parsedServers) {
|
|
119
|
+
return void 0;
|
|
120
|
+
}
|
|
121
|
+
return validateBundledMcpServers(
|
|
122
|
+
bundleDirectory,
|
|
123
|
+
parsedServers,
|
|
124
|
+
ownerName,
|
|
125
|
+
sourceLabel,
|
|
126
|
+
warnings
|
|
127
|
+
);
|
|
128
|
+
} catch (error) {
|
|
129
|
+
if (error instanceof SyntaxError) {
|
|
130
|
+
warnings.push(`[${ownerName}] Failed to parse ${sourceLabel}: invalid JSON`);
|
|
131
|
+
} else {
|
|
132
|
+
warnings.push(`[${ownerName}] Failed to load ${sourceLabel}: ${String(error)}`);
|
|
133
|
+
}
|
|
134
|
+
return void 0;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
function loadBundledMcpConfigFromDirectory(bundleDirectory, ownerName, options = {}) {
|
|
138
|
+
const warnings = [];
|
|
139
|
+
let mcpServers = loadBundledMcpConfigFile(
|
|
140
|
+
path.join(bundleDirectory, ".mcp.json"),
|
|
141
|
+
bundleDirectory,
|
|
142
|
+
ownerName,
|
|
143
|
+
".mcp.json",
|
|
144
|
+
warnings
|
|
145
|
+
);
|
|
146
|
+
if (options.scanNestedMcps) {
|
|
147
|
+
const mcpsDirectory = path.join(bundleDirectory, "mcps");
|
|
148
|
+
if (existsSync(mcpsDirectory)) {
|
|
149
|
+
try {
|
|
150
|
+
const entries = readdirSync(mcpsDirectory, { withFileTypes: true }).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).sort((left, right) => left.name.localeCompare(right.name));
|
|
151
|
+
for (const entry of entries) {
|
|
152
|
+
const nestedServers = loadBundledMcpConfigFile(
|
|
153
|
+
path.join(mcpsDirectory, entry.name),
|
|
154
|
+
bundleDirectory,
|
|
155
|
+
ownerName,
|
|
156
|
+
`mcps/${entry.name}`,
|
|
157
|
+
warnings
|
|
158
|
+
);
|
|
159
|
+
mcpServers = mergeBundledMcpServers(mcpServers, nestedServers);
|
|
160
|
+
}
|
|
161
|
+
} catch (error) {
|
|
162
|
+
warnings.push(`[${ownerName}] Failed to read mcps/: ${String(error)}`);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return {
|
|
167
|
+
...mcpServers ? { mcpServers } : {},
|
|
168
|
+
warnings
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
export {
|
|
172
|
+
loadBundledMcpConfigFromDirectory
|
|
173
|
+
};
|
package/dist/mcp/index.cjs
CHANGED
|
@@ -3,6 +3,10 @@ var __defProp = Object.defineProperty;
|
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
6
10
|
var __copyProps = (to, from, except, desc) => {
|
|
7
11
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
12
|
for (let key of __getOwnPropNames(from))
|
|
@@ -11,24 +15,48 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
11
15
|
}
|
|
12
16
|
return to;
|
|
13
17
|
};
|
|
14
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
19
|
var mcp_exports = {};
|
|
20
|
+
__export(mcp_exports, {
|
|
21
|
+
DEFAULT_MCP_CONNECTION_MODE: () => import_schemas.DEFAULT_MCP_CONNECTION_MODE,
|
|
22
|
+
DextoMcpClient: () => import_mcp_client.DextoMcpClient,
|
|
23
|
+
HttpServerConfigSchema: () => import_schemas.HttpServerConfigSchema,
|
|
24
|
+
MCPError: () => import_errors.MCPError,
|
|
25
|
+
MCPErrorCode: () => import_error_codes.MCPErrorCode,
|
|
26
|
+
MCPManager: () => import_manager.MCPManager,
|
|
27
|
+
MCP_CONNECTION_MODES: () => import_schemas.MCP_CONNECTION_MODES,
|
|
28
|
+
MCP_CONNECTION_STATUSES: () => import_schemas.MCP_CONNECTION_STATUSES,
|
|
29
|
+
MCP_SERVER_TYPES: () => import_schemas.MCP_SERVER_TYPES,
|
|
30
|
+
McpServerConfigSchema: () => import_schemas.McpServerConfigSchema,
|
|
31
|
+
ServersConfigSchema: () => import_schemas.ServersConfigSchema,
|
|
32
|
+
SseServerConfigSchema: () => import_schemas.SseServerConfigSchema,
|
|
33
|
+
StdioServerConfigSchema: () => import_schemas.StdioServerConfigSchema,
|
|
34
|
+
loadBundledMcpConfigFromDirectory: () => import_bundled_config.loadBundledMcpConfigFromDirectory,
|
|
35
|
+
resolveAndValidateMcpServerConfig: () => import_resolver.resolveAndValidateMcpServerConfig
|
|
36
|
+
});
|
|
17
37
|
module.exports = __toCommonJS(mcp_exports);
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
38
|
+
var import_manager = require("./manager.js");
|
|
39
|
+
var import_mcp_client = require("./mcp-client.js");
|
|
40
|
+
var import_schemas = require("./schemas.js");
|
|
41
|
+
var import_errors = require("./errors.js");
|
|
42
|
+
var import_error_codes = require("./error-codes.js");
|
|
43
|
+
var import_resolver = require("./resolver.js");
|
|
44
|
+
var import_bundled_config = require("./bundled-config.js");
|
|
25
45
|
// Annotate the CommonJS export names for ESM import in node:
|
|
26
46
|
0 && (module.exports = {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
47
|
+
DEFAULT_MCP_CONNECTION_MODE,
|
|
48
|
+
DextoMcpClient,
|
|
49
|
+
HttpServerConfigSchema,
|
|
50
|
+
MCPError,
|
|
51
|
+
MCPErrorCode,
|
|
52
|
+
MCPManager,
|
|
53
|
+
MCP_CONNECTION_MODES,
|
|
54
|
+
MCP_CONNECTION_STATUSES,
|
|
55
|
+
MCP_SERVER_TYPES,
|
|
56
|
+
McpServerConfigSchema,
|
|
57
|
+
ServersConfigSchema,
|
|
58
|
+
SseServerConfigSchema,
|
|
59
|
+
StdioServerConfigSchema,
|
|
60
|
+
loadBundledMcpConfigFromDirectory,
|
|
61
|
+
resolveAndValidateMcpServerConfig
|
|
34
62
|
});
|
package/dist/mcp/index.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
1
|
+
export { MCPManager } from './manager.js';
|
|
2
|
+
export { DextoMcpClient } from './mcp-client.js';
|
|
3
|
+
export type { McpAuthProvider, McpAuthProviderFactory, MCPResourceSummary, MCPResolvedResource, McpClient, } from './types.js';
|
|
4
|
+
export { MCP_SERVER_TYPES, MCP_CONNECTION_MODES, MCP_CONNECTION_STATUSES, DEFAULT_MCP_CONNECTION_MODE, StdioServerConfigSchema, SseServerConfigSchema, HttpServerConfigSchema, McpServerConfigSchema, ServersConfigSchema, } from './schemas.js';
|
|
5
|
+
export type { McpServerType, McpConnectionMode, McpConnectionStatus, McpServerStatus, StdioServerConfig, ValidatedStdioServerConfig, SseServerConfig, ValidatedSseServerConfig, HttpServerConfig, ValidatedHttpServerConfig, McpServerConfig, ValidatedMcpServerConfig, ServersConfig, ValidatedServersConfig, } from './schemas.js';
|
|
6
|
+
export { MCPError } from './errors.js';
|
|
7
|
+
export { MCPErrorCode } from './error-codes.js';
|
|
8
|
+
export { resolveAndValidateMcpServerConfig } from './resolver.js';
|
|
9
|
+
export type { McpServerContext } from './resolver.js';
|
|
10
|
+
export { loadBundledMcpConfigFromDirectory } from './bundled-config.js';
|
|
11
|
+
export type { LoadBundledMcpConfigOptions, LoadBundledMcpConfigResult } from './bundled-config.js';
|
|
8
12
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/mcp/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,YAAY,EACR,eAAe,EACf,sBAAsB,EACtB,kBAAkB,EAClB,mBAAmB,EACnB,SAAS,GACZ,MAAM,YAAY,CAAC;AACpB,OAAO,EACH,gBAAgB,EAChB,oBAAoB,EACpB,uBAAuB,EACvB,2BAA2B,EAC3B,uBAAuB,EACvB,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,mBAAmB,GACtB,MAAM,cAAc,CAAC;AACtB,YAAY,EACR,aAAa,EACb,iBAAiB,EACjB,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EACjB,0BAA0B,EAC1B,eAAe,EACf,wBAAwB,EACxB,gBAAgB,EAChB,yBAAyB,EACzB,eAAe,EACf,wBAAwB,EACxB,aAAa,EACb,sBAAsB,GACzB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,iCAAiC,EAAE,MAAM,eAAe,CAAC;AAClE,YAAY,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,iCAAiC,EAAE,MAAM,qBAAqB,CAAC;AACxE,YAAY,EAAE,2BAA2B,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC"}
|
package/dist/mcp/index.js
CHANGED
|
@@ -1,7 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import "../chunk-PTJYTZNU.js";
|
|
2
|
+
import { MCPManager } from "./manager.js";
|
|
3
|
+
import { DextoMcpClient } from "./mcp-client.js";
|
|
4
|
+
import {
|
|
5
|
+
MCP_SERVER_TYPES,
|
|
6
|
+
MCP_CONNECTION_MODES,
|
|
7
|
+
MCP_CONNECTION_STATUSES,
|
|
8
|
+
DEFAULT_MCP_CONNECTION_MODE,
|
|
9
|
+
StdioServerConfigSchema,
|
|
10
|
+
SseServerConfigSchema,
|
|
11
|
+
HttpServerConfigSchema,
|
|
12
|
+
McpServerConfigSchema,
|
|
13
|
+
ServersConfigSchema
|
|
14
|
+
} from "./schemas.js";
|
|
15
|
+
import { MCPError } from "./errors.js";
|
|
16
|
+
import { MCPErrorCode } from "./error-codes.js";
|
|
17
|
+
import { resolveAndValidateMcpServerConfig } from "./resolver.js";
|
|
18
|
+
import { loadBundledMcpConfigFromDirectory } from "./bundled-config.js";
|
|
19
|
+
export {
|
|
20
|
+
DEFAULT_MCP_CONNECTION_MODE,
|
|
21
|
+
DextoMcpClient,
|
|
22
|
+
HttpServerConfigSchema,
|
|
23
|
+
MCPError,
|
|
24
|
+
MCPErrorCode,
|
|
25
|
+
MCPManager,
|
|
26
|
+
MCP_CONNECTION_MODES,
|
|
27
|
+
MCP_CONNECTION_STATUSES,
|
|
28
|
+
MCP_SERVER_TYPES,
|
|
29
|
+
McpServerConfigSchema,
|
|
30
|
+
ServersConfigSchema,
|
|
31
|
+
SseServerConfigSchema,
|
|
32
|
+
StdioServerConfigSchema,
|
|
33
|
+
loadBundledMcpConfigFromDirectory,
|
|
34
|
+
resolveAndValidateMcpServerConfig
|
|
35
|
+
};
|
|
@@ -26,6 +26,7 @@ var import_types = require("../../logger/v2/types.js");
|
|
|
26
26
|
var import_errors = require("../errors.js");
|
|
27
27
|
var import_utils = require("../utils.js");
|
|
28
28
|
var import_name_validation = require("../name-validation.js");
|
|
29
|
+
var import_bundled_config = require("../../mcp/bundled-config.js");
|
|
29
30
|
var import_promises = require("fs/promises");
|
|
30
31
|
var import_fs = require("fs");
|
|
31
32
|
var import_path = require("path");
|
|
@@ -223,6 +224,16 @@ class ConfigPromptProvider {
|
|
|
223
224
|
const model = prompt.model ?? parsed.model;
|
|
224
225
|
const context = prompt.context ?? parsed.context;
|
|
225
226
|
const agent = prompt.agent ?? parsed.agent;
|
|
227
|
+
const bundledMcpResult = (0, import_bundled_config.loadBundledMcpConfigFromDirectory)(
|
|
228
|
+
(0, import_path.dirname)(filePath),
|
|
229
|
+
parsed.id,
|
|
230
|
+
{
|
|
231
|
+
scanNestedMcps: true
|
|
232
|
+
}
|
|
233
|
+
);
|
|
234
|
+
for (const warning of bundledMcpResult.warnings) {
|
|
235
|
+
this.logger.warn(warning);
|
|
236
|
+
}
|
|
226
237
|
const displayName = parsed.id;
|
|
227
238
|
const promptName = prompt.namespace ? `config:${prompt.namespace}:${parsed.id}` : `config:${parsed.id}`;
|
|
228
239
|
const promptInfo = {
|
|
@@ -248,7 +259,10 @@ class ConfigPromptProvider {
|
|
|
248
259
|
showInStarters: prompt.showInStarters,
|
|
249
260
|
originalId: parsed.id,
|
|
250
261
|
...prompt.namespace && { namespace: prompt.namespace },
|
|
251
|
-
...parsed.toolkits !== void 0 && { toolkits: parsed.toolkits }
|
|
262
|
+
...parsed.toolkits !== void 0 && { toolkits: parsed.toolkits },
|
|
263
|
+
...bundledMcpResult.mcpServers !== void 0 && {
|
|
264
|
+
mcpServers: bundledMcpResult.mcpServers
|
|
265
|
+
}
|
|
252
266
|
}
|
|
253
267
|
};
|
|
254
268
|
return { info: promptInfo, content: parsed.content };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-prompt-provider.d.ts","sourceRoot":"","sources":["../../../src/prompts/providers/config-prompt-provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAc,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAClG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,KAAK,EAA4B,aAAa,EAAE,MAAM,eAAe,CAAC;AAE7E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"config-prompt-provider.d.ts","sourceRoot":"","sources":["../../../src/prompts/providers/config-prompt-provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAc,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAClG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,KAAK,EAA4B,aAAa,EAAE,MAAM,eAAe,CAAC;AAE7E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAUvD;;;;;;;;GAQG;AACH,qBAAa,oBAAqB,YAAW,cAAc;IACvD,OAAO,CAAC,OAAO,CAAqB;IACpC,OAAO,CAAC,YAAY,CAAoB;IACxC,OAAO,CAAC,aAAa,CAAkC;IACvD,OAAO,CAAC,UAAU,CAAkB;IACpC,OAAO,CAAC,MAAM,CAAS;gBAEX,WAAW,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM;IAM7D,SAAS,IAAI,MAAM;IAInB,eAAe,IAAI,IAAI;IAOvB,aAAa,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI;IAYrC,WAAW,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAUxD,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC;IAgCjF,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC;YAgC3D,iBAAiB;IAsC/B,OAAO,CAAC,mBAAmB;YA8Bb,iBAAiB;IAgH/B,OAAO,CAAC,mBAAmB;IAuL3B,OAAO,CAAC,iBAAiB;IAyBzB,OAAO,CAAC,cAAc;CA+BzB"}
|
|
@@ -4,6 +4,7 @@ import { DextoLogComponent } from "../../logger/v2/types.js";
|
|
|
4
4
|
import { PromptError } from "../errors.js";
|
|
5
5
|
import { expandPlaceholders } from "../utils.js";
|
|
6
6
|
import { assertValidPromptName } from "../name-validation.js";
|
|
7
|
+
import { loadBundledMcpConfigFromDirectory } from "../../mcp/bundled-config.js";
|
|
7
8
|
import { readFile, realpath } from "fs/promises";
|
|
8
9
|
import { existsSync } from "fs";
|
|
9
10
|
import { basename, dirname, relative, sep } from "path";
|
|
@@ -201,6 +202,16 @@ class ConfigPromptProvider {
|
|
|
201
202
|
const model = prompt.model ?? parsed.model;
|
|
202
203
|
const context = prompt.context ?? parsed.context;
|
|
203
204
|
const agent = prompt.agent ?? parsed.agent;
|
|
205
|
+
const bundledMcpResult = loadBundledMcpConfigFromDirectory(
|
|
206
|
+
dirname(filePath),
|
|
207
|
+
parsed.id,
|
|
208
|
+
{
|
|
209
|
+
scanNestedMcps: true
|
|
210
|
+
}
|
|
211
|
+
);
|
|
212
|
+
for (const warning of bundledMcpResult.warnings) {
|
|
213
|
+
this.logger.warn(warning);
|
|
214
|
+
}
|
|
204
215
|
const displayName = parsed.id;
|
|
205
216
|
const promptName = prompt.namespace ? `config:${prompt.namespace}:${parsed.id}` : `config:${parsed.id}`;
|
|
206
217
|
const promptInfo = {
|
|
@@ -226,7 +237,10 @@ class ConfigPromptProvider {
|
|
|
226
237
|
showInStarters: prompt.showInStarters,
|
|
227
238
|
originalId: parsed.id,
|
|
228
239
|
...prompt.namespace && { namespace: prompt.namespace },
|
|
229
|
-
...parsed.toolkits !== void 0 && { toolkits: parsed.toolkits }
|
|
240
|
+
...parsed.toolkits !== void 0 && { toolkits: parsed.toolkits },
|
|
241
|
+
...bundledMcpResult.mcpServers !== void 0 && {
|
|
242
|
+
mcpServers: bundledMcpResult.mcpServers
|
|
243
|
+
}
|
|
230
244
|
}
|
|
231
245
|
};
|
|
232
246
|
return { info: promptInfo, content: parsed.content };
|