dsh-inbox-bridge 2.18.3 → 2.19.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 +10 -0
- package/README.en.md +2 -2
- package/README.md +2 -2
- package/docs/DETAIL.md +1 -1
- package/docs/DETAIL.zh.md +1 -1
- package/docs/configuration.md +3 -1
- package/docs/how-it-works.md +4 -3
- package/docs/index.json +3 -3
- package/index.js +69 -2
- package/package.json +1 -1
- package/scripts/inbox-bridge.mjs +5 -0
- package/scripts/inbox-bridge.test.mjs +28 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
## 2.19.1
|
|
2
|
+
|
|
3
|
+
- 一件还没告诉过任何人的事不再被「来源不再报出」直接收口。issue 与评论是只报一次的事实:某个会话正忙时事件被留下,下一次轮询本来就取不到第二次,原来的收口逻辑正好把它丢掉——于是事件永远等不到那个愿意叫人的时刻,唤醒也就永远不会发生。现在只有已经投递过的 key 才会因为事实不再成立而收口。
|
|
4
|
+
- `wakePlan` 的 `primary` 也会写进 `runtime.json`,`doctor` 与面板读到的是同一份事实。
|
|
5
|
+
- 回归测试:`a fact nobody was told about is not closed by the source going quiet`(去掉判定后该用例立刻红)。
|
|
6
|
+
## 2.19.0
|
|
7
|
+
|
|
8
|
+
- 唤醒要先说清「谁负责」:同一个工作区里可以开多个会话,它们看的是同一个仓库,于是「这个仓库的会话」不再是一个确定的答案。现在一个仓库只有一个会话在看时,它就是负责的那个;有多个时,谁都不叫,直到你在面板里指定某一个负责(`primary`)。插件没有资格替你挑谈话对象。
|
|
9
|
+
- 新增第五道门:`wakePlan` 在角色、空闲、两个预算之外,先看负责关系;日志会写 `no wakeup: ambiguous`(多人看同一个仓库)或 `no wakeup: not-primary`。
|
|
10
|
+
- `primary` 与其它设置一样会被校验:键必须是 `owner/name`,值必须是会话 id,写错直接报出来而不是悄悄失效。
|
|
1
11
|
## 2.18.3
|
|
2
12
|
|
|
3
13
|
- 登录一次就够:归档结束后让浏览器自己关掉,等它真的退出(Chromium 只在退出时把 cookie 写进磁盘),而不是 1.5 秒后强杀。以前每次运行都丢掉刚登录的会话,于是看起来「才登录过又要登录」。
|
package/README.en.md
CHANGED
|
@@ -27,7 +27,7 @@ That is also why it only reads: its job is to make the agent aware. The work hap
|
|
|
27
27
|
- **It reads repositories, not the notification inbox.** GitHub's notification inbox pushes per account and cannot tell one session or repository from another; querying repository state directly keeps two repositories on the same account apart.
|
|
28
28
|
- **Polling follows turns.** Once when a session starts, every minute while a turn runs, once when it ends; an idle session makes no request. Only with `delivery: wakeup` does it also read on that interval while idle — without that it could never wake you while you are away.
|
|
29
29
|
- **It also watches security and merge state.** Open Dependabot and code-scanning alerts, and a pull request of yours that conflicts with the base branch or is behind it, matter as much as a red check.
|
|
30
|
-
- **It goes into the context, and opens a turn only when it has to.** By default a notice arrives at the next safe injection point and does not interrupt the tool loop; with `delivery: wakeup` it opens a turn only for a listed `wakeOn` role,
|
|
30
|
+
- **It goes into the context, and opens a turn only when it has to.** By default a notice arrives at the next safe injection point and does not interrupt the tool loop; with `delivery: wakeup` it opens a turn only for a listed `wakeOn` role, in the one session responsible for that repository (or the one you named), idle for 15 minutes, at most 3 times in a row per session, and at most 2 times an hour — anything else keeps queueing. A notice is marked `delivered`, and unhandled events come back once after six hours.
|
|
31
31
|
|
|
32
32
|
## What you will see
|
|
33
33
|
|
|
@@ -100,7 +100,7 @@ Full configuration, CLI and state files: [configuration](docs/configuration.md).
|
|
|
100
100
|
## Boundaries
|
|
101
101
|
|
|
102
102
|
- **Read-only.** It does not merge, comment, or change anything.
|
|
103
|
-
- **No turn by default.** Only `delivery: wakeup` with a matching `wakeOn` role, enough idle time, and room in both budgets may start one; any gate that fails falls back to queueing.
|
|
103
|
+
- **No turn by default.** Only `delivery: wakeup` with a matching `wakeOn` role, one responsible session for that repository, enough idle time, and room in both budgets may start one; any gate that fails falls back to queueing.
|
|
104
104
|
- **Archiving needs one browser sign-in, but you do not type a command for it.** GitHub has no archive API; `scripts/clear-inbox.mjs` drives a local Chromium-based browser (Edge, Chrome or Chromium). Switching "message clearing" to archive opens the sign-in window by itself, and it opens again if the session expires.
|
|
105
105
|
- **Archiving touches only the repositories you subscribe to.** It opens GitHub's notification search per repository (`repo:owner/name`) and archives what is in that view; with no subscription it archives nothing. The whole inbox needs an explicit `--all`.
|
|
106
106
|
- **State is local.** It lives under `.work/` in the working directory and is not synced across machines.
|
package/README.md
CHANGED
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
- **只看仓库,不看通知箱。** GitHub 的通知箱(`/notifications`)按账号推送,无法区分是哪个会话、哪个仓库;这里直接查仓库状态,因此同一个账号下的两个仓库互不干扰。
|
|
28
28
|
- **轮询跟随回合。** 会话开始时一次、进行中每 1 分钟一次、结束时一次,空闲会话不发请求;开启 `delivery: wakeup` 后空闲时也按同一间隔读一次,否则它没机会在你不在时叫醒你。
|
|
29
29
|
- **也看安全与合并状态。** 开着的 Dependabot 告警、code scanning 告警,以及我这些 PR 与基分支的冲突或落后,和 CI 失败一样是要紧的事。
|
|
30
|
-
- **送进上下文,必要时才开一轮。** 默认只在这一轮的下一次安全注入点进入会话,不打断工具循环;开启 `delivery: wakeup` 后,只有命中 `wakeOn`
|
|
30
|
+
- **送进上下文,必要时才开一轮。** 默认只在这一轮的下一次安全注入点进入会话,不打断工具循环;开启 `delivery: wakeup` 后,只有命中 `wakeOn` 的角色、这个仓库只有它一个会话在看(或被你指定负责)、会话空闲满 15 分钟、每会话连续不超过 3 次、每小时不超过 2 次时才主动开一轮,其余情况仍然排队。送达后标为 `delivered`,未处理的 6 小时后重新提醒一次。
|
|
31
31
|
|
|
32
32
|
## 你会看到什么
|
|
33
33
|
|
|
@@ -100,7 +100,7 @@ dsh plugin add dsh-inbox-bridge
|
|
|
100
100
|
## 边界
|
|
101
101
|
|
|
102
102
|
- **只读。** 不合并、不评论、不修改仓库。
|
|
103
|
-
- **默认不主动开启对话。** 只有显式设置 `delivery: wakeup` 且命中 `wakeOn
|
|
103
|
+
- **默认不主动开启对话。** 只有显式设置 `delivery: wakeup` 且命中 `wakeOn`、这个仓库只由一个会话负责、会话足够空闲、两个预算都还有余额时才会;任何一道门不过,就退回只排队。
|
|
104
104
|
- **Done 归档依赖一次浏览器登录,但不用你敲命令。** GitHub 没有归档 API,`scripts/clear-inbox.mjs` 通过本机浏览器(Edge / Chrome / Chromium)完成。把「消息清理」切到归档,插件会自己弹出登录窗口;会话失效时会再弹一次。
|
|
105
105
|
- **归档只碰你订阅的仓库。** 它按仓库逐个打开 GitHub 的通知搜索视图(`repo:owner/name`),只归档这些视图里的线程;没有订阅就什么都不归档。整个收件箱要显式 `--all` 才会动。
|
|
106
106
|
- **状态在本机。** 存放在工作目录的 `.work/` 下,不跨机器同步。
|
package/docs/DETAIL.md
CHANGED
|
@@ -39,6 +39,6 @@ Then give it a working directory (`cwd`); the repository and the identity come f
|
|
|
39
39
|
## Boundaries
|
|
40
40
|
|
|
41
41
|
- Read-only: no merging, commenting or changing repositories.
|
|
42
|
-
- No turn by default; only `delivery: wakeup` with a matching `wakeOn` role, enough idle time, and room in both budgets may start one; any gate that fails falls back to queueing.
|
|
42
|
+
- No turn by default; only `delivery: wakeup` with a matching `wakeOn` role, one responsible session for that repository, enough idle time, and room in both budgets may start one; any gate that fails falls back to queueing.
|
|
43
43
|
- Archiving to Done needs one browser sign-in (GitHub has no archive API).
|
|
44
44
|
- State is local, under `<cwd>/.work/`, and is not synced across machines.
|
package/docs/DETAIL.zh.md
CHANGED
|
@@ -39,6 +39,6 @@ dsh plugin add ./dsh-inbox-bridge
|
|
|
39
39
|
## 边界
|
|
40
40
|
|
|
41
41
|
- 只读:不合并、不评论、不修改仓库。
|
|
42
|
-
- 默认不主动开启对话;只有 `delivery: wakeup` 命中 `wakeOn
|
|
42
|
+
- 默认不主动开启对话;只有 `delivery: wakeup` 命中 `wakeOn`、这个仓库由某个会话负责、会话足够空闲、两个预算都还有余额时才会,任何一道门不过就退回只排队。
|
|
43
43
|
- 归档到 Done 依赖一次浏览器登录(GitHub 没有归档 API)。
|
|
44
44
|
- 状态保存在本机 `<cwd>/.work/` 下,不跨机器同步。
|
package/docs/configuration.md
CHANGED
|
@@ -60,7 +60,7 @@ GitHub 的 Done 只有网页端点,所以归档要用插件自己的浏览器
|
|
|
60
60
|
| `resurfaceMs` | `21600000`(6 小时) | 标了 delivered 但没处理的,多久后再提一次 |
|
|
61
61
|
| `offlineReminderMs` | `43200000`(12 小时) | 工作区连不上仓库时,最多多久提醒一次 |
|
|
62
62
|
| `injectWhileRunning` | `false` | 允许打断正在跑的工具循环;默认只在回合边界注入 |
|
|
63
|
-
| `delivery` | `"quiet"` | `quiet` 只排队;`wakeup`
|
|
63
|
+
| `delivery` | `"quiet"` | `quiet` 只排队;`wakeup` 还会替你开一轮(受下面五道门约束) |
|
|
64
64
|
| `wakeOn` | `[]` | 允许唤醒的角色白名单;空 = 永不唤醒。若设了非空值,`delivery` 必须是 `wakeup` |
|
|
65
65
|
| `wakeAfterIdleMs` | `900000`(15 分钟) | 会话静默多久后才允许唤醒 |
|
|
66
66
|
| `wakesPerHour` | `2` | 滚动一小时内最多唤醒几次;0 = 关闭 |
|
|
@@ -93,6 +93,8 @@ identity:
|
|
|
93
93
|
|
|
94
94
|
区别在能看到什么:`user` 能看到账号的 `/notifications`(别人把事推给你),`app` 没有用户收件箱,只读仓库状态(PR、检查、评审请求、issue、评论)。两种都能判断「这件事跟我有关吗」,因为判断依据是仓库里的关系,不是通知流。
|
|
95
95
|
|
|
96
|
+
谁来接这一轮:一个仓库只有一个会话在看时,那个会话就是负责的;同一仓库被多个会话看着(同一工作区开多个会话就会这样)时,谁都不叫,直到你在面板里把某个会话指定为负责——插件没有资格替你挑谈话对象。
|
|
97
|
+
|
|
96
98
|
`roles` 与事件里的角色一致:`author`(你提交的)、`reviewer`(请你评审)、`assignee`(派给你的)、`mention`(@你)、`ci`(默认分支)。`wakeOn` 用同一套名字。
|
|
97
99
|
|
|
98
100
|
## 命令行
|
package/docs/how-it-works.md
CHANGED
|
@@ -31,9 +31,9 @@ DSH 插件 (index.js) 调度与投递:什么时候去取、取回来给
|
|
|
31
31
|
2. 判断「跟我有关吗」——这是插件的核心判断,见下一节。
|
|
32
32
|
3. 给每个事件一个 key(`owner/name#pr:23:reviewer:review-requested` 这样),同一件事在多次轮询里是同一个 key。
|
|
33
33
|
4. 队列里已有记录的 key 不重复投递;已经投出去但没有人收口的,6 小时后重提**一次**,再之后就当作已经说过了。
|
|
34
|
-
5. 上一次轮询能报出、这一次报不出的 key,说明这条事实已经不再成立(检查变绿、PR 合了、issue
|
|
34
|
+
5. 上一次轮询能报出、这一次报不出的 key,说明这条事实已经不再成立(检查变绿、PR 合了、issue 关了),直接收口——队列里只留「此刻仍然成立」的事。还没有告诉过任何人的事件不收口:issue 与评论这类只报一次的事实,一旦在「会话正忙」时被留下,下一次轮询就没有第二次机会了,收口等于把它丢掉。
|
|
35
35
|
6. 按会话分组:会话自己的仓库 + 自己的角色都匹配,才进它那份。
|
|
36
|
-
7. 投递:`quiet` 时注入给空闲的会话、等它下一轮;`wakeup`
|
|
36
|
+
7. 投递:`quiet` 时注入给空闲的会话、等它下一轮;`wakeup` 时先过五道门。
|
|
37
37
|
8. 只把**真正投出去**的 key 标 delivered。没投出去的下次还有机会,不会被误标。
|
|
38
38
|
9. 把这些线程标为已读(`clear`,默认只清订阅的仓库;整个账号不在范围内)。GitHub 没有「完成」的公开接口,所以清掉的是未读角标,收件箱里的历史还在——在你自己的界面上一切照旧可查。
|
|
39
39
|
10. 如果配了 `sweep`,在**这一轮真的抓到东西**时顺手把它们归档进 Done(`scripts/clear-inbox.mjs` 用一次浏览器完成,约 3–5 秒)。它按仓库逐个打开 GitHub 的通知搜索视图(`repo:owner/name`),只归档订阅的这些视图里的线程;没有订阅就一条也不归档(整个收件箱要显式 `--all`)。没抓到就什么也不做,空回合不花这笔钱。
|
|
@@ -82,9 +82,10 @@ DSH 插件 (index.js) 调度与投递:什么时候去取、取回来给
|
|
|
82
82
|
|
|
83
83
|
## 唤醒(默认关闭)
|
|
84
84
|
|
|
85
|
-
`delivery: quiet` 时插件永远不替你开一轮,只排队。改成 `wakeup`
|
|
85
|
+
`delivery: quiet` 时插件永远不替你开一轮,只排队。改成 `wakeup` 后,要同时满足五道门才会开一轮:
|
|
86
86
|
|
|
87
87
|
1. `wakeOn` 列了这个角色(默认空 = 永不);
|
|
88
|
+
2. 这个仓库只有一个会话在看,或者被指定的那个会话正是它(同一仓库多个会话时默认谁都不叫);
|
|
88
89
|
2. 会话已经静默 `wakeAfterIdleMs`(默认 15 分钟)——所以这个模式在空闲时也按 `intervalMs` 取数,否则永远等不到这一刻;
|
|
89
90
|
3. 这个会话自你上次发言起被唤醒不足 `maxConsecutiveWakes` 次;
|
|
90
91
|
4. 滚动一小时内总唤醒数没超过 `wakesPerHour`(默认 2)。
|
package/docs/index.json
CHANGED
|
@@ -50,12 +50,12 @@
|
|
|
50
50
|
},
|
|
51
51
|
"versions": [
|
|
52
52
|
{
|
|
53
|
-
"version": "2.
|
|
54
|
-
"publishTimestamp":
|
|
53
|
+
"version": "2.19.1",
|
|
54
|
+
"publishTimestamp": 1794919046,
|
|
55
55
|
"source": {
|
|
56
56
|
"type": "git",
|
|
57
57
|
"url": "https://github.com/c3115644151/dsh-inbox-bridge",
|
|
58
|
-
"commit": "
|
|
58
|
+
"commit": "293b2f1b80a8f4ebbd3d8e1bf51d6661843df9e7"
|
|
59
59
|
},
|
|
60
60
|
"engines": {
|
|
61
61
|
"dsh": ">=0.1.0"
|
package/index.js
CHANGED
|
@@ -115,6 +115,17 @@ export function preferenceNext(current = {}, action = "", value = "", options =
|
|
|
115
115
|
}
|
|
116
116
|
return next;
|
|
117
117
|
}
|
|
118
|
+
if (action === "primary") {
|
|
119
|
+
// Who may be woken for this repository. An empty value releases the claim.
|
|
120
|
+
if (!sessionId) return null;
|
|
121
|
+
const repo = value ? repoFromInput(value) : sessionRepo;
|
|
122
|
+
if (!repo) return null;
|
|
123
|
+
const primary = { ...(next.primary ?? {}) };
|
|
124
|
+
if (value) primary[repo] = sessionId;
|
|
125
|
+
else delete primary[repo];
|
|
126
|
+
next.primary = primary;
|
|
127
|
+
return next;
|
|
128
|
+
}
|
|
118
129
|
return null;
|
|
119
130
|
}
|
|
120
131
|
|
|
@@ -228,6 +239,13 @@ const DEFAULTS = Object.freeze({
|
|
|
228
239
|
* leaves the inbox alone. GitHub has no "done" API, so this is read, not done.
|
|
229
240
|
*/
|
|
230
241
|
clear: "repo",
|
|
242
|
+
/**
|
|
243
|
+
* Which session is responsible for opening a turn on a repository:
|
|
244
|
+
* `{ "owner/name": "<session id>" }`. Without a claim, a repository whose
|
|
245
|
+
* events reach more than one session wakes nobody — the plugin may not choose
|
|
246
|
+
* which conversation starts working.
|
|
247
|
+
*/
|
|
248
|
+
primary: {},
|
|
231
249
|
poll: { command: process.execPath, args: [CLI, "poll"] },
|
|
232
250
|
ack: { command: process.execPath, args: [CLI, "ack"] },
|
|
233
251
|
});
|
|
@@ -403,6 +421,7 @@ export function apply(ctx, config) {
|
|
|
403
421
|
clear: options.clear,
|
|
404
422
|
sweep: options.sweep ? options.sweep.when : null,
|
|
405
423
|
wakeOn: options.wakeOn,
|
|
424
|
+
primary: options.primary ?? {},
|
|
406
425
|
wakeAfterIdleMs: options.wakeAfterIdleMs,
|
|
407
426
|
wakesPerHour: options.wakesPerHour,
|
|
408
427
|
maxConsecutiveWakes: options.maxConsecutiveWakes,
|
|
@@ -601,7 +620,13 @@ export function apply(ctx, config) {
|
|
|
601
620
|
);
|
|
602
621
|
return;
|
|
603
622
|
}
|
|
604
|
-
const wake = wakePlan(batches, options, {
|
|
623
|
+
const wake = wakePlan(batches, options, {
|
|
624
|
+
streak: wakeStreak,
|
|
625
|
+
lastActive,
|
|
626
|
+
wakes,
|
|
627
|
+
now,
|
|
628
|
+
primary: prefs.primary ?? {},
|
|
629
|
+
});
|
|
605
630
|
if (!wake.agent && wake.considered > 0) log(`no wakeup: ${wake.why}`);
|
|
606
631
|
const waking = wake.agent ? new Set([wake.agent]) : new Set();
|
|
607
632
|
const deliveredKeys = new Set();
|
|
@@ -978,10 +1003,25 @@ export function wakePlan(batches, options, state = {}) {
|
|
|
978
1003
|
const streak = state.streak ?? new Map();
|
|
979
1004
|
const lastActive = state.lastActive ?? new Map();
|
|
980
1005
|
const wakes = state.wakes ?? [];
|
|
1006
|
+
const primary = state.primary ?? {};
|
|
981
1007
|
const perHour = options?.wakesPerHour ?? DEFAULTS.wakesPerHour;
|
|
982
1008
|
const cap = options?.maxConsecutiveWakes ?? DEFAULTS.maxConsecutiveWakes;
|
|
983
1009
|
const idleMs = options?.wakeAfterIdleMs ?? DEFAULTS.wakeAfterIdleMs;
|
|
984
1010
|
|
|
1011
|
+
// Opening a turn is expensive and public: whoever gets it suddenly starts
|
|
1012
|
+
// working. Several sessions can share one workspace, and then they all watch
|
|
1013
|
+
// the same repository, so "the session on this repository" is not an answer.
|
|
1014
|
+
// A repository therefore wakes its responsible session — claimed in the page —
|
|
1015
|
+
// and stays silent while more than one session watches it without a claim.
|
|
1016
|
+
const watchers = new Map();
|
|
1017
|
+
for (const [agent, events] of batches ?? []) {
|
|
1018
|
+
for (const event of events) {
|
|
1019
|
+
const repo = event.repo ?? "";
|
|
1020
|
+
if (!watchers.has(repo)) watchers.set(repo, new Set());
|
|
1021
|
+
watchers.get(repo).add(agent);
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
|
|
985
1025
|
const recentWakes = wakes.filter((at) => now - at < 60 * 60 * 1000).length;
|
|
986
1026
|
let considered = 0;
|
|
987
1027
|
let why = "no-match";
|
|
@@ -990,6 +1030,17 @@ export function wakePlan(batches, options, state = {}) {
|
|
|
990
1030
|
const role = event.role ?? "any";
|
|
991
1031
|
if (!wakeOn.includes(role)) continue;
|
|
992
1032
|
considered += 1;
|
|
1033
|
+
const repo = event.repo ?? "";
|
|
1034
|
+
const owner = primary[repo] ?? null;
|
|
1035
|
+
const key = keyOf(agent);
|
|
1036
|
+
if (owner && key !== owner) {
|
|
1037
|
+
why = "not-primary";
|
|
1038
|
+
continue;
|
|
1039
|
+
}
|
|
1040
|
+
if (!owner && (watchers.get(repo)?.size ?? 0) > 1) {
|
|
1041
|
+
why = "ambiguous";
|
|
1042
|
+
continue;
|
|
1043
|
+
}
|
|
993
1044
|
if (recentWakes >= perHour) {
|
|
994
1045
|
why = "hourly-budget";
|
|
995
1046
|
continue;
|
|
@@ -1171,10 +1222,25 @@ export function mergeConfig(config) {
|
|
|
1171
1222
|
`inbox-bridge: \`signInCooldownMs\` must be a non-negative integer, got ${JSON.stringify(signInCooldownMs)}`,
|
|
1172
1223
|
);
|
|
1173
1224
|
}
|
|
1225
|
+
// Which session opens a turn for a repository. Written by the page, but it is
|
|
1226
|
+
// configuration like any other: a typo here would silently silence wakeups.
|
|
1227
|
+
const primary = given.primary ?? DEFAULTS.primary;
|
|
1228
|
+
if (primary === null || typeof primary !== "object" || Array.isArray(primary)) {
|
|
1229
|
+
throw new Error(`inbox-bridge: \`primary\` must be { "owner/name": sessionId }, got ${JSON.stringify(primary)}`);
|
|
1230
|
+
}
|
|
1231
|
+
for (const [repo, session] of Object.entries(primary)) {
|
|
1232
|
+
if (!/^[\w.-]+\/[\w.-]+$/u.test(repo)) {
|
|
1233
|
+
throw new Error(`inbox-bridge: \`primary\` has a key that is not owner/name: ${JSON.stringify(repo)}`);
|
|
1234
|
+
}
|
|
1235
|
+
if (typeof session !== "string" || session.length === 0) {
|
|
1236
|
+
throw new Error(`inbox-bridge: \`primary.${repo}\` must be a session id, got ${JSON.stringify(session)}`);
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1174
1239
|
return {
|
|
1175
1240
|
...DEFAULTS,
|
|
1176
1241
|
...given,
|
|
1177
1242
|
signInCooldownMs,
|
|
1243
|
+
primary,
|
|
1178
1244
|
repo,
|
|
1179
1245
|
repos: watched,
|
|
1180
1246
|
delivery,
|
|
@@ -1378,7 +1444,8 @@ function wakeNotice(options, delivery) {
|
|
|
1378
1444
|
const idleMinutes = Math.max(1, Math.round((options.wakeAfterIdleMs ?? DEFAULTS.wakeAfterIdleMs) / 60_000));
|
|
1379
1445
|
const perHour = options.wakesPerHour ?? DEFAULTS.wakesPerHour;
|
|
1380
1446
|
return (
|
|
1381
|
-
`插件可能替你开一轮:仅限 ${wakeOn.join("/")}
|
|
1447
|
+
`插件可能替你开一轮:仅限 ${wakeOn.join("/")} 角色,且只有被指定负责该仓库的会话;` +
|
|
1448
|
+
`会话空闲满 ${idleMinutes} 分钟后,` +
|
|
1382
1449
|
`每小时最多 ${perHour} 次(另有每个会话 ${options.maxConsecutiveWakes ?? DEFAULTS.maxConsecutiveWakes} 次的连续上限)。`
|
|
1383
1450
|
);
|
|
1384
1451
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-inbox-bridge",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.19.1",
|
|
4
4
|
"displayName": "GitHub inbox",
|
|
5
5
|
"description": "DSH 插件:让 agent 像维护者一样盯着你的仓库——按会话订阅仓库,取回与你有关、需要你处理的事件(失败的 CI、待评审的 PR、指派给你的 issue、@你的评论、开着的安全告警),在自己的回合送进上下文;会话空闲又遇到要紧的事时也能主动开一轮,让 agent 自己去修、去审、去接。",
|
|
6
6
|
"type": "module",
|
package/scripts/inbox-bridge.mjs
CHANGED
|
@@ -176,6 +176,11 @@ export function closeResolved(state, events, { at, repos = [] } = {}) {
|
|
|
176
176
|
const repo = hash > 0 ? key.slice(0, hash).toLowerCase() : null;
|
|
177
177
|
if (!repo || !covered.has(repo)) continue;
|
|
178
178
|
if (live.has(key)) continue;
|
|
179
|
+
// Never told anyone about it: a fact we have not reported yet is not
|
|
180
|
+
// settled by the source going quiet. Issues and comments are reported once,
|
|
181
|
+
// so closing a held one would drop exactly the news a wakeup was waiting
|
|
182
|
+
// for.
|
|
183
|
+
if (entry.status === "pending" && (entry.attempts ?? 0) === 0) continue;
|
|
179
184
|
events_[key] = { ...entry, status: "done", at };
|
|
180
185
|
marked.push(key);
|
|
181
186
|
}
|
|
@@ -100,6 +100,34 @@ test("a fact the repository no longer reports is closed", () => {
|
|
|
100
100
|
assert.equal(closed.state.events["other/r#run:3"].status, "delivered");
|
|
101
101
|
});
|
|
102
102
|
|
|
103
|
+
test("a fact nobody was told about is not closed by the source going quiet", () => {
|
|
104
|
+
// An issue is reported once. If a poll finds a session busy, the event is
|
|
105
|
+
// held; the next poll has nothing to report, and closing it there would drop
|
|
106
|
+
// the very news a wakeup was waiting on.
|
|
107
|
+
const state = {
|
|
108
|
+
events: {
|
|
109
|
+
"o/r#issue:4:author:2026-11-17T12:25:51Z": {
|
|
110
|
+
status: "pending",
|
|
111
|
+
at: AT,
|
|
112
|
+
kind: "issue",
|
|
113
|
+
attempts: 0,
|
|
114
|
+
},
|
|
115
|
+
"o/r#issue:3:author:2026-11-16T19:30:22Z": {
|
|
116
|
+
status: "pending",
|
|
117
|
+
at: AT,
|
|
118
|
+
kind: "issue",
|
|
119
|
+
attempts: 1,
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
const closed = closeResolved(state, [], { at: AT, repos: ["o/r"] });
|
|
124
|
+
assert.deepEqual(closed.marked, ["o/r#issue:3:author:2026-11-16T19:30:22Z"]);
|
|
125
|
+
assert.equal(
|
|
126
|
+
closed.state.events["o/r#issue:4:author:2026-11-17T12:25:51Z"].status,
|
|
127
|
+
"pending",
|
|
128
|
+
);
|
|
129
|
+
});
|
|
130
|
+
|
|
103
131
|
test("classify splits events by the state they carry", () => {
|
|
104
132
|
const events = [
|
|
105
133
|
{ key: "ci:1", kind: "ci" },
|