@simplexai/localmodels-darwin-arm64 0.1.0-dev.48 → 0.1.0-dev.50
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/bootstrap.identity +1 -1
- package/bootstrap.sha256 +82 -72
- package/modules/localmodels/__init__.py +1 -1
- package/modules/localmodels/budget.py +40 -14
- package/modules/localmodels/catalog.json +473 -36
- package/modules/localmodels/debug_mode.py +25 -0
- package/modules/localmodels/deploy.py +3 -0
- package/modules/localmodels/download-mirrors.json +47 -0
- package/modules/localmodels/engines-b12588-mix-c0c3de8.json +13 -1
- package/modules/localmodels/engines-strata-poly-0.2.19-poly.1.json +79 -0
- package/modules/localmodels/engines.py +31 -6
- package/modules/localmodels/gateway.py +23 -6
- package/modules/localmodels/gateway_bifrost.py +6 -2
- package/modules/localmodels/harness.py +8 -2
- package/modules/localmodels/harness_gateway.py +78 -17
- package/modules/localmodels/harness_probe.py +5 -1
- package/modules/localmodels/hosts.py +52 -5
- package/modules/localmodels/library_floor.py +76 -0
- package/modules/localmodels/library_jobs.py +60 -7
- package/modules/localmodels/library_model.py +38 -2
- package/modules/localmodels/library_poly.py +272 -0
- package/modules/localmodels/library_pricing.py +251 -79
- package/modules/localmodels/library_serve.py +27 -4
- package/modules/localmodels/library_state.py +16 -0
- package/modules/localmodels/library_status.py +46 -18
- package/modules/localmodels/library_vram.py +123 -0
- package/modules/localmodels/llm_rank.py +42 -1
- package/modules/localmodels/magpie_windows.py +312 -0
- package/modules/localmodels/probe.py +39 -37
- package/modules/localmodels/process_identity.py +26 -33
- package/modules/localmodels/process_identity_darwin.py +189 -0
- package/modules/localmodels/process_identity_linux.py +62 -30
- package/modules/localmodels/recommend.py +3 -1
- package/modules/localmodels/remote_ops.py +11 -0
- package/modules/localmodels/remote_ops_download.py +30 -5
- package/modules/localmodels/remote_ops_service.py +15 -46
- package/modules/localmodels/reuse.py +13 -6
- package/modules/localmodels/runtime_io.py +32 -18
- package/modules/localmodels/service_probe.py +1 -1
- package/modules/localmodels/setup_inspection.py +97 -80
- package/modules/localmodels/setup_inspection_harness.py +147 -0
- package/modules/localmodels/setup_text.py +24 -0
- package/modules/localmodels/setup_upgrade.py +155 -0
- package/modules/localmodels/stack.py +3 -1
- package/modules/localmodels/stack_auto.py +6 -2
- package/modules/localmodels/stack_clients.py +1 -1
- package/modules/localmodels/stack_compose.py +5 -1
- package/modules/localmodels/stack_down.py +25 -16
- package/modules/localmodels/stack_hardware.py +17 -3
- package/modules/localmodels/stack_picks.py +28 -13
- package/modules/localmodels/stack_remove.py +3 -1
- package/modules/localmodels/stack_route.py +5 -1
- package/modules/localmodels/stack_suite.py +29 -8
- package/modules/localmodels/stack_view_access.py +238 -58
- package/modules/localmodels/stack_view_hub.py +12 -7
- package/modules/localmodels/stack_view_serve.py +13 -6
- package/modules/localmodels/strata-poly-serve-0.2.19-poly.1.txt +428 -0
- package/modules/localmodels/strata_poly_server.py +14 -2
- package/modules/localmodels/suite.py +19 -3
- package/modules/localmodels/tool_archive.py +4 -0
- package/modules/localmodels/transport.py +3 -1
- package/modules/localmodels/tui.py +4 -1
- package/modules/localmodels/tui_dialogs.py +42 -9
- package/modules/localmodels/tui_modals.py +63 -16
- package/modules/localmodels/tui_screen.py +80 -53
- package/modules/localmodels/tui_views.py +36 -6
- package/modules/localmodels/vision.py +4 -2
- package/modules/localmodels/web/index.html +996 -300
- package/modules/localmodels/web/sizecalc/app.js +616 -88
- package/modules/localmodels/web/sizecalc/page.html +239 -106
- package/modules/localmodels/web/view/fleet.js +25 -2
- package/modules/localmodels/web/view/nav.js +19 -3
- package/modules/localmodels/web/view/view.css +110 -22
- package/modules/localmodels/web/view/view.js +40 -22
- package/modules/localmodels/win_probe.py +204 -0
- package/modules/{simplex_localmodels-0.1.0.dev48.dist-info → simplex_localmodels-0.1.0.dev50.dist-info}/METADATA +1 -1
- package/modules/{simplex_localmodels-0.1.0.dev48.dist-info → simplex_localmodels-0.1.0.dev50.dist-info}/RECORD +79 -69
- package/package.json +1 -1
- package/tool.json +1 -1
- /package/modules/{simplex_localmodels-0.1.0.dev48.dist-info → simplex_localmodels-0.1.0.dev50.dist-info}/WHEEL +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev48.dist-info → simplex_localmodels-0.1.0.dev50.dist-info}/entry_points.txt +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev48.dist-info → simplex_localmodels-0.1.0.dev50.dist-info}/licenses/NOTICE +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev48.dist-info → simplex_localmodels-0.1.0.dev50.dist-info}/licenses/localmodels/HERMES-LICENSE +0 -0
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="utf-8">
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
|
+
<meta name="color-scheme" content="light dark">
|
|
6
7
|
<title>本地模型设置</title>
|
|
7
|
-
<link rel="icon" type="image/svg+xml" href="data:image/svg+xml,%3Csvg xmlns=
|
|
8
|
+
<link rel="icon" type="image/svg+xml" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Crect width='64' height='64' rx='14' fill='%231c1c21'/%3E%3Cg fill='none' stroke-linejoin='round' stroke-width='3.6'%3E%3Cpath d='M32 12 13 21.5 32 31l19-9.5L32 12Z' stroke='%238b85ff' fill='%238b85ff' fill-opacity='.18'/%3E%3Cpath d='m13 32 19 9.5L51 32' stroke='%232dd4bf'/%3E%3Cpath d='m13 42 19 9.5L51 42' stroke='%23fb923c'/%3E%3C/g%3E%3C/svg%3E">
|
|
8
9
|
<!--
|
|
9
10
|
本地模型设置页,served by `python3 -m localmodels serve`; every value comes from /api.
|
|
10
11
|
Layout, primitives and Chinese copy follow Hermes Desktop「设置 → 提供方 → 本地模型」
|
|
@@ -15,62 +16,78 @@
|
|
|
15
16
|
<style>
|
|
16
17
|
:root {
|
|
17
18
|
color-scheme: light dark;
|
|
18
|
-
--bg: #
|
|
19
|
-
--
|
|
20
|
-
--
|
|
21
|
-
--
|
|
22
|
-
--
|
|
23
|
-
--
|
|
24
|
-
--
|
|
25
|
-
--
|
|
26
|
-
--
|
|
27
|
-
--
|
|
28
|
-
--
|
|
29
|
-
--nav-
|
|
30
|
-
--
|
|
31
|
-
--
|
|
32
|
-
--primary
|
|
19
|
+
--bg: #f4f4f6;
|
|
20
|
+
--card: #ffffff;
|
|
21
|
+
--card-2: #f9f9fb;
|
|
22
|
+
--sidebar-bg: #f4f4f6;
|
|
23
|
+
--fg: #1c1c21;
|
|
24
|
+
--text-secondary: #4a4a53;
|
|
25
|
+
--text-tertiary: #5e5e68;
|
|
26
|
+
--muted-fg: #5e5e68;
|
|
27
|
+
--muted-bg: #f1f1f4;
|
|
28
|
+
--border: #e3e3e8;
|
|
29
|
+
--stroke: #d4d4dc;
|
|
30
|
+
--nav-active: #ffffff;
|
|
31
|
+
--nav-active-border: #e3e3e8;
|
|
32
|
+
--nav-hover: rgba(28, 28, 33, .045);
|
|
33
|
+
--primary: #4f46e5;
|
|
34
|
+
--primary-hover: #4338ca;
|
|
35
|
+
--primary-soft: #eeedfd;
|
|
33
36
|
--primary-fg: #ffffff;
|
|
34
|
-
--success: #
|
|
35
|
-
--success-soft: rgba(
|
|
37
|
+
--success: #16713c;
|
|
38
|
+
--success-soft: rgba(22, 113, 60, .10);
|
|
36
39
|
--warn: #985100;
|
|
37
|
-
--warn-soft: rgba(
|
|
38
|
-
--danger: #
|
|
39
|
-
--danger-soft: rgba(
|
|
40
|
+
--warn-soft: rgba(152, 81, 0, .11);
|
|
41
|
+
--danger: #d70015;
|
|
42
|
+
--danger-soft: rgba(215, 0, 21, .10);
|
|
43
|
+
--tip-bg: #1c1c21;
|
|
44
|
+
--tip-fg: #f4f4f6;
|
|
45
|
+
--tip-border: rgba(255, 255, 255, .12);
|
|
40
46
|
--text-size: 13px;
|
|
41
47
|
--caption-size: 12px;
|
|
42
|
-
--shadow: 0 1px 2px rgba(
|
|
48
|
+
--shadow: 0 1px 2px rgba(20, 22, 30, .06);
|
|
49
|
+
--shadow-lg: 0 16px 44px rgba(20, 22, 30, .16), 0 2px 8px rgba(20, 22, 30, .06);
|
|
43
50
|
}
|
|
44
51
|
:root[data-theme="light"] { color-scheme: light; }
|
|
45
52
|
@media (prefers-color-scheme: dark) {
|
|
46
53
|
:root:not([data-theme="light"]) {
|
|
47
54
|
color-scheme: dark;
|
|
48
|
-
--bg: #
|
|
49
|
-
--
|
|
50
|
-
--
|
|
51
|
-
--
|
|
52
|
-
--
|
|
53
|
-
--
|
|
55
|
+
--bg: #121215; --card: #1b1b1e; --card-2: #232327; --sidebar-bg: #121215;
|
|
56
|
+
--fg: #ececf0; --text-secondary: #c2c2c9; --text-tertiary: #aaaab4; --muted-fg: #aaaab4;
|
|
57
|
+
--muted-bg: #2e2e33; --border: #34343a; --stroke: #42424a;
|
|
58
|
+
--nav-active: #232327; --nav-active-border: #34343a; --nav-hover: rgba(236, 236, 240, .06);
|
|
59
|
+
--primary: #9b95ff; --primary-hover: #b2adff; --primary-soft: #2e2b52; --primary-fg: #121215;
|
|
60
|
+
--success: #4ade80; --success-soft: rgba(74, 222, 128, .12);
|
|
61
|
+
--warn: #fdba74; --warn-soft: rgba(253, 186, 116, .13);
|
|
62
|
+
--danger: #fb7185; --danger-soft: rgba(251, 113, 133, .13);
|
|
63
|
+
--tip-bg: #2a2a30; --tip-fg: #ececf0; --tip-border: #44444e;
|
|
64
|
+
--shadow: 0 1px 2px rgba(0, 0, 0, .28);
|
|
65
|
+
--shadow-lg: 0 18px 48px rgba(0, 0, 0, .55);
|
|
54
66
|
}
|
|
55
67
|
}
|
|
56
68
|
:root[data-theme="dark"] {
|
|
57
69
|
color-scheme: dark;
|
|
58
|
-
--bg: #
|
|
59
|
-
--
|
|
60
|
-
--
|
|
61
|
-
--
|
|
62
|
-
--
|
|
63
|
-
--
|
|
70
|
+
--bg: #121215; --card: #1b1b1e; --card-2: #232327; --sidebar-bg: #121215;
|
|
71
|
+
--fg: #ececf0; --text-secondary: #c2c2c9; --text-tertiary: #aaaab4; --muted-fg: #aaaab4;
|
|
72
|
+
--muted-bg: #2e2e33; --border: #34343a; --stroke: #42424a;
|
|
73
|
+
--nav-active: #232327; --nav-active-border: #34343a; --nav-hover: rgba(236, 236, 240, .06);
|
|
74
|
+
--primary: #9b95ff; --primary-hover: #b2adff; --primary-soft: #2e2b52; --primary-fg: #121215;
|
|
75
|
+
--success: #4ade80; --success-soft: rgba(74, 222, 128, .12);
|
|
76
|
+
--warn: #fdba74; --warn-soft: rgba(253, 186, 116, .13);
|
|
77
|
+
--danger: #fb7185; --danger-soft: rgba(251, 113, 133, .13);
|
|
78
|
+
--tip-bg: #2a2a30; --tip-fg: #ececf0; --tip-border: #44444e;
|
|
79
|
+
--shadow: 0 1px 2px rgba(0, 0, 0, .28);
|
|
80
|
+
--shadow-lg: 0 18px 48px rgba(0, 0, 0, .55);
|
|
64
81
|
}
|
|
65
82
|
|
|
66
83
|
* { box-sizing: border-box; }
|
|
67
84
|
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
|
|
68
|
-
#plan-title:focus { outline: none; }
|
|
85
|
+
#plan-title:focus, #remove-title:focus { outline: none; }
|
|
69
86
|
html, body { height: 100%; margin: 0; }
|
|
70
87
|
body {
|
|
71
88
|
background: var(--bg);
|
|
72
89
|
color: var(--fg);
|
|
73
|
-
font: var(--text-size)/1.5 "
|
|
90
|
+
font: var(--text-size)/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
|
|
74
91
|
-webkit-font-smoothing: antialiased;
|
|
75
92
|
overflow: hidden;
|
|
76
93
|
}
|
|
@@ -82,209 +99,333 @@ svg.i.xs { width: 12px; height: 12px; }
|
|
|
82
99
|
@keyframes spin { to { transform: rotate(360deg); } }
|
|
83
100
|
|
|
84
101
|
/* ── Shell ── */
|
|
85
|
-
.window { display: grid; grid-template-columns:
|
|
102
|
+
.window { display: grid; grid-template-columns: 212px minmax(0, 1fr); height: 100vh; }
|
|
86
103
|
.sidebar {
|
|
87
104
|
background: var(--sidebar-bg);
|
|
88
105
|
border-right: 1px solid var(--border);
|
|
89
106
|
display: flex; flex-direction: column;
|
|
90
|
-
padding: 12px 10px
|
|
107
|
+
padding: 12px 10px;
|
|
91
108
|
min-height: 0;
|
|
92
109
|
}
|
|
93
110
|
.nav-list { display: grid; gap: 2px; }
|
|
94
111
|
.nav-item {
|
|
95
112
|
display: flex; align-items: center; gap: 8px;
|
|
96
|
-
min-height:
|
|
97
|
-
padding: 0
|
|
98
|
-
border: 1px solid transparent; border-radius:
|
|
113
|
+
min-height: 32px; width: 100%;
|
|
114
|
+
padding: 0 10px;
|
|
115
|
+
border: 1px solid transparent; border-radius: 8px;
|
|
99
116
|
background: transparent; text-align: left; text-decoration: none;
|
|
100
|
-
color: var(--text-secondary);
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
.nav-item
|
|
117
|
+
color: var(--text-secondary); cursor: pointer;
|
|
118
|
+
transition: background .15s, color .15s, border-color .15s;
|
|
119
|
+
}
|
|
120
|
+
.nav-item svg { color: var(--muted-fg); transition: color .15s; }
|
|
121
|
+
.nav-item:hover { background: var(--nav-hover); color: var(--fg); }
|
|
122
|
+
.nav-item[aria-current="page"],
|
|
123
|
+
.nav-item[aria-current="location"] {
|
|
124
|
+
background: var(--nav-active); border-color: var(--nav-active-border);
|
|
125
|
+
color: var(--fg); font-weight: 560; box-shadow: var(--shadow);
|
|
126
|
+
}
|
|
127
|
+
.nav-item[aria-current="page"] svg,
|
|
128
|
+
.nav-item[aria-current="location"] svg { color: var(--primary); }
|
|
104
129
|
.nav-item .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
105
130
|
.sidebar-foot { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--border); display: grid; gap: 8px; }
|
|
106
131
|
.cross-links { display: grid; gap: 2px; }
|
|
107
132
|
.theme-btn {
|
|
108
133
|
display: inline-flex; align-items: center; gap: 8px;
|
|
109
|
-
width: 100%; min-height:
|
|
110
|
-
border: 1px solid var(--border); border-radius:
|
|
111
|
-
background: var(--
|
|
134
|
+
width: 100%; min-height: 32px; padding: 0 10px;
|
|
135
|
+
border: 1px solid var(--border); border-radius: 8px;
|
|
136
|
+
background: var(--card); color: var(--text-secondary);
|
|
112
137
|
font-size: 12px; cursor: pointer; text-align: left;
|
|
138
|
+
transition: background .15s, color .15s;
|
|
113
139
|
}
|
|
114
140
|
.theme-btn:hover { background: var(--nav-hover); color: var(--fg); }
|
|
115
141
|
|
|
116
142
|
.main { position: relative; min-height: 0; display: flex; flex-direction: column; }
|
|
117
|
-
.
|
|
118
|
-
.
|
|
119
|
-
.page-
|
|
120
|
-
.
|
|
143
|
+
.mobile-nav { display: none; }
|
|
144
|
+
.scroll { flex: 1; overflow-y: auto; padding: 24px 36px 80px; scroll-behavior: smooth; }
|
|
145
|
+
.page-head, #page { max-width: 1080px; margin-left: auto; margin-right: auto; }
|
|
146
|
+
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 auto 16px; }
|
|
147
|
+
.page-title { margin: 0; font-size: 17px; font-weight: 650; letter-spacing: -.01em; }
|
|
121
148
|
.setup-guide, .section { scroll-margin-top: 16px; }
|
|
122
149
|
|
|
123
150
|
/* ── Settings primitives (primitives.tsx) ── */
|
|
124
|
-
.section {
|
|
125
|
-
|
|
151
|
+
.section {
|
|
152
|
+
margin-bottom: 16px; padding: 16px 18px;
|
|
153
|
+
background: var(--card); border: 1px solid var(--border); border-radius: 12px;
|
|
154
|
+
}
|
|
155
|
+
.section-heading { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-weight: 600; font-size: 14px; }
|
|
126
156
|
.section-heading > svg { color: var(--muted-fg); }
|
|
127
|
-
.section-heading .aside { margin-left: auto; display: flex; align-items: center; }
|
|
157
|
+
.section-heading .aside { margin-left: auto; display: flex; align-items: center; gap: 6px; font-weight: 400; }
|
|
158
|
+
|
|
159
|
+
.active-strip {
|
|
160
|
+
display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px;
|
|
161
|
+
margin-bottom: 16px; padding: 10px 14px; border-radius: 10px;
|
|
162
|
+
background: var(--card); border: 1px solid var(--border);
|
|
163
|
+
}
|
|
164
|
+
.active-strip.is-ready {
|
|
165
|
+
background: color-mix(in srgb, var(--success-soft) 55%, var(--card));
|
|
166
|
+
border-color: color-mix(in srgb, var(--success) 35%, var(--border));
|
|
167
|
+
}
|
|
168
|
+
.active-strip-main { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; min-width: 0; flex: 1 1 260px; }
|
|
169
|
+
.active-strip-ep { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; max-width: 100%; }
|
|
170
|
+
.active-strip-name { font-weight: 550; color: var(--fg); font-size: 12px; }
|
|
171
|
+
.active-strip-ep code {
|
|
172
|
+
padding: 2px 7px; border-radius: 5px;
|
|
173
|
+
background: var(--card); border: 1px solid var(--border); color: var(--fg);
|
|
174
|
+
overflow-wrap: anywhere;
|
|
175
|
+
}
|
|
176
|
+
.active-strip-link {
|
|
177
|
+
font-size: 12px; font-weight: 550; color: var(--primary); text-decoration: none;
|
|
178
|
+
white-space: nowrap; flex-shrink: 0;
|
|
179
|
+
}
|
|
180
|
+
.active-strip-link:hover { text-decoration: underline; }
|
|
128
181
|
|
|
129
182
|
.pill {
|
|
130
183
|
display: inline-flex; align-items: center; gap: 4px;
|
|
131
184
|
width: fit-content; flex-shrink: 0;
|
|
132
|
-
padding: 3px
|
|
133
|
-
font-size:
|
|
185
|
+
padding: 3px 7px; border-radius: 5px;
|
|
186
|
+
font-size: 11px; font-weight: 500; line-height: 1.1; white-space: nowrap;
|
|
187
|
+
font-variant-numeric: tabular-nums;
|
|
134
188
|
background: var(--muted-bg); color: var(--muted-fg);
|
|
135
189
|
}
|
|
136
190
|
.pill svg { width: 12px; height: 12px; }
|
|
137
191
|
.pill.primary { background: var(--primary-soft); color: var(--primary); }
|
|
138
|
-
.recommended-model .pill.primary { background:
|
|
139
|
-
.recommended-model .pill:not(.primary) { background: var(--
|
|
192
|
+
.recommended-model .pill.primary { background: var(--primary); color: var(--primary-fg); }
|
|
193
|
+
.recommended-model .pill:not(.primary):not(.success):not(.warn):not(.destructive) { background: var(--card); border: 1px solid var(--border); }
|
|
140
194
|
.pill.success { background: var(--success-soft); color: var(--success); }
|
|
141
195
|
.pill.warn { background: var(--warn-soft); color: var(--warn); }
|
|
142
196
|
.pill.destructive { background: var(--danger-soft); color: var(--danger); }
|
|
143
197
|
|
|
144
198
|
.row { display: grid; gap: 12px; padding: 12px 0; grid-template-columns: minmax(0, 1fr) minmax(15rem, 22rem); align-items: center; }
|
|
145
|
-
.row
|
|
199
|
+
.row + .row { border-top: 1px solid color-mix(in srgb, var(--border) 70%, transparent); }
|
|
200
|
+
.row-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-weight: 550; color: var(--fg); font-size: var(--text-size); }
|
|
146
201
|
.row-desc { margin-top: 4px; font-size: var(--caption-size); line-height: 1.55; color: var(--text-tertiary); }
|
|
147
202
|
.row-action { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; min-width: 0; }
|
|
148
203
|
.pills { margin-top: 6px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
|
|
149
|
-
.rows { display: grid;
|
|
150
|
-
.setup-guide { border: 1px solid var(--border); border-radius:
|
|
204
|
+
.rows { display: grid; }
|
|
205
|
+
.setup-guide { background: var(--card); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 16px; }
|
|
151
206
|
.setup-guide-summary {
|
|
152
207
|
display: flex; align-items: center; justify-content: space-between; gap: 12px;
|
|
153
|
-
padding:
|
|
208
|
+
padding: 13px 18px; cursor: pointer; font-weight: 600; color: var(--fg); list-style: none;
|
|
154
209
|
}
|
|
155
210
|
.setup-guide-summary::-webkit-details-marker { display: none; }
|
|
156
|
-
.setup-guide-summary:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius:
|
|
211
|
+
.setup-guide-summary:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 10px; }
|
|
157
212
|
.setup-guide-toggle { display: inline-flex; align-items: center; color: var(--muted-fg); flex-shrink: 0; }
|
|
158
213
|
.setup-guide-toggle svg { transition: transform .15s; }
|
|
159
214
|
.setup-guide[open] .setup-guide-toggle svg { transform: rotate(90deg); }
|
|
160
|
-
.setup-guide-body { padding:
|
|
215
|
+
.setup-guide-body { padding: 4px 18px 16px; border-top: 1px solid var(--border); }
|
|
161
216
|
.setup-guide p { margin: 8px 0 0; color: var(--text-secondary); }
|
|
162
|
-
.install-command { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin:
|
|
217
|
+
.install-command { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 0; }
|
|
163
218
|
.setup-guide code { overflow-wrap: anywhere; }
|
|
164
|
-
.
|
|
165
|
-
|
|
219
|
+
.install-command code {
|
|
220
|
+
user-select: all; padding: 5px 10px; border-radius: 7px;
|
|
221
|
+
background: var(--muted-bg); border: 1px solid var(--border); color: var(--fg);
|
|
222
|
+
}
|
|
223
|
+
.inline-cmd { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px; vertical-align: baseline; }
|
|
224
|
+
.inline-cmd code {
|
|
225
|
+
padding: 1px 6px; border-radius: 5px;
|
|
226
|
+
background: var(--muted-bg); border: 1px solid var(--border); color: var(--fg);
|
|
227
|
+
}
|
|
228
|
+
.recommended-model {
|
|
229
|
+
padding: 12px 14px; border: 1px solid color-mix(in srgb, var(--primary) 42%, var(--border));
|
|
230
|
+
border-radius: 10px; background: color-mix(in srgb, var(--primary-soft) 55%, var(--card));
|
|
231
|
+
}
|
|
232
|
+
.recommended-model .row { padding: 8px 0; }
|
|
233
|
+
.recommendation-note { margin: 0 0 6px; color: var(--text-secondary); font-size: var(--caption-size); }
|
|
234
|
+
.recommendation-note:last-child { margin: 6px 0 0; }
|
|
166
235
|
.model-alternatives { margin-top: 12px; }
|
|
167
|
-
.model-alternatives summary { cursor: pointer; padding: 8px 0; color: var(--text-secondary); }
|
|
168
|
-
.model-alternatives summary:
|
|
236
|
+
.model-alternatives summary { cursor: pointer; padding: 8px 0; color: var(--text-secondary); font-weight: 500; }
|
|
237
|
+
.model-alternatives summary:hover { color: var(--fg); }
|
|
238
|
+
.model-alternatives summary:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px; }
|
|
169
239
|
.model-alternatives > .hint { margin-bottom: 8px; }
|
|
170
|
-
@media (max-width: 760px) {
|
|
171
|
-
.window { grid-template-columns: 1fr; }
|
|
172
|
-
.sidebar { display: none; }
|
|
173
|
-
.mobile-theme-btn { display: inline-flex; }
|
|
174
|
-
.scroll { padding: 40px 16px 60px; }
|
|
175
|
-
.row { grid-template-columns: 1fr; }
|
|
176
|
-
.row-action { justify-content: flex-start; }
|
|
177
|
-
}
|
|
178
240
|
|
|
179
241
|
.btn {
|
|
180
242
|
display: inline-flex; align-items: center; justify-content: center; gap: 6px;
|
|
181
|
-
height:
|
|
243
|
+
height: 28px; padding: 0 10px; border-radius: 7px;
|
|
182
244
|
border: 1px solid transparent; cursor: pointer; white-space: nowrap;
|
|
183
245
|
font-size: 12px; font-weight: 500;
|
|
246
|
+
transition: background .15s, border-color .15s, color .15s, opacity .15s;
|
|
184
247
|
}
|
|
185
248
|
.btn svg { width: 14px; height: 14px; }
|
|
186
249
|
.btn.primary { background: var(--primary); color: var(--primary-fg); }
|
|
187
250
|
.btn.primary:hover:not(:disabled) { background: var(--primary-hover); }
|
|
188
|
-
.btn.danger { background: var(--danger); color:
|
|
251
|
+
.btn.danger { background: var(--danger); color: #ffffff; }
|
|
189
252
|
.btn.danger:hover:not(:disabled) { opacity: .9; }
|
|
190
|
-
.btn.outline { background: var(--
|
|
253
|
+
.btn.outline { background: var(--card); border-color: var(--stroke); color: var(--fg); box-shadow: var(--shadow); }
|
|
191
254
|
.btn.outline:hover:not(:disabled) { background: var(--nav-hover); }
|
|
192
255
|
.btn.ghost { background: none; color: var(--text-secondary); }
|
|
193
256
|
.btn.ghost:hover:not(:disabled) { background: var(--nav-hover); color: var(--fg); }
|
|
194
|
-
.btn.icon { width:
|
|
195
|
-
.btn.
|
|
257
|
+
.btn.icon { width: 28px; padding: 0; }
|
|
258
|
+
.btn.sm { height: 22px; padding: 0 7px; font-size: 11px; gap: 4px; border-radius: 5px; }
|
|
259
|
+
.btn.sm svg { width: 12px; height: 12px; }
|
|
260
|
+
.btn.lg { height: 34px; padding: 0 14px; font-size: 13px; }
|
|
261
|
+
.btn.is-copied { color: var(--success); border-color: color-mix(in srgb, var(--success) 40%, var(--border)); }
|
|
196
262
|
.btn:disabled { opacity: .5; cursor: not-allowed; }
|
|
263
|
+
.btn.mobile-theme-btn { display: none; }
|
|
264
|
+
|
|
265
|
+
.error-card {
|
|
266
|
+
display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px;
|
|
267
|
+
margin-bottom: 16px; padding: 14px 16px; border-radius: 12px;
|
|
268
|
+
background: var(--card); border: 1px solid color-mix(in srgb, var(--danger) 42%, var(--border));
|
|
269
|
+
box-shadow: inset 3px 0 0 var(--danger);
|
|
270
|
+
}
|
|
271
|
+
.error-card-body { display: grid; gap: 4px; min-width: 0; flex: 1 1 240px; }
|
|
272
|
+
.error-card-title { display: flex; align-items: center; gap: 6px; font-weight: 600; color: var(--danger); }
|
|
273
|
+
.error-card-msg { margin: 0; font-size: 12px; color: var(--text-secondary); white-space: pre-wrap; overflow-wrap: anywhere; }
|
|
197
274
|
|
|
198
|
-
.hw { display: flex; flex-wrap: wrap; align-items: center; column-gap: 20px; row-gap:
|
|
275
|
+
.hw { display: flex; flex-wrap: wrap; align-items: center; column-gap: 20px; row-gap: 6px; padding: 4px 0; font-size: var(--caption-size); color: var(--muted-fg); font-variant-numeric: tabular-nums; }
|
|
199
276
|
.hw span { display: inline-flex; align-items: center; gap: 6px; }
|
|
200
277
|
|
|
201
|
-
.progress { height:
|
|
278
|
+
.progress { height: 5px; border-radius: 99px; background: var(--muted-bg); overflow: hidden; box-shadow: inset 0 0 0 1px var(--border); position: relative; }
|
|
202
279
|
.progress > div { height: 100%; background: var(--primary); border-radius: inherit; transition: width .3s; }
|
|
203
|
-
.progress.
|
|
204
|
-
|
|
205
|
-
|
|
280
|
+
.progress.indeterminate > div { width: 38%; animation: progress-slide 1.4s ease-in-out infinite; }
|
|
281
|
+
@keyframes progress-slide {
|
|
282
|
+
0% { transform: translateX(-110%); }
|
|
283
|
+
100% { transform: translateX(300%); }
|
|
284
|
+
}
|
|
285
|
+
.progress-text { font-size: 11.5px; color: var(--muted-fg); font-variant-numeric: tabular-nums; }
|
|
286
|
+
.job-done-line { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
|
|
287
|
+
.below { margin-top: 8px; display: grid; gap: 5px; }
|
|
206
288
|
|
|
207
289
|
.hint { font-size: 12px; color: var(--muted-fg); margin: 0; }
|
|
208
|
-
.
|
|
209
|
-
|
|
210
|
-
|
|
290
|
+
.refresh-banner {
|
|
291
|
+
display: flex; align-items: center; gap: 8px;
|
|
292
|
+
margin: 0 0 10px; padding: 7px 11px; border-radius: 8px;
|
|
293
|
+
background: var(--primary-soft); color: var(--primary);
|
|
294
|
+
border: 1px solid color-mix(in srgb, var(--primary) 28%, var(--border));
|
|
295
|
+
font-size: 12px; font-weight: 500;
|
|
296
|
+
}
|
|
297
|
+
.busy-note { display: flex; gap: 8px; align-items: flex-start; margin: 0 0 12px; padding: 10px 12px; border-radius: 8px; background: var(--warn-soft); color: var(--fg); border: 1px solid color-mix(in srgb, var(--warn) 28%, var(--border)); }
|
|
298
|
+
.search-field { display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 10px; margin: 8px 0; color: var(--muted-fg); background: var(--bg); border: 1px solid var(--border); border-radius: 8px; transition: border-color .15s, box-shadow .15s; }
|
|
299
|
+
.search-field input { flex: 1; border: 0; outline: 0; background: none; color: var(--fg); font: inherit; font-size: 12px; min-width: 0; }
|
|
211
300
|
.search-field input::placeholder { color: var(--muted-fg); opacity: 1; }
|
|
212
|
-
.search-field:focus-within { border-
|
|
213
|
-
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12px; }
|
|
301
|
+
.search-field:focus-within { border-color: var(--primary); box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 18%, transparent); }
|
|
302
|
+
.mono { font-family: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace; font-size: 12px; }
|
|
214
303
|
.row-desc .mono { overflow-wrap: anywhere; }
|
|
215
|
-
.
|
|
216
|
-
.file { display: flex; flex-direction: column; gap: 4px; border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; }
|
|
217
|
-
.file.too-big { opacity: .45; }
|
|
218
|
-
.file .top, .file .bottom { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
|
|
219
|
-
.file .size { font-size: 11px; color: var(--muted-fg); }
|
|
220
|
-
.status-line { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted-fg); margin: 6px 0; }
|
|
304
|
+
.status-line { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted-fg); margin: 8px 0; }
|
|
221
305
|
|
|
222
306
|
/* Tooltip (Tip) */
|
|
223
307
|
[data-tip] { position: relative; }
|
|
224
308
|
.tip {
|
|
225
309
|
position: fixed; z-index: 50; max-width: 280px; pointer-events: none;
|
|
226
|
-
padding: 6px
|
|
227
|
-
background:
|
|
310
|
+
padding: 6px 9px; border-radius: 7px; font-size: 11.5px; line-height: 1.45;
|
|
311
|
+
background: var(--tip-bg); color: var(--tip-fg);
|
|
312
|
+
border: 1px solid var(--tip-border);
|
|
313
|
+
box-shadow: 0 8px 24px rgba(0, 0, 0, .26);
|
|
228
314
|
opacity: 0; transition: opacity .12s; overflow-wrap: anywhere;
|
|
229
315
|
}
|
|
230
316
|
.tip.show { opacity: 1; }
|
|
231
317
|
|
|
232
318
|
/* Toasts */
|
|
233
|
-
.toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 8px; z-index: 60; }
|
|
234
|
-
.toast {
|
|
235
|
-
|
|
319
|
+
.toasts { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 8px; z-index: 60; max-width: calc(100vw - 32px); }
|
|
320
|
+
.toast {
|
|
321
|
+
display: flex; align-items: flex-start; gap: 10px;
|
|
322
|
+
min-width: 240px; max-width: 380px; padding: 10px 12px; border-radius: 9px;
|
|
323
|
+
background: var(--card); border: 1px solid var(--border); border-left: 3px solid var(--primary);
|
|
324
|
+
box-shadow: var(--shadow-lg); font-size: 12px;
|
|
325
|
+
}
|
|
326
|
+
.toast--success { border-left-color: var(--success); }
|
|
327
|
+
.toast--error { border-left-color: var(--danger); }
|
|
328
|
+
.toast-body { flex: 1; min-width: 0; overflow-wrap: anywhere; }
|
|
329
|
+
.toast b { display: block; font-weight: 600; margin-bottom: 2px; color: var(--fg); }
|
|
330
|
+
.toast--error b { color: var(--danger); }
|
|
331
|
+
.toast-close {
|
|
332
|
+
display: inline-flex; align-items: center; justify-content: center;
|
|
333
|
+
width: 20px; height: 20px; padding: 0; border: 0; border-radius: 5px;
|
|
334
|
+
background: transparent; color: var(--muted-fg); cursor: pointer; flex-shrink: 0;
|
|
335
|
+
}
|
|
336
|
+
.toast-close:hover { background: var(--nav-hover); color: var(--fg); }
|
|
236
337
|
|
|
237
338
|
/* Devices (localmodels extension) */
|
|
238
339
|
.devices { display: flex; flex-wrap: wrap; gap: 8px; }
|
|
239
|
-
.device { display:
|
|
340
|
+
.device-item { display: inline-flex; align-items: stretch; gap: 0; max-width: 100%; }
|
|
341
|
+
.device-item .device { border-top-right-radius: 0; border-bottom-right-radius: 0; }
|
|
342
|
+
.device-remove-btn {
|
|
343
|
+
display: inline-flex; align-items: center; justify-content: center;
|
|
344
|
+
padding: 0 9px; border: 1px solid var(--border); border-left: 0;
|
|
345
|
+
border-radius: 0 8px 8px 0; background: var(--card-2); color: var(--muted-fg);
|
|
346
|
+
font-size: 11.5px; cursor: pointer; white-space: nowrap;
|
|
347
|
+
transition: background .15s, color .15s;
|
|
348
|
+
}
|
|
349
|
+
.device-remove-btn:hover:not(:disabled) { background: var(--danger-soft); color: var(--danger); }
|
|
350
|
+
.device-remove-btn:disabled { opacity: .5; cursor: not-allowed; }
|
|
351
|
+
.device {
|
|
352
|
+
display: grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: center;
|
|
353
|
+
min-width: 190px; max-width: 300px; padding: 8px 12px;
|
|
354
|
+
border: 1px solid var(--border); border-radius: 8px; background: var(--card-2);
|
|
355
|
+
cursor: pointer; text-align: left; transition: background .15s, border-color .15s;
|
|
356
|
+
}
|
|
240
357
|
.device:hover { background: var(--nav-hover); }
|
|
241
|
-
.device.active { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary) inset; }
|
|
358
|
+
.device.active { border-color: var(--primary); background: color-mix(in srgb, var(--primary-soft) 50%, var(--card)); box-shadow: 0 0 0 1px var(--primary) inset; }
|
|
242
359
|
.device svg { grid-row: span 2; color: var(--muted-fg); }
|
|
243
|
-
.device
|
|
360
|
+
.device.active svg { color: var(--primary); }
|
|
361
|
+
.device-name { font-weight: 550; }
|
|
244
362
|
.device-meta { font-size: 11px; color: var(--muted-fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
245
|
-
.
|
|
246
|
-
|
|
247
|
-
|
|
363
|
+
.device-confirm-bar {
|
|
364
|
+
display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px;
|
|
365
|
+
margin-top: 10px; padding: 9px 12px; border-radius: 8px;
|
|
366
|
+
background: var(--danger-soft); border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--border));
|
|
367
|
+
font-size: 12px; color: var(--fg);
|
|
368
|
+
}
|
|
369
|
+
.device-confirm-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
|
|
370
|
+
.add-panel { margin-top: 12px; padding: 12px 14px; border: 1px dashed var(--stroke); border-radius: 9px; background: var(--card-2); }
|
|
371
|
+
.add-form { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
|
|
372
|
+
.add-form input, .plan-form input, .plan-form select {
|
|
373
|
+
flex: 1; height: 30px; padding: 0 9px; border: 1px solid var(--stroke); border-radius: 7px;
|
|
374
|
+
background: var(--card); color: var(--fg); font: inherit; font-size: 12px; min-width: 0;
|
|
375
|
+
}
|
|
376
|
+
.add-error { margin: 8px 0; }
|
|
377
|
+
.discover-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 6px 0 4px; font-size: 11.5px; color: var(--muted-fg); }
|
|
378
|
+
.discover-empty { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border-radius: 7px; background: var(--card); border: 1px solid var(--border); font-size: 12px; color: var(--text-secondary); margin-top: 6px; }
|
|
248
379
|
.candidates { display: grid; gap: 2px; max-height: 260px; overflow-y: auto; }
|
|
249
|
-
.candidate { display: grid; grid-template-columns: minmax(0, 14rem) minmax(0, 1fr) auto; gap: 12px; align-items: center; padding:
|
|
380
|
+
.candidate { display: grid; grid-template-columns: minmax(0, 14rem) minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 4px 0; font-size: 12px; }
|
|
250
381
|
.candidate.offline { opacity: .55; }
|
|
251
382
|
.candidate-meta { color: var(--muted-fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
252
|
-
.gpus { display: grid; gap:
|
|
383
|
+
.gpus { display: grid; gap: 8px; margin-top: 10px; }
|
|
253
384
|
.gpu { display: grid; grid-template-columns: minmax(0, 22rem) 140px auto auto; gap: 12px; align-items: center; font-size: 12px; color: var(--muted-fg); }
|
|
254
385
|
.gpu-name { display: inline-flex; align-items: center; gap: 6px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
255
386
|
.gpu-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
|
|
256
|
-
.gpu-bar { height:
|
|
387
|
+
.gpu-bar { height: 5px; border-radius: 99px; background: var(--muted-bg); overflow: hidden; box-shadow: inset 0 0 0 1px var(--border); }
|
|
257
388
|
.gpu-bar > span { display: block; height: 100%; background: var(--primary); }
|
|
258
389
|
.gpu-bar.busy > span { background: var(--warn); }
|
|
259
390
|
.gpu-meta { font-variant-numeric: tabular-nums; }
|
|
260
391
|
.gpu-meta.warn { color: var(--warn); font-weight: 500; }
|
|
261
392
|
.live-status { color: var(--text-secondary); }
|
|
262
393
|
.error-text { color: var(--danger); font-size: 12px; white-space: pre-wrap; }
|
|
263
|
-
.dialog::backdrop { background: rgba(15, 18, 24, .
|
|
264
|
-
.dialog {
|
|
394
|
+
.dialog::backdrop { background: rgba(15, 18, 24, .42); backdrop-filter: blur(2px); }
|
|
395
|
+
.dialog {
|
|
396
|
+
width: min(760px, calc(100% - 32px)); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px);
|
|
397
|
+
margin: auto; padding: 0; flex-direction: column;
|
|
398
|
+
background: var(--card); color: var(--fg); border: 1px solid var(--border); border-radius: 12px;
|
|
399
|
+
box-shadow: var(--shadow-lg);
|
|
400
|
+
}
|
|
265
401
|
.dialog.dialog-sm { width: min(440px, calc(100% - 32px)); }
|
|
266
402
|
.dialog[open] { display: flex; }
|
|
267
|
-
.dialog-head { display: flex; align-items: center; gap: 8px; padding:
|
|
403
|
+
.dialog-head { display: flex; align-items: center; gap: 8px; padding: 13px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
|
|
268
404
|
.dialog-head b { flex: 1; font-weight: 600; }
|
|
269
|
-
.dialog-body { padding:
|
|
270
|
-
.dialog-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px 16px; padding: 12px 16px; border-top: 1px solid var(--border); }
|
|
405
|
+
.dialog-body { flex: 1 1 auto; min-height: 0; padding: 14px 16px; overflow-y: auto; font-size: 12px; }
|
|
406
|
+
.dialog-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px 16px; padding: 12px 16px; border-top: 1px solid var(--border); flex-shrink: 0; }
|
|
271
407
|
.foot-summary { flex: 1 1 18rem; min-width: 0; margin: 0; padding: 0; list-style: none; display: grid; gap: 2px; font-size: 11.5px; color: var(--text-secondary); }
|
|
272
408
|
.foot-summary li { overflow-wrap: anywhere; }
|
|
273
409
|
.foot-summary .warn { color: var(--warn); }
|
|
274
410
|
.foot-summary .danger { color: var(--danger); font-weight: 500; }
|
|
275
411
|
.foot-actions { display: flex; gap: 8px; margin-left: auto; }
|
|
276
|
-
.stale-hint { margin: 0 0 12px; padding: 8px 12px; border-radius:
|
|
277
|
-
.dialog.stale .dialog-body > :not(.stale-hint), .dialog.stale .foot-summary { opacity: .4; }
|
|
278
|
-
.plan-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; padding: 10px 16px; border-bottom: 1px solid var(--border); font-size: 11.5px; color: var(--text-tertiary); }
|
|
279
|
-
.plan-form label { display: grid; gap: 3px; flex: 1 1
|
|
412
|
+
.stale-hint { margin: 0 0 12px; padding: 8px 12px; border-radius: 8px; background: var(--warn-soft); color: var(--warn); font-size: 12px; font-weight: 500; }
|
|
413
|
+
.dialog.stale .dialog-body > :not(.stale-hint):not(.gate-top), .dialog.stale .foot-summary { opacity: .4; }
|
|
414
|
+
.plan-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--card-2); font-size: 11.5px; color: var(--text-tertiary); flex-shrink: 0; }
|
|
415
|
+
.plan-form label { display: grid; gap: 3px; flex: 1 1 135px; min-width: 0; }
|
|
416
|
+
.plan-form label:has([name="port"]) { flex: 0 1 92px; }
|
|
417
|
+
.plan-form label:has([name="bind"]) { flex: 1.35 1 172px; }
|
|
280
418
|
.plan dl, dl.plan { display: grid; grid-template-columns: 5.5em minmax(0, 1fr); gap: 8px 12px; margin: 0; }
|
|
281
419
|
dl.plan dt { color: var(--muted-fg); }
|
|
282
420
|
dl.plan dd { margin: 0; min-width: 0; }
|
|
283
421
|
dl.plan ul { margin: 0 0 4px; padding-left: 16px; }
|
|
284
|
-
|
|
285
|
-
.
|
|
422
|
+
.plan-file-item .btn.sm { margin-left: 4px; vertical-align: middle; }
|
|
423
|
+
dl.plan pre { margin: 0; white-space: pre-wrap; word-break: break-all; font: 11px/1.5 ui-monospace, Consolas, monospace; background: var(--muted-bg); padding: 6px 8px; border-radius: 6px; }
|
|
424
|
+
.code-box { display: flex; align-items: flex-start; gap: 8px; flex-wrap: wrap; }
|
|
425
|
+
.code-box pre { flex: 1 1 220px; min-width: 0; }
|
|
426
|
+
.warnings { margin: 12px 0 0; padding: 8px 12px; list-style: none; background: var(--warn-soft); color: var(--warn); border-radius: 8px; display: grid; gap: 4px; }
|
|
286
427
|
.warnings li { display: flex; gap: 6px; align-items: center; }
|
|
287
|
-
.gate { margin: 0 0 12px; padding:
|
|
428
|
+
.gate { margin: 0 0 12px; padding: 9px 12px; border-radius: 8px; display: grid; gap: 6px; }
|
|
288
429
|
.gate.warn { background: var(--warn-soft); color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 35%, var(--border)); }
|
|
289
430
|
.gate.danger { background: var(--danger-soft); color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--border)); }
|
|
290
431
|
.gate p { margin: 0; }
|
|
@@ -293,13 +434,51 @@ dl.plan pre { margin: 0; white-space: pre-wrap; word-break: break-all; font: 11p
|
|
|
293
434
|
dl.plan dt.changed { color: var(--warn); font-weight: 600; }
|
|
294
435
|
dl.plan dd.changed { box-shadow: inset 2px 0 var(--warn); padding-left: 8px; }
|
|
295
436
|
@media (max-width: 760px) {
|
|
296
|
-
.
|
|
437
|
+
.window { grid-template-columns: minmax(0, 1fr); }
|
|
438
|
+
.main { min-width: 0; }
|
|
439
|
+
.sidebar { display: none; }
|
|
440
|
+
.btn.mobile-theme-btn { display: inline-flex; }
|
|
441
|
+
.mobile-nav {
|
|
442
|
+
display: flex; align-items: center; gap: 6px;
|
|
443
|
+
padding: 8px 14px; overflow-x: auto; scrollbar-width: none;
|
|
444
|
+
background: color-mix(in srgb, var(--bg) 92%, transparent);
|
|
445
|
+
backdrop-filter: blur(10px);
|
|
446
|
+
border-bottom: 1px solid var(--border);
|
|
447
|
+
position: sticky; top: 0; z-index: 20; flex-shrink: 0;
|
|
448
|
+
}
|
|
449
|
+
.mobile-nav::-webkit-scrollbar { display: none; }
|
|
450
|
+
.mobile-nav-item {
|
|
451
|
+
display: inline-flex; align-items: center; gap: 5px;
|
|
452
|
+
height: 28px; padding: 0 10px; border-radius: 7px;
|
|
453
|
+
border: 1px solid transparent; background: transparent;
|
|
454
|
+
color: var(--text-secondary); font-size: 12px; text-decoration: none;
|
|
455
|
+
white-space: nowrap; flex-shrink: 0; cursor: pointer;
|
|
456
|
+
}
|
|
457
|
+
.mobile-nav-item[aria-current="page"],
|
|
458
|
+
.mobile-nav-item[aria-current="location"] {
|
|
459
|
+
background: var(--card); border-color: var(--border); color: var(--fg); font-weight: 560;
|
|
460
|
+
box-shadow: var(--shadow);
|
|
461
|
+
}
|
|
462
|
+
.mobile-cross-links { display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; }
|
|
463
|
+
.mobile-cross-links:empty { display: none; }
|
|
464
|
+
.mobile-cross-links::before { content: ""; width: 1px; height: 14px; background: var(--border); margin: 0 2px; }
|
|
465
|
+
.scroll { padding: 16px 16px 60px; }
|
|
466
|
+
.section { padding: 14px; }
|
|
467
|
+
.row { grid-template-columns: 1fr; }
|
|
468
|
+
.row-action { justify-content: flex-start; }
|
|
469
|
+
.candidate, .gpu { grid-template-columns: 1fr; gap: 4px; }
|
|
297
470
|
dl.plan { grid-template-columns: 1fr; }
|
|
471
|
+
.dialog { width: calc(100% - 20px); max-height: calc(100vh - 20px); max-height: calc(100dvh - 20px); }
|
|
472
|
+
.plan-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 8px 12px; }
|
|
473
|
+
.plan-form [data-action="replan"] { grid-column: 1 / -1; justify-self: start; }
|
|
474
|
+
.dialog-body { min-height: 150px; padding: 12px; }
|
|
475
|
+
.dialog-foot { padding: 10px 12px; }
|
|
298
476
|
}
|
|
299
477
|
@media (prefers-reduced-motion: reduce) {
|
|
300
478
|
.scroll { scroll-behavior: auto; }
|
|
301
479
|
.spin { animation: none; }
|
|
302
|
-
.progress > div
|
|
480
|
+
.progress.indeterminate > div { animation: none; width: 100%; opacity: .45; transform: none; }
|
|
481
|
+
.progress > div, .tip, .setup-guide-toggle svg, .nav-item, .btn { transition: none; }
|
|
303
482
|
}
|
|
304
483
|
</style>
|
|
305
484
|
</head>
|
|
@@ -320,6 +499,14 @@ dl.plan dd.changed { box-shadow: inset 2px 0 var(--warn); padding-left: 8px; }
|
|
|
320
499
|
</div>
|
|
321
500
|
</aside>
|
|
322
501
|
<main class="main">
|
|
502
|
+
<nav class="mobile-nav" aria-label="页面导航">
|
|
503
|
+
<button type="button" class="mobile-nav-item" data-action="scroll-top" data-nav-top aria-current="location">总览</button>
|
|
504
|
+
<a class="mobile-nav-item" href="#sec-devices">设备</a>
|
|
505
|
+
<a class="mobile-nav-item" href="#sec-models">单模型目录</a>
|
|
506
|
+
<a class="mobile-nav-item" href="#sec-runtime">本地运行时</a>
|
|
507
|
+
<a class="mobile-nav-item" href="#sec-hardware">本机配置</a>
|
|
508
|
+
<span class="mobile-cross-links"></span>
|
|
509
|
+
</nav>
|
|
323
510
|
<div class="scroll">
|
|
324
511
|
<div class="page-head">
|
|
325
512
|
<h1 class="page-title">本地模型设置</h1>
|
|
@@ -343,24 +530,10 @@ dl.plan dd.changed { box-shadow: inset 2px 0 var(--warn); padding-left: 8px; }
|
|
|
343
530
|
// ── Icons (lucide geometry, 24×24 stroke) ──
|
|
344
531
|
const ICONS = {
|
|
345
532
|
chevronRight: '<path d="m9 18 6-6-6-6"/>',
|
|
346
|
-
chevronDown: '<path d="m6 9 6 6 6-6"/>',
|
|
347
533
|
box: '<path d="M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z"/><path d="m3.3 7 8.7 5 8.7-5"/><path d="M12 22V12"/>',
|
|
348
|
-
message: '<path d="M7.9 20A9 9 0 1 0 4 16.1L2 22Z"/>',
|
|
349
|
-
palette: '<circle cx="13.5" cy="6.5" r=".5" fill="currentColor"/><circle cx="17.5" cy="10.5" r=".5" fill="currentColor"/><circle cx="8.5" cy="7.5" r=".5" fill="currentColor"/><circle cx="6.5" cy="12.5" r=".5" fill="currentColor"/><path d="M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z"/>',
|
|
350
534
|
monitor: '<rect width="20" height="14" x="2" y="3" rx="2"/><line x1="8" x2="16" y1="21" y2="21"/><line x1="12" x2="12" y1="17" y2="21"/>',
|
|
351
|
-
lock: '<rect width="18" height="11" x="3" y="11" rx="2" ry="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/>',
|
|
352
|
-
bulb: '<path d="M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5"/><path d="M9 18h6"/><path d="M10 22h4"/>',
|
|
353
|
-
shield: '<path d="M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z"/>',
|
|
354
|
-
brain: '<path d="M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z"/><path d="M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z"/><path d="M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4"/>',
|
|
355
|
-
mic: '<path d="M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z"/><path d="M19 10v2a7 7 0 0 1-14 0v-2"/><line x1="12" x2="12" y1="19" y2="22"/>',
|
|
356
|
-
wrench: '<path d="M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"/>',
|
|
357
|
-
bell: '<path d="M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9"/><path d="M10.3 21a1.94 1.94 0 0 0 3.4 0"/>',
|
|
358
|
-
chart: '<path d="M3 3v18h18"/><path d="M18 17V9"/><path d="M13 17V5"/><path d="M8 17v-3"/>',
|
|
359
535
|
zap: '<path d="M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"/>',
|
|
360
|
-
userCircle: '<circle cx="12" cy="12" r="10"/><circle cx="12" cy="10" r="3"/><path d="M7 20.662V19a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v1.662"/>',
|
|
361
|
-
key: '<circle cx="7.5" cy="15.5" r="5.5"/><path d="m21 2-9.6 9.6"/><path d="m15.5 7.5 3 3L22 7l-3-3"/>',
|
|
362
536
|
cpu: '<rect width="16" height="16" x="4" y="4" rx="2"/><rect width="6" height="6" x="9" y="9" rx="1"/><path d="M15 2v2"/><path d="M15 20v2"/><path d="M2 15h2"/><path d="M2 9h2"/><path d="M20 15h2"/><path d="M20 9h2"/><path d="M9 2v2"/><path d="M9 20v2"/>',
|
|
363
|
-
keyboard: '<path d="M10 8h.01"/><path d="M12 12h.01"/><path d="M14 8h.01"/><path d="M16 12h.01"/><path d="M18 8h.01"/><path d="M6 8h.01"/><path d="M7 16h10"/><path d="M8 12h.01"/><rect width="20" height="16" x="2" y="4" rx="2"/>',
|
|
364
537
|
archive: '<rect width="20" height="5" x="2" y="3" rx="1"/><path d="M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8"/><path d="M10 12h4"/>',
|
|
365
538
|
network: '<rect x="16" y="16" width="6" height="6" rx="1"/><rect x="2" y="16" width="6" height="6" rx="1"/><rect x="9" y="2" width="6" height="6" rx="1"/><path d="M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3"/><path d="M12 12V8"/>',
|
|
366
539
|
grid: '<rect width="7" height="7" x="3" y="3" rx="1"/><rect width="7" height="7" x="14" y="3" rx="1"/><rect width="7" height="7" x="14" y="14" rx="1"/><rect width="7" height="7" x="3" y="14" rx="1"/>',
|
|
@@ -368,18 +541,13 @@ const ICONS = {
|
|
|
368
541
|
search: '<circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/>',
|
|
369
542
|
x: '<path d="M18 6 6 18"/><path d="m6 6 12 12"/>',
|
|
370
543
|
download: '<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" x2="12" y1="15" y2="3"/>',
|
|
371
|
-
upload: '<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" x2="12" y1="3" y2="15"/>',
|
|
372
544
|
refresh: '<path d="M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"/><path d="M21 3v5h-5"/><path d="M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"/><path d="M8 16H3v5"/>',
|
|
373
545
|
checkCircle: '<circle cx="12" cy="12" r="10"/><path d="m9 12 2 2 4-4"/>',
|
|
374
546
|
check: '<path d="M20 6 9 17l-5-5"/>',
|
|
375
547
|
package: '<path d="M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z"/><path d="M12 22V12"/><path d="m3.3 7 7.703 4.734a2 2 0 0 0 1.994 0L20.7 7"/><path d="m7.5 4.27 9 5.15"/>',
|
|
376
|
-
folderOpen: '<path d="m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2"/>',
|
|
377
548
|
loader: '<path d="M21 12a9 9 0 1 1-6.219-8.56"/>',
|
|
378
|
-
pause: '<rect x="14" y="4" width="4" height="16" rx="1"/><rect x="6" y="4" width="4" height="16" rx="1"/>',
|
|
379
|
-
play: '<polygon points="6 3 20 12 6 21 6 3"/>',
|
|
380
549
|
stop: '<rect width="14" height="14" x="5" y="5" rx="2" fill="currentColor"/>',
|
|
381
550
|
trash: '<path d="M3 6h18"/><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"/><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"/>',
|
|
382
|
-
eject: '<path d="M5 18h14"/><path d="M12 5 5 14h14z"/>',
|
|
383
551
|
sun: '<circle cx="12" cy="12" r="4"/><path d="M12 2v2"/><path d="M12 20v2"/><path d="m4.93 4.93 1.41 1.41"/><path d="m17.66 17.66 1.41 1.41"/><path d="M2 12h2"/><path d="M20 12h2"/><path d="m6.34 17.66-1.41 1.41"/><path d="m19.07 4.93-1.41 1.41"/>',
|
|
384
552
|
moon: '<path d="M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"/>',
|
|
385
553
|
copy: '<rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/>'
|
|
@@ -435,7 +603,7 @@ const copy = {
|
|
|
435
603
|
recommended: '推荐',
|
|
436
604
|
noRecommendationTitle: '此设备暂无自动推荐模型',
|
|
437
605
|
noRecommendationDetail: '当前设备事实下没有可自动推荐的模型;不代表其他候选已通过本机验收。可展开目录查看,或在目标设备终端运行完整安装命令检查套件计划。',
|
|
438
|
-
deployAction: s => `部署 · ${s}
|
|
606
|
+
deployAction: s => (s ? `部署 · ${s}` : '部署'),
|
|
439
607
|
pillFitsGpu: '完全在 GPU 上运行',
|
|
440
608
|
pillFitsBusy: '容量够 · 卡上有其他程序',
|
|
441
609
|
pillFitsBusyTip: '按这张卡的总容量能完全放进显存;它现在还跑着其他程序。部署时按当前空闲显存重新计划:放得下时要在计划里确认共用,放不下时计划会说明',
|
|
@@ -481,10 +649,18 @@ const state = {
|
|
|
481
649
|
catalog: null,
|
|
482
650
|
deployments: [],
|
|
483
651
|
loading: false,
|
|
652
|
+
reprobing: false,
|
|
484
653
|
error: null,
|
|
485
654
|
adding: false,
|
|
655
|
+
addingDevice: false,
|
|
656
|
+
addingTarget: '',
|
|
657
|
+
addTargetInput: '',
|
|
658
|
+
addError: null,
|
|
659
|
+
discoverError: null,
|
|
486
660
|
candidates: null,
|
|
487
|
-
|
|
661
|
+
confirmRemoveDevice: null,
|
|
662
|
+
removingDevice: null,
|
|
663
|
+
planning: null, // { model_id, plan_id, plan, options, error, errorTitle, busy, deploying, changed, occupied, share }
|
|
488
664
|
confirmRemove: null, // { name, busy }
|
|
489
665
|
modelQuery: '',
|
|
490
666
|
jobs: {}, // model id -> job
|
|
@@ -554,18 +730,26 @@ function initTheme() {
|
|
|
554
730
|
|
|
555
731
|
// ── Components (primitives.tsx) ──
|
|
556
732
|
function pill(tone, body, tip) {
|
|
557
|
-
|
|
733
|
+
const safeTip = tip ? esc(tip) : ''
|
|
734
|
+
return `<span class="pill ${tone}"${safeTip ? ` data-tip="${safeTip}" title="${safeTip}"` : ''}>${body}</span>`
|
|
558
735
|
}
|
|
559
736
|
|
|
560
737
|
function btn({ variant = 'outline', label = '', iconName, action, arg = '', disabled = false, tip, spin = false, extra = '', attrs = '' }) {
|
|
561
|
-
return `<button class="btn ${variant} ${extra}" data-action="${action}" data-arg="${esc(arg)}"${disabled ? ' disabled' : ''}${tip ? ` data-tip="${esc(tip)}"` : ''}${attrs}>${iconName ? icon(iconName, '', spin ? 'spin' : '') : ''}${label}</button>`
|
|
738
|
+
return `<button type="button" class="btn ${variant} ${extra}" data-action="${action}" data-arg="${esc(arg)}"${disabled ? ' disabled' : ''}${tip ? ` data-tip="${esc(tip)}"` : ''}${attrs}>${iconName ? icon(iconName, '', spin ? 'spin' : '') : ''}${label}</button>`
|
|
562
739
|
}
|
|
563
740
|
|
|
564
|
-
// A tip is also the element's description and shows on keyboard focus
|
|
565
|
-
//
|
|
741
|
+
// A tip is also the element's description and shows on keyboard focus inside dialogs and on controls;
|
|
742
|
+
// read-only pills outside dialogs keep native `title` tooltips without adding redundant tab stops.
|
|
566
743
|
let tipIds = 0
|
|
567
744
|
function describeTips(root) {
|
|
745
|
+
if (!root || typeof root.querySelectorAll !== 'function') return
|
|
568
746
|
root.querySelectorAll('[data-tip]:not([aria-describedby])').forEach(el => {
|
|
747
|
+
const inDialog = Boolean(el.closest?.('[role="dialog"]'))
|
|
748
|
+
const isReadOnlyPill = !inDialog && Boolean(el.classList?.contains('pill'))
|
|
749
|
+
if (isReadOnlyPill) {
|
|
750
|
+
if (!el.getAttribute('title')) el.setAttribute('title', el.dataset.tip)
|
|
751
|
+
return
|
|
752
|
+
}
|
|
569
753
|
const note = document.createElement('span')
|
|
570
754
|
note.id = `tip-${++tipIds}`
|
|
571
755
|
note.hidden = true
|
|
@@ -575,6 +759,7 @@ function describeTips(root) {
|
|
|
575
759
|
if (el.matches('button')) {
|
|
576
760
|
if (!el.textContent.trim()) el.setAttribute('aria-label', el.dataset.tip)
|
|
577
761
|
} else {
|
|
762
|
+
if (inDialog && el.hasAttribute?.('title')) el.removeAttribute('title')
|
|
578
763
|
el.tabIndex = 0
|
|
579
764
|
}
|
|
580
765
|
})
|
|
@@ -585,7 +770,54 @@ function listRow({ title, desc = '', action = '', below = '' }) {
|
|
|
585
770
|
}
|
|
586
771
|
|
|
587
772
|
function section({ iconName, title, meta, aside = '', id = '' }, body) {
|
|
588
|
-
return `<section class="section"${id ? ` id="${id}"` : ''}><
|
|
773
|
+
return `<section class="section"${id ? ` id="${id}"` : ''}><h2 class="section-heading">${icon(iconName)}<span>${esc(title)}</span>${meta ? pill('', esc(meta)) : ''}${aside ? `<span class="aside">${aside}</span>` : ''}</h2>${body}</section>`
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
function selectedHostLabel() {
|
|
777
|
+
const dev = state.devices.find(d => d.id === state.selected)
|
|
778
|
+
return dev?.label || dev?.facts?.hostname || state.catalog?.facts?.hostname || state.selected
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
function sectionTitles() {
|
|
782
|
+
if (!state.selected || state.selected === 'local') {
|
|
783
|
+
return { runtime: copy.runtimeTitle, hardware: copy.hardwareTitle }
|
|
784
|
+
}
|
|
785
|
+
const host = selectedHostLabel()
|
|
786
|
+
return {
|
|
787
|
+
runtime: `运行状态 · ${host}`,
|
|
788
|
+
hardware: `主机配置 · ${host}`
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
function syncSectionNavLabels() {
|
|
793
|
+
if (typeof document === 'undefined' || typeof document.querySelectorAll !== 'function') return
|
|
794
|
+
const titles = sectionTitles()
|
|
795
|
+
for (const [href, text] of [['#sec-runtime', titles.runtime], ['#sec-hardware', titles.hardware]]) {
|
|
796
|
+
document.querySelectorAll(`.nav-list .nav-item[href="${href}"] .label`).forEach(el => {
|
|
797
|
+
el.textContent = text
|
|
798
|
+
if (el.parentElement) el.parentElement.title = text
|
|
799
|
+
})
|
|
800
|
+
document.querySelectorAll(`.mobile-nav .mobile-nav-item[href="${href}"]`).forEach(el => {
|
|
801
|
+
el.textContent = text
|
|
802
|
+
})
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
function shortenGpuName(name) {
|
|
807
|
+
return String(name || 'GPU').replace(/^NVIDIA (GeForce )?/i, '').trim() || 'GPU'
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
function formatGpuSummary(gpus) {
|
|
811
|
+
const counts = new Map()
|
|
812
|
+
for (const g of gpus) {
|
|
813
|
+
const short = shortenGpuName(g?.name)
|
|
814
|
+
counts.set(short, (counts.get(short) || 0) + 1)
|
|
815
|
+
}
|
|
816
|
+
return [...counts.entries()].map(([name, count]) => count > 1 ? `${count}× ${name}` : name).join(' + ')
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
function serviceBusyKey(devId, name) {
|
|
820
|
+
return `${devId}:${name}`
|
|
589
821
|
}
|
|
590
822
|
|
|
591
823
|
// ── Sections ──
|
|
@@ -604,45 +836,92 @@ function setupGuide() {
|
|
|
604
836
|
<p>本页只部署一个模型,不会安装完整套件。首次使用、希望装好后直接开始任务?请在<strong>要安装的设备终端</strong>运行:</p>
|
|
605
837
|
<div class="install-command"><code class="mono">python3 -m localmodels install</code>${btn({ label: '复制完整安装命令', action: 'copy-install' })}</div>
|
|
606
838
|
<p>完整安装:检测设备 → 生成套件计划 → 确认一次 → 安装并验收。最终组件与资源需求以计划为准;复制命令不会执行安装。</p>
|
|
607
|
-
<p>装好后,运行 <code class="mono">python3 -m localmodels stack status</code> 检查各组件状态;运行 <code class="mono">python3 -m localmodels stack clients</code> 查看客户端接入方式。</p>
|
|
839
|
+
<p>装好后,运行 <span class="inline-cmd"><code class="mono">python3 -m localmodels stack status</code>${btn({ variant: 'ghost sm', label: '复制', iconName: 'copy', action: 'copy-cmd', arg: 'python3 -m localmodels stack status', attrs: ' aria-label="复制 stack status 命令"' })}</span> 检查各组件状态;运行 <span class="inline-cmd"><code class="mono">python3 -m localmodels stack clients</code>${btn({ variant: 'ghost sm', label: '复制', iconName: 'copy', action: 'copy-cmd', arg: 'python3 -m localmodels stack clients', attrs: ' aria-label="复制 stack clients 命令"' })}</span> 查看客户端接入方式。</p>
|
|
608
840
|
</div>
|
|
609
841
|
</details>`
|
|
610
842
|
}
|
|
611
843
|
|
|
844
|
+
function activeDeploymentsStrip() {
|
|
845
|
+
const list = state.deployments || []
|
|
846
|
+
if (!list.length) return ''
|
|
847
|
+
const ready = list.filter(r => {
|
|
848
|
+
const live = r.liveState ?? null
|
|
849
|
+
return live === 'running' || (live == null && r.ok)
|
|
850
|
+
})
|
|
851
|
+
const total = list.length
|
|
852
|
+
const summaryPill = ready.length
|
|
853
|
+
? pill('success', `${icon('checkCircle', 'xs')}已就绪 ${ready.length}${ready.length < total ? ` / ${total}` : ''}`)
|
|
854
|
+
: pill(list.some(r => r.liveState === 'failed' || !r.ok) ? 'destructive' : 'warn', `已部署 ${total}(未运行)`)
|
|
855
|
+
const endpoints = ready
|
|
856
|
+
.map(r => {
|
|
857
|
+
const url = r.plan?.endpoint?.base_url
|
|
858
|
+
if (!url) return ''
|
|
859
|
+
const label = r.plan?.model?.display_name || r.plan?.name || ''
|
|
860
|
+
return `<span class="active-strip-ep">${label ? `<span class="active-strip-name">${esc(label)}</span>` : ''}<code class="mono">${esc(url)}</code>${btn({ variant: 'outline sm', label: '复制地址', iconName: 'copy', action: 'copy-endpoint', arg: url })}</span>`
|
|
861
|
+
})
|
|
862
|
+
.filter(Boolean)
|
|
863
|
+
.join('')
|
|
864
|
+
const fallbackNote = !endpoints && !ready.length
|
|
865
|
+
? '<span class="hint">当前服务未运行,可前往运行时区查看状态或开启。</span>'
|
|
866
|
+
: ''
|
|
867
|
+
return `<div class="active-strip${ready.length ? ' is-ready' : ''}" id="active-deployments" role="region" aria-label="当前部署摘要">
|
|
868
|
+
<div class="active-strip-main">${summaryPill}${endpoints || fallbackNote}</div>
|
|
869
|
+
<a class="active-strip-link" href="#sec-runtime">查看详情 →</a>
|
|
870
|
+
</div>`
|
|
871
|
+
}
|
|
872
|
+
|
|
612
873
|
function deviceSection() {
|
|
613
874
|
const chips = state.devices.map(d => {
|
|
614
875
|
const f = d.facts
|
|
615
|
-
const gpus = f?.gpus?.length ?
|
|
876
|
+
const gpus = f?.gpus?.length ? formatGpuSummary(f.gpus) : f ? (f.platform === 'darwin' ? 'Apple 统一内存' : '无独立 GPU') : '未检测'
|
|
616
877
|
const displayLabel = d.id === 'local' && d.label === 'this computer' ? '本机' : d.label
|
|
617
|
-
|
|
878
|
+
const metaText = f ? `${f.hostname} · ${gpus}` : gpus
|
|
879
|
+
const chipBtn = `<button type="button" class="device${d.id === state.selected ? ' active' : ''}" data-action="select-device" data-arg="${esc(d.id)}" aria-pressed="${d.id === state.selected}">
|
|
618
880
|
${icon(d.id === 'local' ? 'monitor' : 'network', 'sm')}
|
|
619
881
|
<span class="device-name">${esc(displayLabel)}</span>
|
|
620
|
-
<span class="device-meta"
|
|
882
|
+
<span class="device-meta" title="${esc(metaText)}">${esc(metaText)}</span>
|
|
621
883
|
</button>`
|
|
884
|
+
if (d.id === 'local') return chipBtn
|
|
885
|
+
return `<div class="device-item">${chipBtn}<button type="button" class="device-remove-btn" data-action="ask-remove-device" data-arg="${esc(d.id)}" aria-label="移除设备 ${esc(displayLabel)}"${state.removingDevice === d.id ? ' disabled' : ''}>移除</button></div>`
|
|
622
886
|
}).join('')
|
|
623
887
|
let body = `<div class="devices">${chips}</div>`
|
|
888
|
+
const pendingRemove = state.confirmRemoveDevice && state.devices.find(d => d.id === state.confirmRemoveDevice && d.id !== 'local')
|
|
889
|
+
if (pendingRemove) {
|
|
890
|
+
const busy = state.removingDevice === pendingRemove.id
|
|
891
|
+
body += `<div class="device-confirm-bar" role="alert"><span>将从设备列表移除「${esc(pendingRemove.label)}」(不会停止远端主机上正在运行的服务)。</span><div class="device-confirm-actions">${btn({ variant: 'outline', label: copy.cancel, action: 'cancel-remove-device', disabled: busy })}${btn({ variant: 'danger', label: busy ? '移除中…' : '确认移除', iconName: busy ? 'loader' : 'trash', spin: busy, action: 'remove-device', arg: pendingRemove.id, disabled: busy })}</div></div>`
|
|
892
|
+
}
|
|
624
893
|
if (state.adding) body += addDevicePanel()
|
|
625
894
|
const aside = btn({ label: state.adding ? copy.closeAddDevice : copy.addDevice, iconName: state.adding ? 'x' : 'search', action: 'toggle-add', attrs: ` aria-expanded="${state.adding}"` })
|
|
626
895
|
return section({ id: 'sec-devices', iconName: 'network', title: copy.devicesTitle, meta: String(state.devices.length), aside }, body)
|
|
627
896
|
}
|
|
628
897
|
|
|
629
898
|
function addDevicePanel() {
|
|
899
|
+
const busy = Boolean(state.addingDevice)
|
|
630
900
|
let html = `<div class="add-panel"><p class="hint">${copy.addDeviceHint}</p>
|
|
631
901
|
<form class="add-form" data-form="add-device">
|
|
632
|
-
<input name="target" placeholder="${copy.addDevicePlaceholder}" autocomplete="off" required>
|
|
633
|
-
${btn({ variant: 'primary', label: '连接并检测', iconName: 'zap', action: 'submit-add' })}
|
|
902
|
+
<input name="target" value="${esc(state.addTargetInput || '')}" placeholder="${copy.addDevicePlaceholder}" autocomplete="off"${busy ? ' disabled' : ''} required>
|
|
903
|
+
${btn({ variant: 'primary', label: busy ? '连接检测中…' : '连接并检测', iconName: busy ? 'loader' : 'zap', spin: busy, action: 'submit-add', disabled: busy })}
|
|
634
904
|
</form>`
|
|
905
|
+
if (state.addError) {
|
|
906
|
+
html += `<div class="gate danger add-error" role="alert"><b>添加设备失败</b><p>${esc(state.addError)}</p></div>`
|
|
907
|
+
}
|
|
635
908
|
if (state.candidates === null) {
|
|
636
909
|
html += `<p class="status-line">${icon('loader', 'xs', 'spin')}正在发现局域网设备…</p>`
|
|
910
|
+
} else if (state.discoverError) {
|
|
911
|
+
html += `<div class="discover-empty" role="alert"><span>自动发现失败:${esc(state.discoverError)}</span>${btn({ variant: 'outline', label: '重试发现', iconName: 'refresh', action: 'rediscover' })}</div>`
|
|
912
|
+
} else if (!state.candidates.length) {
|
|
913
|
+
html += `<div class="discover-empty"><span>未自动发现候选主机,可在上方直接输入 SSH 别名或 user@host。</span>${btn({ variant: 'ghost', label: '重新扫描', iconName: 'refresh', action: 'rediscover' })}</div>`
|
|
637
914
|
} else {
|
|
638
915
|
const known = new Set(state.devices.map(d => d.target))
|
|
916
|
+
html += `<div class="discover-head"><span>已发现候选主机(${state.candidates.length})</span>${btn({ variant: 'ghost', label: '重新扫描', iconName: 'refresh', action: 'rediscover', disabled: busy })}</div>`
|
|
639
917
|
html += '<div class="candidates">' + state.candidates.map(c => {
|
|
640
918
|
const target = c.ssh_target || c.address
|
|
641
919
|
const added = known.has(target)
|
|
920
|
+
const connecting = busy && state.addingTarget === target
|
|
642
921
|
return `<div class="candidate${c.online === false ? ' offline' : ''}">
|
|
643
922
|
<span class="mono">${esc(c.label)}</span>
|
|
644
|
-
<span class="candidate-meta">${esc(c.address)}${c.port !== 22 ? ':' + c.port : ''} · ${esc(c.sources.join(' + '))}${c.os ? ' · ' + esc(c.os) : ''}${c.online === false ? ' · 离线' : ''}</span>
|
|
645
|
-
${btn({ variant: 'ghost', label: added ? '已添加' : '添加', action: 'add-candidate', arg: JSON.stringify({ target, label: c.label }), disabled: added })}
|
|
923
|
+
<span class="candidate-meta">${esc(c.address)}${c.port !== 22 ? ':' + c.port : ''} · ${esc((c.sources || []).join(' + '))}${c.os ? ' · ' + esc(c.os) : ''}${c.online === false ? ' · 离线' : ''}</span>
|
|
924
|
+
${btn({ variant: 'ghost', label: connecting ? '连接中…' : added ? '已添加' : '添加', iconName: connecting ? 'loader' : undefined, spin: connecting, action: 'add-candidate', arg: JSON.stringify({ target, label: c.label }), disabled: added || busy })}
|
|
646
925
|
</div>`
|
|
647
926
|
}).join('') + '</div>'
|
|
648
927
|
}
|
|
@@ -650,25 +929,32 @@ function addDevicePanel() {
|
|
|
650
929
|
}
|
|
651
930
|
|
|
652
931
|
function runtimeSection(facts, cat) {
|
|
653
|
-
const engines = facts
|
|
654
|
-
const servers = (facts
|
|
655
|
-
const backend = cat.placements[0]?.backend || 'cpu'
|
|
932
|
+
const engines = facts?.engines || []
|
|
933
|
+
const servers = (facts?.llama_servers || []).filter(s => s.verified)
|
|
934
|
+
const backend = cat.placements?.[0]?.backend || 'cpu'
|
|
656
935
|
const aside = state.deployments.some(r => r.ok) ? pill('primary', `已部署 · ${backend}`) : engines.length ? pill('primary', `就绪 · ${backend}`) : ''
|
|
657
936
|
let body = ''
|
|
658
937
|
for (const rec of state.deployments) {
|
|
659
938
|
const p = rec.plan
|
|
660
|
-
const busy = state.serviceBusy[p.name]
|
|
939
|
+
const busy = state.serviceBusy[serviceBusyKey(state.selected, p.name)]
|
|
661
940
|
const status = rec.liveStatus
|
|
662
941
|
const live = rec.liveState ?? null
|
|
663
942
|
const showCopy = p.endpoint?.base_url && (live === 'running' || (live == null && rec.ok))
|
|
664
|
-
const showStart = live === 'stopped' || live == null
|
|
943
|
+
const showStart = live === 'stopped' || live === 'failed' || live == null
|
|
665
944
|
const showStop = live === 'running' || (live == null && rec.ok)
|
|
666
|
-
const startVariant = live === 'stopped' || (live == null && !rec.ok) ? 'primary' : 'outline'
|
|
945
|
+
const startVariant = live === 'stopped' || live === 'failed' || (live == null && !rec.ok) ? 'primary' : 'outline'
|
|
946
|
+
const statusBadge = live === 'failed'
|
|
947
|
+
? pill('destructive', '异常')
|
|
948
|
+
: !rec.ok
|
|
949
|
+
? pill('destructive', '失败')
|
|
950
|
+
: live === 'stopped'
|
|
951
|
+
? pill('warn', '已停止')
|
|
952
|
+
: pill('success', '已就绪')
|
|
667
953
|
const desc = `${esc(p.model.display_name)} · ${esc(p.placement.label)} · ${k(p.launch.window)} 上下文 · <span class="mono">${esc(p.endpoint.base_url)}</span>`
|
|
668
954
|
+ (rec.ok ? '' : `<br><span class="error-text">${esc(rec.error || '部署未完成')}</span>`)
|
|
669
955
|
+ (status ? `<br><span class="live-status">${esc(status)}</span>` : '')
|
|
670
956
|
body += listRow({
|
|
671
|
-
title: `<span class="mono" style="font-weight:500">${esc(p.service.name)}</span>${
|
|
957
|
+
title: `<span class="mono" style="font-weight:500">${esc(p.service.name)}</span>${statusBadge}`,
|
|
672
958
|
desc,
|
|
673
959
|
action: [
|
|
674
960
|
showCopy ? btn({ variant: 'ghost', label: '复制地址', iconName: 'copy', action: 'copy-endpoint', arg: p.endpoint.base_url, disabled: Boolean(busy) }) : '',
|
|
@@ -692,16 +978,21 @@ function runtimeSection(facts, cat) {
|
|
|
692
978
|
: pin.present ? copy.pinnedPresentDetail(pin.tag, pin.backend) : copy.noDeploymentsDetail(pin.tag, pin.backend)
|
|
693
979
|
body += listRow({ title: copy.noDeployments, desc: esc(detail) })
|
|
694
980
|
}
|
|
695
|
-
return section({ id: 'sec-runtime', iconName: 'zap', title:
|
|
981
|
+
return section({ id: 'sec-runtime', iconName: 'zap', title: sectionTitles().runtime, meta: engines[0]?.build || '', aside }, body)
|
|
696
982
|
}
|
|
697
983
|
|
|
698
984
|
function hardwareSection(facts) {
|
|
699
|
-
const
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
985
|
+
const f = facts || {}
|
|
986
|
+
const gpus = f.gpus || []
|
|
987
|
+
let body = ''
|
|
988
|
+
if (state.reprobing) {
|
|
989
|
+
body += `<div class="refresh-banner" role="status" aria-live="polite">${icon('loader', 'xs', 'spin')}<span>正在重新检测设备硬件…</span></div>`
|
|
990
|
+
}
|
|
991
|
+
body += `<div class="hw">
|
|
992
|
+
<span>${icon('box', 'sm')}${esc(f.hostname || '未知主机')} · ${esc(f.os?.distro || f.platform || '未知系统')}</span>
|
|
993
|
+
${f.ram ? `<span>${icon('package', 'sm')}${copy.ram(gb(f.ram.total_bytes))}(可用 ${gb(f.ram.available_bytes)})</span>` : ''}
|
|
994
|
+
${f.nvidia ? `<span>${icon('zap', 'sm')}驱动 ${esc(f.nvidia.driver_version)} · CUDA ${esc(f.nvidia.cuda_version)}</span>` : ''}
|
|
995
|
+
${f.disk?.free_bytes != null ? `<span>${icon('archive', 'sm')}模型目录剩余 ${gb(f.disk.free_bytes)}</span>` : ''}
|
|
705
996
|
</div>`
|
|
706
997
|
if (gpus.length) {
|
|
707
998
|
body += '<div class="gpus">' + gpus.map(g => {
|
|
@@ -714,11 +1005,13 @@ function hardwareSection(facts) {
|
|
|
714
1005
|
<span class="gpu-meta${usedPct >= 85 ? ' warn' : ''}">已用 ${gb(usedBytes)} / ${gb(g.total_bytes)} (${usedPct}%) · 空闲 ${gb(g.free_bytes)}${util != null ? ` · 利用率 ${esc(util)}%` : ''}</span>${busy ? pill('warn', '占用中', '其他进程正在使用这张卡的显存;部署会优先选择空闲卡') : ''}</div>`
|
|
715
1006
|
}).join('') + '</div>'
|
|
716
1007
|
} else {
|
|
717
|
-
body += `<p class="hint">${
|
|
1008
|
+
body += `<p class="hint">${f.gpu_vendor_class === 'apple_silicon' ? '统一内存:按系统内存的 80% 计价' : '未发现 NVIDIA GPU:按 CPU + 内存计价'}</p>`
|
|
718
1009
|
}
|
|
719
|
-
|
|
1010
|
+
const collected = f.collected_at ? new Date(f.collected_at) : null
|
|
1011
|
+
const collectedStr = collected && !Number.isNaN(collected.getTime()) ? collected.toLocaleString() : ''
|
|
1012
|
+
if (collectedStr) body += `<p class="hint" style="margin-top:6px">检测于 ${esc(collectedStr)}</p>`
|
|
720
1013
|
const aside = btn({ variant: 'ghost', label: state.loading ? copy.probing : copy.reprobe, iconName: state.loading ? 'loader' : 'refresh', spin: state.loading, action: 'reprobe', disabled: state.loading })
|
|
721
|
-
return section({ id: 'sec-hardware', iconName: 'monitor', title:
|
|
1014
|
+
return section({ id: 'sec-hardware', iconName: 'monitor', title: sectionTitles().hardware, aside }, body)
|
|
722
1015
|
}
|
|
723
1016
|
|
|
724
1017
|
function jobBelow(job) {
|
|
@@ -731,8 +1024,18 @@ function jobBelow(job) {
|
|
|
731
1024
|
else if (p?.phase === 'loading') text += ' · 正在加载模型'
|
|
732
1025
|
const last = job.events?.filter(e => e.event === 'log').slice(-1)[0]
|
|
733
1026
|
if (job.state === 'error') text = `<span class="error-text">失败(${esc(stepName)}):${esc(job.error || '')}</span>`
|
|
734
|
-
if (job.state === 'done')
|
|
735
|
-
|
|
1027
|
+
if (job.state === 'done') {
|
|
1028
|
+
const url = job.record?.plan?.endpoint?.base_url || ''
|
|
1029
|
+
text = url
|
|
1030
|
+
? `<span class="job-done-line">已就绪 · <span class="mono">${esc(url)}</span>${btn({ variant: 'ghost sm', label: '复制地址', iconName: 'copy', action: 'copy-endpoint', arg: url })}</span>`
|
|
1031
|
+
: '已就绪'
|
|
1032
|
+
}
|
|
1033
|
+
const bar = job.state === 'running'
|
|
1034
|
+
? pct == null
|
|
1035
|
+
? '<div class="progress indeterminate"><div></div></div>'
|
|
1036
|
+
: `<div class="progress"><div style="width:${pct}%"></div></div>`
|
|
1037
|
+
: ''
|
|
1038
|
+
return `<div class="below">${bar}<div class="progress-text">${text}${job.state === 'running' && last ? ` · ${esc(last.message)}` : ''}</div></div>`
|
|
736
1039
|
}
|
|
737
1040
|
|
|
738
1041
|
// The catalog rows price each card's capacity, not its free memory now (budget.placements);
|
|
@@ -744,21 +1047,22 @@ function busyCard(m) {
|
|
|
744
1047
|
|
|
745
1048
|
function catalogRow(m, shared, recommended = false) {
|
|
746
1049
|
const job = state.jobs[m.id]
|
|
747
|
-
const deployed = state.deployments.find(r => r.plan
|
|
1050
|
+
const deployed = state.deployments.find(r => r.plan?.model?.id === m.id && r.ok)
|
|
748
1051
|
let action
|
|
749
1052
|
if (job && job.state === 'running') {
|
|
750
1053
|
action = btn({ label: copy.steps[job.step] || '准备', iconName: 'loader', spin: true, action: 'noop', disabled: true })
|
|
751
1054
|
} else {
|
|
752
|
-
action = (deployed ? pill('primary', `${icon('check')}已部署`, deployed.plan
|
|
1055
|
+
action = (deployed ? pill('primary', `${icon('check')}已部署`, deployed.plan?.endpoint?.base_url) : '')
|
|
753
1056
|
+ (m.status === 'deprecated' ? '' : btn({ variant: recommended ? 'primary' : 'outline', label: copy.deployAction(m.size_label), iconName: 'download', action: 'plan', arg: m.id, disabled: !m.fits }))
|
|
754
1057
|
}
|
|
1058
|
+
const fitTip = [m.quant_reason, m.fit_summary].filter(Boolean).join('。') || undefined
|
|
755
1059
|
const fitPill = !m.fits
|
|
756
1060
|
? pill('destructive', `${icon('cpu')}${copy.fitReasons.get(m.fit_reason) || copy.pillUnavailable}`, m.fit_detail || m.fit_summary)
|
|
757
1061
|
: m.spilled
|
|
758
|
-
? pill('warn', `${icon('cpu')}${copy.pillUsesRam}`,
|
|
1062
|
+
? pill('warn', `${icon('cpu')}${copy.pillUsesRam}`, fitTip)
|
|
759
1063
|
: busyCard(m)
|
|
760
1064
|
? pill('warn', `${icon('cpu')}${copy.pillFitsBusy}`, copy.pillFitsBusyTip)
|
|
761
|
-
: pill('success', `${icon('cpu')}${copy.pillFitsGpu}`,
|
|
1065
|
+
: pill('success', `${icon('cpu')}${copy.pillFitsGpu}`, fitTip)
|
|
762
1066
|
const full = m.fits && m.start_window && m.start_window >= m.native_context
|
|
763
1067
|
const ctxPill = full
|
|
764
1068
|
? pill(m.spilled ? '' : 'success', copy.pillFullContext(m.native_context_label), copy.pillFullContextTip)
|
|
@@ -792,28 +1096,20 @@ function statusPill(m, platform) {
|
|
|
792
1096
|
return pill('warn', copy.pillOtherPlatform(names), copy.pillOtherPlatformTip)
|
|
793
1097
|
}
|
|
794
1098
|
|
|
795
|
-
function
|
|
796
|
-
let body = ''
|
|
1099
|
+
function catalogPartition(cat) {
|
|
797
1100
|
const recommended = cat.facts && cat.models.find(m => m.recommended && m.id === cat.recommendation?.id && m.status !== 'deprecated')
|
|
798
|
-
if (!recommended) {
|
|
799
|
-
body += listRow({ title: copy.noRecommendationTitle, desc: copy.noRecommendationDetail })
|
|
800
|
-
}
|
|
801
|
-
const gpuPlacements = (cat.placements || []).filter(p => p.gpu_indices && p.gpu_indices.length && !p.uma)
|
|
802
|
-
if (gpuPlacements.length && gpuPlacements.every(p => p.busy)) {
|
|
803
|
-
const free = Math.max(...(cat.facts?.gpus || []).map(g => g.free_bytes))
|
|
804
|
-
body += `<p class="hint busy-note">${icon('cpu', 'sm')}${esc(copy.allBusy(gb(free)))}</p>`
|
|
805
|
-
}
|
|
806
1101
|
const rank = m => (m.fits && !m.spilled ? 0 : m.fits ? 1 : 2)
|
|
807
1102
|
const platform = cat.facts?.platform
|
|
808
1103
|
// Deprecated rows sink whatever they fit; otherwise what fits comes first, validated ahead.
|
|
809
1104
|
const key = m => (m.status === 'deprecated' ? 6 : 0) + rank(m) * 2 + Math.min(statusRank(m, platform), 1)
|
|
810
1105
|
const rows = [...cat.models].sort((a, b) => key(a) - key(b))
|
|
811
1106
|
const named = rows.reduce((n, m) => n.set(m.display_name, (n.get(m.display_name) || 0) + 1), new Map())
|
|
812
|
-
if (recommended) {
|
|
813
|
-
body += `<div class="recommended-model"><p class="recommendation-note">此设备的单模型推荐 · 下一步:点击「部署」查看计划,确认后才执行。仅部署此模型不等于完整套件就绪。</p>${catalogRow(recommended, named.get(recommended.display_name) > 1, true)}${cat.recommendation.reason_text ? `<p class="recommendation-note">推荐依据:${esc(cat.recommendation.reason_text)}</p>` : ''}</div>`
|
|
814
|
-
}
|
|
815
|
-
const query = (state.modelQuery || '').trim().toLowerCase()
|
|
816
1107
|
const alternatives = rows.filter(m => m !== recommended)
|
|
1108
|
+
return { recommended, named, alternatives }
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
function alternativeRowsHtml(cat, partition = catalogPartition(cat)) {
|
|
1112
|
+
const query = (state.modelQuery || '').trim().toLowerCase()
|
|
817
1113
|
const matches = m => !query || [
|
|
818
1114
|
m.id,
|
|
819
1115
|
m.display_name,
|
|
@@ -822,23 +1118,58 @@ function modelsSection(cat) {
|
|
|
822
1118
|
m.fit_summary,
|
|
823
1119
|
m.quant_reason
|
|
824
1120
|
].some(v => v && String(v).toLowerCase().includes(query))
|
|
825
|
-
const filtered = alternatives.filter(matches)
|
|
1121
|
+
const filtered = partition.alternatives.filter(matches)
|
|
1122
|
+
return filtered.length
|
|
1123
|
+
? `<div class="rows">${filtered.map(m => catalogRow(m, partition.named.get(m.display_name) > 1)).join('')}</div>`
|
|
1124
|
+
: '<p class="hint">未找到匹配的模型。</p>'
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
|
+
function modelsSection(cat) {
|
|
1128
|
+
let body = ''
|
|
1129
|
+
const partition = catalogPartition(cat)
|
|
1130
|
+
const { recommended, named, alternatives } = partition
|
|
1131
|
+
if (!recommended) {
|
|
1132
|
+
body += listRow({ title: copy.noRecommendationTitle, desc: copy.noRecommendationDetail })
|
|
1133
|
+
}
|
|
1134
|
+
const gpuPlacements = (cat.placements || []).filter(p => p.gpu_indices && p.gpu_indices.length && !p.uma)
|
|
1135
|
+
if (gpuPlacements.length && gpuPlacements.every(p => p.busy)) {
|
|
1136
|
+
const free = Math.max(...(cat.facts?.gpus || []).map(g => g.free_bytes))
|
|
1137
|
+
body += `<p class="hint busy-note">${icon('cpu', 'sm')}${esc(copy.allBusy(gb(free)))}</p>`
|
|
1138
|
+
}
|
|
1139
|
+
if (recommended) {
|
|
1140
|
+
body += `<div class="recommended-model"><p class="recommendation-note">此设备的单模型推荐 · 下一步:点击「部署」查看计划,确认后才执行。仅部署此模型不等于完整套件就绪。</p>${catalogRow(recommended, named.get(recommended.display_name) > 1, true)}${cat.recommendation.reason_text ? `<p class="recommendation-note">推荐依据:${esc(cat.recommendation.reason_text)}</p>` : ''}</div>`
|
|
1141
|
+
}
|
|
1142
|
+
const query = (state.modelQuery || '').trim().toLowerCase()
|
|
826
1143
|
if (alternatives.length) {
|
|
827
1144
|
const searchBox = `<label class="search-field">${icon('search', 'sm')}<input type="search" name="model-query" value="${esc(state.modelQuery || '')}" placeholder="搜索模型名称、量化格式或说明…" aria-label="搜索模型目录"></label>`
|
|
828
|
-
const rowsHtml =
|
|
829
|
-
|
|
830
|
-
: '<p class="hint">未找到匹配的模型。</p>'
|
|
831
|
-
body += `<details class="model-alternatives"${query ? ' open' : ''}><summary>${recommended ? '其他模型与历史条目' : '查看模型目录'}(${alternatives.length})</summary><p class="hint">候选与仅在其他平台验证的条目不代表本机已通过验收。已弃用条目仅供查询,已有部署可在「本地运行时」管理。</p>${searchBox}${rowsHtml}</details>`
|
|
1145
|
+
const rowsHtml = alternativeRowsHtml(cat, partition)
|
|
1146
|
+
body += `<details class="model-alternatives"${query ? ' open' : ''}><summary>${recommended ? '其他模型与历史条目' : '查看模型目录'}(${alternatives.length})</summary><p class="hint">候选与仅在其他平台验证的条目不代表本机已通过验收。已弃用条目仅供查询,已有部署可在「${esc(sectionTitles().runtime)}」管理。</p>${searchBox}<div class="model-alternatives-list">${rowsHtml}</div></details>`
|
|
832
1147
|
}
|
|
833
1148
|
return section({ id: 'sec-models', iconName: 'download', title: copy.modelsTitle, meta: String(cat.models.length) }, body)
|
|
834
1149
|
}
|
|
835
1150
|
|
|
1151
|
+
function validPort(value) {
|
|
1152
|
+
const raw = String(value ?? '').trim()
|
|
1153
|
+
if (!/^\d+$/.test(raw)) return false
|
|
1154
|
+
const n = Number(raw)
|
|
1155
|
+
return Number.isInteger(n) && n >= 1024 && n <= 65535
|
|
1156
|
+
}
|
|
1157
|
+
|
|
836
1158
|
function planOptionsChanged(pl) {
|
|
837
|
-
|
|
1159
|
+
if (!pl.plan || !pl.plannedOptions) return false
|
|
1160
|
+
return Object.keys(pl.options).some(key => {
|
|
1161
|
+
if (key === 'port') {
|
|
1162
|
+
const a = pl.options.port
|
|
1163
|
+
const b = pl.plannedOptions.port
|
|
1164
|
+
if (validPort(a) && validPort(b)) return Number(a) !== Number(b)
|
|
1165
|
+
return String(a ?? '').trim() !== String(b ?? '').trim()
|
|
1166
|
+
}
|
|
1167
|
+
return pl.options[key] !== pl.plannedOptions[key]
|
|
1168
|
+
})
|
|
838
1169
|
}
|
|
839
1170
|
|
|
840
1171
|
function planDeployDisabled(pl) {
|
|
841
|
-
return Boolean(!pl.plan || pl.busy || planOptionsChanged(pl) || (pl.occupied?.length && !pl.share))
|
|
1172
|
+
return Boolean(!pl.plan || pl.busy || !validPort(pl.options?.port) || planOptionsChanged(pl) || (pl.occupied?.length && !pl.share))
|
|
842
1173
|
}
|
|
843
1174
|
|
|
844
1175
|
// What confirming does, beside the button: the TUI's confirmation lines from the same plan
|
|
@@ -846,12 +1177,14 @@ function planDeployDisabled(pl) {
|
|
|
846
1177
|
function planSummary(pl) {
|
|
847
1178
|
const p = pl.plan
|
|
848
1179
|
if (!p) return ''
|
|
849
|
-
const s = p.service
|
|
1180
|
+
const s = p.service || {}
|
|
850
1181
|
const lines = [
|
|
851
|
-
['', `下载 ${gb(p.model.download_bytes)}(${p.files.length} 个文件,已校验的跳过)`]
|
|
852
|
-
['', `写入 ${s.deploy_dir},服务 ${s.name}`],
|
|
853
|
-
['', `启动 ${s.kind} 服务,监听 ${s.bind}:${s.port}`]
|
|
1182
|
+
['', `下载 ${gb(p.model.download_bytes)}(${(p.files || []).length} 个文件,已校验的跳过)`]
|
|
854
1183
|
]
|
|
1184
|
+
if (s.deploy_dir) lines.push(['', `写入 ${s.deploy_dir},服务 ${s.name}`])
|
|
1185
|
+
else if (s.name) lines.push(['', `服务 ${s.name}`])
|
|
1186
|
+
const listen = s.bind != null && s.port != null ? `${s.bind}:${s.port}` : (p.endpoint?.base_url || '')
|
|
1187
|
+
if (s.kind && listen) lines.push(['', `启动 ${s.kind} 服务,监听 ${listen}`])
|
|
855
1188
|
const native = state.catalog?.models?.find(m => m.id === pl.model_id)?.native_context
|
|
856
1189
|
if (native && p.launch.window < native) lines.push(['warn', `上下文 ${k(p.launch.window)}(模型最高 ${k(native)})`])
|
|
857
1190
|
if (p.launch.spilled) lines.push(['warn', `${gb(p.launch.spill_bytes)} 权重放到系统内存,解码更慢`])
|
|
@@ -870,23 +1203,29 @@ function planDialog() {
|
|
|
870
1203
|
const conflict = pl.conflict
|
|
871
1204
|
body = `<div class="gate warn" role="alert"><b>当前显卡有其他服务</b>
|
|
872
1205
|
<span>可换空闲显卡;如确需共用,先在“位置”选择具体显卡,点击“重新计划”,再按批准流程确认共用。生成计划不代表已授权,不会停止已有服务。</span>
|
|
873
|
-
<b>${esc(conflict.label)}</b><ul>${conflict.occupants.map(occupant => `<li>${esc(occupant)}</li>`).join('')}</ul>
|
|
874
|
-
${conflict.gpus.map(gpu => `<span>GPU ${esc(gpu.index)} · ${esc(gpu.name)} · 已用 ${gb(gpu.used_bytes)} · 可用 ${gb(gpu.free_bytes)} · 总计 ${gb(gpu.total_bytes)}</span>`).join('')}
|
|
875
|
-
<span>来源:本次计划的主机检测(${esc(conflict.collected_at)});重新计划时会再次检查。</span></div>
|
|
1206
|
+
<b>${esc(conflict.label)}</b><ul>${(conflict.occupants || []).map(occupant => `<li>${esc(occupant)}</li>`).join('')}</ul>
|
|
1207
|
+
${(conflict.gpus || []).map(gpu => `<span>GPU ${esc(gpu.index)} · ${esc(gpu.name)} · 已用 ${gb(gpu.used_bytes)} · 可用 ${gb(gpu.free_bytes)} · 总计 ${gb(gpu.total_bytes)}</span>`).join('')}
|
|
1208
|
+
<span>来源:本次计划的主机检测(${esc(conflict.collected_at || '未知时间')});重新计划时会再次检查。</span></div>
|
|
876
1209
|
<details><summary>原始诊断</summary><p class="error-text">${esc(pl.error)}</p></details>`
|
|
877
1210
|
} else {
|
|
878
|
-
body = `<div class="gate danger" role="alert"><b
|
|
1211
|
+
body = `<div class="gate danger" role="alert"><b>${esc(pl.errorTitle || '无法生成部署计划')}</b><p>${esc(pl.error)}</p></div>`
|
|
879
1212
|
}
|
|
880
1213
|
} else {
|
|
881
1214
|
const p = pl.plan
|
|
882
1215
|
const changed = pl.changed || []
|
|
883
1216
|
const mark = (...keys) => keys.some(key => changed.includes(key)) ? ' class="changed"' : ''
|
|
884
1217
|
const row = (keys, label, value) => `<dt${mark(...keys)}>${label}</dt><dd${mark(...keys)}>${value}</dd>`
|
|
885
|
-
const
|
|
1218
|
+
const planFiles = p.files || []
|
|
1219
|
+
const files = planFiles.map(f => `<li class="plan-file-item"><span class="mono">${esc(f.local_name)}</span> · ${gb(f.size_bytes)}${f.sha256 ? ` · <span class="mono" data-tip="${esc(f.sha256)}">sha256 ${esc(f.sha256.slice(0, 12))}…</span>${btn({ variant: 'ghost sm', label: '复制 SHA256', iconName: 'copy', action: 'copy-sha256', arg: f.sha256, attrs: ` aria-label="复制 SHA256(${esc(f.local_name)})"` })}` : ''}</li>`).join('')
|
|
1220
|
+
let fileOrigin = ''
|
|
1221
|
+
try { if (planFiles[0]?.url) fileOrigin = new URL(planFiles[0].url).origin } catch { /* ignore invalid url */ }
|
|
886
1222
|
const engine = p.engine.source === 'release'
|
|
887
1223
|
? `llama.cpp ${esc(p.engine.build)}(${esc(p.engine.backend)}${p.engine.min_cuda ? ' · CUDA ' + esc(p.engine.min_cuda) : ''})官方预编译包,SHA256 固定`
|
|
888
1224
|
: `复用 <span class="mono">${esc(p.engine.binary)}</span>`
|
|
889
1225
|
body = ''
|
|
1226
|
+
if (pl.error) {
|
|
1227
|
+
body += `<div class="gate danger gate-top" role="alert"><b>${esc(pl.errorTitle || '部署失败')}</b><p>${esc(pl.error)}</p></div>`
|
|
1228
|
+
}
|
|
890
1229
|
if (changed.length) {
|
|
891
1230
|
body += `<div class="gate warn"><b>${esc(pl.refusal)}</b><span>${copy.planChanged}${changed.map(key => `<span class="mono">${esc(key)}</span>(${esc(copy.planKeys[key] || key)})`).join('、')}</span></div>`
|
|
892
1231
|
}
|
|
@@ -894,46 +1233,57 @@ function planDialog() {
|
|
|
894
1233
|
body += `<div class="gate danger" role="alert"><b>${pl.occupiedAt === 'plan' ? copy.gpuOccupiedAtPlan : copy.gpuOccupied}</b><ul>${pl.occupied.map(b => `<li>${esc(b)}</li>`).join('')}</ul>
|
|
895
1234
|
<label><input type="checkbox" data-action="toggle-share"${pl.share ? ' checked' : ''}>${copy.shareConsent}</label></div>`
|
|
896
1235
|
}
|
|
1236
|
+
const placementGpus = p.placement?.gpus || []
|
|
1237
|
+
const launchReasons = p.launch?.reasons || []
|
|
1238
|
+
const serviceArgv = p.service?.argv || []
|
|
1239
|
+
const fullCmd = serviceArgv.join(' ')
|
|
1240
|
+
const launchHtml = `<div class="code-box"><pre>${esc(serviceArgv.slice(1).join(' '))}</pre>${fullCmd ? btn({ variant: 'ghost sm', label: '复制命令', iconName: 'copy', action: 'copy-cmd', arg: fullCmd }) : ''}</div>`
|
|
1241
|
+
const warnings = p.warnings || []
|
|
897
1242
|
body += `<dl class="plan">
|
|
898
1243
|
<dt>主机</dt><dd>${esc(p.hostname)}(${esc(p.host)})</dd>
|
|
899
|
-
${row(['placement'], '位置', `${esc(p.placement.label)}${
|
|
900
|
-
${row(['launch'], '上下文', `${k(p.launch.window)}${p.launch.spilled ? ` · ${gb(p.launch.spill_bytes)} 权重放到系统内存` : ' · 全部在 GPU'} · <span class="hint">${esc(
|
|
1244
|
+
${row(['placement'], '位置', `${esc(p.placement.label)}${placementGpus.length ? ` · <span class="mono">${esc(placementGpus.map(g => g.uuid).join(', '))}</span>` : ''}`)}
|
|
1245
|
+
${row(['launch'], '上下文', `${k(p.launch.window)}${p.launch.spilled ? ` · ${gb(p.launch.spill_bytes)} 权重放到系统内存` : ' · 全部在 GPU'}${launchReasons.length ? ` · <span class="hint">${esc(launchReasons.join(';'))}</span>` : ''}`)}
|
|
901
1246
|
${row(['engine'], '引擎', engine)}
|
|
902
|
-
${row(['model', 'files'], '文件', `<ul>${files}</ul>共 ${gb(p.model.download_bytes)}
|
|
1247
|
+
${row(['model', 'files'], '文件', `<ul>${files}</ul>共 ${gb(p.model.download_bytes)}${fileOrigin ? `,下载源 <span class="mono">${esc(fileOrigin)}</span>` : ''}`)}
|
|
903
1248
|
${row(['service', 'endpoint'], '服务', `${esc(p.service.kind)} · <span class="mono">${esc(p.service.name)}</span> · ${esc(p.endpoint.base_url)}`)}
|
|
904
|
-
${row(['launch', 'service'], '启动参数',
|
|
1249
|
+
${row(['launch', 'service'], '启动参数', launchHtml)}
|
|
905
1250
|
</dl>`
|
|
906
|
-
if (
|
|
907
|
-
if (pl.error) body += `<div class="gate danger" role="alert"><b>部署失败</b><p>${esc(pl.error)}</p></div>`
|
|
1251
|
+
if (warnings.length) body += `<ul class="warnings">${warnings.map(w => `<li>${icon('info', 'xs')}${esc(w)}</li>`).join('')}</ul>`
|
|
908
1252
|
}
|
|
909
1253
|
const o = pl.options
|
|
910
|
-
const placements = state.catalog
|
|
1254
|
+
const placements = state.catalog?.placements || []
|
|
1255
|
+
const deploying = Boolean(pl.deploying)
|
|
1256
|
+
const replanning = Boolean(pl.busy && !deploying)
|
|
1257
|
+
const stale = planOptionsChanged(pl)
|
|
1258
|
+
const formDisabled = deploying ? ' disabled' : ''
|
|
911
1259
|
const form = `<form class="plan-form" data-form="replan">
|
|
912
|
-
<label>位置<select name="placement_id">
|
|
1260
|
+
<label>位置<select name="placement_id"${formDisabled}>
|
|
913
1261
|
<option value="auto"${o.placement_id === 'auto' ? ' selected' : ''}>自动(空闲显存最多)</option>
|
|
914
1262
|
${placements.map(p => `<option value="${esc(p.id)}"${o.placement_id === p.id ? ' selected' : ''}>${esc(p.label)}${p.busy ? '(占用中)' : ''}</option>`).join('')}
|
|
915
1263
|
</select></label>
|
|
916
|
-
<label>端口<input name="port" type="number" min="1024" max="65535" value="${esc(o.port)}"></label>
|
|
917
|
-
<label>监听<select name="bind"><option value="127.0.0.1"${o.bind === '127.0.0.1' ? ' selected' : ''}>仅本机(SSH 隧道访问)</option><option value="0.0.0.0"${o.bind === '0.0.0.0' ? ' selected' : ''}>局域网(API 密钥保护)</option></select></label>
|
|
918
|
-
<label>下载源<select name="hf_download_endpoint"><option value="https://huggingface.co"${o.hf_download_endpoint === 'https://huggingface.co' ? ' selected' : ''}>huggingface.co</option><option value="https://hf-mirror.com"${o.hf_download_endpoint === 'https://hf-mirror.com' ? ' selected' : ''}>hf-mirror.com</option></select></label>
|
|
919
|
-
${btn({ variant: '
|
|
1264
|
+
<label>端口<input name="port" type="number" min="1024" max="65535" value="${esc(o.port)}"${formDisabled}></label>
|
|
1265
|
+
<label>监听<select name="bind"${formDisabled}><option value="127.0.0.1"${o.bind === '127.0.0.1' ? ' selected' : ''}>仅本机(SSH 隧道访问)</option><option value="0.0.0.0"${o.bind === '0.0.0.0' ? ' selected' : ''}>局域网(API 密钥保护)</option></select></label>
|
|
1266
|
+
<label>下载源<select name="hf_download_endpoint"${formDisabled}><option value="https://huggingface.co"${o.hf_download_endpoint === 'https://huggingface.co' ? ' selected' : ''}>huggingface.co</option><option value="https://hf-mirror.com"${o.hf_download_endpoint === 'https://hf-mirror.com' ? ' selected' : ''}>hf-mirror.com</option></select></label>
|
|
1267
|
+
${btn({ variant: stale ? 'primary' : 'outline', label: replanning ? '重新计划中…' : '重新计划', iconName: replanning ? 'loader' : 'refresh', spin: replanning, action: 'replan', disabled: Boolean(pl.busy) })}
|
|
920
1268
|
</form>`
|
|
921
|
-
const stale = planOptionsChanged(pl)
|
|
922
1269
|
return `<dialog class="dialog${stale ? ' stale' : ''}" role="dialog" aria-modal="true" aria-labelledby="plan-title" data-action="close-plan-backdrop">
|
|
923
|
-
<div class="dialog-head">${icon('download')}<b id="plan-title" tabindex="-1">${copy.planTitle} · ${esc(pl.display_name)}</b><button type="button" class="btn ghost icon" data-action="close-plan" aria-label="关闭部署计划">${icon('x')}</button></div>
|
|
1270
|
+
<div class="dialog-head">${icon('download')}<b id="plan-title" tabindex="-1">${copy.planTitle} · ${esc(pl.display_name)}</b><button type="button" class="btn ghost icon" data-action="close-plan" aria-label="关闭部署计划"${deploying ? ' disabled' : ''}>${icon('x')}</button></div>
|
|
924
1271
|
${form}
|
|
925
1272
|
<div class="dialog-body"><p class="stale-hint" role="status" data-plan-options-changed${stale ? '' : ' hidden'}>参数已更改,下面是旧计划;请点击“重新计划”后再确认部署。</p>${body}</div>
|
|
926
|
-
<div class="dialog-foot">${planSummary(pl)}<div class="foot-actions">${btn({ label: copy.cancel, action: 'close-plan' })}${btn({ variant: 'primary lg', label: pl.occupied?.length ? copy.shareAndDeploy : copy.confirmDeploy, iconName: 'zap', action: 'deploy', disabled: planDeployDisabled(pl), attrs: pl.plan ? ' aria-describedby="plan-summary"' : '' })}</div></div>
|
|
1273
|
+
<div class="dialog-foot">${planSummary(pl)}<div class="foot-actions">${btn({ label: copy.cancel, action: 'close-plan', disabled: deploying })}${btn({ variant: 'primary lg', label: deploying ? '部署中…' : (pl.occupied?.length ? copy.shareAndDeploy : copy.confirmDeploy), iconName: deploying ? 'loader' : 'zap', spin: deploying, action: 'deploy', disabled: planDeployDisabled(pl), attrs: pl.plan ? ' aria-describedby="plan-summary"' : '' })}</div></div>
|
|
927
1274
|
</dialog>`
|
|
928
1275
|
}
|
|
929
1276
|
|
|
930
1277
|
function confirmRemoveDialog() {
|
|
931
1278
|
const cr = state.confirmRemove
|
|
932
1279
|
if (!cr) return ''
|
|
1280
|
+
const errBlock = cr.error
|
|
1281
|
+
? `<div class="gate danger" role="alert" style="margin:10px 0 0"><b>移除失败</b><p class="error-text">${esc(cr.error)}</p></div>`
|
|
1282
|
+
: ''
|
|
933
1283
|
return `<dialog class="dialog dialog-sm" role="dialog" aria-modal="true" aria-labelledby="remove-title" data-action="close-remove-backdrop">
|
|
934
1284
|
<div class="dialog-head">${icon('trash')}<b id="remove-title" tabindex="-1">移除部署 · ${esc(cr.name)}</b><button type="button" class="btn ghost icon" data-action="close-remove" aria-label="关闭移除确认"${cr.busy ? ' disabled' : ''}>${icon('x')}</button></div>
|
|
935
|
-
<div class="dialog-body"><p style="margin:0;color:var(--text-secondary)">将停止并移除服务 <span class="mono">${esc(cr.name)}</span>;已下载的模型文件和引擎会保留在主机上。</p
|
|
936
|
-
<div class="dialog-foot"><div class="foot-actions">${btn({ label: copy.cancel, action: 'close-remove', disabled: cr.busy })}${btn({ variant: 'danger lg', label: cr.busy ? '正在移除…' : '确认移除', iconName: cr.busy ? 'loader' : 'trash', spin: cr.busy, action: 'confirm-remove', disabled: cr.busy })}</div></div>
|
|
1285
|
+
<div class="dialog-body"><p style="margin:0;color:var(--text-secondary)">将停止并移除服务 <span class="mono">${esc(cr.name)}</span>;已下载的模型文件和引擎会保留在主机上。</p>${errBlock}</div>
|
|
1286
|
+
<div class="dialog-foot"><div class="foot-actions">${btn({ label: copy.cancel, action: 'close-remove', disabled: cr.busy })}${btn({ variant: 'danger lg', label: cr.busy ? '正在移除…' : (cr.error ? '重试移除' : '确认移除'), iconName: cr.busy ? 'loader' : 'trash', spin: cr.busy, action: 'confirm-remove', disabled: cr.busy })}</div></div>
|
|
937
1287
|
</dialog>`
|
|
938
1288
|
}
|
|
939
1289
|
|
|
@@ -946,6 +1296,7 @@ let removeTrigger = null
|
|
|
946
1296
|
|
|
947
1297
|
function renderPlanDialog() {
|
|
948
1298
|
const root = document.getElementById('dialog-root')
|
|
1299
|
+
if (!root || typeof root.querySelector !== 'function') return
|
|
949
1300
|
const dialog = root.querySelector('dialog')
|
|
950
1301
|
const mode = state.planning ? 'plan' : state.confirmRemove ? 'remove' : null
|
|
951
1302
|
if (!mode) {
|
|
@@ -957,9 +1308,19 @@ function renderPlanDialog() {
|
|
|
957
1308
|
.find(button => button.dataset.arg === planTrigger.modelId && !button.disabled)
|
|
958
1309
|
trigger?.focus()
|
|
959
1310
|
} else if (renderedModal === 'remove' && removeTrigger?.deviceId === state.selected) {
|
|
960
|
-
const trigger =
|
|
961
|
-
.
|
|
962
|
-
|
|
1311
|
+
const trigger = !removeTrigger.succeeded
|
|
1312
|
+
? [...document.querySelectorAll('[data-action="service"]')]
|
|
1313
|
+
.find(button => button.dataset.arg === `${removeTrigger.name}:remove` && !button.disabled)
|
|
1314
|
+
: null
|
|
1315
|
+
if (trigger) {
|
|
1316
|
+
trigger.focus()
|
|
1317
|
+
} else {
|
|
1318
|
+
const runtimeSec = document.getElementById('sec-runtime')
|
|
1319
|
+
if (runtimeSec) {
|
|
1320
|
+
if (!runtimeSec.hasAttribute?.('tabindex')) runtimeSec.setAttribute?.('tabindex', '-1')
|
|
1321
|
+
runtimeSec.focus?.()
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
963
1324
|
}
|
|
964
1325
|
renderedModal = null
|
|
965
1326
|
renderedPlanning = null
|
|
@@ -992,7 +1353,7 @@ function renderPlanDialog() {
|
|
|
992
1353
|
const closeBtn = dialog.querySelector('.dialog-head [data-action="close-remove"]')
|
|
993
1354
|
if (closeBtn) closeBtn.disabled = Boolean(state.confirmRemove.busy)
|
|
994
1355
|
describeTips(dialog)
|
|
995
|
-
if (!dialog.contains(document.activeElement) || document.activeElement
|
|
1356
|
+
if (!dialog.contains(document.activeElement) || document.activeElement?.disabled) {
|
|
996
1357
|
const replacement = focusedAction && dialog.querySelector(`${focusedSection} [data-action="${focusedAction}"]`)
|
|
997
1358
|
if (replacement && !replacement.disabled) replacement.focus()
|
|
998
1359
|
else dialog.querySelector('#remove-title').focus()
|
|
@@ -1019,22 +1380,50 @@ function renderPlanDialog() {
|
|
|
1019
1380
|
for (const selector of ['.dialog-body', '.dialog-foot']) {
|
|
1020
1381
|
dialog.querySelector(selector).replaceChildren(...next.content.querySelector(selector).childNodes)
|
|
1021
1382
|
}
|
|
1022
|
-
|
|
1023
|
-
|
|
1383
|
+
const deploying = Boolean(state.planning.deploying)
|
|
1384
|
+
const replanning = Boolean(state.planning.busy && !deploying)
|
|
1385
|
+
const stale = planOptionsChanged(state.planning)
|
|
1386
|
+
const replanBtn = dialog.querySelector('[data-action="replan"]')
|
|
1387
|
+
if (replanBtn) {
|
|
1388
|
+
replanBtn.disabled = Boolean(state.planning.busy)
|
|
1389
|
+
replanBtn.classList.toggle('primary', stale)
|
|
1390
|
+
replanBtn.classList.toggle('outline', !stale)
|
|
1391
|
+
replanBtn.innerHTML = `${icon(replanning ? 'loader' : 'refresh', '', replanning ? 'spin' : '')}${replanning ? '重新计划中…' : '重新计划'}`
|
|
1392
|
+
}
|
|
1393
|
+
const headClose = dialog.querySelector('.dialog-head [data-action="close-plan"]')
|
|
1394
|
+
if (headClose) headClose.disabled = deploying
|
|
1395
|
+
dialog.querySelectorAll('.plan-form input, .plan-form select').forEach(ctrl => {
|
|
1396
|
+
ctrl.disabled = deploying
|
|
1397
|
+
})
|
|
1398
|
+
dialog.classList.toggle('stale', stale)
|
|
1024
1399
|
describeTips(dialog)
|
|
1025
|
-
if (!dialog.contains(document.activeElement) || document.activeElement
|
|
1400
|
+
if (!dialog.contains(document.activeElement) || document.activeElement?.disabled) {
|
|
1026
1401
|
const replacement = focusedAction && dialog.querySelector(`${focusedSection} [data-action="${focusedAction}"]`)
|
|
1027
1402
|
if (replacement && !replacement.disabled) replacement.focus()
|
|
1028
1403
|
else dialog.querySelector('#plan-title').focus()
|
|
1029
1404
|
}
|
|
1030
1405
|
}
|
|
1031
1406
|
|
|
1407
|
+
function errorCard(message) {
|
|
1408
|
+
return `<div class="error-card" role="alert">
|
|
1409
|
+
<div class="error-card-body">
|
|
1410
|
+
<div class="error-card-title">${icon('info', 'sm')}<span>无法读取或检测设备</span></div>
|
|
1411
|
+
<p class="error-card-msg">${esc(message)}</p>
|
|
1412
|
+
</div>
|
|
1413
|
+
${btn({ variant: 'primary', label: state.loading ? copy.probing : '重试检测', iconName: state.loading ? 'loader' : 'refresh', spin: state.loading, action: 'reprobe', disabled: state.loading })}
|
|
1414
|
+
</div>`
|
|
1415
|
+
}
|
|
1416
|
+
|
|
1032
1417
|
function render() {
|
|
1033
1418
|
const page = document.getElementById('page')
|
|
1034
|
-
const
|
|
1035
|
-
|
|
1419
|
+
const scrollBox = typeof document !== 'undefined' && typeof document.querySelector === 'function'
|
|
1420
|
+
? document.querySelector('.scroll')
|
|
1421
|
+
: null
|
|
1422
|
+
const prevScrollTop = scrollBox && state.catalog ? scrollBox.scrollTop : null
|
|
1423
|
+
const alternativesOpen = page.querySelector?.('.model-alternatives')?.open
|
|
1424
|
+
let html = setupGuide() + activeDeploymentsStrip() + deviceSection()
|
|
1036
1425
|
if (state.error) {
|
|
1037
|
-
html +=
|
|
1426
|
+
html += errorCard(state.error)
|
|
1038
1427
|
}
|
|
1039
1428
|
if (state.catalog) {
|
|
1040
1429
|
const facts = state.catalog.facts
|
|
@@ -1047,9 +1436,13 @@ function render() {
|
|
|
1047
1436
|
const selStart = active && 'selectionStart' in active ? active.selectionStart : null
|
|
1048
1437
|
const selEnd = active && 'selectionEnd' in active ? active.selectionEnd : null
|
|
1049
1438
|
page.innerHTML = html
|
|
1050
|
-
if (alternativesOpen || (state.modelQuery || '').trim()) page.querySelector('.model-alternatives')?.setAttribute('open', '')
|
|
1439
|
+
if (alternativesOpen || (state.modelQuery || '').trim()) page.querySelector?.('.model-alternatives')?.setAttribute('open', '')
|
|
1051
1440
|
describeTips(page)
|
|
1441
|
+
syncSectionNavLabels()
|
|
1052
1442
|
renderPlanDialog()
|
|
1443
|
+
if (scrollBox && prevScrollTop != null && prevScrollTop > 0) {
|
|
1444
|
+
scrollBox.scrollTop = prevScrollTop
|
|
1445
|
+
}
|
|
1053
1446
|
if (focused && !state.planning && !state.confirmRemove) {
|
|
1054
1447
|
const next = document.querySelector(`[name="${focused}"]`)
|
|
1055
1448
|
if (next) {
|
|
@@ -1062,12 +1455,62 @@ function render() {
|
|
|
1062
1455
|
}
|
|
1063
1456
|
|
|
1064
1457
|
// ── Actions ──
|
|
1065
|
-
function toast(message, title = '本地模型') {
|
|
1458
|
+
function toast(message, title = '本地模型', tone = '') {
|
|
1459
|
+
const host = document.getElementById('toasts')
|
|
1460
|
+
if (!host || typeof host.append !== 'function') return
|
|
1066
1461
|
const el = document.createElement('div')
|
|
1067
|
-
|
|
1068
|
-
el.
|
|
1069
|
-
|
|
1070
|
-
|
|
1462
|
+
const isError = tone === 'error'
|
|
1463
|
+
el.className = tone ? `toast toast--${tone}` : 'toast'
|
|
1464
|
+
if (isError) {
|
|
1465
|
+
el.setAttribute('role', 'alert')
|
|
1466
|
+
el.setAttribute('aria-live', 'assertive')
|
|
1467
|
+
}
|
|
1468
|
+
el.innerHTML = `<div class="toast-body"><b>${esc(title)}</b><span>${esc(message)}</span></div><button type="button" class="toast-close" aria-label="关闭通知">${icon('x', 'xs')}</button>`
|
|
1469
|
+
const close = el.querySelector?.('.toast-close')
|
|
1470
|
+
const timer = setTimeout(() => el.remove(), isError ? 8000 : 4200)
|
|
1471
|
+
close?.addEventListener?.('click', () => { clearTimeout(timer); el.remove() })
|
|
1472
|
+
host.append(el)
|
|
1473
|
+
}
|
|
1474
|
+
|
|
1475
|
+
async function copyText(text) {
|
|
1476
|
+
if (typeof navigator !== 'undefined' && navigator.clipboard?.writeText) {
|
|
1477
|
+
try {
|
|
1478
|
+
await navigator.clipboard.writeText(text)
|
|
1479
|
+
return true
|
|
1480
|
+
} catch {
|
|
1481
|
+
// Fall back to execCommand on non-HTTPS LAN origins
|
|
1482
|
+
}
|
|
1483
|
+
}
|
|
1484
|
+
if (typeof document !== 'undefined' && document.body && typeof document.execCommand === 'function') {
|
|
1485
|
+
const area = document.createElement('textarea')
|
|
1486
|
+
area.value = text
|
|
1487
|
+
area.setAttribute('readonly', '')
|
|
1488
|
+
area.style.cssText = 'position:fixed;top:-9999px;left:-9999px;opacity:0'
|
|
1489
|
+
document.body.appendChild(area)
|
|
1490
|
+
area.select()
|
|
1491
|
+
try {
|
|
1492
|
+
return Boolean(document.execCommand('copy'))
|
|
1493
|
+
} catch {
|
|
1494
|
+
return false
|
|
1495
|
+
} finally {
|
|
1496
|
+
area.remove()
|
|
1497
|
+
}
|
|
1498
|
+
}
|
|
1499
|
+
return false
|
|
1500
|
+
}
|
|
1501
|
+
|
|
1502
|
+
function flashCopiedButton(event) {
|
|
1503
|
+
const button = event?.target?.closest?.('button')
|
|
1504
|
+
if (!button || typeof button.innerHTML !== 'string') return
|
|
1505
|
+
if (!button.dataset.origHtml) button.dataset.origHtml = button.innerHTML
|
|
1506
|
+
button.innerHTML = `${icon('check', 'sm')}已复制`
|
|
1507
|
+
button.classList?.add('is-copied')
|
|
1508
|
+
clearTimeout(Number(button.dataset.copyTimer || 0))
|
|
1509
|
+
const timer = setTimeout(() => {
|
|
1510
|
+
if (button.dataset.origHtml) button.innerHTML = button.dataset.origHtml
|
|
1511
|
+
button.classList?.remove('is-copied')
|
|
1512
|
+
}, 1800)
|
|
1513
|
+
button.dataset.copyTimer = String(timer)
|
|
1071
1514
|
}
|
|
1072
1515
|
|
|
1073
1516
|
let loadSeq = 0
|
|
@@ -1089,12 +1532,13 @@ async function loadDevice({ fresh = false } = {}) {
|
|
|
1089
1532
|
loadController = controller
|
|
1090
1533
|
const signal = controller?.signal
|
|
1091
1534
|
const devId = state.selected
|
|
1535
|
+
const hadCatalog = Boolean(state.catalog)
|
|
1092
1536
|
const prevStates = !fresh
|
|
1093
1537
|
? new Map((state.deployments || []).filter(r => r.liveState != null && r.plan?.name).map(r => [r.plan.name, r.liveState]))
|
|
1094
1538
|
: new Map()
|
|
1095
1539
|
state.loading = true
|
|
1540
|
+
state.reprobing = Boolean(fresh && hadCatalog)
|
|
1096
1541
|
state.error = null
|
|
1097
|
-
if (fresh) state.catalog = null
|
|
1098
1542
|
render()
|
|
1099
1543
|
try {
|
|
1100
1544
|
if (fresh) await api(`devices/${encodeURIComponent(devId)}/probe`, { method: 'POST', body: {}, ...(signal ? { signal } : {}) })
|
|
@@ -1108,25 +1552,35 @@ async function loadDevice({ fresh = false } = {}) {
|
|
|
1108
1552
|
state.deployments = deployments.map(r => prevStates.has(r.plan?.name) ? { ...r, liveState: prevStates.get(r.plan.name) } : r)
|
|
1109
1553
|
await loadDevices(signal)
|
|
1110
1554
|
} catch (e) {
|
|
1111
|
-
if (seq === loadSeq && devId === state.selected) {
|
|
1555
|
+
if (seq === loadSeq && devId === state.selected) {
|
|
1556
|
+
state.error = e.message
|
|
1557
|
+
if (!hadCatalog) state.catalog = null
|
|
1558
|
+
else toast(e.message, '重新检测失败', 'error')
|
|
1559
|
+
}
|
|
1112
1560
|
} finally {
|
|
1113
1561
|
if (seq === loadSeq) {
|
|
1114
1562
|
if (loadController === controller) loadController = null
|
|
1115
1563
|
state.loading = false
|
|
1564
|
+
state.reprobing = false
|
|
1116
1565
|
render()
|
|
1117
1566
|
}
|
|
1118
1567
|
}
|
|
1119
1568
|
}
|
|
1120
1569
|
|
|
1121
1570
|
async function makePlan() {
|
|
1571
|
+
const pl = state.planning
|
|
1572
|
+
const options = { ...pl.options }
|
|
1573
|
+
if (!validPort(options.port)) {
|
|
1574
|
+
Object.assign(pl, { busy: false, error: '端口须为 1024–65535 之间的整数。', errorTitle: '端口无效', conflict: null })
|
|
1575
|
+
render()
|
|
1576
|
+
return
|
|
1577
|
+
}
|
|
1122
1578
|
const seq = ++planSeq
|
|
1123
1579
|
planController?.abort()
|
|
1124
1580
|
const controller = typeof AbortController !== 'undefined' ? new AbortController() : null
|
|
1125
1581
|
planController = controller
|
|
1126
1582
|
const signal = controller?.signal
|
|
1127
|
-
|
|
1128
|
-
const options = { ...pl.options }
|
|
1129
|
-
Object.assign(pl, { busy: true, error: null, conflict: null, changed: null, refusal: null, occupied: null, share: false })
|
|
1583
|
+
Object.assign(pl, { busy: true, error: null, errorTitle: null, conflict: null, changed: null, refusal: null, occupied: null, share: false })
|
|
1130
1584
|
render()
|
|
1131
1585
|
try {
|
|
1132
1586
|
const body = { model_id: pl.model_id, ...options, port: Number(options.port) }
|
|
@@ -1152,15 +1606,34 @@ async function makePlan() {
|
|
|
1152
1606
|
}
|
|
1153
1607
|
|
|
1154
1608
|
async function pollJob(modelId, jobId, deviceId) {
|
|
1609
|
+
let failures = 0
|
|
1155
1610
|
for (;;) {
|
|
1156
1611
|
let job
|
|
1157
|
-
try {
|
|
1612
|
+
try {
|
|
1613
|
+
job = await api(`jobs/${jobId}`)
|
|
1614
|
+
failures = 0
|
|
1615
|
+
} catch (e) {
|
|
1616
|
+
failures++
|
|
1617
|
+
if (failures <= 3) {
|
|
1618
|
+
await new Promise(r => setTimeout(r, failures * 1000))
|
|
1619
|
+
continue
|
|
1620
|
+
}
|
|
1621
|
+
const msg = `轮询部署状态失败(已重试 3 次):${e.message}`
|
|
1622
|
+
if (deviceId === state.selected) {
|
|
1623
|
+
const prev = state.jobs[modelId] || {}
|
|
1624
|
+
state.jobs[modelId] = { ...prev, state: 'error', error: msg }
|
|
1625
|
+
render()
|
|
1626
|
+
}
|
|
1627
|
+
toast(msg, '部署状态异常', 'error')
|
|
1628
|
+
return
|
|
1629
|
+
}
|
|
1158
1630
|
if (deviceId === state.selected) {
|
|
1159
1631
|
state.jobs[modelId] = job
|
|
1160
1632
|
render()
|
|
1161
1633
|
}
|
|
1162
1634
|
if (job.state !== 'running') {
|
|
1163
|
-
|
|
1635
|
+
const ok = job.state === 'done'
|
|
1636
|
+
toast(ok ? `${job.name} 已就绪` : `${job.name} 部署失败:${job.error || ''}`, '本地模型', ok ? 'success' : 'error')
|
|
1164
1637
|
if (deviceId === state.selected) loadDevice()
|
|
1165
1638
|
return
|
|
1166
1639
|
}
|
|
@@ -1168,26 +1641,95 @@ async function pollJob(modelId, jobId, deviceId) {
|
|
|
1168
1641
|
}
|
|
1169
1642
|
}
|
|
1170
1643
|
|
|
1644
|
+
async function loadCandidates() {
|
|
1645
|
+
state.candidates = null
|
|
1646
|
+
state.discoverError = null
|
|
1647
|
+
render()
|
|
1648
|
+
try {
|
|
1649
|
+
state.candidates = await api('discover')
|
|
1650
|
+
} catch (e) {
|
|
1651
|
+
state.candidates = []
|
|
1652
|
+
state.discoverError = e.message
|
|
1653
|
+
}
|
|
1654
|
+
render()
|
|
1655
|
+
}
|
|
1656
|
+
|
|
1171
1657
|
const ACTIONS = {
|
|
1172
1658
|
noop() {},
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1659
|
+
'scroll-top'() {
|
|
1660
|
+
if (typeof scrollToTopNav === 'function') scrollToTopNav()
|
|
1661
|
+
},
|
|
1662
|
+
async 'copy-install'(arg, event) {
|
|
1663
|
+
if (await copyText('python3 -m localmodels install')) {
|
|
1664
|
+
flashCopiedButton(event)
|
|
1665
|
+
toast('已复制完整安装命令;请在要安装的设备终端粘贴运行。', '本地模型', 'success')
|
|
1666
|
+
} else {
|
|
1667
|
+
toast('复制失败,请选中上方的完整安装命令手动复制。', '本地模型', 'error')
|
|
1668
|
+
}
|
|
1669
|
+
},
|
|
1670
|
+
async 'copy-cmd'(cmd, event) {
|
|
1671
|
+
if (await copyText(cmd)) {
|
|
1672
|
+
flashCopiedButton(event)
|
|
1673
|
+
toast(`已复制命令:${cmd}`, '本地模型', 'success')
|
|
1674
|
+
} else {
|
|
1675
|
+
toast(`复制失败,请手动复制命令:${cmd}`, '本地模型', 'error')
|
|
1676
|
+
}
|
|
1677
|
+
},
|
|
1678
|
+
async 'copy-sha256'(hash, event) {
|
|
1679
|
+
if (await copyText(hash)) {
|
|
1680
|
+
flashCopiedButton(event)
|
|
1681
|
+
toast(`已复制 SHA256:${hash.slice(0, 12)}…`, '本地模型', 'success')
|
|
1682
|
+
} else {
|
|
1683
|
+
toast('复制 SHA256 失败,请手动复制。', '本地模型', 'error')
|
|
1179
1684
|
}
|
|
1180
1685
|
},
|
|
1181
1686
|
'select-device'(id) {
|
|
1182
1687
|
if (id === state.selected) return
|
|
1183
1688
|
state.selected = id
|
|
1689
|
+
state.confirmRemoveDevice = null
|
|
1184
1690
|
localStorageSet('localmodels.device', id)
|
|
1185
1691
|
state.catalog = null
|
|
1692
|
+
state.reprobing = false
|
|
1186
1693
|
state.deployments = []
|
|
1187
1694
|
state.jobs = {}
|
|
1188
1695
|
state.confirmRemove = null
|
|
1189
1696
|
loadDevice()
|
|
1190
1697
|
},
|
|
1698
|
+
'ask-remove-device'(id) {
|
|
1699
|
+
if (!id || id === 'local') return
|
|
1700
|
+
state.confirmRemoveDevice = state.confirmRemoveDevice === id ? null : id
|
|
1701
|
+
render()
|
|
1702
|
+
},
|
|
1703
|
+
'cancel-remove-device'() {
|
|
1704
|
+
if (state.removingDevice) return
|
|
1705
|
+
state.confirmRemoveDevice = null
|
|
1706
|
+
render()
|
|
1707
|
+
},
|
|
1708
|
+
async 'remove-device'(id) {
|
|
1709
|
+
if (!id || id === 'local' || state.removingDevice) return
|
|
1710
|
+
state.removingDevice = id
|
|
1711
|
+
render()
|
|
1712
|
+
try {
|
|
1713
|
+
await api(`devices/${encodeURIComponent(id)}`, { method: 'DELETE' })
|
|
1714
|
+
state.confirmRemoveDevice = null
|
|
1715
|
+
await loadDevices()
|
|
1716
|
+
if (state.selected === id || !state.devices.some(d => d.id === state.selected)) {
|
|
1717
|
+
state.selected = 'local'
|
|
1718
|
+
localStorageSet('localmodels.device', 'local')
|
|
1719
|
+
state.catalog = null
|
|
1720
|
+
state.reprobing = false
|
|
1721
|
+
state.deployments = []
|
|
1722
|
+
state.jobs = {}
|
|
1723
|
+
await loadDevice()
|
|
1724
|
+
}
|
|
1725
|
+
toast('已移除设备记录(远端主机上的服务未受影响)。', '本地模型', 'success')
|
|
1726
|
+
} catch (e) {
|
|
1727
|
+
toast(e.message, '移除设备失败', 'error')
|
|
1728
|
+
} finally {
|
|
1729
|
+
state.removingDevice = null
|
|
1730
|
+
render()
|
|
1731
|
+
}
|
|
1732
|
+
},
|
|
1191
1733
|
'cycle-theme'() {
|
|
1192
1734
|
const idx = THEME_CYCLE.indexOf(currentTheme())
|
|
1193
1735
|
const next = THEME_CYCLE[(idx + 1) % THEME_CYCLE.length]
|
|
@@ -1196,25 +1738,29 @@ const ACTIONS = {
|
|
|
1196
1738
|
applyTheme(next)
|
|
1197
1739
|
toast(`外观主题已切换为:${THEME_LABEL[next]}`)
|
|
1198
1740
|
},
|
|
1199
|
-
async 'copy-endpoint'(url) {
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
toast(`已复制接口地址:${url}
|
|
1203
|
-
}
|
|
1204
|
-
toast(`复制失败,请手动复制地址:${url}
|
|
1741
|
+
async 'copy-endpoint'(url, event) {
|
|
1742
|
+
if (await copyText(url)) {
|
|
1743
|
+
flashCopiedButton(event)
|
|
1744
|
+
toast(`已复制接口地址:${url}`, '本地模型', 'success')
|
|
1745
|
+
} else {
|
|
1746
|
+
toast(`复制失败,请手动复制地址:${url}`, '本地模型', 'error')
|
|
1205
1747
|
}
|
|
1206
1748
|
},
|
|
1207
1749
|
async 'toggle-add'() {
|
|
1208
1750
|
state.adding = !state.adding
|
|
1751
|
+
state.addError = null
|
|
1209
1752
|
render()
|
|
1210
1753
|
if (state.adding && state.candidates === null) {
|
|
1211
|
-
|
|
1212
|
-
render()
|
|
1754
|
+
await loadCandidates()
|
|
1213
1755
|
}
|
|
1214
1756
|
},
|
|
1757
|
+
async rediscover() {
|
|
1758
|
+
await loadCandidates()
|
|
1759
|
+
},
|
|
1215
1760
|
'submit-add'() {
|
|
1216
1761
|
const input = document.querySelector('[data-form="add-device"] [name="target"]')
|
|
1217
|
-
|
|
1762
|
+
const val = (input?.value ?? state.addTargetInput ?? '').trim()
|
|
1763
|
+
if (val) addDevice(val)
|
|
1218
1764
|
},
|
|
1219
1765
|
'add-candidate'(raw) {
|
|
1220
1766
|
const c = JSON.parse(raw)
|
|
@@ -1224,7 +1770,7 @@ const ACTIONS = {
|
|
|
1224
1770
|
plan(modelId) {
|
|
1225
1771
|
const m = state.catalog.models.find(x => x.id === modelId)
|
|
1226
1772
|
planTrigger = { modelId, deviceId: state.selected }
|
|
1227
|
-
state.planning = { model_id: modelId, display_name: m.display_name, plan: null, plan_id: null, busy: false, error: null,
|
|
1773
|
+
state.planning = { model_id: modelId, display_name: m.display_name, plan: null, plan_id: null, busy: false, deploying: false, error: null, errorTitle: null,
|
|
1228
1774
|
options: { placement_id: 'auto', port: 18100, bind: '127.0.0.1', hf_download_endpoint: 'https://huggingface.co' } }
|
|
1229
1775
|
makePlan()
|
|
1230
1776
|
},
|
|
@@ -1238,6 +1784,7 @@ const ACTIONS = {
|
|
|
1238
1784
|
if (!event?.target || event.target.id !== 'setup-guide') render()
|
|
1239
1785
|
},
|
|
1240
1786
|
'close-plan'() {
|
|
1787
|
+
if (state.planning?.deploying) return
|
|
1241
1788
|
planSeq++
|
|
1242
1789
|
planController?.abort()
|
|
1243
1790
|
planController = null
|
|
@@ -1262,7 +1809,9 @@ const ACTIONS = {
|
|
|
1262
1809
|
const body = { plan_id: pl.plan_id }
|
|
1263
1810
|
if (pl.occupied?.length && pl.share) body.share_gpu = true
|
|
1264
1811
|
pl.busy = true
|
|
1812
|
+
pl.deploying = true
|
|
1265
1813
|
pl.error = null
|
|
1814
|
+
pl.errorTitle = null
|
|
1266
1815
|
render()
|
|
1267
1816
|
try {
|
|
1268
1817
|
const job = await api(`devices/${encodeURIComponent(deviceId)}/deploy`, { method: 'POST', body })
|
|
@@ -1277,9 +1826,11 @@ const ACTIONS = {
|
|
|
1277
1826
|
Object.assign(pl, { occupied: refusal.busy, occupiedAt: 'deploy', share: false, changed: null })
|
|
1278
1827
|
} else {
|
|
1279
1828
|
pl.error = e.message
|
|
1829
|
+
pl.errorTitle = '部署失败'
|
|
1280
1830
|
}
|
|
1281
1831
|
} finally {
|
|
1282
1832
|
pl.busy = false
|
|
1833
|
+
pl.deploying = false
|
|
1283
1834
|
render()
|
|
1284
1835
|
}
|
|
1285
1836
|
},
|
|
@@ -1306,14 +1857,20 @@ const ACTIONS = {
|
|
|
1306
1857
|
async 'confirm-remove'() {
|
|
1307
1858
|
const cr = state.confirmRemove
|
|
1308
1859
|
if (!cr || cr.busy) return
|
|
1860
|
+
const devId = removeTrigger?.deviceId || state.selected
|
|
1309
1861
|
cr.busy = true
|
|
1862
|
+
delete cr.error
|
|
1310
1863
|
render()
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1864
|
+
const result = await runServiceAction(cr.name, 'remove', devId)
|
|
1865
|
+
if (state.confirmRemove !== cr) return
|
|
1866
|
+
cr.busy = false
|
|
1867
|
+
if (result.ok) {
|
|
1868
|
+
if (removeTrigger) removeTrigger.succeeded = true
|
|
1869
|
+
state.confirmRemove = null
|
|
1870
|
+
} else {
|
|
1871
|
+
cr.error = result.error?.message || '移除部署失败'
|
|
1316
1872
|
}
|
|
1873
|
+
render()
|
|
1317
1874
|
}
|
|
1318
1875
|
}
|
|
1319
1876
|
|
|
@@ -1348,44 +1905,61 @@ function inferLiveState(action, res) {
|
|
|
1348
1905
|
if (action === 'status' && res) {
|
|
1349
1906
|
const raw = typeof res.state === 'string' ? res.state.toLowerCase() : ''
|
|
1350
1907
|
if (raw === 'active' || raw === 'running') return 'running'
|
|
1351
|
-
if (raw === '
|
|
1908
|
+
if (raw === 'failed') return 'failed'
|
|
1909
|
+
if (raw === 'inactive' || raw === 'stopped' || raw === 'dead' || raw === 'exited') return 'stopped'
|
|
1352
1910
|
if (typeof res.running === 'boolean') return res.running ? 'running' : 'stopped'
|
|
1353
1911
|
if (typeof res.active === 'boolean') return res.active ? 'running' : 'stopped'
|
|
1354
1912
|
}
|
|
1355
1913
|
return null
|
|
1356
1914
|
}
|
|
1357
1915
|
|
|
1358
|
-
async function runServiceAction(name, action) {
|
|
1359
|
-
|
|
1916
|
+
async function runServiceAction(name, action, devId = state.selected) {
|
|
1917
|
+
const busyKey = serviceBusyKey(devId, name)
|
|
1918
|
+
state.serviceBusy[busyKey] = action
|
|
1360
1919
|
render()
|
|
1361
1920
|
try {
|
|
1362
|
-
const res = await api(`devices/${encodeURIComponent(
|
|
1921
|
+
const res = await api(`devices/${encodeURIComponent(devId)}/deployments/${encodeURIComponent(name)}/${action}`, { method: 'POST', body: {} })
|
|
1363
1922
|
if (res?.event === 'error') throw new Error(res.message)
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1923
|
+
if (state.selected === devId) {
|
|
1924
|
+
const rec = state.deployments.find(r => r.plan?.name === name)
|
|
1925
|
+
if (rec) {
|
|
1926
|
+
rec.liveState = inferLiveState(action, res)
|
|
1927
|
+
if (action === 'status') rec.liveStatus = formatServiceStatus(res)
|
|
1928
|
+
else delete rec.liveStatus
|
|
1929
|
+
}
|
|
1369
1930
|
}
|
|
1370
|
-
if (action !== 'status') toast(`${name}:${{ start: '已启动', stop: '已停止', remove: '已移除' }[action]}
|
|
1371
|
-
if (action !== 'status') await loadDevice()
|
|
1931
|
+
if (action !== 'status') toast(`${name}:${{ start: '已启动', stop: '已停止', remove: '已移除' }[action]}`, '本地模型', 'success')
|
|
1932
|
+
if (action !== 'status' && state.selected === devId) await loadDevice()
|
|
1933
|
+
return { ok: true, res }
|
|
1372
1934
|
} catch (e) {
|
|
1373
|
-
toast(e.message, name)
|
|
1935
|
+
toast(e.message, name, 'error')
|
|
1936
|
+
return { ok: false, error: e }
|
|
1374
1937
|
} finally {
|
|
1375
|
-
delete state.serviceBusy[
|
|
1938
|
+
delete state.serviceBusy[busyKey]
|
|
1376
1939
|
render()
|
|
1377
1940
|
}
|
|
1378
1941
|
}
|
|
1379
1942
|
|
|
1380
1943
|
async function addDevice(target, label) {
|
|
1381
|
-
|
|
1944
|
+
if (state.addingDevice) return
|
|
1945
|
+
state.addingDevice = true
|
|
1946
|
+
state.addingTarget = target
|
|
1947
|
+
state.addError = null
|
|
1948
|
+
render()
|
|
1382
1949
|
try {
|
|
1383
1950
|
const dev = await api('devices', { method: 'POST', body: { target, label } })
|
|
1384
1951
|
await loadDevices()
|
|
1385
1952
|
state.adding = false
|
|
1953
|
+
state.addTargetInput = ''
|
|
1954
|
+
state.addError = null
|
|
1955
|
+
toast(`已添加设备 ${dev.label || target}`, '本地模型', 'success')
|
|
1386
1956
|
ACTIONS['select-device'](dev.id)
|
|
1387
1957
|
} catch (e) {
|
|
1388
|
-
|
|
1958
|
+
state.addError = `${target}:${e.message}`
|
|
1959
|
+
} finally {
|
|
1960
|
+
state.addingDevice = false
|
|
1961
|
+
state.addingTarget = ''
|
|
1962
|
+
render()
|
|
1389
1963
|
}
|
|
1390
1964
|
}
|
|
1391
1965
|
|
|
@@ -1394,15 +1968,41 @@ function updatePlanOptions(event) {
|
|
|
1394
1968
|
const field = event.target
|
|
1395
1969
|
if (!pl || !field.closest('[data-form="replan"]') || !(field.name in pl.options)) return
|
|
1396
1970
|
pl.options[field.name] = field.value
|
|
1397
|
-
|
|
1398
|
-
document.querySelector('[data-
|
|
1399
|
-
|
|
1971
|
+
const stale = planOptionsChanged(pl)
|
|
1972
|
+
const deployBtn = document.querySelector('[data-action="deploy"]')
|
|
1973
|
+
if (deployBtn) deployBtn.disabled = planDeployDisabled(pl)
|
|
1974
|
+
const staleHint = document.querySelector('[data-plan-options-changed]')
|
|
1975
|
+
if (staleHint) staleHint.hidden = !stale
|
|
1976
|
+
const dialog = document.querySelector('#dialog-root dialog')
|
|
1977
|
+
dialog?.classList?.toggle('stale', stale)
|
|
1978
|
+
const replanBtn = document.querySelector('[data-action="replan"]')
|
|
1979
|
+
replanBtn?.classList?.toggle('primary', stale)
|
|
1980
|
+
replanBtn?.classList?.toggle('outline', !stale)
|
|
1981
|
+
}
|
|
1982
|
+
|
|
1983
|
+
let composing = false
|
|
1984
|
+
|
|
1985
|
+
function handleModelQueryChange(value) {
|
|
1986
|
+
state.modelQuery = value
|
|
1987
|
+
const container = typeof document !== 'undefined' && typeof document.querySelector === 'function'
|
|
1988
|
+
? document.querySelector('.model-alternatives-list')
|
|
1989
|
+
: null
|
|
1990
|
+
if (container && state.catalog) {
|
|
1991
|
+
container.innerHTML = alternativeRowsHtml(state.catalog)
|
|
1992
|
+
describeTips(container)
|
|
1993
|
+
return
|
|
1994
|
+
}
|
|
1995
|
+
render()
|
|
1400
1996
|
}
|
|
1401
1997
|
|
|
1402
1998
|
function handleInput(event) {
|
|
1403
1999
|
if (event.target?.name === 'model-query') {
|
|
1404
|
-
|
|
1405
|
-
|
|
2000
|
+
if (event.isComposing || composing) return
|
|
2001
|
+
handleModelQueryChange(event.target.value)
|
|
2002
|
+
return
|
|
2003
|
+
}
|
|
2004
|
+
if (event.target?.name === 'target' && event.target.closest?.('[data-form="add-device"]')) {
|
|
2005
|
+
state.addTargetInput = event.target.value
|
|
1406
2006
|
return
|
|
1407
2007
|
}
|
|
1408
2008
|
updatePlanOptions(event)
|
|
@@ -1422,14 +2022,18 @@ function safeCrossLinkUrl(url) {
|
|
|
1422
2022
|
|
|
1423
2023
|
function renderCrossLinks() {
|
|
1424
2024
|
if (typeof document === 'undefined' || typeof document.querySelector !== 'function') return
|
|
1425
|
-
const foot = document.querySelector('.sidebar-foot')
|
|
1426
|
-
if (!foot) return
|
|
1427
|
-
foot.querySelector('.cross-links')?.remove()
|
|
1428
2025
|
const valid = (state.crossLinks || []).map(item => {
|
|
1429
2026
|
const label = typeof item?.label === 'string' ? item.label.trim() : ''
|
|
1430
2027
|
const url = safeCrossLinkUrl(item?.url)
|
|
1431
2028
|
return label && url ? { label, url } : null
|
|
1432
2029
|
}).filter(Boolean)
|
|
2030
|
+
const mobileCross = document.querySelector('.mobile-cross-links')
|
|
2031
|
+
if (mobileCross) {
|
|
2032
|
+
mobileCross.innerHTML = valid.map(item => `<a class="mobile-nav-item" href="${esc(item.url)}">${esc(item.label)}</a>`).join('')
|
|
2033
|
+
}
|
|
2034
|
+
const foot = document.querySelector('.sidebar-foot')
|
|
2035
|
+
if (!foot) return
|
|
2036
|
+
foot.querySelector('.cross-links')?.remove()
|
|
1433
2037
|
if (!valid.length) return
|
|
1434
2038
|
const nav = document.createElement('nav')
|
|
1435
2039
|
nav.className = 'cross-links'
|
|
@@ -1453,11 +2057,25 @@ async function loadCrossLinks() {
|
|
|
1453
2057
|
} catch { /* served only under web_preview */ }
|
|
1454
2058
|
}
|
|
1455
2059
|
|
|
2060
|
+
document.addEventListener('compositionstart', e => {
|
|
2061
|
+
if (e.target?.name === 'model-query') composing = true
|
|
2062
|
+
})
|
|
2063
|
+
document.addEventListener('compositionend', e => {
|
|
2064
|
+
if (e.target?.name === 'model-query') {
|
|
2065
|
+
composing = false
|
|
2066
|
+
handleModelQueryChange(e.target.value)
|
|
2067
|
+
}
|
|
2068
|
+
})
|
|
1456
2069
|
document.addEventListener('input', handleInput)
|
|
1457
2070
|
document.addEventListener('change', updatePlanOptions)
|
|
1458
2071
|
document.addEventListener('toggle', e => {
|
|
1459
2072
|
if (e.target?.id === 'setup-guide') ACTIONS['toggle-guide'](null, e)
|
|
1460
2073
|
}, true)
|
|
2074
|
+
document.addEventListener('cancel', e => {
|
|
2075
|
+
if (e.target?.tagName === 'DIALOG' && (state.planning?.deploying || state.confirmRemove?.busy)) {
|
|
2076
|
+
e.preventDefault()
|
|
2077
|
+
}
|
|
2078
|
+
}, true)
|
|
1461
2079
|
|
|
1462
2080
|
document.addEventListener('click', e => {
|
|
1463
2081
|
const el = e.target.closest('[data-action]')
|
|
@@ -1496,7 +2114,10 @@ document.addEventListener('keydown', e => {
|
|
|
1496
2114
|
// Tooltip (Tip)
|
|
1497
2115
|
const tipEl = document.getElementById('tip')
|
|
1498
2116
|
function showTip(t) {
|
|
1499
|
-
if (!t
|
|
2117
|
+
if (!t || (t.classList?.contains('pill') && !t.closest('dialog') && t.hasAttribute('title'))) {
|
|
2118
|
+
tipEl.classList.remove('show')
|
|
2119
|
+
return
|
|
2120
|
+
}
|
|
1500
2121
|
// A modal dialog sits in the top layer; a tip for something inside it must live there too.
|
|
1501
2122
|
const layer = t.closest('dialog') || document.body
|
|
1502
2123
|
if (tipEl.parentElement !== layer) layer.append(tipEl)
|
|
@@ -1521,7 +2142,15 @@ document.addEventListener('scroll', () => showTip(null), true)
|
|
|
1521
2142
|
|
|
1522
2143
|
hydrateIcons()
|
|
1523
2144
|
initTheme()
|
|
2145
|
+
const scrollEl = document.querySelector('.scroll')
|
|
1524
2146
|
const navLinks = [...document.querySelectorAll('.nav-list .nav-item')]
|
|
2147
|
+
const mobileNavLinks = [...document.querySelectorAll('.mobile-nav .mobile-nav-item')]
|
|
2148
|
+
const topNavItem = navLinks[0]
|
|
2149
|
+
if (topNavItem) {
|
|
2150
|
+
topNavItem.setAttribute('role', 'button')
|
|
2151
|
+
topNavItem.tabIndex = 0
|
|
2152
|
+
}
|
|
2153
|
+
let spyLockUntil = 0
|
|
1525
2154
|
function syncNavCurrent(targetHash) {
|
|
1526
2155
|
const activeHash = targetHash || location.hash || '#setup-guide'
|
|
1527
2156
|
const matched = navLinks.some(a => a.getAttribute('href') === activeHash)
|
|
@@ -1529,8 +2158,75 @@ function syncNavCurrent(targetHash) {
|
|
|
1529
2158
|
if ((matched && a.getAttribute('href') === activeHash) || (!matched && i === 0)) a.setAttribute('aria-current', 'location')
|
|
1530
2159
|
else a.removeAttribute('aria-current')
|
|
1531
2160
|
})
|
|
2161
|
+
const mobileMatched = mobileNavLinks.some(a => a.getAttribute('href') === activeHash)
|
|
2162
|
+
mobileNavLinks.forEach((a, i) => {
|
|
2163
|
+
if ((mobileMatched && a.getAttribute('href') === activeHash) || (!mobileMatched && i === 0)) a.setAttribute('aria-current', 'location')
|
|
2164
|
+
else a.removeAttribute('aria-current')
|
|
2165
|
+
})
|
|
2166
|
+
}
|
|
2167
|
+
function scrollToTopNav() {
|
|
2168
|
+
spyLockUntil = Date.now() + 500
|
|
2169
|
+
if (location.hash) {
|
|
2170
|
+
try { history.replaceState(null, '', location.pathname + location.search) } catch { /* ignore */ }
|
|
2171
|
+
}
|
|
2172
|
+
const reduced = typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion: reduce)').matches
|
|
2173
|
+
scrollEl?.scrollTo?.({ top: 0, behavior: reduced ? 'auto' : 'smooth' })
|
|
2174
|
+
syncNavCurrent('#setup-guide')
|
|
2175
|
+
}
|
|
2176
|
+
navLinks.forEach((item, i) => {
|
|
2177
|
+
if (i === 0) {
|
|
2178
|
+
item.addEventListener('click', scrollToTopNav)
|
|
2179
|
+
item.addEventListener('keydown', e => {
|
|
2180
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
2181
|
+
e.preventDefault()
|
|
2182
|
+
scrollToTopNav()
|
|
2183
|
+
}
|
|
2184
|
+
})
|
|
2185
|
+
} else {
|
|
2186
|
+
item.addEventListener('click', () => {
|
|
2187
|
+
spyLockUntil = Date.now() + 500
|
|
2188
|
+
syncNavCurrent(item.getAttribute('href'))
|
|
2189
|
+
})
|
|
2190
|
+
}
|
|
2191
|
+
})
|
|
2192
|
+
mobileNavLinks.forEach(item => {
|
|
2193
|
+
if (!item.hasAttribute('data-nav-top')) {
|
|
2194
|
+
item.addEventListener('click', () => {
|
|
2195
|
+
spyLockUntil = Date.now() + 500
|
|
2196
|
+
syncNavCurrent(item.getAttribute('href'))
|
|
2197
|
+
})
|
|
2198
|
+
}
|
|
2199
|
+
})
|
|
2200
|
+
if (scrollEl) {
|
|
2201
|
+
let spyScheduled = false
|
|
2202
|
+
const sectionHashes = ['#sec-devices', '#sec-models', '#sec-runtime', '#sec-hardware']
|
|
2203
|
+
const updateScrollSpy = () => {
|
|
2204
|
+
spyScheduled = false
|
|
2205
|
+
if (Date.now() < spyLockUntil) return
|
|
2206
|
+
if (scrollEl.scrollTop <= 24) {
|
|
2207
|
+
syncNavCurrent('#setup-guide')
|
|
2208
|
+
return
|
|
2209
|
+
}
|
|
2210
|
+
const existing = sectionHashes.map(hash => ({ hash, el: document.querySelector(hash) })).filter(x => x.el)
|
|
2211
|
+
if (!existing.length) return
|
|
2212
|
+
if (scrollEl.scrollTop + scrollEl.clientHeight >= scrollEl.scrollHeight - 16) {
|
|
2213
|
+
syncNavCurrent(existing[existing.length - 1].hash)
|
|
2214
|
+
return
|
|
2215
|
+
}
|
|
2216
|
+
const topEdge = scrollEl.getBoundingClientRect().top
|
|
2217
|
+
let current = '#setup-guide'
|
|
2218
|
+
for (const item of existing) {
|
|
2219
|
+
if (item.el.getBoundingClientRect().top - topEdge <= 96) current = item.hash
|
|
2220
|
+
}
|
|
2221
|
+
syncNavCurrent(current)
|
|
2222
|
+
}
|
|
2223
|
+
scrollEl.addEventListener('scroll', () => {
|
|
2224
|
+
if (!spyScheduled) {
|
|
2225
|
+
spyScheduled = true
|
|
2226
|
+
requestAnimationFrame(updateScrollSpy)
|
|
2227
|
+
}
|
|
2228
|
+
}, { passive: true })
|
|
1532
2229
|
}
|
|
1533
|
-
navLinks.forEach(a => a.addEventListener('click', () => syncNavCurrent(a.getAttribute('href'))))
|
|
1534
2230
|
addEventListener('hashchange', () => syncNavCurrent())
|
|
1535
2231
|
syncNavCurrent()
|
|
1536
2232
|
loadCrossLinks()
|