@goodandready/dsh-lanmode 0.6.3 → 0.6.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/README.md +3 -0
- package/lib/assumptions.js +19 -3
- package/lib/bridge.js +20 -1
- package/lib/index.js +7 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
# dsh-lanmode
|
|
2
2
|
|
|
3
|
+
> Adapted for DeepSeek Harness **0.1.2-alpha.1**: the host now decides LAN trust from the request `Host` header, so the plugin no longer patches the page for it.
|
|
4
|
+
|
|
5
|
+
|
|
3
6
|
Open the [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) Web UI from another device — a phone, a tablet, the laptop on the other side of the room — and have **all of it** work, including the parts the UI switches off when the page is not `localhost`.
|
|
4
7
|
|
|
5
8
|
Works whether you put a reverse proxy in front of the harness or let this plugin serve the network itself. Pick a mode, restart, done.
|
package/lib/assumptions.js
CHANGED
|
@@ -42,14 +42,29 @@ export async function checkAssumptions(options) {
|
|
|
42
42
|
'webServer.port — без него не поднять прямой режим и не проверить, кто слушает сеть',
|
|
43
43
|
))
|
|
44
44
|
|
|
45
|
-
let
|
|
45
|
+
let page = { status: 0, html: '' }
|
|
46
46
|
try {
|
|
47
|
-
|
|
47
|
+
page = await options.fetchIndex()
|
|
48
48
|
} catch (unreachable) {
|
|
49
49
|
results.push(verdict('страница отдаётся', false, String(unreachable.message || unreachable)))
|
|
50
50
|
return results
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
// Харнесс может потребовать токен и ответить отказом. Тело отказа — не
|
|
54
|
+
// страница интерфейса, и искать в нём заплатку бессмысленно: получилось бы
|
|
55
|
+
// уверенное «её нет» там, где мы просто не смотрели.
|
|
56
|
+
if (page.status && page.status !== 200) {
|
|
57
|
+
results.push(verdict(
|
|
58
|
+
'страница отдаётся нам',
|
|
59
|
+
false,
|
|
60
|
+
'харнесс ответил ' + page.status + ' на запрос по петле без токена — проверить страницу отсюда нельзя. '
|
|
61
|
+
+ 'Это не поломка плагина: заплатка могла встать, но увидеть её мы не можем',
|
|
62
|
+
))
|
|
63
|
+
return results
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const html = page.html
|
|
67
|
+
|
|
53
68
|
results.push(verdict(
|
|
54
69
|
'заплатка попала на страницу',
|
|
55
70
|
html.includes('data-dsh-lanmode'),
|
|
@@ -72,5 +87,6 @@ export function summarize(results) {
|
|
|
72
87
|
if (bad.length === 0) return 'точки крепления на месте: ' + results.length + ' из ' + results.length
|
|
73
88
|
return 'ТОЧКИ КРЕПЛЕНИЯ УЕХАЛИ (' + bad.length + ' из ' + results.length + '): '
|
|
74
89
|
+ bad.map((item) => item.name).join('; ')
|
|
75
|
-
+ '. Плагин может работать не так, как
|
|
90
|
+
+ '. Плагин может работать не так, как задумано. Что именно не сошлось — в списке выше; '
|
|
91
|
+
+ 'ядро при этом может быть совершенно исправным'
|
|
76
92
|
}
|
package/lib/bridge.js
CHANGED
|
@@ -58,6 +58,25 @@ function throttle(log, everyMs) {
|
|
|
58
58
|
* снаружи выглядит как поломка харнесса. Обратный прокси перед харнессом
|
|
59
59
|
* настраивают ровно так же, иначе он не годится.
|
|
60
60
|
*/
|
|
61
|
+
/**
|
|
62
|
+
* Пояснение про ядро, которое обходится без нашей правки страницы.
|
|
63
|
+
*
|
|
64
|
+
* До 0.1.2 признак «страница открыта с этой же машины» вычислялся в браузере,
|
|
65
|
+
* и разделы настроек по сети приезжали пустыми — поэтому плагин правил это
|
|
66
|
+
* вычисление в сборке на лету. С 0.1.2 ядро решает то же самое у себя, по
|
|
67
|
+
* заголовку `Host` запроса. Мост подменяет `Host` на петлю с самого начала,
|
|
68
|
+
* значит вопрос закрыт раньше, чем страница успевает его задать.
|
|
69
|
+
*
|
|
70
|
+
* Говорим об этом один раз: иначе строка повторяется на каждый запрос сборки.
|
|
71
|
+
*/
|
|
72
|
+
let coreNoted = false
|
|
73
|
+
|
|
74
|
+
function noteSelfSufficientCore(log) {
|
|
75
|
+
if (coreNoted) return
|
|
76
|
+
coreNoted = true
|
|
77
|
+
log('ядро само решает, доверять ли адресу, — по заголовку запроса; правка страницы не нужна')
|
|
78
|
+
}
|
|
79
|
+
|
|
61
80
|
function relaxTimeouts(server, streamTimeoutMs) {
|
|
62
81
|
server.timeout = streamTimeoutMs
|
|
63
82
|
server.requestTimeout = streamTimeoutMs
|
|
@@ -135,7 +154,7 @@ export function startDirectBridge(ctx, options) {
|
|
|
135
154
|
answer.on('data', (chunk) => parts.push(chunk))
|
|
136
155
|
answer.on('end', () => {
|
|
137
156
|
const done = forceLoopback(Buffer.concat(parts).toString('utf8'))
|
|
138
|
-
if (!done.changed) options.log
|
|
157
|
+
if (!done.changed) noteSelfSufficientCore(options.log)
|
|
139
158
|
const body = Buffer.from(done.source, 'utf8')
|
|
140
159
|
const out = { ...answer.headers }
|
|
141
160
|
out['content-length'] = String(body.length)
|
package/lib/index.js
CHANGED
|
@@ -326,12 +326,16 @@ function start(ctx, config) {
|
|
|
326
326
|
// поломка обязана быть заметной.
|
|
327
327
|
ctx.effect(() => {
|
|
328
328
|
let alive = true
|
|
329
|
-
|
|
330
|
-
|
|
329
|
+
// Держим сам сервис, а не путь к нему: отложенное обращение через ctx
|
|
330
|
+
// в новых сборках возвращает пустоту, хотя сервис на месте.
|
|
331
|
+
const webServer = ctx.webServer
|
|
332
|
+
const port = webServer && webServer.port
|
|
333
|
+
const fetchIndex = () => fetch('http://127.0.0.1:' + port + '/')
|
|
334
|
+
.then((answer) => answer.text().then((html) => ({ status: answer.status, html })))
|
|
331
335
|
|
|
332
336
|
// Даём харнессу договорить о себе: страница отдаётся не в первый миг.
|
|
333
337
|
const timer = setTimeout(() => {
|
|
334
|
-
checkAssumptions({ webServer
|
|
338
|
+
checkAssumptions({ webServer, fetchIndex })
|
|
335
339
|
.then((results) => {
|
|
336
340
|
if (!alive) return
|
|
337
341
|
state.assumptions = results
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@goodandready/dsh-lanmode",
|
|
3
|
-
"version": "0.6.
|
|
4
|
-
"description": "LAN and reverse-proxy access for the DeepSeek Harness Web UI: returns the settings service on pages that are not localhost, fills in the Web APIs the browser withholds on plain HTTP, and can open a listener of its own so nothing else is needed.",
|
|
3
|
+
"version": "0.6.4",
|
|
4
|
+
"description": "LAN and reverse-proxy access for the DeepSeek Harness Web UI: returns the settings service on pages that are not localhost, fills in the Web APIs the browser withholds on plain HTTP, and can open a listener of its own so nothing else is needed. Adapted for DeepSeek Harness 0.1.2-alpha.1.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./lib/index.js",
|