@frontmcp/sdk 1.9.1-rc.2 → 1.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/index.cjs +44 -81
- package/browser/index.mjs +62 -99
- package/builtin/config/config.plugin.d.ts.map +1 -1
- package/builtin/config/providers/config-loader.d.ts.map +1 -1
- package/builtin/config/providers/env-loader.d.ts +7 -1
- package/builtin/config/providers/env-loader.d.ts.map +1 -1
- package/esm/index.mjs +62 -99
- package/index.js +44 -81
- package/package.json +13 -16
- package/skill/providers/memory-skill.provider.d.ts +4 -10
- package/skill/providers/memory-skill.provider.d.ts.map +1 -1
package/esm/index.mjs
CHANGED
|
@@ -28290,7 +28290,7 @@ var init_config_symbols = __esm({
|
|
|
28290
28290
|
});
|
|
28291
28291
|
|
|
28292
28292
|
// libs/sdk/src/builtin/config/providers/env-loader.ts
|
|
28293
|
-
import { fileExists as fileExists3, getCwd, getEnv as getEnv5, pathResolve as pathResolve2, readFile as readFile3, setEnv } from "@frontmcp/utils";
|
|
28293
|
+
import { fileExists as fileExists3, getCwd, getEnv as getEnv5, getRuntimeContext as getRuntimeContext9, pathResolve as pathResolve2, readFile as readFile3, setEnv } from "@frontmcp/utils";
|
|
28294
28294
|
function parseEnvContent(content) {
|
|
28295
28295
|
const result = {};
|
|
28296
28296
|
const lines = content.split("\n");
|
|
@@ -28316,8 +28316,20 @@ function parseEnvContent(content) {
|
|
|
28316
28316
|
}
|
|
28317
28317
|
return result;
|
|
28318
28318
|
}
|
|
28319
|
+
function canReadConfigFiles() {
|
|
28320
|
+
return getRuntimeContext9().runtime !== "browser";
|
|
28321
|
+
}
|
|
28322
|
+
function processEnvEntries() {
|
|
28323
|
+
const env = {};
|
|
28324
|
+
const processEnv = typeof process === "undefined" ? void 0 : process.env;
|
|
28325
|
+
for (const [key, value] of Object.entries(processEnv ?? {})) {
|
|
28326
|
+
if (value !== void 0) env[key] = value;
|
|
28327
|
+
}
|
|
28328
|
+
return env;
|
|
28329
|
+
}
|
|
28319
28330
|
async function loadEnvFiles(basePath = getCwd(), envPath = ".env", localEnvPath = ".env.local") {
|
|
28320
28331
|
const result = {};
|
|
28332
|
+
if (!canReadConfigFiles()) return result;
|
|
28321
28333
|
const envFile = pathResolve2(basePath, envPath);
|
|
28322
28334
|
if (await fileExists3(envFile)) {
|
|
28323
28335
|
const content = await readFile3(envFile);
|
|
@@ -28466,12 +28478,7 @@ async function loadConfig(schema, options = {}) {
|
|
|
28466
28478
|
if (shouldPopulate) {
|
|
28467
28479
|
populateProcessEnv(envFromFiles, false);
|
|
28468
28480
|
}
|
|
28469
|
-
const allEnv = { ...envFromFiles };
|
|
28470
|
-
for (const [key, value] of Object.entries(process.env)) {
|
|
28471
|
-
if (value !== void 0) {
|
|
28472
|
-
allEnv[key] = value;
|
|
28473
|
-
}
|
|
28474
|
-
}
|
|
28481
|
+
const allEnv = { ...envFromFiles, ...processEnvEntries() };
|
|
28475
28482
|
const paths = extractSchemaPaths(schema);
|
|
28476
28483
|
const envConfig = mapEnvToNestedConfig(allEnv, paths);
|
|
28477
28484
|
config = deepMerge(config, envConfig);
|
|
@@ -28483,6 +28490,7 @@ async function loadConfig(schema, options = {}) {
|
|
|
28483
28490
|
return result.data;
|
|
28484
28491
|
}
|
|
28485
28492
|
async function loadYamlConfig(basePath, configPath) {
|
|
28493
|
+
if (!canReadConfigFiles()) return {};
|
|
28486
28494
|
const extensions = ["", ".yml", ".yaml"];
|
|
28487
28495
|
const baseName = configPath.replace(/\.(ya?ml)$/, "");
|
|
28488
28496
|
for (const ext of extensions) {
|
|
@@ -28606,14 +28614,7 @@ var init_config_plugin = __esm({
|
|
|
28606
28614
|
const basePath = pluginConfig.basePath ?? getCwd3();
|
|
28607
28615
|
env = await loadEnvFiles(basePath, pluginConfig.envPath, pluginConfig.localEnvPath);
|
|
28608
28616
|
}
|
|
28609
|
-
const merged = { ...env };
|
|
28610
|
-
if (typeof process !== "undefined" && process.env) {
|
|
28611
|
-
for (const [key, value] of Object.entries(process.env)) {
|
|
28612
|
-
if (value !== void 0 && merged[key] === void 0) {
|
|
28613
|
-
merged[key] = value;
|
|
28614
|
-
}
|
|
28615
|
-
}
|
|
28616
|
-
}
|
|
28617
|
+
const merged = { ...processEnvEntries(), ...env };
|
|
28617
28618
|
if (pluginConfig.populateProcessEnv) {
|
|
28618
28619
|
populateProcessEnv(env, false);
|
|
28619
28620
|
}
|
|
@@ -31496,7 +31497,7 @@ var init_flow_interface = __esm({
|
|
|
31496
31497
|
|
|
31497
31498
|
// libs/sdk/src/common/interfaces/execution-context.interface.ts
|
|
31498
31499
|
import { buildAuthContext } from "@frontmcp/auth";
|
|
31499
|
-
import { getRuntimeContext as
|
|
31500
|
+
import { getRuntimeContext as getRuntimeContext10, randomUUID as randomUUID13 } from "@frontmcp/utils";
|
|
31500
31501
|
var ExecutionContextBase;
|
|
31501
31502
|
var init_execution_context_interface = __esm({
|
|
31502
31503
|
"libs/sdk/src/common/interfaces/execution-context.interface.ts"() {
|
|
@@ -31803,7 +31804,7 @@ var init_execution_context_interface = __esm({
|
|
|
31803
31804
|
* Get the current runtime context (platform, runtime, deployment, env).
|
|
31804
31805
|
*/
|
|
31805
31806
|
get runtimeContext() {
|
|
31806
|
-
return
|
|
31807
|
+
return getRuntimeContext10();
|
|
31807
31808
|
}
|
|
31808
31809
|
/**
|
|
31809
31810
|
* Check if running on a specific OS platform.
|
|
@@ -31838,7 +31839,7 @@ var init_execution_context_interface = __esm({
|
|
|
31838
31839
|
});
|
|
31839
31840
|
|
|
31840
31841
|
// libs/sdk/src/common/interfaces/prompt.interface.ts
|
|
31841
|
-
import { getRuntimeContext as
|
|
31842
|
+
import { getRuntimeContext as getRuntimeContext11, randomUUID as randomUUID14 } from "@frontmcp/utils";
|
|
31842
31843
|
var PromptContext;
|
|
31843
31844
|
var init_prompt_interface = __esm({
|
|
31844
31845
|
"libs/sdk/src/common/interfaces/prompt.interface.ts"() {
|
|
@@ -31938,7 +31939,7 @@ var init_prompt_interface = __esm({
|
|
|
31938
31939
|
// ---- Runtime context helpers ----
|
|
31939
31940
|
/** Get the current runtime context (platform, runtime, deployment, env). */
|
|
31940
31941
|
get runtimeContext() {
|
|
31941
|
-
return
|
|
31942
|
+
return getRuntimeContext11();
|
|
31942
31943
|
}
|
|
31943
31944
|
/** Check if running on a specific OS platform. */
|
|
31944
31945
|
isPlatform(platform) {
|
|
@@ -32300,41 +32301,8 @@ var init_skill_validation_error = __esm({
|
|
|
32300
32301
|
}
|
|
32301
32302
|
});
|
|
32302
32303
|
|
|
32303
|
-
// libs/sdk/src/scope/optional-dependency.util.ts
|
|
32304
|
-
function probeOptionalDependency(moduleName, loadError, resolve) {
|
|
32305
|
-
let resolvedPath;
|
|
32306
|
-
try {
|
|
32307
|
-
resolvedPath = resolve(moduleName);
|
|
32308
|
-
} catch {
|
|
32309
|
-
resolvedPath = void 0;
|
|
32310
|
-
}
|
|
32311
|
-
const error = loadError instanceof Error ? loadError.message : String(loadError);
|
|
32312
|
-
return resolvedPath ? { status: "load-failed", resolvedPath, error } : { status: "not-installed", error };
|
|
32313
|
-
}
|
|
32314
|
-
async function importOptionalPeer(moduleName, importer, resolve, feature) {
|
|
32315
|
-
try {
|
|
32316
|
-
return await importer();
|
|
32317
|
-
} catch (cause) {
|
|
32318
|
-
const probe = probeOptionalDependency(moduleName, cause, resolve);
|
|
32319
|
-
if (probe.status === "not-installed") {
|
|
32320
|
-
throw new Error(
|
|
32321
|
-
`@frontmcp/sdk ${feature} needs the optional peer dependency '${moduleName}'. Install it in your project (e.g. \`npm i ${moduleName}\`).`,
|
|
32322
|
-
{ cause }
|
|
32323
|
-
);
|
|
32324
|
-
}
|
|
32325
|
-
throw new Error(
|
|
32326
|
-
`@frontmcp/sdk ${feature} found '${moduleName}' at ${probe.resolvedPath} but it failed to load \u2014 reinstalling will not help. This is usually an export-condition, transpile, or transitive-peer mismatch. Original error: ${probe.error}`,
|
|
32327
|
-
{ cause }
|
|
32328
|
-
);
|
|
32329
|
-
}
|
|
32330
|
-
}
|
|
32331
|
-
var init_optional_dependency_util = __esm({
|
|
32332
|
-
"libs/sdk/src/scope/optional-dependency.util.ts"() {
|
|
32333
|
-
"use strict";
|
|
32334
|
-
}
|
|
32335
|
-
});
|
|
32336
|
-
|
|
32337
32304
|
// libs/sdk/src/skill/providers/memory-skill.provider.ts
|
|
32305
|
+
import { TFIDFVectoria } from "vectoriadb";
|
|
32338
32306
|
import { sha256Hex as sha256Hex9 } from "@frontmcp/utils";
|
|
32339
32307
|
function isSnapshotCapable(db) {
|
|
32340
32308
|
const d = db;
|
|
@@ -32344,8 +32312,6 @@ var STOP_WORDS, MemorySkillProvider;
|
|
|
32344
32312
|
var init_memory_skill_provider = __esm({
|
|
32345
32313
|
"libs/sdk/src/skill/providers/memory-skill.provider.ts"() {
|
|
32346
32314
|
"use strict";
|
|
32347
|
-
init_optional_dependency_util();
|
|
32348
|
-
init_dynamic_import_utils();
|
|
32349
32315
|
STOP_WORDS = /* @__PURE__ */ new Set([
|
|
32350
32316
|
// Articles & Determiners
|
|
32351
32317
|
"the",
|
|
@@ -32420,13 +32386,8 @@ var init_memory_skill_provider = __esm({
|
|
|
32420
32386
|
]);
|
|
32421
32387
|
MemorySkillProvider = class {
|
|
32422
32388
|
type = "memory";
|
|
32423
|
-
/**
|
|
32424
|
-
* The search index. `vectoriadb` is loaded the first time a search needs it,
|
|
32425
|
-
* never at construction: a server whose skills are only listed or loaded
|
|
32426
|
-
* (or that has none) must not pay for, or depend on, the optional peer.
|
|
32427
|
-
*/
|
|
32389
|
+
/** The search index, created the first time a search needs it. */
|
|
32428
32390
|
vectorDB;
|
|
32429
|
-
vectorDBLoad;
|
|
32430
32391
|
skills = /* @__PURE__ */ new Map();
|
|
32431
32392
|
defaultTopK;
|
|
32432
32393
|
defaultMinScore;
|
|
@@ -32439,8 +32400,8 @@ var init_memory_skill_provider = __esm({
|
|
|
32439
32400
|
/**
|
|
32440
32401
|
* The index is rebuilt from `skills` when it is stale: adds/removes bump
|
|
32441
32402
|
* `skillsVersion`, and the FIRST search after a mutation builds (or restores)
|
|
32442
|
-
* the index exactly once. This keeps the expensive IDF/embedding pass
|
|
32443
|
-
*
|
|
32403
|
+
* the index exactly once. This keeps the expensive IDF/embedding pass off the
|
|
32404
|
+
* registration hot-path.
|
|
32444
32405
|
*/
|
|
32445
32406
|
skillsVersion = 0;
|
|
32446
32407
|
indexedVersion = -1;
|
|
@@ -32451,25 +32412,13 @@ var init_memory_skill_provider = __esm({
|
|
|
32451
32412
|
this.scoring = options.scoring ?? "cosine";
|
|
32452
32413
|
this.indexCache = options.indexCache;
|
|
32453
32414
|
}
|
|
32454
|
-
|
|
32455
|
-
const mod = await importOptionalPeer(
|
|
32456
|
-
"vectoriadb",
|
|
32457
|
-
// A dynamic import inside Jest's VM throws unless the run uses
|
|
32458
|
-
// --experimental-vm-modules; `vectoriadb` ships CommonJS, so fall back to `require`.
|
|
32459
|
-
() => importWithRequireFallback(
|
|
32460
|
-
() => import("vectoriadb"),
|
|
32461
|
-
() => __require("vectoriadb")
|
|
32462
|
-
),
|
|
32463
|
-
// Read only when the import fails: an ESM browser bundle has no `require` at all
|
|
32464
|
-
(id) => __require.resolve(id),
|
|
32465
|
-
"skill search"
|
|
32466
|
-
);
|
|
32415
|
+
createVectorDB() {
|
|
32467
32416
|
const dbConfig = {
|
|
32468
32417
|
defaultTopK: this.defaultTopK,
|
|
32469
32418
|
defaultSimilarityThreshold: this.defaultMinScore
|
|
32470
32419
|
};
|
|
32471
32420
|
if (this.scoring !== "cosine") dbConfig.scoring = this.scoring;
|
|
32472
|
-
return new
|
|
32421
|
+
return new TFIDFVectoria(dbConfig);
|
|
32473
32422
|
}
|
|
32474
32423
|
/**
|
|
32475
32424
|
* Attach (or replace) the snapshot cache after construction — useful when the
|
|
@@ -32498,7 +32447,7 @@ var init_memory_skill_provider = __esm({
|
|
|
32498
32447
|
*/
|
|
32499
32448
|
async ensureIndexed() {
|
|
32500
32449
|
if (this.indexReady) return;
|
|
32501
|
-
const db =
|
|
32450
|
+
const db = this.db();
|
|
32502
32451
|
const version = this.skillsVersion;
|
|
32503
32452
|
if (this.indexCache && isSnapshotCapable(db)) {
|
|
32504
32453
|
const key = await this.computeIndexKey();
|
|
@@ -32554,11 +32503,8 @@ var init_memory_skill_provider = __esm({
|
|
|
32554
32503
|
const canonical = `frontmcp-skill-index:v1|${this.scoring}|${this.skills.size}|${parts.join("")}`;
|
|
32555
32504
|
return sha256Hex9(canonical);
|
|
32556
32505
|
}
|
|
32557
|
-
|
|
32558
|
-
|
|
32559
|
-
if (this.vectorDB) return this.vectorDB;
|
|
32560
|
-
this.vectorDBLoad ??= this.loadVectorDB();
|
|
32561
|
-
this.vectorDB = await this.vectorDBLoad;
|
|
32506
|
+
db() {
|
|
32507
|
+
this.vectorDB ??= this.createVectorDB();
|
|
32562
32508
|
return this.vectorDB;
|
|
32563
32509
|
}
|
|
32564
32510
|
/**
|
|
@@ -32605,7 +32551,7 @@ var init_memory_skill_provider = __esm({
|
|
|
32605
32551
|
}
|
|
32606
32552
|
return true;
|
|
32607
32553
|
};
|
|
32608
|
-
const db =
|
|
32554
|
+
const db = this.db();
|
|
32609
32555
|
await this.ensureIndexed();
|
|
32610
32556
|
let results = await db.search(query, {
|
|
32611
32557
|
topK,
|
|
@@ -33421,7 +33367,7 @@ var init_skill_instance = __esm({
|
|
|
33421
33367
|
|
|
33422
33368
|
// libs/sdk/src/skill/skill.registry.ts
|
|
33423
33369
|
import { tokenName as tokenName10 } from "@frontmcp/di";
|
|
33424
|
-
import { getRuntimeContext as
|
|
33370
|
+
import { getRuntimeContext as getRuntimeContext12, isEntryAvailable as isEntryAvailable5 } from "@frontmcp/utils";
|
|
33425
33371
|
function findIdPathCollision(skills) {
|
|
33426
33372
|
const byPath = /* @__PURE__ */ new Map();
|
|
33427
33373
|
for (const skill of skills) {
|
|
@@ -33711,7 +33657,7 @@ var init_skill_registry = __esm({
|
|
|
33711
33657
|
return skillVis === visibility;
|
|
33712
33658
|
});
|
|
33713
33659
|
}
|
|
33714
|
-
const ctx =
|
|
33660
|
+
const ctx = getRuntimeContext12();
|
|
33715
33661
|
skills = skills.filter((s) => isEntryAvailable5(s.metadata.availableWhen, ctx));
|
|
33716
33662
|
return skills;
|
|
33717
33663
|
}
|
|
@@ -33733,7 +33679,7 @@ var init_skill_registry = __esm({
|
|
|
33733
33679
|
getAlwaysLoadedSkills() {
|
|
33734
33680
|
let skills = this.listAllIndexed().map((r) => r.instance);
|
|
33735
33681
|
skills = skills.filter((s) => s.isAlwaysLoaded());
|
|
33736
|
-
const ctx =
|
|
33682
|
+
const ctx = getRuntimeContext12();
|
|
33737
33683
|
skills = skills.filter((s) => isEntryAvailable5(s.metadata.availableWhen, ctx));
|
|
33738
33684
|
return skills;
|
|
33739
33685
|
}
|
|
@@ -33864,7 +33810,7 @@ var init_skill_registry = __esm({
|
|
|
33864
33810
|
}
|
|
33865
33811
|
}
|
|
33866
33812
|
if (localSkill) {
|
|
33867
|
-
const ctx =
|
|
33813
|
+
const ctx = getRuntimeContext12();
|
|
33868
33814
|
if (!isEntryAvailable5(localSkill.metadata.availableWhen, ctx)) {
|
|
33869
33815
|
return void 0;
|
|
33870
33816
|
}
|
|
@@ -36907,7 +36853,7 @@ var init_agent_instance = __esm({
|
|
|
36907
36853
|
|
|
36908
36854
|
// libs/sdk/src/agent/agent.registry.ts
|
|
36909
36855
|
import { tokenName as tokenName13 } from "@frontmcp/di";
|
|
36910
|
-
import { getRuntimeContext as
|
|
36856
|
+
import { getRuntimeContext as getRuntimeContext13, isEntryAvailable as isEntryAvailable6 } from "@frontmcp/utils";
|
|
36911
36857
|
function ownerKeyOf2(lineage) {
|
|
36912
36858
|
return lineage.map((o) => `${o.kind}:${o.id}`).join("/");
|
|
36913
36859
|
}
|
|
@@ -37129,7 +37075,7 @@ var init_agent_registry = __esm({
|
|
|
37129
37075
|
*/
|
|
37130
37076
|
// NOTE: `any` is intentional - heterogeneous agent collections
|
|
37131
37077
|
getAgents(includeHidden = false) {
|
|
37132
|
-
const ctx =
|
|
37078
|
+
const ctx = getRuntimeContext13();
|
|
37133
37079
|
const local = [...this.localRows].map((a) => a.instance);
|
|
37134
37080
|
const adopted = [...this.adopted.values()].flat().map((a) => a.instance);
|
|
37135
37081
|
return [...local, ...adopted].filter((a) => {
|
|
@@ -37162,7 +37108,7 @@ var init_agent_registry = __esm({
|
|
|
37162
37108
|
* Used by discovery/listing APIs to enforce registry-level constraints.
|
|
37163
37109
|
*/
|
|
37164
37110
|
getAvailableInstances() {
|
|
37165
|
-
const ctx =
|
|
37111
|
+
const ctx = getRuntimeContext13();
|
|
37166
37112
|
return [...this.listAllInstances()].filter((a) => isEntryAvailable6(a.metadata.availableWhen, ctx));
|
|
37167
37113
|
}
|
|
37168
37114
|
/**
|
|
@@ -60055,9 +60001,9 @@ var init_handle_mcp_20260728_flow = __esm({
|
|
|
60055
60001
|
});
|
|
60056
60002
|
|
|
60057
60003
|
// libs/sdk/src/ha/ha-headers.ts
|
|
60058
|
-
import { buildSetCookie, getEnv as getEnv12, getMachineId as getMachineId3, getRuntimeContext as
|
|
60004
|
+
import { buildSetCookie, getEnv as getEnv12, getMachineId as getMachineId3, getRuntimeContext as getRuntimeContext14 } from "@frontmcp/utils";
|
|
60059
60005
|
function machineIdHeader() {
|
|
60060
|
-
if (
|
|
60006
|
+
if (getRuntimeContext14().deployment !== "distributed") return void 0;
|
|
60061
60007
|
return [DEFAULT_FRONTMCP_MACHINE_ID_HEADER, getMachineId3()];
|
|
60062
60008
|
}
|
|
60063
60009
|
function applyMachineIdHeader(response) {
|
|
@@ -64837,6 +64783,23 @@ var init_http_request_flow = __esm({
|
|
|
64837
64783
|
}
|
|
64838
64784
|
});
|
|
64839
64785
|
|
|
64786
|
+
// libs/sdk/src/scope/optional-dependency.util.ts
|
|
64787
|
+
function probeOptionalDependency(moduleName, loadError, resolve) {
|
|
64788
|
+
let resolvedPath;
|
|
64789
|
+
try {
|
|
64790
|
+
resolvedPath = resolve(moduleName);
|
|
64791
|
+
} catch {
|
|
64792
|
+
resolvedPath = void 0;
|
|
64793
|
+
}
|
|
64794
|
+
const error = loadError instanceof Error ? loadError.message : String(loadError);
|
|
64795
|
+
return resolvedPath ? { status: "load-failed", resolvedPath, error } : { status: "not-installed", error };
|
|
64796
|
+
}
|
|
64797
|
+
var init_optional_dependency_util = __esm({
|
|
64798
|
+
"libs/sdk/src/scope/optional-dependency.util.ts"() {
|
|
64799
|
+
"use strict";
|
|
64800
|
+
}
|
|
64801
|
+
});
|
|
64802
|
+
|
|
64840
64803
|
// libs/sdk/src/scope/server-entries.helper.ts
|
|
64841
64804
|
async function registerServerEntries(providers, entries, appIds) {
|
|
64842
64805
|
if (!entries.tools?.length && !entries.resources?.length) return;
|
|
@@ -64869,7 +64832,7 @@ import {
|
|
|
64869
64832
|
AuthoritiesProfileRegistry
|
|
64870
64833
|
} from "@frontmcp/auth";
|
|
64871
64834
|
import { createGuardManager } from "@frontmcp/guard";
|
|
64872
|
-
import { createRedisClient, getEnvFlag, getMachineId as getMachineId5, getRuntimeContext as
|
|
64835
|
+
import { createRedisClient, getEnvFlag, getMachineId as getMachineId5, getRuntimeContext as getRuntimeContext15, isEdgeRuntime } from "@frontmcp/utils";
|
|
64873
64836
|
var SCOPE_NON_DISPATCHABLE_FLOWS, Scope;
|
|
64874
64837
|
var init_scope_instance = __esm({
|
|
64875
64838
|
"libs/sdk/src/scope/scope.instance.ts"() {
|
|
@@ -65033,7 +64996,7 @@ var init_scope_instance = __esm({
|
|
|
65033
64996
|
this.scopeApps = new AppRegistry(this.scopeProviders, this.metadata.apps, scopeRef);
|
|
65034
64997
|
this.logger.info(`Initializing ${this.metadata.apps.length} app(s)...`);
|
|
65035
64998
|
const transportConfig = this.metadata.transport;
|
|
65036
|
-
const isDistributed =
|
|
64999
|
+
const isDistributed = getRuntimeContext15().deployment === "distributed";
|
|
65037
65000
|
if (isDistributed && this.metadata.redis && !this.cliMode) {
|
|
65038
65001
|
try {
|
|
65039
65002
|
const haRedis = this.createHaRedisClient();
|
|
@@ -65080,7 +65043,7 @@ var init_scope_instance = __esm({
|
|
|
65080
65043
|
onOrphan: (sessionId, previousNodeId, session) => transportService.adoptClaimedSession(sessionId, previousNodeId, session)
|
|
65081
65044
|
});
|
|
65082
65045
|
}
|
|
65083
|
-
if (
|
|
65046
|
+
if (getRuntimeContext15().deployment === "serverless") {
|
|
65084
65047
|
const protocolCfg = transportConfig?.protocol;
|
|
65085
65048
|
const hasSSE = typeof protocolCfg === "string" ? protocolCfg !== "stateless-api" : protocolCfg?.sse === true;
|
|
65086
65049
|
if (hasSSE) {
|
|
@@ -68673,7 +68636,7 @@ var init_node_express_host = __esm({
|
|
|
68673
68636
|
});
|
|
68674
68637
|
|
|
68675
68638
|
// libs/sdk/src/server/server.instance.ts
|
|
68676
|
-
import { getRuntimeContext as
|
|
68639
|
+
import { getRuntimeContext as getRuntimeContext16, isProduction as isProduction7 } from "@frontmcp/utils";
|
|
68677
68640
|
var DEFAULT_CORS, FrontMcpServerInstance;
|
|
68678
68641
|
var init_server_instance = __esm({
|
|
68679
68642
|
"libs/sdk/src/server/server.instance.ts"() {
|
|
@@ -68782,7 +68745,7 @@ var init_server_instance = __esm({
|
|
|
68782
68745
|
}
|
|
68783
68746
|
async start() {
|
|
68784
68747
|
this.prepare();
|
|
68785
|
-
const deploymentMode =
|
|
68748
|
+
const deploymentMode = getRuntimeContext16().deployment;
|
|
68786
68749
|
const bindAddress = resolveBindAddress(this.config.security, deploymentMode);
|
|
68787
68750
|
const findings = auditSecurityDefaults(
|
|
68788
68751
|
{
|
|
@@ -69288,7 +69251,7 @@ var init_front_mcp = __esm({
|
|
|
69288
69251
|
* const scopes = instance.getScopes();
|
|
69289
69252
|
*/
|
|
69290
69253
|
static async createForGraph(options) {
|
|
69291
|
-
const parsedConfig = frontMcpMetadataSchema.parse(options);
|
|
69254
|
+
const parsedConfig = frontMcpMetadataSchema.parse({ ...options, serve: false });
|
|
69292
69255
|
const frontMcp = new _FrontMcpInstance2(parsedConfig);
|
|
69293
69256
|
await frontMcp.ready;
|
|
69294
69257
|
return frontMcp;
|
package/index.js
CHANGED
|
@@ -28237,8 +28237,20 @@ function parseEnvContent(content) {
|
|
|
28237
28237
|
}
|
|
28238
28238
|
return result;
|
|
28239
28239
|
}
|
|
28240
|
+
function canReadConfigFiles() {
|
|
28241
|
+
return (0, import_utils60.getRuntimeContext)().runtime !== "browser";
|
|
28242
|
+
}
|
|
28243
|
+
function processEnvEntries() {
|
|
28244
|
+
const env = {};
|
|
28245
|
+
const processEnv = typeof process === "undefined" ? void 0 : process.env;
|
|
28246
|
+
for (const [key, value] of Object.entries(processEnv ?? {})) {
|
|
28247
|
+
if (value !== void 0) env[key] = value;
|
|
28248
|
+
}
|
|
28249
|
+
return env;
|
|
28250
|
+
}
|
|
28240
28251
|
async function loadEnvFiles(basePath = (0, import_utils60.getCwd)(), envPath = ".env", localEnvPath = ".env.local") {
|
|
28241
28252
|
const result = {};
|
|
28253
|
+
if (!canReadConfigFiles()) return result;
|
|
28242
28254
|
const envFile = (0, import_utils60.pathResolve)(basePath, envPath);
|
|
28243
28255
|
if (await (0, import_utils60.fileExists)(envFile)) {
|
|
28244
28256
|
const content = await (0, import_utils60.readFile)(envFile);
|
|
@@ -28386,12 +28398,7 @@ async function loadConfig(schema, options = {}) {
|
|
|
28386
28398
|
if (shouldPopulate) {
|
|
28387
28399
|
populateProcessEnv(envFromFiles, false);
|
|
28388
28400
|
}
|
|
28389
|
-
const allEnv = { ...envFromFiles };
|
|
28390
|
-
for (const [key, value] of Object.entries(process.env)) {
|
|
28391
|
-
if (value !== void 0) {
|
|
28392
|
-
allEnv[key] = value;
|
|
28393
|
-
}
|
|
28394
|
-
}
|
|
28401
|
+
const allEnv = { ...envFromFiles, ...processEnvEntries() };
|
|
28395
28402
|
const paths = extractSchemaPaths(schema);
|
|
28396
28403
|
const envConfig = mapEnvToNestedConfig(allEnv, paths);
|
|
28397
28404
|
config = deepMerge(config, envConfig);
|
|
@@ -28403,6 +28410,7 @@ async function loadConfig(schema, options = {}) {
|
|
|
28403
28410
|
return result.data;
|
|
28404
28411
|
}
|
|
28405
28412
|
async function loadYamlConfig(basePath, configPath) {
|
|
28413
|
+
if (!canReadConfigFiles()) return {};
|
|
28406
28414
|
const extensions = ["", ".yml", ".yaml"];
|
|
28407
28415
|
const baseName = configPath.replace(/\.(ya?ml)$/, "");
|
|
28408
28416
|
for (const ext of extensions) {
|
|
@@ -28528,14 +28536,7 @@ var init_config_plugin = __esm({
|
|
|
28528
28536
|
const basePath = pluginConfig.basePath ?? (0, import_utils62.getCwd)();
|
|
28529
28537
|
env = await loadEnvFiles(basePath, pluginConfig.envPath, pluginConfig.localEnvPath);
|
|
28530
28538
|
}
|
|
28531
|
-
const merged = { ...env };
|
|
28532
|
-
if (typeof process !== "undefined" && process.env) {
|
|
28533
|
-
for (const [key, value] of Object.entries(process.env)) {
|
|
28534
|
-
if (value !== void 0 && merged[key] === void 0) {
|
|
28535
|
-
merged[key] = value;
|
|
28536
|
-
}
|
|
28537
|
-
}
|
|
28538
|
-
}
|
|
28539
|
+
const merged = { ...processEnvEntries(), ...env };
|
|
28539
28540
|
if (pluginConfig.populateProcessEnv) {
|
|
28540
28541
|
populateProcessEnv(env, false);
|
|
28541
28542
|
}
|
|
@@ -32225,52 +32226,17 @@ var init_skill_validation_error = __esm({
|
|
|
32225
32226
|
}
|
|
32226
32227
|
});
|
|
32227
32228
|
|
|
32228
|
-
// libs/sdk/src/scope/optional-dependency.util.ts
|
|
32229
|
-
function probeOptionalDependency(moduleName, loadError, resolve) {
|
|
32230
|
-
let resolvedPath;
|
|
32231
|
-
try {
|
|
32232
|
-
resolvedPath = resolve(moduleName);
|
|
32233
|
-
} catch {
|
|
32234
|
-
resolvedPath = void 0;
|
|
32235
|
-
}
|
|
32236
|
-
const error = loadError instanceof Error ? loadError.message : String(loadError);
|
|
32237
|
-
return resolvedPath ? { status: "load-failed", resolvedPath, error } : { status: "not-installed", error };
|
|
32238
|
-
}
|
|
32239
|
-
async function importOptionalPeer(moduleName, importer, resolve, feature) {
|
|
32240
|
-
try {
|
|
32241
|
-
return await importer();
|
|
32242
|
-
} catch (cause) {
|
|
32243
|
-
const probe = probeOptionalDependency(moduleName, cause, resolve);
|
|
32244
|
-
if (probe.status === "not-installed") {
|
|
32245
|
-
throw new Error(
|
|
32246
|
-
`@frontmcp/sdk ${feature} needs the optional peer dependency '${moduleName}'. Install it in your project (e.g. \`npm i ${moduleName}\`).`,
|
|
32247
|
-
{ cause }
|
|
32248
|
-
);
|
|
32249
|
-
}
|
|
32250
|
-
throw new Error(
|
|
32251
|
-
`@frontmcp/sdk ${feature} found '${moduleName}' at ${probe.resolvedPath} but it failed to load \u2014 reinstalling will not help. This is usually an export-condition, transpile, or transitive-peer mismatch. Original error: ${probe.error}`,
|
|
32252
|
-
{ cause }
|
|
32253
|
-
);
|
|
32254
|
-
}
|
|
32255
|
-
}
|
|
32256
|
-
var init_optional_dependency_util = __esm({
|
|
32257
|
-
"libs/sdk/src/scope/optional-dependency.util.ts"() {
|
|
32258
|
-
"use strict";
|
|
32259
|
-
}
|
|
32260
|
-
});
|
|
32261
|
-
|
|
32262
32229
|
// libs/sdk/src/skill/providers/memory-skill.provider.ts
|
|
32263
32230
|
function isSnapshotCapable(db) {
|
|
32264
32231
|
const d = db;
|
|
32265
32232
|
return typeof d.toSnapshot === "function" && typeof d.loadSnapshot === "function";
|
|
32266
32233
|
}
|
|
32267
|
-
var import_utils68, STOP_WORDS, MemorySkillProvider;
|
|
32234
|
+
var import_vectoriadb, import_utils68, STOP_WORDS, MemorySkillProvider;
|
|
32268
32235
|
var init_memory_skill_provider = __esm({
|
|
32269
32236
|
"libs/sdk/src/skill/providers/memory-skill.provider.ts"() {
|
|
32270
32237
|
"use strict";
|
|
32238
|
+
import_vectoriadb = require("vectoriadb");
|
|
32271
32239
|
import_utils68 = require("@frontmcp/utils");
|
|
32272
|
-
init_optional_dependency_util();
|
|
32273
|
-
init_dynamic_import_utils();
|
|
32274
32240
|
STOP_WORDS = /* @__PURE__ */ new Set([
|
|
32275
32241
|
// Articles & Determiners
|
|
32276
32242
|
"the",
|
|
@@ -32345,13 +32311,8 @@ var init_memory_skill_provider = __esm({
|
|
|
32345
32311
|
]);
|
|
32346
32312
|
MemorySkillProvider = class {
|
|
32347
32313
|
type = "memory";
|
|
32348
|
-
/**
|
|
32349
|
-
* The search index. `vectoriadb` is loaded the first time a search needs it,
|
|
32350
|
-
* never at construction: a server whose skills are only listed or loaded
|
|
32351
|
-
* (or that has none) must not pay for, or depend on, the optional peer.
|
|
32352
|
-
*/
|
|
32314
|
+
/** The search index, created the first time a search needs it. */
|
|
32353
32315
|
vectorDB;
|
|
32354
|
-
vectorDBLoad;
|
|
32355
32316
|
skills = /* @__PURE__ */ new Map();
|
|
32356
32317
|
defaultTopK;
|
|
32357
32318
|
defaultMinScore;
|
|
@@ -32364,8 +32325,8 @@ var init_memory_skill_provider = __esm({
|
|
|
32364
32325
|
/**
|
|
32365
32326
|
* The index is rebuilt from `skills` when it is stale: adds/removes bump
|
|
32366
32327
|
* `skillsVersion`, and the FIRST search after a mutation builds (or restores)
|
|
32367
|
-
* the index exactly once. This keeps the expensive IDF/embedding pass
|
|
32368
|
-
*
|
|
32328
|
+
* the index exactly once. This keeps the expensive IDF/embedding pass off the
|
|
32329
|
+
* registration hot-path.
|
|
32369
32330
|
*/
|
|
32370
32331
|
skillsVersion = 0;
|
|
32371
32332
|
indexedVersion = -1;
|
|
@@ -32376,25 +32337,13 @@ var init_memory_skill_provider = __esm({
|
|
|
32376
32337
|
this.scoring = options.scoring ?? "cosine";
|
|
32377
32338
|
this.indexCache = options.indexCache;
|
|
32378
32339
|
}
|
|
32379
|
-
|
|
32380
|
-
const mod = await importOptionalPeer(
|
|
32381
|
-
"vectoriadb",
|
|
32382
|
-
// A dynamic import inside Jest's VM throws unless the run uses
|
|
32383
|
-
// --experimental-vm-modules; `vectoriadb` ships CommonJS, so fall back to `require`.
|
|
32384
|
-
() => importWithRequireFallback(
|
|
32385
|
-
() => import("vectoriadb"),
|
|
32386
|
-
() => require("vectoriadb")
|
|
32387
|
-
),
|
|
32388
|
-
// Read only when the import fails: an ESM browser bundle has no `require` at all
|
|
32389
|
-
(id) => require.resolve(id),
|
|
32390
|
-
"skill search"
|
|
32391
|
-
);
|
|
32340
|
+
createVectorDB() {
|
|
32392
32341
|
const dbConfig = {
|
|
32393
32342
|
defaultTopK: this.defaultTopK,
|
|
32394
32343
|
defaultSimilarityThreshold: this.defaultMinScore
|
|
32395
32344
|
};
|
|
32396
32345
|
if (this.scoring !== "cosine") dbConfig.scoring = this.scoring;
|
|
32397
|
-
return new
|
|
32346
|
+
return new import_vectoriadb.TFIDFVectoria(dbConfig);
|
|
32398
32347
|
}
|
|
32399
32348
|
/**
|
|
32400
32349
|
* Attach (or replace) the snapshot cache after construction — useful when the
|
|
@@ -32423,7 +32372,7 @@ var init_memory_skill_provider = __esm({
|
|
|
32423
32372
|
*/
|
|
32424
32373
|
async ensureIndexed() {
|
|
32425
32374
|
if (this.indexReady) return;
|
|
32426
|
-
const db =
|
|
32375
|
+
const db = this.db();
|
|
32427
32376
|
const version = this.skillsVersion;
|
|
32428
32377
|
if (this.indexCache && isSnapshotCapable(db)) {
|
|
32429
32378
|
const key = await this.computeIndexKey();
|
|
@@ -32479,11 +32428,8 @@ var init_memory_skill_provider = __esm({
|
|
|
32479
32428
|
const canonical = `frontmcp-skill-index:v1|${this.scoring}|${this.skills.size}|${parts.join("")}`;
|
|
32480
32429
|
return (0, import_utils68.sha256Hex)(canonical);
|
|
32481
32430
|
}
|
|
32482
|
-
|
|
32483
|
-
|
|
32484
|
-
if (this.vectorDB) return this.vectorDB;
|
|
32485
|
-
this.vectorDBLoad ??= this.loadVectorDB();
|
|
32486
|
-
this.vectorDB = await this.vectorDBLoad;
|
|
32431
|
+
db() {
|
|
32432
|
+
this.vectorDB ??= this.createVectorDB();
|
|
32487
32433
|
return this.vectorDB;
|
|
32488
32434
|
}
|
|
32489
32435
|
/**
|
|
@@ -32530,7 +32476,7 @@ var init_memory_skill_provider = __esm({
|
|
|
32530
32476
|
}
|
|
32531
32477
|
return true;
|
|
32532
32478
|
};
|
|
32533
|
-
const db =
|
|
32479
|
+
const db = this.db();
|
|
32534
32480
|
await this.ensureIndexed();
|
|
32535
32481
|
let results = await db.search(query, {
|
|
32536
32482
|
topK,
|
|
@@ -64634,6 +64580,23 @@ var init_http_request_flow = __esm({
|
|
|
64634
64580
|
}
|
|
64635
64581
|
});
|
|
64636
64582
|
|
|
64583
|
+
// libs/sdk/src/scope/optional-dependency.util.ts
|
|
64584
|
+
function probeOptionalDependency(moduleName, loadError, resolve) {
|
|
64585
|
+
let resolvedPath;
|
|
64586
|
+
try {
|
|
64587
|
+
resolvedPath = resolve(moduleName);
|
|
64588
|
+
} catch {
|
|
64589
|
+
resolvedPath = void 0;
|
|
64590
|
+
}
|
|
64591
|
+
const error = loadError instanceof Error ? loadError.message : String(loadError);
|
|
64592
|
+
return resolvedPath ? { status: "load-failed", resolvedPath, error } : { status: "not-installed", error };
|
|
64593
|
+
}
|
|
64594
|
+
var init_optional_dependency_util = __esm({
|
|
64595
|
+
"libs/sdk/src/scope/optional-dependency.util.ts"() {
|
|
64596
|
+
"use strict";
|
|
64597
|
+
}
|
|
64598
|
+
});
|
|
64599
|
+
|
|
64637
64600
|
// libs/sdk/src/scope/server-entries.helper.ts
|
|
64638
64601
|
async function registerServerEntries(providers, entries, appIds) {
|
|
64639
64602
|
if (!entries.tools?.length && !entries.resources?.length) return;
|
|
@@ -69075,7 +69038,7 @@ var init_front_mcp = __esm({
|
|
|
69075
69038
|
* const scopes = instance.getScopes();
|
|
69076
69039
|
*/
|
|
69077
69040
|
static async createForGraph(options) {
|
|
69078
|
-
const parsedConfig = frontMcpMetadataSchema.parse(options);
|
|
69041
|
+
const parsedConfig = frontMcpMetadataSchema.parse({ ...options, serve: false });
|
|
69079
69042
|
const frontMcp = new _FrontMcpInstance2(parsedConfig);
|
|
69080
69043
|
await frontMcp.ready;
|
|
69081
69044
|
return frontMcp;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontmcp/sdk",
|
|
3
|
-
"version": "1.9.1
|
|
3
|
+
"version": "1.9.1",
|
|
4
4
|
"description": "FrontMCP SDK",
|
|
5
5
|
"author": "AgentFront <info@agentfront.dev>",
|
|
6
6
|
"homepage": "https://docs.agentfront.dev",
|
|
@@ -96,8 +96,8 @@
|
|
|
96
96
|
"peerDependencies": {
|
|
97
97
|
"@anthropic-ai/sdk": "^0.30.0 || ^0.78.0",
|
|
98
98
|
"@enclave-vm/core": "^2.16.0",
|
|
99
|
-
"@frontmcp/observability": "1.9.1
|
|
100
|
-
"@frontmcp/storage-sqlite": "1.9.1
|
|
99
|
+
"@frontmcp/observability": "1.9.1",
|
|
100
|
+
"@frontmcp/storage-sqlite": "1.9.1",
|
|
101
101
|
"@opentelemetry/api": "^1.9.0",
|
|
102
102
|
"@opentelemetry/sdk-trace-base": "^2.8.0",
|
|
103
103
|
"@vercel/kv": "^3.0.0",
|
|
@@ -105,8 +105,7 @@
|
|
|
105
105
|
"cors": "^2.8.5",
|
|
106
106
|
"express": "^4.18.0 || ^5.0.0",
|
|
107
107
|
"openai": "^4.0.0 || ^5.0.0 || ^6.0.0",
|
|
108
|
-
"raw-body": "^3.0.0"
|
|
109
|
-
"vectoriadb": "^2.3.0"
|
|
108
|
+
"raw-body": "^3.0.0"
|
|
110
109
|
},
|
|
111
110
|
"peerDependenciesMeta": {
|
|
112
111
|
"@anthropic-ai/sdk": {
|
|
@@ -132,25 +131,23 @@
|
|
|
132
131
|
},
|
|
133
132
|
"openai": {
|
|
134
133
|
"optional": true
|
|
135
|
-
},
|
|
136
|
-
"vectoriadb": {
|
|
137
|
-
"optional": true
|
|
138
134
|
}
|
|
139
135
|
},
|
|
140
136
|
"dependencies": {
|
|
141
|
-
"@frontmcp/auth": "1.9.1
|
|
142
|
-
"@frontmcp/di": "1.9.1
|
|
143
|
-
"@frontmcp/guard": "1.9.1
|
|
144
|
-
"@frontmcp/lazy-zod": "1.9.1
|
|
145
|
-
"@frontmcp/protocol": "1.9.1
|
|
146
|
-
"@frontmcp/uipack": "1.9.1
|
|
147
|
-
"@frontmcp/utils": "1.9.1
|
|
137
|
+
"@frontmcp/auth": "1.9.1",
|
|
138
|
+
"@frontmcp/di": "1.9.1",
|
|
139
|
+
"@frontmcp/guard": "1.9.1",
|
|
140
|
+
"@frontmcp/lazy-zod": "1.9.1",
|
|
141
|
+
"@frontmcp/protocol": "1.9.1",
|
|
142
|
+
"@frontmcp/uipack": "1.9.1",
|
|
143
|
+
"@frontmcp/utils": "1.9.1",
|
|
148
144
|
"@types/cors": "^2.8.17",
|
|
149
145
|
"ioredis": "^5.8.0",
|
|
150
146
|
"jose": "^6.1.3",
|
|
151
147
|
"js-yaml": "^4.1.1",
|
|
152
148
|
"reflect-metadata": "^0.2.2",
|
|
153
|
-
"semver": "^7.6.0"
|
|
149
|
+
"semver": "^7.6.0",
|
|
150
|
+
"vectoriadb": "^2.3.3"
|
|
154
151
|
},
|
|
155
152
|
"devDependencies": {
|
|
156
153
|
"typescript": "^5.9.3"
|