@frontmcp/sdk 1.0.0 → 1.0.2
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/direct/client.types.d.ts +33 -0
- package/direct/client.types.d.ts.map +1 -1
- package/direct/index.d.ts +1 -1
- package/direct/index.d.ts.map +1 -1
- package/esm/index.mjs +411 -157
- package/front-mcp/front-mcp.d.ts.map +1 -1
- package/index.js +400 -146
- package/logger/instances/instance.file-logger.d.ts +31 -0
- package/logger/instances/instance.file-logger.d.ts.map +1 -0
- package/package.json +9 -9
- package/skill/skill.instance.d.ts +5 -0
- package/skill/skill.instance.d.ts.map +1 -1
package/esm/index.mjs
CHANGED
|
@@ -3131,8 +3131,8 @@ var init_job_metadata = __esm({
|
|
|
3131
3131
|
|
|
3132
3132
|
// libs/sdk/src/common/metadata/workflow.metadata.ts
|
|
3133
3133
|
import { z as z34 } from "zod";
|
|
3134
|
-
function isValidWebhookPath(
|
|
3135
|
-
return WEBHOOK_PATH_PATTERN.test(
|
|
3134
|
+
function isValidWebhookPath(path2) {
|
|
3135
|
+
return WEBHOOK_PATH_PATTERN.test(path2);
|
|
3136
3136
|
}
|
|
3137
3137
|
var workflowStepSchema, WEBHOOK_PATH_PATTERN, workflowWebhookConfigSchema, frontMcpWorkflowMetadataSchema;
|
|
3138
3138
|
var init_workflow_metadata = __esm({
|
|
@@ -4420,8 +4420,8 @@ var init_sdk_errors = __esm({
|
|
|
4420
4420
|
}
|
|
4421
4421
|
};
|
|
4422
4422
|
ConfigNotFoundError = class extends InternalMcpError {
|
|
4423
|
-
constructor(
|
|
4424
|
-
const msg = triedPaths?.length ? `Config not found at "${
|
|
4423
|
+
constructor(path2, triedPaths) {
|
|
4424
|
+
const msg = triedPaths?.length ? `Config not found at "${path2}". Tried: ${triedPaths.join(", ")}` : `Config not found at "${path2}"`;
|
|
4425
4425
|
super(msg, "CONFIG_NOT_FOUND");
|
|
4426
4426
|
}
|
|
4427
4427
|
};
|
|
@@ -4486,8 +4486,8 @@ var init_sdk_errors = __esm({
|
|
|
4486
4486
|
}
|
|
4487
4487
|
};
|
|
4488
4488
|
AgentConfigKeyNotFoundError = class extends InternalMcpError {
|
|
4489
|
-
constructor(
|
|
4490
|
-
super(`Agent config key not found: "${
|
|
4489
|
+
constructor(path2) {
|
|
4490
|
+
super(`Agent config key not found: "${path2}"`, "AGENT_CONFIG_KEY_NOT_FOUND");
|
|
4491
4491
|
}
|
|
4492
4492
|
};
|
|
4493
4493
|
AgentToolExecutionError = class extends InternalMcpError {
|
|
@@ -4514,8 +4514,8 @@ var init_sdk_errors = __esm({
|
|
|
4514
4514
|
}
|
|
4515
4515
|
};
|
|
4516
4516
|
RequiredConfigUndefinedError = class extends InternalMcpError {
|
|
4517
|
-
constructor(
|
|
4518
|
-
super(`Required configuration path "${
|
|
4517
|
+
constructor(path2) {
|
|
4518
|
+
super(`Required configuration path "${path2}" is undefined`, "REQUIRED_CONFIG_UNDEFINED");
|
|
4519
4519
|
}
|
|
4520
4520
|
};
|
|
4521
4521
|
RegistryNotInitializedError = class extends InternalMcpError {
|
|
@@ -5693,8 +5693,8 @@ ${formattedErrors}`);
|
|
|
5693
5693
|
constructor(config) {
|
|
5694
5694
|
this.config = config;
|
|
5695
5695
|
}
|
|
5696
|
-
get(
|
|
5697
|
-
const keys =
|
|
5696
|
+
get(path2, defaultValue) {
|
|
5697
|
+
const keys = path2.split(".");
|
|
5698
5698
|
let result = this.config;
|
|
5699
5699
|
for (const key of keys) {
|
|
5700
5700
|
if (result && typeof result === "object" && key in result) {
|
|
@@ -5715,18 +5715,18 @@ ${formattedErrors}`);
|
|
|
5715
5715
|
* @example
|
|
5716
5716
|
* config.getOrThrow('database.url') // string (throws if missing)
|
|
5717
5717
|
*/
|
|
5718
|
-
getOrThrow(
|
|
5719
|
-
const value = this.get(
|
|
5718
|
+
getOrThrow(path2) {
|
|
5719
|
+
const value = this.get(path2);
|
|
5720
5720
|
if (value === void 0) {
|
|
5721
|
-
throw new ConfigMissingError(
|
|
5721
|
+
throw new ConfigMissingError(path2);
|
|
5722
5722
|
}
|
|
5723
5723
|
return value;
|
|
5724
5724
|
}
|
|
5725
5725
|
/**
|
|
5726
5726
|
* Alias for getOrThrow.
|
|
5727
5727
|
*/
|
|
5728
|
-
getRequired(
|
|
5729
|
-
return this.getOrThrow(
|
|
5728
|
+
getRequired(path2) {
|
|
5729
|
+
return this.getOrThrow(path2);
|
|
5730
5730
|
}
|
|
5731
5731
|
/**
|
|
5732
5732
|
* Check if a configuration path exists and has a value.
|
|
@@ -5734,8 +5734,8 @@ ${formattedErrors}`);
|
|
|
5734
5734
|
* @param path - Dot notation path (e.g., 'database.url')
|
|
5735
5735
|
* @returns True if path exists and has a defined value
|
|
5736
5736
|
*/
|
|
5737
|
-
has(
|
|
5738
|
-
const keys =
|
|
5737
|
+
has(path2) {
|
|
5738
|
+
const keys = path2.split(".");
|
|
5739
5739
|
let result = this.config;
|
|
5740
5740
|
for (const key of keys) {
|
|
5741
5741
|
if (result && typeof result === "object" && key in result) {
|
|
@@ -5767,8 +5767,8 @@ ${formattedErrors}`);
|
|
|
5767
5767
|
* @param defaultValue - Default value if not found or not a number
|
|
5768
5768
|
* @returns Number value or NaN
|
|
5769
5769
|
*/
|
|
5770
|
-
getNumber(
|
|
5771
|
-
const value = this.get(
|
|
5770
|
+
getNumber(path2, defaultValue) {
|
|
5771
|
+
const value = this.get(path2);
|
|
5772
5772
|
if (value === void 0) {
|
|
5773
5773
|
return defaultValue ?? NaN;
|
|
5774
5774
|
}
|
|
@@ -5786,8 +5786,8 @@ ${formattedErrors}`);
|
|
|
5786
5786
|
* @param defaultValue - Default value if not found
|
|
5787
5787
|
* @returns Boolean value
|
|
5788
5788
|
*/
|
|
5789
|
-
getBoolean(
|
|
5790
|
-
const value = this.get(
|
|
5789
|
+
getBoolean(path2, defaultValue) {
|
|
5790
|
+
const value = this.get(path2);
|
|
5791
5791
|
if (value === void 0) {
|
|
5792
5792
|
return defaultValue ?? false;
|
|
5793
5793
|
}
|
|
@@ -6417,22 +6417,22 @@ var init_provider_registry = __esm({
|
|
|
6417
6417
|
const WHITE = 0, GRAY = 1, BLACK = 2;
|
|
6418
6418
|
const color = /* @__PURE__ */ new Map();
|
|
6419
6419
|
const order = /* @__PURE__ */ new Set();
|
|
6420
|
-
const
|
|
6420
|
+
const path2 = [];
|
|
6421
6421
|
const dfs = (n) => {
|
|
6422
6422
|
color.set(n, GRAY);
|
|
6423
|
-
|
|
6423
|
+
path2.push(n);
|
|
6424
6424
|
for (const dep of this.graph.get(n) ?? []) {
|
|
6425
6425
|
const c = color.get(dep) ?? WHITE;
|
|
6426
6426
|
if (c === GRAY) {
|
|
6427
|
-
const idx =
|
|
6428
|
-
const cycle = [...
|
|
6427
|
+
const idx = path2.findIndex((p) => p === dep);
|
|
6428
|
+
const cycle = [...path2.slice(idx), dep].map((t) => tokenName2(t)).join(" -> ");
|
|
6429
6429
|
throw new DependencyCycleError(cycle);
|
|
6430
6430
|
}
|
|
6431
6431
|
if (c === WHITE) dfs(dep);
|
|
6432
6432
|
}
|
|
6433
6433
|
color.set(n, BLACK);
|
|
6434
6434
|
order.add(n);
|
|
6435
|
-
|
|
6435
|
+
path2.pop();
|
|
6436
6436
|
};
|
|
6437
6437
|
for (const n of this.graph.keys()) if ((color.get(n) ?? WHITE) === WHITE) dfs(n);
|
|
6438
6438
|
this.order = order;
|
|
@@ -14928,11 +14928,63 @@ var init_skill_utils = __esm({
|
|
|
14928
14928
|
});
|
|
14929
14929
|
|
|
14930
14930
|
// libs/sdk/src/skill/skill.instance.ts
|
|
14931
|
-
import { dirname, pathResolve } from "@frontmcp/utils";
|
|
14931
|
+
import { dirname, pathResolve, pathJoin, fileExists as fileExists2, readJSON } from "@frontmcp/utils";
|
|
14932
14932
|
function createSkillInstance(record, providers, owner) {
|
|
14933
14933
|
return new SkillInstance(record, providers, owner);
|
|
14934
14934
|
}
|
|
14935
|
-
|
|
14935
|
+
async function loadResourceWithManifestFallback(resourcePath, baseDir, skillName, resourceType, loader) {
|
|
14936
|
+
if (!resourcePath) return void 0;
|
|
14937
|
+
let dir = resourcePath.startsWith("/") ? resourcePath : baseDir ? pathResolve(baseDir, resourcePath) : void 0;
|
|
14938
|
+
if (dir) {
|
|
14939
|
+
try {
|
|
14940
|
+
return await loader(dir);
|
|
14941
|
+
} catch (err) {
|
|
14942
|
+
if (err.code !== "ENOENT") throw err;
|
|
14943
|
+
dir = await resolveResourceFromManifest(skillName, resourceType);
|
|
14944
|
+
if (dir) return await loader(dir);
|
|
14945
|
+
}
|
|
14946
|
+
} else {
|
|
14947
|
+
dir = await resolveResourceFromManifest(skillName, resourceType);
|
|
14948
|
+
if (dir) return await loader(dir);
|
|
14949
|
+
}
|
|
14950
|
+
return void 0;
|
|
14951
|
+
}
|
|
14952
|
+
async function resolveFromSkillManifest(skillName) {
|
|
14953
|
+
if (skillManifestCache === null) return void 0;
|
|
14954
|
+
if (skillManifestCache === void 0) {
|
|
14955
|
+
try {
|
|
14956
|
+
const mainDir2 = __require.main?.filename ? dirname(__require.main.filename) : process.cwd();
|
|
14957
|
+
const manifestPath = pathJoin(mainDir2, "_skills", "manifest.json");
|
|
14958
|
+
if (await fileExists2(manifestPath)) {
|
|
14959
|
+
skillManifestCache = await readJSON(manifestPath);
|
|
14960
|
+
} else {
|
|
14961
|
+
skillManifestCache = null;
|
|
14962
|
+
return void 0;
|
|
14963
|
+
}
|
|
14964
|
+
} catch (err) {
|
|
14965
|
+
if (err.code === "ENOENT") {
|
|
14966
|
+
skillManifestCache = null;
|
|
14967
|
+
return void 0;
|
|
14968
|
+
}
|
|
14969
|
+
throw err;
|
|
14970
|
+
}
|
|
14971
|
+
}
|
|
14972
|
+
if (!skillManifestCache) return void 0;
|
|
14973
|
+
const entry = skillManifestCache[skillName];
|
|
14974
|
+
if (!entry?.instructions) return void 0;
|
|
14975
|
+
const mainDir = __require.main?.filename ? dirname(__require.main.filename) : process.cwd();
|
|
14976
|
+
return pathResolve(mainDir, entry.instructions);
|
|
14977
|
+
}
|
|
14978
|
+
async function resolveResourceFromManifest(skillName, resourceType) {
|
|
14979
|
+
await resolveFromSkillManifest(skillName);
|
|
14980
|
+
if (!skillManifestCache) return void 0;
|
|
14981
|
+
const entry = skillManifestCache[skillName];
|
|
14982
|
+
const relPath = entry?.[resourceType];
|
|
14983
|
+
if (!relPath) return void 0;
|
|
14984
|
+
const mainDir = __require.main?.filename ? dirname(__require.main.filename) : process.cwd();
|
|
14985
|
+
return pathResolve(mainDir, relPath);
|
|
14986
|
+
}
|
|
14987
|
+
var SkillInstance, skillManifestCache;
|
|
14936
14988
|
var init_skill_instance = __esm({
|
|
14937
14989
|
"libs/sdk/src/skill/skill.instance.ts"() {
|
|
14938
14990
|
"use strict";
|
|
@@ -14993,7 +15045,20 @@ var init_skill_instance = __esm({
|
|
|
14993
15045
|
} else if (this.record.kind === "VALUE" /* VALUE */ && this.record.callerDir) {
|
|
14994
15046
|
basePath = this.record.callerDir;
|
|
14995
15047
|
}
|
|
14996
|
-
|
|
15048
|
+
try {
|
|
15049
|
+
this.cachedInstructions = await loadInstructions(this.metadata.instructions, basePath);
|
|
15050
|
+
} catch (err) {
|
|
15051
|
+
if (err.code === "ENOENT") {
|
|
15052
|
+
const resolved = await resolveFromSkillManifest(this.metadata.name);
|
|
15053
|
+
if (resolved) {
|
|
15054
|
+
this.cachedInstructions = await loadInstructions({ file: resolved }, void 0);
|
|
15055
|
+
} else {
|
|
15056
|
+
throw err;
|
|
15057
|
+
}
|
|
15058
|
+
} else {
|
|
15059
|
+
throw err;
|
|
15060
|
+
}
|
|
15061
|
+
}
|
|
14997
15062
|
return this.cachedInstructions;
|
|
14998
15063
|
}
|
|
14999
15064
|
/**
|
|
@@ -15018,22 +15083,20 @@ var init_skill_instance = __esm({
|
|
|
15018
15083
|
}
|
|
15019
15084
|
const instructions = await this.loadInstructions();
|
|
15020
15085
|
const baseDir = this.getBaseDir();
|
|
15021
|
-
const
|
|
15022
|
-
|
|
15023
|
-
|
|
15024
|
-
|
|
15025
|
-
|
|
15026
|
-
|
|
15027
|
-
|
|
15028
|
-
|
|
15029
|
-
|
|
15030
|
-
|
|
15031
|
-
|
|
15032
|
-
|
|
15033
|
-
|
|
15034
|
-
|
|
15035
|
-
}
|
|
15036
|
-
}
|
|
15086
|
+
const resolvedRefs = await loadResourceWithManifestFallback(
|
|
15087
|
+
this.metadata.resources?.references,
|
|
15088
|
+
baseDir,
|
|
15089
|
+
this.metadata.name,
|
|
15090
|
+
"references",
|
|
15091
|
+
resolveReferences
|
|
15092
|
+
);
|
|
15093
|
+
const resolvedExs = await loadResourceWithManifestFallback(
|
|
15094
|
+
this.metadata.resources?.examples,
|
|
15095
|
+
baseDir,
|
|
15096
|
+
this.metadata.name,
|
|
15097
|
+
"examples",
|
|
15098
|
+
resolveExamples
|
|
15099
|
+
);
|
|
15037
15100
|
const baseContent = buildSkillContent(this.metadata, instructions, resolvedRefs, resolvedExs);
|
|
15038
15101
|
this.cachedContent = {
|
|
15039
15102
|
...baseContent,
|
|
@@ -17963,8 +18026,8 @@ function generateEnvFallbacks(key, context) {
|
|
|
17963
18026
|
];
|
|
17964
18027
|
}
|
|
17965
18028
|
function resolveWithFallbacks(config, paths) {
|
|
17966
|
-
for (const
|
|
17967
|
-
const value = config.get(
|
|
18029
|
+
for (const path2 of paths) {
|
|
18030
|
+
const value = config.get(path2);
|
|
17968
18031
|
if (value !== void 0) {
|
|
17969
18032
|
return value;
|
|
17970
18033
|
}
|
|
@@ -17973,31 +18036,31 @@ function resolveWithFallbacks(config, paths) {
|
|
|
17973
18036
|
}
|
|
17974
18037
|
function createContextResolver(config, context) {
|
|
17975
18038
|
return {
|
|
17976
|
-
get(
|
|
17977
|
-
const fallbacks = generateFallbacks(
|
|
18039
|
+
get(path2) {
|
|
18040
|
+
const fallbacks = generateFallbacks(path2, context);
|
|
17978
18041
|
const value = resolveWithFallbacks(config, fallbacks);
|
|
17979
18042
|
if (value === void 0) {
|
|
17980
|
-
throw new ConfigNotFoundError(
|
|
18043
|
+
throw new ConfigNotFoundError(path2, fallbacks);
|
|
17981
18044
|
}
|
|
17982
18045
|
return value;
|
|
17983
18046
|
},
|
|
17984
|
-
tryGet(
|
|
17985
|
-
const fallbacks = generateFallbacks(
|
|
18047
|
+
tryGet(path2) {
|
|
18048
|
+
const fallbacks = generateFallbacks(path2, context);
|
|
17986
18049
|
return resolveWithFallbacks(config, fallbacks);
|
|
17987
18050
|
}
|
|
17988
18051
|
};
|
|
17989
18052
|
}
|
|
17990
18053
|
function createDirectResolver(config) {
|
|
17991
18054
|
return {
|
|
17992
|
-
get(
|
|
17993
|
-
const value = config.get(
|
|
18055
|
+
get(path2) {
|
|
18056
|
+
const value = config.get(path2);
|
|
17994
18057
|
if (value === void 0) {
|
|
17995
|
-
throw new ConfigNotFoundError(
|
|
18058
|
+
throw new ConfigNotFoundError(path2);
|
|
17996
18059
|
}
|
|
17997
18060
|
return value;
|
|
17998
18061
|
},
|
|
17999
|
-
tryGet(
|
|
18000
|
-
return config.get(
|
|
18062
|
+
tryGet(path2) {
|
|
18063
|
+
return config.get(path2);
|
|
18001
18064
|
}
|
|
18002
18065
|
};
|
|
18003
18066
|
}
|
|
@@ -18021,8 +18084,8 @@ function resolveWithConfigValue(withConfig2, configResolver, entityContext) {
|
|
|
18021
18084
|
} else {
|
|
18022
18085
|
paths = [withConfig2.configPath];
|
|
18023
18086
|
}
|
|
18024
|
-
for (const
|
|
18025
|
-
const value = configResolver.tryGet(
|
|
18087
|
+
for (const path2 of paths) {
|
|
18088
|
+
const value = configResolver.tryGet(path2);
|
|
18026
18089
|
if (value !== void 0) {
|
|
18027
18090
|
return withConfig2.transform ? withConfig2.transform(value) : value;
|
|
18028
18091
|
}
|
|
@@ -18205,7 +18268,7 @@ var init_config_symbols = __esm({
|
|
|
18205
18268
|
});
|
|
18206
18269
|
|
|
18207
18270
|
// libs/sdk/src/builtin/config/providers/env-loader.ts
|
|
18208
|
-
import { readFile as readFile3, fileExists as
|
|
18271
|
+
import { readFile as readFile3, fileExists as fileExists3, getCwd, getEnv as getEnv2, setEnv, pathResolve as pathResolve2 } from "@frontmcp/utils";
|
|
18209
18272
|
function parseEnvContent(content) {
|
|
18210
18273
|
const result = {};
|
|
18211
18274
|
const lines = content.split("\n");
|
|
@@ -18234,12 +18297,12 @@ function parseEnvContent(content) {
|
|
|
18234
18297
|
async function loadEnvFiles(basePath = getCwd(), envPath = ".env", localEnvPath = ".env.local") {
|
|
18235
18298
|
const result = {};
|
|
18236
18299
|
const envFile = pathResolve2(basePath, envPath);
|
|
18237
|
-
if (await
|
|
18300
|
+
if (await fileExists3(envFile)) {
|
|
18238
18301
|
const content = await readFile3(envFile);
|
|
18239
18302
|
Object.assign(result, parseEnvContent(content));
|
|
18240
18303
|
}
|
|
18241
18304
|
const localFile = pathResolve2(basePath, localEnvPath);
|
|
18242
|
-
if (await
|
|
18305
|
+
if (await fileExists3(localFile)) {
|
|
18243
18306
|
const content = await readFile3(localFile);
|
|
18244
18307
|
Object.assign(result, parseEnvContent(content));
|
|
18245
18308
|
}
|
|
@@ -18258,11 +18321,11 @@ function populateProcessEnv(env, override = false) {
|
|
|
18258
18321
|
function isSafeKey(key) {
|
|
18259
18322
|
return !UNSAFE_KEYS.has(key);
|
|
18260
18323
|
}
|
|
18261
|
-
function pathToEnvKey(
|
|
18262
|
-
return
|
|
18324
|
+
function pathToEnvKey(path2) {
|
|
18325
|
+
return path2.toUpperCase().replace(/\./g, "_");
|
|
18263
18326
|
}
|
|
18264
|
-
function setNestedValue(obj,
|
|
18265
|
-
const keys =
|
|
18327
|
+
function setNestedValue(obj, path2, value) {
|
|
18328
|
+
const keys = path2.split(".");
|
|
18266
18329
|
for (const key of keys) {
|
|
18267
18330
|
if (!isSafeKey(key)) {
|
|
18268
18331
|
return;
|
|
@@ -18285,8 +18348,8 @@ function setNestedValue(obj, path, value) {
|
|
|
18285
18348
|
}
|
|
18286
18349
|
current[finalKey] = value;
|
|
18287
18350
|
}
|
|
18288
|
-
function getNestedValue(obj,
|
|
18289
|
-
const keys =
|
|
18351
|
+
function getNestedValue(obj, path2) {
|
|
18352
|
+
const keys = path2.split(".");
|
|
18290
18353
|
for (const key of keys) {
|
|
18291
18354
|
if (!isSafeKey(key)) {
|
|
18292
18355
|
return void 0;
|
|
@@ -18341,11 +18404,11 @@ function unwrapZodType(schema) {
|
|
|
18341
18404
|
}
|
|
18342
18405
|
function mapEnvToNestedConfig(env, paths) {
|
|
18343
18406
|
const result = {};
|
|
18344
|
-
for (const
|
|
18345
|
-
const envKey = pathToEnvKey(
|
|
18407
|
+
for (const path2 of paths) {
|
|
18408
|
+
const envKey = pathToEnvKey(path2);
|
|
18346
18409
|
const value = env[envKey];
|
|
18347
18410
|
if (value !== void 0) {
|
|
18348
|
-
setNestedValue(result,
|
|
18411
|
+
setNestedValue(result, path2, value);
|
|
18349
18412
|
}
|
|
18350
18413
|
}
|
|
18351
18414
|
return result;
|
|
@@ -18360,7 +18423,7 @@ var init_env_loader = __esm({
|
|
|
18360
18423
|
|
|
18361
18424
|
// libs/sdk/src/builtin/config/providers/config-loader.ts
|
|
18362
18425
|
import * as yaml2 from "js-yaml";
|
|
18363
|
-
import { readFile as readFile4, fileExists as
|
|
18426
|
+
import { readFile as readFile4, fileExists as fileExists4, getCwd as getCwd2, pathResolve as pathResolve3 } from "@frontmcp/utils";
|
|
18364
18427
|
async function loadConfig(schema, options = {}) {
|
|
18365
18428
|
const {
|
|
18366
18429
|
basePath = getCwd2(),
|
|
@@ -18402,7 +18465,7 @@ async function loadYamlConfig(basePath, configPath) {
|
|
|
18402
18465
|
const baseName = configPath.replace(/\.(ya?ml)$/, "");
|
|
18403
18466
|
for (const ext of extensions) {
|
|
18404
18467
|
const fullPath = pathResolve3(basePath, baseName + ext);
|
|
18405
|
-
if (await
|
|
18468
|
+
if (await fileExists4(fullPath)) {
|
|
18406
18469
|
const content = await readFile4(fullPath);
|
|
18407
18470
|
const parsed = yaml2.load(content);
|
|
18408
18471
|
if (parsed && typeof parsed === "object") {
|
|
@@ -18893,8 +18956,8 @@ var init_flow_instance = __esm({
|
|
|
18893
18956
|
this.stages = collectFlowHookMap(this.FlowClass);
|
|
18894
18957
|
const { middleware } = this.metadata;
|
|
18895
18958
|
if (middleware) {
|
|
18896
|
-
const
|
|
18897
|
-
server.registerMiddleware(
|
|
18959
|
+
const path2 = typeof middleware.path === "string" ? middleware.path : "";
|
|
18960
|
+
server.registerMiddleware(path2, async (request, response, next) => {
|
|
18898
18961
|
const canActivate = await this.canActivate(request);
|
|
18899
18962
|
if (!canActivate) return next();
|
|
18900
18963
|
const contextStorage = this.getContextStorage();
|
|
@@ -19929,8 +19992,8 @@ var init_agent_instance = __esm({
|
|
|
19929
19992
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
19930
19993
|
createConfigResolver(configService) {
|
|
19931
19994
|
const config = configService.getAll();
|
|
19932
|
-
const getNestedValue2 = (
|
|
19933
|
-
const keys =
|
|
19995
|
+
const getNestedValue2 = (path2) => {
|
|
19996
|
+
const keys = path2.split(".");
|
|
19934
19997
|
let current = config;
|
|
19935
19998
|
for (const key of keys) {
|
|
19936
19999
|
if (current && typeof current === "object" && key in current) {
|
|
@@ -19942,15 +20005,15 @@ var init_agent_instance = __esm({
|
|
|
19942
20005
|
return current;
|
|
19943
20006
|
};
|
|
19944
20007
|
return {
|
|
19945
|
-
get(
|
|
19946
|
-
const value = getNestedValue2(
|
|
20008
|
+
get(path2) {
|
|
20009
|
+
const value = getNestedValue2(path2);
|
|
19947
20010
|
if (value === void 0) {
|
|
19948
|
-
throw new AgentConfigKeyNotFoundError(
|
|
20011
|
+
throw new AgentConfigKeyNotFoundError(path2);
|
|
19949
20012
|
}
|
|
19950
20013
|
return value;
|
|
19951
20014
|
},
|
|
19952
|
-
tryGet(
|
|
19953
|
-
return getNestedValue2(
|
|
20015
|
+
tryGet(path2) {
|
|
20016
|
+
return getNestedValue2(path2);
|
|
19954
20017
|
}
|
|
19955
20018
|
};
|
|
19956
20019
|
}
|
|
@@ -22935,21 +22998,21 @@ function getDefaultCacheDir() {
|
|
|
22935
22998
|
return "";
|
|
22936
22999
|
}
|
|
22937
23000
|
try {
|
|
22938
|
-
const
|
|
23001
|
+
const path2 = __require("node:path");
|
|
22939
23002
|
try {
|
|
22940
|
-
const nodeModulesDir =
|
|
22941
|
-
const
|
|
22942
|
-
if (
|
|
22943
|
-
return
|
|
23003
|
+
const nodeModulesDir = path2.join(process.cwd(), "node_modules");
|
|
23004
|
+
const fs2 = __require("node:fs");
|
|
23005
|
+
if (fs2.existsSync(nodeModulesDir)) {
|
|
23006
|
+
return path2.join(nodeModulesDir, ".cache", "frontmcp-esm");
|
|
22944
23007
|
}
|
|
22945
23008
|
} catch {
|
|
22946
23009
|
}
|
|
22947
23010
|
try {
|
|
22948
|
-
const
|
|
22949
|
-
return
|
|
23011
|
+
const os2 = __require("node:os");
|
|
23012
|
+
return path2.join(os2.homedir(), ".frontmcp", "esm-cache");
|
|
22950
23013
|
} catch {
|
|
22951
23014
|
}
|
|
22952
|
-
return
|
|
23015
|
+
return path2.join(__require("node:os").tmpdir?.() ?? "/tmp", ".frontmcp-esm-cache");
|
|
22953
23016
|
} catch {
|
|
22954
23017
|
return "";
|
|
22955
23018
|
}
|
|
@@ -22982,21 +23045,21 @@ var init_esm_cache = __esm({
|
|
|
22982
23045
|
}
|
|
22983
23046
|
if (!this.cacheDir) return void 0;
|
|
22984
23047
|
try {
|
|
22985
|
-
const
|
|
22986
|
-
const { fileExists:
|
|
23048
|
+
const path2 = __require("node:path");
|
|
23049
|
+
const { fileExists: fileExists8, readJSON: readJSON2 } = __require("@frontmcp/utils");
|
|
22987
23050
|
const entryDir = this.getEntryDir(packageName, version);
|
|
22988
|
-
const metaPath =
|
|
22989
|
-
if (!await
|
|
23051
|
+
const metaPath = path2.join(entryDir, "meta.json");
|
|
23052
|
+
if (!await fileExists8(metaPath)) {
|
|
22990
23053
|
return void 0;
|
|
22991
23054
|
}
|
|
22992
|
-
const meta = await
|
|
23055
|
+
const meta = await readJSON2(metaPath);
|
|
22993
23056
|
if (!meta) {
|
|
22994
23057
|
return void 0;
|
|
22995
23058
|
}
|
|
22996
23059
|
if (Date.now() - meta.cachedAt > this.maxAgeMs) {
|
|
22997
23060
|
return void 0;
|
|
22998
23061
|
}
|
|
22999
|
-
if (!await
|
|
23062
|
+
if (!await fileExists8(meta.bundlePath)) {
|
|
23000
23063
|
return void 0;
|
|
23001
23064
|
}
|
|
23002
23065
|
this.memoryStore.set(memKey, meta);
|
|
@@ -23016,12 +23079,12 @@ var init_esm_cache = __esm({
|
|
|
23016
23079
|
let bundlePath = "";
|
|
23017
23080
|
if (this.cacheDir) {
|
|
23018
23081
|
try {
|
|
23019
|
-
const
|
|
23082
|
+
const path2 = __require("node:path");
|
|
23020
23083
|
const { writeFile, ensureDir, writeJSON } = __require("@frontmcp/utils");
|
|
23021
23084
|
const entryDir = this.getEntryDir(packageName, version);
|
|
23022
23085
|
await ensureDir(entryDir);
|
|
23023
23086
|
const cachedBundle = toCachedBundle(bundleContent);
|
|
23024
|
-
bundlePath =
|
|
23087
|
+
bundlePath = path2.join(entryDir, cachedBundle.fileName);
|
|
23025
23088
|
await writeFile(bundlePath, cachedBundle.content);
|
|
23026
23089
|
const diskEntry = {
|
|
23027
23090
|
packageUrl,
|
|
@@ -23031,7 +23094,7 @@ var init_esm_cache = __esm({
|
|
|
23031
23094
|
bundlePath,
|
|
23032
23095
|
etag
|
|
23033
23096
|
};
|
|
23034
|
-
const metaPath =
|
|
23097
|
+
const metaPath = path2.join(entryDir, "meta.json");
|
|
23035
23098
|
await writeJSON(metaPath, diskEntry);
|
|
23036
23099
|
} catch {
|
|
23037
23100
|
}
|
|
@@ -23059,10 +23122,10 @@ var init_esm_cache = __esm({
|
|
|
23059
23122
|
}
|
|
23060
23123
|
if (!this.cacheDir) return;
|
|
23061
23124
|
try {
|
|
23062
|
-
const
|
|
23063
|
-
const { fileExists:
|
|
23125
|
+
const path2 = __require("node:path");
|
|
23126
|
+
const { fileExists: fileExists8, readJSON: readJSON2, rm } = __require("@frontmcp/utils");
|
|
23064
23127
|
const { readdir: readdir2 } = __require("@frontmcp/utils");
|
|
23065
|
-
if (!await
|
|
23128
|
+
if (!await fileExists8(this.cacheDir)) {
|
|
23066
23129
|
return;
|
|
23067
23130
|
}
|
|
23068
23131
|
let entries;
|
|
@@ -23072,11 +23135,11 @@ var init_esm_cache = __esm({
|
|
|
23072
23135
|
return;
|
|
23073
23136
|
}
|
|
23074
23137
|
for (const dirEntry of entries) {
|
|
23075
|
-
const metaPath =
|
|
23076
|
-
if (await
|
|
23077
|
-
const meta = await
|
|
23138
|
+
const metaPath = path2.join(this.cacheDir, dirEntry, "meta.json");
|
|
23139
|
+
if (await fileExists8(metaPath)) {
|
|
23140
|
+
const meta = await readJSON2(metaPath);
|
|
23078
23141
|
if (meta?.packageName === packageName) {
|
|
23079
|
-
await rm(
|
|
23142
|
+
await rm(path2.join(this.cacheDir, dirEntry), { recursive: true, force: true });
|
|
23080
23143
|
}
|
|
23081
23144
|
}
|
|
23082
23145
|
}
|
|
@@ -23098,10 +23161,10 @@ var init_esm_cache = __esm({
|
|
|
23098
23161
|
}
|
|
23099
23162
|
if (!this.cacheDir) return removed;
|
|
23100
23163
|
try {
|
|
23101
|
-
const
|
|
23102
|
-
const { fileExists:
|
|
23164
|
+
const path2 = __require("node:path");
|
|
23165
|
+
const { fileExists: fileExists8, readJSON: readJSON2, rm } = __require("@frontmcp/utils");
|
|
23103
23166
|
const { readdir: readdir2 } = __require("@frontmcp/utils");
|
|
23104
|
-
if (!await
|
|
23167
|
+
if (!await fileExists8(this.cacheDir)) {
|
|
23105
23168
|
return removed;
|
|
23106
23169
|
}
|
|
23107
23170
|
let entries;
|
|
@@ -23111,11 +23174,11 @@ var init_esm_cache = __esm({
|
|
|
23111
23174
|
return removed;
|
|
23112
23175
|
}
|
|
23113
23176
|
for (const dirEntry of entries) {
|
|
23114
|
-
const metaPath =
|
|
23115
|
-
if (await
|
|
23116
|
-
const meta = await
|
|
23177
|
+
const metaPath = path2.join(this.cacheDir, dirEntry, "meta.json");
|
|
23178
|
+
if (await fileExists8(metaPath)) {
|
|
23179
|
+
const meta = await readJSON2(metaPath);
|
|
23117
23180
|
if (meta && now - meta.cachedAt > threshold) {
|
|
23118
|
-
await rm(
|
|
23181
|
+
await rm(path2.join(this.cacheDir, dirEntry), { recursive: true, force: true });
|
|
23119
23182
|
removed++;
|
|
23120
23183
|
}
|
|
23121
23184
|
}
|
|
@@ -23138,9 +23201,9 @@ var init_esm_cache = __esm({
|
|
|
23138
23201
|
* Get the cache directory for a specific package+version combination.
|
|
23139
23202
|
*/
|
|
23140
23203
|
getEntryDir(packageName, version) {
|
|
23141
|
-
const
|
|
23204
|
+
const path2 = __require("node:path");
|
|
23142
23205
|
const hash = sha256Hex2(`${packageName}@${version}`);
|
|
23143
|
-
return
|
|
23206
|
+
return path2.join(this.cacheDir, hash);
|
|
23144
23207
|
}
|
|
23145
23208
|
};
|
|
23146
23209
|
}
|
|
@@ -25683,8 +25746,8 @@ var init_oauth_authorize_flow = __esm({
|
|
|
25683
25746
|
*/
|
|
25684
25747
|
formatZodErrors(error) {
|
|
25685
25748
|
return error.issues.map((err) => {
|
|
25686
|
-
const
|
|
25687
|
-
return `${
|
|
25749
|
+
const path2 = err.path.length > 0 ? `${err.path.join(".")}: ` : "";
|
|
25750
|
+
return `${path2}${err.message}`;
|
|
25688
25751
|
});
|
|
25689
25752
|
}
|
|
25690
25753
|
/**
|
|
@@ -35135,8 +35198,8 @@ var init_skills_api_flow = __esm({
|
|
|
35135
35198
|
const basePath = `${entryPrefix}${scopeBase}`;
|
|
35136
35199
|
const apiPath = options.normalizedApi.path ?? "/skills";
|
|
35137
35200
|
const fullPath = `${basePath}${apiPath}`;
|
|
35138
|
-
const
|
|
35139
|
-
return
|
|
35201
|
+
const path2 = request.path;
|
|
35202
|
+
return path2 === apiPath || path2.startsWith(`${apiPath}/`) || path2 === fullPath || path2.startsWith(`${fullPath}/`);
|
|
35140
35203
|
}
|
|
35141
35204
|
async checkEnabled() {
|
|
35142
35205
|
const skillsConfig = this.scope.metadata.skillsConfig;
|
|
@@ -35180,11 +35243,11 @@ var init_skills_api_flow = __esm({
|
|
|
35180
35243
|
const apiPath = options.normalizedApi.path ?? "/skills";
|
|
35181
35244
|
const fullPath = `${basePath}${apiPath}`;
|
|
35182
35245
|
let skillId;
|
|
35183
|
-
const
|
|
35184
|
-
if (
|
|
35185
|
-
skillId =
|
|
35186
|
-
} else if (
|
|
35187
|
-
skillId =
|
|
35246
|
+
const path2 = request.path;
|
|
35247
|
+
if (path2.startsWith(`${fullPath}/`)) {
|
|
35248
|
+
skillId = path2.slice(fullPath.length + 1);
|
|
35249
|
+
} else if (path2.startsWith(`${apiPath}/`)) {
|
|
35250
|
+
skillId = path2.slice(apiPath.length + 1);
|
|
35188
35251
|
}
|
|
35189
35252
|
const queryRaw = request.query?.["query"];
|
|
35190
35253
|
const query = Array.isArray(queryRaw) ? queryRaw[0] : queryRaw;
|
|
@@ -36797,8 +36860,8 @@ function pathOf(req) {
|
|
|
36797
36860
|
return String(raw).split("?")[0] || "/";
|
|
36798
36861
|
}
|
|
36799
36862
|
}
|
|
36800
|
-
function isLegacySsePath(
|
|
36801
|
-
return
|
|
36863
|
+
function isLegacySsePath(path2) {
|
|
36864
|
+
return path2 === "/sse" || path2.endsWith("/sse");
|
|
36802
36865
|
}
|
|
36803
36866
|
function tryDecodeTransportType(sessionId) {
|
|
36804
36867
|
if (!sessionId) return;
|
|
@@ -36823,8 +36886,8 @@ function getQuerySessionId2(req) {
|
|
|
36823
36886
|
function computeBitmap(req, cfg) {
|
|
36824
36887
|
const method = req.method.toUpperCase();
|
|
36825
36888
|
const accept = h(req, "accept");
|
|
36826
|
-
const
|
|
36827
|
-
const postToMessage = method === "POST" && (
|
|
36889
|
+
const path2 = pathOf(req);
|
|
36890
|
+
const postToMessage = method === "POST" && (path2 === "/message" || path2.endsWith("/message"));
|
|
36828
36891
|
const headerSessionId = h(req, "mcp-session-id");
|
|
36829
36892
|
const querySessionId = postToMessage ? getQuerySessionId2(req) : void 0;
|
|
36830
36893
|
const sessionId = headerSessionId ?? querySessionId;
|
|
@@ -36833,7 +36896,7 @@ function computeBitmap(req, cfg) {
|
|
|
36833
36896
|
const acceptSSE = wantsSSE(accept);
|
|
36834
36897
|
const acceptJSON = wantsJSON(accept) || !accept && cfg.tolerateMissingAccept;
|
|
36835
36898
|
const init = method === "POST" && isInitialize(req.body);
|
|
36836
|
-
const getToSsePath = method === "GET" && isLegacySsePath(
|
|
36899
|
+
const getToSsePath = method === "GET" && isLegacySsePath(path2);
|
|
36837
36900
|
const channel = method === "POST" && postToMessage ? CH_POST_MESSAGE : getToSsePath && acceptSSE ? CH_GET_SSE_PATH : method === "GET" && acceptSSE ? CH_GET_SSE : method === "POST" && init && acceptSSE ? CH_POST_INIT_SSE : method === "POST" && init && acceptJSON ? CH_POST_INIT_JSON : method === "POST" && !init && acceptSSE ? CH_POST_SSE : method === "POST" && !init && acceptJSON ? CH_POST_JSON : CH_OTHER;
|
|
36838
36901
|
let flags = 0;
|
|
36839
36902
|
if (sessionId) flags |= B_HAS_SESSION;
|
|
@@ -44517,7 +44580,7 @@ var init_base_host_adapter = __esm({
|
|
|
44517
44580
|
import * as http from "node:http";
|
|
44518
44581
|
import express from "express";
|
|
44519
44582
|
import cors from "cors";
|
|
44520
|
-
import { fileExists as
|
|
44583
|
+
import { fileExists as fileExists5, unlink } from "@frontmcp/utils";
|
|
44521
44584
|
var ExpressHostAdapter;
|
|
44522
44585
|
var init_express_host_adapter = __esm({
|
|
44523
44586
|
"libs/sdk/src/server/adapters/express.host.adapter.ts"() {
|
|
@@ -44551,8 +44614,8 @@ var init_express_host_adapter = __esm({
|
|
|
44551
44614
|
next();
|
|
44552
44615
|
});
|
|
44553
44616
|
}
|
|
44554
|
-
registerRoute(method,
|
|
44555
|
-
this.router[method.toLowerCase()](
|
|
44617
|
+
registerRoute(method, path2, handler) {
|
|
44618
|
+
this.router[method.toLowerCase()](path2, this.enhancedHandler(handler));
|
|
44556
44619
|
}
|
|
44557
44620
|
registerMiddleware(entryPath, handler) {
|
|
44558
44621
|
this.router.use(entryPath, handler);
|
|
@@ -44594,8 +44657,8 @@ var init_express_host_adapter = __esm({
|
|
|
44594
44657
|
server.on("error", reject);
|
|
44595
44658
|
server.listen(portOrSocketPath, () => {
|
|
44596
44659
|
try {
|
|
44597
|
-
const
|
|
44598
|
-
|
|
44660
|
+
const fs2 = __require("node:fs");
|
|
44661
|
+
fs2.chmodSync(portOrSocketPath, 432);
|
|
44599
44662
|
} catch {
|
|
44600
44663
|
}
|
|
44601
44664
|
console.log(`MCP HTTP (Express) on unix://${portOrSocketPath}`);
|
|
@@ -44614,7 +44677,7 @@ var init_express_host_adapter = __esm({
|
|
|
44614
44677
|
}
|
|
44615
44678
|
async cleanupStaleSocket(socketPath) {
|
|
44616
44679
|
try {
|
|
44617
|
-
if (await
|
|
44680
|
+
if (await fileExists5(socketPath)) {
|
|
44618
44681
|
await unlink(socketPath);
|
|
44619
44682
|
}
|
|
44620
44683
|
} catch {
|
|
@@ -44666,8 +44729,8 @@ var init_server_instance = __esm({
|
|
|
44666
44729
|
registerMiddleware(entryPath, handler) {
|
|
44667
44730
|
return this.host.registerMiddleware(entryPath, handler);
|
|
44668
44731
|
}
|
|
44669
|
-
registerRoute(method,
|
|
44670
|
-
return this.host.registerRoute(method,
|
|
44732
|
+
registerRoute(method, path2, handler) {
|
|
44733
|
+
return this.host.registerRoute(method, path2, handler);
|
|
44671
44734
|
}
|
|
44672
44735
|
enhancedHandler(handler) {
|
|
44673
44736
|
return this.host.enhancedHandler(handler);
|
|
@@ -45064,8 +45127,39 @@ var direct_client_exports = {};
|
|
|
45064
45127
|
__export(direct_client_exports, {
|
|
45065
45128
|
DirectClientImpl: () => DirectClientImpl
|
|
45066
45129
|
});
|
|
45067
|
-
import { randomUUID as randomUUID23 } from "@frontmcp/utils";
|
|
45130
|
+
import { randomUUID as randomUUID23, pathResolve as pathResolve5, fileExists as fileExists6 } from "@frontmcp/utils";
|
|
45068
45131
|
import { Client as Client2 } from "@frontmcp/protocol";
|
|
45132
|
+
function findFileFromRoot(root, relativePath) {
|
|
45133
|
+
const fs2 = __require("fs");
|
|
45134
|
+
const path2 = __require("path");
|
|
45135
|
+
const cleanRelative = relativePath.replace(/^\.\//, "");
|
|
45136
|
+
const searchDirs = ["src", "."];
|
|
45137
|
+
for (const srcDir of searchDirs) {
|
|
45138
|
+
const srcRoot = path2.join(root, srcDir);
|
|
45139
|
+
if (!fs2.existsSync(srcRoot)) continue;
|
|
45140
|
+
const found = walkForFile(srcRoot, cleanRelative, fs2, path2);
|
|
45141
|
+
if (found) return found;
|
|
45142
|
+
}
|
|
45143
|
+
return void 0;
|
|
45144
|
+
}
|
|
45145
|
+
function walkForFile(dir, targetRelative, fs2, path2, maxDepth = 10) {
|
|
45146
|
+
const candidate = path2.join(dir, targetRelative);
|
|
45147
|
+
if (fs2.existsSync(candidate)) {
|
|
45148
|
+
return { absolute: candidate, baseDir: dir };
|
|
45149
|
+
}
|
|
45150
|
+
if (maxDepth <= 0) return void 0;
|
|
45151
|
+
try {
|
|
45152
|
+
const entries = fs2.readdirSync(dir, { withFileTypes: true });
|
|
45153
|
+
for (const entry of entries) {
|
|
45154
|
+
if (entry.isDirectory() && !entry.name.startsWith(".") && entry.name !== "node_modules" && entry.name !== "dist") {
|
|
45155
|
+
const result = walkForFile(path2.join(dir, entry.name), targetRelative, fs2, path2, maxDepth - 1);
|
|
45156
|
+
if (result) return result;
|
|
45157
|
+
}
|
|
45158
|
+
}
|
|
45159
|
+
} catch {
|
|
45160
|
+
}
|
|
45161
|
+
return void 0;
|
|
45162
|
+
}
|
|
45069
45163
|
var DirectClientImpl;
|
|
45070
45164
|
var init_direct_client = __esm({
|
|
45071
45165
|
"libs/sdk/src/direct/direct-client.ts"() {
|
|
@@ -45089,6 +45183,8 @@ var init_direct_client = __esm({
|
|
|
45089
45183
|
resourceUpdateHandlers = /* @__PURE__ */ new Set();
|
|
45090
45184
|
// Generic notification handlers
|
|
45091
45185
|
notificationHandlers = /* @__PURE__ */ new Set();
|
|
45186
|
+
// Scope reference for build-time operations (collectSkillAssets)
|
|
45187
|
+
scopeRef;
|
|
45092
45188
|
constructor(mcpClient, sessionId, clientInfo, serverInfo, capabilities) {
|
|
45093
45189
|
this.mcpClient = mcpClient;
|
|
45094
45190
|
this.sessionId = sessionId;
|
|
@@ -45141,6 +45237,7 @@ var init_direct_client = __esm({
|
|
|
45141
45237
|
}
|
|
45142
45238
|
const client = new _DirectClientImpl(mcpClient, sessionId, clientInfo, serverInfo, serverCapabilities);
|
|
45143
45239
|
client.closeServer = close;
|
|
45240
|
+
client.scopeRef = scope;
|
|
45144
45241
|
await client.setupNotificationHandlers(mcpClient);
|
|
45145
45242
|
return client;
|
|
45146
45243
|
} catch (error) {
|
|
@@ -45444,6 +45541,52 @@ var init_direct_client = __esm({
|
|
|
45444
45541
|
async getWorkflowStatus(runId) {
|
|
45445
45542
|
return this.callToolAndParseJson("get-workflow-status", { runId });
|
|
45446
45543
|
}
|
|
45544
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
45545
|
+
// Build-Time Asset Collection
|
|
45546
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
45547
|
+
async collectSkillAssets() {
|
|
45548
|
+
const scope = this.scopeRef;
|
|
45549
|
+
if (!scope?.skills) return { entries: [] };
|
|
45550
|
+
const skills = scope.skills.getSkills({ includeHidden: true });
|
|
45551
|
+
const entries = [];
|
|
45552
|
+
for (const skill of skills) {
|
|
45553
|
+
const baseDir = skill.getBaseDir?.();
|
|
45554
|
+
const meta = skill.metadata;
|
|
45555
|
+
const entry = {
|
|
45556
|
+
skillName: meta.name,
|
|
45557
|
+
baseDir
|
|
45558
|
+
};
|
|
45559
|
+
if (meta.instructions && typeof meta.instructions === "object" && "file" in meta.instructions) {
|
|
45560
|
+
const filePath = meta.instructions.file;
|
|
45561
|
+
const resolved = filePath.startsWith("/") ? filePath : baseDir ? pathResolve5(baseDir, filePath) : void 0;
|
|
45562
|
+
if (resolved && await fileExists6(resolved)) {
|
|
45563
|
+
entry.instructionFile = resolved;
|
|
45564
|
+
} else if (!filePath.startsWith("/")) {
|
|
45565
|
+
const fromCwd = findFileFromRoot(process.cwd(), filePath);
|
|
45566
|
+
if (fromCwd) {
|
|
45567
|
+
entry.instructionFile = fromCwd.absolute;
|
|
45568
|
+
entry.baseDir = fromCwd.baseDir;
|
|
45569
|
+
}
|
|
45570
|
+
}
|
|
45571
|
+
}
|
|
45572
|
+
const resources = skill.getResources?.();
|
|
45573
|
+
if (resources) {
|
|
45574
|
+
entry.resources = {};
|
|
45575
|
+
for (const key of ["references", "examples", "scripts", "assets"]) {
|
|
45576
|
+
const p = resources[key];
|
|
45577
|
+
if (p) {
|
|
45578
|
+
const base = entry.baseDir || baseDir;
|
|
45579
|
+
const resolved = p.startsWith("/") ? p : base ? pathResolve5(base, p) : void 0;
|
|
45580
|
+
if (resolved && await fileExists6(resolved)) {
|
|
45581
|
+
entry.resources[key] = resolved;
|
|
45582
|
+
}
|
|
45583
|
+
}
|
|
45584
|
+
}
|
|
45585
|
+
}
|
|
45586
|
+
entries.push(entry);
|
|
45587
|
+
}
|
|
45588
|
+
return { entries };
|
|
45589
|
+
}
|
|
45447
45590
|
};
|
|
45448
45591
|
}
|
|
45449
45592
|
});
|
|
@@ -45813,12 +45956,108 @@ var init_direct = __esm({
|
|
|
45813
45956
|
}
|
|
45814
45957
|
});
|
|
45815
45958
|
|
|
45959
|
+
// libs/sdk/src/logger/instances/instance.file-logger.ts
|
|
45960
|
+
import * as path from "path";
|
|
45961
|
+
import * as fs from "fs";
|
|
45962
|
+
import * as os from "os";
|
|
45963
|
+
function stripAnsi(str) {
|
|
45964
|
+
return str.split(ESC).map((s) => s.replace(/\[[0-9;]*m/, "")).join("");
|
|
45965
|
+
}
|
|
45966
|
+
var LOG_LEVEL_LABELS, ESC, DEFAULT_LOGS_MAX, FileLogTransportInstance;
|
|
45967
|
+
var init_instance_file_logger = __esm({
|
|
45968
|
+
"libs/sdk/src/logger/instances/instance.file-logger.ts"() {
|
|
45969
|
+
"use strict";
|
|
45970
|
+
init_common();
|
|
45971
|
+
LOG_LEVEL_LABELS = {
|
|
45972
|
+
[100 /* Off */]: "OFF",
|
|
45973
|
+
[0 /* Debug */]: "DEBUG",
|
|
45974
|
+
[1 /* Verbose */]: "VERBOSE",
|
|
45975
|
+
[2 /* Info */]: "INFO",
|
|
45976
|
+
[3 /* Warn */]: "WARN",
|
|
45977
|
+
[4 /* Error */]: "ERROR"
|
|
45978
|
+
};
|
|
45979
|
+
ESC = String.fromCharCode(27);
|
|
45980
|
+
DEFAULT_LOGS_MAX = 25;
|
|
45981
|
+
FileLogTransportInstance = class extends LogTransportInterface {
|
|
45982
|
+
fd;
|
|
45983
|
+
logDir;
|
|
45984
|
+
appName;
|
|
45985
|
+
constructor() {
|
|
45986
|
+
super();
|
|
45987
|
+
const rawAppName = process.env["FRONTMCP_APP_NAME"] || "frontmcp";
|
|
45988
|
+
const sanitized = rawAppName.replace(/[^a-zA-Z0-9._-]/g, "_");
|
|
45989
|
+
this.appName = sanitized.length > 0 ? sanitized : "frontmcp";
|
|
45990
|
+
this.logDir = process.env["FRONTMCP_LOG_DIR"] || path.join(process.env["FRONTMCP_HOME"] || path.join(os.homedir(), ".frontmcp"), "logs");
|
|
45991
|
+
const logsMax = parseInt(process.env["FRONTMCP_LOGS_MAX"] || "", 10);
|
|
45992
|
+
if (logsMax === 0) {
|
|
45993
|
+
this.fd = void 0;
|
|
45994
|
+
return;
|
|
45995
|
+
}
|
|
45996
|
+
try {
|
|
45997
|
+
fs.mkdirSync(this.logDir, { recursive: true });
|
|
45998
|
+
const ts = (/* @__PURE__ */ new Date()).toISOString().replace(/:/g, "_");
|
|
45999
|
+
const filePath = path.join(this.logDir, `${this.appName}-${ts}.log`);
|
|
46000
|
+
this.fd = fs.openSync(filePath, "a");
|
|
46001
|
+
this.rotate(isNaN(logsMax) ? DEFAULT_LOGS_MAX : logsMax);
|
|
46002
|
+
} catch {
|
|
46003
|
+
this.fd = void 0;
|
|
46004
|
+
}
|
|
46005
|
+
}
|
|
46006
|
+
/** Close the file descriptor. Call during shutdown to prevent handle leaks. */
|
|
46007
|
+
close() {
|
|
46008
|
+
if (this.fd !== void 0) {
|
|
46009
|
+
try {
|
|
46010
|
+
fs.closeSync(this.fd);
|
|
46011
|
+
} catch {
|
|
46012
|
+
}
|
|
46013
|
+
this.fd = void 0;
|
|
46014
|
+
}
|
|
46015
|
+
}
|
|
46016
|
+
log(rec) {
|
|
46017
|
+
if (this.fd === void 0) return;
|
|
46018
|
+
const ts = rec.timestamp.toISOString();
|
|
46019
|
+
const level = LOG_LEVEL_LABELS[rec.level] ?? "INFO";
|
|
46020
|
+
const prefix = rec.prefix ? ` [${rec.prefix}]` : "";
|
|
46021
|
+
const message = stripAnsi(String(rec.message));
|
|
46022
|
+
const line = `[${ts}] ${level}${prefix} ${message}
|
|
46023
|
+
`;
|
|
46024
|
+
try {
|
|
46025
|
+
fs.writeSync(this.fd, line);
|
|
46026
|
+
} catch {
|
|
46027
|
+
}
|
|
46028
|
+
}
|
|
46029
|
+
/** Remove oldest log files when count exceeds max (npm-style rotation). */
|
|
46030
|
+
rotate(maxFiles) {
|
|
46031
|
+
try {
|
|
46032
|
+
const prefix = `${this.appName}-`;
|
|
46033
|
+
const files = fs.readdirSync(this.logDir).filter((f) => f.startsWith(prefix) && f.endsWith(".log")).sort();
|
|
46034
|
+
const excess = files.length - maxFiles;
|
|
46035
|
+
if (excess <= 0) return;
|
|
46036
|
+
for (let i = 0; i < excess; i++) {
|
|
46037
|
+
try {
|
|
46038
|
+
fs.unlinkSync(path.join(this.logDir, files[i]));
|
|
46039
|
+
} catch {
|
|
46040
|
+
}
|
|
46041
|
+
}
|
|
46042
|
+
} catch {
|
|
46043
|
+
}
|
|
46044
|
+
}
|
|
46045
|
+
};
|
|
46046
|
+
FileLogTransportInstance = __decorateClass([
|
|
46047
|
+
FrontMcpLogTransport({
|
|
46048
|
+
name: "FileLogger",
|
|
46049
|
+
description: "Writes logs to a file for CLI mode diagnostics"
|
|
46050
|
+
})
|
|
46051
|
+
], FileLogTransportInstance);
|
|
46052
|
+
}
|
|
46053
|
+
});
|
|
46054
|
+
|
|
45816
46055
|
// libs/sdk/src/front-mcp/front-mcp.ts
|
|
45817
46056
|
var front_mcp_exports = {};
|
|
45818
46057
|
__export(front_mcp_exports, {
|
|
45819
46058
|
FrontMcpInstance: () => FrontMcpInstance
|
|
45820
46059
|
});
|
|
45821
|
-
import { randomUUID as randomUUID25, fileExists as
|
|
46060
|
+
import { randomUUID as randomUUID25, fileExists as fileExists7, unlink as unlink2 } from "@frontmcp/utils";
|
|
45822
46061
|
var FrontMcpInstance;
|
|
45823
46062
|
var init_front_mcp = __esm({
|
|
45824
46063
|
"libs/sdk/src/front-mcp/front-mcp.ts"() {
|
|
@@ -45830,6 +46069,7 @@ var init_front_mcp = __esm({
|
|
|
45830
46069
|
init_logger_registry();
|
|
45831
46070
|
init_direct();
|
|
45832
46071
|
init_errors();
|
|
46072
|
+
init_instance_file_logger();
|
|
45833
46073
|
init_health2();
|
|
45834
46074
|
FrontMcpInstance = class _FrontMcpInstance2 {
|
|
45835
46075
|
config;
|
|
@@ -45970,6 +46210,20 @@ var init_front_mcp = __esm({
|
|
|
45970
46210
|
static async createForCli(options) {
|
|
45971
46211
|
const parsedConfig = parseFrontMcpConfigLite(options);
|
|
45972
46212
|
parsedConfig["__cliMode"] = true;
|
|
46213
|
+
const verbose = process.env["FRONTMCP_CLI_VERBOSE"] === "1";
|
|
46214
|
+
if (parsedConfig.logging) {
|
|
46215
|
+
parsedConfig.logging.enableConsole = verbose;
|
|
46216
|
+
const transports = parsedConfig.logging.transports ?? [];
|
|
46217
|
+
if (!transports.includes(FileLogTransportInstance)) {
|
|
46218
|
+
transports.push(FileLogTransportInstance);
|
|
46219
|
+
}
|
|
46220
|
+
parsedConfig.logging.transports = transports;
|
|
46221
|
+
} else {
|
|
46222
|
+
parsedConfig["logging"] = {
|
|
46223
|
+
enableConsole: verbose,
|
|
46224
|
+
transports: [FileLogTransportInstance]
|
|
46225
|
+
};
|
|
46226
|
+
}
|
|
45973
46227
|
const frontMcp = new _FrontMcpInstance2(parsedConfig);
|
|
45974
46228
|
await frontMcp.ready;
|
|
45975
46229
|
return frontMcp;
|
|
@@ -46087,7 +46341,7 @@ var init_front_mcp = __esm({
|
|
|
46087
46341
|
frontMcp.log?.info(`MCP server listening on unix://${socketPath}`);
|
|
46088
46342
|
const cleanup = async () => {
|
|
46089
46343
|
try {
|
|
46090
|
-
if (await
|
|
46344
|
+
if (await fileExists7(socketPath)) {
|
|
46091
46345
|
await unlink2(socketPath);
|
|
46092
46346
|
}
|
|
46093
46347
|
} catch {
|
|
@@ -47179,9 +47433,9 @@ var init_flow_entry = __esm({
|
|
|
47179
47433
|
scope;
|
|
47180
47434
|
constructor(scope, record, token, metadata) {
|
|
47181
47435
|
super(record, token, metadata);
|
|
47182
|
-
const { path, method } = record.metadata.middleware ?? metadata?.middleware ?? {};
|
|
47436
|
+
const { path: path2, method } = record.metadata.middleware ?? metadata?.middleware ?? {};
|
|
47183
47437
|
this.name = metadata?.name ?? record.metadata?.name;
|
|
47184
|
-
this.path =
|
|
47438
|
+
this.path = path2;
|
|
47185
47439
|
this.method = method;
|
|
47186
47440
|
this.scope = scope;
|
|
47187
47441
|
}
|
|
@@ -47776,8 +48030,8 @@ var init_base_config_provider = __esm({
|
|
|
47776
48030
|
getAll() {
|
|
47777
48031
|
return this.config;
|
|
47778
48032
|
}
|
|
47779
|
-
get(
|
|
47780
|
-
const keys =
|
|
48033
|
+
get(path2, defaultValue) {
|
|
48034
|
+
const keys = path2.split(".");
|
|
47781
48035
|
let result = this.config;
|
|
47782
48036
|
for (const key of keys) {
|
|
47783
48037
|
if (result && typeof result === "object" && key in result) {
|
|
@@ -47795,8 +48049,8 @@ var init_base_config_provider = __esm({
|
|
|
47795
48049
|
* config.has('vm.preset') // returns true
|
|
47796
48050
|
* config.has('nonexistent.path') // returns false
|
|
47797
48051
|
*/
|
|
47798
|
-
has(
|
|
47799
|
-
const keys =
|
|
48052
|
+
has(path2) {
|
|
48053
|
+
const keys = path2.split(".");
|
|
47800
48054
|
let result = this.config;
|
|
47801
48055
|
for (const key of keys) {
|
|
47802
48056
|
if (result && typeof result === "object" && key in result) {
|
|
@@ -47812,8 +48066,8 @@ var init_base_config_provider = __esm({
|
|
|
47812
48066
|
* @example
|
|
47813
48067
|
* config.getOrDefault('vm.timeout', 5000)
|
|
47814
48068
|
*/
|
|
47815
|
-
getOrDefault(
|
|
47816
|
-
const value = this.get(
|
|
48069
|
+
getOrDefault(path2, defaultValue) {
|
|
48070
|
+
const value = this.get(path2);
|
|
47817
48071
|
return value !== void 0 ? value : defaultValue;
|
|
47818
48072
|
}
|
|
47819
48073
|
/**
|
|
@@ -47822,10 +48076,10 @@ var init_base_config_provider = __esm({
|
|
|
47822
48076
|
* config.getRequired('vm.preset')
|
|
47823
48077
|
* config.getOrThrow('vm.preset')
|
|
47824
48078
|
*/
|
|
47825
|
-
getRequired(
|
|
47826
|
-
const value = this.get(
|
|
48079
|
+
getRequired(path2) {
|
|
48080
|
+
const value = this.get(path2);
|
|
47827
48081
|
if (value === void 0) {
|
|
47828
|
-
throw new RequiredConfigUndefinedError(
|
|
48082
|
+
throw new RequiredConfigUndefinedError(path2);
|
|
47829
48083
|
}
|
|
47830
48084
|
return value;
|
|
47831
48085
|
}
|
|
@@ -47834,8 +48088,8 @@ var init_base_config_provider = __esm({
|
|
|
47834
48088
|
* @example
|
|
47835
48089
|
* config.getOrThrow('vm.preset')
|
|
47836
48090
|
*/
|
|
47837
|
-
getOrThrow(
|
|
47838
|
-
return this.getRequired(
|
|
48091
|
+
getOrThrow(path2) {
|
|
48092
|
+
return this.getRequired(path2);
|
|
47839
48093
|
}
|
|
47840
48094
|
/**
|
|
47841
48095
|
* Get a nested object at a path
|
|
@@ -47850,8 +48104,8 @@ var init_base_config_provider = __esm({
|
|
|
47850
48104
|
* @example
|
|
47851
48105
|
* config.matches('vm.preset', 'secure') // returns true/false
|
|
47852
48106
|
*/
|
|
47853
|
-
matches(
|
|
47854
|
-
return this.get(
|
|
48107
|
+
matches(path2, value) {
|
|
48108
|
+
return this.get(path2) === value;
|
|
47855
48109
|
}
|
|
47856
48110
|
/**
|
|
47857
48111
|
* Get multiple values at once
|
|
@@ -47860,8 +48114,8 @@ var init_base_config_provider = __esm({
|
|
|
47860
48114
|
*/
|
|
47861
48115
|
getMany(paths) {
|
|
47862
48116
|
const result = {};
|
|
47863
|
-
for (const
|
|
47864
|
-
result[
|
|
48117
|
+
for (const path2 of paths) {
|
|
48118
|
+
result[path2] = this.get(path2);
|
|
47865
48119
|
}
|
|
47866
48120
|
return result;
|
|
47867
48121
|
}
|