dominus-cli 2.1.0 → 2.1.1
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/CHANGELOG.md +24 -4
- package/README.md +12 -14
- package/dist/install-plugin.js +58 -13
- package/dist/install-plugin.js.map +1 -1
- package/dist/mcp.js +13 -121
- package/dist/mcp.js.map +1 -1
- package/docs/DOMINUS_2_PLAN.md +4 -4
- package/package.json +5 -3
- package/plugin/Dominus.rbxmx +3674 -0
- package/plugin/src/BridgeConfig.lua +2 -0
- package/plugin/src/ValueCodec.lua +5 -4
- package/plugin/src/WsClient.lua +13 -0
- package/plugin/src/init.server.lua +35 -22
- package/plugin/Dominus.rbxm +0 -0
|
@@ -51,12 +51,13 @@ local function decodeEnum(current, value)
|
|
|
51
51
|
if type(value) ~= "string" then
|
|
52
52
|
error("Enum value must be a string")
|
|
53
53
|
end
|
|
54
|
-
local enumName = tostring(current.EnumType):match("Enum%.(.+)")
|
|
55
54
|
local itemName = value:match("Enum%.[^.]+%.(.+)") or value
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
for _, item in current.EnumType:GetEnumItems() do
|
|
56
|
+
if item.Name == itemName then
|
|
57
|
+
return item
|
|
58
|
+
end
|
|
58
59
|
end
|
|
59
|
-
|
|
60
|
+
error("Invalid enum value " .. value .. " for " .. tostring(current.EnumType))
|
|
60
61
|
end
|
|
61
62
|
|
|
62
63
|
function ValueCodec.decodeForCurrent(current, value)
|
package/plugin/src/WsClient.lua
CHANGED
|
@@ -4,6 +4,7 @@ local WsClient = {}
|
|
|
4
4
|
|
|
5
5
|
local currentConnection = nil
|
|
6
6
|
local currentSignals = {}
|
|
7
|
+
local currentCancel = nil
|
|
7
8
|
local generation = 0
|
|
8
9
|
|
|
9
10
|
local function disconnectSignals()
|
|
@@ -46,6 +47,10 @@ function WsClient.connect(url, callbacks, timeoutSeconds)
|
|
|
46
47
|
completed = true
|
|
47
48
|
completion:Fire(success, reason)
|
|
48
49
|
end
|
|
50
|
+
local function cancelPending()
|
|
51
|
+
finish(false, "Connection cancelled")
|
|
52
|
+
end
|
|
53
|
+
currentCancel = cancelPending
|
|
49
54
|
|
|
50
55
|
table.insert(
|
|
51
56
|
currentSignals,
|
|
@@ -112,6 +117,9 @@ function WsClient.connect(url, callbacks, timeoutSeconds)
|
|
|
112
117
|
end)
|
|
113
118
|
|
|
114
119
|
local success, reason = completion.Event:Wait()
|
|
120
|
+
if currentCancel == cancelPending then
|
|
121
|
+
currentCancel = nil
|
|
122
|
+
end
|
|
115
123
|
completion:Destroy()
|
|
116
124
|
if not success then
|
|
117
125
|
closeCandidate(candidate)
|
|
@@ -138,6 +146,11 @@ end
|
|
|
138
146
|
|
|
139
147
|
function WsClient.disconnect()
|
|
140
148
|
generation += 1
|
|
149
|
+
local cancelPending = currentCancel
|
|
150
|
+
currentCancel = nil
|
|
151
|
+
if cancelPending then
|
|
152
|
+
cancelPending()
|
|
153
|
+
end
|
|
141
154
|
local connection = currentConnection
|
|
142
155
|
currentConnection = nil
|
|
143
156
|
disconnectSignals()
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
local HttpService = game:GetService("HttpService")
|
|
2
2
|
|
|
3
|
+
local EmbeddedBridgeToken = require(script.BridgeConfig)
|
|
3
4
|
local CommandRouter = require(script.CommandRouter)
|
|
4
5
|
local Protocol = require(script.Protocol)
|
|
5
6
|
local Watcher = require(script.Watcher)
|
|
@@ -22,6 +23,7 @@ local shouldReconnect = true
|
|
|
22
23
|
local reconnectScheduled = false
|
|
23
24
|
local reconnectDelay = 1
|
|
24
25
|
local shuttingDown = false
|
|
26
|
+
local connecting = false
|
|
25
27
|
|
|
26
28
|
local function getSetting(name, default)
|
|
27
29
|
local ok, value = pcall(function()
|
|
@@ -41,6 +43,12 @@ if type(clientId) ~= "string" then
|
|
|
41
43
|
end)
|
|
42
44
|
end
|
|
43
45
|
local bridgeToken = getSetting("Dominus2BridgeToken", nil)
|
|
46
|
+
if type(EmbeddedBridgeToken) == "string" and EmbeddedBridgeToken ~= "__DOMINUS_BRIDGE_TOKEN__" then
|
|
47
|
+
bridgeToken = EmbeddedBridgeToken
|
|
48
|
+
pcall(function()
|
|
49
|
+
plugin:SetSetting("Dominus2BridgeToken", bridgeToken)
|
|
50
|
+
end)
|
|
51
|
+
end
|
|
44
52
|
local port = tonumber(getSetting("Dominus2Port", DEFAULT_PORT)) or DEFAULT_PORT
|
|
45
53
|
|
|
46
54
|
local function log(message)
|
|
@@ -83,17 +91,6 @@ local function handleMessage(rawMessage)
|
|
|
83
91
|
return
|
|
84
92
|
end
|
|
85
93
|
|
|
86
|
-
if message.type == "server:pairing_required" then
|
|
87
|
-
local payload = message.payload or {}
|
|
88
|
-
log(
|
|
89
|
-
"Pairing required. In your MCP client call dominus_pair_studio with connectionId "
|
|
90
|
-
.. tostring(payload.connectionId)
|
|
91
|
-
.. " and code "
|
|
92
|
-
.. tostring(payload.pairingCode)
|
|
93
|
-
)
|
|
94
|
-
return
|
|
95
|
-
end
|
|
96
|
-
|
|
97
94
|
if message.type == "server:authenticated" then
|
|
98
95
|
local payload = message.payload or {}
|
|
99
96
|
if payload.protocolVersion ~= PROTOCOL_VERSION or type(payload.connectionId) ~= "string" then
|
|
@@ -119,7 +116,7 @@ local function handleMessage(rawMessage)
|
|
|
119
116
|
end
|
|
120
117
|
|
|
121
118
|
if message.type == "server:auth_rejected" then
|
|
122
|
-
warn("[Dominus 2] Authentication
|
|
119
|
+
warn("[Dominus 2] Authentication failed. Run dominus-install-plugin and restart Studio.")
|
|
123
120
|
WsClient.disconnect()
|
|
124
121
|
return
|
|
125
122
|
end
|
|
@@ -135,6 +132,13 @@ local function connect()
|
|
|
135
132
|
if shuttingDown or transportOpen then
|
|
136
133
|
return
|
|
137
134
|
end
|
|
135
|
+
if connecting then
|
|
136
|
+
if shouldReconnect then
|
|
137
|
+
scheduleReconnect()
|
|
138
|
+
end
|
|
139
|
+
return
|
|
140
|
+
end
|
|
141
|
+
connecting = true
|
|
138
142
|
reconnectScheduled = false
|
|
139
143
|
local success = WsClient.connect("ws://127.0.0.1:" .. port, {
|
|
140
144
|
onOpen = function()
|
|
@@ -156,6 +160,8 @@ local function connect()
|
|
|
156
160
|
})
|
|
157
161
|
if not sent then
|
|
158
162
|
warn("[Dominus 2] Could not send handshake: " .. tostring(sendErr))
|
|
163
|
+
stopSession()
|
|
164
|
+
WsClient.disconnect()
|
|
159
165
|
end
|
|
160
166
|
end,
|
|
161
167
|
onMessage = function(message)
|
|
@@ -174,9 +180,15 @@ local function connect()
|
|
|
174
180
|
onError = function(statusCode, errorMessage)
|
|
175
181
|
if transportOpen then
|
|
176
182
|
warn("[Dominus 2] Bridge error " .. tostring(statusCode) .. ": " .. tostring(errorMessage))
|
|
183
|
+
stopSession()
|
|
184
|
+
WsClient.disconnect()
|
|
185
|
+
if shouldReconnect then
|
|
186
|
+
scheduleReconnect()
|
|
187
|
+
end
|
|
177
188
|
end
|
|
178
189
|
end,
|
|
179
190
|
}, 4)
|
|
191
|
+
connecting = false
|
|
180
192
|
if not success then
|
|
181
193
|
stopSession()
|
|
182
194
|
if shouldReconnect then
|
|
@@ -201,16 +213,17 @@ scheduleReconnect = function()
|
|
|
201
213
|
end
|
|
202
214
|
|
|
203
215
|
connectButton.Click:Connect(function()
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
216
|
+
shouldReconnect = true
|
|
217
|
+
reconnectDelay = 1
|
|
218
|
+
stopSession()
|
|
219
|
+
WsClient.disconnect()
|
|
220
|
+
log("Reconnecting to the Dominus 2 MCP server")
|
|
221
|
+
task.spawn(function()
|
|
222
|
+
while connecting and not shuttingDown do
|
|
223
|
+
task.wait()
|
|
224
|
+
end
|
|
225
|
+
connect()
|
|
226
|
+
end)
|
|
214
227
|
end)
|
|
215
228
|
|
|
216
229
|
task.delay(1, function()
|
package/plugin/Dominus.rbxm
DELETED
|
Binary file
|