@frontmcp/sdk 1.10.9-rc.1 → 1.10.9-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/agent/agent.registry.mjs +1 -1
- package/browser/app/instances/app.esm.instance.mjs +4 -4
- package/browser/app/instances/app.remote.instance.mjs +6 -6
- package/browser/auth/auth-ui/auth-ui.registry.mjs +6 -6
- package/browser/auth/flows/oauth.authorize.flow.mjs +5 -5
- package/browser/auth/flows/oauth.callback.flow.mjs +11 -11
- package/browser/auth/flows/oauth.connect.flow.mjs +1 -1
- package/browser/auth/flows/oauth.register.flow.mjs +1 -1
- package/browser/auth/flows/oauth.token.flow.mjs +1 -1
- package/browser/auth/flows/well-known.oauth-authorization-server.flow.mjs +5 -5
- package/browser/auth/instances/instance.local-primary-auth.mjs +10 -10
- package/browser/auth/session/utils/session-id.utils.mjs +1 -1
- package/browser/common/entries/skill.entry.mjs +2 -2
- package/browser/common/entries/tool.entry.mjs +3 -3
- package/browser/common/interfaces/channel.interface.mjs +1 -1
- package/browser/common/interfaces/execution-context.interface.mjs +4 -4
- package/browser/common/interfaces/internal/primary-auth-provider.interface.mjs +2 -2
- package/browser/common/metadata/app.metadata.mjs +1 -1
- package/browser/common/metadata/front-mcp.metadata.mjs +5 -5
- package/browser/common/tokens/app.tokens.mjs +1 -1
- package/browser/common/tokens/front-mcp.tokens.mjs +1 -1
- package/browser/common/types/options/http/schema.mjs +4 -4
- package/browser/common/types/options/redis/schema.mjs +1 -1
- package/browser/common/types/options/sqlite/schema.mjs +3 -3
- package/browser/common/types/options/transport/schema.mjs +4 -4
- package/browser/common/utils/decide-request-intent.utils.mjs +10 -10
- package/browser/context/frontmcp-context.mjs +1 -1
- package/browser/direct/direct-client.mjs +29 -29
- package/browser/direct/direct-server.mjs +14 -14
- package/browser/errors/job.errors.mjs +1 -1
- package/browser/errors/mcp.error.mjs +4 -4
- package/browser/errors/plugin.errors.mjs +1 -1
- package/browser/errors/task.error.mjs +1 -1
- package/browser/errors/tool-credentials-required.error.mjs +2 -2
- package/browser/esm-loader/esm-module-loader.mjs +1 -7
- package/browser/esm-loader/import-computed.mjs +11 -0
- package/browser/esm-loader/semver.utils.mjs +17 -11
- package/browser/flows/flow.instance.mjs +1 -1
- package/browser/front-mcp/front-mcp.mjs +10 -14
- package/browser/ha/ha-manager.mjs +1 -1
- package/browser/ha/notification-relay.mjs +1 -1
- package/browser/index.cjs +1226 -1453
- package/browser/index.mjs +4 -4
- package/browser/job/store/job-definition-store.factory.mjs +1 -1
- package/browser/job/store/redis-job-definition.store.mjs +2 -2
- package/browser/job/tools/get-job-status.tool.mjs +1 -1
- package/browser/logger/logger.registry.mjs +1 -1
- package/browser/metrics/metrics.service.mjs +3 -3
- package/browser/prompt/prompt.registry.mjs +1 -1
- package/browser/provider/provider.registry.mjs +4 -4
- package/browser/remote-mcp/mcp-client.service.mjs +19 -19
- package/browser/remote-mcp/resilience/circuit-breaker.mjs +2 -2
- package/browser/resource/resource.registry.mjs +2 -2
- package/browser/scope/flows/http.request.flow.mjs +3 -3
- package/browser/scope/scope.instance.mjs +4 -4
- package/browser/scope/scope.utils.mjs +1 -1
- package/browser/skill/providers/memory-skill.provider.mjs +2 -2
- package/browser/skill/skill.registry.mjs +10 -10
- package/browser/task/flows/tasks-result.flow.mjs +2 -2
- package/browser/task/task.registry.mjs +5 -5
- package/browser/tool/flows/call-tool.flow.mjs +4 -4
- package/browser/tool/tool.instance.mjs +4 -4
- package/browser/tool/tool.registry.mjs +4 -4
- package/browser/tool/ui/ui-shared.mjs +1 -1
- package/browser/transport/adapters/transport.local.adapter.mjs +2 -2
- package/browser/transport/adapters/transport.streamable-http.adapter.mjs +13 -4
- package/browser/transport/event-stores/redis.event-store.mjs +1 -1
- package/browser/transport/mcp-20260728/client/mcp-stateless.client.mjs +1 -1
- package/browser/transport/mcp-20260728/request-notifications.mjs +1 -1
- package/browser/transport/transport.registry.mjs +31 -24
- package/browser/transport/web-response.renderer.mjs +2 -2
- package/browser/utils/lineage.utils.mjs +1 -1
- package/browser/workflow/tools/get-workflow-status.tool.mjs +1 -1
- package/esm/esm-loader/import-computed.mjs +10 -0
- package/esm/index.mjs +136 -77113
- package/esm-loader/esm-module-loader.d.ts.map +1 -1
- package/esm-loader/import-computed.d.ts +21 -0
- package/esm-loader/import-computed.d.ts.map +1 -0
- package/esm-loader/import-computed.js +34 -0
- package/esm-loader/semver.utils.d.ts.map +1 -1
- package/front-mcp/front-mcp.d.ts.map +1 -1
- package/index.d.ts +9 -8
- package/index.d.ts.map +1 -1
- package/index.js +140 -77769
- package/package.json +14 -10
- package/transport/adapters/transport.streamable-http.adapter.d.ts +2 -1
- package/transport/adapters/transport.streamable-http.adapter.d.ts.map +1 -1
- package/transport/transport.registry.d.ts +4 -0
- package/transport/transport.registry.d.ts.map +1 -1
- package/browser/transport/index.mjs +0 -32
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
// libs/sdk/src/transport/adapters/transport.streamable-http.adapter.ts
|
|
2
2
|
import { toJSONSchema } from "@frontmcp/lazy-zod";
|
|
3
|
-
import { ElicitationTimeoutError } from "../../errors/index.mjs";
|
|
3
|
+
import { ElicitationTimeoutError, InternalMcpError } from "../../errors/index.mjs";
|
|
4
4
|
import { createSessionScopedEventStore } from "../event-stores/session-scoped.event-store.mjs";
|
|
5
5
|
import { rpcRequest } from "../transport.error.mjs";
|
|
6
6
|
import { STATELESS_SESSION_ID } from "../transport.types.mjs";
|
|
7
|
-
import { RecreateableStreamableHTTPServerTransport } from "./streamable-http-transport.mjs";
|
|
8
7
|
import { LocalTransportAdapter } from "./transport.local.adapter.mjs";
|
|
8
|
+
var RecreateableTransport;
|
|
9
|
+
async function loadStreamableHttpTransport() {
|
|
10
|
+
RecreateableTransport ??= (await import("./streamable-http-transport.mjs")).RecreateableStreamableHTTPServerTransport;
|
|
11
|
+
}
|
|
9
12
|
var resolveSessionIdGenerator = (transportType, sessionId) => {
|
|
10
13
|
return transportType === "stateless-http" ? () => STATELESS_SESSION_ID : () => sessionId;
|
|
11
14
|
};
|
|
@@ -15,7 +18,12 @@ var TransportStreamableHttpAdapter = class extends LocalTransportAdapter {
|
|
|
15
18
|
const sharedEventStore = this.scope.eventStore;
|
|
16
19
|
const eventStore = sharedEventStore ? createSessionScopedEventStore(sharedEventStore, sessionId) : void 0;
|
|
17
20
|
const isStateless = this.key.type === "stateless-http";
|
|
18
|
-
|
|
21
|
+
if (!RecreateableTransport) {
|
|
22
|
+
throw new InternalMcpError(
|
|
23
|
+
"The Streamable HTTP transport was used before loadStreamableHttpTransport() loaded it"
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
return new RecreateableTransport({
|
|
19
27
|
sessionIdGenerator,
|
|
20
28
|
isStateless,
|
|
21
29
|
onsessionclosed: () => {
|
|
@@ -47,7 +55,7 @@ var TransportStreamableHttpAdapter = class extends LocalTransportAdapter {
|
|
|
47
55
|
});
|
|
48
56
|
await this.ready;
|
|
49
57
|
this.logger.verbose("[StreamableHttpAdapter] transport state before handleRequest", {
|
|
50
|
-
isRecreatable: this.transport instanceof
|
|
58
|
+
isRecreatable: RecreateableTransport !== void 0 && this.transport instanceof RecreateableTransport,
|
|
51
59
|
hasWebTransport: !!this.transport._webStandardTransport,
|
|
52
60
|
webTransportInitialized: this.transport._webStandardTransport?._initialized,
|
|
53
61
|
webTransportStarted: this.transport._webStandardTransport?._started,
|
|
@@ -224,5 +232,6 @@ var TransportStreamableHttpAdapter = class extends LocalTransportAdapter {
|
|
|
224
232
|
};
|
|
225
233
|
export {
|
|
226
234
|
TransportStreamableHttpAdapter,
|
|
235
|
+
loadStreamableHttpTransport,
|
|
227
236
|
resolveSessionIdGenerator
|
|
228
237
|
};
|
|
@@ -116,7 +116,7 @@ var RedisEventStore = class {
|
|
|
116
116
|
* rather than data.
|
|
117
117
|
*
|
|
118
118
|
* The stream-id half is NOT character-filtered. `xadd`/`xrange` take the key
|
|
119
|
-
* as an exact argument
|
|
119
|
+
* as an exact argument \u2014 Redis applies no glob matching there \u2014 and ioredis
|
|
120
120
|
* length-prefixes it, so no character is special. Filtering here would also
|
|
121
121
|
* make `storeEvent`, which accepts any `StreamId`, able to mint ids this
|
|
122
122
|
* function then refuses, silently breaking replay for that stream. Ownership
|
|
@@ -158,7 +158,7 @@ var McpStatelessClient = class {
|
|
|
158
158
|
* Poll a task handle to a terminal state, answering mid-flight input requests.
|
|
159
159
|
*
|
|
160
160
|
* Honours the server's `pollIntervalMs` hint rather than picking our own
|
|
161
|
-
* cadence
|
|
161
|
+
* cadence \u2014 the server knows how long its work takes.
|
|
162
162
|
*/
|
|
163
163
|
async awaitTask(task) {
|
|
164
164
|
const taskId = String(task["taskId"]);
|
|
@@ -23,7 +23,7 @@ var RequestNotificationSink = class {
|
|
|
23
23
|
/**
|
|
24
24
|
* Queue a log message.
|
|
25
25
|
*
|
|
26
|
-
* Dropped outright when the client did not set `logLevel`
|
|
26
|
+
* Dropped outright when the client did not set `logLevel` \u2014 the spec makes
|
|
27
27
|
* that a MUST NOT, not a preference.
|
|
28
28
|
*/
|
|
29
29
|
log(level, logger, data) {
|
|
@@ -4,6 +4,7 @@ import { createSessionStore } from "../auth/session/session-store.factory.mjs";
|
|
|
4
4
|
import { isDeploymentSessionId } from "../auth/session/utils/session-id.utils.mjs";
|
|
5
5
|
import { sessionIdPresentedBy } from "../common/utils/auth-info.utils.mjs";
|
|
6
6
|
import { InvalidTransportSessionError, SessionClaimConflictError } from "../errors/transport.errors.mjs";
|
|
7
|
+
import { loadStreamableHttpTransport } from "./adapters/transport.streamable-http.adapter.mjs";
|
|
7
8
|
import HandleMcp20260728Flow from "./flows/handle.mcp-20260728.flow.mjs";
|
|
8
9
|
import HandleSseFlow from "./flows/handle.sse.flow.mjs";
|
|
9
10
|
import HandleStatelessHttpFlow from "./flows/handle.stateless-http.flow.mjs";
|
|
@@ -50,7 +51,7 @@ var TransportService = class {
|
|
|
50
51
|
persistenceConfig;
|
|
51
52
|
/**
|
|
52
53
|
* Pending store configuration for async initialization. Either a Redis/Vercel KV
|
|
53
|
-
* shape or a `{ sqlite: ... }` shape
|
|
54
|
+
* shape or a `{ sqlite: ... }` shape \u2014 discriminated in `createSessionStore`.
|
|
54
55
|
*/
|
|
55
56
|
pendingStoreConfig;
|
|
56
57
|
/** Set when the configured backend is SQLite. Used for telemetry-only branching. */
|
|
@@ -71,6 +72,13 @@ var TransportService = class {
|
|
|
71
72
|
* Key: JSON-encoded {t: type, h: tokenHash, s: sessionId}, Value: Promise that resolves when creation completes
|
|
72
73
|
*/
|
|
73
74
|
creationMutex = /* @__PURE__ */ new Map();
|
|
75
|
+
// The Streamable HTTP transport class loads with the first session that uses it, so stdio and SSE servers never load it.
|
|
76
|
+
async newLocalTransporter(key, res, onDispose) {
|
|
77
|
+
if (key.type === "streamable-http" || key.type === "stateless-http") {
|
|
78
|
+
await loadStreamableHttpTransport();
|
|
79
|
+
}
|
|
80
|
+
return new LocalTransporter(this.scope, key, res, onDispose);
|
|
81
|
+
}
|
|
74
82
|
/**
|
|
75
83
|
* Get the default TTL for session persistence.
|
|
76
84
|
* Returns undefined if persistence is disabled or not configured.
|
|
@@ -278,7 +286,7 @@ var TransportService = class {
|
|
|
278
286
|
/** True when a backend (Redis / Vercel KV / SQLite) was wired at construction.
|
|
279
287
|
* Note: this reflects construction-time intent, not live connection state.
|
|
280
288
|
* A `false` here means no backend was configured at all; a `true` does NOT
|
|
281
|
-
* guarantee the store is currently reachable
|
|
289
|
+
* guarantee the store is currently reachable \u2014 use `pingSessionStore()` for
|
|
282
290
|
* that signal. */
|
|
283
291
|
isSessionStoreConfigured() {
|
|
284
292
|
return this.sessionStoreConfigured;
|
|
@@ -348,7 +356,7 @@ var TransportService = class {
|
|
|
348
356
|
* owns the session it presents. `undefined` means "serve it here": the session is local,
|
|
349
357
|
* unknown, owned by this node, or owned by a node that stopped (this node takes it over).
|
|
350
358
|
*
|
|
351
|
-
* Runs before authentication
|
|
359
|
+
* Runs before authentication \u2014 it only decides where the request is served; the owner
|
|
352
360
|
* authenticates it. Only session ids this deployment minted cost a Redis lookup.
|
|
353
361
|
*/
|
|
354
362
|
async findRemoteSessionOwner(request) {
|
|
@@ -659,8 +667,7 @@ var TransportService = class {
|
|
|
659
667
|
this.sessionHistory.set(historyKey, storedSession.createdAt);
|
|
660
668
|
const sessionStore = this.sessionStore;
|
|
661
669
|
const defaultTtlMs = this.getDefaultTtlMs();
|
|
662
|
-
const transporter =
|
|
663
|
-
this.scope,
|
|
670
|
+
const transporter = await this.newLocalTransporter(
|
|
664
671
|
key,
|
|
665
672
|
res,
|
|
666
673
|
() => this.onSessionTransportDisposed(key, sessionId, sessionStore)
|
|
@@ -720,8 +727,7 @@ var TransportService = class {
|
|
|
720
727
|
if (existing) return existing;
|
|
721
728
|
const sessionStore = this.sessionStore;
|
|
722
729
|
const defaultTtlMs = this.getDefaultTtlMs();
|
|
723
|
-
const transporter =
|
|
724
|
-
this.scope,
|
|
730
|
+
const transporter = await this.newLocalTransporter(
|
|
725
731
|
key,
|
|
726
732
|
res,
|
|
727
733
|
() => this.onSessionTransportDisposed(key, sessionId, sessionStore)
|
|
@@ -844,31 +850,32 @@ var TransportService = class {
|
|
|
844
850
|
* All anonymous requests share the same transport instance.
|
|
845
851
|
*/
|
|
846
852
|
async getOrCreateAnonymousStatelessTransport(type, res) {
|
|
847
|
-
|
|
848
|
-
const existing = this.lookupLocal(key);
|
|
849
|
-
if (existing) return existing;
|
|
850
|
-
const transporter = new LocalTransporter(this.scope, key, res, () => {
|
|
851
|
-
this.evictLocal(key);
|
|
852
|
-
if (this.distributed && this.bus) {
|
|
853
|
-
this.bus.revoke(key).catch(() => void 0);
|
|
854
|
-
}
|
|
855
|
-
});
|
|
856
|
-
await transporter.ready();
|
|
857
|
-
this.insertLocal(key, transporter);
|
|
858
|
-
if (this.distributed && this.bus) {
|
|
859
|
-
await this.bus.advertise(key);
|
|
860
|
-
}
|
|
861
|
-
return transporter;
|
|
853
|
+
return this.getOrCreateStatelessTransport(this.keyOf(type, "__anonymous__", STATELESS_SESSION_ID), res);
|
|
862
854
|
}
|
|
863
855
|
/**
|
|
864
856
|
* Get or create a singleton transport for authenticated stateless requests.
|
|
865
857
|
* Each unique token gets its own singleton transport.
|
|
866
858
|
*/
|
|
867
859
|
async getOrCreateAuthenticatedStatelessTransport(type, token, res) {
|
|
868
|
-
|
|
860
|
+
return this.getOrCreateStatelessTransport(this.keyOf(type, token, STATELESS_SESSION_ID), res);
|
|
861
|
+
}
|
|
862
|
+
/** Concurrent first requests share one creation, so a second transport never replaces the first and gets evicted with it. */
|
|
863
|
+
async getOrCreateStatelessTransport(key, res) {
|
|
869
864
|
const existing = this.lookupLocal(key);
|
|
870
865
|
if (existing) return existing;
|
|
871
|
-
const
|
|
866
|
+
const mutexKey = JSON.stringify({ t: key.type, h: key.tokenHash, s: key.sessionId });
|
|
867
|
+
const pendingCreation = this.creationMutex.get(mutexKey);
|
|
868
|
+
if (pendingCreation) return pendingCreation;
|
|
869
|
+
const creationPromise = this.doCreateStatelessTransport(key, res);
|
|
870
|
+
this.creationMutex.set(mutexKey, creationPromise);
|
|
871
|
+
try {
|
|
872
|
+
return await creationPromise;
|
|
873
|
+
} finally {
|
|
874
|
+
this.creationMutex.delete(mutexKey);
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
async doCreateStatelessTransport(key, res) {
|
|
878
|
+
const transporter = await this.newLocalTransporter(key, res, () => {
|
|
872
879
|
this.evictLocal(key);
|
|
873
880
|
if (this.distributed && this.bus) {
|
|
874
881
|
this.bus.revoke(key).catch(() => void 0);
|
|
@@ -48,10 +48,10 @@ function buildHeaders(out, contentType) {
|
|
|
48
48
|
function renderHttpOutputToWebResponse(output) {
|
|
49
49
|
const out = output;
|
|
50
50
|
switch (out.kind) {
|
|
51
|
-
// Already a Web Response (the MCP execute stage on a worker)
|
|
51
|
+
// Already a Web Response (the MCP execute stage on a worker) \u2014 return verbatim.
|
|
52
52
|
case "web-response":
|
|
53
53
|
return out.response;
|
|
54
|
-
// "no response"
|
|
54
|
+
// "no response" \u2014 let the adapter fall through (404 / next middleware).
|
|
55
55
|
case "next":
|
|
56
56
|
case "consumed":
|
|
57
57
|
return void 0;
|
|
@@ -51,7 +51,7 @@ var EntryLineageIndex = class {
|
|
|
51
51
|
if (!this.lineages.has(row.instance)) this.lineages.set(row.instance, row.lineage);
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
-
/** Owner lineage (root
|
|
54
|
+
/** Owner lineage (root \u2192 leaf) of an entry, or undefined when no row holds it. */
|
|
55
55
|
lineageOf(entry) {
|
|
56
56
|
return this.lineages.get(entry);
|
|
57
57
|
}
|
|
@@ -41,7 +41,7 @@ var GetWorkflowStatusTool = class extends ToolContext {
|
|
|
41
41
|
*
|
|
42
42
|
* A record carrying NEITHER identity is refused. Such a run cannot be
|
|
43
43
|
* attributed to anyone, and its inputs and results are exactly what this check
|
|
44
|
-
* exists to protect
|
|
44
|
+
* exists to protect \u2014 anyone holding the id would otherwise be able to read
|
|
45
45
|
* it. Internal callers that must read unattributed runs should go through the
|
|
46
46
|
* execution manager directly rather than this tool.
|
|
47
47
|
*/
|