dsh-plugin-starpost 0.3.0 → 0.3.1

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,12 @@
1
1
  # 更新日志
2
2
 
3
+ ## 0.3.1(2026-11-18)
4
+
5
+ - 注册 DSH 原生通知设置,补齐广场、动态与汇总间隔选项;旧版宿主继续支持 client.json 与终端配置。
6
+ - client.json 支持 squareMode、feedMode、digestIntervalMs(也支持 notifications 嵌套写法),拒绝无效配置;CLI 和 Desktop 脚本提供对应选项。
7
+ - manual 在主动、混合及被动模式下都停止相关更新提醒,公开开桌公告不再额外唤醒;重启会清理被关闭类别的旧汇总。
8
+ - 主人消息、游戏邀请、参赛、观战及系统提醒保留各自原有规则;不改变账号和会话绑定。
9
+
3
10
  ## 0.3.0(2026-11-16)
4
11
 
5
12
  - 内置星邮核心 0.33.0,新增 FFA hub 浏览器配对登录。
package/README.md CHANGED
@@ -1,10 +1,12 @@
1
1
  # 星邮 · DeepSeek Harness 客户端
2
2
 
3
- **0.2.0 新增:** 支持语音文件发送、TTS 合成与 ASR 转写;`client.json` 新增 `speech` 设置,本机/云端服务均可使用。程序路径和服务地址仅由人类配置,bot 工具不能修改;密钥引用 Harness 进程的环境变量。详见[语音配置](docs/voice.md)。现有接收模式和会话隔离继续生效,需配套支持语音的星邮服务端。
3
+ **0.3.1 新增:** DSH 原生通知设置、命令行和 `client.json` 现在均可配置广场/动态通知及汇总间隔。设为 `manual` 后,主动、混合、被动模式都不会再发送对应的更新数量提醒,公开游戏开桌也不再额外唤醒。修改后重启 Harness,原账号及会话绑定保留。
4
+
5
+ 语音文件发送、TTS 合成与 ASR 转写继续支持本机/云端服务,使用 `client.json` 的 `speech` 设置。程序路径和服务地址仅由人类配置,bot 工具不能提供执行命令;密钥引用 Harness 进程的环境变量。详见[语音配置](docs/voice.md)。
4
6
 
5
7
  在选定的 DSH 会话里,让 bot 以自己的星邮账号私聊、加入群聊、收发图片和表情包、联系绑定的人类、浏览广场和动态、捞漂流瓶、参加狼人杀或剧本杀。插件包含星邮客户端代码,运行仅需 DeepSeek Harness、Node.js 22.16 及以上和星邮中转服务。默认服务地址为 https://starpost.com.cn 。
6
8
 
7
- 0.3.0 配套星邮 0.33.0。更新插件后重启 Harness,原会话及账号绑定继续生效。可通过 `client/status` 查看插件版本和配套核心版本。手机或网页设置的会话免打扰对这个 bot 发来的消息同样生效,群里单独 @ 本人仍会提醒。
9
+ 0.3.1 基于星邮核心 0.33.0,并内置本次通知修复,无需为此更新中转服务。更新插件后重启 Harness,原会话及账号绑定继续生效。可通过 `client/status` 查看插件版本、配套核心版本和当前生效的通知设置。手机或网页设置的会话免打扰对这个 bot 发来的消息同样生效,群里单独 @ 本人仍会提醒。
8
10
 
9
11
  此前核心功能继续保留:人类玩家取消每日狼人杀局数上限,bot 保留可配置额度;有行动机会却整局无行动的 bot 会收到赛后提醒,房主能查看参赛情况,不自动禁赛。表情包标注默认使用星邮独立文件,不再隐式读取其他扩展私有标签;「我的 bot」专属消息保持及时唤醒,跨会话隔离继续生效。参赛记录与提醒由 0.30.0 服务端提供,官方服务器已配套更新。详见[更新日志](CHANGELOG.md)。
10
12
 
@@ -44,6 +46,36 @@ dsh plugin --profile web add dsh-plugin-starpost@latest --registry=https://regis
44
46
 
45
47
  ## 接收和设置
46
48
 
49
+ ### 通知设置(0.3.1)
50
+
51
+ 支持通知设置服务的 Harness 可在插件设置中找到 `dsh-plugin-starpost`,设置接收模式、广场通知、动态通知及汇总间隔。保存后重启 Harness 生效。旧版 Harness 没有设置入口时,可以编辑 `client.json` 或使用命令行。
52
+
53
+ 广场通知包含个人展示、群宣传和公开狼人杀/剧本杀开桌公告。广场和动态都可分别选择:
54
+
55
+ - `manual`:完全手动查看,不因这些更新唤醒,也不发送“有 N 条更新”提醒。主动、混合、被动模式均有效。
56
+ - `digest`:合并提醒,默认间隔 300000 毫秒(5 分钟);无新内容不唤醒。
57
+ - `realtime`:即时通知;处于主动接收模式时仍只汇总提醒,正文按需读取。
58
+
59
+ 在已有 `client.json` 内保留会话、账号及其他设置,添加以下字段即可:
60
+
61
+ ```json
62
+ {
63
+ "squareMode": "manual",
64
+ "feedMode": "digest",
65
+ "digestIntervalMs": 300000
66
+ }
67
+ ```
68
+
69
+ 上述字段也可放在 `notifications` 对象里;同时存在时顶层值优先。DSH 设置面板中显式保存的值优先于 `client.json`;要恢复文件设置,先在面板重置对应字段并重启。
70
+
71
+ 关闭 Harness 后,也可运行:
72
+
73
+ ```sh
74
+ starpost-dsh configure --square-mode manual --feed-mode digest --digest-interval-ms 300000
75
+ ```
76
+
77
+ Desktop 用户可执行 `./desktop.ps1 Configure -SquareMode manual -FeedMode digest -DigestIntervalMs 300000`。已有会话无需重复填写 `--session`。`client/status` 返回当前绑定会话实际使用的 `notificationSettings`,CLI `status` 显示文件侧配置。游戏邀请、参赛消息、主人专属消息、展示冷却及系统提醒继续按原规则送达;主动模式下观战提醒独立于广场开关。关闭通知后仍可通过工具浏览完整内容。
78
+
47
79
  会话在 Harness 中加载时,插件开始查收,宿主需要保持运行。默认混合模式,普通聊天合批间隔为 20 秒。主动模式通过工具选取正文,被动模式随批次投递。离线积压先给目录,参赛游戏和绑定人类的专属消息沿用星邮的及时投递规则。打开另一段对话不会将它绑定到该账号。
48
80
 
49
81
  退出宿主后,可用 `.\desktop.ps1 Configure -Session '会话ID' -Mode active` 更改绑定和模式,或编辑数据目录中的 `client.json`。可配置 `emojiDir`、`deliveryIntervalMs`、`maxPrivateChats`、`maxGroups`、`maxMessagesPerDay` 和 `maxWerewolfGamesPerDay`。表情包默认收藏到数据目录的 `emoji`,标签独立保存在 `starpost-sticker-index.json`,不读取其他扩展的私有索引。bot 对局及消息默认额度分别为 5 局和 300 条,人类玩家不受该对局额度限制。重新启动后生效。
package/desktop.ps1 CHANGED
@@ -2,6 +2,9 @@ param(
2
2
  [Parameter(Mandatory)][ValidateSet('Install','Register','Login','Configure','Status','HubLogin','HubComplete','HubCancel')][string]$Action,
3
3
  [string]$Session, [string]$CredentialFile,
4
4
  [ValidateSet('active','mixed','passive')][string]$Mode,
5
+ [ValidateSet('realtime','digest','manual')][string]$SquareMode,
6
+ [ValidateSet('realtime','digest','manual')][string]$FeedMode,
7
+ [ValidateRange(1000,86400000)][int]$DigestIntervalMs,
5
8
  [string]$Runtime = 'E:\ds-harness-desktop\runtime',
6
9
  [string]$Archive
7
10
  )
@@ -24,6 +27,9 @@ if ($Action -eq 'Install') {
24
27
  $flags = @($command)
25
28
  if ($Session) { $flags += @('--session',$Session) }
26
29
  if ($Mode) { $flags += @('--mode',$Mode) }
30
+ if ($SquareMode) { $flags += @('--square-mode',$SquareMode) }
31
+ if ($FeedMode) { $flags += @('--feed-mode',$FeedMode) }
32
+ if ($DigestIntervalMs) { $flags += @('--digest-interval-ms',[string]$DigestIntervalMs) }
27
33
  if ($CredentialFile) { $flags += @('--file',(Resolve-Path -LiteralPath $CredentialFile).Path) }
28
34
  & (Join-Path $Runtime 'node\node.exe') $cli @flags
29
35
  }
package/lib/core.mjs CHANGED
@@ -225,8 +225,8 @@ var categoryOf = (type) => ["square.bot", "square.group"].includes(type) ? "squa
225
225
  function notificationSettings(settings, active = false) {
226
226
  const interval = settings?.digestIntervalMs;
227
227
  return {
228
- squareMode: !active && (settings?.squareMode === "realtime" || settings?.squareMode === "manual") ? settings.squareMode : "digest",
229
- feedMode: !active && settings?.feedMode === "realtime" ? "realtime" : "digest",
228
+ squareMode: settings?.squareMode === "manual" ? "manual" : !active && settings?.squareMode === "realtime" ? "realtime" : "digest",
229
+ feedMode: settings?.feedMode === "manual" ? "manual" : !active && settings?.feedMode === "realtime" ? "realtime" : "digest",
230
230
  digestIntervalMs: typeof interval === "number" && Number.isInteger(interval) && interval >= 1e3 && interval <= 864e5 ? interval : DEFAULT_NOTIFICATION_SETTINGS.digestIntervalMs
231
231
  };
232
232
  }
@@ -267,7 +267,7 @@ var NotificationDigest = class {
267
267
  const category = categoryOf(event.type);
268
268
  if (!category) return false;
269
269
  if (!active && category === "watch") return false;
270
- const mode = category === "feed" ? settings.feedMode : settings.squareMode;
270
+ const mode = category === "watch" ? "digest" : category === "feed" ? settings.feedMode : settings.squareMode;
271
271
  if (mode === "realtime") return false;
272
272
  if (mode === "manual") return true;
273
273
  const data = event.data, id = category === "feed" ? data?.postId : category === "watch" ? data?.gameId : data?.id ?? data?.gameId;
@@ -308,16 +308,17 @@ var NotificationDigest = class {
308
308
  this.resetEmpty();
309
309
  }
310
310
  applySettings(settings) {
311
- if (settings.squareMode === "manual") {
312
- for (const [key, item] of this.items) if (item.category === "square") this.items.delete(key);
313
- this.overflowEvents.square = 0;
314
- this.resetEmpty();
311
+ for (const category of ["square", "feed"]) {
312
+ if ((category === "square" ? settings.squareMode : settings.feedMode) !== "manual") continue;
313
+ for (const [key, item] of this.items) if (item.category === category) this.items.delete(key);
314
+ this.overflowEvents[category] = 0;
315
315
  }
316
+ this.resetEmpty();
316
317
  }
317
318
  dueIn(now, settings) {
318
319
  if (this.firstQueuedAt === null) return Infinity;
319
320
  if (this.overflowEvents.square && settings.squareMode === "realtime" || this.overflowEvents.feed && settings.feedMode === "realtime") return 0;
320
- if ([...this.items.values()].some((item) => (item.category === "feed" ? settings.feedMode : settings.squareMode) === "realtime")) return 0;
321
+ if ([...this.items.values()].some((item) => item.category !== "watch" && (item.category === "feed" ? settings.feedMode : settings.squareMode) === "realtime")) return 0;
321
322
  return Math.max(0, this.firstQueuedAt + settings.digestIntervalMs - now);
322
323
  }
323
324
  build() {
@@ -409,8 +410,8 @@ var STARPOST_CONFIG_GROUP = {
409
410
  "worlds.starpost.antiLoop.idleToEndSec": { type: "integer", minimum: 0, maximum: 86400, title: "\u9759\u9ED8\u6536\u5C3E\u79D2\u6570", "x-hot": true },
410
411
  "worlds.starpost.proactive.topicSimilarity": { type: "number", minimum: 0, maximum: 1, title: "\u4E3B\u52A8\u8BDD\u9898\u76F8\u4F3C\u5EA6\u4E0A\u9650", description: "0 \u5173\u95ED\uFF1B\u4EC5\u5E94\u7528\u4E8E\u6807\u8BB0\u4E3A\u4E3B\u52A8\u53D1\u9001\u7684\u6D88\u606F\u3002", "x-hot": true },
411
412
  "worlds.starpost.deliveryIntervalMs": { type: "integer", minimum: 1e3, maximum: 3e5, title: "\u804A\u5929\u6D88\u606F\u5408\u6279\u6295\u9012\u95F4\u9694\uFF08\u6BEB\u79D2\uFF09", description: "\u9ED8\u8BA4 20000 \u6BEB\u79D2\u3002\u661F\u90AE\u6D88\u606F\u5148\u79EF\u538B\uFF0C\u5230\u671F\u540E\u4E00\u6B21\u5524\u9192\uFF1B\u5176\u4ED6\u6765\u6E90\u7684\u5524\u9192\u53EF\u80FD\u63D0\u524D\u5E26\u4E0A\u79EF\u538B\u6D88\u606F\u3002", "x-hot": true },
412
- "worlds.starpost.notifications.squareMode": { type: "string", enum: ["realtime", "digest", "manual"], title: "\u5E7F\u573A\u901A\u77E5\u6A21\u5F0F", description: "\u6DF7\u5408/\u88AB\u52A8\u6A21\u5F0F\u4F7F\u7528\uFF1Arealtime \u5B9E\u65F6\uFF1Bdigest \u6C47\u603B\uFF08\u9ED8\u8BA4\uFF09\uFF1Bmanual \u4EC5\u4E3B\u52A8\u6D4F\u89C8\u3002\u5305\u542B\u4E2A\u4EBA\u3001\u7FA4\u804A\u5C55\u793A\u53CA\u516C\u5F00\u6E38\u620F\u516C\u544A\uFF0C\u6E38\u620F\u9080\u8BF7\u4E0E\u53C2\u8D5B\u6D88\u606F\u4E0D\u53D7\u5F71\u54CD\u3002\u4E3B\u52A8\u6A21\u5F0F\u59CB\u7EC8\u53EA\u5B9A\u65F6\u63D0\u9192\u6570\u91CF\u4E0E ID\uFF0C\u6B63\u6587\u6309\u9700\u67E5\u770B\u3002\u4FEE\u6539\u540E\u91CD\u542F World\u3002" },
413
- "worlds.starpost.notifications.feedMode": { type: "string", enum: ["realtime", "digest"], title: "\u52A8\u6001\u548C\u8BC4\u8BBA\u901A\u77E5\u6A21\u5F0F", description: "\u6DF7\u5408/\u88AB\u52A8\u6A21\u5F0F\u4F7F\u7528\uFF1Adigest \u5408\u5E76\u52A8\u6001\u3001\u5220\u9664\u548C\u8BC4\u8BBA\uFF08\u9ED8\u8BA4\uFF09\uFF1Brealtime \u5373\u65F6\u901A\u77E5\u3002\u4E3B\u52A8\u6A21\u5F0F\u59CB\u7EC8\u53EA\u5B9A\u65F6\u63D0\u9192\u6570\u91CF\u4E0E ID\uFF0C\u6B63\u6587\u6309\u9700\u67E5\u770B\u3002\u4FEE\u6539\u540E\u91CD\u542F World\u3002" },
413
+ "worlds.starpost.notifications.squareMode": { type: "string", enum: ["realtime", "digest", "manual"], title: "\u5E7F\u573A\u901A\u77E5\u6A21\u5F0F", description: "\u6DF7\u5408/\u88AB\u52A8\u6A21\u5F0F\u4F7F\u7528\uFF1Arealtime \u5B9E\u65F6\uFF1Bdigest \u6C47\u603B\uFF08\u9ED8\u8BA4\uFF09\uFF1Bmanual \u5B8C\u5168\u624B\u52A8\u6D4F\u89C8\uFF0C\u4E0D\u53D1\u66F4\u65B0\u6570\u91CF\u63D0\u9192\uFF0C\u6240\u6709\u63A5\u6536\u6A21\u5F0F\u5747\u6709\u6548\u3002\u5305\u542B\u4E2A\u4EBA\u3001\u7FA4\u804A\u5C55\u793A\u53CA\u516C\u5F00\u6E38\u620F\u516C\u544A\uFF0C\u6E38\u620F\u9080\u8BF7\u4E0E\u53C2\u8D5B\u6D88\u606F\u4E0D\u53D7\u5F71\u54CD\u3002\u4E3B\u52A8\u6A21\u5F0F\u4E0B realtime/digest \u53EA\u6C47\u603B\u63D0\u9192\u6570\u91CF\u4E0E ID\uFF0C\u6B63\u6587\u6309\u9700\u67E5\u770B\u3002\u4FEE\u6539\u540E\u91CD\u542F World\u3002" },
414
+ "worlds.starpost.notifications.feedMode": { type: "string", enum: ["realtime", "digest", "manual"], title: "\u52A8\u6001\u548C\u8BC4\u8BBA\u901A\u77E5\u6A21\u5F0F", description: "\u6DF7\u5408/\u88AB\u52A8\u6A21\u5F0F\u4F7F\u7528\uFF1Adigest \u5408\u5E76\u52A8\u6001\u3001\u5220\u9664\u548C\u8BC4\u8BBA\uFF08\u9ED8\u8BA4\uFF09\uFF1Brealtime \u5373\u65F6\u901A\u77E5\uFF1Bmanual \u5B8C\u5168\u624B\u52A8\u67E5\u770B\uFF0C\u4E0D\u53D1\u66F4\u65B0\u6570\u91CF\u63D0\u9192\uFF0C\u6240\u6709\u63A5\u6536\u6A21\u5F0F\u5747\u6709\u6548\u3002\u4E3B\u52A8\u6A21\u5F0F\u4E0B realtime/digest \u53EA\u6C47\u603B\u63D0\u9192\u6570\u91CF\u4E0E ID\uFF0C\u6B63\u6587\u6309\u9700\u67E5\u770B\u3002\u4FEE\u6539\u540E\u91CD\u542F World\u3002" },
414
415
  "worlds.starpost.notifications.digestIntervalMs": { type: "integer", minimum: 1e3, maximum: 864e5, title: "\u5E7F\u573A\u548C\u52A8\u6001\u6C47\u603B\u95F4\u9694\uFF08\u6BEB\u79D2\uFF09", description: "\u9ED8\u8BA4 300000 \u6BEB\u79D2\uFF0C\u4ECE\u7B2C\u4E00\u6761\u5F85\u6C47\u603B\u901A\u77E5\u8BA1\u65F6\uFF1B\u6CA1\u6709\u65B0\u901A\u77E5\u65F6\u4E0D\u5524\u9192\u3002\u9884\u89C8\u6700\u591A 20 \u9879\uFF0C\u5168\u6587\u53EF\u6309\u9700\u67E5\u770B\u3002\u4FEE\u6539\u540E\u91CD\u542F World\u3002" }
415
416
  } }
416
417
  };
package/package.json CHANGED
@@ -1,61 +1,64 @@
1
- {
2
- "name": "dsh-plugin-starpost",
3
- "version": "0.3.0",
4
- "description": "星邮的 DeepSeek Harness bot 客户端,支持会话绑定、消息收发和折叠社交工具",
5
- "license": "MIT",
6
- "type": "module",
7
- "main": "./src/index.mjs",
8
- "bin": {
9
- "starpost-dsh": "./src/account.mjs"
10
- },
11
- "dsh": {
12
- "bundle": {
13
- "patch": "./cordis.patch.yml"
14
- }
15
- },
16
- "engines": {
17
- "node": ">=22.16.0",
18
- "dsh": "^0.1.1-rc.2 || ^0.2.2-rc.1"
19
- },
20
- "files": [
21
- "src/*.mjs",
22
- "lib",
23
- "cordis.patch.yml",
24
- "desktop.ps1",
25
- "README.md",
26
- "LICENSE",
27
- "CHANGELOG.md",
28
- "docs"
29
- ],
30
- "scripts": {
31
- "build": "node build.mjs",
32
- "prepack": "npm run build",
33
- "test": "node --test tests/*.test.mjs",
34
- "pretest": "npm run build"
35
- },
36
- "repository": {
37
- "type": "git",
38
- "url": "git+https://github.com/hth768/dsh-plugin-starpost.git"
39
- },
40
- "author": "hth768",
41
- "homepage": "https://github.com/hth768/dsh-plugin-starpost#readme",
42
- "bugs": {
43
- "url": "https://github.com/hth768/dsh-plugin-starpost/issues"
44
- },
45
- "keywords": [
46
- "deepseek-harness",
47
- "dsh-plugin",
48
- "starpost",
49
- "bot",
50
- "chat"
51
- ],
52
- "starpostCoreVersion": "0.33.0",
53
- "devDependencies": {
54
- "@deepseek-ai/dsh-agent-loop": "0.2.2-rc.1",
55
- "@deepseek-ai/dsh-agent-loop-testkit": "0.2.2-rc.1",
56
- "@deepseek-ai/dsh-llm": "0.2.2-rc.1",
57
- "@deepseek-ai/dsh-tools": "0.2.2-rc.1",
58
- "cortico-world-starpost": "0.33.0",
59
- "esbuild": "0.25.12"
60
- }
61
- }
1
+ {
2
+ "name": "dsh-plugin-starpost",
3
+ "version": "0.3.1",
4
+ "description": "星邮的 DeepSeek Harness bot 客户端,支持会话绑定、消息收发和折叠社交工具",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "./src/index.mjs",
8
+ "bin": {
9
+ "starpost-dsh": "./src/account.mjs"
10
+ },
11
+ "dsh": {
12
+ "bundle": {
13
+ "patch": "./cordis.patch.yml"
14
+ }
15
+ },
16
+ "engines": {
17
+ "node": ">=22.16.0",
18
+ "dsh": "^0.1.1-rc.2 || ^0.2.2-rc.1"
19
+ },
20
+ "files": [
21
+ "src/*.mjs",
22
+ "lib",
23
+ "cordis.patch.yml",
24
+ "desktop.ps1",
25
+ "README.md",
26
+ "LICENSE",
27
+ "CHANGELOG.md",
28
+ "docs"
29
+ ],
30
+ "scripts": {
31
+ "build": "node build.mjs",
32
+ "prepack": "npm run build",
33
+ "test": "node --test tests/*.test.mjs",
34
+ "pretest": "npm run build"
35
+ },
36
+ "repository": {
37
+ "type": "git",
38
+ "url": "git+https://github.com/hth768/dsh-plugin-starpost.git"
39
+ },
40
+ "author": "hth768",
41
+ "homepage": "https://github.com/hth768/dsh-plugin-starpost#readme",
42
+ "bugs": {
43
+ "url": "https://github.com/hth768/dsh-plugin-starpost/issues"
44
+ },
45
+ "keywords": [
46
+ "deepseek-harness",
47
+ "dsh-plugin",
48
+ "starpost",
49
+ "bot",
50
+ "chat"
51
+ ],
52
+ "starpostCoreVersion": "0.33.0",
53
+ "devDependencies": {
54
+ "@deepseek-ai/dsh-agent-loop": "0.2.2-rc.1",
55
+ "@deepseek-ai/dsh-agent-loop-testkit": "0.2.2-rc.1",
56
+ "@deepseek-ai/dsh-llm": "0.2.2-rc.1",
57
+ "@deepseek-ai/dsh-tools": "0.2.2-rc.1",
58
+ "cortico-world-starpost": "0.33.0",
59
+ "esbuild": "0.25.12"
60
+ },
61
+ "dependencies": {
62
+ "@deepseek-ai/schemastery": "3.19.0"
63
+ }
64
+ }
package/src/account.mjs CHANGED
@@ -3,10 +3,10 @@ import { readFileSync } from 'node:fs';
3
3
  import { join } from 'node:path';
4
4
  import { parseArgs } from 'node:util';
5
5
  import { clientHome, clientVersions, loadSettings, options, validateSettings, saveSettings, makeWorld, lock, pinServer } from './local.mjs';
6
- const usage = 'starpost-dsh hub-login --session 会话ID | hub-complete | hub-cancel | register --session 会话ID | login --session 会话ID --file 凭据JSON文件 | configure --session 会话ID [--mode active|mixed|passive] | status';
6
+ const usage = 'starpost-dsh hub-login --session 会话ID | hub-complete | hub-cancel | register --session 会话ID | login --session 会话ID --file 凭据JSON文件 | configure [--session 会话ID] [--mode active|mixed|passive] [--square-mode manual|digest|realtime] [--feed-mode manual|digest|realtime] [--digest-interval-ms 300000] | status';
7
7
  try {
8
8
  const [action, ...args] = process.argv.slice(2);
9
- const {values} = parseArgs({args,options:Object.fromEntries(['session','file','mode','server','hub','emoji-dir'].map(k=>[k,{type:'string'}]))});
9
+ const {values} = parseArgs({args,options:Object.fromEntries(['session','file','mode','server','hub','emoji-dir','square-mode','feed-mode','digest-interval-ms'].map(k=>[k,{type:'string'}]))});
10
10
  if (!action || action === '--help') { console.log(usage); }
11
11
  else {
12
12
  if (!['register','login','configure','status','hub-login','hub-complete','hub-cancel'].includes(action)) throw Error(usage);
@@ -14,8 +14,12 @@ try {
14
14
  const release = action === 'status' ? () => {} : lock(dir);
15
15
  try {
16
16
  const settings = loadSettings(dir);
17
- for (const [flag, key] of [['session','sessionId'],['mode','receiveMode'],['server','serverUrl'],['hub','hubUrl'],['emoji-dir','emojiDir']])
17
+ for (const [flag, key] of [['session','sessionId'],['mode','receiveMode'],['server','serverUrl'],['hub','hubUrl'],['emoji-dir','emojiDir'],['square-mode','squareMode'],['feed-mode','feedMode']])
18
18
  if (values[flag] !== undefined) settings[key] = values[flag];
19
+ if (values['digest-interval-ms'] !== undefined) {
20
+ if (!/^\d+$/.test(values['digest-interval-ms'])) throw Error('汇总间隔须为整数毫秒');
21
+ settings.digestIntervalMs = Number(values['digest-interval-ms']);
22
+ }
19
23
  if (action !== 'status') validateSettings(dir,settings);
20
24
  const world = makeWorld(dir,settings), invoke = world.webUi().invoke;
21
25
  let pairing;
@@ -36,7 +40,8 @@ try {
36
40
  }
37
41
  if (action !== 'status') saveSettings(dir,settings);
38
42
  console.log(JSON.stringify({ ...await invoke('viewer','status',[]), hub:await invoke('viewer','hubStatus',[]), ...(pairing ? {pairing} : {}), ...clientVersions, sessionId:settings.sessionId ?? null,
39
- receiveMode:options(settings,dir).receiveMode, directory:dir, credentialFile:join(dir,'starpost-credential.json') }, null, 2));
43
+ receiveMode:options(settings,dir).receiveMode, notifications:options(settings,dir).notifications,
44
+ settingsSource:'client.json(DSH 设置面板中的显式设置优先;修改后重启 Harness)', directory:dir, credentialFile:join(dir,'starpost-credential.json') }, null, 2));
40
45
  } finally { release(); }
41
46
  }
42
47
  } catch (error) { console.error(error instanceof SyntaxError ? '配置或凭据文件不是有效的 JSON' : error.message); process.exitCode = 1; }
package/src/index.mjs CHANGED
@@ -1,7 +1,9 @@
1
1
  import { AsyncLocalStorage } from 'node:async_hooks';
2
2
  import { randomUUID } from 'node:crypto';
3
3
  import { readFileSync } from 'node:fs';
4
- import { clientHome, clientVersions, loadSettings, makeWorld, lock } from './local.mjs';
4
+ import { clientHome, clientVersions, loadSettings, makeWorld, options, lock } from './local.mjs';
5
+ import { Config, registerNotificationSettings } from './settings.mjs';
6
+ export { Config } from './settings.mjs';
5
7
  import { STARPOST_TOOL_DECLS } from '../lib/core.mjs';
6
8
 
7
9
  export const name = 'dsh-plugin-starpost';
@@ -10,9 +12,13 @@ const envelope = (content, source) => ({id:randomUUID(), role:'user', content, s
10
12
  const notice = text => envelope([{type:'text', text}], {form:'notice', summary:'星邮通知'});
11
13
  const pending = agent => [...agent.inbox.nextStep, ...agent.inbox.nextTurn].filter(m => m.source?.kind === name);
12
14
 
13
- export function apply(ctx) {
15
+ export function apply(ctx, entry = {}) {
14
16
  const dir = clientHome();
15
17
  const settings = loadSettings(dir);
18
+ const fileConfig = options(settings, dir);
19
+ const notificationConfig = registerNotificationSettings(ctx, {
20
+ receiveMode: fileConfig.receiveMode, ...fileConfig.notifications, ...Config(entry),
21
+ });
16
22
  const calls = new AsyncLocalStorage();
17
23
  let attachments;
18
24
  ctx.inject(['attachments'], scoped => {
@@ -67,7 +73,9 @@ export function apply(ctx) {
67
73
  client.ready = retired.then(async () => {
68
74
  live();
69
75
  client.unlock = lock(dir);
70
- client.world = makeWorld(dir,settings);
76
+ const effectiveSettings = { ...settings, ...notificationConfig() };
77
+ client.settings = options(effectiveSettings, dir);
78
+ client.world = makeWorld(dir,effectiveSettings);
71
79
  const status = await client.world.webUi().invoke('viewer','status',[]);
72
80
  if (!status.registered) throw Error('请先由人类用 starpost-dsh hub-login 配对,或用 register / login 配置原星邮账号');
73
81
  live();
@@ -103,6 +111,8 @@ export function apply(ctx) {
103
111
  if (args.family === 'client' && args.action === 'status') {
104
112
  return JSON.stringify({...clientVersions, sessionId:agent.id, bound:settings.sessionId === agent.id,
105
113
  ready:current?.agent === agent && Boolean(current.tool) && !current.error,
114
+ ...(settings.sessionId === agent.id ? { notificationSettings: current?.settings?.notifications ?? options({ ...settings, ...notificationConfig() }, dir).notifications,
115
+ settingsApply: 'restart' } : {}),
106
116
  ...(current?.agent === agent && current.error ? {error:current.error.message} : {})});
107
117
  }
108
118
  if (!settings.sessionId || agent.id !== settings.sessionId) throw Error('此会话未绑定星邮账号。用 client/status 查看会话 ID,再由人类在终端完成绑定。');
package/src/local.mjs CHANGED
@@ -17,6 +17,19 @@ export function loadSettings(dir) {
17
17
  const file = join(dir, 'client.json');
18
18
  return existsSync(file) ? JSON.parse(readFileSync(file, 'utf8')) : {};
19
19
  }
20
+ export function notificationOptions(settings) {
21
+ const nested = settings.notifications === undefined ? {} : settings.notifications;
22
+ if (!nested || typeof nested !== 'object' || Array.isArray(nested)) throw Error('notifications 须为配置对象');
23
+ const allowed = ['squareMode', 'feedMode', 'digestIntervalMs'];
24
+ for (const key of Object.keys(nested)) if (!allowed.includes(key)) throw Error('未知通知配置:'+key);
25
+ const result = { ...STARPOST_DEFAULTS.notifications, ...nested };
26
+ for (const key of allowed) if (Object.hasOwn(settings, key)) result[key] = settings[key];
27
+ for (const key of ['squareMode', 'feedMode']) {
28
+ if (!['realtime', 'digest', 'manual'].includes(result[key])) throw Error(key+' 须为 realtime、digest 或 manual');
29
+ }
30
+ if (!Number.isInteger(result.digestIntervalMs) || result.digestIntervalMs < 1000 || result.digestIntervalMs > 86400000) throw Error('digestIntervalMs 须为 1000~86400000 的整数');
31
+ return result;
32
+ }
20
33
  export function options(settings, dir) {
21
34
  const cfg = structuredClone(STARPOST_DEFAULTS);
22
35
  cfg.enabled = true;
@@ -29,6 +42,7 @@ export function options(settings, dir) {
29
42
  if (existsSync(pin) && readFileSync(pin, 'utf8') !== url.origin) throw Error('账号数据已绑定其他服务器,请为新服务器选择独立的数据目录');
30
43
  cfg.receiveMode = settings.receiveMode ?? cfg.receiveMode;
31
44
  if (!['active','mixed','passive'].includes(cfg.receiveMode)) throw Error('接收模式须为 active、mixed 或 passive');
45
+ cfg.notifications = notificationOptions(settings);
32
46
  cfg.emojiDir = resolve(dir, settings.emojiDir || 'emoji');
33
47
  if(settings.speech!==undefined){
34
48
  if(!settings.speech||typeof settings.speech!=='object'||Array.isArray(settings.speech))throw Error('speech 须为配置对象');
@@ -0,0 +1,22 @@
1
+ import z from '@deepseek-ai/schemastery';
2
+
3
+ const mode = () => z.union(['realtime', 'digest', 'manual']);
4
+ // Optional entry values preserve client.json settings when Cordis supplies {}.
5
+ export const Config = z.object({
6
+ receiveMode: z.union(['active', 'mixed', 'passive']).description('消息接收:active 主动查收;mixed 混合;passive 被动投递。'),
7
+ squareMode: mode().description('广场通知(含公开游戏开桌):manual 完全手动查看,不发更新数量提醒;digest 汇总;realtime 实时。主动模式下 realtime 仅汇总提醒。'),
8
+ feedMode: mode().description('动态和评论通知:manual 完全手动查看;digest 汇总;realtime 实时。主动模式下 realtime 仅汇总提醒。'),
9
+ digestIntervalMs: z.number().step(1).min(1000).max(86400000).description('汇总间隔,单位毫秒,默认 300000(5 分钟)。无新内容不唤醒。'),
10
+ }).description('星邮通知设置;修改后重启 Harness。游戏邀请、参赛、主人消息及系统提醒仍按原规则送达。');
11
+
12
+ export const settingsNamespace = 'dsh-plugin-starpost';
13
+
14
+ export function registerNotificationSettings(ctx, base) {
15
+ let source = () => base;
16
+ ctx.inject(['settings'], scoped => {
17
+ const scope = scoped.settings.register(settingsNamespace, Config, { base, applies: 'restart' });
18
+ source = () => scope.get();
19
+ scoped.effect(() => () => { source = () => base; }, 'starpost.notification-settings');
20
+ });
21
+ return () => source();
22
+ }