@frontmcp/sdk 0.8.0 → 0.9.0
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/README.md +108 -0
- package/auth/flows/oauth.authorize.flow.d.ts +3 -3
- package/auth/flows/oauth.authorize.flow.d.ts.map +1 -1
- package/auth/machine-id.d.ts +9 -1
- package/auth/machine-id.d.ts.map +1 -1
- package/direct/create.d.ts +62 -0
- package/direct/create.d.ts.map +1 -0
- package/direct/create.types.d.ts +86 -0
- package/direct/create.types.d.ts.map +1 -0
- package/direct/direct-server.d.ts +3 -0
- package/direct/direct-server.d.ts.map +1 -1
- package/direct/direct.types.d.ts +9 -0
- package/direct/direct.types.d.ts.map +1 -1
- package/direct/index.d.ts +2 -0
- package/direct/index.d.ts.map +1 -1
- package/esm/index.mjs +161 -17
- package/esm/package.json +6 -6
- package/index.d.ts +2 -0
- package/index.d.ts.map +1 -1
- package/index.js +188 -42
- package/package.json +6 -6
- package/server/adapters/express.host.adapter.d.ts +39 -1
- package/server/adapters/express.host.adapter.d.ts.map +1 -1
package/index.js
CHANGED
|
@@ -21006,6 +21006,11 @@ var init_tiny_ttl_cache = __esm({
|
|
|
21006
21006
|
});
|
|
21007
21007
|
|
|
21008
21008
|
// libs/sdk/src/auth/machine-id.ts
|
|
21009
|
+
var machine_id_exports = {};
|
|
21010
|
+
__export(machine_id_exports, {
|
|
21011
|
+
getMachineId: () => getMachineId,
|
|
21012
|
+
setMachineIdOverride: () => setMachineIdOverride
|
|
21013
|
+
});
|
|
21009
21014
|
function isDevPersistenceEnabled() {
|
|
21010
21015
|
return process.env["NODE_ENV"] !== "production";
|
|
21011
21016
|
}
|
|
@@ -21032,7 +21037,7 @@ function loadMachineIdSync() {
|
|
|
21032
21037
|
return null;
|
|
21033
21038
|
}
|
|
21034
21039
|
}
|
|
21035
|
-
function saveMachineIdAsync(
|
|
21040
|
+
function saveMachineIdAsync(machineId2) {
|
|
21036
21041
|
if (!isDevPersistenceEnabled()) {
|
|
21037
21042
|
return;
|
|
21038
21043
|
}
|
|
@@ -21041,23 +21046,26 @@ function saveMachineIdAsync(machineId) {
|
|
|
21041
21046
|
(async () => {
|
|
21042
21047
|
try {
|
|
21043
21048
|
await (0, import_utils29.mkdir)(dir, { recursive: true, mode: 448 });
|
|
21044
|
-
await (0, import_utils29.writeFile)(machineIdPath,
|
|
21049
|
+
await (0, import_utils29.writeFile)(machineIdPath, machineId2, { mode: 384 });
|
|
21045
21050
|
} catch (error) {
|
|
21046
21051
|
console.warn(`[MachineId] Failed to save to ${machineIdPath}: ${error.message}`);
|
|
21047
21052
|
}
|
|
21048
21053
|
})();
|
|
21049
21054
|
}
|
|
21050
21055
|
function getMachineId() {
|
|
21051
|
-
return
|
|
21056
|
+
return machineIdOverride ?? machineId;
|
|
21057
|
+
}
|
|
21058
|
+
function setMachineIdOverride(id) {
|
|
21059
|
+
machineIdOverride = id;
|
|
21052
21060
|
}
|
|
21053
|
-
var path3, import_utils29, DEFAULT_MACHINE_ID_PATH,
|
|
21061
|
+
var path3, import_utils29, DEFAULT_MACHINE_ID_PATH, machineId, machineIdOverride;
|
|
21054
21062
|
var init_machine_id = __esm({
|
|
21055
21063
|
"libs/sdk/src/auth/machine-id.ts"() {
|
|
21056
21064
|
"use strict";
|
|
21057
21065
|
path3 = __toESM(require("path"));
|
|
21058
21066
|
import_utils29 = require("@frontmcp/utils");
|
|
21059
21067
|
DEFAULT_MACHINE_ID_PATH = ".frontmcp/machine-id";
|
|
21060
|
-
|
|
21068
|
+
machineId = (() => {
|
|
21061
21069
|
const envMachineId = process.env["MACHINE_ID"];
|
|
21062
21070
|
if (envMachineId) {
|
|
21063
21071
|
return envMachineId;
|
|
@@ -21319,11 +21327,11 @@ var init_session_verify_flow = __esm({
|
|
|
21319
21327
|
*/
|
|
21320
21328
|
createAnonymousSession(options) {
|
|
21321
21329
|
const { authMode, issuer, scopes = ["anonymous"], sessionIdHeader } = options;
|
|
21322
|
-
const
|
|
21330
|
+
const machineId2 = getMachineId();
|
|
21323
21331
|
if (sessionIdHeader) {
|
|
21324
21332
|
const existingPayload = decryptPublicSession(sessionIdHeader);
|
|
21325
21333
|
const user2 = existingPayload ? { sub: `anon:${existingPayload.iat * 1e3}`, iss: issuer, name: "Anonymous", scope: scopes.join(" ") } : { sub: `anon:${crypto.randomUUID()}`, iss: issuer, name: "Anonymous", scope: scopes.join(" ") };
|
|
21326
|
-
const finalPayload = existingPayload && existingPayload.nodeId ===
|
|
21334
|
+
const finalPayload = existingPayload && existingPayload.nodeId === machineId2 ? existingPayload : void 0;
|
|
21327
21335
|
this.respond({
|
|
21328
21336
|
kind: "authorized",
|
|
21329
21337
|
authorization: {
|
|
@@ -21349,7 +21357,7 @@ var init_session_verify_flow = __esm({
|
|
|
21349
21357
|
const platformType = detectPlatformFromUserAgent(this.state.userAgent, platformDetectionConfig);
|
|
21350
21358
|
const payload = {
|
|
21351
21359
|
uuid,
|
|
21352
|
-
nodeId:
|
|
21360
|
+
nodeId: machineId2,
|
|
21353
21361
|
authSig: authMode,
|
|
21354
21362
|
iat: Math.floor(now / 1e3),
|
|
21355
21363
|
isPublic: authMode === "public",
|
|
@@ -21952,7 +21960,7 @@ var init_cimd = __esm({
|
|
|
21952
21960
|
});
|
|
21953
21961
|
|
|
21954
21962
|
// libs/sdk/src/auth/flows/oauth.authorize.flow.ts
|
|
21955
|
-
var import_zod56, pkceChallengeSchema, codeChallengeMethodSchema, responseTypeSchema, oauthAuthorizeRequestSchema, anonymousAuthorizeRequestSchema, inputSchema15, stateSchema13, outputSchema13, plan13, name14, Stage14, OauthAuthorizeFlow;
|
|
21963
|
+
var import_zod56, pkceChallengeSchema, codeChallengeMethodSchema, responseTypeSchema, safeRedirectUriSchema, oauthAuthorizeRequestSchema, anonymousAuthorizeRequestSchema, inputSchema15, stateSchema13, outputSchema13, plan13, name14, Stage14, OauthAuthorizeFlow;
|
|
21956
21964
|
var init_oauth_authorize_flow = __esm({
|
|
21957
21965
|
"libs/sdk/src/auth/flows/oauth.authorize.flow.ts"() {
|
|
21958
21966
|
"use strict";
|
|
@@ -21967,10 +21975,21 @@ var init_oauth_authorize_flow = __esm({
|
|
|
21967
21975
|
responseTypeSchema = import_zod56.z.literal("code", {
|
|
21968
21976
|
message: 'response_type must be "code" (OAuth 2.1)'
|
|
21969
21977
|
});
|
|
21978
|
+
safeRedirectUriSchema = import_zod56.z.url().refine(
|
|
21979
|
+
(uri) => {
|
|
21980
|
+
try {
|
|
21981
|
+
const url = new URL(uri);
|
|
21982
|
+
return url.protocol === "http:" || url.protocol === "https:";
|
|
21983
|
+
} catch {
|
|
21984
|
+
return false;
|
|
21985
|
+
}
|
|
21986
|
+
},
|
|
21987
|
+
{ message: "redirect_uri must use http or https scheme" }
|
|
21988
|
+
);
|
|
21970
21989
|
oauthAuthorizeRequestSchema = import_zod56.z.object({
|
|
21971
21990
|
response_type: responseTypeSchema,
|
|
21972
21991
|
client_id: import_zod56.z.string().min(1, "client_id is required"),
|
|
21973
|
-
redirect_uri:
|
|
21992
|
+
redirect_uri: safeRedirectUriSchema,
|
|
21974
21993
|
code_challenge: pkceChallengeSchema,
|
|
21975
21994
|
code_challenge_method: codeChallengeMethodSchema.optional().default("S256"),
|
|
21976
21995
|
scope: import_zod56.z.string().optional(),
|
|
@@ -21978,7 +21997,7 @@ var init_oauth_authorize_flow = __esm({
|
|
|
21978
21997
|
resource: import_zod56.z.string().url().optional()
|
|
21979
21998
|
});
|
|
21980
21999
|
anonymousAuthorizeRequestSchema = import_zod56.z.object({
|
|
21981
|
-
redirect_uri:
|
|
22000
|
+
redirect_uri: safeRedirectUriSchema,
|
|
21982
22001
|
state: import_zod56.z.string().optional()
|
|
21983
22002
|
});
|
|
21984
22003
|
inputSchema15 = httpInputSchema;
|
|
@@ -22134,7 +22153,7 @@ var init_oauth_authorize_flow = __esm({
|
|
|
22134
22153
|
} catch (error) {
|
|
22135
22154
|
const errorMessage = error instanceof Error ? error.message : "CIMD validation failed";
|
|
22136
22155
|
this.logger.warn(`CIMD validation failed for ${client_id}: ${errorMessage}`);
|
|
22137
|
-
this.respondWithError([errorMessage],
|
|
22156
|
+
this.respondWithError([errorMessage], void 0, rawState);
|
|
22138
22157
|
return;
|
|
22139
22158
|
}
|
|
22140
22159
|
}
|
|
@@ -22320,8 +22339,9 @@ var init_oauth_authorize_flow = __esm({
|
|
|
22320
22339
|
respondWithError(errors, redirectUri, state) {
|
|
22321
22340
|
const errorDescription = errors.join("; ");
|
|
22322
22341
|
if (redirectUri) {
|
|
22323
|
-
|
|
22324
|
-
|
|
22342
|
+
const safe = safeRedirectUriSchema.safeParse(redirectUri);
|
|
22343
|
+
if (safe.success) {
|
|
22344
|
+
const url = new URL(safe.data);
|
|
22325
22345
|
url.searchParams.set("error", "invalid_request");
|
|
22326
22346
|
url.searchParams.set("error_description", errorDescription);
|
|
22327
22347
|
if (state) {
|
|
@@ -22329,7 +22349,6 @@ var init_oauth_authorize_flow = __esm({
|
|
|
22329
22349
|
}
|
|
22330
22350
|
this.respond(httpRespond.redirect(url.toString()));
|
|
22331
22351
|
return;
|
|
22332
|
-
} catch {
|
|
22333
22352
|
}
|
|
22334
22353
|
}
|
|
22335
22354
|
this.respond(httpRespond.html(this.renderErrorPage("invalid_request", errorDescription), 400));
|
|
@@ -35955,11 +35974,20 @@ var init_express_host_adapter = __esm({
|
|
|
35955
35974
|
app = (0, import_express.default)();
|
|
35956
35975
|
router = import_express.default.Router();
|
|
35957
35976
|
prepared = false;
|
|
35958
|
-
constructor() {
|
|
35977
|
+
constructor(options) {
|
|
35959
35978
|
super();
|
|
35960
35979
|
this.app.use(import_express.default.json());
|
|
35961
35980
|
this.app.use(import_express.default.urlencoded({ extended: true }));
|
|
35962
|
-
|
|
35981
|
+
const corsOptions = options?.cors;
|
|
35982
|
+
if (corsOptions?.origin !== void 0 && corsOptions.origin !== false) {
|
|
35983
|
+
this.app.use(
|
|
35984
|
+
(0, import_cors.default)({
|
|
35985
|
+
origin: corsOptions.origin,
|
|
35986
|
+
credentials: corsOptions.credentials ?? false,
|
|
35987
|
+
maxAge: corsOptions.maxAge ?? 300
|
|
35988
|
+
})
|
|
35989
|
+
);
|
|
35990
|
+
}
|
|
35963
35991
|
this.app.use((req, res, next) => {
|
|
35964
35992
|
res.setHeader("Access-Control-Expose-Headers", "WWW-Authenticate");
|
|
35965
35993
|
res.setHeader("Cache-Control", "no-cache, no-transform");
|
|
@@ -37145,6 +37173,17 @@ var init_direct_server = __esm({
|
|
|
37145
37173
|
);
|
|
37146
37174
|
}
|
|
37147
37175
|
// ─────────────────────────────────────────────────────────────────
|
|
37176
|
+
// Client Connections
|
|
37177
|
+
// ─────────────────────────────────────────────────────────────────
|
|
37178
|
+
async connect(sessionIdOrOptions) {
|
|
37179
|
+
if (this._isDisposed) {
|
|
37180
|
+
throw new InternalMcpError("DirectMcpServer has been disposed");
|
|
37181
|
+
}
|
|
37182
|
+
const options = typeof sessionIdOrOptions === "string" ? { session: { id: sessionIdOrOptions } } : sessionIdOrOptions;
|
|
37183
|
+
const { DirectClientImpl: DirectClientImpl2 } = await Promise.resolve().then(() => (init_direct_client(), direct_client_exports));
|
|
37184
|
+
return DirectClientImpl2.create(this.scope, options);
|
|
37185
|
+
}
|
|
37186
|
+
// ─────────────────────────────────────────────────────────────────
|
|
37148
37187
|
// Lifecycle
|
|
37149
37188
|
// ─────────────────────────────────────────────────────────────────
|
|
37150
37189
|
async dispose() {
|
|
@@ -37162,6 +37201,107 @@ var init_direct_server = __esm({
|
|
|
37162
37201
|
}
|
|
37163
37202
|
});
|
|
37164
37203
|
|
|
37204
|
+
// libs/sdk/src/direct/create.ts
|
|
37205
|
+
function buildConfig(config) {
|
|
37206
|
+
const appName = config.appName ?? config.info.name;
|
|
37207
|
+
const syntheticApp = class SyntheticApp {
|
|
37208
|
+
};
|
|
37209
|
+
Object.defineProperty(syntheticApp, "name", { value: appName });
|
|
37210
|
+
Reflect.defineMetadata(FrontMcpLocalAppTokens.type, true, syntheticApp);
|
|
37211
|
+
const appMeta = {
|
|
37212
|
+
name: appName,
|
|
37213
|
+
tools: config.tools,
|
|
37214
|
+
resources: config.resources,
|
|
37215
|
+
prompts: config.prompts,
|
|
37216
|
+
adapters: config.adapters,
|
|
37217
|
+
plugins: config.plugins,
|
|
37218
|
+
providers: config.providers,
|
|
37219
|
+
authProviders: config.authProviders,
|
|
37220
|
+
agents: config.agents,
|
|
37221
|
+
skills: config.skills,
|
|
37222
|
+
auth: config.auth
|
|
37223
|
+
};
|
|
37224
|
+
for (const key of Object.keys(appMeta)) {
|
|
37225
|
+
if (appMeta[key] !== void 0) {
|
|
37226
|
+
const token = FrontMcpLocalAppTokens[key] ?? key;
|
|
37227
|
+
Reflect.defineMetadata(token, appMeta[key], syntheticApp);
|
|
37228
|
+
}
|
|
37229
|
+
}
|
|
37230
|
+
return {
|
|
37231
|
+
info: config.info,
|
|
37232
|
+
apps: [syntheticApp],
|
|
37233
|
+
serve: false,
|
|
37234
|
+
redis: config.redis,
|
|
37235
|
+
pubsub: config.pubsub,
|
|
37236
|
+
transport: config.transport,
|
|
37237
|
+
logging: config.logging,
|
|
37238
|
+
pagination: config.pagination,
|
|
37239
|
+
elicitation: config.elicitation,
|
|
37240
|
+
skillsConfig: config.skillsConfig,
|
|
37241
|
+
extApps: config.extApps
|
|
37242
|
+
};
|
|
37243
|
+
}
|
|
37244
|
+
async function create(config) {
|
|
37245
|
+
const { cacheKey } = config;
|
|
37246
|
+
if (cacheKey) {
|
|
37247
|
+
const cached = instanceCache.get(cacheKey);
|
|
37248
|
+
if (cached) {
|
|
37249
|
+
return cached;
|
|
37250
|
+
}
|
|
37251
|
+
}
|
|
37252
|
+
const serverPromise = (async () => {
|
|
37253
|
+
const machineIdWasSet = config.machineId !== void 0;
|
|
37254
|
+
try {
|
|
37255
|
+
if (machineIdWasSet) {
|
|
37256
|
+
const { setMachineIdOverride: setMachineIdOverride2 } = await Promise.resolve().then(() => (init_machine_id(), machine_id_exports));
|
|
37257
|
+
setMachineIdOverride2(config.machineId);
|
|
37258
|
+
}
|
|
37259
|
+
const fullConfig = buildConfig(config);
|
|
37260
|
+
const { FrontMcpInstance: FrontMcpInstance2 } = await Promise.resolve().then(() => (init_front_mcp(), front_mcp_exports));
|
|
37261
|
+
const server = await FrontMcpInstance2.createDirect(fullConfig);
|
|
37262
|
+
if (cacheKey || machineIdWasSet) {
|
|
37263
|
+
const originalDispose = server.dispose.bind(server);
|
|
37264
|
+
server.dispose = async () => {
|
|
37265
|
+
if (cacheKey) {
|
|
37266
|
+
instanceCache.delete(cacheKey);
|
|
37267
|
+
}
|
|
37268
|
+
if (machineIdWasSet) {
|
|
37269
|
+
const { setMachineIdOverride: setMachineIdOverride2 } = await Promise.resolve().then(() => (init_machine_id(), machine_id_exports));
|
|
37270
|
+
setMachineIdOverride2(void 0);
|
|
37271
|
+
}
|
|
37272
|
+
return originalDispose();
|
|
37273
|
+
};
|
|
37274
|
+
}
|
|
37275
|
+
return server;
|
|
37276
|
+
} catch (error) {
|
|
37277
|
+
if (cacheKey) {
|
|
37278
|
+
instanceCache.delete(cacheKey);
|
|
37279
|
+
}
|
|
37280
|
+
if (machineIdWasSet) {
|
|
37281
|
+
const { setMachineIdOverride: setMachineIdOverride2 } = await Promise.resolve().then(() => (init_machine_id(), machine_id_exports));
|
|
37282
|
+
setMachineIdOverride2(void 0);
|
|
37283
|
+
}
|
|
37284
|
+
throw error;
|
|
37285
|
+
}
|
|
37286
|
+
})();
|
|
37287
|
+
if (cacheKey) {
|
|
37288
|
+
instanceCache.set(cacheKey, serverPromise);
|
|
37289
|
+
}
|
|
37290
|
+
return serverPromise;
|
|
37291
|
+
}
|
|
37292
|
+
function clearCreateCache() {
|
|
37293
|
+
instanceCache = /* @__PURE__ */ new Map();
|
|
37294
|
+
}
|
|
37295
|
+
var import_reflect_metadata22, instanceCache;
|
|
37296
|
+
var init_create = __esm({
|
|
37297
|
+
"libs/sdk/src/direct/create.ts"() {
|
|
37298
|
+
"use strict";
|
|
37299
|
+
import_reflect_metadata22 = require("reflect-metadata");
|
|
37300
|
+
init_tokens();
|
|
37301
|
+
instanceCache = /* @__PURE__ */ new Map();
|
|
37302
|
+
}
|
|
37303
|
+
});
|
|
37304
|
+
|
|
37165
37305
|
// libs/sdk/src/direct/index.ts
|
|
37166
37306
|
var init_direct = __esm({
|
|
37167
37307
|
"libs/sdk/src/direct/index.ts"() {
|
|
@@ -37169,6 +37309,7 @@ var init_direct = __esm({
|
|
|
37169
37309
|
init_connect();
|
|
37170
37310
|
init_llm_platform();
|
|
37171
37311
|
init_direct_server();
|
|
37312
|
+
init_create();
|
|
37172
37313
|
}
|
|
37173
37314
|
});
|
|
37174
37315
|
|
|
@@ -37552,11 +37693,11 @@ ${JSON.stringify(
|
|
|
37552
37693
|
}
|
|
37553
37694
|
};
|
|
37554
37695
|
}
|
|
37555
|
-
var
|
|
37696
|
+
var import_reflect_metadata23, _FrontMcpInstance, _serverlessHandlerFns;
|
|
37556
37697
|
var init_front_mcp_decorator = __esm({
|
|
37557
37698
|
"libs/sdk/src/common/decorators/front-mcp.decorator.ts"() {
|
|
37558
37699
|
"use strict";
|
|
37559
|
-
|
|
37700
|
+
import_reflect_metadata23 = require("reflect-metadata");
|
|
37560
37701
|
init_tokens();
|
|
37561
37702
|
init_metadata();
|
|
37562
37703
|
init_mcp_error();
|
|
@@ -37624,11 +37765,11 @@ ${JSON.stringify(error.format().prompts, null, 2)}`);
|
|
|
37624
37765
|
}
|
|
37625
37766
|
};
|
|
37626
37767
|
}
|
|
37627
|
-
var
|
|
37768
|
+
var import_reflect_metadata24;
|
|
37628
37769
|
var init_app_decorator = __esm({
|
|
37629
37770
|
"libs/sdk/src/common/decorators/app.decorator.ts"() {
|
|
37630
37771
|
"use strict";
|
|
37631
|
-
|
|
37772
|
+
import_reflect_metadata24 = require("reflect-metadata");
|
|
37632
37773
|
init_tokens();
|
|
37633
37774
|
init_metadata();
|
|
37634
37775
|
}
|
|
@@ -37644,11 +37785,11 @@ function FrontMcpProvider(providedMetadata) {
|
|
|
37644
37785
|
}
|
|
37645
37786
|
};
|
|
37646
37787
|
}
|
|
37647
|
-
var
|
|
37788
|
+
var import_reflect_metadata25;
|
|
37648
37789
|
var init_provider_decorator = __esm({
|
|
37649
37790
|
"libs/sdk/src/common/decorators/provider.decorator.ts"() {
|
|
37650
37791
|
"use strict";
|
|
37651
|
-
|
|
37792
|
+
import_reflect_metadata25 = require("reflect-metadata");
|
|
37652
37793
|
init_tokens();
|
|
37653
37794
|
init_metadata();
|
|
37654
37795
|
}
|
|
@@ -37664,11 +37805,11 @@ function FrontMcpAuthProvider(providedMetadata) {
|
|
|
37664
37805
|
}
|
|
37665
37806
|
};
|
|
37666
37807
|
}
|
|
37667
|
-
var
|
|
37808
|
+
var import_reflect_metadata26;
|
|
37668
37809
|
var init_auth_provider_decorator = __esm({
|
|
37669
37810
|
"libs/sdk/src/common/decorators/auth-provider.decorator.ts"() {
|
|
37670
37811
|
"use strict";
|
|
37671
|
-
|
|
37812
|
+
import_reflect_metadata26 = require("reflect-metadata");
|
|
37672
37813
|
init_tokens();
|
|
37673
37814
|
init_metadata();
|
|
37674
37815
|
}
|
|
@@ -37684,11 +37825,11 @@ function FrontMcpAdapter(providedMetadata) {
|
|
|
37684
37825
|
}
|
|
37685
37826
|
};
|
|
37686
37827
|
}
|
|
37687
|
-
var
|
|
37828
|
+
var import_reflect_metadata27;
|
|
37688
37829
|
var init_adapter_decorator = __esm({
|
|
37689
37830
|
"libs/sdk/src/common/decorators/adapter.decorator.ts"() {
|
|
37690
37831
|
"use strict";
|
|
37691
|
-
|
|
37832
|
+
import_reflect_metadata27 = require("reflect-metadata");
|
|
37692
37833
|
init_tokens();
|
|
37693
37834
|
init_metadata();
|
|
37694
37835
|
}
|
|
@@ -37746,11 +37887,11 @@ ${JSON.stringify(formatted.prompts, null, 2)}`
|
|
|
37746
37887
|
}
|
|
37747
37888
|
};
|
|
37748
37889
|
}
|
|
37749
|
-
var
|
|
37890
|
+
var import_reflect_metadata28;
|
|
37750
37891
|
var init_plugin_decorator = __esm({
|
|
37751
37892
|
"libs/sdk/src/common/decorators/plugin.decorator.ts"() {
|
|
37752
37893
|
"use strict";
|
|
37753
|
-
|
|
37894
|
+
import_reflect_metadata28 = require("reflect-metadata");
|
|
37754
37895
|
init_tokens();
|
|
37755
37896
|
init_metadata();
|
|
37756
37897
|
}
|
|
@@ -37779,11 +37920,11 @@ function frontMcpPrompt(providedMetadata) {
|
|
|
37779
37920
|
return toolFunction;
|
|
37780
37921
|
};
|
|
37781
37922
|
}
|
|
37782
|
-
var
|
|
37923
|
+
var import_reflect_metadata29;
|
|
37783
37924
|
var init_prompt_decorator = __esm({
|
|
37784
37925
|
"libs/sdk/src/common/decorators/prompt.decorator.ts"() {
|
|
37785
37926
|
"use strict";
|
|
37786
|
-
|
|
37927
|
+
import_reflect_metadata29 = require("reflect-metadata");
|
|
37787
37928
|
init_tokens();
|
|
37788
37929
|
init_metadata();
|
|
37789
37930
|
}
|
|
@@ -37799,11 +37940,11 @@ function FrontMcpLogTransport(providedMetadata) {
|
|
|
37799
37940
|
}
|
|
37800
37941
|
};
|
|
37801
37942
|
}
|
|
37802
|
-
var
|
|
37943
|
+
var import_reflect_metadata30;
|
|
37803
37944
|
var init_logger_decorator = __esm({
|
|
37804
37945
|
"libs/sdk/src/common/decorators/logger.decorator.ts"() {
|
|
37805
37946
|
"use strict";
|
|
37806
|
-
|
|
37947
|
+
import_reflect_metadata30 = require("reflect-metadata");
|
|
37807
37948
|
init_tokens();
|
|
37808
37949
|
init_metadata();
|
|
37809
37950
|
}
|
|
@@ -37842,11 +37983,11 @@ function frontMcpAgent(providedMetadata) {
|
|
|
37842
37983
|
return agentFunction;
|
|
37843
37984
|
};
|
|
37844
37985
|
}
|
|
37845
|
-
var
|
|
37986
|
+
var import_reflect_metadata31;
|
|
37846
37987
|
var init_agent_decorator = __esm({
|
|
37847
37988
|
"libs/sdk/src/common/decorators/agent.decorator.ts"() {
|
|
37848
37989
|
"use strict";
|
|
37849
|
-
|
|
37990
|
+
import_reflect_metadata31 = require("reflect-metadata");
|
|
37850
37991
|
init_tokens();
|
|
37851
37992
|
init_metadata();
|
|
37852
37993
|
}
|
|
@@ -38113,11 +38254,11 @@ function getSkillMetadata(target) {
|
|
|
38113
38254
|
}
|
|
38114
38255
|
return metadata;
|
|
38115
38256
|
}
|
|
38116
|
-
var
|
|
38257
|
+
var import_reflect_metadata32;
|
|
38117
38258
|
var init_skill_decorator = __esm({
|
|
38118
38259
|
"libs/sdk/src/common/decorators/skill.decorator.ts"() {
|
|
38119
38260
|
"use strict";
|
|
38120
|
-
|
|
38261
|
+
import_reflect_metadata32 = require("reflect-metadata");
|
|
38121
38262
|
init_tokens();
|
|
38122
38263
|
init_metadata();
|
|
38123
38264
|
}
|
|
@@ -40027,11 +40168,11 @@ var init_dynamic = __esm({
|
|
|
40027
40168
|
});
|
|
40028
40169
|
|
|
40029
40170
|
// libs/sdk/src/common/entries/base.entry.ts
|
|
40030
|
-
var
|
|
40171
|
+
var import_reflect_metadata33, BaseEntry;
|
|
40031
40172
|
var init_base_entry = __esm({
|
|
40032
40173
|
"libs/sdk/src/common/entries/base.entry.ts"() {
|
|
40033
40174
|
"use strict";
|
|
40034
|
-
|
|
40175
|
+
import_reflect_metadata33 = require("reflect-metadata");
|
|
40035
40176
|
BaseEntry = class {
|
|
40036
40177
|
ready;
|
|
40037
40178
|
record;
|
|
@@ -40064,11 +40205,11 @@ var init_scope_entry = __esm({
|
|
|
40064
40205
|
});
|
|
40065
40206
|
|
|
40066
40207
|
// libs/sdk/src/common/entries/flow.entry.ts
|
|
40067
|
-
var
|
|
40208
|
+
var import_reflect_metadata34, FlowEntry;
|
|
40068
40209
|
var init_flow_entry = __esm({
|
|
40069
40210
|
"libs/sdk/src/common/entries/flow.entry.ts"() {
|
|
40070
40211
|
"use strict";
|
|
40071
|
-
|
|
40212
|
+
import_reflect_metadata34 = require("reflect-metadata");
|
|
40072
40213
|
init_base_entry();
|
|
40073
40214
|
FlowEntry = class extends BaseEntry {
|
|
40074
40215
|
name;
|
|
@@ -41025,6 +41166,7 @@ __export(index_exports, {
|
|
|
41025
41166
|
buildRemoteResourceTemplateRecord: () => buildRemoteResourceTemplateRecord,
|
|
41026
41167
|
buildRemoteToolRecord: () => buildRemoteToolRecord,
|
|
41027
41168
|
canDeliverNotifications: () => canDeliverNotifications,
|
|
41169
|
+
clearCreateCache: () => clearCreateCache,
|
|
41028
41170
|
computeIssuer: () => computeIssuer,
|
|
41029
41171
|
computeResource: () => computeResource,
|
|
41030
41172
|
connect: () => connect,
|
|
@@ -41034,6 +41176,7 @@ __export(index_exports, {
|
|
|
41034
41176
|
connectVercelAI: () => connectVercelAI,
|
|
41035
41177
|
consentConfigSchema: () => consentConfigSchema,
|
|
41036
41178
|
consumePendingTC39Hooks: () => consumePendingTC39Hooks,
|
|
41179
|
+
create: () => create,
|
|
41037
41180
|
createChildSpanContext: () => createChildSpanContext,
|
|
41038
41181
|
createContextResolver: () => createContextResolver,
|
|
41039
41182
|
createDirectResolver: () => createDirectResolver,
|
|
@@ -41235,7 +41378,7 @@ __export(index_exports, {
|
|
|
41235
41378
|
withRetry: () => withRetry
|
|
41236
41379
|
});
|
|
41237
41380
|
module.exports = __toCommonJS(index_exports);
|
|
41238
|
-
var
|
|
41381
|
+
var import_reflect_metadata35 = require("reflect-metadata");
|
|
41239
41382
|
init_common();
|
|
41240
41383
|
init_front_mcp2();
|
|
41241
41384
|
init_serverless_handler();
|
|
@@ -41352,6 +41495,7 @@ init_config();
|
|
|
41352
41495
|
init_config();
|
|
41353
41496
|
init_direct();
|
|
41354
41497
|
init_direct();
|
|
41498
|
+
init_direct();
|
|
41355
41499
|
|
|
41356
41500
|
// libs/sdk/src/transport/index.ts
|
|
41357
41501
|
init_in_memory_server();
|
|
@@ -41646,6 +41790,7 @@ var AgentCallHook = FlowHooksOf("agents:call-agent");
|
|
|
41646
41790
|
buildRemoteResourceTemplateRecord,
|
|
41647
41791
|
buildRemoteToolRecord,
|
|
41648
41792
|
canDeliverNotifications,
|
|
41793
|
+
clearCreateCache,
|
|
41649
41794
|
computeIssuer,
|
|
41650
41795
|
computeResource,
|
|
41651
41796
|
connect,
|
|
@@ -41655,6 +41800,7 @@ var AgentCallHook = FlowHooksOf("agents:call-agent");
|
|
|
41655
41800
|
connectVercelAI,
|
|
41656
41801
|
consentConfigSchema,
|
|
41657
41802
|
consumePendingTC39Hooks,
|
|
41803
|
+
create,
|
|
41658
41804
|
createChildSpanContext,
|
|
41659
41805
|
createContextResolver,
|
|
41660
41806
|
createDirectResolver,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontmcp/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "FrontMCP SDK",
|
|
5
5
|
"author": "AgentFront <info@agentfront.dev>",
|
|
6
6
|
"homepage": "https://docs.agentfront.dev",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"cors": "^2.8.5",
|
|
63
63
|
"raw-body": "^3.0.0",
|
|
64
64
|
"content-type": "^1.0.5",
|
|
65
|
-
"vectoriadb": "^2.
|
|
65
|
+
"vectoriadb": "^2.1.3",
|
|
66
66
|
"@vercel/kv": "^3.0.0"
|
|
67
67
|
},
|
|
68
68
|
"peerDependenciesMeta": {
|
|
@@ -71,10 +71,10 @@
|
|
|
71
71
|
}
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
|
-
"@frontmcp/utils": "0.
|
|
75
|
-
"@frontmcp/di": "0.
|
|
76
|
-
"@frontmcp/uipack": "0.
|
|
77
|
-
"@frontmcp/auth": "0.
|
|
74
|
+
"@frontmcp/utils": "0.9.0",
|
|
75
|
+
"@frontmcp/di": "0.9.0",
|
|
76
|
+
"@frontmcp/uipack": "0.9.0",
|
|
77
|
+
"@frontmcp/auth": "0.9.0",
|
|
78
78
|
"@modelcontextprotocol/sdk": "1.25.3",
|
|
79
79
|
"@langchain/core": "^1.1.8",
|
|
80
80
|
"@langchain/openai": "^1.2.0",
|
|
@@ -1,11 +1,49 @@
|
|
|
1
1
|
import express from 'express';
|
|
2
2
|
import { HostServerAdapter } from './base.host.adapter';
|
|
3
3
|
import { HttpMethod, ServerRequestHandler } from '../../common';
|
|
4
|
+
/**
|
|
5
|
+
* CORS configuration options for ExpressHostAdapter.
|
|
6
|
+
*/
|
|
7
|
+
export interface ExpressCorsOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Allowed origins. Can be:
|
|
10
|
+
* - `true` to reflect the request origin (allows all origins with credentials)
|
|
11
|
+
* - `false` to disable CORS
|
|
12
|
+
* - `'*'` to allow all origins (no credentials)
|
|
13
|
+
* - A string for a single origin
|
|
14
|
+
* - An array of strings for multiple origins
|
|
15
|
+
* - A function that dynamically determines if an origin is allowed
|
|
16
|
+
* @default false (CORS disabled by default for security)
|
|
17
|
+
*/
|
|
18
|
+
origin?: boolean | string | string[] | ((origin: string | undefined, callback: (err: Error | null, allow?: boolean) => void) => void);
|
|
19
|
+
/**
|
|
20
|
+
* Whether to allow credentials (cookies, authorization headers).
|
|
21
|
+
* Cannot be used with `origin: '*'`.
|
|
22
|
+
* @default false
|
|
23
|
+
*/
|
|
24
|
+
credentials?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* How long preflight results can be cached (in seconds).
|
|
27
|
+
* @default 300
|
|
28
|
+
*/
|
|
29
|
+
maxAge?: number;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Options for ExpressHostAdapter.
|
|
33
|
+
*/
|
|
34
|
+
export interface ExpressHostAdapterOptions {
|
|
35
|
+
/**
|
|
36
|
+
* CORS configuration.
|
|
37
|
+
* For security, CORS is disabled by default.
|
|
38
|
+
* Enable it explicitly with appropriate origins.
|
|
39
|
+
*/
|
|
40
|
+
cors?: ExpressCorsOptions;
|
|
41
|
+
}
|
|
4
42
|
export declare class ExpressHostAdapter extends HostServerAdapter {
|
|
5
43
|
private app;
|
|
6
44
|
private router;
|
|
7
45
|
private prepared;
|
|
8
|
-
constructor();
|
|
46
|
+
constructor(options?: ExpressHostAdapterOptions);
|
|
9
47
|
registerRoute(method: HttpMethod, path: string, handler: ServerRequestHandler): void;
|
|
10
48
|
registerMiddleware(entryPath: string, handler: ServerRequestHandler): void;
|
|
11
49
|
enhancedHandler(handler: ServerRequestHandler): (req: express.Request, res: express.Response, next: express.NextFunction) => void | Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"express.host.adapter.d.ts","sourceRoot":"","sources":["../../../src/server/adapters/express.host.adapter.ts"],"names":[],"mappings":"AAEA,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAiB,oBAAoB,EAAkB,MAAM,cAAc,CAAC;AAE/F,qBAAa,kBAAmB,SAAQ,iBAAiB;IACvD,OAAO,CAAC,GAAG,CAAa;IACxB,OAAO,CAAC,MAAM,CAAoB;IAClC,OAAO,CAAC,QAAQ,CAAS
|
|
1
|
+
{"version":3,"file":"express.host.adapter.d.ts","sourceRoot":"","sources":["../../../src/server/adapters/express.host.adapter.ts"],"names":[],"mappings":"AAEA,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAiB,oBAAoB,EAAkB,MAAM,cAAc,CAAC;AAE/F;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;;;;;;;OASG;IACH,MAAM,CAAC,EACH,OAAO,GACP,MAAM,GACN,MAAM,EAAE,GACR,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE,QAAQ,EAAE,CAAC,GAAG,EAAE,KAAK,GAAG,IAAI,EAAE,KAAK,CAAC,EAAE,OAAO,KAAK,IAAI,KAAK,IAAI,CAAC,CAAC;IAEnG;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC;;;;OAIG;IACH,IAAI,CAAC,EAAE,kBAAkB,CAAC;CAC3B;AAED,qBAAa,kBAAmB,SAAQ,iBAAiB;IACvD,OAAO,CAAC,GAAG,CAAa;IACxB,OAAO,CAAC,MAAM,CAAoB;IAClC,OAAO,CAAC,QAAQ,CAAS;gBAEb,OAAO,CAAC,EAAE,yBAAyB;IA4B/C,aAAa,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,oBAAoB;IAI7E,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,oBAAoB;IAInE,eAAe,CAAC,OAAO,EAAE,oBAAoB,IACnC,KAAK,OAAO,CAAC,OAAO,EAAE,KAAK,OAAO,CAAC,QAAQ,EAAE,MAAM,OAAO,CAAC,YAAY;IAQjF;;;;OAIG;IACH,OAAO,IAAI,IAAI;IAMf;;;OAGG;IACH,UAAU,IAAI,OAAO,CAAC,WAAW;IAKjC,KAAK,CAAC,IAAI,EAAE,MAAM;CAQnB"}
|