@ggui-ai/mcp-server 0.2.0-alpha.3 → 0.3.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.
Files changed (152) hide show
  1. package/dist/admin-blueprints-transport.d.ts.map +1 -1
  2. package/dist/admin-blueprints-transport.js +2 -1
  3. package/dist/admin-oauth-providers-transport.d.ts.map +1 -1
  4. package/dist/admin-oauth-providers-transport.js +7 -5
  5. package/dist/api-renders-routes.d.ts +85 -0
  6. package/dist/api-renders-routes.d.ts.map +1 -0
  7. package/dist/api-renders-routes.js +372 -0
  8. package/dist/build-mcp.d.ts +1 -1
  9. package/dist/build-mcp.d.ts.map +1 -1
  10. package/dist/build-mcp.js +39 -5
  11. package/dist/code-routes.d.ts +47 -0
  12. package/dist/code-routes.d.ts.map +1 -0
  13. package/dist/code-routes.js +81 -0
  14. package/dist/code-store-fs.js +2 -2
  15. package/dist/console-auth.d.ts +10 -10
  16. package/dist/console-auth.d.ts.map +1 -1
  17. package/dist/console-auth.js +5 -5
  18. package/dist/console-blueprint-routes.d.ts +71 -0
  19. package/dist/console-blueprint-routes.d.ts.map +1 -0
  20. package/dist/console-blueprint-routes.js +348 -0
  21. package/dist/console-chat-routes.d.ts +80 -0
  22. package/dist/console-chat-routes.d.ts.map +1 -0
  23. package/dist/console-chat-routes.js +182 -0
  24. package/dist/console-config-routes.d.ts +37 -0
  25. package/dist/console-config-routes.d.ts.map +1 -0
  26. package/dist/console-config-routes.js +91 -0
  27. package/dist/console-headers.d.ts +1 -1
  28. package/dist/console-info-routes.d.ts +84 -0
  29. package/dist/console-info-routes.d.ts.map +1 -0
  30. package/dist/console-info-routes.js +135 -0
  31. package/dist/console-keys-routes.d.ts +50 -0
  32. package/dist/console-keys-routes.d.ts.map +1 -0
  33. package/dist/console-keys-routes.js +222 -0
  34. package/dist/console-llm-keys-routes.d.ts +47 -0
  35. package/dist/console-llm-keys-routes.d.ts.map +1 -0
  36. package/dist/console-llm-keys-routes.js +443 -0
  37. package/dist/console-mcp-tools-routes.d.ts +41 -0
  38. package/dist/console-mcp-tools-routes.d.ts.map +1 -0
  39. package/dist/console-mcp-tools-routes.js +60 -0
  40. package/dist/console-registry-routes.d.ts +66 -0
  41. package/dist/console-registry-routes.d.ts.map +1 -0
  42. package/dist/console-registry-routes.js +276 -0
  43. package/dist/console-session-routes.d.ts +89 -0
  44. package/dist/console-session-routes.d.ts.map +1 -0
  45. package/dist/console-session-routes.js +385 -0
  46. package/dist/console-sessions-routes.d.ts +52 -0
  47. package/dist/console-sessions-routes.d.ts.map +1 -0
  48. package/dist/console-sessions-routes.js +106 -0
  49. package/dist/console-static-routes.d.ts +54 -0
  50. package/dist/console-static-routes.d.ts.map +1 -0
  51. package/dist/console-static-routes.js +190 -0
  52. package/dist/console-theme-routes.d.ts +3 -3
  53. package/dist/console-theme-routes.js +1 -1
  54. package/dist/console-timeline.d.ts +5 -5
  55. package/dist/console-timeline.d.ts.map +1 -1
  56. package/dist/console-timeline.js +27 -26
  57. package/dist/console-welcome.js +2 -2
  58. package/dist/email-login.d.ts.map +1 -1
  59. package/dist/email-login.js +2 -3
  60. package/dist/ggui-session-channel/action-ingress.d.ts +54 -0
  61. package/dist/ggui-session-channel/action-ingress.d.ts.map +1 -0
  62. package/dist/ggui-session-channel/action-ingress.js +228 -0
  63. package/dist/ggui-session-channel/channel-subscriptions.d.ts +97 -0
  64. package/dist/ggui-session-channel/channel-subscriptions.d.ts.map +1 -0
  65. package/dist/ggui-session-channel/channel-subscriptions.js +224 -0
  66. package/dist/ggui-session-channel/internal-types.d.ts +102 -0
  67. package/dist/ggui-session-channel/internal-types.d.ts.map +1 -0
  68. package/dist/ggui-session-channel/internal-types.js +6 -0
  69. package/dist/ggui-session-channel/outbound.d.ts +81 -0
  70. package/dist/ggui-session-channel/outbound.d.ts.map +1 -0
  71. package/dist/ggui-session-channel/outbound.js +174 -0
  72. package/dist/ggui-session-channel/socket-router.d.ts +38 -0
  73. package/dist/ggui-session-channel/socket-router.d.ts.map +1 -0
  74. package/dist/ggui-session-channel/socket-router.js +213 -0
  75. package/dist/ggui-session-channel/subscribe.d.ts +165 -0
  76. package/dist/ggui-session-channel/subscribe.d.ts.map +1 -0
  77. package/dist/ggui-session-channel/subscribe.js +370 -0
  78. package/dist/ggui-session-channel/subscriber-lifecycle.d.ts +40 -0
  79. package/dist/ggui-session-channel/subscriber-lifecycle.d.ts.map +1 -0
  80. package/dist/ggui-session-channel/subscriber-lifecycle.js +123 -0
  81. package/dist/ggui-session-channel.d.ts +425 -0
  82. package/dist/ggui-session-channel.d.ts.map +1 -0
  83. package/dist/ggui-session-channel.js +262 -0
  84. package/dist/health-routes.d.ts +76 -0
  85. package/dist/health-routes.d.ts.map +1 -0
  86. package/dist/health-routes.js +145 -0
  87. package/dist/index.d.ts +10 -11
  88. package/dist/index.d.ts.map +1 -1
  89. package/dist/index.js +8 -9
  90. package/dist/instructions-presets.d.ts +3 -3
  91. package/dist/instructions-presets.js +25 -25
  92. package/dist/llm-backed-negotiator.d.ts +68 -67
  93. package/dist/llm-backed-negotiator.d.ts.map +1 -1
  94. package/dist/llm-backed-negotiator.js +82 -248
  95. package/dist/mcp-apps-outbound.d.ts +47 -48
  96. package/dist/mcp-apps-outbound.d.ts.map +1 -1
  97. package/dist/mcp-apps-outbound.js +204 -183
  98. package/dist/mcp-endpoint-routes.d.ts +88 -0
  99. package/dist/mcp-endpoint-routes.d.ts.map +1 -0
  100. package/dist/mcp-endpoint-routes.js +359 -0
  101. package/dist/mcp-mounts.d.ts +2 -76
  102. package/dist/mcp-mounts.d.ts.map +1 -1
  103. package/dist/mcp-mounts.js +0 -76
  104. package/dist/oauth-as-routes.d.ts +60 -0
  105. package/dist/oauth-as-routes.d.ts.map +1 -0
  106. package/dist/oauth-as-routes.js +82 -0
  107. package/dist/oauth-clients-routes.d.ts +39 -0
  108. package/dist/oauth-clients-routes.d.ts.map +1 -0
  109. package/dist/oauth-clients-routes.js +87 -0
  110. package/dist/oauth-login-types.d.ts +1 -20
  111. package/dist/oauth-login-types.d.ts.map +1 -1
  112. package/dist/oauth-login-types.js +30 -7
  113. package/dist/oauth-login.d.ts.map +1 -1
  114. package/dist/oauth-login.js +3 -2
  115. package/dist/oauth-providers-store.d.ts.map +1 -1
  116. package/dist/oauth-providers-store.js +5 -5
  117. package/dist/oauth.d.ts +9 -8
  118. package/dist/oauth.d.ts.map +1 -1
  119. package/dist/oauth.js +41 -19
  120. package/dist/pairing-transport.d.ts.map +1 -1
  121. package/dist/pairing-transport.js +2 -1
  122. package/dist/request-context.d.ts +2 -2
  123. package/dist/request-context.js +2 -2
  124. package/dist/reserved-validators.d.ts.map +1 -1
  125. package/dist/reserved-validators.js +9 -1
  126. package/dist/route-param.d.ts +9 -0
  127. package/dist/route-param.d.ts.map +1 -0
  128. package/dist/route-param.js +10 -0
  129. package/dist/runtime-bundle-route.d.ts +43 -0
  130. package/dist/runtime-bundle-route.d.ts.map +1 -0
  131. package/dist/runtime-bundle-route.js +80 -0
  132. package/dist/schema-compat.d.ts +64 -62
  133. package/dist/schema-compat.d.ts.map +1 -1
  134. package/dist/schema-compat.js +23 -51
  135. package/dist/server.d.ts +179 -193
  136. package/dist/server.d.ts.map +1 -1
  137. package/dist/server.js +644 -3759
  138. package/dist/storage.d.ts +5 -5
  139. package/dist/storage.d.ts.map +1 -1
  140. package/dist/storage.js +5 -5
  141. package/dist/thread-transport.d.ts.map +1 -1
  142. package/dist/thread-transport.js +4 -3
  143. package/dist/user-session-auth.d.ts +7 -21
  144. package/dist/user-session-auth.d.ts.map +1 -1
  145. package/dist/user-session-auth.js +7 -28
  146. package/package.json +16 -15
  147. package/dist/mcp-apps-inbound.d.ts +0 -86
  148. package/dist/mcp-apps-inbound.d.ts.map +0 -1
  149. package/dist/mcp-apps-inbound.js +0 -283
  150. package/dist/render-channel.d.ts +0 -694
  151. package/dist/render-channel.d.ts.map +0 -1
  152. package/dist/render-channel.js +0 -1775
@@ -0,0 +1,276 @@
1
+ /**
2
+ * Console blueprint-catalog read/maintenance routes.
3
+ *
4
+ * GET /ggui/console/registry — declared-blueprint +
5
+ * primitive catalog (boot-time content).
6
+ * GET /ggui/console/blueprints/cached — intent-keyed
7
+ * generation-cache listing (legacy surface).
8
+ * DELETE /ggui/console/blueprints/cached/:id — invalidate one entry.
9
+ * POST /ggui/console/blueprints/cached/clear — bulk-clear the scope.
10
+ * GET /ggui/console/blueprints/registry — contract-keyed runtime
11
+ * registry the matcher actually consults (per-row tier
12
+ * diagnostics: kind, contractKey, hitCount, lastHitAt,
13
+ * provenance).
14
+ *
15
+ * `/registry` sources:
16
+ * - `blueprints[]` ← `uiRegistry?.list()` (full manifest entries;
17
+ * surfaces `name` + `description?` + `category?`). Same registry
18
+ * the `/ggui/console/blueprint/:id` endpoint resolves against, so
19
+ * the /registry click-through to /preview/<id> is guaranteed to
20
+ * hit the same dataset.
21
+ * - `primitives[]` ← `primitiveCatalogs` (`DiscoveredPrimitiveCatalog`
22
+ * shape from `@ggui-ai/project-config`). Each entry flattens
23
+ * one primitive per row, tagging it with its catalog's
24
+ * `source` ('package' | 'local') + `import` specifier.
25
+ *
26
+ * Scope: read-only on `/registry` (authoring happens on disk and the
27
+ * server re-reads on boot; zero-config is an honest empty shape).
28
+ * The cache/registry surfaces are scoped to `DEFAULT_BUILDER_APP_ID`
29
+ * because the OSS server is single-tenant by construction — same
30
+ * scope the render handler writes to, so list/invalidate/clear see
31
+ * what the real cache writes.
32
+ *
33
+ * Enumeration gate: `listGenerationCache` + `clearGenerationCache` +
34
+ * `listBlueprints` require an EnumerableVectorStore. Every OSS
35
+ * default satisfies it (`InMemoryVectorStore`, `SqliteVectorStore`);
36
+ * deployments that wire a non-enumerable backend get an honest `501`
37
+ * with a reason code rather than a silent empty list or a runtime
38
+ * throw.
39
+ *
40
+ * No bearer auth (same rule as the other console endpoints —
41
+ * same-origin operator-facing).
42
+ */
43
+ import { isEnumerableVectorStore } from "@ggui-ai/mcp-server-core";
44
+ import { clearGenerationCache, invalidateGenerationCache, listBlueprints, listGenerationCache, } from "@ggui-ai/mcp-server-handlers/renders";
45
+ import { DEFAULT_BUILDER_APP_ID } from "./auth.js";
46
+ import { applyDevtoolSecurityHeaders } from "./console-headers.js";
47
+ /**
48
+ * Mount the console catalog routes onto the express app. Returns
49
+ * nothing — the routes self-register.
50
+ */
51
+ export function mountConsoleRegistryRoutes(opts) {
52
+ const { app, uiRegistry, primitiveCatalogs, vectors, logger } = opts;
53
+ // GET /ggui/console/registry — declared catalog. Output is
54
+ // stable-sorted by id / name so the SPA's filter-as-you-type UI
55
+ // doesn't need a second sort pass.
56
+ app.get("/ggui/console/registry", async (_req, res) => {
57
+ applyDevtoolSecurityHeaders(res);
58
+ const blueprints = [];
59
+ if (uiRegistry) {
60
+ try {
61
+ const entries = await uiRegistry.list();
62
+ for (const entry of entries) {
63
+ const summary = {
64
+ id: entry.id,
65
+ name: entry.manifest.name,
66
+ ...(entry.manifest.description !== undefined
67
+ ? { description: entry.manifest.description }
68
+ : {}),
69
+ ...(entry.manifest.category !== undefined ? { category: entry.manifest.category } : {}),
70
+ };
71
+ blueprints.push(summary);
72
+ }
73
+ blueprints.sort((a, b) => a.id.localeCompare(b.id));
74
+ }
75
+ catch (err) {
76
+ logger.warn("console_registry_blueprint_list_failed", {
77
+ error: String(err),
78
+ });
79
+ res.status(500).json({
80
+ error: "registry_unavailable",
81
+ message: err instanceof Error
82
+ ? `Blueprint registry failed to list — ${err.message}`
83
+ : `Blueprint registry failed to list — ${String(err)}`,
84
+ });
85
+ return;
86
+ }
87
+ }
88
+ const primitives = [];
89
+ for (const catalog of primitiveCatalogs ?? []) {
90
+ for (const primitive of catalog.manifest.primitives) {
91
+ primitives.push({
92
+ name: primitive.name,
93
+ source: catalog.source,
94
+ catalog: catalog.import,
95
+ });
96
+ }
97
+ }
98
+ // Stable sort: primary by catalog import (packages first, then
99
+ // locals under their own groups), secondary by primitive name.
100
+ // Operator reads "everything from @ggui-ai/design" as one block
101
+ // rather than having @ggui-ai/design's Button interleaved with
102
+ // a local-catalog Button at the letter-b slot.
103
+ primitives.sort((a, b) => {
104
+ const byCatalog = a.catalog.localeCompare(b.catalog);
105
+ if (byCatalog !== 0)
106
+ return byCatalog;
107
+ return a.name.localeCompare(b.name);
108
+ });
109
+ res.json({ blueprints, primitives });
110
+ });
111
+ // GET /ggui/console/blueprints/cached — list cached generation
112
+ // entries. Rejects with 501 when the vector store doesn't
113
+ // support enumeration. Empty scope returns
114
+ // `{entries: [], total: 0}` — not an error.
115
+ app.get("/ggui/console/blueprints/cached", async (_req, res) => {
116
+ applyDevtoolSecurityHeaders(res);
117
+ if (!isEnumerableVectorStore(vectors)) {
118
+ res.status(501).json({
119
+ error: "enumeration_unsupported",
120
+ message: "The configured vector store does not support enumeration. " +
121
+ "Wire an EnumerableVectorStore (default InMemoryVectorStore " +
122
+ "or SqliteVectorStore) to surface the cache in the console.",
123
+ });
124
+ return;
125
+ }
126
+ try {
127
+ const entries = await listGenerationCache({ vectorStore: vectors }, DEFAULT_BUILDER_APP_ID);
128
+ const payload = entries;
129
+ res.json({ entries: payload, total: payload.length });
130
+ }
131
+ catch (err) {
132
+ logger.warn("console_blueprints_cached_list_failed", {
133
+ error: String(err),
134
+ });
135
+ res.status(500).json({
136
+ error: "cache_unavailable",
137
+ message: err instanceof Error
138
+ ? `Generation cache failed to list — ${err.message}`
139
+ : `Generation cache failed to list — ${String(err)}`,
140
+ });
141
+ }
142
+ });
143
+ // DELETE /ggui/console/blueprints/cached/:id — invalidate one
144
+ // cached entry. Idempotent — 204 whether the id was present or
145
+ // not (same contract as VectorStore.deleteVector). No enumerable
146
+ // gate — delete works on every vector-store implementation.
147
+ app.delete("/ggui/console/blueprints/cached/:id", async (req, res) => {
148
+ applyDevtoolSecurityHeaders(res);
149
+ const id = req.params.id;
150
+ if (!id || id.length === 0) {
151
+ res.status(400).json({
152
+ error: "missing_id",
153
+ message: "Cache entry id required in path segment.",
154
+ });
155
+ return;
156
+ }
157
+ try {
158
+ await invalidateGenerationCache({ vectorStore: vectors }, DEFAULT_BUILDER_APP_ID, id);
159
+ res.status(204).end();
160
+ }
161
+ catch (err) {
162
+ logger.warn("console_blueprints_cached_invalidate_failed", {
163
+ error: String(err),
164
+ id,
165
+ });
166
+ res.status(500).json({
167
+ error: "cache_invalidate_failed",
168
+ message: err instanceof Error
169
+ ? `Invalidate failed — ${err.message}`
170
+ : `Invalidate failed — ${String(err)}`,
171
+ });
172
+ }
173
+ });
174
+ // POST /ggui/console/blueprints/cached/clear — bulk-delete every
175
+ // cached entry in the scope. Returns the count. Requires
176
+ // EnumerableVectorStore (we enumerate to find keys to delete).
177
+ app.post("/ggui/console/blueprints/cached/clear", async (_req, res) => {
178
+ applyDevtoolSecurityHeaders(res);
179
+ if (!isEnumerableVectorStore(vectors)) {
180
+ res.status(501).json({
181
+ error: "enumeration_unsupported",
182
+ message: "Bulk-clear requires a vector store that supports " +
183
+ "enumeration. Invalidate entries individually via " +
184
+ "DELETE /ggui/console/blueprints/cached/:id, or wire an " +
185
+ "EnumerableVectorStore to unlock bulk-clear.",
186
+ });
187
+ return;
188
+ }
189
+ try {
190
+ const result = await clearGenerationCache({ vectorStore: vectors }, DEFAULT_BUILDER_APP_ID);
191
+ res.json(result);
192
+ }
193
+ catch (err) {
194
+ logger.warn("console_blueprints_cached_clear_failed", {
195
+ error: String(err),
196
+ });
197
+ res.status(500).json({
198
+ error: "cache_clear_failed",
199
+ message: err instanceof Error ? `Clear failed — ${err.message}` : `Clear failed — ${String(err)}`,
200
+ });
201
+ }
202
+ });
203
+ // GET /ggui/console/blueprints/registry — list every blueprint
204
+ // registered in the three-tier matcher's storage.
205
+ // Sibling of `/blueprints/cached` and intentionally distinct from
206
+ // the declared-blueprint catalog at `/ggui/console/registry`:
207
+ // - `/registry` (above) — operator-declared static catalog
208
+ // (uiRegistry sources + primitiveCatalogs). Boot-time content.
209
+ // - `/blueprints/cached` (legacy) — intent-keyed generation
210
+ // cache. Retired.
211
+ // - `/blueprints/registry` (this) — contract-keyed runtime
212
+ // registry the matcher actually consults. Per-row tier
213
+ // diagnostics: kind, contractKey, hitCount, lastHitAt.
214
+ //
215
+ // Optional `?kind=template|organism|molecule|atom` filter narrows
216
+ // by atomic-design level — kindless query returns everything.
217
+ app.get("/ggui/console/blueprints/registry", async (req, res) => {
218
+ applyDevtoolSecurityHeaders(res);
219
+ if (!isEnumerableVectorStore(vectors)) {
220
+ res.status(501).json({
221
+ error: "enumeration_unsupported",
222
+ message: "The configured vector store does not support enumeration. " +
223
+ "Wire an EnumerableVectorStore (default InMemoryVectorStore " +
224
+ "or SqliteVectorStore) to surface the registry in the console.",
225
+ });
226
+ return;
227
+ }
228
+ const rawKind = typeof req.query.kind === "string" ? req.query.kind : undefined;
229
+ const allowedKinds = ["template", "organism", "molecule", "atom"];
230
+ const kind = rawKind !== undefined
231
+ ? allowedKinds.find((k) => k === rawKind)
232
+ : undefined;
233
+ if (rawKind !== undefined && kind === undefined) {
234
+ res.status(400).json({
235
+ error: "invalid_kind",
236
+ message: `kind must be one of ${allowedKinds.join(", ")}; got '${rawKind}'.`,
237
+ });
238
+ return;
239
+ }
240
+ try {
241
+ const blueprints = await listBlueprints({ vectorStore: vectors }, DEFAULT_BUILDER_APP_ID, kind);
242
+ // Project to a wire-friendly view — `componentCode` is large
243
+ // and not load-bearing for the operator listing; surface a
244
+ // length signal instead so the UI can show "12 KB" without
245
+ // parsing 12 KB.
246
+ const entries = blueprints.map((bp) => ({
247
+ id: bp.id,
248
+ kind: bp.kind,
249
+ contractKey: bp.contractKey,
250
+ intent: bp.intent,
251
+ createdAt: bp.createdAt,
252
+ hitCount: bp.hitCount,
253
+ ...(bp.lastHitAt !== undefined ? { lastHitAt: bp.lastHitAt } : {}),
254
+ // Surface provenance (the BlueprintSource union — llm rows
255
+ // carry engine slug + model) plus the install-bridge
256
+ // lifecycle marker so operators can distinguish cold-gen vs.
257
+ // operator-registered vs. marketplace-installed rows on
258
+ // `/ggui/console/blueprints/registry`. Matcher behaviour is
259
+ // unchanged — provenance is purely informational.
260
+ source: bp.source,
261
+ ...(bp.installed === true ? { installed: true } : {}),
262
+ componentCodeBytes: bp.componentCode.length,
263
+ }));
264
+ res.json({ entries, total: entries.length });
265
+ }
266
+ catch (err) {
267
+ logger.warn("console_registry_list_failed", { error: String(err) });
268
+ res.status(500).json({
269
+ error: "registry_unavailable",
270
+ message: err instanceof Error
271
+ ? `Registry list failed — ${err.message}`
272
+ : `Registry list failed — ${String(err)}`,
273
+ });
274
+ }
275
+ });
276
+ }
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Console render-viewer session routes (cookie mint + resource +
3
+ * meta + observation).
4
+ *
5
+ * POST /ggui/console/session-cookie
6
+ * — resolve shortCode → render and mint the same-origin HTTP-only
7
+ * cookie the viewer authenticates to the live channel with.
8
+ *
9
+ * GET /ggui/console/session-resource?session=<sessionId>
10
+ * — production thin-shell HTML, wrapped as a ResourceContents
11
+ * blob (`text` IS `GGUI_RENDER_SHELL_HTML`, byte-identical to
12
+ * what Claude Desktop fetches via MCP `resources/read
13
+ * ui://ggui/render`). NO inlined bootstrap — console fetches
14
+ * the bootstrap separately (meta route below) and replies to
15
+ * the iframe's `ui/initialize` postMessage with it.
16
+ *
17
+ * GET /ggui/console/sessions/:sessionId/meta
18
+ * — slice-envelope JSON (`{ "ai.ggui/render": {...} }`, the same
19
+ * shape as the wire `_meta`). The console forwards this to the
20
+ * iframe as the `_meta` slice of a spec-canonical
21
+ * `ui/notifications/tool-result` notification (per
22
+ * `docs/protocol/extensions/ai.ggui-meta.md`). Requires
23
+ * `mcpApps: true` (mintBootstrap presence) — 503 otherwise.
24
+ *
25
+ * GET /ggui/console/session?session=<sessionId>
26
+ * — `{render, eventSequence}` JSON. Console-only observation
27
+ * surface for `<GguiSessionViewer>` to mount `<RenderInspector>`.
28
+ *
29
+ * Named parties (all routes):
30
+ * - console (SPA caller) — holds the same-origin cookie.
31
+ * - mcp-server (these handlers) — gates auth + scope; mints the
32
+ * bootstrap on the meta route.
33
+ * - host wrapper (bootstrap forwarder; `<AppRenderer>` on web,
34
+ * `<McpAppIframe>` on RN) — receives the bootstrap JSON and
35
+ * forwards it as a `ui/notifications/tool-result` `_meta` slice.
36
+ * - renderer bundle (inside the iframe) — runs the same boot
37
+ * code path as production; reads the single `ai.ggui/render`
38
+ * slice meta.
39
+ *
40
+ * Auth + scope obligations (uniform):
41
+ * - Cookie-auth via `readDevtoolCookieFromHeaders` +
42
+ * `verifyDevtoolCookie`. Invalid / missing → 401.
43
+ * - Scope: `cookie.sessionId` MUST equal the requested session.
44
+ * Cross-render access with a valid cookie → 403.
45
+ * - GguiSession existence + appId match: 404 / 403 respectively.
46
+ *
47
+ * The mount RETURNS the `GguiSessionChannelCookieAuth` binding the
48
+ * composer threads into `createGguiSessionChannelServer`, so the
49
+ * cookie minted here authenticates the live-channel WS upgrade.
50
+ */
51
+ import type { CodeStore, GguiSessionStore, ShortCodeIndex } from "@ggui-ai/mcp-server-core";
52
+ import type { Express } from "express";
53
+ import type { GguiSessionChannelCookieAuth } from "./ggui-session-channel.js";
54
+ import type { Logger } from "./logger.js";
55
+ interface MountOptions {
56
+ /** Express app to mount onto. */
57
+ readonly app: Express;
58
+ /** Shared HMAC secret backing the console cookie mint/verify pair. */
59
+ readonly secret: string;
60
+ /** shortCode → render binding the cookie-mint route resolves through. */
61
+ readonly shortCodeIndex: ShortCodeIndex;
62
+ /** Cookie TTL override (undefined → helper default, 8h). */
63
+ readonly cookieTtlSec?: number;
64
+ /** Mark the cookie Secure (TLS-terminating deployments). */
65
+ readonly cookieSecure: boolean;
66
+ /** GguiSession store the gate + observation routes read. */
67
+ readonly renderStore?: GguiSessionStore;
68
+ /** Live-mode credential minter (`mcpApps: true` at construction). */
69
+ readonly mintBootstrap?: (sessionId: string, appId: string) => {
70
+ wsUrl: string;
71
+ token: string;
72
+ expiresAt: string;
73
+ };
74
+ /** Runtime-bundle bootstrap URL (rewritten absolute on meta reads). */
75
+ readonly runtimeBootstrapUrl: string;
76
+ /** Content-addressable store for the validator-bundle emission. */
77
+ readonly codeStore?: CodeStore;
78
+ /** Operator-configured public origin for absolute URL composition. */
79
+ readonly publicBaseUrl?: string;
80
+ /** Parent logger; the mount derives its `console-cookie` child. */
81
+ readonly logger: Logger;
82
+ }
83
+ /**
84
+ * Mount the console session routes onto the express app and return
85
+ * the cookie-auth binding for the live channel.
86
+ */
87
+ export declare function mountConsoleSessionRoutes(opts: MountOptions): GguiSessionChannelCookieAuth;
88
+ export {};
89
+ //# sourceMappingURL=console-session-routes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"console-session-routes.d.ts","sourceRoot":"","sources":["../src/console-session-routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAQ5F,OAAO,KAAK,EAAE,OAAO,EAAqB,MAAM,SAAS,CAAC;AAQ1D,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,2BAA2B,CAAC;AAC9E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAI1C,UAAU,YAAY;IACpB,iCAAiC;IACjC,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC;IACtB,sEAAsE;IACtE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,yEAAyE;IACzE,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAC;IACxC,4DAA4D;IAC5D,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,4DAA4D;IAC5D,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAC/B,4DAA4D;IAC5D,QAAQ,CAAC,WAAW,CAAC,EAAE,gBAAgB,CAAC;IACxC,qEAAqE;IACrE,QAAQ,CAAC,aAAa,CAAC,EAAE,CACvB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,KACV;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IACzD,uEAAuE;IACvE,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;IACrC,mEAAmE;IACnE,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC;IAC/B,sEAAsE;IACtE,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,mEAAmE;IACnE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,YAAY,GAAG,4BAA4B,CA0V1F"}