@ggui-ai/mcp-server 0.2.0-alpha.4 → 0.4.0-rc.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/dist/admin-blueprints-transport.d.ts.map +1 -1
- package/dist/admin-blueprints-transport.js +2 -1
- package/dist/admin-oauth-providers-transport.d.ts.map +1 -1
- package/dist/admin-oauth-providers-transport.js +7 -5
- package/dist/api-renders-routes.d.ts +85 -0
- package/dist/api-renders-routes.d.ts.map +1 -0
- package/dist/api-renders-routes.js +372 -0
- package/dist/build-mcp.d.ts +2 -2
- package/dist/build-mcp.d.ts.map +1 -1
- package/dist/build-mcp.js +64 -5
- package/dist/code-routes.d.ts +47 -0
- package/dist/code-routes.d.ts.map +1 -0
- package/dist/code-routes.js +81 -0
- package/dist/code-store-fs.js +2 -2
- package/dist/console-auth.d.ts +10 -10
- package/dist/console-auth.d.ts.map +1 -1
- package/dist/console-auth.js +5 -5
- package/dist/console-blueprint-routes.d.ts +71 -0
- package/dist/console-blueprint-routes.d.ts.map +1 -0
- package/dist/console-blueprint-routes.js +348 -0
- package/dist/console-chat-routes.d.ts +80 -0
- package/dist/console-chat-routes.d.ts.map +1 -0
- package/dist/console-chat-routes.js +204 -0
- package/dist/console-config-routes.d.ts +37 -0
- package/dist/console-config-routes.d.ts.map +1 -0
- package/dist/console-config-routes.js +91 -0
- package/dist/console-headers.d.ts +1 -1
- package/dist/console-info-routes.d.ts +84 -0
- package/dist/console-info-routes.d.ts.map +1 -0
- package/dist/console-info-routes.js +135 -0
- package/dist/console-keys-routes.d.ts +50 -0
- package/dist/console-keys-routes.d.ts.map +1 -0
- package/dist/console-keys-routes.js +222 -0
- package/dist/console-llm-keys-routes.d.ts +47 -0
- package/dist/console-llm-keys-routes.d.ts.map +1 -0
- package/dist/console-llm-keys-routes.js +443 -0
- package/dist/console-mcp-tools-routes.d.ts +41 -0
- package/dist/console-mcp-tools-routes.d.ts.map +1 -0
- package/dist/console-mcp-tools-routes.js +60 -0
- package/dist/console-registry-routes.d.ts +66 -0
- package/dist/console-registry-routes.d.ts.map +1 -0
- package/dist/console-registry-routes.js +276 -0
- package/dist/console-session-routes.d.ts +89 -0
- package/dist/console-session-routes.d.ts.map +1 -0
- package/dist/console-session-routes.js +385 -0
- package/dist/console-sessions-routes.d.ts +52 -0
- package/dist/console-sessions-routes.d.ts.map +1 -0
- package/dist/console-sessions-routes.js +106 -0
- package/dist/console-static-routes.d.ts +54 -0
- package/dist/console-static-routes.d.ts.map +1 -0
- package/dist/console-static-routes.js +190 -0
- package/dist/console-theme-routes.d.ts +3 -3
- package/dist/console-theme-routes.js +1 -1
- package/dist/console-timeline.d.ts +5 -5
- package/dist/console-timeline.d.ts.map +1 -1
- package/dist/console-timeline.js +27 -26
- package/dist/console-welcome.js +2 -2
- package/dist/email-login.d.ts.map +1 -1
- package/dist/email-login.js +2 -3
- package/dist/ggui-session-channel/action-ingress.d.ts +54 -0
- package/dist/ggui-session-channel/action-ingress.d.ts.map +1 -0
- package/dist/ggui-session-channel/action-ingress.js +228 -0
- package/dist/ggui-session-channel/channel-subscriptions.d.ts +97 -0
- package/dist/ggui-session-channel/channel-subscriptions.d.ts.map +1 -0
- package/dist/ggui-session-channel/channel-subscriptions.js +224 -0
- package/dist/ggui-session-channel/internal-types.d.ts +102 -0
- package/dist/ggui-session-channel/internal-types.d.ts.map +1 -0
- package/dist/ggui-session-channel/internal-types.js +6 -0
- package/dist/ggui-session-channel/outbound.d.ts +81 -0
- package/dist/ggui-session-channel/outbound.d.ts.map +1 -0
- package/dist/ggui-session-channel/outbound.js +174 -0
- package/dist/ggui-session-channel/socket-router.d.ts +38 -0
- package/dist/ggui-session-channel/socket-router.d.ts.map +1 -0
- package/dist/ggui-session-channel/socket-router.js +213 -0
- package/dist/ggui-session-channel/subscribe.d.ts +165 -0
- package/dist/ggui-session-channel/subscribe.d.ts.map +1 -0
- package/dist/ggui-session-channel/subscribe.js +370 -0
- package/dist/ggui-session-channel/subscriber-lifecycle.d.ts +40 -0
- package/dist/ggui-session-channel/subscriber-lifecycle.d.ts.map +1 -0
- package/dist/ggui-session-channel/subscriber-lifecycle.js +123 -0
- package/dist/ggui-session-channel.d.ts +425 -0
- package/dist/ggui-session-channel.d.ts.map +1 -0
- package/dist/ggui-session-channel.js +262 -0
- package/dist/health-routes.d.ts +76 -0
- package/dist/health-routes.d.ts.map +1 -0
- package/dist/health-routes.js +145 -0
- package/dist/index.d.ts +10 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -9
- package/dist/instructions-presets.d.ts +3 -3
- package/dist/instructions-presets.js +24 -24
- package/dist/llm-backed-negotiator.d.ts +68 -67
- package/dist/llm-backed-negotiator.d.ts.map +1 -1
- package/dist/llm-backed-negotiator.js +82 -221
- package/dist/mcp-apps-outbound.d.ts +47 -48
- package/dist/mcp-apps-outbound.d.ts.map +1 -1
- package/dist/mcp-apps-outbound.js +154 -177
- package/dist/mcp-endpoint-routes.d.ts +88 -0
- package/dist/mcp-endpoint-routes.d.ts.map +1 -0
- package/dist/mcp-endpoint-routes.js +359 -0
- package/dist/mcp-mounts.d.ts +2 -76
- package/dist/mcp-mounts.d.ts.map +1 -1
- package/dist/mcp-mounts.js +0 -76
- package/dist/oauth-as-routes.d.ts +60 -0
- package/dist/oauth-as-routes.d.ts.map +1 -0
- package/dist/oauth-as-routes.js +82 -0
- package/dist/oauth-clients-routes.d.ts +39 -0
- package/dist/oauth-clients-routes.d.ts.map +1 -0
- package/dist/oauth-clients-routes.js +87 -0
- package/dist/oauth-login-types.d.ts +1 -20
- package/dist/oauth-login-types.d.ts.map +1 -1
- package/dist/oauth-login-types.js +30 -7
- package/dist/oauth-login.d.ts.map +1 -1
- package/dist/oauth-login.js +3 -2
- package/dist/oauth-providers-store.d.ts.map +1 -1
- package/dist/oauth-providers-store.js +5 -5
- package/dist/oauth.d.ts +9 -8
- package/dist/oauth.d.ts.map +1 -1
- package/dist/oauth.js +41 -19
- package/dist/pairing-transport.d.ts.map +1 -1
- package/dist/pairing-transport.js +2 -1
- package/dist/request-context.d.ts +2 -2
- package/dist/request-context.js +2 -2
- package/dist/reserved-validators.d.ts.map +1 -1
- package/dist/reserved-validators.js +9 -1
- package/dist/route-param.d.ts +9 -0
- package/dist/route-param.d.ts.map +1 -0
- package/dist/route-param.js +10 -0
- package/dist/runtime-bundle-route.d.ts +43 -0
- package/dist/runtime-bundle-route.d.ts.map +1 -0
- package/dist/runtime-bundle-route.js +80 -0
- package/dist/schema-compat.d.ts +64 -62
- package/dist/schema-compat.d.ts.map +1 -1
- package/dist/schema-compat.js +23 -51
- package/dist/server.d.ts +179 -193
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +644 -3759
- package/dist/storage.d.ts +5 -5
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +5 -5
- package/dist/thread-transport.d.ts.map +1 -1
- package/dist/thread-transport.js +4 -3
- package/dist/user-session-auth.d.ts +7 -21
- package/dist/user-session-auth.d.ts.map +1 -1
- package/dist/user-session-auth.js +7 -28
- package/package.json +16 -15
- package/dist/mcp-apps-inbound.d.ts +0 -86
- package/dist/mcp-apps-inbound.d.ts.map +0 -1
- package/dist/mcp-apps-inbound.js +0 -283
- package/dist/render-channel.d.ts +0 -694
- package/dist/render-channel.d.ts.map +0 -1
- package/dist/render-channel.js +0 -1775
package/dist/storage.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { GguiSessionStore, ThreadStore, VectorStore } from '@ggui-ai/mcp-server-core';
|
|
2
2
|
import type { StorageConfig } from '@ggui-ai/project-config';
|
|
3
3
|
export interface ResolveStorageFromConfigOptions {
|
|
4
4
|
/**
|
|
5
5
|
* Directory used to resolve relative `path` values in the storage
|
|
6
6
|
* config. Typically the directory containing `ggui.json` so a
|
|
7
|
-
* manifest saying `"path": "./ggui-
|
|
7
|
+
* manifest saying `"path": "./ggui-sessions.sqlite"` lands next to
|
|
8
8
|
* the manifest (not CWD, which would silently create a file wherever
|
|
9
9
|
* the process happened to be started).
|
|
10
10
|
*
|
|
@@ -16,9 +16,9 @@ export interface ResolveStorageFromConfigOptions {
|
|
|
16
16
|
readonly baseDir?: string;
|
|
17
17
|
}
|
|
18
18
|
export interface ResolvedStorageStores {
|
|
19
|
-
/** Concrete
|
|
19
|
+
/** Concrete GguiSessionStore, iff the config declared one. Undefined =
|
|
20
20
|
* caller falls back to createGguiServer's in-memory default. */
|
|
21
|
-
readonly renderStore?:
|
|
21
|
+
readonly renderStore?: GguiSessionStore;
|
|
22
22
|
/** Concrete VectorStore, iff the config declared one. Undefined =
|
|
23
23
|
* caller falls back to createGguiServer's in-memory default. */
|
|
24
24
|
readonly vectors?: VectorStore;
|
|
@@ -66,7 +66,7 @@ export interface ResolvedStorageStores {
|
|
|
66
66
|
* memory is the same outcome
|
|
67
67
|
* as omitting it; present
|
|
68
68
|
* for intent visibility).
|
|
69
|
-
* - `driver: 'sqlite'` → `
|
|
69
|
+
* - `driver: 'sqlite'` → `SqliteGguiSessionStore` /
|
|
70
70
|
* `SqliteVectorStore`.
|
|
71
71
|
*
|
|
72
72
|
* - `threads`:
|
package/dist/storage.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAqDA,OAAO,KAAK,EACV,
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAqDA,OAAO,KAAK,EACV,gBAAgB,EAChB,WAAW,EACX,WAAW,EACZ,MAAM,0BAA0B,CAAC;AAQlC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAE7D,MAAM,WAAW,+BAA+B;IAC9C;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,qBAAqB;IACpC;oEACgE;IAChE,QAAQ,CAAC,WAAW,CAAC,EAAE,gBAAgB,CAAC;IACxC;oEACgE;IAChE,QAAQ,CAAC,OAAO,CAAC,EAAE,WAAW,CAAC;IAC/B;;;;;;;;;;;;;;;;;yCAiBqC;IACrC,QAAQ,CAAC,WAAW,CAAC,EAAE,WAAW,CAAC;IACnC;;;;;;OAMG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,SAAS,GAAG,WAAW,CAAC;CACrD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,aAAa,GAAG,SAAS,EACjC,IAAI,GAAE,+BAAoC,GACzC,OAAO,CAAC,qBAAqB,CAAC,CAgDhC"}
|
package/dist/storage.js
CHANGED
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
* ## Why `better-sqlite3` gets imported dynamically
|
|
28
28
|
*
|
|
29
29
|
* `better-sqlite3` is an optional peer dep of `@ggui-ai/mcp-server-core`.
|
|
30
|
-
* If we `import {
|
|
30
|
+
* If we `import { SqliteGguiSessionStore } from '@ggui-ai/mcp-server-core/sqlite'`
|
|
31
31
|
* at the top of this file, any consumer that doesn't opt into SQLite
|
|
32
32
|
* storage still pays the peer-dep cost (the module graph resolves the
|
|
33
33
|
* subpath at import time, which tries to load better-sqlite3's N-API
|
|
@@ -55,7 +55,7 @@ import path from 'node:path';
|
|
|
55
55
|
// adapters, the in-memory subpath carries no optional peer dep cost
|
|
56
56
|
// (no `better-sqlite3`, no N-API binding). `storage.threads.driver =
|
|
57
57
|
// 'memory'` uses this to mount actual thread routes instead of being
|
|
58
|
-
// a silent no-op like
|
|
58
|
+
// a silent no-op like renders/vectors (which createGguiServer
|
|
59
59
|
// already defaults to in-memory internally).
|
|
60
60
|
import { InMemoryThreadStore } from '@ggui-ai/mcp-server-core/in-memory';
|
|
61
61
|
/**
|
|
@@ -74,7 +74,7 @@ import { InMemoryThreadStore } from '@ggui-ai/mcp-server-core/in-memory';
|
|
|
74
74
|
* memory is the same outcome
|
|
75
75
|
* as omitting it; present
|
|
76
76
|
* for intent visibility).
|
|
77
|
-
* - `driver: 'sqlite'` → `
|
|
77
|
+
* - `driver: 'sqlite'` → `SqliteGguiSessionStore` /
|
|
78
78
|
* `SqliteVectorStore`.
|
|
79
79
|
*
|
|
80
80
|
* - `threads`:
|
|
@@ -113,11 +113,11 @@ export async function resolveStorageFromConfig(config, opts = {}) {
|
|
|
113
113
|
// Single dynamic import serves every sqlite adapter — better-sqlite3's
|
|
114
114
|
// N-API binding loads once even if the import lands twice; the
|
|
115
115
|
// subpath barrel is cached by Node's module loader.
|
|
116
|
-
const {
|
|
116
|
+
const { SqliteGguiSessionStore, SqliteVectorStore, SqliteThreadStore } = await import('@ggui-ai/mcp-server-core/sqlite');
|
|
117
117
|
if (config.renders && config.renders.driver === 'sqlite') {
|
|
118
118
|
const filename = resolveStoragePath(config.renders.path, opts.baseDir);
|
|
119
119
|
ensureParentDir(filename);
|
|
120
|
-
result.renderStore = new
|
|
120
|
+
result.renderStore = new SqliteGguiSessionStore({ filename });
|
|
121
121
|
}
|
|
122
122
|
if (config.vectors && config.vectors.driver === 'sqlite') {
|
|
123
123
|
const filename = resolveStoragePath(config.vectors.path, opts.baseDir);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thread-transport.d.ts","sourceRoot":"","sources":["../src/thread-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,OAAO,KAAK,EAAE,OAAO,EAAqB,MAAM,SAAS,CAAC;AAE1D,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,WAAW,EACZ,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"thread-transport.d.ts","sourceRoot":"","sources":["../src/thread-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,OAAO,KAAK,EAAE,OAAO,EAAqB,MAAM,SAAS,CAAC;AAE1D,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,WAAW,EACZ,MAAM,0BAA0B,CAAC;AAkBlC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,2DAA2D;AAC3D,eAAO,MAAM,oBAAoB,aAAa,CAAC;AAE/C;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,MAAM,EAAE,UAAU,KAAK,MAAM,CAAC;AAEjE,eAAO,MAAM,wBAAwB,YAAY,CAAC;AAElD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,8BAA8B,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAqBzE;AAED,MAAM,WAAW,sBAAsB;IACrC,mEAAmE;IACnE,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAC5B;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,8DAA8D;IAC9D,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;OAKG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,mBAAmB,CAAC;CAClD;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,OAAO,EACZ,IAAI,EAAE,sBAAsB,GAC3B,IAAI,CAuYN"}
|
package/dist/thread-transport.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
2
|
import { appendMessage, applyThreadAction, createThread, getThread, InvalidThreadActionError, InvalidThreadRequestError, listMessages, listThreads, observeMessages, ThreadActionInvalidStateError, ThreadNotFoundError, } from '@ggui-ai/mcp-server-handlers/threads';
|
|
3
|
+
import { isRecord } from '@ggui-ai/protocol';
|
|
3
4
|
import { resolveIdentity, UnauthenticatedError } from './auth.js';
|
|
4
5
|
/** Default URL prefix the thread routes are mounted at. */
|
|
5
6
|
export const DEFAULT_THREADS_PATH = '/threads';
|
|
@@ -205,8 +206,8 @@ export function mountThreadTransport(app, opts) {
|
|
|
205
206
|
//
|
|
206
207
|
// Body: `{ action: ThreadStateAction }`. PATCH picked (over POST
|
|
207
208
|
// on `/:id/actions`) because the action is a state transition on
|
|
208
|
-
// the resource, not a new sub-resource
|
|
209
|
-
//
|
|
209
|
+
// the resource, not a new sub-resource — the same framing the
|
|
210
|
+
// thread-adapter interface uses (`updateThreadState`).
|
|
210
211
|
app.patch(`${prefix}/:id`, async (req, res) => {
|
|
211
212
|
const routeLogger = opts.logger.child({
|
|
212
213
|
route: 'PATCH ' + prefix + '/:id',
|
|
@@ -256,7 +257,7 @@ export function mountThreadTransport(app, opts) {
|
|
|
256
257
|
if (!ctx)
|
|
257
258
|
return;
|
|
258
259
|
try {
|
|
259
|
-
const body =
|
|
260
|
+
const body = isRecord(req.body) ? req.body : {};
|
|
260
261
|
const input = { ...body, threadId: req.params.id };
|
|
261
262
|
const message = await appendMessage(deps, input, ctx);
|
|
262
263
|
res.status(201).json(message);
|
|
@@ -60,9 +60,10 @@ import type { Request, RequestHandler } from 'express';
|
|
|
60
60
|
* Cookie name. Distinct from `ggui_console_session` so cross-kind
|
|
61
61
|
* confusion is impossible — a cookie value never gets misinterpreted
|
|
62
62
|
* as a different auth artifact. Change carries a compat concern (the
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
63
|
+
* login mint endpoints and `cookieAuthMiddleware` read this exact
|
|
64
|
+
* name); keep this export as the single source of truth. NOTE: no
|
|
65
|
+
* server-side clear route exists today — the cookie expires via
|
|
66
|
+
* `Max-Age` only (8h default).
|
|
66
67
|
*/
|
|
67
68
|
export declare const USER_SESSION_COOKIE_NAME = "ggui_user_session";
|
|
68
69
|
/**
|
|
@@ -107,20 +108,6 @@ export interface FormatUserSessionCookieInput {
|
|
|
107
108
|
* symmetrically.
|
|
108
109
|
*/
|
|
109
110
|
export declare function formatUserSessionCookieHeader(input: FormatUserSessionCookieInput): string;
|
|
110
|
-
/**
|
|
111
|
-
* Format a `Set-Cookie` header that immediately invalidates the
|
|
112
|
-
* user-session cookie. Used by `/logout` and `/revoke-bearer` so the
|
|
113
|
-
* browser drops it without waiting for `Max-Age`.
|
|
114
|
-
*
|
|
115
|
-
* `Max-Age=0` is the canonical clear pattern; matching attrs (Path,
|
|
116
|
-
* Secure) are required so the browser pairs this with the original
|
|
117
|
-
* mint and replaces it.
|
|
118
|
-
*/
|
|
119
|
-
export declare function formatClearUserSessionCookieHeader(input: {
|
|
120
|
-
readonly secure?: boolean;
|
|
121
|
-
readonly path?: string;
|
|
122
|
-
readonly sameSite?: 'Strict' | 'Lax' | 'None';
|
|
123
|
-
}): string;
|
|
124
111
|
/**
|
|
125
112
|
* Read the user-session cookie value from a `Cookie` header string.
|
|
126
113
|
* Returns the URL-decoded bearer, or `null` when the cookie is absent
|
|
@@ -158,10 +145,9 @@ export declare function readUserSessionCookieFromHeaders(headers: IncomingHttpHe
|
|
|
158
145
|
*/
|
|
159
146
|
export declare function cookieAuthMiddleware(): RequestHandler;
|
|
160
147
|
/**
|
|
161
|
-
* Read the user-session cookie off an Express request. Used by
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
* that need to inspect the cookie without going through middleware.
|
|
148
|
+
* Read the user-session cookie off an Express request. Used by tests
|
|
149
|
+
* that need to inspect the cookie without going through middleware,
|
|
150
|
+
* and available to embedders composing their own session routes.
|
|
165
151
|
*/
|
|
166
152
|
export declare function readUserSessionCookie(req: Request): string | null;
|
|
167
153
|
//# sourceMappingURL=user-session-auth.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-session-auth.d.ts","sourceRoot":"","sources":["../src/user-session-auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AACH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEvD
|
|
1
|
+
{"version":3,"file":"user-session-auth.d.ts","sourceRoot":"","sources":["../src/user-session-auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AACH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEvD;;;;;;;;GAQG;AACH,eAAO,MAAM,wBAAwB,sBAAsB,CAAC;AAE5D;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,QAAc,CAAC;AAExD,MAAM,WAAW,4BAA4B;IAC3C,8DAA8D;IAC9D,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,+EAA+E;IAC/E,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,oCAAoC;IACpC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;;;;OAQG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,GAAG,KAAK,GAAG,MAAM,CAAC;CAC/C;AAED;;;;;;;GAOG;AACH,wBAAgB,6BAA6B,CAC3C,KAAK,EAAE,4BAA4B,GAClC,MAAM,CAWR;AAED;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CACtC,YAAY,EAAE,MAAM,GAAG,SAAS,GAC/B,MAAM,GAAG,IAAI,CAqBf;AAED;;;;GAIG;AACH,wBAAgB,gCAAgC,CAC9C,OAAO,EAAE,mBAAmB,GAC3B,MAAM,GAAG,IAAI,CAIf;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,oBAAoB,IAAI,cAAc,CAYrD;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAEjE"}
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
* Cookie name. Distinct from `ggui_console_session` so cross-kind
|
|
3
3
|
* confusion is impossible — a cookie value never gets misinterpreted
|
|
4
4
|
* as a different auth artifact. Change carries a compat concern (the
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* login mint endpoints and `cookieAuthMiddleware` read this exact
|
|
6
|
+
* name); keep this export as the single source of truth. NOTE: no
|
|
7
|
+
* server-side clear route exists today — the cookie expires via
|
|
8
|
+
* `Max-Age` only (8h default).
|
|
8
9
|
*/
|
|
9
10
|
export const USER_SESSION_COOKIE_NAME = 'ggui_user_session';
|
|
10
11
|
/**
|
|
@@ -36,27 +37,6 @@ export function formatUserSessionCookieHeader(input) {
|
|
|
36
37
|
attrs.push('Secure');
|
|
37
38
|
return attrs.join('; ');
|
|
38
39
|
}
|
|
39
|
-
/**
|
|
40
|
-
* Format a `Set-Cookie` header that immediately invalidates the
|
|
41
|
-
* user-session cookie. Used by `/logout` and `/revoke-bearer` so the
|
|
42
|
-
* browser drops it without waiting for `Max-Age`.
|
|
43
|
-
*
|
|
44
|
-
* `Max-Age=0` is the canonical clear pattern; matching attrs (Path,
|
|
45
|
-
* Secure) are required so the browser pairs this with the original
|
|
46
|
-
* mint and replaces it.
|
|
47
|
-
*/
|
|
48
|
-
export function formatClearUserSessionCookieHeader(input) {
|
|
49
|
-
const attrs = [
|
|
50
|
-
`${USER_SESSION_COOKIE_NAME}=`,
|
|
51
|
-
`Path=${input.path ?? '/'}`,
|
|
52
|
-
`Max-Age=0`,
|
|
53
|
-
`SameSite=${input.sameSite ?? 'Lax'}`,
|
|
54
|
-
`HttpOnly`,
|
|
55
|
-
];
|
|
56
|
-
if (input.secure)
|
|
57
|
-
attrs.push('Secure');
|
|
58
|
-
return attrs.join('; ');
|
|
59
|
-
}
|
|
60
40
|
/**
|
|
61
41
|
* Read the user-session cookie value from a `Cookie` header string.
|
|
62
42
|
* Returns the URL-decoded bearer, or `null` when the cookie is absent
|
|
@@ -138,10 +118,9 @@ export function cookieAuthMiddleware() {
|
|
|
138
118
|
};
|
|
139
119
|
}
|
|
140
120
|
/**
|
|
141
|
-
* Read the user-session cookie off an Express request. Used by
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
* that need to inspect the cookie without going through middleware.
|
|
121
|
+
* Read the user-session cookie off an Express request. Used by tests
|
|
122
|
+
* that need to inspect the cookie without going through middleware,
|
|
123
|
+
* and available to embedders composing their own session routes.
|
|
145
124
|
*/
|
|
146
125
|
export function readUserSessionCookie(req) {
|
|
147
126
|
return readUserSessionCookieFromHeaders(req.headers);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ggui-ai/mcp-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0-rc.0",
|
|
4
4
|
"description": "Self-hosted MCP server for the ggui protocol. An HTTP/MCP binding layer over @ggui-ai/mcp-server-handlers and the reference adapters from @ggui-ai/mcp-server-core — run it via `ggui serve`.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ggui",
|
|
@@ -27,29 +27,30 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@modelcontextprotocol/ext-apps": "^1.7.2",
|
|
29
29
|
"@modelcontextprotocol/sdk": "^1.27.0",
|
|
30
|
-
"express": "^
|
|
30
|
+
"express": "^5.2.1",
|
|
31
31
|
"nodemailer": "^8.0.7",
|
|
32
32
|
"resend": "^6.12.2",
|
|
33
33
|
"ws": "^8.20.1",
|
|
34
34
|
"zod": "^4.3.6",
|
|
35
|
-
"@ggui-ai/console": "0.
|
|
36
|
-
"@ggui-ai/
|
|
37
|
-
"@ggui-ai/
|
|
38
|
-
"@ggui-ai/mcp-server-handlers": "0.
|
|
39
|
-
"@ggui-ai/negotiator": "0.
|
|
40
|
-
"@ggui-ai/preview-a2ui": "0.
|
|
41
|
-
"@ggui-ai/project-config": "0.
|
|
42
|
-
"@ggui-ai/protocol": "0.
|
|
43
|
-
"@ggui-ai/ui-
|
|
44
|
-
"@ggui-ai/ui-
|
|
35
|
+
"@ggui-ai/console": "0.4.0-rc.0",
|
|
36
|
+
"@ggui-ai/iframe-runtime": "0.4.0-rc.0",
|
|
37
|
+
"@ggui-ai/mcp-server-core": "0.4.0-rc.0",
|
|
38
|
+
"@ggui-ai/mcp-server-handlers": "0.4.0-rc.0",
|
|
39
|
+
"@ggui-ai/negotiator": "0.4.0-rc.0",
|
|
40
|
+
"@ggui-ai/preview-a2ui": "0.4.0-rc.0",
|
|
41
|
+
"@ggui-ai/project-config": "0.4.0-rc.0",
|
|
42
|
+
"@ggui-ai/protocol": "0.4.0-rc.0",
|
|
43
|
+
"@ggui-ai/ui-registry": "0.4.0-rc.0",
|
|
44
|
+
"@ggui-ai/ui-gen": "0.4.0-rc.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@types/express": "^
|
|
47
|
+
"@types/express": "^5.0.0",
|
|
48
48
|
"@types/node": "^22.0.0",
|
|
49
49
|
"@types/nodemailer": "^8.0.0",
|
|
50
50
|
"@types/ws": "^8.5.10",
|
|
51
51
|
"typescript": "^5.0.0",
|
|
52
|
-
"vitest": "^3.
|
|
52
|
+
"vitest": "^3.2.6",
|
|
53
|
+
"@ggui-ai/protocol-conformance": "0.4.0-rc.0"
|
|
53
54
|
},
|
|
54
55
|
"repository": {
|
|
55
56
|
"type": "git",
|
|
@@ -68,7 +69,7 @@
|
|
|
68
69
|
},
|
|
69
70
|
"author": "ggui contributors <hello@ggui.ai>",
|
|
70
71
|
"scripts": {
|
|
71
|
-
"build": "tsc -p tsconfig.build.json && node ../scripts/fix-esm-imports.mjs dist",
|
|
72
|
+
"build": "rm -rf dist && tsc -p tsconfig.build.json && node ../scripts/fix-esm-imports.mjs dist",
|
|
72
73
|
"dev": "tsc --watch",
|
|
73
74
|
"typecheck": "tsc --noEmit",
|
|
74
75
|
"test": "vitest run",
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MCP Apps inbound hosting — resource proxy + tools/call visibility gate.
|
|
3
|
-
*
|
|
4
|
-
* When the ggui server hosts a third-party MCP App iframe, the browser
|
|
5
|
-
* CANNOT resolve `ui://` URIs directly (browser URL scheme set is
|
|
6
|
-
* limited to http/https/etc). The server owns the only path to the
|
|
7
|
-
* resource bytes:
|
|
8
|
-
*
|
|
9
|
-
* browser iframe
|
|
10
|
-
* ↓ https://<ggui-server>/mcp-apps/resource?session=…&item=…
|
|
11
|
-
* ggui-server proxy route
|
|
12
|
-
* ↓ MCP resources/read (via @modelcontextprotocol/sdk/client)
|
|
13
|
-
* source MCP server
|
|
14
|
-
* ↓ ui:// resource HTML
|
|
15
|
-
* ggui-server returns the HTML bytes to the iframe.
|
|
16
|
-
*
|
|
17
|
-
* Similarly, iframe-originated `tools/call` flows:
|
|
18
|
-
*
|
|
19
|
-
* iframe ----postMessage---> ggui client (in parent)
|
|
20
|
-
* ggui client -----fetch----> ggui-server /mcp-apps/tools-call
|
|
21
|
-
* ggui-server enforces visibility, proxies via MCP client to source.
|
|
22
|
-
*
|
|
23
|
-
* Visibility enforcement lives at the proxy boundary (this file), NOT
|
|
24
|
-
* in the client. Source `tools/list` is fetched + cached per connector;
|
|
25
|
-
* `_meta.ui.visibility` gates which tools iframe-originated calls can
|
|
26
|
-
* invoke. Cross-connector calls are rejected — the iframe for connector
|
|
27
|
-
* A can NEVER call tools on connector B.
|
|
28
|
-
*/
|
|
29
|
-
import type { Express } from 'express';
|
|
30
|
-
import { type ConnectorRegistry, type RenderStore } from '@ggui-ai/mcp-server-core';
|
|
31
|
-
import type { Logger } from './logger.js';
|
|
32
|
-
/** Default mount path for the MCP Apps inbound routes. */
|
|
33
|
-
export declare const DEFAULT_MCP_APPS_INBOUND_PATH = "/mcp-apps";
|
|
34
|
-
export interface McpAppsInboundOptions {
|
|
35
|
-
readonly connectors: ConnectorRegistry;
|
|
36
|
-
readonly renderStore: RenderStore;
|
|
37
|
-
readonly logger: Logger;
|
|
38
|
-
/** Override for the mount path prefix. Defaults to `/mcp-apps`. */
|
|
39
|
-
readonly path?: string;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Shape of one entry in a cached source `tools/list`.
|
|
43
|
-
*
|
|
44
|
-
* Kept local — we only care about the fields that gate visibility,
|
|
45
|
-
* not the full MCP tool-definition shape.
|
|
46
|
-
*/
|
|
47
|
-
interface SourceToolMeta {
|
|
48
|
-
readonly name: string;
|
|
49
|
-
readonly visibility: ReadonlyArray<'model' | 'app'>;
|
|
50
|
-
}
|
|
51
|
-
export interface ToolsListCacheEntry {
|
|
52
|
-
readonly byName: ReadonlyMap<string, SourceToolMeta>;
|
|
53
|
-
readonly fetchedAt: number;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Tools-list cache keyed by connectorId. Short TTL — stale visibility
|
|
57
|
-
* decisions have small but real security impact, so cache invalidation
|
|
58
|
-
* is time-bounded (default 60s) with on-demand refresh.
|
|
59
|
-
*/
|
|
60
|
-
export declare class ToolsListCache {
|
|
61
|
-
private readonly ttlMs;
|
|
62
|
-
private readonly map;
|
|
63
|
-
constructor(ttlMs?: number);
|
|
64
|
-
get(connectorId: string): ToolsListCacheEntry | null;
|
|
65
|
-
set(connectorId: string, tools: Iterable<SourceToolMeta>): ToolsListCacheEntry;
|
|
66
|
-
invalidate(connectorId: string): void;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Register the MCP Apps inbound proxy routes on an Express app.
|
|
70
|
-
*
|
|
71
|
-
* GET /mcp-apps/resource?session=<id>&item=<id>
|
|
72
|
-
* Fetches the referenced McpAppsRender's `source.resourceUri`
|
|
73
|
-
* via resources/read on the source MCP server. Returns the HTML
|
|
74
|
-
* with the MIME declared by the source (typically
|
|
75
|
-
* `text/html;profile=mcp-app`) and spec-canonical CSP headers.
|
|
76
|
-
*
|
|
77
|
-
* POST /mcp-apps/tools-call
|
|
78
|
-
* Body: { session, item, tool, arguments? }.
|
|
79
|
-
* Resolves the stack item → connector → cached tools/list, gates
|
|
80
|
-
* on `_meta.ui.visibility` (must include 'app'), and proxies the
|
|
81
|
-
* call via MCP client. Cross-connector / unknown tool / model-
|
|
82
|
-
* only tool are all rejected.
|
|
83
|
-
*/
|
|
84
|
-
export declare function installMcpAppsInbound(app: Express, opts: McpAppsInboundOptions): ToolsListCache;
|
|
85
|
-
export {};
|
|
86
|
-
//# sourceMappingURL=mcp-apps-inbound.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-apps-inbound.d.ts","sourceRoot":"","sources":["../src/mcp-apps-inbound.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAqB,MAAM,SAAS,CAAC;AAG1D,OAAO,EACL,KAAK,iBAAiB,EAEtB,KAAK,WAAW,EACjB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,0DAA0D;AAC1D,eAAO,MAAM,6BAA6B,cAAc,CAAC;AAEzD,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,UAAU,EAAE,iBAAiB,CAAC;IACvC,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAClC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,mEAAmE;IACnE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;GAKG;AACH,UAAU,cAAc;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC,OAAO,GAAG,KAAK,CAAC,CAAC;CACrD;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACrD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED;;;;GAIG;AACH,qBAAa,cAAc;IAEb,OAAO,CAAC,QAAQ,CAAC,KAAK;IADlC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAA0C;gBACjC,KAAK,GAAE,MAAe;IAEnD,GAAG,CAAC,WAAW,EAAE,MAAM,GAAG,mBAAmB,GAAG,IAAI;IAUpD,GAAG,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,cAAc,CAAC,GAAG,mBAAmB;IAQ9E,UAAU,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;CAGtC;AA6DD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,OAAO,EACZ,IAAI,EAAE,qBAAqB,GAC1B,cAAc,CAsIhB"}
|