@ggui-ai/mcp-server 0.24.0 → 0.26.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 +2 -2
- package/dist/api-renders-routes.d.ts +46 -5
- package/dist/api-renders-routes.d.ts.map +1 -1
- package/dist/api-renders-routes.js +98 -39
- package/dist/api-renders-stream-route.d.ts +2 -1
- package/dist/api-renders-stream-route.d.ts.map +1 -1
- package/dist/api-renders-stream-route.js +14 -2
- package/dist/build-mcp.d.ts +16 -0
- package/dist/build-mcp.d.ts.map +1 -1
- package/dist/build-mcp.js +82 -12
- package/dist/console-auth.d.ts +10 -10
- package/dist/console-auth.d.ts.map +1 -1
- package/dist/control-service.d.ts.map +1 -1
- package/dist/control-service.js +0 -3
- package/dist/first-seen.d.ts +14 -0
- package/dist/first-seen.d.ts.map +1 -0
- package/dist/first-seen.js +19 -0
- package/dist/ggui-session-channel/action-ingress.d.ts.map +1 -1
- package/dist/ggui-session-channel/action-ingress.js +96 -8
- package/dist/ggui-session-channel/channel-subscriptions.d.ts +0 -1
- package/dist/ggui-session-channel/channel-subscriptions.d.ts.map +1 -1
- package/dist/ggui-session-channel/channel-subscriptions.js +4 -1
- package/dist/ggui-session-channel/internal-types.d.ts +20 -12
- package/dist/ggui-session-channel/internal-types.d.ts.map +1 -1
- package/dist/ggui-session-channel/outbound.d.ts.map +1 -1
- package/dist/ggui-session-channel/outbound.js +18 -6
- package/dist/ggui-session-channel/stream-epoch.d.ts +61 -0
- package/dist/ggui-session-channel/stream-epoch.d.ts.map +1 -0
- package/dist/ggui-session-channel/stream-epoch.js +47 -0
- package/dist/ggui-session-channel/subscribe.d.ts +40 -53
- package/dist/ggui-session-channel/subscribe.d.ts.map +1 -1
- package/dist/ggui-session-channel/subscribe.js +288 -124
- package/dist/ggui-session-channel/subscriber-lifecycle.d.ts.map +1 -1
- package/dist/ggui-session-channel/subscriber-lifecycle.js +17 -7
- package/dist/ggui-session-channel.d.ts +43 -7
- package/dist/ggui-session-channel.d.ts.map +1 -1
- package/dist/ggui-session-channel.js +7 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/instructions-presets.d.ts +22 -21
- package/dist/instructions-presets.d.ts.map +1 -1
- package/dist/instructions-presets.js +38 -38
- package/dist/llm-backed-negotiator.d.ts +4 -37
- package/dist/llm-backed-negotiator.d.ts.map +1 -1
- package/dist/llm-backed-negotiator.js +28 -210
- package/dist/mcp-apps-outbound.d.ts +40 -91
- package/dist/mcp-apps-outbound.d.ts.map +1 -1
- package/dist/mcp-apps-outbound.js +100 -15
- package/dist/mcp-endpoint-routes.d.ts +1 -0
- package/dist/mcp-endpoint-routes.d.ts.map +1 -1
- package/dist/mcp-endpoint-routes.js +38 -4
- package/dist/runtime-bundle-hash.d.ts +7 -0
- package/dist/runtime-bundle-hash.d.ts.map +1 -1
- package/dist/runtime-bundle-hash.js +8 -2
- package/dist/runtime-bundle-route.d.ts.map +1 -1
- package/dist/runtime-bundle-route.js +15 -0
- package/dist/server.d.ts +143 -85
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +224 -110
- package/dist/storage.d.ts +9 -1
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +4 -3
- package/dist/view-proof-gate.d.ts +96 -0
- package/dist/view-proof-gate.d.ts.map +1 -0
- package/dist/view-proof-gate.js +167 -0
- package/package.json +14 -15
- package/dist/render-read-gate.d.ts +0 -50
- package/dist/render-read-gate.d.ts.map +0 -1
- package/dist/render-read-gate.js +0 -36
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Subscribe / credential-path family for the live channel — upgrade-
|
|
3
3
|
* time identity resolution across the three auth planes (bearer via
|
|
4
4
|
* the AuthAdapter, ws-token bootstrap, console cookie) and the
|
|
5
|
-
* `subscribe` handler itself: version handshake, bootstrap verify
|
|
6
|
-
*
|
|
5
|
+
* `subscribe` handler itself: version handshake, bootstrap verify,
|
|
6
|
+
* identity-default appId resolution,
|
|
7
7
|
* dev-mode render provisioning, replay, registration, and the ack.
|
|
8
8
|
*/
|
|
9
9
|
import type { AuthAdapter, AuthResult, GguiSessionStore, GguiSessionStreamBuffer, StoredGguiSession, StreamFanout } from "@ggui-ai/mcp-server-core";
|
|
@@ -25,10 +25,11 @@ import type { SubscriberLifecycle } from "./subscriber-lifecycle.js";
|
|
|
25
25
|
* (invalid sig, expired, wrong kind, replayed, etc.).
|
|
26
26
|
* 2. The bound `sessionId` MUST match the one on the subscribe
|
|
27
27
|
* payload. Mismatches are rejected with a clean error.
|
|
28
|
-
* 3. On success, the
|
|
29
|
-
*
|
|
30
|
-
* `
|
|
31
|
-
*
|
|
28
|
+
* 3. On success, the subscribe binds to that identity. No reconnect
|
|
29
|
+
* credential is minted (ggui#1488): a reconnect presents a live
|
|
30
|
+
* `wsToken` again, renewed before it expires through
|
|
31
|
+
* `GET /api/sessions/:id/state`, or at any age through
|
|
32
|
+
* `ggui_runtime_refresh_ws_token`.
|
|
32
33
|
*
|
|
33
34
|
* Bootstrap auth is MUTUALLY EXCLUSIVE with the upstream `AuthAdapter`
|
|
34
35
|
* bearer path at subscribe time — when a bootstrap token is present,
|
|
@@ -44,8 +45,9 @@ import type { SubscriberLifecycle } from "./subscriber-lifecycle.js";
|
|
|
44
45
|
* G14 (2026-05-23): bootstrap envelopes are no longer single-use. A
|
|
45
46
|
* signature-valid + unexpired token authenticates EVERY subscribe
|
|
46
47
|
* within the TTL window; transient WS drops reconnect without a fresh
|
|
47
|
-
* handshake. Past expiry, the
|
|
48
|
-
*
|
|
48
|
+
* handshake. Past expiry, the view refreshes through
|
|
49
|
+
* `ggui_runtime_refresh_ws_token`, which re-mints only for a caller
|
|
50
|
+
* admitted to the session (ggui#1496 part B).
|
|
49
51
|
*/
|
|
50
52
|
export type GguiSessionChannelBootstrapVerifyResult = {
|
|
51
53
|
readonly ok: true;
|
|
@@ -55,53 +57,17 @@ export type GguiSessionChannelBootstrapVerifyResult = {
|
|
|
55
57
|
readonly ok: false;
|
|
56
58
|
readonly reason: "expired" | "invalid";
|
|
57
59
|
};
|
|
58
|
-
/**
|
|
59
|
-
* Result of {@link GguiSessionChannelBootstrap.refresh}.
|
|
60
|
-
*
|
|
61
|
-
* - `ok: true`: caller swaps the old envelope for `token` and resumes.
|
|
62
|
-
* - `ok: false`: caller MUST re-handshake (refresh window closed,
|
|
63
|
-
* tampered envelope, etc.).
|
|
64
|
-
*/
|
|
65
|
-
export type GguiSessionChannelBootstrapRefreshResult = {
|
|
66
|
-
readonly ok: true;
|
|
67
|
-
readonly token: string;
|
|
68
|
-
readonly expiresAt: string;
|
|
69
|
-
} | {
|
|
70
|
-
readonly ok: false;
|
|
71
|
-
readonly reason: "window_closed" | "invalid";
|
|
72
|
-
};
|
|
73
60
|
export interface GguiSessionChannelBootstrap {
|
|
74
61
|
/**
|
|
75
62
|
* Verify a `SubscribePayload.wsToken` token.
|
|
76
63
|
*
|
|
77
64
|
* Returns the bound identity on success, or a discriminated failure.
|
|
78
|
-
* The channel server maps `'expired'` to `BOOTSTRAP_EXPIRED`
|
|
79
|
-
*
|
|
80
|
-
* `BOOTSTRAP_INVALID` for tamper
|
|
81
|
-
*
|
|
65
|
+
* The channel server maps `'expired'` to `BOOTSTRAP_EXPIRED` (the view
|
|
66
|
+
* then refreshes through `ggui_runtime_refresh_ws_token`, an authorized
|
|
67
|
+
* re-mint), and `'invalid'` to `BOOTSTRAP_INVALID` for tamper, format or
|
|
68
|
+
* kind failures.
|
|
82
69
|
*/
|
|
83
70
|
verify(token: string): GguiSessionChannelBootstrapVerifyResult;
|
|
84
|
-
/**
|
|
85
|
-
* Mint a longer-lived reconnect credential to return in
|
|
86
|
-
* `AckPayload.sessionToken`. Called only after a successful
|
|
87
|
-
* `verify()` on a bootstrap subscribe.
|
|
88
|
-
*/
|
|
89
|
-
issueSessionToken(sessionId: string, appId: string): string;
|
|
90
|
-
/**
|
|
91
|
-
* Refresh a (possibly-expired-but-signature-valid) bootstrap envelope
|
|
92
|
-
* into a new envelope with a fresh TTL. Used by the
|
|
93
|
-
* `ggui_runtime_refresh_ws_token` MCP tool — iframes that see their
|
|
94
|
-
* bootstrap drift out of the TTL window swap in the refreshed
|
|
95
|
-
* envelope without going back through `ggui_render`.
|
|
96
|
-
*
|
|
97
|
-
* Stateless: verifies HMAC against the same secret used at mint,
|
|
98
|
-
* checks the refresh window against the ORIGINAL `iat`, and mints
|
|
99
|
-
* a fresh bootstrap envelope bound to the SAME `(sessionId, appId)`.
|
|
100
|
-
* Past the refresh window the result is `{ok:false, reason:
|
|
101
|
-
* 'window_closed'}`; tampered envelopes are `{ok:false, reason:
|
|
102
|
-
* 'invalid'}`.
|
|
103
|
-
*/
|
|
104
|
-
refresh(token: string): GguiSessionChannelBootstrapRefreshResult;
|
|
105
71
|
}
|
|
106
72
|
/**
|
|
107
73
|
* Cookie-based authentication for the live-channel upgrade. Used
|
|
@@ -140,6 +106,10 @@ export interface SubscribeDeps {
|
|
|
140
106
|
readonly cookieAuth?: GguiSessionChannelCookieAuth;
|
|
141
107
|
/** Identity → appId mapping — see `GguiSessionChannelOptions.appIdFromIdentity`. */
|
|
142
108
|
readonly appIdFromIdentity?: (result: AuthResult) => string;
|
|
109
|
+
/** Per-app authorization for a declared appId — see `GguiSessionChannelOptions.authorizeApp`. */
|
|
110
|
+
readonly authorizeApp?: (appId: string, identity: AuthResult) => Promise<void>;
|
|
111
|
+
/** Sources authorized on every subscribe — see `GguiSessionChannelOptions.perAppOnlySources`. */
|
|
112
|
+
readonly perAppOnlySources?: readonly AuthResult["source"][];
|
|
143
113
|
/** Version-handshake policy — see `GguiSessionChannelOptions.versionPolicy`. */
|
|
144
114
|
readonly versionPolicy?: "advisory" | "reject";
|
|
145
115
|
readonly sendError: Outbound["sendError"];
|
|
@@ -153,6 +123,12 @@ export interface SubscribeDeps {
|
|
|
153
123
|
* `/api/sessions/:sessionId/stream`) runs BEFORE this; the tail trusts
|
|
154
124
|
* `stored` + `identity` as already-authorized.
|
|
155
125
|
*/
|
|
126
|
+
/**
|
|
127
|
+
* A subscribe's credential when it is not the auth adapter's bearer
|
|
128
|
+
* (ggui#1488): a `wsToken`, or the console cookie. Logged as
|
|
129
|
+
* `render_channel_subscribed.source`.
|
|
130
|
+
*/
|
|
131
|
+
export type SubscribeCredential = "ws_token" | "console_cookie";
|
|
156
132
|
export type CompleteSubscribeArgs = {
|
|
157
133
|
/** Resolved render row the subscriber binds to. */
|
|
158
134
|
readonly stored: StoredGguiSession;
|
|
@@ -164,10 +140,17 @@ export type CompleteSubscribeArgs = {
|
|
|
164
140
|
readonly sinceSequence?: number;
|
|
165
141
|
/** Stream-buffer cursor — replays `data` frames per policy when set. */
|
|
166
142
|
readonly fromSeq?: number;
|
|
143
|
+
/** The epoch `fromSeq` was counted in (ggui#1531); read only beside it. */
|
|
144
|
+
readonly fromEpoch?: string;
|
|
167
145
|
/** Correlates the ack / error frames to a WS request. SSE has none. */
|
|
168
146
|
readonly requestId?: string;
|
|
169
|
-
/**
|
|
170
|
-
|
|
147
|
+
/**
|
|
148
|
+
* The credential the subscribe came on, when it is not the auth
|
|
149
|
+
* adapter's bearer: a `wsToken` (the bootstrap path, on the WebSocket or
|
|
150
|
+
* the SSE stream) or the console cookie. Both resolve to a synthetic
|
|
151
|
+
* identity whose own `source` would misreport them.
|
|
152
|
+
*/
|
|
153
|
+
readonly credential?: SubscribeCredential;
|
|
171
154
|
} & ({
|
|
172
155
|
readonly transport: "ws";
|
|
173
156
|
/** The socket — kept on the subscriber row for inbound dispatch. */
|
|
@@ -193,9 +176,13 @@ export interface SubscribeHandlers {
|
|
|
193
176
|
/**
|
|
194
177
|
* The transport-neutral subscribe tail, order preserved exactly:
|
|
195
178
|
* stream-cursor snapshot → stream-buffer replay read → StreamFanout
|
|
196
|
-
* iterator → register (pump starts
|
|
197
|
-
*
|
|
198
|
-
*
|
|
179
|
+
* iterator → register (pump starts; every write to the subscriber's
|
|
180
|
+
* sink is held until the replay below is written, ggui#1525) → the
|
|
181
|
+
* first GguiSessionEvent-ledger page read, when `sinceSequence` is set
|
|
182
|
+
* (before the ack, so a failed read sends none, ggui#1528) → ack →
|
|
183
|
+
* ledger replay (`render_event` frames, `resumeId` = ledger seq; later
|
|
184
|
+
* pages read as they go) → stream-replay `data` frames → release of the
|
|
185
|
+
* held frames. WS `handleSubscribe` calls this after
|
|
199
186
|
* its auth/provision head; SSE attaches call it via
|
|
200
187
|
* `GguiSessionChannelServer.attachExternalSubscriber`.
|
|
201
188
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscribe.d.ts","sourceRoot":"","sources":["../../src/ggui-session-channel/subscribe.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,gBAAgB,EAChB,uBAAuB,EACvB,iBAAiB,EACjB,YAAY,
|
|
1
|
+
{"version":3,"file":"subscribe.d.ts","sourceRoot":"","sources":["../../src/ggui-session-channel/subscribe.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,gBAAgB,EAChB,uBAAuB,EACvB,iBAAiB,EACjB,YAAY,EAEb,MAAM,0BAA0B,CAAC;AAGlC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AAC9E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAMpC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,EAGV,cAAc,EAEf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAgB,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAErE;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH;;;;;;;;;;;G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