@ggui-ai/mcp-server 0.2.0-alpha.4 → 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 +24 -24
  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 -221
  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 +154 -177
  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,47 @@
1
+ /**
2
+ * Content-addressable code delivery routes.
3
+ *
4
+ * GET /code/:hash.js — content-addressable componentCode delivery.
5
+ * GET /contract/:hash.js — content-addressable contract-validator-bundle
6
+ * delivery (#109).
7
+ *
8
+ * Both routes serve from the same {@link CodeStore} keyed by
9
+ * `sha256(bytes)`. The same store is safe to share — content-addressable
10
+ * hashes can't collide across kinds unless the bytes are identical
11
+ * (in which case the cached value is equally valid for either path).
12
+ * Two separate URLs exist for debuggability + protocol clarity: a
13
+ * request to `/code/<hash>.js` is unambiguously a component fetch;
14
+ * `/contract/<hash>.js` is unambiguously a validator-bundle fetch.
15
+ *
16
+ * Cache posture: `Cache-Control: public, max-age=31536000, immutable` —
17
+ * hash is content-derived, the bytes can NEVER change for a given URL,
18
+ * so browsers + CDNs cache forever (immutable means "don't even
19
+ * revalidate"). A second render with the same componentCode / contract
20
+ * hits browser cache for free.
21
+ *
22
+ * CORS: same `*` posture as `/r/:shortCode` (JSON branch) — bytes are
23
+ * public-by-shortCode anyway (the agent already shared the URL with
24
+ * the host), and the bytes carry no credentials.
25
+ *
26
+ * Validation: hash MUST match `[a-f0-9]{64}` — strict charset gate
27
+ * closes path-traversal (`..`, `/`) and other shenanigans before the
28
+ * store sees the parameter.
29
+ */
30
+ import type { CodeStore } from "@ggui-ai/mcp-server-core";
31
+ import type { Express } from "express";
32
+ import type { Logger } from "./logger.js";
33
+ interface MountOptions {
34
+ /** Express app to mount onto. */
35
+ readonly app: Express;
36
+ /** Content-addressable store both routes serve from. */
37
+ readonly codeStore: CodeStore;
38
+ /** Structured logger for fetch-failure warnings. */
39
+ readonly logger: Logger;
40
+ }
41
+ /**
42
+ * Mount `GET /code/:hash.js` + `GET /contract/:hash.js` onto the
43
+ * express app. Returns nothing — the routes self-register.
44
+ */
45
+ export declare function mountCodeRoutes(opts: MountOptions): void;
46
+ export {};
47
+ //# sourceMappingURL=code-routes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-routes.d.ts","sourceRoot":"","sources":["../src/code-routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAE1D,OAAO,KAAK,EAAE,OAAO,EAAqB,MAAM,SAAS,CAAC;AAC1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C,UAAU,YAAY;IACpB,iCAAiC;IACjC,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC;IACtB,wDAAwD;IACxD,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,oDAAoD;IACpD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,CA6CxD"}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Content-addressable code delivery routes.
3
+ *
4
+ * GET /code/:hash.js — content-addressable componentCode delivery.
5
+ * GET /contract/:hash.js — content-addressable contract-validator-bundle
6
+ * delivery (#109).
7
+ *
8
+ * Both routes serve from the same {@link CodeStore} keyed by
9
+ * `sha256(bytes)`. The same store is safe to share — content-addressable
10
+ * hashes can't collide across kinds unless the bytes are identical
11
+ * (in which case the cached value is equally valid for either path).
12
+ * Two separate URLs exist for debuggability + protocol clarity: a
13
+ * request to `/code/<hash>.js` is unambiguously a component fetch;
14
+ * `/contract/<hash>.js` is unambiguously a validator-bundle fetch.
15
+ *
16
+ * Cache posture: `Cache-Control: public, max-age=31536000, immutable` —
17
+ * hash is content-derived, the bytes can NEVER change for a given URL,
18
+ * so browsers + CDNs cache forever (immutable means "don't even
19
+ * revalidate"). A second render with the same componentCode / contract
20
+ * hits browser cache for free.
21
+ *
22
+ * CORS: same `*` posture as `/r/:shortCode` (JSON branch) — bytes are
23
+ * public-by-shortCode anyway (the agent already shared the URL with
24
+ * the host), and the bytes carry no credentials.
25
+ *
26
+ * Validation: hash MUST match `[a-f0-9]{64}` — strict charset gate
27
+ * closes path-traversal (`..`, `/`) and other shenanigans before the
28
+ * store sees the parameter.
29
+ */
30
+ import { CODE_HASH_REGEX } from "@ggui-ai/mcp-server-core";
31
+ /**
32
+ * Mount `GET /code/:hash.js` + `GET /contract/:hash.js` onto the
33
+ * express app. Returns nothing — the routes self-register.
34
+ */
35
+ export function mountCodeRoutes(opts) {
36
+ const { app, codeStore, logger } = opts;
37
+ const mountContentAddressableRoute = (mountPath, label) => {
38
+ app.get(mountPath, async (req, res) => {
39
+ res.setHeader("Access-Control-Allow-Origin", "*");
40
+ const hash = req.params["hash"];
41
+ if (typeof hash !== "string" || !CODE_HASH_REGEX.test(hash)) {
42
+ res.setHeader("Cache-Control", "no-store");
43
+ res.status(400).json({
44
+ error: {
45
+ code: "invalid_request",
46
+ message: "hash path parameter must be 64-char lowercase hex",
47
+ },
48
+ });
49
+ return;
50
+ }
51
+ try {
52
+ const code = await codeStore.get(hash);
53
+ if (code === null) {
54
+ res.setHeader("Cache-Control", "no-store");
55
+ res.status(404).json({
56
+ error: {
57
+ code: "not_found",
58
+ message: `unknown ${label} hash`,
59
+ },
60
+ });
61
+ return;
62
+ }
63
+ res.setHeader("Content-Type", "application/javascript; charset=utf-8");
64
+ res.setHeader("Cache-Control", "public, max-age=31536000, immutable");
65
+ res.status(200).send(code);
66
+ }
67
+ catch (err) {
68
+ logger.warn(`${label}_route_failed`, { hash, error: String(err) });
69
+ res.setHeader("Cache-Control", "no-store");
70
+ res.status(500).json({
71
+ error: {
72
+ code: "internal",
73
+ message: `${label} fetch failed`,
74
+ },
75
+ });
76
+ }
77
+ });
78
+ };
79
+ mountContentAddressableRoute("/code/:hash.js", "code");
80
+ mountContentAddressableRoute("/contract/:hash.js", "contract");
81
+ }
@@ -29,7 +29,7 @@
29
29
  * The store grows unbounded. Operators who care can periodically
30
30
  * `rm -rf ~/.ggui/code-cache/` — every entry is content-addressable
31
31
  * and immutable, so a re-fetch will repopulate from upstream code on
32
- * next push. There is no eviction policy in the seam itself.
32
+ * next render. There is no eviction policy in the seam itself.
33
33
  *
34
34
  * ## Permissions
35
35
  *
@@ -61,7 +61,7 @@ export class FileSystemCodeStore {
61
61
  const absPath = this.absPath(hash);
62
62
  // Idempotent: if the file already exists, skip rewrite. Cheap fast
63
63
  // path that avoids unnecessary disk churn when the same blueprint
64
- // is pushed repeatedly.
64
+ // is rendered repeatedly.
65
65
  if (await fileExists(absPath))
66
66
  return;
67
67
  await mkdir(dirname(absPath), { recursive: true });
@@ -33,23 +33,23 @@
33
33
  * so the cookie never leaves the console's origin in the first
34
34
  * place.
35
35
  *
36
- * Lifecycle. Cookie is minted at `POST /ggui/console/render-cookie`
36
+ * Lifecycle. Cookie is minted at `POST /ggui/console/session-cookie`
37
37
  * (operator posts a shortCode → server resolves → sets Set-Cookie).
38
38
  * Cookie is consumed at `GET /ws` upgrade (if the server composition
39
- * wires `cookieAuth` to the session-channel). Never mutated in
39
+ * wires `cookieAuth` to the render-channel). Never mutated in
40
40
  * between.
41
41
  */
42
42
  import type { IncomingHttpHeaders } from 'node:http';
43
43
  /**
44
44
  * Cookie name. Chosen deliberately to NOT conflict with common framework
45
45
  * cookies (Express session, CSRF, etc.). Change carries a compat
46
- * concern — the console SPA + the session-channel upgrade read by
46
+ * concern — the console SPA + the render-channel upgrade read by
47
47
  * this exact name. Keep this export as the single source of truth.
48
48
  */
49
49
  export declare const CONSOLE_COOKIE_NAME = "ggui_console_session";
50
50
  /**
51
51
  * Result of minting a cookie. Callers set the cookie on their response
52
- * (the cookie endpoint) and echo the bound `renderId`/`appId` back in
52
+ * (the cookie endpoint) and echo the bound `sessionId`/`appId` back in
53
53
  * the response body so the client SPA can bootstrap the viewer without
54
54
  * a follow-up round-trip.
55
55
  */
@@ -57,11 +57,11 @@ export interface DevtoolCookieMint {
57
57
  readonly cookieValue: string;
58
58
  readonly setCookieHeader: string;
59
59
  readonly expiresAt: number;
60
- readonly renderId: string;
60
+ readonly sessionId: string;
61
61
  readonly appId: string;
62
62
  }
63
63
  export interface MintDevtoolCookieInput {
64
- readonly renderId: string;
64
+ readonly sessionId: string;
65
65
  readonly appId: string;
66
66
  /** HMAC secret. Shared with bootstrap + session tokens by design. */
67
67
  readonly secret: string;
@@ -84,7 +84,7 @@ export interface MintDevtoolCookieInput {
84
84
  readonly sameSite?: 'Strict' | 'Lax' | 'None';
85
85
  }
86
86
  /**
87
- * Mint a cookie value bound to `{ renderId, appId }` and the formatted
87
+ * Mint a cookie value bound to `{ sessionId, appId }` and the formatted
88
88
  * `Set-Cookie` header to send on the response. Caller does
89
89
  * `res.setHeader('Set-Cookie', result.setCookieHeader)`.
90
90
  */
@@ -117,11 +117,11 @@ export declare function extractDevtoolCookie(cookieHeader: string | undefined):
117
117
  export declare function readDevtoolCookieFromHeaders(headers: IncomingHttpHeaders): string | null;
118
118
  /**
119
119
  * Verified claims extracted from an console cookie. Scope is
120
- * deliberately narrow: just the binding the session-channel upgrade
121
- * needs to enforce `subscribe.renderId === cookie.renderId`.
120
+ * deliberately narrow: just the binding the render-channel upgrade
121
+ * needs to enforce `subscribe.sessionId === cookie.sessionId`.
122
122
  */
123
123
  export interface DevtoolCookieClaims {
124
- readonly renderId: string;
124
+ readonly sessionId: string;
125
125
  readonly appId: string;
126
126
  }
127
127
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"console-auth.d.ts","sourceRoot":"","sources":["../src/console-auth.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAOrD;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,yBAAyB,CAAC;AAE1D;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;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S,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,MAAM,GACb,mBAAmB,GAAG,IAAI,CAO5B"}
@@ -2,18 +2,18 @@ import { DEFAULT_DEVTOOL_SESSION_TTL_SEC, mintDevtoolSessionToken, verifyToken,
2
2
  /**
3
3
  * Cookie name. Chosen deliberately to NOT conflict with common framework
4
4
  * cookies (Express session, CSRF, etc.). Change carries a compat
5
- * concern — the console SPA + the session-channel upgrade read by
5
+ * concern — the console SPA + the render-channel upgrade read by
6
6
  * this exact name. Keep this export as the single source of truth.
7
7
  */
8
8
  export const CONSOLE_COOKIE_NAME = 'ggui_console_session';
9
9
  /**
10
- * Mint a cookie value bound to `{ renderId, appId }` and the formatted
10
+ * Mint a cookie value bound to `{ sessionId, appId }` and the formatted
11
11
  * `Set-Cookie` header to send on the response. Caller does
12
12
  * `res.setHeader('Set-Cookie', result.setCookieHeader)`.
13
13
  */
14
14
  export function mintDevtoolCookie(input) {
15
15
  const ttlSec = input.ttlSec ?? DEFAULT_DEVTOOL_SESSION_TTL_SEC;
16
- const { token, claims } = mintDevtoolSessionToken({ renderId: input.renderId, appId: input.appId, ttlSec }, input.secret);
16
+ const { token, claims } = mintDevtoolSessionToken({ sessionId: input.sessionId, appId: input.appId, ttlSec }, input.secret);
17
17
  const attrs = [
18
18
  `${CONSOLE_COOKIE_NAME}=${token}`,
19
19
  `Path=${input.path ?? '/'}`,
@@ -27,7 +27,7 @@ export function mintDevtoolCookie(input) {
27
27
  cookieValue: token,
28
28
  setCookieHeader: attrs.join('; '),
29
29
  expiresAt: claims.exp * 1000,
30
- renderId: input.renderId,
30
+ sessionId: input.sessionId,
31
31
  appId: input.appId,
32
32
  };
33
33
  }
@@ -96,7 +96,7 @@ export function verifyDevtoolCookie(cookieValue, secret) {
96
96
  if (!result.ok)
97
97
  return null;
98
98
  return {
99
- renderId: result.claims.renderId,
99
+ sessionId: result.claims.sessionId,
100
100
  appId: result.claims.appId,
101
101
  };
102
102
  }
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Console blueprint resolution + try-live routes.
3
+ *
4
+ * GET /ggui/console/blueprint/:id — same-origin HTTP mirror of
5
+ * the `ggui_render_blueprint` MCP tool. Resolves a
6
+ * manifest-declared blueprint id to its compiled bundle +
7
+ * metadata via the wired `UiRegistry`; lets the SPA's
8
+ * `/preview/<id>` route mount the blueprint with a single fetch
9
+ * instead of negotiating a full MCP round-trip from the browser.
10
+ * POST /ggui/console/blueprint/:id/try — create a render, compile
11
+ * the blueprint's componentCode, commit a render with its full
12
+ * contract (actionSpec/streamSpec/propsSpec from the manifest),
13
+ * mint a shortCode, and return `{sessionId, shortCode, url}`.
14
+ * The returned `/s/<shortCode>` lands on the console's render
15
+ * viewer + subscribes to the render over `/ws`.
16
+ *
17
+ * Scope: registered only when a `UiRegistry` is present (same gate
18
+ * as the MCP render handler — no registry = no render path, no
19
+ * endpoint). No bearer auth: console routes are same-origin
20
+ * operator-facing; the operator already has OS access to the TSX
21
+ * sources this endpoint serves back.
22
+ *
23
+ * GET failure shape: { error, message } with a matching HTTP code.
24
+ * - 404 for unknown id OR known-id-no-bundle (source-only /
25
+ * compile-failed). The operator's remediation is the same in
26
+ * both cases (fix the manifest / fix the entry / fix the
27
+ * compile); splitting codes would add noise without signal.
28
+ * - 400 for malformed id parameters (empty, oversized).
29
+ *
30
+ * Shape symmetry: GET matches `GguiRenderBlueprintOutput` exactly, so
31
+ * the browser-side fetch can share a type import with MCP-tool
32
+ * callers without a translation layer.
33
+ *
34
+ * Try-live gates (all three required):
35
+ * - `uiRegistry` — blueprint resolution
36
+ * - `renderStore` — render persistence
37
+ * - `shortCodeIndex` — shortCode → render binding
38
+ *
39
+ * Partial gate (uiRegistry alone) → 503 with a remediation hint.
40
+ */
41
+ import type { GguiSessionStore, ShortCodeIndex } from "@ggui-ai/mcp-server-core";
42
+ import type { SharedHandler } from "@ggui-ai/mcp-server-handlers";
43
+ import type { UiRegistry } from "@ggui-ai/ui-registry";
44
+ import type { Express } from "express";
45
+ import type { ZodRawShape } from "zod";
46
+ import type { Logger } from "./logger.js";
47
+ import { type SchemaCompatMode } from "./schema-compat.js";
48
+ interface MountOptions {
49
+ /** Express app to mount onto. */
50
+ readonly app: Express;
51
+ /** Blueprint registry both routes resolve against. */
52
+ readonly uiRegistry: UiRegistry;
53
+ /** GguiSession store the try route commits into (gate 2 of 3). */
54
+ readonly renderStore?: GguiSessionStore;
55
+ /** shortCode → render binding for the try route (gate 3 of 3). */
56
+ readonly shortCodeIndex?: ShortCodeIndex;
57
+ /** Composed handler list the schema-compat check validates against. */
58
+ readonly handlers: ReadonlyArray<SharedHandler<ZodRawShape, ZodRawShape>>;
59
+ /** Schema-compat posture (`reject` default / `warn` / `off`). */
60
+ readonly schemaCompatMode: SchemaCompatMode;
61
+ /** Structured logger. */
62
+ readonly logger: Logger;
63
+ }
64
+ /**
65
+ * Mount `GET /ggui/console/blueprint/:id` +
66
+ * `POST /ggui/console/blueprint/:id/try` onto the express app.
67
+ * Returns nothing — the routes self-register.
68
+ */
69
+ export declare function mountConsoleBlueprintRoutes(opts: MountOptions): void;
70
+ export {};
71
+ //# sourceMappingURL=console-blueprint-routes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"console-blueprint-routes.d.ts","sourceRoot":"","sources":["../src/console-blueprint-routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AACjF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAElE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,KAAK,CAAC;AAGvC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAGL,KAAK,gBAAgB,EACtB,MAAM,oBAAoB,CAAC;AAqB5B,UAAU,YAAY;IACpB,iCAAiC;IACjC,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC;IACtB,sDAAsD;IACtD,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC,kEAAkE;IAClE,QAAQ,CAAC,WAAW,CAAC,EAAE,gBAAgB,CAAC;IACxC,kEAAkE;IAClE,QAAQ,CAAC,cAAc,CAAC,EAAE,cAAc,CAAC;IACzC,uEAAuE;IACvE,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC,aAAa,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC,CAAC;IAC1E,iEAAiE;IACjE,QAAQ,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IAC5C,yBAAyB;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,CAwRpE"}