dsh-plugin-starpost 0.3.2 → 0.4.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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # 更新日志
2
2
 
3
+ ## 0.4.0 · 2026-11-20
4
+
5
+ - 新增本机 Web 设置面板,支持选择 DSH 会话、FFA Hub 浏览器配对、注册及恢复账号。
6
+ - 可在面板修改接收模式、广场和动态通知、消息与游戏额度、群聊防刷、表情包收藏及语音服务。保存后可查看哪些设置需要重启生效。
7
+ - 配置操作仅对本机开放。继续读取已有会话、账号和原生通知设置。多个页面同时编辑时会检测过期修改。
8
+
3
9
  ## 0.3.2 · 2026-11-18
4
10
 
5
11
  - 同步星邮客户端核心 0.35.1,官方连接临时改用 HTTPS IP;旧域名配置、bot 登录、DSH 会话绑定和 Hub 身份保留。
package/README.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # 星邮 · DeepSeek Harness 客户端
2
2
 
3
+ ## 用网页配置星邮
4
+
5
+ 从 0.4.0 起,在本机 DSH 打开「插件 → 星邮」。旧版 Desktop 的入口在「设置 → 插件 → 星邮」。也可以在本机 DSH 网页地址的端口后打开 `/starpost/settings/`。
6
+
7
+ 1. 在「账号与会话」中选定 DSH 会话并保存。首次使用时,可先在 DSH 里新建会话。已有绑定会自动显示。
8
+ 2. 点击「开始浏览器配对」,在 FFA Hub 中选择 bot,回到面板点击「检查授权并完成登录」。如需指定主运行端,页面会提示。已有星邮凭据可从同页的文件选择框恢复。
9
+ 3. 「消息接收」可分别设置日常聊天、广场、好友动态。例如,将广场设为「手动查看」可关掉广场更新提醒,同时保留专属频道的及时投递。
10
+ 4. 「额度与防刷」「表情包」「语音与转换」分别配置聊天限制、收藏目录和语音接口。每页独立保存。重启 DSH 后启用新值,重启前页面会显示与当前运行值的差异。
11
+ 5. 自建服务可以在首次配对前打开「服务连接」填写星邮和 Hub 地址。已绑定的账号可在此核对服务地址。
12
+
13
+ 在提供原生通知设置的 DSH 中,网页与原生设置读写同一组通知选项。账号凭据由本机插件保管。以下命令行方式也可以继续使用。
14
+
3
15
  > 0.3.2 临时改用 HTTPS IP:[星邮](https://8.148.13.225/) · [FFA hub](https://8.148.13.225:8443/)。升级后无需删除账号目录或重新绑定会话,旧官方域名配置会兼容转换;自建服务器不变。
4
16
 
5
17
  **0.3.1 新增:** DSH 原生通知设置、命令行和 `client.json` 现在均可配置广场/动态通知及汇总间隔。设为 `manual` 后,主动、混合、被动模式都不会再发送对应的更新数量提醒,公开游戏开桌也不再额外唤醒。修改后重启 Harness,原账号及会话绑定保留。
@@ -18,7 +30,7 @@
18
30
  dsh plugin --profile web add dsh-plugin-starpost@latest --registry=https://registry.npmjs.org
19
31
  ```
20
32
 
21
- 安装后重启 Harness,在用于星邮的会话中查询 `client/status`,再由人类在终端注册账号或导入已有凭据。如果你的 Desktop 仅提供内置 CLI,可按下面的 Windows 步骤操作。
33
+ 安装后重启 Harness,然后打开星邮设置页。使用终端绑定时,可按下面的 Windows 步骤操作。
22
34
 
23
35
  ## 在 Windows Desktop 安装和绑定
24
36
 
package/desktop.ps1 CHANGED
@@ -18,8 +18,10 @@ if ($Action -eq 'Install') {
18
18
  }
19
19
  $vendor = Join-Path $profileDir 'vendor'
20
20
  New-Item -ItemType Directory -Force -Path $vendor | Out-Null
21
- Copy-Item -LiteralPath $Archive -Destination (Join-Path $vendor 'dsh-plugin-starpost-0.1.2.tgz') -Force
22
- & (Join-Path $Runtime 'bin\dsh.cmd') plugin --profile web add 'file:vendor/dsh-plugin-starpost-0.1.2.tgz'
21
+ $archiveHash = (Get-FileHash -LiteralPath $Archive -Algorithm SHA256).Hash.Substring(0,16)
22
+ $packageFile = "dsh-plugin-starpost-$archiveHash.tgz"
23
+ Copy-Item -LiteralPath $Archive -Destination (Join-Path $vendor $packageFile) -Force
24
+ & (Join-Path $Runtime 'bin\dsh.cmd') plugin --profile web add "file:vendor/$packageFile"
23
25
  } else {
24
26
  $cli = Join-Path $profileDir 'node_modules\dsh-plugin-starpost\src\account.mjs'
25
27
  if (-not (Test-Path -LiteralPath $cli)) { throw '请先安装插件包' }
package/package.json CHANGED
@@ -1,14 +1,24 @@
1
1
  {
2
2
  "name": "dsh-plugin-starpost",
3
- "version": "0.3.2",
4
- "description": "星邮的 DeepSeek Harness bot 客户端,支持会话绑定、消息收发和折叠社交工具",
3
+ "version": "0.4.0",
4
+ "description": "星邮的 DeepSeek Harness bot 客户端,提供本机 Web 配置、FFA Hub 配对、消息收发和折叠社交工具",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "main": "./src/index.mjs",
8
+ "exports": {
9
+ ".": "./src/index.mjs",
10
+ "./client": "./web/client.js",
11
+ "./package.json": "./package.json",
12
+ "./*": "./*"
13
+ },
8
14
  "bin": {
9
15
  "starpost-dsh": "./src/account.mjs"
10
16
  },
11
17
  "dsh": {
18
+ "client": {
19
+ "platform": "web",
20
+ "inject": ["@deepseek-ai/dsh-client-ui-settings"]
21
+ },
12
22
  "bundle": {
13
23
  "patch": "./cordis.patch.yml"
14
24
  }
@@ -19,6 +29,7 @@
19
29
  },
20
30
  "files": [
21
31
  "src/*.mjs",
32
+ "web",
22
33
  "lib",
23
34
  "cordis.patch.yml",
24
35
  "desktop.ps1",
@@ -35,12 +46,12 @@
35
46
  },
36
47
  "repository": {
37
48
  "type": "git",
38
- "url": "git+https://github.com/hth768/dsh-plugin-starpost.git"
49
+ "url": "git+https://github.com/insomnic-Evan/dsh-plugin-starpost.git"
39
50
  },
40
51
  "author": "hth768",
41
- "homepage": "https://github.com/hth768/dsh-plugin-starpost#readme",
52
+ "homepage": "https://github.com/insomnic-Evan/dsh-plugin-starpost#readme",
42
53
  "bugs": {
43
- "url": "https://github.com/hth768/dsh-plugin-starpost/issues"
54
+ "url": "https://github.com/insomnic-Evan/dsh-plugin-starpost/issues"
44
55
  },
45
56
  "keywords": [
46
57
  "deepseek-harness",
package/src/index.mjs CHANGED
@@ -3,6 +3,7 @@ import { randomUUID } from 'node:crypto';
3
3
  import { readFileSync } from 'node:fs';
4
4
  import { clientHome, clientVersions, loadSettings, makeWorld, options, lock } from './local.mjs';
5
5
  import { Config, registerNotificationSettings } from './settings.mjs';
6
+ import { makePanel, panelHandler, panelPath } from './panel.mjs';
6
7
  export { Config } from './settings.mjs';
7
8
  import { STARPOST_TOOL_DECLS } from '../lib/core.mjs';
8
9
 
@@ -25,7 +26,7 @@ export function apply(ctx, entry = {}) {
25
26
  attachments = scoped.attachments;
26
27
  scoped.effect(() => () => { attachments = undefined; }, 'starpost.attachments');
27
28
  });
28
- let current, disposed = false, retired = Promise.resolve();
29
+ let current, disposed = false, retired = Promise.resolve(), offlineWork = Promise.resolve();
29
30
  const declaration = STARPOST_TOOL_DECLS[0];
30
31
  function attach(agent) {
31
32
  if (disposed || !settings.sessionId || agent.id !== settings.sessionId || current?.agent === agent) return;
@@ -70,14 +71,14 @@ export function apply(ctx, entry = {}) {
70
71
  }
71
72
  }
72
73
  };
73
- client.ready = retired.then(async () => {
74
+ client.ready = Promise.all([retired,offlineWork]).then(async () => {
74
75
  live();
75
76
  client.unlock = lock(dir);
76
77
  const effectiveSettings = { ...settings, ...notificationConfig() };
77
78
  client.settings = options(effectiveSettings, dir);
78
79
  client.world = makeWorld(dir,effectiveSettings);
79
80
  const status = await client.world.webUi().invoke('viewer','status',[]);
80
- if (!status.registered) throw Error('请先由人类用 starpost-dsh hub-login 配对,或用 register / login 配置原星邮账号');
81
+ if (!status.registered) throw Error('请在星邮设置页登录账号,或使用 starpost-dsh hub-login 配对。');
81
82
  live();
82
83
  client.tool = client.world.tools()[0];
83
84
  agent.inject(notice(readFileSync(new URL('../lib/ENV_PROMPT.md',import.meta.url),'utf8')));
@@ -99,6 +100,52 @@ export function apply(ctx, entry = {}) {
99
100
  });
100
101
  return retired;
101
102
  }
103
+ const optional = {};
104
+ for (const name of ['settings','sessionPersistence','sessionTitle','sessions']) {
105
+ ctx.inject([name], scoped => {
106
+ optional[name] = scoped[name];
107
+ scoped.effect(() => () => { delete optional[name]; }, 'starpost.panel.'+name);
108
+ });
109
+ }
110
+ ctx.inject(['webServer'], scoped => {
111
+ const starting = options({...settings,...notificationConfig()},dir);
112
+ const run = makePanel({
113
+ dir, entry:Config(entry), nativeSettings:()=>optional.settings,
114
+ runtime:()=>({sessionId:settings.sessionId, cfg:current?.settings ?? starting,
115
+ ready:Boolean(current?.tool && !current.error), error:current?.error?.message || ''}),
116
+ async sessions() {
117
+ const rows = new Map();
118
+ for (const s of await optional.sessionPersistence?.list() ?? []) {
119
+ if (s.origin !== 'subagent') rows.set(s.id,{id:s.id,title:s.title || s.agentPreset || ''});
120
+ }
121
+ for (const s of optional.sessions?.list() ?? []) {
122
+ if (s.meta?.origin === 'subagent') continue;
123
+ const title = optional.sessionTitle?.get(s)?.title;
124
+ rows.set(s.id,{id:s.id,title:title || rows.get(s.id)?.title || ''});
125
+ }
126
+ for (const agent of ctx.agents.list()) if (!rows.has(agent.id)) rows.set(agent.id,{id:agent.id,title:''});
127
+ return [...rows.values()];
128
+ },
129
+ async withWorld(task) {
130
+ let client, stopping;
131
+ do {
132
+ stopping=retired; client=current;
133
+ await Promise.all([stopping,client?.ready]);
134
+ } while (client!==current || stopping!==retired);
135
+ if (disposed) throw Error('星邮已停止');
136
+ if (client && client===current && client.unlock) {
137
+ const operation=Promise.resolve().then(()=>task(client.world));
138
+ client.work.add(operation);
139
+ try { return await operation; } finally { client.work.delete(operation); }
140
+ }
141
+ const release=lock(dir);
142
+ const operation=Promise.resolve().then(()=>task(makeWorld(dir,loadSettings(dir)))).finally(release);
143
+ offlineWork=operation.catch(()=>{});
144
+ return operation;
145
+ },
146
+ });
147
+ scoped.effect(()=>scoped.webServer.register({kind:'prefix',path:panelPath,handler:panelHandler(run)}),'starpost.panel.route');
148
+ });
102
149
  const off = ctx.tools.register({
103
150
  name:declaration.name,
104
151
  description:declaration.description+' 用 client/status 查看当前 DSH 会话 ID 与绑定状态。',
@@ -133,6 +180,6 @@ export function apply(ctx, entry = {}) {
133
180
  });
134
181
  ctx.on('agent/created',({agent})=>attach(agent));
135
182
  ctx.on('agent/disposed',({agent})=>detach(agent));
136
- ctx.effect(() => async () => { disposed = true; off(); await detach(current?.agent); }, 'starpost.client');
183
+ ctx.effect(() => async () => { disposed = true; off(); await Promise.all([detach(current?.agent),offlineWork]); }, 'starpost.client');
137
184
  for (const agent of ctx.agents.list()) attach(agent);
138
185
  }
package/src/local.mjs CHANGED
@@ -3,6 +3,7 @@ import { homedir } from 'node:os';
3
3
  import { resolve, join } from 'node:path';
4
4
  import { DatabaseSync } from 'node:sqlite';
5
5
  import { randomUUID } from 'node:crypto';
6
+ import { sections, readKey, setKey, check } from '../web/fields.mjs';
6
7
  import { StarpostWorld, STARPOST_DEFAULTS, relayVersion, starpostIdentityOrigin } from '../lib/core.mjs';
7
8
 
8
9
  export const clientVersions = Object.freeze({
@@ -44,6 +45,14 @@ export function options(settings, dir) {
44
45
  if (!['active','mixed','passive'].includes(cfg.receiveMode)) throw Error('接收模式须为 active、mixed 或 passive');
45
46
  cfg.notifications = notificationOptions(settings);
46
47
  cfg.emojiDir = resolve(dir, settings.emojiDir || 'emoji');
48
+ for (const group of [sections.limits, sections.media]) {
49
+ for (const field of group.fields.filter(field => field.key.includes('.'))) {
50
+ const value = readKey(settings, field.key);
51
+ if (value === undefined) continue;
52
+ if (!check(field, value)) throw Error(field.label+' 设置无效');
53
+ setKey(cfg, field.key, value);
54
+ }
55
+ }
47
56
  if(settings.speech!==undefined){
48
57
  if(!settings.speech||typeof settings.speech!=='object'||Array.isArray(settings.speech))throw Error('speech 须为配置对象');
49
58
  for(const [key,value]of Object.entries(settings.speech)){
@@ -65,8 +74,10 @@ export function validateSettings(dir, settings) {
65
74
  options(settings, dir);
66
75
  if (typeof settings.sessionId !== 'string' || !settings.sessionId.trim() || settings.sessionId.length > 512 || /[\x00-\x1f\x7f]/.test(settings.sessionId)) throw Error('请指定有效的 DSH 会话 ID');
67
76
  }
68
- export function saveSettings(dir, settings) {
69
- validateSettings(dir,settings);
77
+ export function saveSettings(dir, settings, { allowUnbound = false } = {}) {
78
+ if (allowUnbound && settings.sessionId === undefined) options(settings, dir);
79
+ else validateSettings(dir,settings);
80
+ mkdirSync(dir,{recursive:true,mode:0o700});
70
81
  const tmp = join(dir, randomUUID()+'.tmp');
71
82
  writeFileSync(tmp, JSON.stringify(settings,null,2)+'\n', {mode:0o600});
72
83
  renameSync(tmp,join(dir,'client.json'));
package/src/panel.mjs ADDED
@@ -0,0 +1,192 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { existsSync, readFileSync } from 'node:fs';
3
+ import { isAbsolute, join } from 'node:path';
4
+ import { clientVersions, loadSettings, options, pinServer, saveSettings } from './local.mjs';
5
+ import { settingsNamespace } from './settings.mjs';
6
+ import { sections, check, readKey, setKey } from '../web/fields.mjs';
7
+
8
+ export const panelPath = '/starpost/settings';
9
+ const assets = new Map([
10
+ ['', ['index.html','text/html']], ['index.html',['index.html','text/html']],
11
+ ['app.mjs',['app.mjs','text/javascript']], ['fields.mjs',['fields.mjs','text/javascript']], ['style.css',['style.css','text/css']]
12
+ ]);
13
+ const error = (message, status = 400) => Object.assign(new Error(message), {status});
14
+ function project(cfg) {
15
+ const flat = {...cfg, ...cfg.notifications};
16
+ return Object.fromEntries(Object.values(sections).flatMap(section => section.fields.map(f => [f.key,readKey(flat,f.key)])));
17
+ }
18
+ const digest = value => createHash('sha256').update(JSON.stringify(value)).digest('hex');
19
+ function loopback(host) { return ['127.0.0.1','localhost','[::1]'].includes(host); }
20
+ function serviceOrigin(value) {
21
+ let url;
22
+ try { url=new URL(value); } catch { throw error('服务地址无效'); }
23
+ if (!(url.protocol==='https:' || url.protocol==='http:' && loopback(url.hostname)) ||
24
+ url.username || url.password || url.search || url.hash || url.pathname!=='/') throw error('请输入 HTTPS 服务根地址,本机测试可使用 HTTP 回环地址');
25
+ return url.origin;
26
+ }
27
+ function hasPrivateUrlParts(url) {
28
+ return Boolean(url.username || url.password || url.hash || [...url.searchParams.keys()].some(key=>/token|secret|password|signature|api.?key|authorization|credential|^key$|^sig$/i.test(key)));
29
+ }
30
+ function forDisplay(values) {
31
+ const clean={...values}, masked=[];
32
+ for (const key of Object.keys(clean).filter(key=>key.endsWith('Url') && clean[key])) {
33
+ try { if (!hasPrivateUrlParts(new URL(clean[key]))) continue; } catch {}
34
+ masked.push(key); clean[key]='';
35
+ }
36
+ return {values:clean, masked};
37
+ }
38
+
39
+ export function makePanel({dir, sessions, runtime, nativeSettings, withWorld, entry = {}}) {
40
+ async function config() {
41
+ const file = loadSettings(dir), service = nativeSettings();
42
+ const descriptor = service && (await service.describe()).find(d => d.ns === settingsNamespace);
43
+ const resolved=options({...file,...entry,...descriptor?.user},dir);
44
+ const saved=project(resolved);
45
+ return {file, descriptor, service, saved, resolved, revision:digest([file, saved, descriptor?.revision ?? null])};
46
+ }
47
+ async function account(world) {
48
+ const invoke = world.webUi().invoke;
49
+ const [identity,hub] = await Promise.all([invoke('viewer','status',[]), invoke('viewer','hubStatus',[])]);
50
+ const pending = hub.pending;
51
+ return {botId:identity.botId, registered:identity.registered, mode:hub.mode, expired:Boolean(hub.expired),
52
+ pending:pending ? {shortCode:pending.shortCode,verificationUri:pending.verificationUri,expiresAt:pending.expiresAt} : null};
53
+ }
54
+ async function state() {
55
+ const cfg = await config(), running = runtime(), choices = await sessions();
56
+ const sessionId = cfg.file.sessionId || '';
57
+ if (sessionId && !choices.some(s=>s.id===sessionId)) choices.push({id:sessionId,title:'已保存的会话'});
58
+ const active = project(running.cfg);
59
+ const identity=await withWorld(account);
60
+ const display=forDisplay(cfg.saved);
61
+ const connection={serverUrl:cfg.resolved.serverUrl,hubUrl:serviceOrigin(cfg.resolved.hubUrl),
62
+ locked:identity.registered || Boolean(identity.pending) || existsSync(join(dir,'server-origin'))};
63
+ return { ...clientVersions, sessions:choices, sessionId, runtimeSession:running.sessionId || '',
64
+ ready:running.ready, runtimeError:running.error, account:identity, connection,
65
+ saved:display.values, masked:display.masked, active:forDisplay(active).values, revision:cfg.revision, native:Boolean(cfg.descriptor),
66
+ pendingRestart:sessionId !== (running.sessionId || '') || Object.keys(active).some(key=>active[key] !== cfg.saved[key]) ||
67
+ running.cfg.serverUrl!==cfg.resolved.serverUrl || running.cfg.hubUrl!==cfg.resolved.hubUrl };
68
+ }
69
+ async function perform(action, body) {
70
+ if (action==='state') return state();
71
+ if (action==='save') {
72
+ // Share the runtime/CLI data-directory lock for the full read–validate–write.
73
+ return withWorld(async world => {
74
+ const cfg = await config();
75
+ if (body.revision !== cfg.revision) throw error('设置已在其他页面修改,请重新载入后再保存。',409);
76
+ if (body.section==='account') {
77
+ const list = await sessions();
78
+ if (!list.some(s=>s.id===body.sessionId) && (!cfg.file.sessionId || cfg.file.sessionId !== body.sessionId)) throw error('请选择当前 DSH 中的会话');
79
+ saveSettings(dir,{...cfg.file,sessionId:body.sessionId});
80
+ return {};
81
+ }
82
+ if (body.section==='connection') {
83
+ const id=await account(world);
84
+ if (id.registered || id.pending || existsSync(join(dir,'server-origin'))) throw error('该数据目录已绑定服务');
85
+ saveSettings(dir,{...cfg.file,serverUrl:serviceOrigin(body.serverUrl),hubUrl:serviceOrigin(body.hubUrl)},{allowUnbound:true});
86
+ return {};
87
+ }
88
+ if (!Object.hasOwn(sections,body.section) || !body.values || typeof body.values!=='object' || Array.isArray(body.values)) throw error('设置栏目无效');
89
+ const fields=sections[body.section].fields, changes=Object.entries(body.values);
90
+ if (!changes.length) return {};
91
+ for (const [key,value] of changes) {
92
+ const field=fields.find(f=>f.key===key);
93
+ if (!field || !check(field,value)) throw error((field?.label ?? '配置项')+' 的值无效');
94
+ if (key.endsWith('Url') && value) {
95
+ let url;
96
+ try { url = new URL(value); } catch { throw error(field.label+' 地址无效'); }
97
+ if (!(url.protocol==='https:' || url.protocol==='http:' && loopback(url.hostname)) || hasPrivateUrlParts(url)) throw error(field.label+' 请使用 HTTPS 或本机 HTTP 地址,密钥请通过环境变量提供');
98
+ }
99
+ if (['speech.ffmpegPath','speech.silkPath'].includes(key) && value && !isAbsolute(value)) throw error(field.label+' 请填写绝对路径');
100
+ setKey(cfg.file,key,value);
101
+ }
102
+ options(cfg.file,dir);
103
+ if (body.section==='notify' && cfg.descriptor) {
104
+ await cfg.service.update(settingsNamespace,body.values,cfg.descriptor.revision);
105
+ } else {
106
+ if (body.section==='notify' && changes.some(([key])=>Object.hasOwn(entry,key))) throw error('该项由 DSH 启动配置覆盖,请在宿主设置中修改。');
107
+ saveSettings(dir,cfg.file,{allowUnbound:true});
108
+ }
109
+ return {};
110
+ });
111
+ }
112
+ if (!['profile','hubBegin','hubFinish','hubCancel','register','login'].includes(action)) throw error('接口不存在',404);
113
+ return withWorld(async world => {
114
+ const invoke=world.webUi().invoke, before=await account(world);
115
+ if (action==='profile') {
116
+ if (!before.botId) throw error('请先登录星邮');
117
+ const result=await invoke('viewer','profileRead',[before.botId,'basic']);
118
+ return {nickname:String(result.nickname ?? '').slice(0,120)};
119
+ }
120
+ if (action==='hubCancel') { await invoke('viewer',action,[]); return {}; }
121
+ const settings=loadSettings(dir);
122
+ if (!settings.sessionId) throw error('请先选择并保存 DSH 会话');
123
+ if (action==='hubFinish') {
124
+ const result=await invoke('viewer',action,[]);
125
+ return {status:result.status};
126
+ }
127
+ pinServer(dir,settings);
128
+ if (action==='hubBegin') {
129
+ if (before.pending && before.pending.expiresAt>Date.now()) throw error('已有配对等待确认,可继续或取消。');
130
+ if (before.pending) await invoke('viewer','hubCancel',[]);
131
+ await invoke('viewer',action,['星邮 DSH · '+settings.sessionId.slice(0,50)]);
132
+ } else {
133
+ if (before.registered) throw error('本机已有星邮账号');
134
+ if (action==='register') {
135
+ if (body.confirm!==true) throw error('请确认注册新账号');
136
+ await invoke('viewer','register',[]);
137
+ } else {
138
+ const data=body.credential;
139
+ if (!data || typeof data.botId!=='string' || typeof data.token!=='string') throw error('请选择包含 botId 和 token 的星邮凭据文件');
140
+ await invoke('viewer','login',[data.botId,JSON.stringify({version:data.version,botId:data.botId,token:data.token})]);
141
+ }
142
+ }
143
+ return {};
144
+ });
145
+ }
146
+ let queue=Promise.resolve();
147
+ return async (action,body={}) => {
148
+ const task=queue.then(()=>perform(action,body));
149
+ queue=task.catch(()=>{});
150
+ return task;
151
+ };
152
+ }
153
+
154
+ export function panelHandler(run) {
155
+ return async (req,res) => {
156
+ const json=(code,obj)=>{res.writeHead(code,{'content-type':'application/json; charset=utf-8'}); res.end(JSON.stringify(obj));};
157
+ res.setHeader('Cache-Control','no-store');
158
+ res.setHeader('X-Content-Type-Options','nosniff');
159
+ res.setHeader('Referrer-Policy','no-referrer');
160
+ res.setHeader('Content-Security-Policy',"default-src 'none'; script-src 'self'; style-src 'self'; connect-src 'self'; frame-ancestors 'self'; base-uri 'none'; form-action 'none'");
161
+ try {
162
+ if (!['127.0.0.1','::1','::ffff:127.0.0.1'].includes(req.socket.remoteAddress) ||
163
+ !/^(localhost|127\.0\.0\.1|\[::1\])(:[0-9]{1,5})?$/i.test(req.headers.host || '') ||
164
+ ['forwarded','x-forwarded-for','x-forwarded-host'].some(key=>req.headers[key])) throw error('请在运行 DSH 的本机打开设置',403);
165
+ const origin=(req.socket.encrypted?'https://':'http://')+req.headers.host;
166
+ const pathname=new URL(req.url,origin).pathname;
167
+ if (pathname===panelPath) {res.writeHead(302,{location:panelPath+'/'});return res.end();}
168
+ if (!pathname.startsWith(panelPath+'/')) throw error('页面不存在',404);
169
+ const name=pathname.slice(panelPath.length+1);
170
+ if (req.method==='GET' && assets.has(name)) {
171
+ const [file,type]=assets.get(name);
172
+ const bytes=readFileSync(new URL('../web/'+file,import.meta.url));
173
+ res.writeHead(200,{'content-type':type+'; charset=utf-8'});return res.end(bytes);
174
+ }
175
+ if (!/^api\/[a-zA-Z]+$/.test(name)) throw error('页面不存在',404);
176
+ const action=name.slice(4);
177
+ if (req.headers['x-starpost-panel']!=='1' || (req.headers.origin && req.headers.origin!==origin)) throw error('请求来源无效',403);
178
+ if (action==='state' && req.method==='GET') return json(200,await run(action));
179
+ if (req.method!=='POST' || action==='state') throw error('请求方法无效',405);
180
+ if (req.headers.origin!==origin || !/^application\/json(?:;|$)/i.test(req.headers['content-type'] || '')) throw error('请求来源或格式无效',403);
181
+ let size=0;const chunks=[];
182
+ for await (const chunk of req) { size+=chunk.length;if(size>16384)throw error('请求过大',413);chunks.push(chunk); }
183
+ let body;
184
+ try {body=JSON.parse(Buffer.concat(chunks).toString('utf8'));} catch {throw error('无效的 JSON');}
185
+ if (!body || typeof body!=='object' || Array.isArray(body)) throw error('请求格式无效');
186
+ return json(200,await run(action,body));
187
+ } catch (cause) {
188
+ const msg=String(cause.message || '操作失败').replace(/\b[A-Za-z0-9_+./=-]{48,}\b/g,'[已隐藏]').slice(0,350);
189
+ return json(Number.isInteger(cause.status) && cause.status>=400 && cause.status<=599 ? cause.status : 400,{error:msg});
190
+ }
191
+ };
192
+ }
package/web/app.mjs ADDED
@@ -0,0 +1,168 @@
1
+ import {sections} from './fields.mjs';
2
+ const $ = id=>document.getElementById(id);
3
+ function el(tag,text,cls) {
4
+ const node=document.createElement(tag);
5
+ if(text!==undefined) node.textContent=text;
6
+ if(cls) node.className=cls;
7
+ return node;
8
+ }
9
+ const labels={account:'账号与会话',...Object.fromEntries(Object.entries(sections).map(([id,s])=>[id,s.title])),connection:'服务连接'};
10
+ const icons={account:'M20 21v-2a7 7 0 0 0-14 0v2 M17 7a4 4 0 1 1-8 0 4 4 0 0 1 8 0',notify:'M3 5h18v13H9l-5 4v-4H3z M7 9h10 M7 13h6',limits:'M3 6h18 M3 12h18 M3 18h18 M9 3v6 M16 9v6 M8 15v6',media:'M3 4h18v16H3z M4 17l6-6 4 4 3-3 4 4 M15 8h2',speech:'M9 4a3 3 0 0 1 6 0v7a3 3 0 0 1-6 0z M5 11a7 7 0 0 0 14 0 M12 18v3 M8 21h8'};
11
+ let tab='account',state,nickname='',profileId='',dirty=false,busy=false;
12
+ icons.connection='M9 15l6-6 M8 13l-2 2a3 3 0 0 0 4 4l3-3 M11 8l3-3a3 3 0 0 1 5 4l-3 3';
13
+ function say(text,failed=false){$('notice').textContent=text;$('notice').className=failed?'error':'';}
14
+ async function api(action,body) {
15
+ const headers={'X-Starpost-Panel':'1'};
16
+ const opts={headers,cache:'no-store',credentials:'same-origin'};
17
+ if(body!==undefined){headers['Content-Type']='application/json';opts.method='POST';opts.body=JSON.stringify(body);}
18
+ const res=await fetch('./api/'+action,opts);
19
+ const json=await res.json();
20
+ if(!res.ok)throw Error(json.error || '请求失败');
21
+ return json;
22
+ }
23
+ function btn(label,handler,primary=false) {
24
+ const b=el('button',label,primary?'primary':'');b.type='button';b.addEventListener('click',handler);return b;
25
+ }
26
+ function group(cls='actions'){return el('div',undefined,cls);}
27
+ function card(title,cls='') {
28
+ const c=el('section',undefined,'card '+cls);
29
+ if(title)c.append(el('h2',title));
30
+ return c;
31
+ }
32
+ function field(label,input) {
33
+ const f=el('label',undefined,'field');f.append(el('span',label),input);return f;
34
+ }
35
+ function setBusy(value){busy=value;$('page').inert=value;$('tabs').inert=value;$('reload').disabled=value;}
36
+ async function action(fn) {
37
+ if(busy)return;
38
+ setBusy(true);
39
+ try {await fn();} catch(e){say(e.message,true);} finally {setBusy(false);}
40
+ }
41
+ function resetAllowed(){return !dirty || window.confirm('放弃本页尚未保存的修改?');}
42
+ const baseline=()=>state.pendingRestart?'有设置待生效,重启 DSH 后将使用已保存的配置。':'已读取本机配置。';
43
+ async function refresh(message) {
44
+ const next=await api('state');
45
+ if(next.account.botId!==state?.account.botId)nickname='';
46
+ state=next;dirty=false;render();say(message || baseline());
47
+ if(state.account.botId && profileId!==state.account.botId){
48
+ const id=state.account.botId;profileId=id;
49
+ api('profile',{}).then(result=>{
50
+ if(state.account.botId!==id)return;
51
+ nickname=result.nickname;
52
+ const title=$('accountName');if(title && nickname)title.textContent=nickname;
53
+ }).catch(()=>{ /* The retry button remains available when the relay is offline. */ });
54
+ }
55
+ }
56
+ async function save(data) {
57
+ await api('save',{...data,revision:state.revision});
58
+ await refresh('已保存。');
59
+ say('已保存。'+(state.pendingRestart?'重启 DSH 后生效。':''));
60
+ }
61
+ function edit(){dirty=true;say('有尚未保存的修改。');}
62
+ window.addEventListener('beforeunload',e=>{if(dirty){e.preventDefault();e.returnValue='';}});
63
+ for(const [id,title] of Object.entries(labels)){
64
+ const b=btn(title,()=>{if(!state || id===tab || !resetAllowed())return;tab=id;dirty=false;render();say(baseline());});
65
+ const svg=document.createElementNS('http://www.w3.org/2000/svg','svg'),p=document.createElementNS(svg.namespaceURI,'path');
66
+ svg.setAttribute('viewBox','0 0 24 24');svg.setAttribute('fill','none');svg.setAttribute('stroke','currentColor');svg.setAttribute('stroke-width','1.8');svg.setAttribute('aria-hidden','true');p.setAttribute('d',icons[id]);svg.append(p);b.prepend(svg);b.dataset.tab=id;$('tabs').append(b);
67
+ }
68
+ $('reload').onclick=()=>action(async()=>{if(resetAllowed())await refresh();});
69
+ function display(f,v){return f.choices?.find(x=>x[0]===v)?.[1] ?? (f.type==='checkbox'?(v?'开启':'关闭'):String(f.scale?v/f.scale:v || '默认'));}
70
+ function accountPage() {
71
+ const {account:a}=state, hero=card(a.registered?(nickname || '已登录的 bot'):'尚未登录星邮','hero');
72
+ hero.querySelector('h2').id='accountName';
73
+ const status=el('p',a.registered?'星邮 ID '+a.botId+' · '+(a.mode==='hub'?'FFA Hub 配对':'本机凭据登录'):'选择 DSH 会话后,使用 FFA Hub 在浏览器中配对。');hero.append(status);
74
+ hero.append(el('div',state.ready?'已连接到 DSH 会话':a.expired?'Hub 授权已到期':state.runtimeSession?'等待会话就绪':'尚未启用接收','badge'));
75
+ if(state.runtimeError)hero.append(el('p',state.runtimeError,'aux'));
76
+ if(a.registered)hero.append(btn('读取 bot 昵称',()=>action(async()=>{nickname=(await api('profile',{})).nickname;hero.querySelector('h2').textContent=nickname || '已登录的 bot';say(nickname?'已读取昵称。':'该 bot 尚未设置昵称。');})));
77
+ const bind=card('DSH 会话'), select=el('select');
78
+ select.append(new Option('选择一个会话',''));
79
+ for(const s of state.sessions)select.append(new Option(s.title?s.title+' · '+s.id:s.id,s.id));
80
+ select.value=state.sessionId;select.onchange=edit;
81
+ bind.append(field('用于收发消息的会话',select));
82
+ if(!state.sessions.length)bind.append(el('p','请先在 DSH 中创建一个会话,然后点击重新载入。'));
83
+ const controls=group(), saveSession=btn('保存会话',()=>action(async()=>{if(!select.value)throw Error('请选择 DSH 会话');await save({section:'account',sessionId:select.value});}),true);
84
+ controls.append(saveSession);bind.append(controls);
85
+ if(state.runtimeSession)bind.append(el('p','本次启动使用的会话 · '+state.runtimeSession,'aux'));
86
+ const auth=card('FFA Hub 登录'), pending=a.pending;
87
+ function command(op,body={},ok='操作完成。'){
88
+ return ()=>action(async()=>{
89
+ if(dirty)throw Error('请先保存会话,或重新载入以放弃改动。');
90
+ const result=await api(op,body);
91
+ const messages={pending:'浏览器授权尚未完成。',awaiting_primary:'请管理员在 Hub 指定本安装为主运行端,再检查授权。',connected:'Hub 配对成功。'};
92
+ await refresh((messages[result.status] || ok)+(result.status==='connected' || op==='login' || op==='register'?' 重启 DSH 后启用收发。':''));
93
+ });
94
+ }
95
+ if(pending){
96
+ const expired=Date.now()>=pending.expiresAt;
97
+ auth.append(el('p',expired?'本次配对已过期,请重新开始。':'在 Hub 中选择要连接的 bot,并核对配对码。'));
98
+ if(!expired){
99
+ auth.append(el('div',pending.shortCode,'code'));
100
+ const uri=new URL(pending.verificationUri);
101
+ if(uri.protocol==='https:' || (uri.protocol==='http:' && ['127.0.0.1','localhost','[::1]'].includes(uri.hostname))){
102
+ const link=el('a','打开 FFA Hub ↗','action primary');link.href=uri.href;link.target='_blank';link.rel='noopener noreferrer';auth.append(link);
103
+ }
104
+ }
105
+ const buttons=group();
106
+ buttons.append(expired?btn('重新配对',command('hubBegin',{},'已生成新的配对码。')):btn('检查授权并完成登录',command('hubFinish')),btn('取消配对',command('hubCancel',{},'已取消配对。')));auth.append(buttons);
107
+ } else {
108
+ auth.append(btn(a.mode==='hub'?'重新配对':'开始浏览器配对',command('hubBegin',{},'配对码已生成,请打开 FFA Hub。'),true));
109
+ }
110
+ const nodes=[hero,bind,auth];
111
+ if(!a.registered){
112
+ const box=el('details',undefined,'card');box.append(el('summary','使用原星邮凭据或注册新 bot'));
113
+ const file=el('input');file.type='file';file.accept='.json,application/json';
114
+ const controls=group();
115
+ controls.append(btn('恢复已有账号',()=>action(async()=>{
116
+ if(dirty || !state.sessionId)throw Error('请先保存 DSH 会话');
117
+ const chosen=file.files[0];if(!chosen || chosen.size>8192)throw Error('请选择星邮凭据 JSON 文件(最大 8 KB)');
118
+ let data;try{data=JSON.parse((await chosen.text()).replace(/^\uFEFF/,''));}catch{throw Error('凭据文件格式无效');}
119
+ await api('login',{credential:data});file.value='';await refresh('账号已恢复,重启 DSH 后启用收发。');
120
+ })),btn('注册新 bot',()=>{if(confirm('为此安装创建一个新的星邮 bot 账号?'))command('register',{confirm:true},'已注册新 bot。')();}));
121
+ box.append(field('本机星邮凭据文件',file),controls);nodes.push(box);
122
+ }
123
+ return nodes;
124
+ }
125
+ function settingsPage(){
126
+ const section=sections[tab], box=card();
127
+ box.append(el('p',section.hint));
128
+ const form=el('form'),grid=group('grid'),inputs=new Map();
129
+ for(const f of section.fields){
130
+ let input;
131
+ if(f.type==='select'){input=el('select');for(const [v,l] of f.choices)input.append(new Option(l,v));}
132
+ else {input=el('input');input.type=f.type;if(f.type==='number'){input.min=f.min/f.scale;input.max=f.max/f.scale;input.step=f.step==='any'?'any':1/f.scale;input.required=true;}else if(f.type==='text')input.maxLength=2048;}
133
+ const saved=state.saved[f.key];if(f.type==='checkbox')input.checked=saved;else input.value=f.scale?saved/f.scale:saved;
134
+ input.name=f.key;input.oninput=edit;const label=field(f.label,input);
135
+ if(f.hint)label.append(el('small',f.hint));
136
+ if(state.masked.includes(f.key))label.append(el('small','已隐藏原地址。填写新地址可替换原值。'));
137
+ if(state.active[f.key]!==saved)label.append(el('small','本次启动 · '+display(f,state.active[f.key]),'pending'));
138
+ inputs.set(f,input);grid.append(label);
139
+ }
140
+ const foot=group('formFoot'),submit=el('button','保存设置','primary');submit.type='submit';
141
+ foot.append(submit,el('span','修改后重启 DSH 生效','aux'));form.append(grid,foot);
142
+ form.onsubmit=e=>{e.preventDefault();action(async()=>{
143
+ const values={};for(const [f,input] of inputs){let v=input.value;if(f.type==='number'){v=Number(v)*f.scale;if(f.step!=='any')v=Math.round(v);}if(f.type==='checkbox')v=input.checked;if(v!==state.saved[f.key])values[f.key]=v;}
144
+ if(!Object.keys(values).length){dirty=false;say('设置没有改动。');return;}
145
+ await save({section:tab,values});
146
+ });};
147
+ box.append(form);return [box];
148
+ }
149
+ function connectionPage() {
150
+ const c=state.connection,box=card('中转与身份认证'),form=el('form'),grid=group('grid'),inputs={};
151
+ box.append(el('p',c.locked?'当前账号数据已绑定以下服务。':'官方地址已预填。使用自建服务时,请在注册或配对前保存地址。'));
152
+ for(const [key,label] of [['serverUrl','星邮中转服务'],['hubUrl','FFA Hub 账号中心']]){
153
+ const input=el('input');input.type='url';input.required=true;input.value=c[key];input.readOnly=c.locked;input.oninput=edit;
154
+ inputs[key]=input;grid.append(field(label,input));
155
+ }
156
+ form.append(grid);
157
+ if(!c.locked){
158
+ const foot=group('formFoot'),b=el('button','保存服务地址','primary');b.type='submit';foot.append(b);form.append(foot);
159
+ }
160
+ form.onsubmit=e=>{e.preventDefault();action(()=>save({section:'connection',serverUrl:inputs.serverUrl.value,hubUrl:inputs.hubUrl.value}));};
161
+ box.append(form);return [box];
162
+ }
163
+ function render(){
164
+ for(const b of $('tabs').children){if(b.dataset.tab===tab)b.setAttribute('aria-current','page');else b.removeAttribute('aria-current');}
165
+ $('version').textContent='v'+state.pluginVersion;$('title').textContent=labels[tab];
166
+ $('page').replaceChildren(...(tab==='account'?accountPage():tab==='connection'?connectionPage():settingsPage()));
167
+ }
168
+ action(()=>refresh());
package/web/client.js ADDED
@@ -0,0 +1,16 @@
1
+ window.__ModuleLoader__.load({
2
+ id: 'dsh-plugin-starpost',
3
+ factory(require) {
4
+ const React = require('react');
5
+ const url = '/starpost/settings/';
6
+ function Panel() {
7
+ return React.createElement('section', {style:{width:'100%',minWidth:0}},
8
+ React.createElement('a',{href:url,target:'_blank',rel:'noopener noreferrer'},'在独立窗口打开星邮设置 ↗'),
9
+ React.createElement('iframe',{src:url,title:'星邮配置',style:{display:'block',width:'100%',height:'min(78vh, 900px)',minHeight:360,border:0,marginTop:12}}));
10
+ }
11
+ return {inject:['slots'],apply(ctx) {
12
+ ctx.slots.inject('plugins.bundle.config',()=>ctx.slots.register({name:'plugins.bundle.config',key:'dsh-plugin-starpost'},Panel));
13
+ ctx.slots.inject('settings.plugins.tab',()=>ctx.slots.register({name:'settings.plugins.tab',id:'starpost',order:40,label:()=>'星邮'},Panel));
14
+ }};
15
+ }
16
+ });
package/web/fields.mjs ADDED
@@ -0,0 +1,49 @@
1
+ // Shared by the local settings form and its allowlisted write API.
2
+ const select = (key, label, choices) => ({ key, label, choices, type: 'select' });
3
+ const num = (key, label, min, max, scale = 1, step = 1) => ({ key, label, min, max, scale, step, type: 'number' });
4
+ const str = (key, label, hint) => ({ key, label, hint, type: 'text' });
5
+ const protocol = [['openai','OpenAI 兼容'],['json','JSON']];
6
+ const notify = [['manual','手动查看'],['digest','汇总提醒'],['realtime','实时提醒']];
7
+ export const sections = {
8
+ notify: { title:'消息接收', hint:'日常聊天按所选模式接收。主人专属消息和参赛消息仍会及时送达。广场或动态选择手动查看后,也会关闭更新数量提醒。', fields:[
9
+ select('receiveMode','日常聊天',[['active','主动查看'],['passive','被动投递'],['mixed','混合模式']]),
10
+ select('squareMode','广场与公开开桌',notify), select('feedMode','好友动态与评论',notify),
11
+ num('digestIntervalMs','汇总间隔(秒)',1000,86400000,1000)
12
+ ]},
13
+ limits: { title:'额度与防刷', hint:'工作日时段按北京时间计算。周末保留每日额度。', fields:[
14
+ num('maxMessagesPerDay','每日消息数',0,1000000),num('maxWerewolfGamesPerDay','每日狼人杀局数',0,1000),
15
+ num('maxPrivateChats','私聊数量上限',0,1000),num('maxGroups','群聊数量上限',0,1000),
16
+ num('deliveryIntervalMs','聊天合批间隔(秒)',1000,300000,1000),
17
+ num('periodLimits.morning','09:00–12:00 消息数',0,1000000),num('periodLimits.afternoon','14:00–18:00 消息数',0,1000000),
18
+ num('periodLimits.sleep','00:00–06:00 消息数',0,1000000),num('groupSpeak.maxPerWindow','单群窗口发言数',1,1000),
19
+ num('groupSpeak.windowSec','群聊窗口(秒)',1,86400),num('antiLoop.maxConsecutiveBotTurns','连续发言上限',1,100),
20
+ num('antiLoop.idleToEndSec','静默收尾(秒)',0,86400),num('proactive.topicSimilarity','主动话题相似度上限',0,1,1,'any')
21
+ ]},
22
+ media: {title:'表情包', hint:'目录可以填写本机 qq-final 的 emoji 路径。需要导入旧标签时,可指定 QQ 标签索引文件。', fields:[
23
+ str('emojiDir','表情包目录','留空使用插件数据目录中的 emoji'),
24
+ {key:'sticker.enabled',label:'自动收藏收到的表情包',type:'checkbox'},
25
+ num('sticker.maxFiles','收藏数量上限',1,50000),str('sticker.qqIndexFile','QQ 标签索引路径(可选)')
26
+ ]},
27
+ speech: {title:'语音与转换',hint:'可接入本机或云端服务。密钥字段只填写环境变量名,由运行 DSH 的进程读取。',fields:[
28
+ str('speech.audioDir','语音文件目录'),str('speech.asrUrl','语音识别 ASR 接口'),select('speech.asrProtocol','ASR 协议',protocol),
29
+ str('speech.asrModel','识别模型'),str('speech.asrKeySecret','ASR 密钥环境变量名'),
30
+ str('speech.ttsUrl','语音合成 TTS 接口'),select('speech.ttsProtocol','TTS 协议',protocol),
31
+ str('speech.ttsModel','合成模型'),str('speech.ttsVoice','音色'),str('speech.ttsKeySecret','TTS 密钥环境变量名'),
32
+ str('speech.ffmpegPath','FFmpeg 可执行文件路径'),str('speech.silkPath','SILK 解码器路径'),
33
+ str('speech.converterUrl','音频转换 HTTP 接口'),str('speech.converterKeySecret','转换服务密钥环境变量名')
34
+ ]}
35
+ };
36
+ export function check(field, value) {
37
+ if (field.type === 'select') return field.choices.some(([v]) => v === value);
38
+ if (field.type === 'number') return Number.isFinite(value) && (field.step === 'any' || Number.isInteger(value)) && value >= field.min && value <= field.max;
39
+ if (field.type === 'checkbox') return typeof value === 'boolean';
40
+ return typeof value === 'string' && value.length <= 2048 && !/[\u0000-\u001f\u007f]/.test(value);
41
+ }
42
+ export function readKey(obj, key) {
43
+ return key.split('.').reduce((value, part) => value?.[part], obj);
44
+ }
45
+ export function setKey(obj, key, value) {
46
+ const [section, field] = key.split('.');
47
+ if (field) obj[section] = { ...obj[section], [field]:value };
48
+ else obj[key] = value;
49
+ }
package/web/index.html ADDED
@@ -0,0 +1,6 @@
1
+ <!doctype html>
2
+ <html lang="zh-CN"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="color-scheme" content="light dark"><title>星邮 · DSH 设置</title><link rel="stylesheet" href="./style.css"><script type="module" src="./app.mjs"></script></head>
3
+ <body><header><div class="identity"><span class="mark" aria-hidden="true">✦</span><strong>星邮</strong><span class="divider"></span><span>DeepSeek Harness</span></div><span id="version"></span></header>
4
+ <div class="layout"><nav aria-label="配置栏目"><h2>插件设置</h2><div id="tabs"></div></nav>
5
+ <main><div class="heading"><h1 id="title">账号与会话</h1><button id="reload" type="button">重新载入</button></div>
6
+ <p id="notice" role="status" aria-live="polite">正在读取本机配置…</p><div id="page"></div></main></div></body></html>
package/web/style.css ADDED
@@ -0,0 +1,3 @@
1
+ :root{color-scheme:light dark;--bg:#f6f7fc;--surface:#fff;--ink:#222638;--muted:#59617a;--line:#dce0ed;--accent:#464baf;--soft:#ecebff;--success:#17654c;--warn:#8a4908;--error:#9c2543;font:15px/1.55 "Segoe UI","Microsoft YaHei",system-ui,sans-serif;color:var(--ink);background:var(--bg)}
2
+ @media(prefers-color-scheme:dark){:root{--bg:#161824;--surface:#202231;--ink:#e9e8f4;--muted:#b4b8d2;--line:#3c4057;--accent:#bdbdff;--soft:#343452;--success:#83dbb7;--warn:#ffc585;--error:#ffabc0}}
3
+ *{box-sizing:border-box}body{margin:0}header,.layout{max-width:1240px;margin:auto}header{display:flex;align-items:center;justify-content:space-between;padding:24px clamp(16px,4vw,52px);border-bottom:1px solid var(--line);gap:12px}.identity{display:flex;align-items:center;gap:12px;color:var(--muted)}.identity strong{font-size:22px;color:var(--ink)}.mark{display:grid;place-items:center;background:var(--accent);color:var(--surface);width:36px;height:36px;border-radius:12px;font-size:26px}.divider{height:17px;border-left:1px solid var(--line)}#version{font-size:12px;color:var(--muted)}.layout{display:grid;grid-template-columns:178px 1fr;gap:clamp(18px,4vw,52px);padding:28px clamp(16px,4vw,52px) 50px}nav h2{font-size:13px;color:var(--muted);margin:6px 12px 14px}#tabs{display:grid;gap:6px}button,a.action{border:1px solid var(--line);border-radius:10px;padding:8px 14px;font:inherit;font-weight:600;cursor:pointer;color:var(--ink);background:var(--surface);text-decoration:none}button:hover,a.action:hover{border-color:var(--accent);color:var(--accent)}button:disabled{opacity:.56;cursor:default}button.primary,a.primary{background:var(--accent);color:var(--surface);border-color:var(--accent)}#tabs button{display:flex;align-items:center;gap:12px;text-align:left;border-color:transparent;background:transparent;color:var(--muted)}#tabs button[aria-current=page]{background:var(--soft);color:var(--accent)}#tabs svg{width:18px;height:18px;flex:none}.heading,.row,.actions{display:flex;align-items:center;gap:12px;flex-wrap:wrap}.heading{justify-content:space-between}.heading h1{font-size:clamp(24px,3.3vw,34px);letter-spacing:-.035em;margin:0}.row{justify-content:space-between}.card{background:var(--surface);border:1px solid var(--line);border-radius:18px;padding:clamp(16px,2.5vw,28px);margin:14px 0}.hero{background:var(--soft);border-color:transparent}.card h2{font-size:19px;margin:0 0 6px}.card p{margin:6px 0 14px;color:var(--muted)}.grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:20px 18px}.field{display:grid;gap:6px;align-content:start;min-width:0}.field>span{font-weight:600}.field small,.aux{color:var(--muted);font-size:13px;overflow-wrap:anywhere}.field input:not([type=checkbox]),select{width:100%;height:42px;border:1px solid var(--line);border-radius:9px;background:var(--bg);color:var(--ink);font:inherit;padding:7px 10px}.field input[type=checkbox]{justify-self:start;width:22px;height:22px;accent-color:var(--accent)}:focus-visible{outline:3px solid var(--accent);outline-offset:2px}.actions{margin-top:18px}.row .actions{margin-top:0}.code{font:600 24px/1.6 ui-monospace,monospace;letter-spacing:.16em}.badge{color:var(--success);font-size:13px;font-weight:650}.warn,.field small.pending{color:var(--warn)}#notice{min-height:1.5em;color:var(--muted);margin:8px 0}#notice.error{color:var(--error)}#page{min-width:0}details summary{cursor:pointer;font-weight:650}details[open] summary{margin-bottom:12px}.formFoot{border-top:1px solid var(--line);padding-top:15px;display:flex;align-items:center;gap:14px;flex-wrap:wrap;margin-top:24px}.full{width:100%}a{color:var(--accent)}@media(max-width:740px){.layout{display:block;padding-top:14px}nav h2{display:none}#tabs{display:flex;overflow-x:auto;gap:2px;margin:0 0 20px;padding:4px 1px}#tabs button{white-space:nowrap;padding:8px 10px}#tabs svg{display:none}header{padding-block:14px}}@media(max-width:500px){.grid{grid-template-columns:1fr}.identity{gap:7px}.heading button{font-size:13px}.card{border-radius:14px}.layout{padding-inline:12px}}