@quenty/studio-bridge 0.23.0 → 0.24.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 (231) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +36 -8
  3. package/dist/src/bridge/bridge-connection.d.ts.map +1 -1
  4. package/dist/src/bridge/bridge-connection.js +1 -0
  5. package/dist/src/bridge/bridge-connection.js.map +1 -1
  6. package/dist/src/bridge/bridge-session.d.ts +11 -16
  7. package/dist/src/bridge/bridge-session.d.ts.map +1 -1
  8. package/dist/src/bridge/bridge-session.js +37 -29
  9. package/dist/src/bridge/bridge-session.js.map +1 -1
  10. package/dist/src/bridge/bridge-session.test.js +35 -0
  11. package/dist/src/bridge/bridge-session.test.js.map +1 -1
  12. package/dist/src/bridge/internal/bridge-host.d.ts +2 -0
  13. package/dist/src/bridge/internal/bridge-host.d.ts.map +1 -1
  14. package/dist/src/bridge/internal/bridge-host.js +1 -0
  15. package/dist/src/bridge/internal/bridge-host.js.map +1 -1
  16. package/dist/src/bridge/internal/host-protocol.d.ts.map +1 -1
  17. package/dist/src/bridge/internal/host-protocol.js +23 -10
  18. package/dist/src/bridge/internal/host-protocol.js.map +1 -1
  19. package/dist/src/bridge/types.d.ts +5 -2
  20. package/dist/src/bridge/types.d.ts.map +1 -1
  21. package/dist/src/bridge/types.js.map +1 -1
  22. package/dist/src/commands/console/exec/exec.d.ts +13 -3
  23. package/dist/src/commands/console/exec/exec.d.ts.map +1 -1
  24. package/dist/src/commands/console/exec/exec.js +82 -7
  25. package/dist/src/commands/console/exec/exec.js.map +1 -1
  26. package/dist/src/commands/console/exec/exec.test.js +63 -1
  27. package/dist/src/commands/console/exec/exec.test.js.map +1 -1
  28. package/dist/src/commands/framework/action-loader.test.js +1 -1
  29. package/dist/src/commands/framework/action-loader.test.js.map +1 -1
  30. package/dist/src/commands/playtest/player/playtest-players.d.ts.map +1 -1
  31. package/dist/src/commands/playtest/player/playtest-players.js +15 -93
  32. package/dist/src/commands/playtest/player/playtest-players.js.map +1 -1
  33. package/dist/src/commands/playtest/player/playtest-players.test.js +34 -21
  34. package/dist/src/commands/playtest/player/playtest-players.test.js.map +1 -1
  35. package/dist/src/commands/playtest/playtest-sessions.d.ts +19 -3
  36. package/dist/src/commands/playtest/playtest-sessions.d.ts.map +1 -1
  37. package/dist/src/commands/playtest/playtest-sessions.js +54 -74
  38. package/dist/src/commands/playtest/playtest-sessions.js.map +1 -1
  39. package/dist/src/commands/playtest/playtest-sessions.test.js +74 -8
  40. package/dist/src/commands/playtest/playtest-sessions.test.js.map +1 -1
  41. package/dist/src/commands/playtest/run/run.d.ts +9 -7
  42. package/dist/src/commands/playtest/run/run.d.ts.map +1 -1
  43. package/dist/src/commands/playtest/run/run.js +33 -38
  44. package/dist/src/commands/playtest/run/run.js.map +1 -1
  45. package/dist/src/commands/process/close/close.d.ts +4 -0
  46. package/dist/src/commands/process/close/close.d.ts.map +1 -1
  47. package/dist/src/commands/process/close/close.js +54 -4
  48. package/dist/src/commands/process/close/close.js.map +1 -1
  49. package/dist/src/commands/process/close/close.test.js +36 -3
  50. package/dist/src/commands/process/close/close.test.js.map +1 -1
  51. package/dist/src/commands/process/info/info.d.ts +15 -2
  52. package/dist/src/commands/process/info/info.d.ts.map +1 -1
  53. package/dist/src/commands/process/info/info.js +44 -4
  54. package/dist/src/commands/process/info/info.js.map +1 -1
  55. package/dist/src/commands/process/info/info.test.js +48 -0
  56. package/dist/src/commands/process/info/info.test.js.map +1 -1
  57. package/dist/src/commands/process/launch/launch.d.ts.map +1 -1
  58. package/dist/src/commands/process/launch/launch.js +22 -3
  59. package/dist/src/commands/process/launch/launch.js.map +1 -1
  60. package/dist/src/commands/process/launch/launch.test.js +27 -5
  61. package/dist/src/commands/process/launch/launch.test.js.map +1 -1
  62. package/dist/src/commands/process/list/list.d.ts +49 -6
  63. package/dist/src/commands/process/list/list.d.ts.map +1 -1
  64. package/dist/src/commands/process/list/list.js +185 -18
  65. package/dist/src/commands/process/list/list.js.map +1 -1
  66. package/dist/src/commands/process/list/list.test.js +92 -1
  67. package/dist/src/commands/process/list/list.test.js.map +1 -1
  68. package/dist/src/commands/process/run/run.d.ts +1 -1
  69. package/dist/src/commands/process/run/run.d.ts.map +1 -1
  70. package/dist/src/commands/process/run/run.js +3 -3
  71. package/dist/src/commands/process/run/run.js.map +1 -1
  72. package/dist/src/docker/docker-delegator.js +1 -1
  73. package/dist/src/docker/docker-delegator.js.map +1 -1
  74. package/dist/src/docker/docker-delegator.test.js +1 -1
  75. package/dist/src/docker/docker-delegator.test.js.map +1 -1
  76. package/dist/src/plugin/playtest-bridge.d.ts +36 -0
  77. package/dist/src/plugin/playtest-bridge.d.ts.map +1 -0
  78. package/dist/src/plugin/playtest-bridge.js +65 -0
  79. package/dist/src/plugin/playtest-bridge.js.map +1 -0
  80. package/dist/src/plugin/playtest-bridge.test.d.ts +2 -0
  81. package/dist/src/plugin/playtest-bridge.test.d.ts.map +1 -0
  82. package/dist/src/plugin/playtest-bridge.test.js +35 -0
  83. package/dist/src/plugin/playtest-bridge.test.js.map +1 -0
  84. package/dist/src/process/studio-launch-registry.d.ts +14 -0
  85. package/dist/src/process/studio-launch-registry.d.ts.map +1 -0
  86. package/dist/src/process/studio-launch-registry.js +37 -0
  87. package/dist/src/process/studio-launch-registry.js.map +1 -0
  88. package/dist/src/process/studio-launch-registry.test.d.ts +2 -0
  89. package/dist/src/process/studio-launch-registry.test.d.ts.map +1 -0
  90. package/dist/src/process/studio-launch-registry.test.js +38 -0
  91. package/dist/src/process/studio-launch-registry.test.js.map +1 -0
  92. package/dist/src/process/studio-process-closer.d.ts +3 -1
  93. package/dist/src/process/studio-process-closer.d.ts.map +1 -1
  94. package/dist/src/process/studio-process-closer.js +29 -11
  95. package/dist/src/process/studio-process-closer.js.map +1 -1
  96. package/dist/src/process/studio-process-identity.d.ts +10 -0
  97. package/dist/src/process/studio-process-identity.d.ts.map +1 -0
  98. package/dist/src/process/studio-process-identity.js +63 -0
  99. package/dist/src/process/studio-process-identity.js.map +1 -0
  100. package/dist/src/process/studio-process-identity.test.d.ts +2 -0
  101. package/dist/src/process/studio-process-identity.test.d.ts.map +1 -0
  102. package/dist/src/process/studio-process-identity.test.js +30 -0
  103. package/dist/src/process/studio-process-identity.test.js.map +1 -0
  104. package/dist/src/roblox-mcp/index.d.ts +3 -0
  105. package/dist/src/roblox-mcp/index.d.ts.map +1 -0
  106. package/dist/src/roblox-mcp/index.js +3 -0
  107. package/dist/src/roblox-mcp/index.js.map +1 -0
  108. package/dist/src/roblox-mcp/mcp/mcp-stdio-client.d.ts +60 -0
  109. package/dist/src/roblox-mcp/mcp/mcp-stdio-client.d.ts.map +1 -0
  110. package/dist/src/roblox-mcp/mcp/mcp-stdio-client.js +171 -0
  111. package/dist/src/roblox-mcp/mcp/mcp-stdio-client.js.map +1 -0
  112. package/dist/src/roblox-mcp/mcp/mcp-stdio-client.test.d.ts +2 -0
  113. package/dist/src/roblox-mcp/mcp/mcp-stdio-client.test.d.ts.map +1 -0
  114. package/dist/src/roblox-mcp/mcp/mcp-stdio-client.test.js +104 -0
  115. package/dist/src/roblox-mcp/mcp/mcp-stdio-client.test.js.map +1 -0
  116. package/dist/src/roblox-mcp/mcp/repair-list-result.d.ts +2 -0
  117. package/dist/src/roblox-mcp/mcp/repair-list-result.d.ts.map +1 -0
  118. package/dist/src/roblox-mcp/mcp/repair-list-result.js +22 -0
  119. package/dist/src/roblox-mcp/mcp/repair-list-result.js.map +1 -0
  120. package/dist/src/roblox-mcp/mcp/repair-list-result.test.d.ts +2 -0
  121. package/dist/src/roblox-mcp/mcp/repair-list-result.test.d.ts.map +1 -0
  122. package/dist/src/roblox-mcp/mcp/repair-list-result.test.js +42 -0
  123. package/dist/src/roblox-mcp/mcp/repair-list-result.test.js.map +1 -0
  124. package/dist/src/roblox-mcp/roblox-studio-mcp.d.ts +34 -0
  125. package/dist/src/roblox-mcp/roblox-studio-mcp.d.ts.map +1 -0
  126. package/dist/src/roblox-mcp/roblox-studio-mcp.js +190 -0
  127. package/dist/src/roblox-mcp/roblox-studio-mcp.js.map +1 -0
  128. package/dist/src/roblox-mcp/roblox-studio-mcp.test.d.ts +2 -0
  129. package/dist/src/roblox-mcp/roblox-studio-mcp.test.d.ts.map +1 -0
  130. package/dist/src/roblox-mcp/roblox-studio-mcp.test.js +123 -0
  131. package/dist/src/roblox-mcp/roblox-studio-mcp.test.js.map +1 -0
  132. package/dist/src/roblox-mcp/studio/studio-session.d.ts +39 -0
  133. package/dist/src/roblox-mcp/studio/studio-session.d.ts.map +1 -0
  134. package/dist/src/roblox-mcp/studio/studio-session.js +175 -0
  135. package/dist/src/roblox-mcp/studio/studio-session.js.map +1 -0
  136. package/dist/src/roblox-mcp/studio/studio-session.test.d.ts +2 -0
  137. package/dist/src/roblox-mcp/studio/studio-session.test.d.ts.map +1 -0
  138. package/dist/src/roblox-mcp/studio/studio-session.test.js +213 -0
  139. package/dist/src/roblox-mcp/studio/studio-session.test.js.map +1 -0
  140. package/dist/src/roblox-mcp/studio-mcp-locator.d.ts +19 -0
  141. package/dist/src/roblox-mcp/studio-mcp-locator.d.ts.map +1 -0
  142. package/dist/src/roblox-mcp/studio-mcp-locator.js +121 -0
  143. package/dist/src/roblox-mcp/studio-mcp-locator.js.map +1 -0
  144. package/dist/src/roblox-mcp/studio-mcp-locator.test.d.ts +2 -0
  145. package/dist/src/roblox-mcp/studio-mcp-locator.test.d.ts.map +1 -0
  146. package/dist/src/roblox-mcp/studio-mcp-locator.test.js +107 -0
  147. package/dist/src/roblox-mcp/studio-mcp-locator.test.js.map +1 -0
  148. package/dist/src/roblox-mcp/studio-mcp-snapshot.d.ts +23 -0
  149. package/dist/src/roblox-mcp/studio-mcp-snapshot.d.ts.map +1 -0
  150. package/dist/src/roblox-mcp/studio-mcp-snapshot.js +65 -0
  151. package/dist/src/roblox-mcp/studio-mcp-snapshot.js.map +1 -0
  152. package/dist/src/roblox-mcp/studio-mcp-snapshot.test.d.ts +2 -0
  153. package/dist/src/roblox-mcp/studio-mcp-snapshot.test.d.ts.map +1 -0
  154. package/dist/src/roblox-mcp/studio-mcp-snapshot.test.js +81 -0
  155. package/dist/src/roblox-mcp/studio-mcp-snapshot.test.js.map +1 -0
  156. package/dist/src/roblox-mcp/test/fake-mcp-server.d.ts +27 -0
  157. package/dist/src/roblox-mcp/test/fake-mcp-server.d.ts.map +1 -0
  158. package/dist/src/roblox-mcp/test/fake-mcp-server.js +55 -0
  159. package/dist/src/roblox-mcp/test/fake-mcp-server.js.map +1 -0
  160. package/dist/src/server/web-socket-protocol.d.ts +50 -15
  161. package/dist/src/server/web-socket-protocol.d.ts.map +1 -1
  162. package/dist/src/server/web-socket-protocol.js +63 -13
  163. package/dist/src/server/web-socket-protocol.js.map +1 -1
  164. package/dist/tsconfig.tsbuildinfo +1 -1
  165. package/docs/playtest-bridge.md +21 -0
  166. package/package.json +2 -2
  167. package/src/bridge/bridge-connection.ts +1 -0
  168. package/src/bridge/bridge-session.test.ts +51 -0
  169. package/src/bridge/bridge-session.ts +66 -47
  170. package/src/bridge/internal/bridge-host.ts +3 -0
  171. package/src/bridge/internal/host-protocol.ts +22 -9
  172. package/src/bridge/types.ts +5 -0
  173. package/src/commands/console/exec/exec.test.ts +94 -0
  174. package/src/commands/console/exec/exec.ts +130 -16
  175. package/src/commands/console/exec/execute.lua +147 -5
  176. package/src/commands/console/exec/execute.spec.lua +22 -2
  177. package/src/commands/framework/action-loader.test.ts +1 -1
  178. package/src/commands/playtest/player/playtest-players.lua +127 -0
  179. package/src/commands/playtest/player/playtest-players.spec.lua +48 -0
  180. package/src/commands/playtest/player/playtest-players.test.ts +40 -21
  181. package/src/commands/playtest/player/playtest-players.ts +30 -110
  182. package/src/commands/playtest/playtest-sessions.test.ts +116 -14
  183. package/src/commands/playtest/playtest-sessions.ts +77 -88
  184. package/src/commands/playtest/run/run.ts +44 -58
  185. package/src/commands/playtest/start/start-playtest.lua +105 -6
  186. package/src/commands/process/close/close.test.ts +52 -3
  187. package/src/commands/process/close/close.ts +78 -4
  188. package/src/commands/process/info/info.test.ts +76 -0
  189. package/src/commands/process/info/info.ts +74 -6
  190. package/src/commands/process/launch/launch.test.ts +33 -5
  191. package/src/commands/process/launch/launch.ts +41 -3
  192. package/src/commands/process/list/list.test.ts +130 -1
  193. package/src/commands/process/list/list.ts +290 -22
  194. package/src/commands/process/run/run.ts +4 -4
  195. package/src/docker/docker-delegator.test.ts +1 -1
  196. package/src/docker/docker-delegator.ts +1 -1
  197. package/src/plugin/playtest-bridge.test.ts +53 -0
  198. package/src/plugin/playtest-bridge.ts +98 -0
  199. package/src/process/studio-launch-registry.test.ts +56 -0
  200. package/src/process/studio-launch-registry.ts +63 -0
  201. package/src/process/studio-process-closer.ts +36 -11
  202. package/src/process/studio-process-identity.test.ts +45 -0
  203. package/src/process/studio-process-identity.ts +90 -0
  204. package/src/roblox-mcp/index.ts +17 -0
  205. package/src/roblox-mcp/mcp/mcp-stdio-client.test.ts +148 -0
  206. package/src/roblox-mcp/mcp/mcp-stdio-client.ts +270 -0
  207. package/src/roblox-mcp/mcp/repair-list-result.test.ts +52 -0
  208. package/src/roblox-mcp/mcp/repair-list-result.ts +23 -0
  209. package/src/roblox-mcp/roblox-studio-mcp.test.ts +168 -0
  210. package/src/roblox-mcp/roblox-studio-mcp.ts +330 -0
  211. package/src/roblox-mcp/studio/studio-session.test.ts +284 -0
  212. package/src/roblox-mcp/studio/studio-session.ts +279 -0
  213. package/src/roblox-mcp/studio-mcp-locator.test.ts +186 -0
  214. package/src/roblox-mcp/studio-mcp-locator.ts +180 -0
  215. package/src/roblox-mcp/studio-mcp-snapshot.test.ts +113 -0
  216. package/src/roblox-mcp/studio-mcp-snapshot.ts +104 -0
  217. package/src/roblox-mcp/test/fake-mcp-server.ts +74 -0
  218. package/src/server/web-socket-protocol.ts +119 -29
  219. package/templates/studio-bridge-plugin/playtest/StudioBridgePlaytest.client.lua +32 -0
  220. package/templates/studio-bridge-plugin/playtest/StudioBridgePlaytest.server.lua +40 -0
  221. package/templates/studio-bridge-plugin/src/Shared/ActionRouter.lua +25 -3
  222. package/templates/studio-bridge-plugin/src/Shared/PrecompiledSources.lua +47 -0
  223. package/templates/studio-bridge-plugin/src/Shared/PrecompiledSources.spec.lua +57 -0
  224. package/templates/studio-bridge-plugin/src/Shared/StudioBridgeClient.lua +357 -0
  225. package/templates/studio-bridge-plugin/src/Shared/StudioBridgeSessionUtils.lua +29 -3
  226. package/templates/studio-bridge-plugin/src/Shared/StudioBridgeSessionUtils.spec.lua +35 -2
  227. package/templates/studio-bridge-plugin/src/StudioBridgePlugin.server.lua +16 -292
  228. package/src/commands/playtest/run/playtest-runner.luau +0 -264
  229. package/src/commands/playtest/run/playtest-runner.spec.lua +0 -71
  230. package/src/commands/playtest/run/run-playtest-script.lua +0 -139
  231. package/src/commands/playtest/run/run-playtest-script.spec.lua +0 -43
@@ -0,0 +1,190 @@
1
+ import { listStudioProcessesAsync } from '../process/studio-process-closer.js';
2
+ import { McpStdioClient, McpTimeoutError, } from './mcp/mcp-stdio-client.js';
3
+ import { findStudioMcpLaunchAsync, StudioMcpUnsupportedError, } from './studio-mcp-locator.js';
4
+ import { cleanToolError, DATAMODEL_TYPES, listMcpStudiosAsync, matchStudiosAsync, resolveStudio, StudioNotFoundError, } from './studio/studio-session.js';
5
+ const DEFAULT_TIMEOUT_MS = 15_000;
6
+ const STEP_TIMEOUT_MS = 5_000;
7
+ const STUDIO_RECONNECT_MS = 4_000;
8
+ const RECONNECT_POLL_MS = 250;
9
+ const SETTLE_RESERVE_MS = 2_500;
10
+ const IDLE_CLOSE_MS = 15_000;
11
+ let _shared;
12
+ export async function tryListStudiosAsync(options = {}) {
13
+ return _withMcpAsync(options, async (shared, remainingMs) => {
14
+ const { studios, settled } = await _listSettledAsync(shared, remainingMs, options.sessions);
15
+ return { value: await _matchAsync(shared, options, studios), settled };
16
+ });
17
+ }
18
+ export async function tryExecuteLuauAsync(code, options = {}) {
19
+ return tryCallStudioToolAsync('execute_luau', { code }, options);
20
+ }
21
+ export async function tryCallStudioToolAsync(tool, args = {}, options = {}) {
22
+ return _withMcpAsync(options, async (shared, remainingMs) => {
23
+ const { studios } = await _listSettledAsync(shared, remainingMs, options.sessions);
24
+ const studio = resolveStudio(await _matchAsync(shared, options, studios), options.target);
25
+ const reply = await shared.client.callToolAsync(tool, {
26
+ ...args,
27
+ studio_id: studio.studioId,
28
+ ...(options.context
29
+ ? { datamodel_type: DATAMODEL_TYPES[options.context] }
30
+ : tool === 'execute_luau'
31
+ ? { datamodel_type: DATAMODEL_TYPES.edit }
32
+ : {}),
33
+ }, remainingMs());
34
+ if (reply.isError) {
35
+ throw new StudioMcpError('failed', cleanToolError(reply.text) || `${tool} failed`, studio);
36
+ }
37
+ return { value: reply.text, studio };
38
+ });
39
+ }
40
+ export async function closeStudioMcpAsync() {
41
+ const shared = _shared;
42
+ _shared = undefined;
43
+ if (shared) {
44
+ clearTimeout(shared.idleTimer);
45
+ await shared.client.closeAsync();
46
+ }
47
+ }
48
+ class StudioMcpError extends Error {
49
+ reason;
50
+ studio;
51
+ constructor(reason, message, studio) {
52
+ super(message);
53
+ this.reason = reason;
54
+ this.studio = studio;
55
+ }
56
+ }
57
+ async function _withMcpAsync(options, runAsync) {
58
+ const totalMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
59
+ const endsAt = Date.now() + totalMs;
60
+ const remainingMs = () => Math.max(1, endsAt - Date.now());
61
+ let shared;
62
+ let timer;
63
+ const work = (async () => {
64
+ shared = await _acquireAsync(options, remainingMs);
65
+ return { success: true, ...(await runAsync(shared, remainingMs)) };
66
+ })();
67
+ work.catch(() => { });
68
+ const deadline = new Promise((_, reject) => {
69
+ timer = setTimeout(() => reject(new McpTimeoutError(`Studio's MCP server did not finish within ${totalMs}ms`)), totalMs);
70
+ });
71
+ try {
72
+ const result = await Promise.race([work, deadline]);
73
+ _scheduleIdleClose(shared);
74
+ return result;
75
+ }
76
+ catch (err) {
77
+ const failure = _toFailure(err);
78
+ if (failure.reason === 'timeout' || failure.reason === 'unavailable') {
79
+ await _discardAsync(shared);
80
+ }
81
+ else {
82
+ _scheduleIdleClose(shared);
83
+ }
84
+ return failure;
85
+ }
86
+ finally {
87
+ clearTimeout(timer);
88
+ }
89
+ }
90
+ async function _acquireAsync(options, remainingMs) {
91
+ const key = options.executablePath ?? 'auto';
92
+ if (_shared &&
93
+ _shared.client.isRunning &&
94
+ _shared.key === key &&
95
+ _shared.spawnProcess === options.spawnProcess) {
96
+ clearTimeout(_shared.idleTimer);
97
+ return _shared;
98
+ }
99
+ await closeStudioMcpAsync();
100
+ try {
101
+ const launch = options.executablePath
102
+ ? { command: options.executablePath, args: [] }
103
+ : await findStudioMcpLaunchAsync();
104
+ const client = await McpStdioClient.startAsync(launch.command, {
105
+ args: launch.args,
106
+ env: 'env' in launch ? launch.env : undefined,
107
+ spawnProcess: options.spawnProcess,
108
+ requestTimeoutMs: STEP_TIMEOUT_MS,
109
+ });
110
+ _shared = {
111
+ client,
112
+ startedAt: Date.now(),
113
+ key,
114
+ spawnProcess: options.spawnProcess,
115
+ };
116
+ return _shared;
117
+ }
118
+ catch (err) {
119
+ if (err instanceof StudioMcpUnsupportedError) {
120
+ throw new StudioMcpError('unsupported', err.message);
121
+ }
122
+ throw new StudioMcpError('unavailable', `Studio's MCP server is unavailable: ${_message(err)}`);
123
+ }
124
+ }
125
+ async function _listSettledAsync(shared, remainingMs, sessions = []) {
126
+ const editSessions = sessions.filter((s) => s.context === 'edit').length;
127
+ const isEnough = (found) => found.length > 0 && found.length >= editSessions;
128
+ const settlesAt = shared.startedAt + STUDIO_RECONNECT_MS;
129
+ let studios = await listMcpStudiosAsync(shared.client);
130
+ while (!isEnough(studios) &&
131
+ Date.now() < settlesAt &&
132
+ remainingMs() > SETTLE_RESERVE_MS) {
133
+ await new Promise((resolve) => setTimeout(resolve, RECONNECT_POLL_MS));
134
+ studios = await listMcpStudiosAsync(shared.client);
135
+ }
136
+ return { studios, settled: isEnough(studios) || Date.now() >= settlesAt };
137
+ }
138
+ async function _matchAsync(shared, options, studios) {
139
+ const windows = await (options.listWindowsAsync ?? _listWindowsAsync)().catch(() => []);
140
+ return matchStudiosAsync(shared.client, options.sessions ?? [], windows, {
141
+ readPlaceIds: options.readPlaceIds,
142
+ studios,
143
+ sessionPids: options.sessionPids,
144
+ });
145
+ }
146
+ function _scheduleIdleClose(shared) {
147
+ if (!shared || shared !== _shared) {
148
+ return;
149
+ }
150
+ clearTimeout(shared.idleTimer);
151
+ shared.idleTimer = setTimeout(() => {
152
+ if (_shared === shared) {
153
+ void closeStudioMcpAsync();
154
+ }
155
+ }, IDLE_CLOSE_MS);
156
+ shared.idleTimer.unref();
157
+ }
158
+ async function _discardAsync(shared) {
159
+ if (shared && shared === _shared) {
160
+ await closeStudioMcpAsync();
161
+ }
162
+ else {
163
+ await shared?.client.closeAsync();
164
+ }
165
+ }
166
+ function _toFailure(err) {
167
+ if (err instanceof StudioMcpError) {
168
+ return {
169
+ success: false,
170
+ reason: err.reason,
171
+ message: err.message,
172
+ ...(err.studio ? { studio: err.studio } : {}),
173
+ };
174
+ }
175
+ const message = _message(err);
176
+ if (err instanceof McpTimeoutError) {
177
+ return { success: false, reason: 'timeout', message };
178
+ }
179
+ if (err instanceof StudioNotFoundError) {
180
+ return { success: false, reason: 'no-studio', message };
181
+ }
182
+ return { success: false, reason: 'unavailable', message };
183
+ }
184
+ async function _listWindowsAsync() {
185
+ return (await listStudioProcessesAsync()).map(({ pid, windowTitle, startedAt }) => ({ pid, windowTitle, startedAt }));
186
+ }
187
+ function _message(err) {
188
+ return err instanceof Error ? err.message : String(err);
189
+ }
190
+ //# sourceMappingURL=roblox-studio-mcp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"roblox-studio-mcp.js","sourceRoot":"","sources":["../../../src/roblox-mcp/roblox-studio-mcp.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAC/E,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 +1 @@
1
+ {"version":3,"file":"roblox-studio-mcp.test.d.ts","sourceRoot":"","sources":["../../../src/roblox-mcp/roblox-studio-mcp.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,123 @@
1
+ import { afterEach, describe, expect, it, vi } from 'vitest';
2
+ import { closeStudioMcpAsync, tryCallStudioToolAsync, tryExecuteLuauAsync, tryListStudiosAsync, } from './roblox-studio-mcp.js';
3
+ import { createFakeMcpServer, toolText, } from './test/fake-mcp-server.js';
4
+ const STUDIOS = [
5
+ { id: 'mcp-1', name: 'Place1' },
6
+ { id: 'mcp-2', name: 'Hub' },
7
+ ];
8
+ function fake(handler = () => undefined, studios = STUDIOS) {
9
+ const server = createFakeMcpServer((method, params) => {
10
+ if (method === 'initialize') {
11
+ return { result: { protocolVersion: '2025-06-18', capabilities: {} } };
12
+ }
13
+ if (params?.name === 'list_roblox_studios') {
14
+ return toolText(JSON.stringify({ studios }));
15
+ }
16
+ if (params?.name === 'execute_luau' &&
17
+ params.arguments.code.includes('os.clock')) {
18
+ return toolText('0,0,0');
19
+ }
20
+ return handler(method, params);
21
+ });
22
+ return {
23
+ server,
24
+ options: {
25
+ executablePath: 'StudioMCP.exe',
26
+ spawnProcess: () => server.child,
27
+ listWindowsAsync: async () => [],
28
+ },
29
+ };
30
+ }
31
+ afterEach(async () => {
32
+ vi.useRealTimers();
33
+ await closeStudioMcpAsync();
34
+ });
35
+ describe('tryExecuteLuauAsync', () => {
36
+ it('runs Luau in the targeted Studio and returns its result', async () => {
37
+ const { server, options } = fake((_method, params) => params?.name === 'execute_luau' ? toolText('42') : undefined);
38
+ const result = await tryExecuteLuauAsync('return 42', {
39
+ ...options,
40
+ target: 'hub',
41
+ });
42
+ expect(result).toMatchObject({ success: true, value: '42' });
43
+ expect(server.requests.at(-1)?.params.arguments).toEqual({
44
+ code: 'return 42',
45
+ studio_id: 'mcp-2',
46
+ datamodel_type: 'Edit',
47
+ });
48
+ });
49
+ it('sends the context as the data model', async () => {
50
+ const { server, options } = fake(() => toolText('ok'));
51
+ await tryExecuteLuauAsync('return 1', {
52
+ ...options,
53
+ target: 'hub',
54
+ context: 'server',
55
+ });
56
+ expect(server.requests.at(-1)?.params.arguments.datamodel_type).toBe('Server');
57
+ });
58
+ it('fails with the script error, naming the Studio', async () => {
59
+ const { options } = fake(() => toolText('boom', true));
60
+ const result = await tryExecuteLuauAsync('error("boom")', {
61
+ ...options,
62
+ target: 'hub',
63
+ });
64
+ expect(result).toMatchObject({
65
+ success: false,
66
+ reason: 'failed',
67
+ message: 'boom',
68
+ studio: { studioId: 'mcp-2' },
69
+ });
70
+ });
71
+ it('fails with no-studio when the target is ambiguous', async () => {
72
+ const { options } = fake();
73
+ const result = await tryExecuteLuauAsync('return 1', options);
74
+ expect(result).toMatchObject({ success: false, reason: 'no-studio' });
75
+ });
76
+ it('fails with unavailable when the server exits before answering', async () => {
77
+ const server = createFakeMcpServer(() => undefined);
78
+ server.exit(1, 'no Studio');
79
+ const result = await tryExecuteLuauAsync('return 1', {
80
+ executablePath: 'StudioMCP.exe',
81
+ spawnProcess: () => server.child,
82
+ listWindowsAsync: async () => [],
83
+ });
84
+ expect(result).toMatchObject({ success: false, reason: 'unavailable' });
85
+ expect(result.success || result.message).toContain('no Studio');
86
+ });
87
+ it('fails with timeout when the whole call outlives its deadline', async () => {
88
+ vi.useFakeTimers({ toFake: ['setTimeout', 'clearTimeout'] });
89
+ const { server, options } = fake(() => undefined);
90
+ const pending = tryExecuteLuauAsync('return 1', {
91
+ ...options,
92
+ target: 'hub',
93
+ });
94
+ await vi.advanceTimersByTimeAsync(15_000);
95
+ expect(await pending).toMatchObject({ success: false, reason: 'timeout' });
96
+ expect(server.child.killed).toBe(true);
97
+ });
98
+ });
99
+ describe('tryCallStudioToolAsync', () => {
100
+ it('fills in the studio id and leaves other tools without a data model', async () => {
101
+ const { server, options } = fake(() => toolText('Edit'));
102
+ const result = await tryCallStudioToolAsync('get_studio_state', {}, {
103
+ ...options,
104
+ target: 'place1',
105
+ });
106
+ expect(result).toMatchObject({ success: true, value: 'Edit' });
107
+ expect(server.requests.at(-1)?.params).toEqual({
108
+ name: 'get_studio_state',
109
+ arguments: { studio_id: 'mcp-1' },
110
+ });
111
+ });
112
+ });
113
+ describe('tryListStudiosAsync', () => {
114
+ it('lists the open Studios', async () => {
115
+ const { options } = fake();
116
+ const result = await tryListStudiosAsync(options);
117
+ expect(result.success && result.value.map((s) => s.placeName)).toEqual([
118
+ 'Place1',
119
+ 'Hub',
120
+ ]);
121
+ });
122
+ });
123
+ //# sourceMappingURL=roblox-studio-mcp.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"roblox-studio-mcp.test.js","sourceRoot":"","sources":["../../../src/roblox-mcp/roblox-studio-mcp.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC7D,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,mBAAmB,EACnB,QAAQ,GAET,MAAM,2BAA2B,CAAC;AAEnC,MAAM,OAAO,GAAG;IACd,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE;IAC/B,EAAE,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE;CAC7B,CAAC;AAEF,SAAS,IAAI,CAAC,UAAuB,GAAG,EAAE,CAAC,SAAS,EAAE,OAAO,GAAG,OAAO;IACrE,MAAM,MAAM,GAAG,mBAAmB,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE;QACpD,IAAI,MAAM,KAAK,YAAY,EAAE,CAAC;YAC5B,OAAO,EAAE,MAAM,EAAE,EAAE,eAAe,EAAE,YAAY,EAAE,YAAY,EAAE,EAAE,EAAE,EAAE,CAAC;QACzE,CAAC;QACD,IAAI,MAAM,EAAE,IAA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AM,MAAM,GAAG,MAAM,mBAAmB,CAAC,OAAO,CAAC,CAAC;QAElD,MAAM,CAAC,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC;YACrE,QAAQ;YACR,KAAK;SACN,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,39 @@
1
+ import type { SessionContext, SessionInfo } from '../../bridge/types.js';
2
+ import type { McpStdioClient } from '../mcp/mcp-stdio-client.js';
3
+ export declare const DATAMODEL_TYPES: Record<SessionContext, string>;
4
+ export declare class StudioNotFoundError extends Error {
5
+ }
6
+ export declare function cleanToolError(text: string): string;
7
+ export interface McpStudio {
8
+ studioId: string;
9
+ placeName: string;
10
+ }
11
+ export interface StudioWindow {
12
+ pid: number;
13
+ windowTitle: string;
14
+ startedAt?: number;
15
+ }
16
+ export interface MatchedStudio {
17
+ studioId: string;
18
+ placeName: string;
19
+ placeId?: number;
20
+ gameId?: number;
21
+ sessionId?: string;
22
+ instanceId?: string;
23
+ pid?: number;
24
+ }
25
+ export interface LuauRunResult {
26
+ success: boolean;
27
+ result?: string;
28
+ error?: string;
29
+ }
30
+ export declare function listMcpStudiosAsync(client: McpStdioClient): Promise<McpStudio[]>;
31
+ export declare function runLuauAsync(client: McpStdioClient, studioId: string, code: string, context?: SessionContext, timeoutMs?: number): Promise<LuauRunResult>;
32
+ export interface MatchStudiosOptions {
33
+ readPlaceIds?: boolean;
34
+ studios?: McpStudio[];
35
+ sessionPids?: Map<string, number>;
36
+ }
37
+ export declare function matchStudiosAsync(client: McpStdioClient, sessions?: SessionInfo[], windows?: StudioWindow[], options?: MatchStudiosOptions): Promise<MatchedStudio[]>;
38
+ export declare function resolveStudio(studios: MatchedStudio[], target?: string): MatchedStudio;
39
+ //# sourceMappingURL=studio-session.d.ts.map
@@ -0,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EAChC,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,aAAa,CAAC,CASxB;AAED,MAAM,WAAW,mBAAmB;IAClC,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,OAAO,CAAC,EAAE,SAAS,EAAE,CAAC;IACtB,WAAW,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC;AAED,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,cAAc,EACtB,QAAQ,GAAE,WAAW,EAAO,EAC5B,OAAO,GAAE,YAAY,EAAO,EAC5B,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,aAAa,EAAE,CAAC,CA8E1B;AAED,wBAAgB,aAAa,CAC3B,OAAO,EAAE,aAAa,EAAE,EACxB,MAAM,CAAC,EAAE,MAAM,GACd,aAAa,CA4Cf"}
@@ -0,0 +1,175 @@
1
+ import { matchProcessByUptime } from '../../process/studio-process-identity.js';
2
+ export const DATAMODEL_TYPES = {
3
+ edit: 'Edit',
4
+ client: 'Client',
5
+ server: 'Server',
6
+ };
7
+ export class StudioNotFoundError extends Error {
8
+ }
9
+ const ASSISTANT_FRAME = /^(?:sabuiltin_[^\s:]+|AssistantCommand):\d+: /;
10
+ export function cleanToolError(text) {
11
+ let cleaned = text;
12
+ while (ASSISTANT_FRAME.test(cleaned)) {
13
+ cleaned = cleaned.replace(ASSISTANT_FRAME, '');
14
+ }
15
+ return cleaned;
16
+ }
17
+ export async function listMcpStudiosAsync(client) {
18
+ const reply = await client.callToolAsync('list_roblox_studios');
19
+ if (reply.isError) {
20
+ throw new Error(`Could not list Studios over MCP: ${reply.text}`);
21
+ }
22
+ let parsed;
23
+ try {
24
+ parsed = JSON.parse(reply.text);
25
+ }
26
+ catch {
27
+ throw new Error(`Unexpected Studio list from MCP: ${reply.text}`);
28
+ }
29
+ return (parsed.studios ?? [])
30
+ .filter((s) => typeof s.id === 'string')
31
+ .map((s) => ({
32
+ studioId: s.id,
33
+ placeName: typeof s.name === 'string' ? s.name : '',
34
+ }));
35
+ }
36
+ export async function runLuauAsync(client, studioId, code, context = 'edit', timeoutMs) {
37
+ const reply = await client.callToolAsync('execute_luau', { studio_id: studioId, datamodel_type: DATAMODEL_TYPES[context], code }, timeoutMs);
38
+ return reply.isError
39
+ ? { success: false, error: cleanToolError(reply.text) }
40
+ : { success: true, result: reply.text };
41
+ }
42
+ export async function matchStudiosAsync(client, sessions = [], windows = [], options = {}) {
43
+ const studios = options.studios ?? (await listMcpStudiosAsync(client));
44
+ const editSessions = sessions.filter((s) => s.context === 'edit');
45
+ const nameCount = (name) => studios.filter((s) => s.placeName === name).length;
46
+ const canTime = windows.some((w) => w.startedAt !== undefined);
47
+ const matched = await Promise.all(studios.map(async (studio) => {
48
+ const named = editSessions.filter((s) => s.placeName === studio.placeName);
49
+ const uniqueByName = named.length === 1 && nameCount(studio.placeName) === 1;
50
+ const wantProbe = canTime ||
51
+ (!uniqueByName && (named.length > 0 || options.readPlaceIds !== false));
52
+ return wantProbe
53
+ ? {
54
+ ...studio,
55
+ ...(await _probeAsync(client, studio.studioId, windows)),
56
+ }
57
+ : { ...studio };
58
+ }));
59
+ const claimed = new Set();
60
+ const assign = (studio, session) => {
61
+ claimed.add(session.sessionId);
62
+ studio.sessionId = session.sessionId;
63
+ studio.instanceId = session.instanceId;
64
+ studio.placeId ??= session.placeId;
65
+ studio.gameId ??= session.gameId;
66
+ };
67
+ const unclaimed = () => editSessions.filter((s) => !claimed.has(s.sessionId));
68
+ if (options.sessionPids) {
69
+ for (const studio of matched) {
70
+ if (studio.pid === undefined)
71
+ continue;
72
+ const byPid = unclaimed().filter((s) => options.sessionPids.get(s.instanceId) === studio.pid);
73
+ if (byPid.length === 1) {
74
+ assign(studio, byPid[0]);
75
+ }
76
+ }
77
+ }
78
+ for (const studio of matched) {
79
+ if (studio.sessionId)
80
+ continue;
81
+ const named = unclaimed().filter((s) => s.placeName === studio.placeName);
82
+ const unmatchedSameName = matched.filter((m) => !m.sessionId && m.placeName === studio.placeName).length;
83
+ if (named.length === 1 && unmatchedSameName === 1) {
84
+ assign(studio, named[0]);
85
+ }
86
+ }
87
+ for (const studio of matched) {
88
+ if (studio.sessionId || !studio.placeId)
89
+ continue;
90
+ const byId = unclaimed().filter((s) => s.placeId === studio.placeId);
91
+ if (byId.length === 1) {
92
+ assign(studio, byId[0]);
93
+ }
94
+ }
95
+ for (const studio of matched) {
96
+ if (studio.pid !== undefined || nameCount(studio.placeName) !== 1)
97
+ continue;
98
+ const window = windows.filter((w) => _windowShowsPlace(w.windowTitle, studio.placeName));
99
+ if (window.length === 1) {
100
+ studio.pid = window[0].pid;
101
+ }
102
+ }
103
+ return matched;
104
+ }
105
+ export function resolveStudio(studios, target) {
106
+ if (target === undefined) {
107
+ if (studios.length === 1) {
108
+ return studios[0];
109
+ }
110
+ throw new StudioNotFoundError(studios.length === 0
111
+ ? 'No Studio is connected to its MCP server'
112
+ : `${studios.length} Studios are open (${_describe(studios)}). Pick one with --target.`);
113
+ }
114
+ const exact = studios.filter((s) => s.studioId === target ||
115
+ s.sessionId === target ||
116
+ s.instanceId === target ||
117
+ String(s.pid) === target);
118
+ if (exact.length === 1) {
119
+ return exact[0];
120
+ }
121
+ const lowered = target.toLowerCase();
122
+ const loose = studios.filter((s) => s.studioId.startsWith(target) ||
123
+ s.sessionId?.startsWith(target) ||
124
+ s.instanceId?.startsWith(target) ||
125
+ s.placeName.toLowerCase() === lowered);
126
+ if (loose.length === 1) {
127
+ return loose[0];
128
+ }
129
+ throw new StudioNotFoundError(loose.length > 1
130
+ ? `'${target}' matches ${loose.length} Studios (${_describe(loose)}). Use a longer id.`
131
+ : `No Studio matches '${target}'. Open: ${_describe(studios) || 'none'}`);
132
+ }
133
+ const PROBE_LUAU = 'return tostring(os.clock()) .. "," .. tostring(game.PlaceId) .. "," .. tostring(game.GameId)';
134
+ async function _probeAsync(client, studioId, windows) {
135
+ for (const context of ['edit', 'server', 'client']) {
136
+ const sentAt = Date.now();
137
+ const run = await runLuauAsync(client, studioId, PROBE_LUAU, context);
138
+ const match = run.success
139
+ ? /^([\d.]+),(\d+),(\d+)$/.exec(run.result ?? '')
140
+ : null;
141
+ if (!match) {
142
+ if (run.success || !/not available/i.test(run.error ?? '')) {
143
+ return {};
144
+ }
145
+ continue;
146
+ }
147
+ const reading = {
148
+ uptimeSec: Number(match[1]),
149
+ observedAt: (sentAt + Date.now()) / 2,
150
+ };
151
+ const window = matchProcessByUptime(windows, reading);
152
+ return {
153
+ placeId: Number(match[2]),
154
+ gameId: Number(match[3]),
155
+ ...(window ? { pid: window.pid } : {}),
156
+ };
157
+ }
158
+ return {};
159
+ }
160
+ function _windowShowsPlace(title, placeName) {
161
+ if (!placeName) {
162
+ return false;
163
+ }
164
+ const shown = title.replace(/ - Roblox Studio$/, '');
165
+ return (shown === placeName ||
166
+ shown.endsWith(`\\${placeName}`) ||
167
+ shown.endsWith(`/${placeName}`) ||
168
+ shown.replace(/\.rbxlx?$/, '').endsWith(placeName));
169
+ }
170
+ function _describe(studios) {
171
+ return studios
172
+ .map((s) => `${s.sessionId ?? s.studioId} '${s.placeName}'`)
173
+ .join(', ');
174
+ }
175
+ //# sourceMappingURL=studio-session.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"studio-session.js","sourceRoot":"","sources":["../../../../src/roblox-mcp/studio/studio-session.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAEhF,MAAM,CAAC,MAAM,eAAe,GAAmC;IAC7D,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;CACjB,CAAC;AAEF,MAAM,OAAO,mBAAoB,SAAQ,KAAK;CAAG;AAEjD,MAAM,eAAe,GAAG,+CAA+C,CAAC;AAExE,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,IAAI,OAAO,GAAG,IAAI,CAAC;IACnB,OAAO,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE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,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,QAAQ,KAAK,CAAC,CAAC,SAAS,GAAG,CAAC;SAC3D,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=studio-session.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"studio-session.test.d.ts","sourceRoot":"","sources":["../../../../src/roblox-mcp/studio/studio-session.test.ts"],"names":[],"mappings":""}