dsh-plugin-agentdeck 0.0.0-stage → 0.2.0
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/LICENSE +21 -0
- package/README.md +66 -2
- package/cordis.patch.yml +3 -0
- package/icon.svg +7 -0
- package/lib/client.js +911 -0
- package/lib/index.js +366 -0
- package/lib/setup.js +1223 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +69 -4
package/lib/client.js
ADDED
|
@@ -0,0 +1,911 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({
|
|
2
|
+
id: 'dsh-plugin-agentdeck',
|
|
3
|
+
factory: (require) => {
|
|
4
|
+
const module = { exports: {} };
|
|
5
|
+
const exports = module.exports;
|
|
6
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
7
|
+
|
|
8
|
+
const React = require('react');
|
|
9
|
+
const { useCallback, useEffect, useState } = React;
|
|
10
|
+
const h = React.createElement;
|
|
11
|
+
|
|
12
|
+
const NS = 'settings.agentdeck';
|
|
13
|
+
const STYLE_TAG_ID = 'dsh-plugin-agentdeck/styles.css';
|
|
14
|
+
|
|
15
|
+
const STORE_LINKS = {
|
|
16
|
+
appStore: 'https://apps.apple.com/app/id6821905390',
|
|
17
|
+
googlePlay:
|
|
18
|
+
'https://play.google.com/store/apps/details?id=com.mantou.agentdeck',
|
|
19
|
+
apk: 'https://github.com/mantou132/AgentDeck/releases/latest',
|
|
20
|
+
websiteEn: 'https://agentdeck.xianqiao.wang',
|
|
21
|
+
websiteZh: 'https://agentdeck.xianqiao.wang/zh',
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const DICTIONARIES = {
|
|
25
|
+
en: {
|
|
26
|
+
nav: 'AgentDeck',
|
|
27
|
+
title: 'AgentDeck Mobile Remote',
|
|
28
|
+
subtitle:
|
|
29
|
+
'Scan with AgentDeck on iPhone or Android to control DeepSeek Harness remotely — end-to-end encrypted.',
|
|
30
|
+
provisioning: 'Setting up remote control & starting agentdeckd…',
|
|
31
|
+
provisioningHint:
|
|
32
|
+
'First-time setup installs the ACP adapter and local daemon automatically. Your QR code will appear here in a few seconds.',
|
|
33
|
+
errorTitle: 'Automatic setup failed',
|
|
34
|
+
btnRetry: 'Retry Setup',
|
|
35
|
+
qrHint:
|
|
36
|
+
'Open AgentDeck on your phone and scan this QR code to pair. Keep it private — it grants full access to this machine.',
|
|
37
|
+
pairingIdLabel: 'Pairing ID',
|
|
38
|
+
customRelayLabel: 'Relay',
|
|
39
|
+
stoppedBanner:
|
|
40
|
+
'Remote service is currently stopped. Start it below to connect from your phone.',
|
|
41
|
+
serviceTitle: 'Remote Service & Autostart',
|
|
42
|
+
serviceDescRunning: 'Running in background and starts on login.',
|
|
43
|
+
serviceDescStopped: 'Stopped — mobile devices cannot connect.',
|
|
44
|
+
statusRunning: 'Running',
|
|
45
|
+
statusStopped: 'Stopped',
|
|
46
|
+
btnStart: 'Start',
|
|
47
|
+
btnStop: 'Stop',
|
|
48
|
+
btnRestart: 'Restart',
|
|
49
|
+
btnWorking: 'Working…',
|
|
50
|
+
awakeTitle: 'Prevent Automatic Sleep',
|
|
51
|
+
awakeActive: 'Active',
|
|
52
|
+
awakeInactive: 'Inactive',
|
|
53
|
+
awakeNever: 'Off',
|
|
54
|
+
awakePlugged: 'On Power',
|
|
55
|
+
awakeActiveMode: 'Active 1h',
|
|
56
|
+
awakeAlways: 'Always',
|
|
57
|
+
awakeHintNever: 'Let the OS sleep normally.',
|
|
58
|
+
awakeHintPlugged: 'Stay awake while plugged into external power.',
|
|
59
|
+
awakeHintActive: 'Stay awake for 1 hour after the last mobile interaction.',
|
|
60
|
+
awakeHintAlways: 'Always stay awake while the remote service runs.',
|
|
61
|
+
modelTitle: 'Mobile Default Model',
|
|
62
|
+
modelDefault: 'DeepSeek Harness default',
|
|
63
|
+
btnSyncModel: 'Sync current',
|
|
64
|
+
downloadTitle: 'Get AgentDeck',
|
|
65
|
+
linkAppStore: 'App Store',
|
|
66
|
+
linkGooglePlay: 'Google Play',
|
|
67
|
+
linkApk: 'Android APK',
|
|
68
|
+
linkWebsite: 'Website',
|
|
69
|
+
loading: 'Loading…',
|
|
70
|
+
isZh: '0',
|
|
71
|
+
},
|
|
72
|
+
zh: {
|
|
73
|
+
nav: 'AgentDeck 手机远控',
|
|
74
|
+
title: 'AgentDeck 手机远控',
|
|
75
|
+
subtitle:
|
|
76
|
+
'打开手机上的 AgentDeck 扫码即可远程控制 DeepSeek Harness,端到端加密。',
|
|
77
|
+
provisioning: '正在自动配置远程控制并启动服务…',
|
|
78
|
+
provisioningHint:
|
|
79
|
+
'首次安装会自动准备 ACP 适配器与本地守护服务并注册开机自启,完成后二维码会自动出现。',
|
|
80
|
+
errorTitle: '自动初始化失败',
|
|
81
|
+
btnRetry: '重试',
|
|
82
|
+
qrHint:
|
|
83
|
+
'打开手机上的 AgentDeck App 扫描此二维码即可配对。请勿泄露二维码——它代表本机远程访问权限。',
|
|
84
|
+
pairingIdLabel: '配对 ID',
|
|
85
|
+
customRelayLabel: 'Relay',
|
|
86
|
+
stoppedBanner: '远程服务当前已停止,开启下方服务开关后手机即可连接。',
|
|
87
|
+
serviceTitle: '远程服务与开机自启',
|
|
88
|
+
serviceDescRunning: '已在后台运行并开启登录自启。',
|
|
89
|
+
serviceDescStopped: '已停止,手机端暂时无法连接。',
|
|
90
|
+
statusRunning: '运行中',
|
|
91
|
+
statusStopped: '已停止',
|
|
92
|
+
btnStart: '开启',
|
|
93
|
+
btnStop: '停止',
|
|
94
|
+
btnRestart: '重启',
|
|
95
|
+
btnWorking: '处理中…',
|
|
96
|
+
awakeTitle: '防自动休眠',
|
|
97
|
+
awakeActive: '生效中',
|
|
98
|
+
awakeInactive: '未激活',
|
|
99
|
+
awakeNever: '关闭',
|
|
100
|
+
awakePlugged: '插电常亮',
|
|
101
|
+
awakeActiveMode: '活跃 1 小时',
|
|
102
|
+
awakeAlways: '始终常亮',
|
|
103
|
+
awakeHintNever: '跟随系统默认休眠策略。',
|
|
104
|
+
awakeHintPlugged: '接通外接电源时防止电脑自动休眠。',
|
|
105
|
+
awakeHintActive: '最近 1 小时有手机远控交互时保持唤醒。',
|
|
106
|
+
awakeHintAlways: '远程服务运行期间始终防止自动休眠。',
|
|
107
|
+
modelTitle: '手机端默认模型',
|
|
108
|
+
modelDefault: '使用 DSH 默认模型',
|
|
109
|
+
btnSyncModel: '同步当前模型',
|
|
110
|
+
downloadTitle: '下载 AgentDeck',
|
|
111
|
+
linkAppStore: 'App Store',
|
|
112
|
+
linkGooglePlay: 'Google Play',
|
|
113
|
+
linkApk: 'Android APK',
|
|
114
|
+
linkWebsite: '官网',
|
|
115
|
+
loading: '加载中…',
|
|
116
|
+
isZh: '1',
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const CSS_TEXT = `
|
|
121
|
+
.adk-root {
|
|
122
|
+
display: flex;
|
|
123
|
+
flex-direction: column;
|
|
124
|
+
gap: 16px;
|
|
125
|
+
padding: 4px 0 24px;
|
|
126
|
+
color: var(--dsw-alias-label-primary, #111827);
|
|
127
|
+
font-size: 13px;
|
|
128
|
+
line-height: 1.5;
|
|
129
|
+
}
|
|
130
|
+
.adk-title {
|
|
131
|
+
margin: 0 0 4px;
|
|
132
|
+
font-size: 16px;
|
|
133
|
+
font-weight: 600;
|
|
134
|
+
color: var(--dsw-alias-label-primary, #111827);
|
|
135
|
+
}
|
|
136
|
+
.adk-subtitle {
|
|
137
|
+
margin: 0;
|
|
138
|
+
font-size: 13px;
|
|
139
|
+
color: var(--dsw-alias-label-secondary, #4b5563);
|
|
140
|
+
}
|
|
141
|
+
.adk-card {
|
|
142
|
+
border-radius: var(--dsw-radius-xl, 14px);
|
|
143
|
+
background: var(--dsw-alias-settings-card-fill, rgba(127, 127, 127, 0.06));
|
|
144
|
+
border: 1px solid var(--dsw-alias-settings-card-stroke, rgba(127, 127, 127, 0.16));
|
|
145
|
+
padding: 16px;
|
|
146
|
+
display: flex;
|
|
147
|
+
flex-direction: column;
|
|
148
|
+
gap: 14px;
|
|
149
|
+
}
|
|
150
|
+
.adk-desc {
|
|
151
|
+
margin: 0;
|
|
152
|
+
font-size: 12.5px;
|
|
153
|
+
color: var(--dsw-alias-label-tertiary, #6b7280);
|
|
154
|
+
}
|
|
155
|
+
.adk-text-err {
|
|
156
|
+
color: #ef4444;
|
|
157
|
+
}
|
|
158
|
+
.adk-qr-layout {
|
|
159
|
+
display: flex;
|
|
160
|
+
gap: 16px;
|
|
161
|
+
align-items: center;
|
|
162
|
+
flex-wrap: wrap;
|
|
163
|
+
}
|
|
164
|
+
.adk-qr-frame {
|
|
165
|
+
width: 168px;
|
|
166
|
+
height: 168px;
|
|
167
|
+
padding: 8px;
|
|
168
|
+
box-sizing: border-box;
|
|
169
|
+
border-radius: 12px;
|
|
170
|
+
background: #ffffff;
|
|
171
|
+
border: 1px solid rgba(0, 0, 0, 0.08);
|
|
172
|
+
flex-shrink: 0;
|
|
173
|
+
display: flex;
|
|
174
|
+
align-items: center;
|
|
175
|
+
justify-content: center;
|
|
176
|
+
}
|
|
177
|
+
.adk-qr-frame img {
|
|
178
|
+
width: 100%;
|
|
179
|
+
height: 100%;
|
|
180
|
+
display: block;
|
|
181
|
+
}
|
|
182
|
+
.adk-qr-info {
|
|
183
|
+
flex: 1;
|
|
184
|
+
min-width: 210px;
|
|
185
|
+
display: flex;
|
|
186
|
+
flex-direction: column;
|
|
187
|
+
gap: 8px;
|
|
188
|
+
}
|
|
189
|
+
.adk-meta-line {
|
|
190
|
+
font-size: 12px;
|
|
191
|
+
color: var(--dsw-alias-label-tertiary, #6b7280);
|
|
192
|
+
}
|
|
193
|
+
.adk-meta-line code {
|
|
194
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
|
195
|
+
color: var(--dsw-alias-label-primary, #111827);
|
|
196
|
+
background: var(--dsw-alias-interactive-bg-hover, rgba(127, 127, 127, 0.1));
|
|
197
|
+
padding: 1px 5px;
|
|
198
|
+
border-radius: 4px;
|
|
199
|
+
}
|
|
200
|
+
.adk-provisioning {
|
|
201
|
+
display: flex;
|
|
202
|
+
flex-direction: column;
|
|
203
|
+
gap: 6px;
|
|
204
|
+
padding: 6px 0;
|
|
205
|
+
}
|
|
206
|
+
.adk-provisioning-title {
|
|
207
|
+
display: flex;
|
|
208
|
+
align-items: center;
|
|
209
|
+
gap: 8px;
|
|
210
|
+
font-size: 13.5px;
|
|
211
|
+
font-weight: 500;
|
|
212
|
+
}
|
|
213
|
+
.adk-spinner {
|
|
214
|
+
width: 14px;
|
|
215
|
+
height: 14px;
|
|
216
|
+
border-radius: 999px;
|
|
217
|
+
border: 2px solid var(--dsw-alias-border-l3, rgba(127, 127, 127, 0.3));
|
|
218
|
+
border-top-color: var(--dsw-alias-button-primary-fill, #2563eb);
|
|
219
|
+
animation: adk-spin 0.8s linear infinite;
|
|
220
|
+
flex-shrink: 0;
|
|
221
|
+
}
|
|
222
|
+
@keyframes adk-spin {
|
|
223
|
+
to { transform: rotate(360deg); }
|
|
224
|
+
}
|
|
225
|
+
.adk-banner {
|
|
226
|
+
border-radius: var(--dsw-radius-md, 8px);
|
|
227
|
+
padding: 10px 12px;
|
|
228
|
+
font-size: 12.5px;
|
|
229
|
+
line-height: 1.5;
|
|
230
|
+
display: flex;
|
|
231
|
+
align-items: center;
|
|
232
|
+
justify-content: space-between;
|
|
233
|
+
gap: 10px;
|
|
234
|
+
flex-wrap: wrap;
|
|
235
|
+
}
|
|
236
|
+
.adk-banner-err {
|
|
237
|
+
background: rgba(239, 68, 68, 0.12);
|
|
238
|
+
border: 1px solid rgba(239, 68, 68, 0.32);
|
|
239
|
+
color: #ef4444;
|
|
240
|
+
}
|
|
241
|
+
.adk-banner-warn {
|
|
242
|
+
background: rgba(245, 158, 11, 0.12);
|
|
243
|
+
border: 1px solid rgba(245, 158, 11, 0.3);
|
|
244
|
+
color: #d97706;
|
|
245
|
+
}
|
|
246
|
+
.adk-rows {
|
|
247
|
+
display: flex;
|
|
248
|
+
flex-direction: column;
|
|
249
|
+
}
|
|
250
|
+
.adk-row {
|
|
251
|
+
display: flex;
|
|
252
|
+
align-items: center;
|
|
253
|
+
justify-content: space-between;
|
|
254
|
+
gap: 12px;
|
|
255
|
+
padding: 12px 0;
|
|
256
|
+
border-bottom: 1px solid var(--dsw-alias-border-l2, rgba(127, 127, 127, 0.15));
|
|
257
|
+
flex-wrap: wrap;
|
|
258
|
+
}
|
|
259
|
+
.adk-row:first-child {
|
|
260
|
+
padding-top: 2px;
|
|
261
|
+
}
|
|
262
|
+
.adk-row:last-child {
|
|
263
|
+
border-bottom: none;
|
|
264
|
+
padding-bottom: 2px;
|
|
265
|
+
}
|
|
266
|
+
.adk-row-col {
|
|
267
|
+
flex-direction: column;
|
|
268
|
+
align-items: stretch;
|
|
269
|
+
gap: 8px;
|
|
270
|
+
}
|
|
271
|
+
.adk-row-head {
|
|
272
|
+
display: flex;
|
|
273
|
+
align-items: center;
|
|
274
|
+
justify-content: space-between;
|
|
275
|
+
gap: 8px;
|
|
276
|
+
}
|
|
277
|
+
.adk-row-main {
|
|
278
|
+
display: flex;
|
|
279
|
+
flex-direction: column;
|
|
280
|
+
gap: 2px;
|
|
281
|
+
min-width: 0;
|
|
282
|
+
flex: 1;
|
|
283
|
+
}
|
|
284
|
+
.adk-row-label {
|
|
285
|
+
display: flex;
|
|
286
|
+
align-items: center;
|
|
287
|
+
gap: 8px;
|
|
288
|
+
font-weight: 500;
|
|
289
|
+
color: var(--dsw-alias-label-primary, #111827);
|
|
290
|
+
}
|
|
291
|
+
.adk-badge {
|
|
292
|
+
display: inline-flex;
|
|
293
|
+
align-items: center;
|
|
294
|
+
padding: 1px 8px;
|
|
295
|
+
border-radius: 999px;
|
|
296
|
+
font-size: 11.5px;
|
|
297
|
+
font-weight: 500;
|
|
298
|
+
white-space: nowrap;
|
|
299
|
+
}
|
|
300
|
+
.adk-badge-ok {
|
|
301
|
+
background: rgba(16, 185, 129, 0.14);
|
|
302
|
+
color: #10b981;
|
|
303
|
+
}
|
|
304
|
+
.adk-badge-muted {
|
|
305
|
+
background: rgba(127, 127, 127, 0.14);
|
|
306
|
+
color: var(--dsw-alias-label-secondary, #6b7280);
|
|
307
|
+
}
|
|
308
|
+
.adk-actions {
|
|
309
|
+
display: flex;
|
|
310
|
+
align-items: center;
|
|
311
|
+
gap: 6px;
|
|
312
|
+
flex-shrink: 0;
|
|
313
|
+
}
|
|
314
|
+
.adk-btn {
|
|
315
|
+
display: inline-flex;
|
|
316
|
+
align-items: center;
|
|
317
|
+
justify-content: center;
|
|
318
|
+
height: 28px;
|
|
319
|
+
padding: 0 12px;
|
|
320
|
+
border-radius: var(--dsw-radius-md, 8px);
|
|
321
|
+
font-size: 12px;
|
|
322
|
+
font-weight: 500;
|
|
323
|
+
font-family: inherit;
|
|
324
|
+
cursor: pointer;
|
|
325
|
+
border: 1px solid transparent;
|
|
326
|
+
transition: background-color 0.15s ease, opacity 0.15s ease;
|
|
327
|
+
}
|
|
328
|
+
.adk-btn:disabled {
|
|
329
|
+
opacity: 0.55;
|
|
330
|
+
cursor: not-allowed;
|
|
331
|
+
}
|
|
332
|
+
.adk-btn-primary {
|
|
333
|
+
background: var(--dsw-alias-button-primary-fill, #2563eb);
|
|
334
|
+
color: var(--dsw-alias-label-primary-foreground, #ffffff);
|
|
335
|
+
}
|
|
336
|
+
.adk-btn-primary:hover:not(:disabled) {
|
|
337
|
+
background: var(--dsw-alias-button-primary-hover, #1d4ed8);
|
|
338
|
+
}
|
|
339
|
+
.adk-btn-secondary {
|
|
340
|
+
background: transparent;
|
|
341
|
+
border-color: var(--dsw-alias-border-l3, rgba(127, 127, 127, 0.25));
|
|
342
|
+
color: var(--dsw-alias-label-primary, #111827);
|
|
343
|
+
}
|
|
344
|
+
.adk-btn-secondary:hover:not(:disabled) {
|
|
345
|
+
background: var(--dsw-alias-interactive-bg-hover, rgba(127, 127, 127, 0.1));
|
|
346
|
+
}
|
|
347
|
+
.adk-seg {
|
|
348
|
+
display: inline-flex;
|
|
349
|
+
flex-wrap: wrap;
|
|
350
|
+
gap: 6px;
|
|
351
|
+
}
|
|
352
|
+
.adk-seg-btn {
|
|
353
|
+
height: 28px;
|
|
354
|
+
padding: 0 10px;
|
|
355
|
+
border-radius: var(--dsw-radius-md, 8px);
|
|
356
|
+
border: 1px solid var(--dsw-alias-border-l3, rgba(127, 127, 127, 0.25));
|
|
357
|
+
background: transparent;
|
|
358
|
+
color: var(--dsw-alias-label-secondary, #4b5563);
|
|
359
|
+
font-family: inherit;
|
|
360
|
+
font-size: 12px;
|
|
361
|
+
font-weight: 500;
|
|
362
|
+
cursor: pointer;
|
|
363
|
+
transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
|
|
364
|
+
}
|
|
365
|
+
.adk-seg-btn:hover:not(:disabled) {
|
|
366
|
+
background: var(--dsw-alias-interactive-bg-hover, rgba(127, 127, 127, 0.1));
|
|
367
|
+
}
|
|
368
|
+
.adk-seg-btn-active {
|
|
369
|
+
background: var(--dsw-alias-button-primary-fill, #2563eb);
|
|
370
|
+
border-color: var(--dsw-alias-button-primary-fill, #2563eb);
|
|
371
|
+
color: var(--dsw-alias-label-primary-foreground, #ffffff);
|
|
372
|
+
}
|
|
373
|
+
.adk-seg-btn-active:hover:not(:disabled) {
|
|
374
|
+
background: var(--dsw-alias-button-primary-hover, #1d4ed8);
|
|
375
|
+
}
|
|
376
|
+
.adk-seg-btn:disabled {
|
|
377
|
+
opacity: 0.55;
|
|
378
|
+
cursor: not-allowed;
|
|
379
|
+
}
|
|
380
|
+
.adk-links {
|
|
381
|
+
display: flex;
|
|
382
|
+
align-items: center;
|
|
383
|
+
gap: 8px;
|
|
384
|
+
flex-wrap: wrap;
|
|
385
|
+
padding-top: 10px;
|
|
386
|
+
border-top: 1px solid var(--dsw-alias-border-l2, rgba(127, 127, 127, 0.15));
|
|
387
|
+
}
|
|
388
|
+
.adk-links-label {
|
|
389
|
+
font-size: 12px;
|
|
390
|
+
color: var(--dsw-alias-label-tertiary, #6b7280);
|
|
391
|
+
margin-right: 4px;
|
|
392
|
+
}
|
|
393
|
+
.adk-link {
|
|
394
|
+
display: inline-flex;
|
|
395
|
+
align-items: center;
|
|
396
|
+
height: 26px;
|
|
397
|
+
padding: 0 10px;
|
|
398
|
+
border-radius: var(--dsw-radius-md, 8px);
|
|
399
|
+
border: 1px solid var(--dsw-alias-border-l3, rgba(127, 127, 127, 0.24));
|
|
400
|
+
color: var(--dsw-alias-label-primary, #111827);
|
|
401
|
+
text-decoration: none;
|
|
402
|
+
font-size: 12px;
|
|
403
|
+
font-weight: 500;
|
|
404
|
+
}
|
|
405
|
+
.adk-link:hover {
|
|
406
|
+
background: var(--dsw-alias-interactive-bg-hover, rgba(127, 127, 127, 0.1));
|
|
407
|
+
}
|
|
408
|
+
`;
|
|
409
|
+
|
|
410
|
+
function injectStyles() {
|
|
411
|
+
if (typeof document === 'undefined') return;
|
|
412
|
+
if (
|
|
413
|
+
document.querySelector(
|
|
414
|
+
`style[data-plugin-css=${JSON.stringify(STYLE_TAG_ID)}]`,
|
|
415
|
+
) !== null
|
|
416
|
+
) {
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
const tag = document.createElement('style');
|
|
420
|
+
tag.dataset.plugin = 'dsh-plugin-agentdeck';
|
|
421
|
+
tag.dataset.pluginCss = STYLE_TAG_ID;
|
|
422
|
+
tag.textContent = CSS_TEXT;
|
|
423
|
+
document.head.appendChild(tag);
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
function PhoneIcon(props) {
|
|
427
|
+
const size = props?.size ?? 16;
|
|
428
|
+
return h(
|
|
429
|
+
'svg',
|
|
430
|
+
{
|
|
431
|
+
width: size,
|
|
432
|
+
height: size,
|
|
433
|
+
viewBox: '0 0 24 24',
|
|
434
|
+
fill: 'none',
|
|
435
|
+
stroke: 'currentColor',
|
|
436
|
+
strokeWidth: 1.8,
|
|
437
|
+
strokeLinecap: 'round',
|
|
438
|
+
strokeLinejoin: 'round',
|
|
439
|
+
'aria-hidden': 'true',
|
|
440
|
+
},
|
|
441
|
+
h('rect', { x: 6, y: 2.5, width: 12, height: 19, rx: 2.5 }),
|
|
442
|
+
h('path', { d: 'M10 9.5L12.5 12L10 14.5' }),
|
|
443
|
+
h('path', { d: 'M13.5 14.5H15' }),
|
|
444
|
+
h('circle', { cx: 12, cy: 18, r: 0.7, fill: 'currentColor' }),
|
|
445
|
+
);
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
function formatModel(entry) {
|
|
449
|
+
if (!entry || (!entry.provider && !entry.model)) return null;
|
|
450
|
+
return [entry.provider, entry.model].filter(Boolean).join(' / ');
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
function AgentDeckSettingsSection(props) {
|
|
454
|
+
const t = props.t || ((k) => DICTIONARIES.en[k] || k);
|
|
455
|
+
const isZh = t('isZh') === '1';
|
|
456
|
+
|
|
457
|
+
const [status, setStatus] = useState(null);
|
|
458
|
+
const [error, setError] = useState(null);
|
|
459
|
+
const [busy, setBusy] = useState(false);
|
|
460
|
+
|
|
461
|
+
const loadStatus = useCallback(async () => {
|
|
462
|
+
try {
|
|
463
|
+
const res = await fetch('api/agentdeck/status', {
|
|
464
|
+
cache: 'no-store',
|
|
465
|
+
});
|
|
466
|
+
const data = await res.json();
|
|
467
|
+
if (!res.ok) throw new Error(data?.error || `HTTP ${res.status}`);
|
|
468
|
+
setStatus(data);
|
|
469
|
+
} catch (err) {
|
|
470
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
471
|
+
}
|
|
472
|
+
}, []);
|
|
473
|
+
|
|
474
|
+
useEffect(() => {
|
|
475
|
+
loadStatus();
|
|
476
|
+
}, [loadStatus]);
|
|
477
|
+
|
|
478
|
+
// Automatically poll while first-time background provisioning is running
|
|
479
|
+
const isProvisioning = status?.provisioning?.state === 'running';
|
|
480
|
+
useEffect(() => {
|
|
481
|
+
if (!isProvisioning) return undefined;
|
|
482
|
+
const timer = setTimeout(() => {
|
|
483
|
+
loadStatus();
|
|
484
|
+
}, 1500);
|
|
485
|
+
return () => clearTimeout(timer);
|
|
486
|
+
}, [isProvisioning, status, loadStatus]);
|
|
487
|
+
|
|
488
|
+
const postAction = useCallback(async (url, body) => {
|
|
489
|
+
setBusy(true);
|
|
490
|
+
setError(null);
|
|
491
|
+
try {
|
|
492
|
+
const res = await fetch(url, {
|
|
493
|
+
method: 'POST',
|
|
494
|
+
headers: { 'content-type': 'application/json' },
|
|
495
|
+
body: JSON.stringify(body),
|
|
496
|
+
});
|
|
497
|
+
const data = await res.json();
|
|
498
|
+
if (data?.status) setStatus(data.status);
|
|
499
|
+
if (!res.ok || !data?.ok) {
|
|
500
|
+
throw new Error(data?.error || `HTTP ${res.status}`);
|
|
501
|
+
}
|
|
502
|
+
} catch (err) {
|
|
503
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
504
|
+
} finally {
|
|
505
|
+
setBusy(false);
|
|
506
|
+
}
|
|
507
|
+
}, []);
|
|
508
|
+
|
|
509
|
+
const awakeMode = status?.daemon?.awake?.mode || 'never';
|
|
510
|
+
const awakeOptions = [
|
|
511
|
+
{ id: 'never', label: t('awakeNever'), hint: t('awakeHintNever') },
|
|
512
|
+
{ id: 'plugged', label: t('awakePlugged'), hint: t('awakeHintPlugged') },
|
|
513
|
+
{ id: 'active', label: t('awakeActiveMode'), hint: t('awakeHintActive') },
|
|
514
|
+
{ id: 'always', label: t('awakeAlways'), hint: t('awakeHintAlways') },
|
|
515
|
+
];
|
|
516
|
+
const currentAwakeHint =
|
|
517
|
+
awakeOptions.find((o) => o.id === awakeMode)?.hint || '';
|
|
518
|
+
|
|
519
|
+
const qrDataUrl = status?.daemon?.qrSvg
|
|
520
|
+
? `data:image/svg+xml;charset=utf-8,${encodeURIComponent(status.daemon.qrSvg)}`
|
|
521
|
+
: null;
|
|
522
|
+
const acpModelText = formatModel(status?.models?.acp?.defaultModel);
|
|
523
|
+
const sourceModelText = formatModel(status?.models?.source?.defaultModel);
|
|
524
|
+
const provisionError = status?.provisioning?.error || null;
|
|
525
|
+
const anyBusy = busy || isProvisioning;
|
|
526
|
+
|
|
527
|
+
return h(
|
|
528
|
+
'div',
|
|
529
|
+
{ className: 'adk-root' },
|
|
530
|
+
h(
|
|
531
|
+
'div',
|
|
532
|
+
null,
|
|
533
|
+
h('h2', { className: 'adk-title' }, t('title')),
|
|
534
|
+
h('p', { className: 'adk-subtitle' }, t('subtitle')),
|
|
535
|
+
),
|
|
536
|
+
|
|
537
|
+
!status && !error
|
|
538
|
+
? h('div', { className: 'adk-card' }, t('loading'))
|
|
539
|
+
: null,
|
|
540
|
+
|
|
541
|
+
error || provisionError
|
|
542
|
+
? h(
|
|
543
|
+
'div',
|
|
544
|
+
{ className: 'adk-banner adk-banner-err' },
|
|
545
|
+
h('span', null, `${t('errorTitle')}: ${error || provisionError}`),
|
|
546
|
+
h(
|
|
547
|
+
'button',
|
|
548
|
+
{
|
|
549
|
+
type: 'button',
|
|
550
|
+
className: 'adk-btn adk-btn-primary',
|
|
551
|
+
disabled: anyBusy,
|
|
552
|
+
onClick: () => postAction('api/agentdeck/setup', {}),
|
|
553
|
+
},
|
|
554
|
+
t('btnRetry'),
|
|
555
|
+
),
|
|
556
|
+
)
|
|
557
|
+
: null,
|
|
558
|
+
|
|
559
|
+
status
|
|
560
|
+
? h(
|
|
561
|
+
React.Fragment,
|
|
562
|
+
null,
|
|
563
|
+
// Card 1: Pairing QR Code (zero-click ready)
|
|
564
|
+
h(
|
|
565
|
+
'section',
|
|
566
|
+
{ className: 'adk-card' },
|
|
567
|
+
isProvisioning && !qrDataUrl
|
|
568
|
+
? h(
|
|
569
|
+
'div',
|
|
570
|
+
{ className: 'adk-provisioning' },
|
|
571
|
+
h(
|
|
572
|
+
'div',
|
|
573
|
+
{ className: 'adk-provisioning-title' },
|
|
574
|
+
h('span', { className: 'adk-spinner' }),
|
|
575
|
+
h('span', null, t('provisioning')),
|
|
576
|
+
),
|
|
577
|
+
h('p', { className: 'adk-desc' }, t('provisioningHint')),
|
|
578
|
+
)
|
|
579
|
+
: qrDataUrl
|
|
580
|
+
? h(
|
|
581
|
+
React.Fragment,
|
|
582
|
+
null,
|
|
583
|
+
!status.daemon?.running
|
|
584
|
+
? h(
|
|
585
|
+
'div',
|
|
586
|
+
{ className: 'adk-banner adk-banner-warn' },
|
|
587
|
+
t('stoppedBanner'),
|
|
588
|
+
)
|
|
589
|
+
: null,
|
|
590
|
+
h(
|
|
591
|
+
'div',
|
|
592
|
+
{ className: 'adk-qr-layout' },
|
|
593
|
+
h(
|
|
594
|
+
'div',
|
|
595
|
+
{ className: 'adk-qr-frame' },
|
|
596
|
+
h('img', {
|
|
597
|
+
src: qrDataUrl,
|
|
598
|
+
alt: 'AgentDeck pairing QR code',
|
|
599
|
+
}),
|
|
600
|
+
),
|
|
601
|
+
h(
|
|
602
|
+
'div',
|
|
603
|
+
{ className: 'adk-qr-info' },
|
|
604
|
+
h('p', { className: 'adk-desc' }, t('qrHint')),
|
|
605
|
+
h(
|
|
606
|
+
'div',
|
|
607
|
+
{ className: 'adk-meta-line' },
|
|
608
|
+
`${t('pairingIdLabel')}: `,
|
|
609
|
+
h('code', null, status.daemon.maskedPairingId),
|
|
610
|
+
),
|
|
611
|
+
status.daemon.hasCustomRelay
|
|
612
|
+
? h(
|
|
613
|
+
'div',
|
|
614
|
+
{ className: 'adk-meta-line' },
|
|
615
|
+
`${t('customRelayLabel')}: `,
|
|
616
|
+
h('code', null, status.daemon.relayUrl),
|
|
617
|
+
)
|
|
618
|
+
: null,
|
|
619
|
+
),
|
|
620
|
+
),
|
|
621
|
+
)
|
|
622
|
+
: h(
|
|
623
|
+
'div',
|
|
624
|
+
{ className: 'adk-actions' },
|
|
625
|
+
h(
|
|
626
|
+
'button',
|
|
627
|
+
{
|
|
628
|
+
type: 'button',
|
|
629
|
+
className: 'adk-btn adk-btn-primary',
|
|
630
|
+
disabled: anyBusy,
|
|
631
|
+
onClick: () => postAction('api/agentdeck/setup', {}),
|
|
632
|
+
},
|
|
633
|
+
t('btnRetry'),
|
|
634
|
+
),
|
|
635
|
+
),
|
|
636
|
+
|
|
637
|
+
h(
|
|
638
|
+
'div',
|
|
639
|
+
{ className: 'adk-links' },
|
|
640
|
+
h(
|
|
641
|
+
'span',
|
|
642
|
+
{ className: 'adk-links-label' },
|
|
643
|
+
t('downloadTitle'),
|
|
644
|
+
),
|
|
645
|
+
h(
|
|
646
|
+
'a',
|
|
647
|
+
{
|
|
648
|
+
className: 'adk-link',
|
|
649
|
+
href: STORE_LINKS.appStore,
|
|
650
|
+
target: '_blank',
|
|
651
|
+
rel: 'noopener noreferrer',
|
|
652
|
+
},
|
|
653
|
+
t('linkAppStore'),
|
|
654
|
+
),
|
|
655
|
+
h(
|
|
656
|
+
'a',
|
|
657
|
+
{
|
|
658
|
+
className: 'adk-link',
|
|
659
|
+
href: STORE_LINKS.googlePlay,
|
|
660
|
+
target: '_blank',
|
|
661
|
+
rel: 'noopener noreferrer',
|
|
662
|
+
},
|
|
663
|
+
t('linkGooglePlay'),
|
|
664
|
+
),
|
|
665
|
+
h(
|
|
666
|
+
'a',
|
|
667
|
+
{
|
|
668
|
+
className: 'adk-link',
|
|
669
|
+
href: STORE_LINKS.apk,
|
|
670
|
+
target: '_blank',
|
|
671
|
+
rel: 'noopener noreferrer',
|
|
672
|
+
},
|
|
673
|
+
t('linkApk'),
|
|
674
|
+
),
|
|
675
|
+
h(
|
|
676
|
+
'a',
|
|
677
|
+
{
|
|
678
|
+
className: 'adk-link',
|
|
679
|
+
href: isZh ? STORE_LINKS.websiteZh : STORE_LINKS.websiteEn,
|
|
680
|
+
target: '_blank',
|
|
681
|
+
rel: 'noopener noreferrer',
|
|
682
|
+
},
|
|
683
|
+
t('linkWebsite'),
|
|
684
|
+
),
|
|
685
|
+
),
|
|
686
|
+
),
|
|
687
|
+
|
|
688
|
+
// Card 2: Essential Settings Only (Service, Keep Awake, Mobile Model)
|
|
689
|
+
h(
|
|
690
|
+
'section',
|
|
691
|
+
{ className: 'adk-card' },
|
|
692
|
+
h(
|
|
693
|
+
'div',
|
|
694
|
+
{ className: 'adk-rows' },
|
|
695
|
+
// 1. Remote Service & Autostart
|
|
696
|
+
h(
|
|
697
|
+
'div',
|
|
698
|
+
{ className: 'adk-row' },
|
|
699
|
+
h(
|
|
700
|
+
'div',
|
|
701
|
+
{ className: 'adk-row-main' },
|
|
702
|
+
h(
|
|
703
|
+
'div',
|
|
704
|
+
{ className: 'adk-row-label' },
|
|
705
|
+
h('span', null, t('serviceTitle')),
|
|
706
|
+
h(
|
|
707
|
+
'span',
|
|
708
|
+
{
|
|
709
|
+
className: `adk-badge ${status.daemon?.running ? 'adk-badge-ok' : 'adk-badge-muted'}`,
|
|
710
|
+
},
|
|
711
|
+
status.daemon?.running
|
|
712
|
+
? t('statusRunning')
|
|
713
|
+
: t('statusStopped'),
|
|
714
|
+
),
|
|
715
|
+
),
|
|
716
|
+
h(
|
|
717
|
+
'p',
|
|
718
|
+
{ className: 'adk-desc' },
|
|
719
|
+
status.daemon?.running
|
|
720
|
+
? t('serviceDescRunning')
|
|
721
|
+
: t('serviceDescStopped'),
|
|
722
|
+
),
|
|
723
|
+
),
|
|
724
|
+
h(
|
|
725
|
+
'div',
|
|
726
|
+
{ className: 'adk-actions' },
|
|
727
|
+
status.daemon?.running
|
|
728
|
+
? status.daemon?.binaryPath
|
|
729
|
+
? h(
|
|
730
|
+
React.Fragment,
|
|
731
|
+
null,
|
|
732
|
+
h(
|
|
733
|
+
'button',
|
|
734
|
+
{
|
|
735
|
+
type: 'button',
|
|
736
|
+
className: 'adk-btn adk-btn-secondary',
|
|
737
|
+
disabled: anyBusy,
|
|
738
|
+
onClick: () =>
|
|
739
|
+
postAction('api/agentdeck/daemon', {
|
|
740
|
+
action: 'restart',
|
|
741
|
+
}),
|
|
742
|
+
},
|
|
743
|
+
busy ? t('btnWorking') : t('btnRestart'),
|
|
744
|
+
),
|
|
745
|
+
h(
|
|
746
|
+
'button',
|
|
747
|
+
{
|
|
748
|
+
type: 'button',
|
|
749
|
+
className: 'adk-btn adk-btn-secondary',
|
|
750
|
+
disabled: anyBusy,
|
|
751
|
+
onClick: () =>
|
|
752
|
+
postAction('api/agentdeck/daemon', {
|
|
753
|
+
action: 'stop',
|
|
754
|
+
}),
|
|
755
|
+
},
|
|
756
|
+
t('btnStop'),
|
|
757
|
+
),
|
|
758
|
+
)
|
|
759
|
+
: null
|
|
760
|
+
: h(
|
|
761
|
+
'button',
|
|
762
|
+
{
|
|
763
|
+
type: 'button',
|
|
764
|
+
className: 'adk-btn adk-btn-primary',
|
|
765
|
+
disabled: anyBusy,
|
|
766
|
+
onClick: () =>
|
|
767
|
+
postAction('api/agentdeck/daemon', {
|
|
768
|
+
action: 'start',
|
|
769
|
+
}),
|
|
770
|
+
},
|
|
771
|
+
busy ? t('btnWorking') : t('btnStart'),
|
|
772
|
+
),
|
|
773
|
+
),
|
|
774
|
+
),
|
|
775
|
+
|
|
776
|
+
// 2. Keep Awake
|
|
777
|
+
h(
|
|
778
|
+
'div',
|
|
779
|
+
{ className: 'adk-row adk-row-col' },
|
|
780
|
+
h(
|
|
781
|
+
'div',
|
|
782
|
+
{ className: 'adk-row-head' },
|
|
783
|
+
h('span', { className: 'adk-row-label' }, t('awakeTitle')),
|
|
784
|
+
status.daemon?.running
|
|
785
|
+
? h(
|
|
786
|
+
'span',
|
|
787
|
+
{
|
|
788
|
+
className: `adk-badge ${status.daemon?.awake?.active ? 'adk-badge-ok' : 'adk-badge-muted'}`,
|
|
789
|
+
},
|
|
790
|
+
status.daemon?.awake?.active
|
|
791
|
+
? t('awakeActive')
|
|
792
|
+
: t('awakeInactive'),
|
|
793
|
+
)
|
|
794
|
+
: null,
|
|
795
|
+
),
|
|
796
|
+
h(
|
|
797
|
+
'div',
|
|
798
|
+
{
|
|
799
|
+
className: 'adk-seg',
|
|
800
|
+
role: 'radiogroup',
|
|
801
|
+
'aria-label': t('awakeTitle'),
|
|
802
|
+
},
|
|
803
|
+
...awakeOptions.map((opt) =>
|
|
804
|
+
h(
|
|
805
|
+
'button',
|
|
806
|
+
{
|
|
807
|
+
key: opt.id,
|
|
808
|
+
type: 'button',
|
|
809
|
+
role: 'radio',
|
|
810
|
+
'aria-checked': awakeMode === opt.id,
|
|
811
|
+
disabled: anyBusy,
|
|
812
|
+
className: `adk-seg-btn ${awakeMode === opt.id ? 'adk-seg-btn-active' : ''}`,
|
|
813
|
+
onClick: () =>
|
|
814
|
+
postAction('api/agentdeck/awake', {
|
|
815
|
+
mode: opt.id,
|
|
816
|
+
}),
|
|
817
|
+
},
|
|
818
|
+
opt.label,
|
|
819
|
+
),
|
|
820
|
+
),
|
|
821
|
+
),
|
|
822
|
+
h('p', { className: 'adk-desc' }, currentAwakeHint),
|
|
823
|
+
status.daemon?.awake?.error
|
|
824
|
+
? h(
|
|
825
|
+
'p',
|
|
826
|
+
{ className: 'adk-desc adk-text-err' },
|
|
827
|
+
status.daemon.awake.error,
|
|
828
|
+
)
|
|
829
|
+
: null,
|
|
830
|
+
),
|
|
831
|
+
|
|
832
|
+
// 3. Mobile Default Model
|
|
833
|
+
h(
|
|
834
|
+
'div',
|
|
835
|
+
{ className: 'adk-row' },
|
|
836
|
+
h(
|
|
837
|
+
'div',
|
|
838
|
+
{ className: 'adk-row-main' },
|
|
839
|
+
h('span', { className: 'adk-row-label' }, t('modelTitle')),
|
|
840
|
+
h(
|
|
841
|
+
'p',
|
|
842
|
+
{ className: 'adk-desc' },
|
|
843
|
+
acpModelText || t('modelDefault'),
|
|
844
|
+
),
|
|
845
|
+
),
|
|
846
|
+
sourceModelText && status.models?.mismatch
|
|
847
|
+
? h(
|
|
848
|
+
'button',
|
|
849
|
+
{
|
|
850
|
+
type: 'button',
|
|
851
|
+
className: 'adk-btn adk-btn-secondary',
|
|
852
|
+
disabled: anyBusy,
|
|
853
|
+
onClick: () =>
|
|
854
|
+
postAction('api/agentdeck/sync-models', {}),
|
|
855
|
+
},
|
|
856
|
+
`${t('btnSyncModel')} (${sourceModelText})`,
|
|
857
|
+
)
|
|
858
|
+
: null,
|
|
859
|
+
),
|
|
860
|
+
),
|
|
861
|
+
),
|
|
862
|
+
)
|
|
863
|
+
: null,
|
|
864
|
+
);
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
function apply(ctx) {
|
|
868
|
+
injectStyles();
|
|
869
|
+
const t = ctx.locale.bind(NS);
|
|
870
|
+
ctx.effect(
|
|
871
|
+
() => ctx.locale.register(NS, DICTIONARIES),
|
|
872
|
+
'agentdeck: dictionaries',
|
|
873
|
+
);
|
|
874
|
+
ctx.effect(
|
|
875
|
+
() =>
|
|
876
|
+
ctx.slots.inject('settings.section.icon', () =>
|
|
877
|
+
ctx.slots.register(
|
|
878
|
+
{
|
|
879
|
+
name: 'settings.section.icon',
|
|
880
|
+
id: 'agentdeck',
|
|
881
|
+
locale: NS,
|
|
882
|
+
},
|
|
883
|
+
PhoneIcon,
|
|
884
|
+
),
|
|
885
|
+
),
|
|
886
|
+
'agentdeck: settings section icon',
|
|
887
|
+
);
|
|
888
|
+
ctx.effect(
|
|
889
|
+
() =>
|
|
890
|
+
ctx.slots.inject('settings.section', () =>
|
|
891
|
+
ctx.slots.register(
|
|
892
|
+
{
|
|
893
|
+
name: 'settings.section',
|
|
894
|
+
id: 'agentdeck',
|
|
895
|
+
order: 65,
|
|
896
|
+
label: () => t('nav'),
|
|
897
|
+
locale: NS,
|
|
898
|
+
},
|
|
899
|
+
AgentDeckSettingsSection,
|
|
900
|
+
),
|
|
901
|
+
),
|
|
902
|
+
'agentdeck: settings section',
|
|
903
|
+
);
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
exports.name = 'agentdeck-settings';
|
|
907
|
+
exports.inject = ['slots', 'locale'];
|
|
908
|
+
exports.apply = apply;
|
|
909
|
+
return module.exports;
|
|
910
|
+
},
|
|
911
|
+
});
|