dsh-ai-game-server 0.0.0-stage → 0.0.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 +47 -2
- package/cordis.patch.yml +3 -0
- package/lib/client.js +535 -0
- package/lib/index.js +27741 -0
- package/package.json +43 -4
package/README.md
CHANGED
|
@@ -1,3 +1,48 @@
|
|
|
1
|
-
#
|
|
1
|
+
# DSH AI 游戏服务器自动化平台 (`dsh-ai-game-server`)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
独立、模块化、纯本地存储的游戏服务器自动化运维底座。通过标准 MCP(Streamable HTTP)对接外部官方 **DSH(DeepSeek Harness,支持本机、1Panel、宝塔部署)**,让 AI(大肥鱼)在严格安全边界下协助完成开服、读日志排障、配置维护与运维审计。
|
|
4
|
+
|
|
5
|
+
## 核心特点
|
|
6
|
+
|
|
7
|
+
- **业务与 AI 基座彻底解耦**:控制中心不内嵌托管 DSH,官方 DSH 自由升级不影响业务模块;游戏进程由宿主机独立 Daemon 托管,DSH 或面板重启不掉线。
|
|
8
|
+
- **插件化游戏模块**:Daemon 基于 Cordis 构建,新游戏模块只需在 `packages/games/<game>` 中作为插件挂载即可自动被网页与 MCP 发现。
|
|
9
|
+
- **Minecraft 全分类抽象**:内置原版端(`vanilla`)、插件端(`plugin`)、模组端(`modded`)、混合端(`hybrid`)、群组端(`proxy`)统一模型;首期实装并验证 `paper`(Fill v3 + 流式 SHA-256)。
|
|
10
|
+
- **纯本地存储**:控制中心状态使用 Node 24 内置 `node:sqlite` 存在 `data/control.db`,实例数据存在 `data/instances/`。
|
|
11
|
+
- **安全红线**:无通用 shell、无宿主机任意文件读写、无 Docker Socket;只读工具自动执行返回结果,变更工具落库审批与审计;Minecraft 创建强制显式 EULA 确认。
|
|
12
|
+
|
|
13
|
+
## 环境要求
|
|
14
|
+
|
|
15
|
+
- Node.js >= 24.9.0(使用内置 `node:sqlite`)
|
|
16
|
+
- pnpm 11
|
|
17
|
+
- Java:按所选 Minecraft 版本动态检测
|
|
18
|
+
|
|
19
|
+
## 快速启动
|
|
20
|
+
|
|
21
|
+
```powershell
|
|
22
|
+
pnpm install
|
|
23
|
+
pnpm dev
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
默认仅监听 `127.0.0.1:24310`(控制中心单端口同时托管网页、API、MCP 与 Daemon 通道;仅前端热更新开发时才额外使用 `5173`)。也可以双击根目录的 `启动游戏服务器.bat`。
|
|
27
|
+
|
|
28
|
+
## 接入外部官方 DSH(本机 / 1Panel / 宝塔)
|
|
29
|
+
|
|
30
|
+
打开官方 DSH 的 **「插件管理 → 添加插件」** 弹窗(支持以下两种安装方式,暂未发布 npm 包):
|
|
31
|
+
|
|
32
|
+
1. **GitHub 仓库地址安装**(将代码推送到 GitHub 后即可直接填写):
|
|
33
|
+
`https://github.com/yubboo/dsh-ai-game-server`
|
|
34
|
+
2. **本地目录路径安装**(本机开发可直接填写):
|
|
35
|
+
`E:\ai-game-server\packages\ai\dsh-adapter` 或仓库根目录 `E:\ai-game-server`
|
|
36
|
+
|
|
37
|
+
安装后在 DSH 环境中配置 `GAME_CONTROL_TOKEN`(控制中心启动时打印,保存在 `data/control.token`)以及可选的 `DSH_GAME_MCP_URL`(默认 `http://127.0.0.1:24310/mcp`),或在控制中心界面复制生成的 `cordis.patch.yml` 覆盖配置。
|
|
38
|
+
|
|
39
|
+
## 目录结构
|
|
40
|
+
|
|
41
|
+
- `apps/control-center`:控制中心装配入口。
|
|
42
|
+
- `apps/daemon`:宿主机 Daemon 装配入口(挂载游戏插件)。
|
|
43
|
+
- `packages/contracts/core`:通用工具契约、风险分级、强类型 WS 协议与领域模型。
|
|
44
|
+
- `packages/execution/daemon`:Cordis 插件宿主、工具注册表与控制中心链路。
|
|
45
|
+
- `packages/games/minecraft`:通用 Minecraft 运行时、五大类核心注册表与 Paper 核心实现。
|
|
46
|
+
- `packages/control/api`:`node:sqlite` 持久化、任务与审批编排、动态 MCP Server、REST/SSE。
|
|
47
|
+
- `packages/ai/dsh-adapter`:面向外部官方 DSH 的安全 Profile Patch 生成器与接入工具。
|
|
48
|
+
- `packages/ui/control-center`:React 轻量管理控制台。
|
package/cordis.patch.yml
ADDED
package/lib/client.js
ADDED
|
@@ -0,0 +1,535 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({
|
|
2
|
+
id: "dsh-ai-game-server",
|
|
3
|
+
factory: (require) => {
|
|
4
|
+
var module = { exports: {} };
|
|
5
|
+
var exports = module.exports;
|
|
6
|
+
"use strict";
|
|
7
|
+
var __defProp = Object.defineProperty;
|
|
8
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
9
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
10
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
11
|
+
var __export = (target, all) => {
|
|
12
|
+
for (var name2 in all)
|
|
13
|
+
__defProp(target, name2, { get: all[name2], enumerable: true });
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from))
|
|
18
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
19
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
22
|
+
};
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
|
|
25
|
+
// packages/ai/dsh-adapter/src/client.tsx
|
|
26
|
+
var client_exports = {};
|
|
27
|
+
__export(client_exports, {
|
|
28
|
+
apply: () => apply,
|
|
29
|
+
default: () => client_default,
|
|
30
|
+
inject: () => inject,
|
|
31
|
+
name: () => name
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(client_exports);
|
|
34
|
+
var import_react = require("react");
|
|
35
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
36
|
+
var OWN_PACKAGE_NAMES = /* @__PURE__ */ new Set(["dsh-ai-game-server", "@dsh-ai-game-server/dsh-adapter"]);
|
|
37
|
+
function isOwnBundleSubject(subject) {
|
|
38
|
+
if (!subject || typeof subject !== "object") return false;
|
|
39
|
+
const s = subject;
|
|
40
|
+
if (s.kind === "bundle" && s.pkg?.name && OWN_PACKAGE_NAMES.has(s.pkg.name)) return true;
|
|
41
|
+
if (s.kind === "row" && s.pkg?.name && OWN_PACKAGE_NAMES.has(s.pkg.name)) return true;
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
function usePluginUpdateStatus() {
|
|
45
|
+
const [status, setStatus] = (0, import_react.useState)(null);
|
|
46
|
+
const [checking, setChecking] = (0, import_react.useState)(false);
|
|
47
|
+
const check = (0, import_react.useCallback)(async (force = false) => {
|
|
48
|
+
setChecking(true);
|
|
49
|
+
try {
|
|
50
|
+
const res = await fetch(`/api/dsh-game-server/update-check${force ? "?force=1" : ""}`);
|
|
51
|
+
if (!res.ok) return;
|
|
52
|
+
const data = await res.json();
|
|
53
|
+
setStatus(data);
|
|
54
|
+
} catch {
|
|
55
|
+
} finally {
|
|
56
|
+
setChecking(false);
|
|
57
|
+
}
|
|
58
|
+
}, []);
|
|
59
|
+
(0, import_react.useEffect)(() => {
|
|
60
|
+
void check(false);
|
|
61
|
+
}, [check]);
|
|
62
|
+
return { status, checking, check };
|
|
63
|
+
}
|
|
64
|
+
var CATEGORY_ZH = {
|
|
65
|
+
vanilla: "\u539F\u7248\u7AEF",
|
|
66
|
+
plugin: "\u63D2\u4EF6\u7AEF",
|
|
67
|
+
modded: "\u6A21\u7EC4\u7AEF",
|
|
68
|
+
hybrid: "\u6DF7\u5408\u7AEF",
|
|
69
|
+
proxy: "\u7FA4\u7EC4\u7AEF"
|
|
70
|
+
};
|
|
71
|
+
var PANEL_STYLE_ID = "dsh-ai-game-server/panel.css";
|
|
72
|
+
var PANEL_CSS = `
|
|
73
|
+
.dgs-wrap {
|
|
74
|
+
display: flex;
|
|
75
|
+
flex-direction: column;
|
|
76
|
+
gap: 12px;
|
|
77
|
+
height: 100%;
|
|
78
|
+
overflow-y: auto;
|
|
79
|
+
padding: 14px;
|
|
80
|
+
color: var(--dsw-alias-label-primary, #e6edf5);
|
|
81
|
+
font-size: 13px;
|
|
82
|
+
box-sizing: border-box;
|
|
83
|
+
}
|
|
84
|
+
.dgs-card {
|
|
85
|
+
background: var(--dsw-alias-bg-layer-1, rgba(128,128,128,0.08));
|
|
86
|
+
border: 1px solid var(--dsw-alias-border-l3, rgba(128,128,128,0.22));
|
|
87
|
+
border-radius: 10px;
|
|
88
|
+
padding: 12px;
|
|
89
|
+
}
|
|
90
|
+
.dgs-head {
|
|
91
|
+
display: flex;
|
|
92
|
+
justify-content: space-between;
|
|
93
|
+
align-items: center;
|
|
94
|
+
gap: 8px;
|
|
95
|
+
margin-bottom: 8px;
|
|
96
|
+
}
|
|
97
|
+
.dgs-title { font-weight: 600; font-size: 14px; margin: 0; }
|
|
98
|
+
.dgs-muted { color: var(--dsw-alias-label-secondary, #8fa0b5); font-size: 12px; }
|
|
99
|
+
.dgs-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
|
|
100
|
+
.dgs-btn {
|
|
101
|
+
padding: 5px 10px;
|
|
102
|
+
border-radius: 6px;
|
|
103
|
+
border: 1px solid var(--dsw-alias-border-l3, rgba(128,128,128,0.3));
|
|
104
|
+
background: transparent;
|
|
105
|
+
color: inherit;
|
|
106
|
+
cursor: pointer;
|
|
107
|
+
font-size: 12px;
|
|
108
|
+
}
|
|
109
|
+
.dgs-btn:hover:not(:disabled) {
|
|
110
|
+
background: var(--dsw-alias-interactive-bg-hover, rgba(128,128,128,0.16));
|
|
111
|
+
}
|
|
112
|
+
.dgs-btn:disabled { opacity: 0.5; cursor: not-allowed; }
|
|
113
|
+
.dgs-input {
|
|
114
|
+
padding: 6px 8px;
|
|
115
|
+
border-radius: 6px;
|
|
116
|
+
border: 1px solid var(--dsw-alias-border-l3, rgba(128,128,128,0.3));
|
|
117
|
+
background: transparent;
|
|
118
|
+
color: inherit;
|
|
119
|
+
font-size: 12px;
|
|
120
|
+
width: 100%;
|
|
121
|
+
box-sizing: border-box;
|
|
122
|
+
}
|
|
123
|
+
.dgs-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 8px; }
|
|
124
|
+
.dgs-chip {
|
|
125
|
+
padding: 4px 8px;
|
|
126
|
+
border-radius: 999px;
|
|
127
|
+
font-size: 11px;
|
|
128
|
+
border: 1px solid var(--dsw-alias-border-l3, rgba(128,128,128,0.28));
|
|
129
|
+
}
|
|
130
|
+
.dgs-chip.ready { border-color: #22c55e; }
|
|
131
|
+
.dgs-chip.planned { opacity: 0.6; }
|
|
132
|
+
.dgs-banner { padding: 8px 10px; border-radius: 8px; font-size: 12px; }
|
|
133
|
+
.dgs-banner.ok { background: rgba(34,197,94,0.14); border: 1px solid rgba(34,197,94,0.45); }
|
|
134
|
+
.dgs-banner.err { background: rgba(239,68,68,0.14); border: 1px solid rgba(239,68,68,0.45); }
|
|
135
|
+
.dgs-log {
|
|
136
|
+
margin: 0;
|
|
137
|
+
padding: 8px;
|
|
138
|
+
border-radius: 8px;
|
|
139
|
+
background: rgba(0,0,0,0.22);
|
|
140
|
+
font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
|
|
141
|
+
font-size: 11px;
|
|
142
|
+
max-height: 200px;
|
|
143
|
+
overflow: auto;
|
|
144
|
+
white-space: pre-wrap;
|
|
145
|
+
word-break: break-word;
|
|
146
|
+
}
|
|
147
|
+
`;
|
|
148
|
+
function ensurePanelCss() {
|
|
149
|
+
if (typeof document === "undefined") return;
|
|
150
|
+
if (document.querySelector(`style[data-plugin-css="${PANEL_STYLE_ID}"]`)) return;
|
|
151
|
+
const style = document.createElement("style");
|
|
152
|
+
style.dataset.plugin = "dsh-ai-game-server";
|
|
153
|
+
style.dataset.pluginCss = PANEL_STYLE_ID;
|
|
154
|
+
style.textContent = PANEL_CSS;
|
|
155
|
+
document.head.appendChild(style);
|
|
156
|
+
}
|
|
157
|
+
function ServerGlyph({ size = 18 }) {
|
|
158
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", { width: size, height: size, viewBox: "0 0 20 20", fill: "none", "aria-hidden": "true", children: [
|
|
159
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { x: "3", y: "3.5", width: "14", height: "5", rx: "1.4", stroke: "currentColor", strokeWidth: "1.4" }),
|
|
160
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { x: "3", y: "11.5", width: "14", height: "5", rx: "1.4", stroke: "currentColor", strokeWidth: "1.4" }),
|
|
161
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "6.5", cy: "6", r: "0.9", fill: "currentColor" }),
|
|
162
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "6.5", cy: "14", r: "0.9", fill: "currentColor" })
|
|
163
|
+
] });
|
|
164
|
+
}
|
|
165
|
+
function GameServerPanel() {
|
|
166
|
+
ensurePanelCss();
|
|
167
|
+
const [state, setState] = (0, import_react.useState)(null);
|
|
168
|
+
const [instanceId, setInstanceId] = (0, import_react.useState)("survival-main");
|
|
169
|
+
const [core, setCore] = (0, import_react.useState)("paper");
|
|
170
|
+
const [version, setVersion] = (0, import_react.useState)("1.21.4");
|
|
171
|
+
const [port, setPort] = (0, import_react.useState)(25565);
|
|
172
|
+
const [maxRamMb, setMaxRamMb] = (0, import_react.useState)(4096);
|
|
173
|
+
const [eulaAccepted, setEulaAccepted] = (0, import_react.useState)(false);
|
|
174
|
+
const [busy, setBusy] = (0, import_react.useState)(false);
|
|
175
|
+
const [notice, setNotice] = (0, import_react.useState)("");
|
|
176
|
+
const [error, setError] = (0, import_react.useState)("");
|
|
177
|
+
const [selectedLogs, setSelectedLogs] = (0, import_react.useState)([]);
|
|
178
|
+
const { status: updateStatus, checking: checkingUpdate, check: checkUpdate } = usePluginUpdateStatus();
|
|
179
|
+
const loadState = (0, import_react.useCallback)(async () => {
|
|
180
|
+
try {
|
|
181
|
+
const res = await fetch("/api/dsh-game-server/state");
|
|
182
|
+
const data = await res.json();
|
|
183
|
+
if (!res.ok) throw new Error(data.error ?? "\u8BFB\u53D6\u72B6\u6001\u5931\u8D25");
|
|
184
|
+
setState(data);
|
|
185
|
+
setError("");
|
|
186
|
+
} catch (err) {
|
|
187
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
188
|
+
}
|
|
189
|
+
}, []);
|
|
190
|
+
(0, import_react.useEffect)(() => {
|
|
191
|
+
void loadState();
|
|
192
|
+
const timer = setInterval(() => void loadState(), 5e3);
|
|
193
|
+
return () => clearInterval(timer);
|
|
194
|
+
}, [loadState]);
|
|
195
|
+
const callApi = async (path, init) => {
|
|
196
|
+
setBusy(true);
|
|
197
|
+
setError("");
|
|
198
|
+
setNotice("");
|
|
199
|
+
try {
|
|
200
|
+
const res = await fetch(`/api/dsh-game-server${path}`, {
|
|
201
|
+
headers: { "Content-Type": "application/json" },
|
|
202
|
+
...init
|
|
203
|
+
});
|
|
204
|
+
const data = await res.json();
|
|
205
|
+
if (!res.ok) throw new Error(String(data.error ?? `HTTP ${res.status}`));
|
|
206
|
+
await loadState();
|
|
207
|
+
return data;
|
|
208
|
+
} catch (err) {
|
|
209
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
210
|
+
return null;
|
|
211
|
+
} finally {
|
|
212
|
+
setBusy(false);
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
const handleCheckEnv = async () => {
|
|
216
|
+
const res = await callApi("/env-check", {
|
|
217
|
+
method: "POST",
|
|
218
|
+
body: JSON.stringify({ core, minecraftVersion: version })
|
|
219
|
+
});
|
|
220
|
+
if (res) {
|
|
221
|
+
setNotice(
|
|
222
|
+
res.compatible ? `Java ${String(res.javaMajor)} \u6EE1\u8DB3 ${core} ${version} \u8981\u6C42\uFF08\u6700\u4F4E Java ${String(res.requiredJava)}\uFF09` : `Java \u4E0D\u517C\u5BB9\uFF1A\u5F53\u524D ${String(res.javaMajor ?? "\u672A\u5B89\u88C5")}\uFF0C\u9700\u8981 Java ${String(res.requiredJava)}+`
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
const handleCreate = async (event) => {
|
|
227
|
+
event.preventDefault();
|
|
228
|
+
if (!eulaAccepted) {
|
|
229
|
+
setError("\u521B\u5EFA Minecraft \u5B9E\u4F8B\u524D\u5FC5\u987B\u5148\u660E\u786E\u52FE\u9009\u540C\u610F Mojang EULA");
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
const res = await callApi("/instances", {
|
|
233
|
+
method: "POST",
|
|
234
|
+
body: JSON.stringify({
|
|
235
|
+
instanceId: instanceId.trim(),
|
|
236
|
+
core,
|
|
237
|
+
minecraftVersion: version.trim(),
|
|
238
|
+
port,
|
|
239
|
+
minRamMb: Math.min(1024, maxRamMb),
|
|
240
|
+
maxRamMb,
|
|
241
|
+
eulaAccepted: true
|
|
242
|
+
})
|
|
243
|
+
});
|
|
244
|
+
if (res) setNotice(`\u5B9E\u4F8B ${instanceId} \u521B\u5EFA\u6210\u529F\uFF01`);
|
|
245
|
+
};
|
|
246
|
+
const handleInstanceAction = async (id, action) => {
|
|
247
|
+
const method = action === "start" || action === "stop" ? "POST" : "GET";
|
|
248
|
+
const res = await callApi(`/instances/${encodeURIComponent(id)}/${action}`, { method });
|
|
249
|
+
if (!res) return;
|
|
250
|
+
if (action === "logs" && Array.isArray(res.lines)) {
|
|
251
|
+
setSelectedLogs(res.lines);
|
|
252
|
+
setNotice(`\u5DF2\u8BFB\u53D6 ${id} \u6700\u8FD1 ${res.lines.length} \u884C\u65E5\u5FD7`);
|
|
253
|
+
} else if (typeof res.message === "string") {
|
|
254
|
+
setNotice(`${id}: ${res.message}`);
|
|
255
|
+
} else {
|
|
256
|
+
setNotice(`${id} ${action} \u5B8C\u6210`);
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dgs-wrap", children: [
|
|
260
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dgs-card", children: [
|
|
261
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dgs-head", children: [
|
|
262
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("h3", { className: "dgs-title", children: [
|
|
263
|
+
"\u6E38\u620F\u670D\u52A1\u5668\u63A7\u5236\u9762\u677F",
|
|
264
|
+
state?.pluginVersion ? ` v${state.pluginVersion}` : ""
|
|
265
|
+
] }),
|
|
266
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dgs-row", children: [
|
|
267
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "dgs-btn", onClick: () => void checkUpdate(true), disabled: checkingUpdate, children: checkingUpdate ? "\u68C0\u67E5\u4E2D..." : "\u68C0\u67E5\u66F4\u65B0" }),
|
|
268
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "dgs-btn", onClick: () => void loadState(), disabled: busy, children: "\u5237\u65B0" })
|
|
269
|
+
] })
|
|
270
|
+
] }),
|
|
271
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dgs-muted", children: [
|
|
272
|
+
"\u672C\u5730\u5B58\u50A8\u76EE\u5F55\uFF1A",
|
|
273
|
+
state?.instancesDir ?? "\u52A0\u8F7D\u4E2D...",
|
|
274
|
+
" \xB7 \u76F4\u63A5\u5728\u5DE6\u4FA7\u5BF9\u8BDD\u8BA9\u5927\u80A5\u9C7C\u67E5\u73AF\u5883\u3001\u5F00\u670D\u3001\u8BFB\u65E5\u5FD7\u6392\u969C"
|
|
275
|
+
] }),
|
|
276
|
+
updateStatus?.updateAvailable && updateStatus.latestVersion && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dgs-banner ok", style: { marginTop: 8 }, children: [
|
|
277
|
+
"\u53D1\u73B0\u65B0\u7248\u672C ",
|
|
278
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("strong", { children: [
|
|
279
|
+
"v",
|
|
280
|
+
updateStatus.latestVersion
|
|
281
|
+
] }),
|
|
282
|
+
"\uFF08\u5F53\u524D v",
|
|
283
|
+
updateStatus.currentVersion,
|
|
284
|
+
"\uFF09\xB7",
|
|
285
|
+
" ",
|
|
286
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { href: updateStatus.releaseUrl, target: "_blank", rel: "noreferrer", children: "\u67E5\u770B GitHub \u66F4\u65B0" })
|
|
287
|
+
] })
|
|
288
|
+
] }),
|
|
289
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dgs-banner err", children: error }),
|
|
290
|
+
notice && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dgs-banner ok", children: notice }),
|
|
291
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dgs-card", children: [
|
|
292
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dgs-head", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { className: "dgs-title", children: "Minecraft \u4E94\u5927\u7C7B\u6838\u5FC3" }) }),
|
|
293
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dgs-row", children: (state?.cores ?? []).map((item) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: item.implemented ? "dgs-chip ready" : "dgs-chip planned", children: [
|
|
294
|
+
item.name,
|
|
295
|
+
" \xB7 ",
|
|
296
|
+
CATEGORY_ZH[item.category] ?? item.category,
|
|
297
|
+
item.implemented ? " \u2714" : " (\u8BA1\u5212)"
|
|
298
|
+
] }, item.id)) })
|
|
299
|
+
] }),
|
|
300
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dgs-card", children: [
|
|
301
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dgs-head", children: [
|
|
302
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { className: "dgs-title", children: "\u521B\u5EFA\u672C\u5730\u5B9E\u4F8B" }),
|
|
303
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "dgs-btn", onClick: () => void handleCheckEnv(), disabled: busy, children: "\u68C0\u6D4B Java \u73AF\u5883" })
|
|
304
|
+
] }),
|
|
305
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("form", { onSubmit: handleCreate, children: [
|
|
306
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dgs-grid", children: [
|
|
307
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { children: [
|
|
308
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dgs-muted", children: "\u6838\u5FC3" }),
|
|
309
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("select", { className: "dgs-input", value: core, onChange: (e) => setCore(e.target.value), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "paper", children: "Paper\uFF08\u63D2\u4EF6\u7AEF \xB7 \u5DF2\u5B9E\u6D4B\uFF09" }) })
|
|
310
|
+
] }),
|
|
311
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { children: [
|
|
312
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dgs-muted", children: "\u5B9E\u4F8B ID" }),
|
|
313
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { className: "dgs-input", value: instanceId, onChange: (e) => setInstanceId(e.target.value), required: true })
|
|
314
|
+
] }),
|
|
315
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { children: [
|
|
316
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dgs-muted", children: "MC \u7248\u672C" }),
|
|
317
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { className: "dgs-input", value: version, onChange: (e) => setVersion(e.target.value), required: true })
|
|
318
|
+
] }),
|
|
319
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { children: [
|
|
320
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dgs-muted", children: "\u7AEF\u53E3 / \u6700\u5927\u5185\u5B58(MB)" }),
|
|
321
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dgs-row", children: [
|
|
322
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
323
|
+
"input",
|
|
324
|
+
{
|
|
325
|
+
className: "dgs-input",
|
|
326
|
+
style: { width: "46%" },
|
|
327
|
+
type: "number",
|
|
328
|
+
value: port,
|
|
329
|
+
onChange: (e) => setPort(Number(e.target.value))
|
|
330
|
+
}
|
|
331
|
+
),
|
|
332
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
333
|
+
"input",
|
|
334
|
+
{
|
|
335
|
+
className: "dgs-input",
|
|
336
|
+
style: { width: "46%" },
|
|
337
|
+
type: "number",
|
|
338
|
+
value: maxRamMb,
|
|
339
|
+
onChange: (e) => setMaxRamMb(Number(e.target.value))
|
|
340
|
+
}
|
|
341
|
+
)
|
|
342
|
+
] })
|
|
343
|
+
] })
|
|
344
|
+
] }),
|
|
345
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: "dgs-row", style: { marginBottom: 8 }, children: [
|
|
346
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { type: "checkbox", checked: eulaAccepted, onChange: (e) => setEulaAccepted(e.target.checked) }),
|
|
347
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "dgs-muted", children: [
|
|
348
|
+
"\u6211\u5DF2\u540C\u610F",
|
|
349
|
+
" ",
|
|
350
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { href: "https://aka.ms/MinecraftEULA", target: "_blank", rel: "noreferrer", children: "Mojang EULA" })
|
|
351
|
+
] })
|
|
352
|
+
] }),
|
|
353
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "submit", className: "dgs-btn", disabled: busy, children: "\u521B\u5EFA\u5B9E\u4F8B\uFF08SHA-256 \u6821\u9A8C\uFF09" })
|
|
354
|
+
] })
|
|
355
|
+
] }),
|
|
356
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dgs-card", children: [
|
|
357
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dgs-head", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("h3", { className: "dgs-title", children: [
|
|
358
|
+
"\u672C\u5730\u5B9E\u4F8B\u5217\u8868\uFF08",
|
|
359
|
+
state?.instances.length ?? 0,
|
|
360
|
+
"\uFF09"
|
|
361
|
+
] }) }),
|
|
362
|
+
!state || state.instances.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dgs-muted", children: "\u6682\u65E0\u672C\u5730\u5B9E\u4F8B\u3002\u4F60\u53EF\u4EE5\u5728\u4E0A\u65B9\u521B\u5EFA\uFF0C\u6216\u76F4\u63A5\u5BF9\u5927\u80A5\u9C7C\u8BF4\u201C\u5E2E\u6211\u5EFA\u4E00\u4E2A Paper \u670D\u201D\u3002" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: state.instances.map((inst) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dgs-card", style: { padding: 10 }, children: [
|
|
363
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dgs-head", style: { marginBottom: 6 }, children: [
|
|
364
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("strong", { children: [
|
|
365
|
+
inst.instanceId,
|
|
366
|
+
" (",
|
|
367
|
+
inst.core,
|
|
368
|
+
" ",
|
|
369
|
+
inst.minecraftVersion,
|
|
370
|
+
")"
|
|
371
|
+
] }),
|
|
372
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dgs-chip", children: inst.state })
|
|
373
|
+
] }),
|
|
374
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dgs-row", children: [
|
|
375
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "dgs-btn", disabled: busy, onClick: () => void handleInstanceAction(inst.instanceId, "start"), children: "\u542F\u52A8" }),
|
|
376
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "dgs-btn", disabled: busy, onClick: () => void handleInstanceAction(inst.instanceId, "stop"), children: "\u4F18\u96C5\u505C\u670D" }),
|
|
377
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "dgs-btn", disabled: busy, onClick: () => void handleInstanceAction(inst.instanceId, "health"), children: "\u5065\u5EB7\u68C0\u67E5" }),
|
|
378
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "dgs-btn", disabled: busy, onClick: () => void handleInstanceAction(inst.instanceId, "logs"), children: "\u67E5\u65E5\u5FD7" })
|
|
379
|
+
] })
|
|
380
|
+
] }, inst.instanceId)) })
|
|
381
|
+
] }),
|
|
382
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dgs-card", children: [
|
|
383
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dgs-head", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { className: "dgs-title", children: "\u670D\u52A1\u7AEF\u65E5\u5FD7" }) }),
|
|
384
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", { className: "dgs-log", children: selectedLogs.length > 0 ? selectedLogs.join("\n") : (state?.logs ?? []).length > 0 ? state.logs.map((l) => `[${l.at.slice(11, 19)}] [${l.instanceId}] ${l.line}`).join("\n") : "\u6682\u65E0\u65E5\u5FD7\u8F93\u51FA\u3002" })
|
|
385
|
+
] })
|
|
386
|
+
] });
|
|
387
|
+
}
|
|
388
|
+
function PluginDetailUpdateBadge({ subject }) {
|
|
389
|
+
ensurePanelCss();
|
|
390
|
+
const { status } = usePluginUpdateStatus();
|
|
391
|
+
if (!isOwnBundleSubject(subject) || !status?.updateAvailable || !status.latestVersion) {
|
|
392
|
+
return null;
|
|
393
|
+
}
|
|
394
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "dgs-chip ready", style: { marginLeft: 8 }, children: [
|
|
395
|
+
"\u53EF\u66F4\u65B0\u5230 v",
|
|
396
|
+
status.latestVersion
|
|
397
|
+
] });
|
|
398
|
+
}
|
|
399
|
+
function PluginDetailVersionSection({ subject }) {
|
|
400
|
+
ensurePanelCss();
|
|
401
|
+
const { status, checking, check } = usePluginUpdateStatus();
|
|
402
|
+
const [copied, setCopied] = (0, import_react.useState)(false);
|
|
403
|
+
if (!isOwnBundleSubject(subject)) return null;
|
|
404
|
+
const hhmm = status?.checkedAt ? status.checkedAt.slice(11, 16) : "--:--";
|
|
405
|
+
const copyInstallUrl = async () => {
|
|
406
|
+
if (!status?.installSpec) return;
|
|
407
|
+
try {
|
|
408
|
+
await navigator.clipboard.writeText(status.installSpec);
|
|
409
|
+
setCopied(true);
|
|
410
|
+
setTimeout(() => setCopied(false), 2e3);
|
|
411
|
+
} catch {
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { marginTop: 16 }, children: [
|
|
415
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dgs-head", style: { marginBottom: 8 }, children: [
|
|
416
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: { fontWeight: 600, fontSize: 13 }, children: "\u7248\u672C\uFF08GitHub \u81EA\u52A8\u68C0\u67E5\uFF09" }),
|
|
417
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "dgs-btn", disabled: checking, onClick: () => void check(true), children: checking ? "\u68C0\u67E5\u4E2D..." : "\u91CD\u65B0\u68C0\u67E5" })
|
|
418
|
+
] }),
|
|
419
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dgs-card", children: !status ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dgs-muted", children: "\u6B63\u5728\u68C0\u67E5 GitHub \u6700\u65B0\u7248\u672C..." }) : status.source === "error" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dgs-muted", children: [
|
|
420
|
+
"\u68C0\u67E5\u5931\u8D25\uFF1A",
|
|
421
|
+
status.error ?? "\u65E0\u6CD5\u8FDE\u63A5 GitHub",
|
|
422
|
+
"\uFF08\u5F53\u524D\u7248\u672C v",
|
|
423
|
+
status.currentVersion,
|
|
424
|
+
"\uFF09"
|
|
425
|
+
] }) : status.updateAvailable && status.latestVersion ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: 8 }, children: [
|
|
426
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dgs-head", style: { marginBottom: 0 }, children: [
|
|
427
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
428
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("strong", { children: [
|
|
429
|
+
"\u53EF\u66F4\u65B0\u5230 v",
|
|
430
|
+
status.latestVersion
|
|
431
|
+
] }),
|
|
432
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dgs-muted", children: [
|
|
433
|
+
"\u5F53\u524D\u5DF2\u5B89\u88C5 v",
|
|
434
|
+
status.currentVersion,
|
|
435
|
+
" \xB7 \u68C0\u67E5\u4E8E ",
|
|
436
|
+
hhmm,
|
|
437
|
+
" \xB7 \u6765\u6E90 GitHub"
|
|
438
|
+
] })
|
|
439
|
+
] }),
|
|
440
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dgs-row", children: [
|
|
441
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "dgs-btn", onClick: () => void copyInstallUrl(), children: copied ? "\u5DF2\u590D\u5236\u5730\u5740" : "\u590D\u5236\u5B89\u88C5\u5730\u5740" }),
|
|
442
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { className: "dgs-btn", href: status.releaseUrl, target: "_blank", rel: "noreferrer", style: { textDecoration: "none" }, children: "\u67E5\u770B\u66F4\u65B0" })
|
|
443
|
+
] })
|
|
444
|
+
] }),
|
|
445
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dgs-muted", children: [
|
|
446
|
+
"\u66F4\u65B0\u65B9\u5F0F\uFF1A\u70B9\u51FB\u53F3\u4E0A\u89D2\u300C\u5378\u8F7D\u300D\u540E\uFF0C\u5728\u300C\u6DFB\u52A0\u63D2\u4EF6\u300D\u4E2D\u7C98\u8D34 ",
|
|
447
|
+
status.installSpec,
|
|
448
|
+
" \u5373\u53EF\u5347\u7EA7\u5230\u6700\u65B0\u7248\u672C\u3002"
|
|
449
|
+
] })
|
|
450
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dgs-head", style: { marginBottom: 0 }, children: [
|
|
451
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
452
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("strong", { style: { color: "#22c55e" }, children: [
|
|
453
|
+
"\u2714 \u5DF2\u662F\u6700\u65B0\u7248\u672C\uFF08v",
|
|
454
|
+
status.currentVersion,
|
|
455
|
+
"\uFF09"
|
|
456
|
+
] }),
|
|
457
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dgs-muted", children: [
|
|
458
|
+
"\u4E0A\u6B21\u68C0\u67E5\u4E8E ",
|
|
459
|
+
hhmm,
|
|
460
|
+
" \xB7 \u6765\u6E90 GitHub (",
|
|
461
|
+
status.source === "github-release" ? "Release" : "main \u5206\u652F",
|
|
462
|
+
")"
|
|
463
|
+
] })
|
|
464
|
+
] }),
|
|
465
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { className: "dgs-btn", href: status.repoUrl, target: "_blank", rel: "noreferrer", style: { textDecoration: "none" }, children: "\u67E5\u770B\u4ED3\u5E93" })
|
|
466
|
+
] }) })
|
|
467
|
+
] });
|
|
468
|
+
}
|
|
469
|
+
var name = "dsh-ai-game-server-client";
|
|
470
|
+
var inject = ["sidebarRightTabs", "slots"];
|
|
471
|
+
function apply(ctx) {
|
|
472
|
+
const PLUGIN_ID = "dsh-ai-game-server";
|
|
473
|
+
ctx.effect(
|
|
474
|
+
() => ctx.sidebarRightTabs.register({
|
|
475
|
+
id: PLUGIN_ID,
|
|
476
|
+
kind: "game-server",
|
|
477
|
+
priority: "extension",
|
|
478
|
+
title: () => "\u6E38\u620F\u670D\u52A1\u5668",
|
|
479
|
+
guide: [
|
|
480
|
+
{
|
|
481
|
+
id: "game-server",
|
|
482
|
+
order: 45,
|
|
483
|
+
title: () => "\u6E38\u620F\u670D\u52A1\u5668",
|
|
484
|
+
description: () => "\u7BA1\u7406 Minecraft \u591A\u6838\u5FC3\u670D\u52A1\u7AEF\u3001\u73AF\u5883\u68C0\u6D4B\u4E0E\u5B9E\u65F6\u65E5\u5FD7",
|
|
485
|
+
icon: ServerGlyph
|
|
486
|
+
}
|
|
487
|
+
]
|
|
488
|
+
}),
|
|
489
|
+
"dsh-ai-game-server:tab-type"
|
|
490
|
+
);
|
|
491
|
+
ctx.effect(
|
|
492
|
+
() => ctx.slots.inject(
|
|
493
|
+
"sidebar.right.pane.tab",
|
|
494
|
+
() => ctx.slots.register(
|
|
495
|
+
{
|
|
496
|
+
name: "sidebar.right.pane.tab",
|
|
497
|
+
key: PLUGIN_ID
|
|
498
|
+
},
|
|
499
|
+
GameServerPanel
|
|
500
|
+
)
|
|
501
|
+
),
|
|
502
|
+
"dsh-ai-game-server:tab-body"
|
|
503
|
+
);
|
|
504
|
+
ctx.effect(
|
|
505
|
+
() => ctx.slots.inject(
|
|
506
|
+
"plugins.detail.badge",
|
|
507
|
+
() => ctx.slots.register(
|
|
508
|
+
{
|
|
509
|
+
name: "plugins.detail.badge",
|
|
510
|
+
id: "dsh-ai-game-server-update-badge"
|
|
511
|
+
},
|
|
512
|
+
PluginDetailUpdateBadge
|
|
513
|
+
)
|
|
514
|
+
),
|
|
515
|
+
"dsh-ai-game-server:detail-badge"
|
|
516
|
+
);
|
|
517
|
+
ctx.effect(
|
|
518
|
+
() => ctx.slots.inject(
|
|
519
|
+
"plugins.detail.section",
|
|
520
|
+
() => ctx.slots.register(
|
|
521
|
+
{
|
|
522
|
+
name: "plugins.detail.section",
|
|
523
|
+
id: "dsh-ai-game-server-version-section"
|
|
524
|
+
},
|
|
525
|
+
PluginDetailVersionSection
|
|
526
|
+
)
|
|
527
|
+
),
|
|
528
|
+
"dsh-ai-game-server:detail-section"
|
|
529
|
+
);
|
|
530
|
+
}
|
|
531
|
+
var client_default = { name, inject, apply };
|
|
532
|
+
|
|
533
|
+
return module.exports;
|
|
534
|
+
}
|
|
535
|
+
});
|