@excitedjs/dreamux 0.9.2 → 0.9.3

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.
@@ -4,15 +4,31 @@
4
4
  * Trigger rule (deliberately different from claudemux):
5
5
  *
6
6
  * In a group, a `/introduce` message triggers **if and only if the sender is
7
- * on the allowlist**. No `@`-mention of our bot is required, and the group's
8
- * `require_mention` setting is ignored on this path.
7
+ * authorized to run it under the group's policy**. No `@`-mention of our bot
8
+ * is required, and the group's `require_mention` setting is ignored on this
9
+ * path.
9
10
  *
10
- * "Sender on the allowlist" is sender-scoped, NOT group-scoped: it is not
11
- * enough for the chat to be authorized the *sender* must be explicitly
12
- * allowlisted for the chat. An open group (no per-sender allowlist) does NOT
13
- * authorize introduce. `canRunIntroduce` therefore never reuses a broad
14
- * group-authorization predicate that would trust the group without checking
15
- * the sender's identity.
11
+ * Authorization mirrors the delivery gate (`dreamuxFeishuGate`) for the same
12
+ * group policy, minus the @-mention requirement that introduce deliberately
13
+ * waives. The parity is exact except for two divergences that are intentional
14
+ * (issue #62), not accidental keep them when "aligning" the two gates:
15
+ *
16
+ * - `block` — never authorized (the gate drops every group message).
17
+ * - `follow-user` — the chat needs no authorization; `allow_chats` is ignored
18
+ * exactly as the gate ignores it. The sender must be on the
19
+ * global `allow_users` list.
20
+ * - `allowlist` — the chat must be named in `allow_chats` (the group is the
21
+ * unit of trust). The sender must ALSO be on `allow_users` —
22
+ * this is the #62 divergence: a trust-changing command is
23
+ * sender-scoped even in an allowlisted group, whereas the
24
+ * delivery gate lets any member of an allowlisted group
25
+ * speak. "Any member of an allowlisted group" is therefore
26
+ * deliberately NOT a path to introduce.
27
+ *
28
+ * Before issue #79/#82 made the gate policy-aware, introduce kept a hardcoded
29
+ * `chat_not_allowlisted` check for *every* policy — so an `allow_users` sender
30
+ * could chat in a brand-new `follow-user` group but could never `/introduce`
31
+ * there. That accidental split is the bug this contract now closes.
16
32
  *
17
33
  * The peer bots being introduced are the message's @-mentions (excluding our
18
34
  * own bot); the host records them as *trusted* for the chat. Recording a human
@@ -26,22 +42,37 @@ const UNKNOWN_PEER_LABEL = '伙伴';
26
42
  * is authorized. This is the single source of truth for the issue #62 hard
27
43
  * contract; `canRunIntroduce` is the boolean projection of it.
28
44
  *
29
- * Sender-scoped, not group-scoped: the chat must be explicitly allowlisted AND
30
- * the sender must be on the global `allow_users` list (the same list that gates
31
- * direct messages and `follow-user` group delivery). Empty allowlists do not
32
- * authorize anyone there is no "any member of an allowlisted group" path.
45
+ * Policy-aware, mirroring `dreamuxFeishuGate`'s group branch for the same policy
46
+ * (minus the @-mention requirement introduce waives):
47
+ * - `block` → `group_blocked` (the gate drops every group message).
48
+ * - `follow-user` `allow_chats` is ignored exactly as the gate ignores it;
49
+ * only the sender's membership in `allow_users` matters.
50
+ * - `allowlist` → the chat must be in `allow_chats` (chat-as-unit-of-trust)
51
+ * AND the sender must be on `allow_users` (the #62 sender
52
+ * scoping that the delivery gate does not impose).
53
+ * Empty allowlists authorize nobody — there is no "any member of an allowlisted
54
+ * group" path.
33
55
  */
34
56
  export function introduceDenyReason(access, input) {
35
57
  if (input.chatType !== 'group')
36
58
  return 'non_group';
37
59
  if (input.senderId === '')
38
60
  return 'empty_sender_id';
39
- // The chat must be explicitly allowlisted. Under the `follow-user` policy an
40
- // empty `allow_chats` means "every chat" for normal delivery, but a
41
- // trust-changing command always requires the chat to be named, so introduce
42
- // never fires in an incidental group regardless of the group policy.
43
- if (!access.group.allow_chats.includes(input.chatId))
61
+ const policy = access.group.policy;
62
+ // `block` drops every group message; a trust-changing command is no exception.
63
+ // (Before this was explicit, `block` blocked introduce only by accident — its
64
+ // empty `allow_chats` tripped `chat_not_allowlisted`. Once `follow-user` stops
65
+ // checking `allow_chats`, the block case needs its own guard.)
66
+ if (policy === 'block')
67
+ return 'group_blocked';
68
+ // Under `allowlist` the group is the unit of trust, so the chat must be named.
69
+ // Under `follow-user` the chat allowlist is intentionally ignored — the group
70
+ // needs no authorization, exactly as the delivery gate ignores it. This is the
71
+ // line that was previously hardcoded for every policy and split introduce from
72
+ // the gate (issue #82 made the gate policy-aware but left this behind).
73
+ if (policy === 'allowlist' && !access.group.allow_chats.includes(input.chatId)) {
44
74
  return 'chat_not_allowlisted';
75
+ }
45
76
  // The sender must be on the global allow-user list — the same list that gates
46
77
  // direct messages and `follow-user` group delivery. An empty list authorizes
47
78
  // nobody, keeping the rule sender-scoped rather than "any member of an
@@ -1 +1 @@
1
- {"version":3,"file":"introduce.js","sourceRoot":"","sources":["../../src/channel/introduce.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAOH,MAAM,YAAY,GAAG,uBAAuB,CAAC;AAC7C,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAoBhC;;;;;;;;;GASG;AACH,MAAM,UAAU,mBAAmB,CACjC,MAA6B,EAC7B,KAAyB;IAEzB,IAAI,KAAK,CAAC,QAAQ,KAAK,OAAO;QAAE,OAAO,WAAW,CAAC;IACnD,IAAI,KAAK,CAAC,QAAQ,KAAK,EAAE;QAAE,OAAO,iBAAiB,CAAC;IACpD,6EAA6E;IAC7E,oEAAoE;IACpE,4EAA4E;IAC5E,qEAAqE;IACrE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC;QAAE,OAAO,sBAAsB,CAAC;IACpF,8EAA8E;IAC9E,6EAA6E;IAC7E,uEAAuE;IACvE,uEAAuE;IACvE,4EAA4E;IAC5E,uCAAuC;IACvC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC;QAAE,OAAO,qBAAqB,CAAC;IAC/E,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAC7B,MAA6B,EAC7B,KAAyB;IAEzB,OAAO,mBAAmB,CAAC,MAAM,EAAE,KAAK,CAAC,KAA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CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;IAC3E,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAgB;IAC/C,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACpC,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,iBAAiB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC3E,OAAO,WAAW,KAAK,CAAC,MAAM,QAAQ,KAAK,EAAE,CAAC;AAChD,CAAC;AAED,SAAS,iBAAiB,CAAC,IAAa;IACtC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACtE,OAAO,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,kBAAkB,CAAC;AACjD,CAAC;AAED,SAAS,cAAc,CAAC,KAAa;IACnC,OAAO,KAAK;SACT,OAAO,CAAC,yBAAyB,EAAE,GAAG,CAAC;SACvC,OAAO,CAAC,UAAU,EAAE,GAAG,CAAC;SACxB,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;SACpB,IAAI,EAAE,CAAC;AACZ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@excitedjs/dreamux",
3
- "version": "0.9.2",
3
+ "version": "0.9.3",
4
4
  "description": "Codex-host server — single-session MVP. One node process hosts N dispatchers, each binding 1 Feishu bot + 1 Codex thread.",
5
5
  "license": "MIT",
6
6
  "repository": {