@chrrxs/robloxstudio-mcp-inspector 3.4.2 → 3.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +332 -105
- package/package.json +1 -1
- package/studio-plugin/MCPInspectorPlugin.rbxmx +310 -70
package/package.json
CHANGED
|
@@ -678,6 +678,12 @@ local DEFAULT_MCP_URL = "http://localhost:58741"
|
|
|
678
678
|
local mcpUrl = DEFAULT_MCP_URL
|
|
679
679
|
local BROKER_NAME = "__MCPClientBroker"
|
|
680
680
|
local BROKER_OWNER_ATTRIBUTE = "__MCPBrokerOwner"
|
|
681
|
+
-- Some games rename every remote in ReplicatedStorage on the client (Pet
|
|
682
|
+
-- Simulator X renames each one to its class name), so the client also finds
|
|
683
|
+
-- the bridge channels by this attribute, which a rename leaves in place.
|
|
684
|
+
local CHANNEL_ATTRIBUTE = "__MCPChannel"
|
|
685
|
+
local CHANNEL_WAIT_SECONDS = 10
|
|
686
|
+
local CHANNEL_POLL_SECONDS = 0.1
|
|
681
687
|
local CLIENT_IDENTITY_KIND = "identity"
|
|
682
688
|
-- A normal capture needs at most 15s sampling + 5s waiting for profiler data.
|
|
683
689
|
-- Leave room for processing, then return a diagnostic before the outer 30s wait.
|
|
@@ -1054,6 +1060,35 @@ local function handleClientInvoke(payload)
|
|
|
1054
1060
|
end
|
|
1055
1061
|
return result
|
|
1056
1062
|
end
|
|
1063
|
+
local function findChannel(name)
|
|
1064
|
+
local named = ReplicatedStorage:FindFirstChild(name)
|
|
1065
|
+
if named ~= nil then
|
|
1066
|
+
return named
|
|
1067
|
+
end
|
|
1068
|
+
local _exp = ReplicatedStorage:GetChildren()
|
|
1069
|
+
-- ▼ ReadonlyArray.find ▼
|
|
1070
|
+
local _callback = function(child)
|
|
1071
|
+
return child:GetAttribute(CHANNEL_ATTRIBUTE) == name
|
|
1072
|
+
end
|
|
1073
|
+
local _result
|
|
1074
|
+
for _i, _v in _exp do
|
|
1075
|
+
if _callback(_v, _i - 1, _exp) == true then
|
|
1076
|
+
_result = _v
|
|
1077
|
+
break
|
|
1078
|
+
end
|
|
1079
|
+
end
|
|
1080
|
+
-- ▲ ReadonlyArray.find ▲
|
|
1081
|
+
return _result
|
|
1082
|
+
end
|
|
1083
|
+
local function waitForChannel(name)
|
|
1084
|
+
local deadline = os.clock() + CHANNEL_WAIT_SECONDS
|
|
1085
|
+
local channel = findChannel(name)
|
|
1086
|
+
while channel == nil and os.clock() < deadline do
|
|
1087
|
+
task.wait(CHANNEL_POLL_SECONDS)
|
|
1088
|
+
channel = findChannel(name)
|
|
1089
|
+
end
|
|
1090
|
+
return channel
|
|
1091
|
+
end
|
|
1057
1092
|
local function startClientHeartbeat(attempt)
|
|
1058
1093
|
if attempt == nil then
|
|
1059
1094
|
attempt = 0
|
|
@@ -1061,7 +1096,7 @@ local function startClientHeartbeat(attempt)
|
|
|
1061
1096
|
if clientHeartbeatStarted or PeerRole.detect() ~= "client" or not RunService:IsRunning() then
|
|
1062
1097
|
return nil
|
|
1063
1098
|
end
|
|
1064
|
-
local event =
|
|
1099
|
+
local event = waitForChannel(HEARTBEAT_NAME)
|
|
1065
1100
|
if not event or not event:IsA("RemoteEvent") then
|
|
1066
1101
|
-- An older server broker has no heartbeat channel; requests still work.
|
|
1067
1102
|
if RunService:IsRunning() and attempt < 5 then
|
|
@@ -1126,7 +1161,7 @@ local function setupClientBroker(attempt)
|
|
|
1126
1161
|
if PeerRole.detect() ~= "client" then
|
|
1127
1162
|
return nil
|
|
1128
1163
|
end
|
|
1129
|
-
local rf =
|
|
1164
|
+
local rf = waitForChannel(BROKER_NAME)
|
|
1130
1165
|
if not rf or not rf:IsA("RemoteFunction") then
|
|
1131
1166
|
if attempt == 0 then
|
|
1132
1167
|
warn(`[robloxstudio-mcp] client: {BROKER_NAME} not found; retrying`)
|
|
@@ -1869,6 +1904,7 @@ local function setupHeartbeatChannel()
|
|
|
1869
1904
|
end
|
|
1870
1905
|
local event = existing or Instance.new("RemoteEvent")
|
|
1871
1906
|
event.Name = HEARTBEAT_NAME
|
|
1907
|
+
event:SetAttribute(CHANNEL_ATTRIBUTE, HEARTBEAT_NAME)
|
|
1872
1908
|
event.OnServerEvent:Connect(function(player, payload)
|
|
1873
1909
|
local _player = player
|
|
1874
1910
|
local entry = proxyByPlayer[_player]
|
|
@@ -1930,6 +1966,7 @@ local function setupServerBroker()
|
|
|
1930
1966
|
end
|
|
1931
1967
|
rf.Name = BROKER_NAME
|
|
1932
1968
|
rf:SetAttribute(BROKER_OWNER_ATTRIBUTE, PluginSession.peerId)
|
|
1969
|
+
rf:SetAttribute(CHANNEL_ATTRIBUTE, BROKER_NAME)
|
|
1933
1970
|
rf.OnServerInvoke = function(player, payload)
|
|
1934
1971
|
local identity = parseClientIdentity(payload)
|
|
1935
1972
|
if identity == nil then
|
|
@@ -2523,9 +2560,9 @@ local function computeBridgeStamp()
|
|
|
2523
2560
|
for i = 1, #combined do
|
|
2524
2561
|
h = (h * 33 + (string.byte(combined, i))) % 2147483647
|
|
2525
2562
|
end
|
|
2526
|
-
-- "3.4.
|
|
2563
|
+
-- "3.4.4" is replaced with the package version at package time
|
|
2527
2564
|
-- (scripts/build-plugin.mjs injectVersion), so a release bump also restamps.
|
|
2528
|
-
return `{tostring(h)}-3.4.
|
|
2565
|
+
return `{tostring(h)}-3.4.4`
|
|
2529
2566
|
end
|
|
2530
2567
|
local BRIDGE_STAMP = computeBridgeStamp()
|
|
2531
2568
|
local function setSource(scriptInst, source)
|
|
@@ -4808,6 +4845,42 @@ local MOUSE_TYPE_MAP = {
|
|
|
4808
4845
|
Middle = Enum.UserInputType.MouseButton3,
|
|
4809
4846
|
}
|
|
4810
4847
|
local NO_MOUSE_ERROR = "This client has no mouse (touch device emulation is active), so cursor movement never reaches the game. " .. "Stop it with set_device_simulator stopSimulation=true, then retry."
|
|
4848
|
+
local RELEASE_RETRY_NOTE = " The release will be re-sent when the window renders again."
|
|
4849
|
+
-- Releases that may not have reached the engine (sent while the window wasn't
|
|
4850
|
+
-- rendering, or the up event threw). Re-sent on the next stale→fresh frame.
|
|
4851
|
+
-- Mouse entries keep the position the release should be sent at.
|
|
4852
|
+
local pendingKeyReleases = {}
|
|
4853
|
+
local pendingButtonReleases = {}
|
|
4854
|
+
local function flushPendingReleases()
|
|
4855
|
+
local vi = cachedVI
|
|
4856
|
+
if vi then
|
|
4857
|
+
for keyCode in pendingKeyReleases do
|
|
4858
|
+
pcall(function()
|
|
4859
|
+
return vi:SendKey(false, keyCode)
|
|
4860
|
+
end)
|
|
4861
|
+
end
|
|
4862
|
+
for inputType, pos in pendingButtonReleases do
|
|
4863
|
+
pcall(function()
|
|
4864
|
+
return vi:SendMouseButton(pos, inputType, false)
|
|
4865
|
+
end)
|
|
4866
|
+
end
|
|
4867
|
+
end
|
|
4868
|
+
table.clear(pendingKeyReleases)
|
|
4869
|
+
table.clear(pendingButtonReleases)
|
|
4870
|
+
end
|
|
4871
|
+
RenderMonitor.onRenderResumed(flushPendingReleases)
|
|
4872
|
+
local MOUSE_ACTIONS = {
|
|
4873
|
+
["click"] = true,
|
|
4874
|
+
["mouseDown"] = true,
|
|
4875
|
+
["mouseUp"] = true,
|
|
4876
|
+
["move"] = true,
|
|
4877
|
+
["scroll"] = true,
|
|
4878
|
+
}
|
|
4879
|
+
local KEY_ACTIONS = {
|
|
4880
|
+
["press"] = true,
|
|
4881
|
+
["release"] = true,
|
|
4882
|
+
["tap"] = true,
|
|
4883
|
+
}
|
|
4811
4884
|
local function simulateMouseInput(requestData)
|
|
4812
4885
|
local action = requestData.action
|
|
4813
4886
|
local x = requestData.x
|
|
@@ -4828,6 +4901,11 @@ local function simulateMouseInput(requestData)
|
|
|
4828
4901
|
error = "x and y are required",
|
|
4829
4902
|
}
|
|
4830
4903
|
end
|
|
4904
|
+
if not (MOUSE_ACTIONS[action] ~= nil) then
|
|
4905
|
+
return {
|
|
4906
|
+
error = `Unsupported action "{action}". Use click, mouseDown, mouseUp, move, or scroll.`,
|
|
4907
|
+
}
|
|
4908
|
+
end
|
|
4831
4909
|
if action == "scroll" and (not (type(wheel) == "number") or wheel == 0) then
|
|
4832
4910
|
return {
|
|
4833
4911
|
error = "wheel must be a non-zero number for scroll",
|
|
@@ -4835,8 +4913,9 @@ local function simulateMouseInput(requestData)
|
|
|
4835
4913
|
end
|
|
4836
4914
|
-- Input is silently dropped by the engine when the window isn't rendering
|
|
4837
4915
|
-- (e.g. minimized). Surface that instead of returning a false success.
|
|
4916
|
+
-- mouseUp is exempt: a held button must always be releasable.
|
|
4838
4917
|
local notRendering = RenderMonitor.notRenderingReason()
|
|
4839
|
-
if notRendering ~= nil then
|
|
4918
|
+
if notRendering ~= nil and action ~= "mouseUp" then
|
|
4840
4919
|
return {
|
|
4841
4920
|
error = notRendering,
|
|
4842
4921
|
}
|
|
@@ -4854,37 +4933,80 @@ local function simulateMouseInput(requestData)
|
|
|
4854
4933
|
end
|
|
4855
4934
|
local inputType = MOUSE_TYPE_MAP[button] or Enum.UserInputType.MouseButton1
|
|
4856
4935
|
local pos = Vector2.new(x, y)
|
|
4936
|
+
local result = {
|
|
4937
|
+
success = true,
|
|
4938
|
+
action = action,
|
|
4939
|
+
x = x,
|
|
4940
|
+
y = y,
|
|
4941
|
+
}
|
|
4942
|
+
if action == "scroll" then
|
|
4943
|
+
result.wheel = wheel
|
|
4944
|
+
elseif action ~= "move" then
|
|
4945
|
+
result.button = button
|
|
4946
|
+
end
|
|
4947
|
+
if action == "mouseUp" then
|
|
4948
|
+
local ok, err = pcall(function()
|
|
4949
|
+
return vi:SendMouseButton(pos, inputType, false)
|
|
4950
|
+
end)
|
|
4951
|
+
if notRendering ~= nil then
|
|
4952
|
+
-- The engine may drop this while not rendering; never report it as delivered.
|
|
4953
|
+
pendingButtonReleases[inputType] = pos
|
|
4954
|
+
result.deliveryConfirmed = false
|
|
4955
|
+
result.warning = if ok then notRendering .. RELEASE_RETRY_NOTE else `{notRendering} Sending the release failed: {err}.{RELEASE_RETRY_NOTE}`
|
|
4956
|
+
return result
|
|
4957
|
+
end
|
|
4958
|
+
if not ok then
|
|
4959
|
+
pendingButtonReleases[inputType] = pos
|
|
4960
|
+
return {
|
|
4961
|
+
error = `Failed to simulate mouse input: {err}. The {button} button may still be held.`,
|
|
4962
|
+
}
|
|
4963
|
+
end
|
|
4964
|
+
pendingButtonReleases[inputType] = nil
|
|
4965
|
+
return result
|
|
4966
|
+
end
|
|
4967
|
+
if action == "click" or action == "mouseDown" then
|
|
4968
|
+
local downOk, downErr = pcall(function()
|
|
4969
|
+
return vi:SendMouseButton(pos, inputType, true)
|
|
4970
|
+
end)
|
|
4971
|
+
if not downOk then
|
|
4972
|
+
return {
|
|
4973
|
+
error = `Failed to simulate mouse input: {downErr}`,
|
|
4974
|
+
}
|
|
4975
|
+
end
|
|
4976
|
+
pendingButtonReleases[inputType] = nil
|
|
4977
|
+
if action == "mouseDown" then
|
|
4978
|
+
return result
|
|
4979
|
+
end
|
|
4980
|
+
-- Down landed, so the up must run even if something fails in between.
|
|
4981
|
+
task.wait(0.05)
|
|
4982
|
+
local upOk, upErr = pcall(function()
|
|
4983
|
+
return vi:SendMouseButton(pos, inputType, false)
|
|
4984
|
+
end)
|
|
4985
|
+
if not upOk then
|
|
4986
|
+
pendingButtonReleases[inputType] = pos
|
|
4987
|
+
return {
|
|
4988
|
+
error = `Click pressed {button} but releasing it failed: {upErr}. ` .. `The {button} button may still be held; call simulate_mouse_input with action="mouseUp" to release it.`,
|
|
4989
|
+
}
|
|
4990
|
+
end
|
|
4991
|
+
local staleAfter = RenderMonitor.notRenderingReason()
|
|
4992
|
+
if staleAfter ~= nil then
|
|
4993
|
+
-- The window stopped rendering during the hold; the up may have been dropped.
|
|
4994
|
+
pendingButtonReleases[inputType] = pos
|
|
4995
|
+
result.deliveryConfirmed = false
|
|
4996
|
+
result.warning = staleAfter .. RELEASE_RETRY_NOTE
|
|
4997
|
+
end
|
|
4998
|
+
return result
|
|
4999
|
+
end
|
|
4857
5000
|
local success, err = pcall(function()
|
|
4858
|
-
if action == "
|
|
4859
|
-
vi:SendMouseButton(pos, inputType, true)
|
|
4860
|
-
task.wait(0.05)
|
|
4861
|
-
vi:SendMouseButton(pos, inputType, false)
|
|
4862
|
-
elseif action == "mouseDown" then
|
|
4863
|
-
vi:SendMouseButton(pos, inputType, true)
|
|
4864
|
-
elseif action == "mouseUp" then
|
|
4865
|
-
vi:SendMouseButton(pos, inputType, false)
|
|
4866
|
-
elseif action == "move" then
|
|
5001
|
+
if action == "move" then
|
|
4867
5002
|
vi:SendMousePosition(pos)
|
|
4868
|
-
|
|
5003
|
+
else
|
|
4869
5004
|
vi:SendPointerAction(pos, {
|
|
4870
5005
|
Wheel = wheel,
|
|
4871
5006
|
})
|
|
4872
|
-
else
|
|
4873
|
-
error(`Unsupported action "{action}". Use click, mouseDown, mouseUp, move, or scroll.`)
|
|
4874
5007
|
end
|
|
4875
5008
|
end)
|
|
4876
5009
|
if success then
|
|
4877
|
-
local result = {
|
|
4878
|
-
success = true,
|
|
4879
|
-
action = action,
|
|
4880
|
-
x = x,
|
|
4881
|
-
y = y,
|
|
4882
|
-
}
|
|
4883
|
-
if action == "scroll" then
|
|
4884
|
-
result.wheel = wheel
|
|
4885
|
-
elseif action ~= "move" then
|
|
4886
|
-
result.button = button
|
|
4887
|
-
end
|
|
4888
5010
|
return result
|
|
4889
5011
|
end
|
|
4890
5012
|
return {
|
|
@@ -4892,8 +5014,45 @@ local function simulateMouseInput(requestData)
|
|
|
4892
5014
|
}
|
|
4893
5015
|
end
|
|
4894
5016
|
local function simulateKeyboardInput(requestData)
|
|
5017
|
+
local text = requestData.text
|
|
5018
|
+
local keyCodeName = requestData.keyCode
|
|
5019
|
+
local _condition = (requestData.action)
|
|
5020
|
+
if _condition == nil then
|
|
5021
|
+
_condition = "tap"
|
|
5022
|
+
end
|
|
5023
|
+
local action = _condition
|
|
5024
|
+
local _condition_1 = (requestData.duration)
|
|
5025
|
+
if _condition_1 == nil then
|
|
5026
|
+
_condition_1 = 0.1
|
|
5027
|
+
end
|
|
5028
|
+
local duration = _condition_1
|
|
5029
|
+
-- Validate before the render gate so bad arguments report themselves.
|
|
5030
|
+
local keyCode
|
|
5031
|
+
if text == nil then
|
|
5032
|
+
if not (keyCodeName ~= "" and keyCodeName) then
|
|
5033
|
+
return {
|
|
5034
|
+
error = "keyCode (or text) is required",
|
|
5035
|
+
}
|
|
5036
|
+
end
|
|
5037
|
+
local enumOk, found = pcall(function()
|
|
5038
|
+
return (Enum.KeyCode)[keyCodeName]
|
|
5039
|
+
end)
|
|
5040
|
+
if not enumOk or not found then
|
|
5041
|
+
return {
|
|
5042
|
+
error = `Unknown keyCode: {keyCodeName}. Use Enum.KeyCode names like "W", "Space", "E", "LeftShift", etc.`,
|
|
5043
|
+
}
|
|
5044
|
+
end
|
|
5045
|
+
keyCode = found
|
|
5046
|
+
if not (KEY_ACTIONS[action] ~= nil) then
|
|
5047
|
+
return {
|
|
5048
|
+
error = `Unknown action: {action}. Use press, release, or tap.`,
|
|
5049
|
+
}
|
|
5050
|
+
end
|
|
5051
|
+
end
|
|
5052
|
+
-- release is exempt: a held key must always be releasable.
|
|
4895
5053
|
local notRendering = RenderMonitor.notRenderingReason()
|
|
4896
|
-
|
|
5054
|
+
local isRelease = text == nil and action == "release"
|
|
5055
|
+
if notRendering ~= nil and not isRelease then
|
|
4897
5056
|
return {
|
|
4898
5057
|
error = notRendering,
|
|
4899
5058
|
}
|
|
@@ -4905,7 +5064,6 @@ local function simulateKeyboardInput(requestData)
|
|
|
4905
5064
|
}
|
|
4906
5065
|
end
|
|
4907
5066
|
-- Text mode: type a string into the focused TextBox.
|
|
4908
|
-
local text = requestData.text
|
|
4909
5067
|
if text ~= nil then
|
|
4910
5068
|
local ok, err = pcall(function()
|
|
4911
5069
|
return vi:SendTextInput(text)
|
|
@@ -4920,53 +5078,63 @@ local function simulateKeyboardInput(requestData)
|
|
|
4920
5078
|
error = `Failed to send text input: {err}`,
|
|
4921
5079
|
}
|
|
4922
5080
|
end
|
|
4923
|
-
local
|
|
4924
|
-
|
|
4925
|
-
|
|
4926
|
-
|
|
4927
|
-
|
|
4928
|
-
|
|
4929
|
-
|
|
4930
|
-
|
|
4931
|
-
|
|
4932
|
-
|
|
4933
|
-
|
|
4934
|
-
|
|
4935
|
-
|
|
4936
|
-
|
|
5081
|
+
local key = keyCode
|
|
5082
|
+
local result = {
|
|
5083
|
+
success = true,
|
|
5084
|
+
keyCode = keyCodeName,
|
|
5085
|
+
action = action,
|
|
5086
|
+
}
|
|
5087
|
+
if action == "release" then
|
|
5088
|
+
local ok, err = pcall(function()
|
|
5089
|
+
return vi:SendKey(false, key)
|
|
5090
|
+
end)
|
|
5091
|
+
if notRendering ~= nil then
|
|
5092
|
+
-- The engine may drop this while not rendering; never report it as delivered.
|
|
5093
|
+
pendingKeyReleases[key] = true
|
|
5094
|
+
result.deliveryConfirmed = false
|
|
5095
|
+
result.warning = if ok then notRendering .. RELEASE_RETRY_NOTE else `{notRendering} Sending the release failed: {err}.{RELEASE_RETRY_NOTE}`
|
|
5096
|
+
return result
|
|
5097
|
+
end
|
|
5098
|
+
if not ok then
|
|
5099
|
+
pendingKeyReleases[key] = true
|
|
5100
|
+
return {
|
|
5101
|
+
error = `Failed to simulate keyboard input: {err}. Key {keyCodeName} may still be held.`,
|
|
5102
|
+
}
|
|
5103
|
+
end
|
|
5104
|
+
pendingKeyReleases[key] = nil
|
|
5105
|
+
return result
|
|
4937
5106
|
end
|
|
4938
|
-
local
|
|
4939
|
-
|
|
4940
|
-
return (Enum.KeyCode)[keyCodeName]
|
|
5107
|
+
local downOk, downErr = pcall(function()
|
|
5108
|
+
return vi:SendKey(true, key)
|
|
4941
5109
|
end)
|
|
4942
|
-
if not
|
|
5110
|
+
if not downOk then
|
|
4943
5111
|
return {
|
|
4944
|
-
error = `
|
|
5112
|
+
error = `Failed to simulate keyboard input: {downErr}`,
|
|
4945
5113
|
}
|
|
4946
5114
|
end
|
|
4947
|
-
|
|
4948
|
-
|
|
4949
|
-
|
|
4950
|
-
|
|
4951
|
-
|
|
4952
|
-
|
|
4953
|
-
|
|
4954
|
-
|
|
4955
|
-
vi:SendKey(false, keyCode)
|
|
4956
|
-
else
|
|
4957
|
-
error(`Unknown action: {action}`)
|
|
4958
|
-
end
|
|
5115
|
+
pendingKeyReleases[key] = nil
|
|
5116
|
+
if action == "press" then
|
|
5117
|
+
return result
|
|
5118
|
+
end
|
|
5119
|
+
-- tap: the down landed, so the up must run even if something fails in between.
|
|
5120
|
+
task.wait(duration)
|
|
5121
|
+
local upOk, upErr = pcall(function()
|
|
5122
|
+
return vi:SendKey(false, key)
|
|
4959
5123
|
end)
|
|
4960
|
-
if
|
|
5124
|
+
if not upOk then
|
|
5125
|
+
pendingKeyReleases[key] = true
|
|
4961
5126
|
return {
|
|
4962
|
-
|
|
4963
|
-
keyCode = keyCodeName,
|
|
4964
|
-
action = action,
|
|
5127
|
+
error = `Tap pressed {keyCodeName} but releasing it failed: {upErr}. ` .. `Key {keyCodeName} may still be held; call simulate_keyboard_input with action="release" to release it.`,
|
|
4965
5128
|
}
|
|
4966
5129
|
end
|
|
4967
|
-
|
|
4968
|
-
|
|
4969
|
-
|
|
5130
|
+
local staleAfter = RenderMonitor.notRenderingReason()
|
|
5131
|
+
if staleAfter ~= nil then
|
|
5132
|
+
-- The window stopped rendering during the hold; the up may have been dropped.
|
|
5133
|
+
pendingKeyReleases[key] = true
|
|
5134
|
+
result.deliveryConfirmed = false
|
|
5135
|
+
result.warning = staleAfter .. RELEASE_RETRY_NOTE
|
|
5136
|
+
end
|
|
5137
|
+
return result
|
|
4970
5138
|
end
|
|
4971
5139
|
return {
|
|
4972
5140
|
simulateMouseInput = simulateMouseInput,
|
|
@@ -9197,7 +9365,13 @@ local StopPlayMonitor = TS.import(script, script.Parent.Parent, "StopPlayMonitor
|
|
|
9197
9365
|
local PluginSession = TS.import(script, script.Parent.Parent, "PluginSession")
|
|
9198
9366
|
local PeerRole = TS.import(script, script.Parent.Parent, "PeerRole")
|
|
9199
9367
|
local StudioTestService = game:GetService("StudioTestService")
|
|
9368
|
+
local TestService = game:GetService("TestService")
|
|
9200
9369
|
local testRunning = false
|
|
9370
|
+
-- Outcome of the latest solo Execute*Async call. MCP polls it so a start Studio
|
|
9371
|
+
-- refuses is reported with Studio's own error instead of a readiness timeout.
|
|
9372
|
+
local soloState = {
|
|
9373
|
+
phase = "idle",
|
|
9374
|
+
}
|
|
9201
9375
|
local multiplayerState = {
|
|
9202
9376
|
phase = "idle",
|
|
9203
9377
|
}
|
|
@@ -9238,6 +9412,30 @@ local function cloneMultiplayerState()
|
|
|
9238
9412
|
error = multiplayerState.error,
|
|
9239
9413
|
}
|
|
9240
9414
|
end
|
|
9415
|
+
local function cloneSoloState()
|
|
9416
|
+
return {
|
|
9417
|
+
phase = soloState.phase,
|
|
9418
|
+
testId = soloState.testId,
|
|
9419
|
+
mode = soloState.mode,
|
|
9420
|
+
startedAt = soloState.startedAt,
|
|
9421
|
+
completedAt = soloState.completedAt,
|
|
9422
|
+
error = soloState.error,
|
|
9423
|
+
}
|
|
9424
|
+
end
|
|
9425
|
+
-- With ExecuteWithStudioRun and NumberOfPlayers > 0, Run opens a separate server
|
|
9426
|
+
-- and NumberOfPlayers client windows instead of a solo run session.
|
|
9427
|
+
local function runModeClientCount()
|
|
9428
|
+
local ok, settings = pcall(function()
|
|
9429
|
+
return {
|
|
9430
|
+
executeWithStudioRun = TestService.ExecuteWithStudioRun,
|
|
9431
|
+
numberOfPlayers = TestService.NumberOfPlayers,
|
|
9432
|
+
}
|
|
9433
|
+
end)
|
|
9434
|
+
if not ok or not settings.executeWithStudioRun or settings.numberOfPlayers <= 0 then
|
|
9435
|
+
return nil
|
|
9436
|
+
end
|
|
9437
|
+
return settings.numberOfPlayers
|
|
9438
|
+
end
|
|
9241
9439
|
local function normalizeNumPlayers(value)
|
|
9242
9440
|
local _value = value
|
|
9243
9441
|
if not (type(_value) == "number") then
|
|
@@ -9262,6 +9460,17 @@ local function startPlaytest(requestData)
|
|
|
9262
9460
|
error = "start_playtest is single-player only. Use multiplayer_test_start for multi-client StudioTestService sessions.",
|
|
9263
9461
|
}
|
|
9264
9462
|
end
|
|
9463
|
+
if mode == "run" then
|
|
9464
|
+
local clientCount = runModeClientCount()
|
|
9465
|
+
if clientCount ~= nil then
|
|
9466
|
+
return {
|
|
9467
|
+
success = false,
|
|
9468
|
+
error = "run_opens_multiplayer_session",
|
|
9469
|
+
message = `TestService.ExecuteWithStudioRun is true and TestService.NumberOfPlayers is {clientCount}, ` .. `so Run would open a separate server and {clientCount} client window(s) that solo_playtest cannot track or stop. ` .. "Ending that session by hand can leave Studio refusing new tests until the place is reopened. " .. 'For a multi-client test use multiplayer_playtest action="start"; for a solo Run set ' .. "TestService.NumberOfPlayers to 0 or TestService.ExecuteWithStudioRun to false.",
|
|
9470
|
+
numberOfPlayers = clientCount,
|
|
9471
|
+
}
|
|
9472
|
+
end
|
|
9473
|
+
end
|
|
9265
9474
|
-- Peer teardown and ExecutePlayModeAsync completion can precede native edit
|
|
9266
9475
|
-- readiness. Do not acknowledge a new start that the engine cannot execute.
|
|
9267
9476
|
if not StudioTestService.EditModeActive then
|
|
@@ -9288,6 +9497,13 @@ local function startPlaytest(requestData)
|
|
|
9288
9497
|
end
|
|
9289
9498
|
testRunning = true
|
|
9290
9499
|
local preparedTest = PluginSession.prepareSoloTest()
|
|
9500
|
+
local testId = HttpService:GenerateGUID(false)
|
|
9501
|
+
soloState = {
|
|
9502
|
+
phase = "running",
|
|
9503
|
+
testId = testId,
|
|
9504
|
+
mode = mode,
|
|
9505
|
+
startedAt = tick(),
|
|
9506
|
+
}
|
|
9291
9507
|
task.spawn(function()
|
|
9292
9508
|
local ok, result = pcall(function()
|
|
9293
9509
|
if mode == "play" then
|
|
@@ -9299,11 +9515,17 @@ local function startPlaytest(requestData)
|
|
|
9299
9515
|
if not ok then
|
|
9300
9516
|
warn(`[robloxstudio-mcp] Playtest ended with error: {result}`)
|
|
9301
9517
|
end
|
|
9518
|
+
if soloState.testId == testId then
|
|
9519
|
+
soloState.completedAt = tick()
|
|
9520
|
+
soloState.phase = if ok then "completed" else "failed"
|
|
9521
|
+
soloState.error = if ok then nil else tostring(result)
|
|
9522
|
+
end
|
|
9302
9523
|
testRunning = false
|
|
9303
9524
|
end)
|
|
9304
9525
|
local response = {
|
|
9305
9526
|
success = true,
|
|
9306
9527
|
message = `Playtest started in {mode} mode.`,
|
|
9528
|
+
testId = testId,
|
|
9307
9529
|
}
|
|
9308
9530
|
return response
|
|
9309
9531
|
end
|
|
@@ -9453,6 +9675,7 @@ local function multiplayerTestState(_requestData)
|
|
|
9453
9675
|
}
|
|
9454
9676
|
if peer == "edit" then
|
|
9455
9677
|
response.session = cloneMultiplayerState()
|
|
9678
|
+
response.soloSession = cloneSoloState()
|
|
9456
9679
|
return response
|
|
9457
9680
|
end
|
|
9458
9681
|
local argsOk, args = pcall(function()
|
|
@@ -11506,6 +11729,14 @@ local connected = false
|
|
|
11506
11729
|
-- gap only happens when minimized/suspended, so 1s cleanly avoids false
|
|
11507
11730
|
-- positives from ordinary frame hitches while still catching the real case.
|
|
11508
11731
|
local STALE_THRESHOLD = 1.0
|
|
11732
|
+
-- Run on the first rendered frame after a stale gap. Input sent while the
|
|
11733
|
+
-- window wasn't rendering may never have reached the engine, so callers use
|
|
11734
|
+
-- this to re-send cleanup (e.g. key releases) once it can land.
|
|
11735
|
+
local resumeCallbacks = {}
|
|
11736
|
+
local function onRenderResumed(callback)
|
|
11737
|
+
local _callback = callback
|
|
11738
|
+
table.insert(resumeCallbacks, _callback)
|
|
11739
|
+
end
|
|
11509
11740
|
local function start()
|
|
11510
11741
|
if connected then
|
|
11511
11742
|
return nil
|
|
@@ -11515,7 +11746,15 @@ local function start()
|
|
|
11515
11746
|
-- (connected stays false → notRenderingReason() returns undefined there).
|
|
11516
11747
|
local ok = pcall(function()
|
|
11517
11748
|
RunService.RenderStepped:Connect(function()
|
|
11518
|
-
|
|
11749
|
+
local now = tick()
|
|
11750
|
+
-- One compare per frame; callbacks only fire on the stale→fresh edge.
|
|
11751
|
+
local resumed = now - lastFrame > STALE_THRESHOLD
|
|
11752
|
+
lastFrame = now
|
|
11753
|
+
if resumed then
|
|
11754
|
+
for _, callback in resumeCallbacks do
|
|
11755
|
+
task.spawn(callback)
|
|
11756
|
+
end
|
|
11757
|
+
end
|
|
11519
11758
|
end)
|
|
11520
11759
|
end)
|
|
11521
11760
|
if ok then
|
|
@@ -11544,6 +11783,7 @@ local function notRenderingReason()
|
|
|
11544
11783
|
return nil
|
|
11545
11784
|
end
|
|
11546
11785
|
return {
|
|
11786
|
+
onRenderResumed = onRenderResumed,
|
|
11547
11787
|
start = start,
|
|
11548
11788
|
secondsSinceFrame = secondsSinceFrame,
|
|
11549
11789
|
notRenderingReason = notRenderingReason,
|
|
@@ -13287,7 +13527,7 @@ return {
|
|
|
13287
13527
|
<Properties>
|
|
13288
13528
|
<string name="Name">State</string>
|
|
13289
13529
|
<string name="Source"><![CDATA[-- Compiled with roblox-ts v3.0.0
|
|
13290
|
-
local CURRENT_VERSION = "3.4.
|
|
13530
|
+
local CURRENT_VERSION = "3.4.4"
|
|
13291
13531
|
local PLUGIN_VARIANT = "inspector"
|
|
13292
13532
|
local BASE_PORT = 58741
|
|
13293
13533
|
local SENSITIVE_DIAGNOSTIC_TERMS = { "token", "authorization", "bearer", "password", "cookie", "secret" }
|