@flowfuse/nr-launcher 3.2.0 → 3.2.1-1a5ae10-202610271523.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.
package/lib/admin.js
CHANGED
|
@@ -129,13 +129,14 @@ class AdminInterface {
|
|
|
129
129
|
})
|
|
130
130
|
|
|
131
131
|
app.post('/flowforge/command', async (request, response) => {
|
|
132
|
-
|
|
132
|
+
const body = request.body || {}
|
|
133
|
+
if (body.cmd === 'stop') {
|
|
133
134
|
launcher.stop()
|
|
134
135
|
response.send({})
|
|
135
136
|
// } else {
|
|
136
137
|
// response.status(409).send({err: "Not running"})
|
|
137
138
|
// }
|
|
138
|
-
} else if (
|
|
139
|
+
} else if (body.cmd === 'restart') {
|
|
139
140
|
if (launcher.state === States.RUNNING ||
|
|
140
141
|
launcher.state === States.CRASHED ||
|
|
141
142
|
launcher.state === States.SAFE
|
|
@@ -145,7 +146,7 @@ class AdminInterface {
|
|
|
145
146
|
// Update the settings
|
|
146
147
|
try {
|
|
147
148
|
await launcher.loadSettings()
|
|
148
|
-
await launcher.start(
|
|
149
|
+
await launcher.start(body.safe ? States.SAFE : States.RUNNING)
|
|
149
150
|
} catch (error) {
|
|
150
151
|
await launcher.logAuditEvent('start-failed', { error })
|
|
151
152
|
return response.status(500).send({ error: error.message })
|
|
@@ -155,7 +156,7 @@ class AdminInterface {
|
|
|
155
156
|
} else if (launcher.state === States.STOPPED) {
|
|
156
157
|
try {
|
|
157
158
|
await launcher.loadSettings()
|
|
158
|
-
await launcher.start(
|
|
159
|
+
await launcher.start(body.safe ? States.SAFE : States.RUNNING)
|
|
159
160
|
} catch (error) {
|
|
160
161
|
await launcher.logAuditEvent('start-failed', { error })
|
|
161
162
|
return response.status(500).send({ error: error.message })
|
|
@@ -165,13 +166,13 @@ class AdminInterface {
|
|
|
165
166
|
// Might need a different response
|
|
166
167
|
response.send({})
|
|
167
168
|
}
|
|
168
|
-
} else if (
|
|
169
|
+
} else if (body.cmd === 'start') {
|
|
169
170
|
if (launcher.getState() === States.RUNNING) {
|
|
170
171
|
response.status(409).send({ err: 'Already running' })
|
|
171
172
|
} else {
|
|
172
173
|
try {
|
|
173
174
|
await launcher.loadSettings()
|
|
174
|
-
await launcher.start(
|
|
175
|
+
await launcher.start(body.safe ? States.SAFE : States.RUNNING)
|
|
175
176
|
} catch (error) {
|
|
176
177
|
// delay error audit entry to allow the start command to return and be logged first
|
|
177
178
|
setTimeout(() => {
|
|
@@ -180,35 +181,35 @@ class AdminInterface {
|
|
|
180
181
|
}
|
|
181
182
|
response.send({})
|
|
182
183
|
}
|
|
183
|
-
} else if (
|
|
184
|
-
await launcher.revokeUserToken(
|
|
184
|
+
} else if (body.cmd === 'logout') { // logout:nodered(step-4)
|
|
185
|
+
await launcher.revokeUserToken(body.token) // logout:nodered(step-5)
|
|
185
186
|
response.send({})
|
|
186
|
-
} else if (
|
|
187
|
+
} else if (body.cmd === 'shutdown') {
|
|
187
188
|
await launcher.stop()
|
|
188
189
|
response.send({})
|
|
189
190
|
process.exit(0)
|
|
190
|
-
} else if (
|
|
191
|
+
} else if (body.cmd === 'mcp:get-features') {
|
|
191
192
|
// MCP ROUTE: step 5 (hosted)
|
|
192
193
|
// Called By: driver (localfs/k8s/docker)
|
|
193
194
|
// Calls To : ./launcher.js helper functions
|
|
194
195
|
try {
|
|
195
|
-
const { endpoints } =
|
|
196
|
+
const { endpoints } = body.data || {}
|
|
196
197
|
const features = await launcher.getMCPFeatures(endpoints)
|
|
197
198
|
response.send(features)
|
|
198
199
|
} catch (error) {
|
|
199
200
|
response.status(500).send({ err: error.message })
|
|
200
201
|
}
|
|
201
|
-
} else if (
|
|
202
|
+
} else if (body.cmd === 'mcp:call-tool') {
|
|
202
203
|
try {
|
|
203
|
-
const { endpoint, name, input } =
|
|
204
|
+
const { endpoint, name, input } = body.data || {}
|
|
204
205
|
const result = await launcher.callMCPTool(endpoint, name, input)
|
|
205
206
|
response.send(result)
|
|
206
207
|
} catch (error) {
|
|
207
208
|
response.status(500).send({ err: error.message })
|
|
208
209
|
}
|
|
209
|
-
} else if (
|
|
210
|
+
} else if (body.cmd === 'mcp:read-resource') {
|
|
210
211
|
try {
|
|
211
|
-
const { endpoint, uri } =
|
|
212
|
+
const { endpoint, uri } = body.data || {}
|
|
212
213
|
const result = await launcher.readMCPResource(endpoint, uri)
|
|
213
214
|
response.send(result)
|
|
214
215
|
} catch (error) {
|