@dsh-overdrive/gateway 0.1.2 → 0.1.3
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/dist/status.d.ts +3 -4
- package/dist/status.js +4 -5
- package/dist/status.js.map +1 -1
- package/package.json +1 -1
- package/src/status.ts +4 -5
- package/web/console.html +151 -0
package/dist/status.d.ts
CHANGED
|
@@ -10,10 +10,9 @@ export interface StatusServerOptions {
|
|
|
10
10
|
* 健康控制台:GET / 与 /console 返回静态页,GET /api/status 返回 DSH 健康 + 适配器状态。
|
|
11
11
|
*
|
|
12
12
|
* console.html 读取路径说明(与 dist 产物核对过):
|
|
13
|
-
* - src 运行(vitest):import.meta.url = packages/gateway/src/status.ts →
|
|
14
|
-
* - dist 运行(node packages/gateway/dist/index.js):import.meta.url = packages/gateway/dist/status.js →
|
|
15
|
-
*
|
|
16
|
-
* ../../../web/console.html 会多上一级到仓库根目录,不正确,已修正)。
|
|
13
|
+
* - src 运行(vitest):import.meta.url = packages/gateway/src/status.ts → ../web/console.html = packages/gateway/web/console.html
|
|
14
|
+
* - dist 运行(node packages/gateway/dist/index.js):import.meta.url = packages/gateway/dist/status.js → ../web/console.html = packages/gateway/web/console.html
|
|
15
|
+
* - npm 安装(@dsh-overdrive/gateway):console.html 随包分发,两种形态均可命中。
|
|
17
16
|
*/
|
|
18
17
|
export declare function createStatusServer(opts: StatusServerOptions): {
|
|
19
18
|
server: Server;
|
package/dist/status.js
CHANGED
|
@@ -5,10 +5,9 @@ import { fileURLToPath } from 'node:url';
|
|
|
5
5
|
* 健康控制台:GET / 与 /console 返回静态页,GET /api/status 返回 DSH 健康 + 适配器状态。
|
|
6
6
|
*
|
|
7
7
|
* console.html 读取路径说明(与 dist 产物核对过):
|
|
8
|
-
* - src 运行(vitest):import.meta.url = packages/gateway/src/status.ts →
|
|
9
|
-
* - dist 运行(node packages/gateway/dist/index.js):import.meta.url = packages/gateway/dist/status.js →
|
|
10
|
-
*
|
|
11
|
-
* ../../../web/console.html 会多上一级到仓库根目录,不正确,已修正)。
|
|
8
|
+
* - src 运行(vitest):import.meta.url = packages/gateway/src/status.ts → ../web/console.html = packages/gateway/web/console.html
|
|
9
|
+
* - dist 运行(node packages/gateway/dist/index.js):import.meta.url = packages/gateway/dist/status.js → ../web/console.html = packages/gateway/web/console.html
|
|
10
|
+
* - npm 安装(@dsh-overdrive/gateway):console.html 随包分发,两种形态均可命中。
|
|
12
11
|
*/
|
|
13
12
|
export function createStatusServer(opts) {
|
|
14
13
|
const http = createServer(async (req, res) => {
|
|
@@ -30,7 +29,7 @@ export function createStatusServer(opts) {
|
|
|
30
29
|
return;
|
|
31
30
|
}
|
|
32
31
|
if (url.pathname === '/' || url.pathname === '/console') {
|
|
33
|
-
const html = await readFile(fileURLToPath(new URL('
|
|
32
|
+
const html = await readFile(fileURLToPath(new URL('../web/console.html', import.meta.url)), 'utf8').catch(() => '<h1>console.html not found</h1>');
|
|
34
33
|
res.writeHead(200, { 'content-type': 'text/html; charset=utf-8' });
|
|
35
34
|
res.end(html);
|
|
36
35
|
return;
|
package/dist/status.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status.js","sourceRoot":"","sources":["../src/status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAe,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAUzC
|
|
1
|
+
{"version":3,"file":"status.js","sourceRoot":"","sources":["../src/status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAe,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAUzC;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAyB;IAK1D,MAA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AAC,EAC9D,MAAM,CACP,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,iCAAiC,CAAC,CAAC;YACjD,GAAG,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,cAAc,EAAE,0BAA0B,EAAE,CAAC,CAAC;YACnE,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACd,OAAO;QACT,CAAC;QACD,GAAG,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,cAAc,EAAE,YAAY,EAAE,CAAC,CAAC;QACrD,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IACvB,CAAC,CAAC,CAAC;IACH,OAAO;QACL,MAAM,EAAE,IAAI;QACZ,MAAM,EAAE,CAAC,IAAY,EAAE,EAAE,CACvB,IAAI,OAAO,CAAS,CAAC,OAAO,EAAE,EAAE,CAC9B,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,OAAO,CAAE,IAAI,CAAC,OAAO,EAAuB,CAAC,IAAI,CAAC,CAAC,CACvF;QACH,KAAK,EAAE,GAAG,EAAE,CAAC,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;KACzE,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
package/src/status.ts
CHANGED
|
@@ -14,10 +14,9 @@ export interface StatusServerOptions {
|
|
|
14
14
|
* 健康控制台:GET / 与 /console 返回静态页,GET /api/status 返回 DSH 健康 + 适配器状态。
|
|
15
15
|
*
|
|
16
16
|
* console.html 读取路径说明(与 dist 产物核对过):
|
|
17
|
-
* - src 运行(vitest):import.meta.url = packages/gateway/src/status.ts →
|
|
18
|
-
* - dist 运行(node packages/gateway/dist/index.js):import.meta.url = packages/gateway/dist/status.js →
|
|
19
|
-
*
|
|
20
|
-
* ../../../web/console.html 会多上一级到仓库根目录,不正确,已修正)。
|
|
17
|
+
* - src 运行(vitest):import.meta.url = packages/gateway/src/status.ts → ../web/console.html = packages/gateway/web/console.html
|
|
18
|
+
* - dist 运行(node packages/gateway/dist/index.js):import.meta.url = packages/gateway/dist/status.js → ../web/console.html = packages/gateway/web/console.html
|
|
19
|
+
* - npm 安装(@dsh-overdrive/gateway):console.html 随包分发,两种形态均可命中。
|
|
21
20
|
*/
|
|
22
21
|
export function createStatusServer(opts: StatusServerOptions): {
|
|
23
22
|
server: Server;
|
|
@@ -43,7 +42,7 @@ export function createStatusServer(opts: StatusServerOptions): {
|
|
|
43
42
|
}
|
|
44
43
|
if (url.pathname === '/' || url.pathname === '/console') {
|
|
45
44
|
const html = await readFile(
|
|
46
|
-
fileURLToPath(new URL('
|
|
45
|
+
fileURLToPath(new URL('../web/console.html', import.meta.url)),
|
|
47
46
|
'utf8',
|
|
48
47
|
).catch(() => '<h1>console.html not found</h1>');
|
|
49
48
|
res.writeHead(200, { 'content-type': 'text/html; charset=utf-8' });
|
package/web/console.html
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="zh">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
+
<title>dsh-overdrive — Setup</title>
|
|
7
|
+
<style>
|
|
8
|
+
body { font-family: system-ui, -apple-system, 'Segoe UI', sans-serif; max-width: 720px; margin: 32px auto; padding: 0 16px; background: #0f1115; color: #e6e6e6; }
|
|
9
|
+
h1 { font-size: 22px; margin-bottom: 4px; }
|
|
10
|
+
.sub { color: #9ca3af; font-size: 13px; margin-bottom: 20px; }
|
|
11
|
+
.card { background: #1a1d24; border: 1px solid #232a38; border-radius: 12px; padding: 16px; margin: 12px 0; }
|
|
12
|
+
.ok { color: #4ade80; } .bad { color: #f87171; } .dim { color: #9ca3af; } .accent { color: #7c9cff; }
|
|
13
|
+
/* progress */
|
|
14
|
+
.bar { height: 8px; border-radius: 4px; background: #232a38; overflow: hidden; margin: 8px 0 4px; }
|
|
15
|
+
.bar > div { height: 100%; width: 0; background: linear-gradient(90deg, #4f7cff, #4ade80); border-radius: 4px; transition: width .6s ease; }
|
|
16
|
+
.steps { counter-reset: step; padding: 0; margin: 12px 0 0; list-style: none; }
|
|
17
|
+
.steps li { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid #1f2632; }
|
|
18
|
+
.steps li:last-child { border-bottom: none; }
|
|
19
|
+
.num { flex: none; width: 26px; height: 26px; border-radius: 50%; background: #232a38; color: #9ca3af; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; margin-top: 2px; }
|
|
20
|
+
.steps li.done .num { background: #1f8b4c; color: #fff; }
|
|
21
|
+
.steps li .body { flex: 1; }
|
|
22
|
+
.steps li .title { font-weight: 600; font-size: 14px; }
|
|
23
|
+
.steps li.done .title { color: #4ade80; }
|
|
24
|
+
.steps li .hint { color: #9ca3af; font-size: 12.5px; margin-top: 3px; line-height: 1.5; }
|
|
25
|
+
.steps li .hint code { background: #232a38; padding: 1px 6px; border-radius: 4px; font-size: 12px; }
|
|
26
|
+
a { color: #7c9cff; }
|
|
27
|
+
.adapters span { margin-right: 10px; }
|
|
28
|
+
</style>
|
|
29
|
+
</head>
|
|
30
|
+
<body>
|
|
31
|
+
<h1>⚡ dsh-overdrive — Setup / 设置向导</h1>
|
|
32
|
+
<div class="sub">The OpenClaw of DeepSeek Harness · 打开 <a href="/api/status">/api/status</a> 查看原始状态</div>
|
|
33
|
+
|
|
34
|
+
<!-- 向导 -->
|
|
35
|
+
<div class="card">
|
|
36
|
+
<div style="display:flex; justify-content:space-between; align-items:baseline;">
|
|
37
|
+
<strong>Getting started / 开始使用</strong>
|
|
38
|
+
<span class="dim" id="progtext">0 / 4</span>
|
|
39
|
+
</div>
|
|
40
|
+
<div class="bar"><div id="bar"></div></div>
|
|
41
|
+
|
|
42
|
+
<ol class="steps">
|
|
43
|
+
<li id="st-dsh">
|
|
44
|
+
<div class="num">1</div>
|
|
45
|
+
<div class="body">
|
|
46
|
+
<div class="title">DeepSeek Harness is running / DSH 已启动</div>
|
|
47
|
+
<div class="hint" id="h-dsh">loading…</div>
|
|
48
|
+
</div>
|
|
49
|
+
</li>
|
|
50
|
+
<li id="st-model">
|
|
51
|
+
<div class="num">2</div>
|
|
52
|
+
<div class="body">
|
|
53
|
+
<div class="title">Model is configured / 已配置模型</div>
|
|
54
|
+
<div class="hint">Open <a href="http://localhost:3080/" target="_blank">DSH Web UI (3080)</a> → settings → pick your model provider & API key. The plugin auto-uses your default model. / 打开 DSH Web UI,在设置里选择模型并填入 API key,插件会自动使用默认模型。</div>
|
|
55
|
+
</div>
|
|
56
|
+
</li>
|
|
57
|
+
<li id="st-plat">
|
|
58
|
+
<div class="num">3</div>
|
|
59
|
+
<div class="body">
|
|
60
|
+
<div class="title">Connect a messaging platform / 连接聊天平台</div>
|
|
61
|
+
<div class="hint"><span id="h-plat">loading…</span></div>
|
|
62
|
+
</div>
|
|
63
|
+
</li>
|
|
64
|
+
<li id="st-chat">
|
|
65
|
+
<div class="num">4</div>
|
|
66
|
+
<div class="body">
|
|
67
|
+
<div class="title">Start chatting / 开始聊天</div>
|
|
68
|
+
<div class="hint">Send <code>/help</code> to your bot, then try <code>/trace</code> · <code>/task</code> · <code>/cron</code>. / 给 bot 发 <code>/help</code>,然后试试 <code>/trace</code> · <code>/task</code> · <code>/cron</code>。</div>
|
|
69
|
+
</div>
|
|
70
|
+
</li>
|
|
71
|
+
</ol>
|
|
72
|
+
</div>
|
|
73
|
+
|
|
74
|
+
<!-- 状态 -->
|
|
75
|
+
<div class="card">
|
|
76
|
+
<strong>Status / 状态</strong>
|
|
77
|
+
<div style="margin-top:8px"><strong>DSH</strong>:<span id="dsh">loading…</span></div>
|
|
78
|
+
<div style="margin-top:8px"><strong>Adapters / 适配器</strong>:<span class="adapters" id="adapters">loading…</span></div>
|
|
79
|
+
</div>
|
|
80
|
+
|
|
81
|
+
<script>
|
|
82
|
+
const PLATFORM_HINTS = {
|
|
83
|
+
telegram: 'Message your bot once, then send <code>/help</code>. / 给 bot 发一条消息,然后发 <code>/help</code>。',
|
|
84
|
+
whatsapp: 'First start prints a QR code in the gateway logs — scan it in WhatsApp → Settings → Linked devices. / 首次启动的日志里有二维码,用 WhatsApp「设置 → 已连接设备」扫码。',
|
|
85
|
+
discord: 'Add the bot to a server and message it. / 把 bot 加进服务器后发消息。',
|
|
86
|
+
slack: 'Install the app into a workspace and message it. / 把应用装进工作区后发消息。',
|
|
87
|
+
feishu: 'Publish the app in the Feishu console, add it as a bot, then message it. / 在飞书开放平台发布应用并加为机器人,然后发消息。',
|
|
88
|
+
dingtalk: 'Add the bot to a group or single chat, then message it. / 把机器人加进群或单聊后发消息。',
|
|
89
|
+
wecom: 'Message the enterprise app. / 给企业微信应用发消息。',
|
|
90
|
+
};
|
|
91
|
+
async function refresh() {
|
|
92
|
+
try {
|
|
93
|
+
const r = await fetch('/api/status');
|
|
94
|
+
const s = await r.json();
|
|
95
|
+
let done = 0;
|
|
96
|
+
|
|
97
|
+
// 1. DSH
|
|
98
|
+
const dshEl = document.getElementById('dsh');
|
|
99
|
+
const hDsh = document.getElementById('h-dsh');
|
|
100
|
+
const stDsh = document.getElementById('st-dsh');
|
|
101
|
+
if (s.dsh.status === 'ok') {
|
|
102
|
+
dshEl.innerHTML = '<span class="ok">● ok(v' + s.version + ')</span>';
|
|
103
|
+
hDsh.innerHTML = 'Running. / 运行中。';
|
|
104
|
+
stDsh.classList.add('done'); done++;
|
|
105
|
+
} else {
|
|
106
|
+
dshEl.innerHTML = '<span class="bad">● ' + (s.dsh.error ?? 'unknown') + '</span>';
|
|
107
|
+
hDsh.innerHTML = 'DSH is not reachable — check <code>DSH_BASE_URL</code> / <code>DSH_TOKEN</code> and restart. / DSH 不可达,检查配置后重启。';
|
|
108
|
+
stDsh.classList.remove('done');
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// 2. model: always actionable (points to DSH Web UI); mark pending until user confirms chat works
|
|
112
|
+
document.getElementById('st-model').classList.remove('done');
|
|
113
|
+
|
|
114
|
+
// 3. platforms
|
|
115
|
+
const hPlat = document.getElementById('h-plat');
|
|
116
|
+
const stPlat = document.getElementById('st-plat');
|
|
117
|
+
const ul = document.getElementById('adapters');
|
|
118
|
+
ul.innerHTML = '';
|
|
119
|
+
let connected = 0;
|
|
120
|
+
const hints = [];
|
|
121
|
+
for (const a of s.adapters) {
|
|
122
|
+
const span = document.createElement('span');
|
|
123
|
+
if (a.connected === true) { span.className = 'ok'; span.textContent = '● ' + a.id; connected++; }
|
|
124
|
+
else if (a.connected === false) { span.className = 'bad'; span.textContent = '○ ' + a.id; hints.push((PLATFORM_HINTS[a.id] ?? 'Check its env vars. / 检查对应环境变量。') + ' <code>' + a.id + '</code>'); }
|
|
125
|
+
else { span.className = 'dim'; span.textContent = '· ' + a.id; }
|
|
126
|
+
ul.appendChild(span);
|
|
127
|
+
}
|
|
128
|
+
if (connected > 0) {
|
|
129
|
+
hPlat.innerHTML = 'Connected: <b>' + connected + '</b>. ' + (hints[0] ?? 'You are all set. / 已就绪。');
|
|
130
|
+
stPlat.classList.add('done'); done++;
|
|
131
|
+
} else {
|
|
132
|
+
hPlat.innerHTML = 'None connected yet. ' + (hints[0] ?? 'Set <code>GATEWAY_ADAPTERS</code> + platform env vars in <code>.env</code> and restart. / 在 .env 里配置 GATEWAY_ADAPTERS 与平台凭据后重启。');
|
|
133
|
+
stPlat.classList.remove('done');
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// 4. chat: same as platforms for now
|
|
137
|
+
document.getElementById('st-chat').classList.toggle('done', connected > 0);
|
|
138
|
+
if (connected > 0) done++;
|
|
139
|
+
|
|
140
|
+
const pct = Math.round((done / 4) * 100);
|
|
141
|
+
document.getElementById('bar').style.width = pct + '%';
|
|
142
|
+
document.getElementById('progtext').textContent = done + ' / 4';
|
|
143
|
+
} catch (e) {
|
|
144
|
+
document.getElementById('dsh').innerHTML = '<span class="bad">console unreachable: ' + e + '</span>';
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
refresh();
|
|
148
|
+
setInterval(refresh, 5000);
|
|
149
|
+
</script>
|
|
150
|
+
</body>
|
|
151
|
+
</html>
|