dsh-dev-modes 1.1.15 → 1.1.16
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/package.json +2 -2
- package/quiet-run/index.js +27 -0
- package/session-lock/index.js +26 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-dev-modes",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.16",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Three DeepSeek Harness Agent presets in one bundle — plus the per-session isolation and quiet-run switches: software development, game development, and read-only discussion, with the matching delivery and engine workflows bundled as skills.",
|
|
6
6
|
"author": "qingfengshangnanzhi",
|
|
@@ -51,4 +51,4 @@
|
|
|
51
51
|
]
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
-
}
|
|
54
|
+
}
|
package/quiet-run/index.js
CHANGED
|
@@ -377,10 +377,35 @@ export function apply(ctx) {
|
|
|
377
377
|
res.end(JSON.stringify(obj));
|
|
378
378
|
};
|
|
379
379
|
|
|
380
|
+
/**
|
|
381
|
+
* 宿主认证:这些路由会读出/改写某个会话的静默状态,必须和 DSH 自己的 API 用同一道闸。
|
|
382
|
+
* `connection.requestRejection` 同时做 Host/Origin 检查与浏览器登录校验:
|
|
383
|
+
* 没有登录凭据、或来自别的站点,都拿不到 401/403 以外的结果。
|
|
384
|
+
* 拿不到这道闸(没有 connection 服务)时按失败关闭处理,不做"看来源地址"之类的猜测。
|
|
385
|
+
* @returns true 表示已经拒绝并写完响应,调用方直接 return。
|
|
386
|
+
*/
|
|
387
|
+
const rejectedByHost = (req, res) => {
|
|
388
|
+
let rejection;
|
|
389
|
+
try {
|
|
390
|
+
const connection = c.get('connection');
|
|
391
|
+
if (typeof connection?.requestRejection !== 'function') throw new Error('admission unavailable');
|
|
392
|
+
rejection = connection.requestRejection(req);
|
|
393
|
+
} catch {
|
|
394
|
+
sendJson(res, 503, { error: 'host admission unavailable' });
|
|
395
|
+
return true;
|
|
396
|
+
}
|
|
397
|
+
if (rejection !== undefined) {
|
|
398
|
+
sendJson(res, rejection === 401 ? 401 : 403, { error: 'unauthenticated' });
|
|
399
|
+
return true;
|
|
400
|
+
}
|
|
401
|
+
return false;
|
|
402
|
+
};
|
|
403
|
+
|
|
380
404
|
const state = c.webServer.register({
|
|
381
405
|
kind: 'exact',
|
|
382
406
|
path: '/dsh-quiet-run/state',
|
|
383
407
|
handler: async (req, res) => {
|
|
408
|
+
if (rejectedByHost(req, res)) return;
|
|
384
409
|
const url = new URL(req.url || '/', 'http://127.0.0.1');
|
|
385
410
|
const asked = url.searchParams.get('sessionId');
|
|
386
411
|
const sessionId = asked || activeSessionId;
|
|
@@ -404,6 +429,7 @@ export function apply(ctx) {
|
|
|
404
429
|
kind: 'exact',
|
|
405
430
|
path: '/dsh-quiet-run/set',
|
|
406
431
|
handler: async (req, res) => {
|
|
432
|
+
if (rejectedByHost(req, res)) return;
|
|
407
433
|
if (req.method !== 'POST') {
|
|
408
434
|
sendJson(res, 405, { error: 'POST only' });
|
|
409
435
|
return;
|
|
@@ -433,6 +459,7 @@ export function apply(ctx) {
|
|
|
433
459
|
kind: 'exact',
|
|
434
460
|
path: '/dsh-quiet-run/log',
|
|
435
461
|
handler: async (req, res) => {
|
|
462
|
+
if (rejectedByHost(req, res)) return;
|
|
436
463
|
let lines = [];
|
|
437
464
|
try {
|
|
438
465
|
lines = fs.readFileSync(LOG_FILE, 'utf8').trim().split('\n').slice(-60);
|
package/session-lock/index.js
CHANGED
|
@@ -215,10 +215,35 @@ export function apply(ctx) {
|
|
|
215
215
|
res.end(JSON.stringify(obj));
|
|
216
216
|
};
|
|
217
217
|
|
|
218
|
+
/**
|
|
219
|
+
* 宿主认证:这两个路由会读出/改写某个会话的隔离状态,必须和 DSH 自己的 API 用同一道闸。
|
|
220
|
+
* `connection.requestRejection` 同时做 Host/Origin 检查与浏览器登录校验:
|
|
221
|
+
* 没有登录凭据、或来自别的站点,都拿不到 401/403 以外的结果。
|
|
222
|
+
* 拿不到这道闸(没有 connection 服务)时按失败关闭处理,不做"看来源地址"之类的猜测。
|
|
223
|
+
* @returns true 表示已经拒绝并写完响应,调用方直接 return。
|
|
224
|
+
*/
|
|
225
|
+
const rejectedByHost = (req, res) => {
|
|
226
|
+
let rejection;
|
|
227
|
+
try {
|
|
228
|
+
const connection = c.get('connection');
|
|
229
|
+
if (typeof connection?.requestRejection !== 'function') throw new Error('admission unavailable');
|
|
230
|
+
rejection = connection.requestRejection(req);
|
|
231
|
+
} catch {
|
|
232
|
+
sendJson(res, 503, { error: 'host admission unavailable' });
|
|
233
|
+
return true;
|
|
234
|
+
}
|
|
235
|
+
if (rejection !== undefined) {
|
|
236
|
+
sendJson(res, rejection === 401 ? 401 : 403, { error: 'unauthenticated' });
|
|
237
|
+
return true;
|
|
238
|
+
}
|
|
239
|
+
return false;
|
|
240
|
+
};
|
|
241
|
+
|
|
218
242
|
const state = c.webServer.register({
|
|
219
243
|
kind: 'exact',
|
|
220
244
|
path: '/dsh-session-lock/state',
|
|
221
245
|
handler: async (req, res) => {
|
|
246
|
+
if (rejectedByHost(req, res)) return;
|
|
222
247
|
const url = new URL(req.url || '/', 'http://127.0.0.1');
|
|
223
248
|
const asked = url.searchParams.get('sessionId');
|
|
224
249
|
const sessionId = asked || activeSessionId;
|
|
@@ -240,6 +265,7 @@ export function apply(ctx) {
|
|
|
240
265
|
kind: 'exact',
|
|
241
266
|
path: '/dsh-session-lock/set',
|
|
242
267
|
handler: async (req, res) => {
|
|
268
|
+
if (rejectedByHost(req, res)) return;
|
|
243
269
|
if (req.method !== 'POST') {
|
|
244
270
|
sendJson(res, 405, { error: 'POST only' });
|
|
245
271
|
return;
|