@superblocksteam/gateway 2.0.161 → 2.0.162-next.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 (232) hide show
  1. package/README.md +135 -39
  2. package/dist/capabilities/lifecycle.d.ts +46 -29
  3. package/dist/capabilities/lifecycle.js +1731 -843
  4. package/dist/capabilities/lifecycle.js.map +1 -1
  5. package/dist/capabilities/query-integration.d.ts +14 -0
  6. package/dist/capabilities/query-integration.js +172 -0
  7. package/dist/capabilities/query-integration.js.map +1 -0
  8. package/dist/capabilities/source-files-archive.d.ts +11 -0
  9. package/dist/capabilities/source-files-archive.js +54 -0
  10. package/dist/capabilities/source-files-archive.js.map +1 -0
  11. package/dist/capabilities/types.d.ts +197 -119
  12. package/dist/capabilities/types.js +45 -6
  13. package/dist/capabilities/types.js.map +1 -1
  14. package/dist/capture/browser-contract.d.ts +15 -5
  15. package/dist/capture/browser-contract.js +13 -3
  16. package/dist/capture/browser-contract.js.map +1 -1
  17. package/dist/capture/browser-instructions.d.ts +3 -2
  18. package/dist/capture/browser-instructions.js +3 -2
  19. package/dist/capture/browser-instructions.js.map +1 -1
  20. package/dist/capture/mode.d.ts +8 -1
  21. package/dist/capture/mode.js +22 -2
  22. package/dist/capture/mode.js.map +1 -1
  23. package/dist/config.d.ts +22 -23
  24. package/dist/config.js +13 -12
  25. package/dist/config.js.map +1 -1
  26. package/dist/deps.d.ts +7 -7
  27. package/dist/index.d.ts +2 -4
  28. package/dist/index.js +2 -4
  29. package/dist/index.js.map +1 -1
  30. package/dist/integrations/read-only-postgres-query.d.ts +2 -0
  31. package/dist/integrations/read-only-postgres-query.js +164 -0
  32. package/dist/integrations/read-only-postgres-query.js.map +1 -0
  33. package/dist/main.js +1 -1
  34. package/dist/main.js.map +1 -1
  35. package/dist/playwright/ensure-chromium.d.ts +5 -7
  36. package/dist/playwright/ensure-chromium.js +13 -13
  37. package/dist/playwright/ensure-chromium.js.map +1 -1
  38. package/dist/preview/capture-screenshot.d.ts +30 -4
  39. package/dist/preview/capture-screenshot.js +67 -17
  40. package/dist/preview/capture-screenshot.js.map +1 -1
  41. package/dist/preview/viewer-url.js +3 -1
  42. package/dist/preview/viewer-url.js.map +1 -1
  43. package/dist/process/fault-barrier.js +1 -1
  44. package/dist/process/fault-barrier.js.map +1 -1
  45. package/dist/sabs/agent-facing-text.d.ts +2 -0
  46. package/dist/sabs/agent-facing-text.js +56 -2
  47. package/dist/sabs/agent-facing-text.js.map +1 -1
  48. package/dist/sabs/app-state.d.ts +126 -0
  49. package/dist/sabs/app-state.js +332 -0
  50. package/dist/sabs/app-state.js.map +1 -0
  51. package/dist/sabs/awaited-decision.d.ts +49 -0
  52. package/dist/sabs/awaited-decision.js +129 -0
  53. package/dist/sabs/awaited-decision.js.map +1 -0
  54. package/dist/sabs/editor-client-methods.d.ts +23 -5
  55. package/dist/sabs/editor-client-methods.js +45 -4
  56. package/dist/sabs/editor-client-methods.js.map +1 -1
  57. package/dist/sabs/editor-socket.d.ts +85 -0
  58. package/dist/sabs/editor-socket.js +67 -0
  59. package/dist/sabs/editor-socket.js.map +1 -0
  60. package/dist/sabs/session-peer.d.ts +119 -82
  61. package/dist/sabs/session-peer.js +10 -1
  62. package/dist/sabs/session-peer.js.map +1 -1
  63. package/dist/sabs/streamed-reply.d.ts +45 -0
  64. package/dist/sabs/streamed-reply.js +125 -0
  65. package/dist/sabs/streamed-reply.js.map +1 -0
  66. package/dist/sabs/turn-collector.d.ts +50 -35
  67. package/dist/sabs/turn-collector.js +110 -176
  68. package/dist/sabs/turn-collector.js.map +1 -1
  69. package/dist/sabs/websocket-session-peer.d.ts +104 -69
  70. package/dist/sabs/websocket-session-peer.js +1329 -475
  71. package/dist/sabs/websocket-session-peer.js.map +1 -1
  72. package/dist/server/client.d.ts +41 -9
  73. package/dist/server/client.js +126 -21
  74. package/dist/server/client.js.map +1 -1
  75. package/dist/start.d.ts +1 -1
  76. package/dist/start.js +30 -8
  77. package/dist/start.js.map +1 -1
  78. package/dist/stores/memory.d.ts +46 -0
  79. package/dist/stores/memory.js +163 -0
  80. package/dist/stores/memory.js.map +1 -0
  81. package/dist/stores/types.d.ts +92 -0
  82. package/dist/stores/types.js +11 -0
  83. package/dist/stores/types.js.map +1 -0
  84. package/dist/telemetry/mcp-client.d.ts +6 -1
  85. package/dist/telemetry/mcp-client.js +100 -4
  86. package/dist/telemetry/mcp-client.js.map +1 -1
  87. package/dist/telemetry/metrics.d.ts +12 -3
  88. package/dist/telemetry/metrics.js +60 -14
  89. package/dist/telemetry/metrics.js.map +1 -1
  90. package/dist/telemetry/runtime.js +4 -6
  91. package/dist/telemetry/runtime.js.map +1 -1
  92. package/dist/transports/mcp/admin-tools.d.ts +8 -0
  93. package/dist/transports/mcp/admin-tools.js +115 -4
  94. package/dist/transports/mcp/admin-tools.js.map +1 -1
  95. package/dist/transports/mcp/app-status-html.d.ts +4 -8
  96. package/dist/transports/mcp/app-status-html.js +336 -128
  97. package/dist/transports/mcp/app-status-html.js.map +1 -1
  98. package/dist/transports/mcp/client-presentation.d.ts +16 -0
  99. package/dist/transports/mcp/client-presentation.js +13 -0
  100. package/dist/transports/mcp/client-presentation.js.map +1 -0
  101. package/dist/transports/mcp/cowork-editor-url.d.ts +6 -0
  102. package/dist/transports/mcp/cowork-editor-url.js +10 -0
  103. package/dist/transports/mcp/cowork-editor-url.js.map +1 -0
  104. package/dist/transports/mcp/decision-card-html.d.ts +26 -0
  105. package/dist/transports/mcp/decision-card-html.js +876 -0
  106. package/dist/transports/mcp/decision-card-html.js.map +1 -0
  107. package/dist/transports/mcp/decision-elicitation.d.ts +42 -0
  108. package/dist/transports/mcp/decision-elicitation.js +59 -0
  109. package/dist/transports/mcp/decision-elicitation.js.map +1 -1
  110. package/dist/transports/mcp/editor-document-probe.d.ts +4 -0
  111. package/dist/transports/mcp/editor-document-probe.js +35 -0
  112. package/dist/transports/mcp/editor-document-probe.js.map +1 -0
  113. package/dist/transports/mcp/editor-integration-setup-url.d.ts +14 -0
  114. package/dist/transports/mcp/editor-integration-setup-url.js +29 -0
  115. package/dist/transports/mcp/editor-integration-setup-url.js.map +1 -0
  116. package/dist/transports/mcp/format-tool-content.d.ts +13 -18
  117. package/dist/transports/mcp/format-tool-content.js +172 -13
  118. package/dist/transports/mcp/format-tool-content.js.map +1 -1
  119. package/dist/transports/mcp/instructions/index.d.ts +23 -0
  120. package/dist/transports/mcp/instructions/index.js +81 -0
  121. package/dist/transports/mcp/instructions/index.js.map +1 -0
  122. package/dist/transports/mcp/instructions/result.d.ts +18 -0
  123. package/dist/transports/mcp/instructions/result.js +58 -0
  124. package/dist/transports/mcp/instructions/result.js.map +1 -0
  125. package/dist/transports/mcp/instructions/tools/ask-user.d.ts +2 -0
  126. package/dist/transports/mcp/instructions/tools/ask-user.js +20 -0
  127. package/dist/transports/mcp/instructions/tools/ask-user.js.map +1 -0
  128. package/dist/transports/mcp/instructions/tools/build-app.d.ts +4 -0
  129. package/dist/transports/mcp/instructions/tools/build-app.js +54 -0
  130. package/dist/transports/mcp/instructions/tools/build-app.js.map +1 -0
  131. package/dist/transports/mcp/instructions/tools/check-app-progress.d.ts +3 -0
  132. package/dist/transports/mcp/instructions/tools/check-app-progress.js +79 -0
  133. package/dist/transports/mcp/instructions/tools/check-app-progress.js.map +1 -0
  134. package/dist/transports/mcp/instructions/tools/check-publish-progress.d.ts +3 -0
  135. package/dist/transports/mcp/instructions/tools/check-publish-progress.js +23 -0
  136. package/dist/transports/mcp/instructions/tools/check-publish-progress.js.map +1 -0
  137. package/dist/transports/mcp/instructions/tools/copy.d.ts +18 -0
  138. package/dist/transports/mcp/instructions/tools/copy.js +49 -0
  139. package/dist/transports/mcp/instructions/tools/copy.js.map +1 -0
  140. package/dist/transports/mcp/instructions/tools/create-integration.d.ts +4 -0
  141. package/dist/transports/mcp/instructions/tools/create-integration.js +41 -0
  142. package/dist/transports/mcp/instructions/tools/create-integration.js.map +1 -0
  143. package/dist/transports/mcp/instructions/tools/edit-app.d.ts +3 -0
  144. package/dist/transports/mcp/instructions/tools/edit-app.js +18 -0
  145. package/dist/transports/mcp/instructions/tools/edit-app.js.map +1 -0
  146. package/dist/transports/mcp/instructions/tools/get-app.d.ts +3 -0
  147. package/dist/transports/mcp/instructions/tools/get-app.js +49 -0
  148. package/dist/transports/mcp/instructions/tools/get-app.js.map +1 -0
  149. package/dist/transports/mcp/instructions/tools/get-integration-metadata.d.ts +2 -0
  150. package/dist/transports/mcp/instructions/tools/get-integration-metadata.js +13 -0
  151. package/dist/transports/mcp/instructions/tools/get-integration-metadata.js.map +1 -0
  152. package/dist/transports/mcp/instructions/tools/index.d.ts +7 -0
  153. package/dist/transports/mcp/instructions/tools/index.js +31 -0
  154. package/dist/transports/mcp/instructions/tools/index.js.map +1 -0
  155. package/dist/transports/mcp/instructions/tools/publish-app.d.ts +3 -0
  156. package/dist/transports/mcp/instructions/tools/publish-app.js +23 -0
  157. package/dist/transports/mcp/instructions/tools/publish-app.js.map +1 -0
  158. package/dist/transports/mcp/instructions/tools/start-app.d.ts +3 -0
  159. package/dist/transports/mcp/instructions/tools/start-app.js +22 -0
  160. package/dist/transports/mcp/instructions/tools/start-app.js.map +1 -0
  161. package/dist/transports/mcp/instructions/tools/upload-artifact.d.ts +2 -0
  162. package/dist/transports/mcp/instructions/tools/upload-artifact.js +13 -0
  163. package/dist/transports/mcp/instructions/tools/upload-artifact.js.map +1 -0
  164. package/dist/transports/mcp/mcp-app-brand-css.d.ts +1 -0
  165. package/dist/transports/mcp/mcp-app-brand-css.js +180 -0
  166. package/dist/transports/mcp/mcp-app-brand-css.js.map +1 -0
  167. package/dist/transports/mcp/mount.d.ts +14 -1
  168. package/dist/transports/mcp/mount.js +729 -172
  169. package/dist/transports/mcp/mount.js.map +1 -1
  170. package/dist/transports/mcp/native-browser-presence.d.ts +45 -0
  171. package/dist/transports/mcp/native-browser-presence.js +158 -0
  172. package/dist/transports/mcp/native-browser-presence.js.map +1 -0
  173. package/dist/transports/mcp/plan-approval.d.ts +44 -0
  174. package/dist/transports/mcp/plan-approval.js +179 -0
  175. package/dist/transports/mcp/plan-approval.js.map +1 -0
  176. package/dist/transports/mcp/session-directory.d.ts +7 -0
  177. package/dist/transports/mcp/session-directory.js +18 -0
  178. package/dist/transports/mcp/session-directory.js.map +1 -0
  179. package/dist/transports/mcp/tool-names.d.ts +2 -0
  180. package/dist/transports/mcp/tool-names.js +2 -0
  181. package/dist/transports/mcp/tool-names.js.map +1 -0
  182. package/package.json +16 -7
  183. package/skills/superblocks-build/SKILL.md +59 -0
  184. package/skills/superblocks-import/SKILL.md +125 -0
  185. package/dist/capabilities/import-prompt.d.ts +0 -11
  186. package/dist/capabilities/import-prompt.js +0 -96
  187. package/dist/capabilities/import-prompt.js.map +0 -1
  188. package/dist/capabilities/persisted-progress.d.ts +0 -46
  189. package/dist/capabilities/persisted-progress.js +0 -246
  190. package/dist/capabilities/persisted-progress.js.map +0 -1
  191. package/dist/events/cursor.d.ts +0 -43
  192. package/dist/events/cursor.js +0 -78
  193. package/dist/events/cursor.js.map +0 -1
  194. package/dist/events/memory-event-store.d.ts +0 -34
  195. package/dist/events/memory-event-store.js +0 -110
  196. package/dist/events/memory-event-store.js.map +0 -1
  197. package/dist/events/merge.d.ts +0 -23
  198. package/dist/events/merge.js +0 -97
  199. package/dist/events/merge.js.map +0 -1
  200. package/dist/events/normalized-collector.d.ts +0 -62
  201. package/dist/events/normalized-collector.js +0 -156
  202. package/dist/events/normalized-collector.js.map +0 -1
  203. package/dist/events/schema.d.ts +0 -9
  204. package/dist/events/schema.js +0 -93
  205. package/dist/events/schema.js.map +0 -1
  206. package/dist/events/snapshot.d.ts +0 -32
  207. package/dist/events/snapshot.js +0 -57
  208. package/dist/events/snapshot.js.map +0 -1
  209. package/dist/events/stream-key.d.ts +0 -2
  210. package/dist/events/stream-key.js +0 -31
  211. package/dist/events/stream-key.js.map +0 -1
  212. package/dist/events/types.d.ts +0 -179
  213. package/dist/events/types.js +0 -66
  214. package/dist/events/types.js.map +0 -1
  215. package/dist/resume/memory-progress-store.d.ts +0 -39
  216. package/dist/resume/memory-progress-store.js +0 -82
  217. package/dist/resume/memory-progress-store.js.map +0 -1
  218. package/dist/resume/memory-recent-app-store.d.ts +0 -14
  219. package/dist/resume/memory-recent-app-store.js +0 -27
  220. package/dist/resume/memory-recent-app-store.js.map +0 -1
  221. package/dist/resume/memory-turn-store.d.ts +0 -18
  222. package/dist/resume/memory-turn-store.js +0 -73
  223. package/dist/resume/memory-turn-store.js.map +0 -1
  224. package/dist/resume/progress-key.d.ts +0 -21
  225. package/dist/resume/progress-key.js +0 -58
  226. package/dist/resume/progress-key.js.map +0 -1
  227. package/dist/resume/stores.d.ts +0 -14
  228. package/dist/resume/stores.js +0 -18
  229. package/dist/resume/stores.js.map +0 -1
  230. package/dist/resume/types.d.ts +0 -124
  231. package/dist/resume/types.js +0 -13
  232. package/dist/resume/types.js.map +0 -1
package/README.md CHANGED
@@ -3,13 +3,14 @@
3
3
  Standalone Superblocks entry point for a **single MCP connector** (Admin + Builder)
4
4
  over **stdio**, running as the already-logged-in Superblocks CLI user.
5
5
 
6
- Builder tools (`start_app`, `import_app`, `edit_app`, `check_app_progress`,
7
- `get_app`, `get_integration_metadata`, `preview_app`, `publish_app`) plus
8
- customer Admin tools from `@superblocksteam/mcp-server` share this process.
9
-
10
- The MCP host owns process lifecycle: it spawns `superblocks gateway serve`.
11
- There is no foreground HTTP `/mcp`, no OAuth resource server, and no linked-grant
12
- exchange. Personal API keys here are the CLI session
6
+ Builder tools (`upload_artifact`, `start_app`, `edit_app`,
7
+ `check_app_progress`, `ask_user`, `get_app`, `build_app`,
8
+ `get_preview_status`, `get_integration_metadata`, `publish_app`) plus customer
9
+ Admin tools from `@superblocksteam/mcp-server` share this process.
10
+
11
+ The MCP host owns process lifecycle: it spawns `superblocks mcp serve`. The
12
+ unified Gateway has no foreground HTTP `/mcp`, no OAuth resource server, and no
13
+ linked-grant exchange. Personal API keys here are the CLI session
13
14
  (`~/.superblocks/auth.json` / `SUPERBLOCKS_AUTH_FILE` / `just worktree auth`).
14
15
 
15
16
  Scope notes:
@@ -22,6 +23,56 @@ Scope notes:
22
23
  - No Slack wrapper (ENG-5596).
23
24
  - Orchestrator URL is discovered from Server agent inventory, not configured here.
24
25
 
26
+ ## Claude Code plugin
27
+
28
+ Add the Superblocks marketplace and install the plugin from inside Claude Code:
29
+
30
+ ```text
31
+ /plugin marketplace add https://unpkg.com/@superblocksteam/cli@beta/.claude-plugin/marketplace.json
32
+ /plugin install superblocks@superblocks
33
+ ```
34
+
35
+ The plugin includes Gateway and the `superblocks-import` skill. When prompted,
36
+ enter a Superblocks personal API key and your Superblocks instance URL. Claude
37
+ stores the API key in secure storage. The npm-backed plugin requires Node.js 24
38
+ or newer and npm 10 or newer.
39
+
40
+ ## Claude Cowork plugin
41
+
42
+ For a local desktop Cowork session:
43
+
44
+ 1. Install Node.js 24 or newer and npm 10 or newer.
45
+ 2. Download [the Cowork plugin](https://unpkg.com/@superblocksteam/cli@beta/dist/superblocks.plugin).
46
+ 3. Open `Customize > Plugins`, choose upload, and select the plugin file.
47
+ 4. Enter a Superblocks personal API key and your Superblocks instance URL.
48
+
49
+ The plugin starts Gateway on the desktop. It is unavailable in cloud Cowork
50
+ sessions, which cannot run local MCP servers.
51
+
52
+ ### Organization-managed rollout
53
+
54
+ Owners and Primary Owners on Team and Enterprise plans can distribute the
55
+ plugin from `Organization settings > Plugins`:
56
+
57
+ 1. Enable Cowork and Skills for the organization.
58
+ 2. Save a copy of `superblocks.plugin` with a `.zip` suffix. Organization
59
+ uploads require a valid `.zip` smaller than 50 MB.
60
+ 3. Choose `Add plugins > Upload a file`, then create a marketplace or add the
61
+ archive to an existing one.
62
+ 4. Set the plugin to `Installed by default` or `Required` and confirm its
63
+ version in the marketplace.
64
+
65
+ Upload a new archive with the same plugin name to replace the current version.
66
+ Members receive it on their next session or plugin refresh. To deprecate it, set
67
+ it to `Not available`; to remove it, delete it from the marketplace. Rollback
68
+ behavior is not documented by Anthropic; validate re-uploading a retained older
69
+ archive in a test marketplace before relying on it.
70
+
71
+ Superblocks supplies the archive and Gateway runtime. Claude organization Owners
72
+ control marketplace distribution and installation policy. Each member supplies
73
+ their Superblocks credentials; each desktop still needs Node.js, npm, and
74
+ permission to run local MCP servers. See [Anthropic's organization plugin guide](https://support.claude.com/en/articles/13837433-manage-plugins-for-your-organization).
75
+
25
76
  ## Internal review
26
77
 
27
78
  ```bash
@@ -29,26 +80,38 @@ Scope notes:
29
80
  superblocks login
30
81
 
31
82
  # Write a stdio MCP entry into the client config
32
- superblocks gateway setup --client claude
83
+ superblocks mcp setup --client claude
33
84
  # or: --client cursor / --client claude-desktop / --client generic
34
85
 
35
- # Restart the MCP host. It spawns Gateway; do not run gateway serve yourself.
86
+ # Restart the MCP host. It spawns Gateway; do not run mcp serve yourself.
36
87
  ```
37
88
 
89
+ `--client claude` also copies `skills/superblocks-import/SKILL.md` to
90
+ `~/.claude/skills/superblocks-import/`. `--client cursor` copies it to
91
+ `~/.cursor/skills/superblocks-import/`. Claude Desktop and generic clients
92
+ have no Agent Skills dir; they rely on the short MCP migration fallback.
93
+ Restart the host after setup so skills reload.
94
+
38
95
  `setup` writes an absolute spawn so the host does not depend on cwd.
39
96
  Published `bin/run.js` is the MCP `command` (its `node` shebang applies).
40
97
  Worktree `bin/dev.js` is launched with `tsx` and without `--watch`: the
41
98
  dev shebang is a file-watcher, which would kill stdio on source edits and
42
- corrupt JSON-RPC on stdout. When `SUPERBLOCKS_AUTH_FILE` or
43
- `SUPERBLOCKS_BASE_URL` is set (worktree auth), those are copied into the MCP
44
- `env` block.
99
+ corrupt JSON-RPC on stdout. When `SUPERBLOCKS_AUTH_FILE` is set (worktree
100
+ auth), it is copied into the MCP `env` block. Gateway derives both control
101
+ plane and remote UI URLs from `superblocksBaseUrl` in that auth file.
45
102
 
46
- Optional: `--with-screenshots` downloads Playwright Chromium for preview
47
- captures. Omit it; start still succeeds.
103
+ Optional: `mcp setup --with-screenshots` downloads Playwright Chromium for
104
+ preview captures. Omit it; MCP setup still succeeds.
48
105
 
49
106
  ## Local run
50
107
 
51
- The MCP host spawns Gateway. Do not run `gateway serve` in a TTY.
108
+ The MCP host spawns Gateway's default stdio transport. Do not run `mcp serve`
109
+ without `--transport http` in a TTY. The legacy Admin-only HTTP transport
110
+ remains available for compatibility:
111
+
112
+ ```bash
113
+ SUPERBLOCKS_MCP_HTTP_TOKEN=<token> superblocks mcp serve --transport http --port 8484
114
+ ```
52
115
 
53
116
  Against a remote Superblocks domain (EE / SaaS IR):
54
117
 
@@ -56,13 +119,14 @@ Against a remote Superblocks domain (EE / SaaS IR):
56
119
  cd packages/cli/packages/cli
57
120
  ./bin/dev.js config set domain <host>
58
121
  ./bin/dev.js login
59
- ./bin/dev.js gateway setup --client claude
122
+ ./bin/dev.js mcp setup --client claude
60
123
  ```
61
124
 
62
125
  Against a local control plane, start the stack first (`just up <worktree>`),
63
- then login and `gateway setup` the same way.
126
+ then login and `mcp setup` the same way.
64
127
 
65
- `superblocks mcp serve` (stdio Admin-only) is deprecated; prefer `gateway setup`.
128
+ The standalone `superblocks-mcp` Admin-only server is deprecated; prefer
129
+ `superblocks mcp setup`.
66
130
 
67
131
  ## Worktree MCP (Cursor / Claude)
68
132
 
@@ -73,7 +137,7 @@ Log in and run setup from the worktree CLI (not a globally installed `superblock
73
137
  cd packages/cli/packages/cli
74
138
  ./bin/dev.js config set domain <host>
75
139
  ./bin/dev.js login
76
- ./bin/dev.js gateway setup --client cursor
140
+ ./bin/dev.js mcp setup --client cursor
77
141
  # or: --client claude
78
142
  ```
79
143
 
@@ -87,12 +151,11 @@ for Cursor, `~/.claude.json` for Claude Code):
87
151
  "command": "/absolute/path/to/tsx/cli.mjs",
88
152
  "args": [
89
153
  "/absolute/path/to/packages/cli/packages/cli/bin/dev.js",
90
- "gateway",
154
+ "mcp",
91
155
  "serve"
92
156
  ],
93
157
  "env": {
94
- "SUPERBLOCKS_AUTH_FILE": "/absolute/path/to/worktree/.superblocks/auth.json",
95
- "SUPERBLOCKS_BASE_URL": "https://your-control-plane"
158
+ "SUPERBLOCKS_AUTH_FILE": "/absolute/path/to/worktree/.superblocks/auth.json"
96
159
  }
97
160
  }
98
161
  }
@@ -101,8 +164,9 @@ for Cursor, `~/.claude.json` for Claude Code):
101
164
 
102
165
  `command` is `tsx` without `--watch`: the `bin/dev.js` shebang is a file
103
166
  watcher, which would kill stdio on source edits and corrupt JSON-RPC on
104
- stdout. `env` only copies the CLI session (`SUPERBLOCKS_AUTH_FILE`,
105
- `SUPERBLOCKS_BASE_URL`). Do not add `SUPERBLOCKS_GATEWAY_FROM_SOURCE`.
167
+ stdout. `env` only copies the worktree CLI session path
168
+ (`SUPERBLOCKS_AUTH_FILE`). Gateway reads `superblocksBaseUrl` from that file.
169
+ Do not add `SUPERBLOCKS_GATEWAY_FROM_SOURCE`.
106
170
  Optional stderr tees (`2>> ~/.cursor/superblocks-gateway.err`) are host
107
171
  specific; `setup` does not write them.
108
172
 
@@ -146,11 +210,43 @@ package only the customer Admin surface. Builder tools are not registered.
146
210
 
147
211
  ## MCP tools
148
212
 
149
- After `gateway setup`, restart Claude Code or Cursor and call `start_app`,
150
- `edit_app`, `check_app_progress`, `get_app`, `get_integration_metadata`,
151
- `preview_app`, and `publish_app`. `get_integration_metadata` reads tables,
152
- columns, and types from a connected integration; use `search`, `limit`, and
153
- `offset` for large results. It needs no application: without one it mints an
213
+ After `mcp setup`, restart Claude Code or Cursor and call `upload_artifact`,
214
+ `start_app`, `edit_app`, `check_app_progress`, `ask_user`, `get_app`,
215
+ `build_app`, `get_preview_status`, `get_integration_metadata`, and
216
+ `publish_app`.
217
+
218
+ `upload_artifact` accepts any file the gateway can read through `filePath` -
219
+ an archive, an image, a PDF, or a log - or source the MCP client is writing out
220
+ itself through `files: [{ path, content }]`. `files` is archived as text, so
221
+ binary belongs on the `filePath` route, where the bytes never pass through the
222
+ model. Pass its returned artifact to `start_app` or `edit_app`; retries reuse
223
+ the same artifact and application IDs.
224
+
225
+ `ask_user` is what a turn ending on a plan or a question goes through. Hosts
226
+ with form elicitation never need it - `check_app_progress` puts the decision as
227
+ a native picker and answers Superblocks itself. Hosts without one (Claude
228
+ Desktop) get an MCP App: the plan with Build it / Change something beside it, or
229
+ the question with a button per option. The answer is posted back as the user's
230
+ own message (`ui/message`), so the host's agent loop continues as if they had
231
+ typed it. The decision is in the tool result as data either way, and the server
232
+ instructions require the host to write it out in chat as well - a host that
233
+ renders the card shows it instead of the tool text, and one that renders nothing
234
+ shows only the text.
235
+
236
+ `get_app` returns the current live development view without creating a commit or
237
+ starting a build. `build_app` is the explicit versioned-preview operation: use
238
+ it only when the user asks to build a commit preview, never automatically after
239
+ `start_app`, `edit_app`, or `get_app`. It creates a commit and starts or reuses
240
+ the build for that content, but does not publish the app or change its
241
+ permissions. If it returns `building`, carry its `applicationId`, `commitId`,
242
+ `directoryHash`, and optional `branch` into `get_preview_status`; do not call
243
+ `build_app` again to poll. The original `previewUrl` is the URL to use once the
244
+ status becomes `ready`. Call `publish_app` only when the user explicitly asks
245
+ to deploy the app.
246
+
247
+ `get_integration_metadata` reads tables, columns, and types from a connected
248
+ integration; use `search`, `limit`, and `offset` for large results. It needs no
249
+ application: without one it mints an
154
250
  `integrations:build` token scoped to that single integration. Pass
155
251
  `applicationId` only for an integration owned by one application, such as a
156
252
  Native DB, which is invisible without app context.
@@ -159,25 +255,25 @@ the org-wide lookup by id, so it answers `integration_not_permitted` without
159
255
  build permission on that integration and `integration_not_supported` for a
160
256
  plugin Clark cannot use as a tool.
161
257
  `get_integration_config_schema` is the create-integration form, not live data.
162
- See `.env.example` for optional configuration.
163
258
 
164
259
  ## Env
165
260
 
166
261
  See `.env.example`. Stores are in-memory only. Identity comes from the CLI
167
262
  session, not from these variables.
168
263
 
169
- | Variable | Purpose |
170
- | -------------------------- | ---------------------------------------------------------- |
171
- | `SUPERBLOCKS_SERVER_URL` | Control plane URL (default from `auth.json` or localhost). |
172
- | `GATEWAY_PROFILE_KEY` | Integration profile key (default `default`). |
173
- | `GATEWAY_LOCAL_AGENT` | Cloud-Prem laptop agent mode. |
174
- | `GATEWAY_ADMIN_TOOLS_ONLY` | Admin tools only; skip Builder surface. |
175
- | `SUPERBLOCKS_AUTH_FILE` | Worktree-local CLI session (from `just worktree auth`). |
176
- | `NODE_DEBUG=gateway` | Tool call stacks and conditional-flow logs on stderr. |
264
+ | Variable | Purpose |
265
+ | ---------------------------- | ---------------------------------------------------------- |
266
+ | `SUPERBLOCKS_SERVER_URL` | Control plane URL (default from `auth.json` or localhost). |
267
+ | `GATEWAY_PROFILE_KEY` | Integration profile key (default `default`). |
268
+ | `GATEWAY_LOCAL_AGENT` | Cloud-Prem laptop agent mode. |
269
+ | `GATEWAY_ADMIN_TOOLS_ONLY` | Admin tools only; skip Builder surface. |
270
+ | `GATEWAY_IMPORT_SEARCH_DIRS` | Fallback folders for bare or sandbox attachment paths. |
271
+ | `SUPERBLOCKS_AUTH_FILE` | Worktree-local CLI session (from `just worktree auth`). |
272
+ | `NODE_DEBUG=gateway` | Tool call stacks and conditional-flow logs on stderr. |
177
273
 
178
274
  Gateway debug logs include tool names, result states, decision branches, and
179
275
  entry-point stacks. They intentionally omit credentials, prompts, answers, and
180
- result payloads. Run `superblocks gateway setup --client <client> --debug`, then
276
+ result payloads. Run `superblocks mcp setup --client <client> --debug`, then
181
277
  restart the MCP host. Re-run setup without `--debug` to turn them off.
182
278
 
183
279
  ## Remote traceability
@@ -1,32 +1,24 @@
1
+ import { type HostBrowserTools } from "../capture/browser-contract.js";
1
2
  import type { CaptureLibraryScreenshot } from "../capture/capture-library.js";
2
3
  import type { GatewayConfig } from "../config.js";
3
- import type { EventStore } from "../events/types.js";
4
- import type { CapturePreviewScreenshot } from "../preview/capture-screenshot.js";
5
- import type { CallerRef, ProgressStore, RecentAppStore, TurnStore } from "../resume/types.js";
6
- import type { SessionPeer } from "../sabs/session-peer.js";
4
+ import { type CapturePreviewScreenshot } from "../preview/capture-screenshot.js";
5
+ import type { AppState } from "../sabs/app-state.js";
6
+ import { type SessionPeer } from "../sabs/session-peer.js";
7
7
  import type { SuperblocksServerClient } from "../server/client.js";
8
- import type { CapabilityResult, CheckAppProgressInput, CheckAppProgressResult, EditAppInput, EditAppResult, GetAppInput, GetAppResult, ImportAppInput, ImportAppResult, PreviewAppInput, PreviewAppResult, Principal, ProgressEvent, PublishAppInput, PublishAppResult, ResolvedPrincipal, StartAppInput, StartAppResult } from "./types.js";
8
+ import type { ProgressStore, RecentAppStore, StepUpTurnStore } from "../stores/types.js";
9
+ import type { CapabilityResult, CheckAppProgressInput, CheckAppProgressResult, CheckPublishProgressInput, EditAppInput, EditAppResult, AskUserInput, AskUserResult, GetAppInput, GetAppResult, PreviewAppInput, PreviewAppResult, PreviewStatusInput, PreviewStatusResult, Principal, ProgressEvent, PublishAppInput, PublishAppResult, ResolvedPrincipal, StartAppInput, StartAppResult, UploadArtifactInput, UploadArtifactResult } from "./types.js";
9
10
  export { IMPORT_ZIP_MAX_BYTES } from "./types.js";
10
11
  export type CapabilityContext = {
11
- /**
12
- * Who is polling, for resume. Absent on one-shot capability calls that do
13
- * not poll, in which case no cursor is kept.
14
- */
15
- caller?: CallerRef;
16
12
  config: GatewayConfig;
17
- /**
18
- * Durable history of the live-edit session. This is what a caller reads
19
- * when there is no local turn to ask — after a restart, on another replica,
20
- * or from a channel that never started the build.
21
- */
22
- events?: EventStore;
23
- /** Injected so pacing and stall thresholds are testable without real time. */
13
+ /** Injected so turn and stall thresholds are testable without real time. */
24
14
  now?: () => number;
25
15
  onProgress?: (event: ProgressEvent) => void;
26
16
  onPrincipalResolved?: (principal: ResolvedPrincipal) => void;
27
17
  principal: Principal;
28
- /** Where each caller's place in the event stream is kept between calls. */
29
- progressCursors?: ProgressStore;
18
+ /** Per-application facts that outlive any one turn. */
19
+ appState: AppState;
20
+ /** When each build last spoke, and whether its silence was reported. */
21
+ progress?: ProgressStore;
30
22
  recentApps: RecentAppStore;
31
23
  /**
32
24
  * Optional headless capture of the live library iframe (pitcherURL). Injected
@@ -39,11 +31,16 @@ export type CapabilityContext = {
39
31
  * Injected in tests; defaults to Playwright in the MCP transport.
40
32
  */
41
33
  capturePreviewScreenshot?: CapturePreviewScreenshot;
34
+ /**
35
+ * What the connected host can drive a browser with. Only a transport knows
36
+ * which client it is talking to; absent, the contract says "unknown".
37
+ */
38
+ hostBrowserTools?: HostBrowserTools;
42
39
  server: SuperblocksServerClient;
43
40
  sessionPeer: SessionPeer;
44
41
  /** The caller gave up on this call (an MCP cancellation, a closed request). */
45
42
  signal?: AbortSignal;
46
- turns: TurnStore;
43
+ stepUpTurns: StepUpTurnStore;
47
44
  };
48
45
  /**
49
46
  * Resolves the Superblocks user behind the CLI session this Gateway was
@@ -54,16 +51,19 @@ export type CapabilityContext = {
54
51
  * so it surfaces as an error rather than an interactive-auth elicitation.
55
52
  */
56
53
  export declare function ensurePrincipal(ctx: CapabilityContext): Promise<CapabilityResult<ResolvedPrincipal>>;
57
- export declare function resolveApplicationId(ctx: CapabilityContext, principal: ResolvedPrincipal, applicationId: string | undefined): Promise<CapabilityResult<string>>;
58
- export declare function startApp(ctx: CapabilityContext, input: StartAppInput): Promise<CapabilityResult<StartAppResult>>;
54
+ export declare function resolveApplicationId(ctx: CapabilityContext, principal: ResolvedPrincipal, applicationId: string | undefined,
59
55
  /**
60
- * Creates a fullstack app, uploads the caller's archive as an app attachment,
61
- * and hands Clark a migration prompt — the same path as the browser import
62
- * wizard, without the sessionStorage hop.
56
+ * `unambiguous` declines to guess while a second application is also in
57
+ * play. Reserved for calls that write: acting on the wrong application is
58
+ * cheap to undo for a status poll and not cheap at all for an edit.
63
59
  */
64
- export declare function importApp(ctx: CapabilityContext, input: ImportAppInput): Promise<CapabilityResult<ImportAppResult>>;
60
+ options?: {
61
+ unambiguous?: boolean;
62
+ }): Promise<CapabilityResult<string>>;
63
+ export declare function startApp(ctx: CapabilityContext, input: StartAppInput): Promise<CapabilityResult<StartAppResult>>;
64
+ export declare function uploadArtifact(ctx: CapabilityContext, input: UploadArtifactInput): Promise<CapabilityResult<UploadArtifactResult>>;
65
65
  export declare function checkAppProgress(ctx: CapabilityContext, input: CheckAppProgressInput): Promise<CapabilityResult<CheckAppProgressResult>>;
66
- export declare function editApp(ctx: CapabilityContext, input: EditAppInput): Promise<CapabilityResult<EditAppResult>>;
66
+ export declare function editApp(ctx: CapabilityContext, input: EditAppInput, approvedPlan?: object): Promise<CapabilityResult<EditAppResult>>;
67
67
  /**
68
68
  * Shows the app's current work on a real URL without deploying it - the
69
69
  * editor's Preview button, driven from here.
@@ -76,9 +76,26 @@ export declare function editApp(ctx: CapabilityContext, input: EditAppInput): Pr
76
76
  * second one.
77
77
  */
78
78
  export declare function previewApp(ctx: CapabilityContext, input: PreviewAppInput): Promise<CapabilityResult<PreviewAppResult>>;
79
+ /** Read the build backing an existing commit preview without creating work. */
80
+ export declare function getPreviewStatus(ctx: CapabilityContext, input: PreviewStatusInput): Promise<CapabilityResult<PreviewStatusResult>>;
81
+ /**
82
+ * Opens the decision card: what Superblocks asked, for the user to answer as a
83
+ * form rather than by typing an approval the host has to interpret.
84
+ *
85
+ * Its own tool because an MCP App is bound to one, and `check_app_progress`
86
+ * must stay text-only - a card tool reopens its card on every poll, so putting
87
+ * this on the poll loop would flash a blank form through a whole build.
88
+ */
89
+ export declare function askUser(ctx: CapabilityContext, input: AskUserInput): Promise<CapabilityResult<AskUserResult>>;
79
90
  /**
80
- * Lovable-style lookup: editor URL always, preview URLs when a build can be
81
- * ensured (default). Captures a screenshot whenever the preview is ready.
91
+ * Read the app's current live editor view without committing or building it.
82
92
  */
83
93
  export declare function getApp(ctx: CapabilityContext, input: GetAppInput): Promise<CapabilityResult<GetAppResult>>;
84
94
  export declare function publishApp(ctx: CapabilityContext, input: PublishAppInput): Promise<CapabilityResult<PublishAppResult>>;
95
+ /**
96
+ * Where a publish handed back as `publishing` has got to.
97
+ *
98
+ * Each call watches for a bounded slice of the rollout, then hands back a
99
+ * changing clock so repeated calls remain useful without outliving the host.
100
+ */
101
+ export declare function checkPublishProgress(ctx: CapabilityContext, input: CheckPublishProgressInput): Promise<CapabilityResult<PublishAppResult>>;