dsh-mworks-ai 1.1.1 → 1.1.2
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/README.md +12 -0
- package/icon.png +0 -0
- package/lib/index.js +62 -6
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -20,6 +20,18 @@ The package declares `dsh.bundle.patch` (`cordis.patch.yml`) and `dsh.client`, s
|
|
|
20
20
|
| Instructions | The official MWORKS working rules: Syslab needs `read_syslab_skill` → `detect_syslab_toolboxes` before any code execution; prefer `Ty*` packages; confirm APIs from local help; call `session_manager` before other Sysplorer tools; keep outputs out of the installation directories. Plus the recovery rule: a MWORKS call that stops answering is not fixed by retrying — read `mworks_mcp_status` and rebuild the server instead. |
|
|
21
21
|
| UI | A **Runtime environment** section on this bundle's own page under **Plugins**, below the configuration the Plugin Manager draws. It lists the detected Syslab and Sysplorer installations and versions, the Julia runtime, both MCP servers with their live connection state, and the MWORKS skills this session can call, with **Re-detect** and, for a server that is not connected, **Reconnect**. The section renders nothing on any other plugin's page. Nothing is added to the conversation. |
|
|
22
22
|
|
|
23
|
+
## The two HTTP routes
|
|
24
|
+
|
|
25
|
+
The section reads `GET /api/dsh-mworks-ai/environment`; its **Reconnect** control posts to `POST /api/dsh-mworks-ai/restart`. Both are gated the way the Host's own routes are:
|
|
26
|
+
|
|
27
|
+
| Layer | What it stops |
|
|
28
|
+
|---|---|
|
|
29
|
+
| `ctx.connection.requestRejection(request)` | The Host's access check: a `Host` fence (loopback, the bind address or `trustedHosts`) that a rebinding page cannot forge, the cross-site and `Origin` fences, and the browser login cookie. Its `401`/`403` is written as-is, and its verdict is **final** — this plugin does not add a second opinion when the service is mounted, because it cannot see the deployment's `trustedHosts`. |
|
|
30
|
+
| Local same-origin test | Fallback for a profile that mounts no `connection` service. On its own it cannot see a bare browser read over plain HTTP, so it is never the only defence. |
|
|
31
|
+
| `application/json` required on `/restart` | A cross-site "simple request" can carry `text/plain` without a CORS preflight; anything else is `415` before the body is parsed. |
|
|
32
|
+
|
|
33
|
+
A guard that throws refuses rather than falling through.
|
|
34
|
+
|
|
23
35
|
## Why the MCP servers are owned by the MCP manager
|
|
24
36
|
|
|
25
37
|
`cordis.patch.yml` contains only this plugin's own row: the two servers are contributed at runtime through `ctx.mcpManager.register()`, not as bare `@deepseek-ai/dsh-mcp-client` rows. That buys two things a bare row cannot:
|
package/icon.png
ADDED
|
Binary file
|
package/lib/index.js
CHANGED
|
@@ -913,6 +913,61 @@ function isSameOrigin(request) {
|
|
|
913
913
|
}
|
|
914
914
|
}
|
|
915
915
|
|
|
916
|
+
/** The connection service, when the profile mounts one. */
|
|
917
|
+
function connectionOf(ctx) {
|
|
918
|
+
try {
|
|
919
|
+
const connection = typeof ctx.get === 'function' ? ctx.get('connection') : undefined
|
|
920
|
+
return connection !== undefined && connection !== null && typeof connection.requestRejection === 'function'
|
|
921
|
+
? connection
|
|
922
|
+
: undefined
|
|
923
|
+
} catch {
|
|
924
|
+
return undefined
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
/**
|
|
929
|
+
* Decide whether a request may reach the route.
|
|
930
|
+
*
|
|
931
|
+
* When the profile mounts the Host's `connection` service, that service alone
|
|
932
|
+
* decides — the same call the Host's own routes make. It is the authority on
|
|
933
|
+
* this question: it owns the Host fence (what defeats DNS rebinding), the
|
|
934
|
+
* cross-site and Origin fences, the browser credential, and the deployment's
|
|
935
|
+
* `trustedHosts` policy. Re-checking its verdict locally would be both
|
|
936
|
+
* redundant and wrong: this plugin cannot see `trustedHosts`, so a second
|
|
937
|
+
* opinion could reject traffic the deployment deliberately trusts (a Proxy that
|
|
938
|
+
* rewrites `Host`, for example).
|
|
939
|
+
*
|
|
940
|
+
* Without that service there is nothing to delegate to, so the local
|
|
941
|
+
* same-origin test runs instead as a weaker fallback. It is deliberately not
|
|
942
|
+
* the only defence even there: a browser read over plain HTTP carries neither
|
|
943
|
+
* Origin nor Fetch-Metadata, so `/restart` also requires a JSON media type.
|
|
944
|
+
*
|
|
945
|
+
* @returns true when the response is already finished and the route must stop.
|
|
946
|
+
*/
|
|
947
|
+
function refuseRequest(ctx, request, response) {
|
|
948
|
+
const connection = connectionOf(ctx)
|
|
949
|
+
if (connection !== undefined) {
|
|
950
|
+
let rejection
|
|
951
|
+
try {
|
|
952
|
+
rejection = connection.requestRejection(request)
|
|
953
|
+
} catch {
|
|
954
|
+
// A guard that fails must refuse, never fall through.
|
|
955
|
+
rejection = 403
|
|
956
|
+
}
|
|
957
|
+
if (rejection !== undefined && rejection !== null) {
|
|
958
|
+
response.writeHead(rejection, { 'cache-control': 'no-store' })
|
|
959
|
+
response.end()
|
|
960
|
+
return true
|
|
961
|
+
}
|
|
962
|
+
return false
|
|
963
|
+
}
|
|
964
|
+
if (!isSameOrigin(request)) {
|
|
965
|
+
sendJson(response, 403, { ok: false, error: 'cross-site request refused' })
|
|
966
|
+
return true
|
|
967
|
+
}
|
|
968
|
+
return false
|
|
969
|
+
}
|
|
970
|
+
|
|
916
971
|
/** Read a bounded JSON body. */
|
|
917
972
|
async function readJsonBody(request, limit = 8192) {
|
|
918
973
|
return await new Promise((resolve, reject) => {
|
|
@@ -1092,15 +1147,12 @@ export function apply(ctx, config) {
|
|
|
1092
1147
|
kind: 'exact',
|
|
1093
1148
|
path: `${ROUTE_PREFIX}/environment`,
|
|
1094
1149
|
handler: async (request, response) => {
|
|
1150
|
+
if (refuseRequest(ctx, request, response)) return
|
|
1095
1151
|
if (request.method !== 'GET' && request.method !== 'HEAD') {
|
|
1096
1152
|
response.writeHead(405, { allow: 'GET, HEAD' })
|
|
1097
1153
|
response.end()
|
|
1098
1154
|
return
|
|
1099
1155
|
}
|
|
1100
|
-
if (!isSameOrigin(request)) {
|
|
1101
|
-
sendJson(response, 403, { ok: false, error: 'cross-site request refused' })
|
|
1102
|
-
return
|
|
1103
|
-
}
|
|
1104
1156
|
try {
|
|
1105
1157
|
sendJson(response, 200, await detectEnvironment(ctx))
|
|
1106
1158
|
} catch (error) {
|
|
@@ -1114,13 +1166,17 @@ export function apply(ctx, config) {
|
|
|
1114
1166
|
kind: 'exact',
|
|
1115
1167
|
path: `${ROUTE_PREFIX}/restart`,
|
|
1116
1168
|
handler: async (request, response) => {
|
|
1169
|
+
if (refuseRequest(ctx, request, response)) return
|
|
1117
1170
|
if (request.method !== 'POST') {
|
|
1118
1171
|
response.writeHead(405, { allow: 'POST' })
|
|
1119
1172
|
response.end()
|
|
1120
1173
|
return
|
|
1121
1174
|
}
|
|
1122
|
-
|
|
1123
|
-
|
|
1175
|
+
// A cross-site "simple request" can carry text/plain without a preflight,
|
|
1176
|
+
// so the media type is part of the gate rather than a nicety.
|
|
1177
|
+
const mediaType = String(request.headers?.['content-type'] ?? '').split(';')[0].trim().toLowerCase()
|
|
1178
|
+
if (mediaType !== 'application/json') {
|
|
1179
|
+
sendJson(response, 415, { ok: false, error: 'expected application/json' })
|
|
1124
1180
|
return
|
|
1125
1181
|
}
|
|
1126
1182
|
let body
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-mworks-ai",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "MWORKS AI for DeepSeek Harness: Syslab and Sysplorer MCP servers owned by the MCP manager (live state plus in-place reconnect), official MWORKS skills and working rules, and a Runtime environment section on the plugin page.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -18,11 +18,12 @@
|
|
|
18
18
|
"locale/*.json",
|
|
19
19
|
"docs",
|
|
20
20
|
"icon.svg",
|
|
21
|
+
"icon.png",
|
|
21
22
|
"README.md",
|
|
22
23
|
"LICENSE"
|
|
23
24
|
],
|
|
24
25
|
"engines": {
|
|
25
|
-
|
|
26
|
+
"dsh": ">=0.2.1-rc.1 <0.3.0-0"
|
|
26
27
|
},
|
|
27
28
|
"scripts": {
|
|
28
29
|
"test": "node test/render-check.mjs && node test/class-check.mjs && node test/metadata-check.mjs && node test/host-check.mjs"
|