@xmanrui/dsh-im 3.0.3 → 3.0.4

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/README.en.md CHANGED
@@ -129,7 +129,7 @@ Use the proxy URL required by your network and restart the Host after changing i
129
129
 
130
130
  Each Telegram bot has its own access-mode control on its bot card. Existing and newly connected bots both default to **Compatible mode**: DMs receive replies, while group messages require a mention of or reply to the bot. Restrictions apply only after explicitly switching that bot to **Safe mode (private-chat allowlist)**. Safe mode ignores every group message and admits only numeric User IDs in that bot's allowlist. Enter one ID per line. Switching back to Compatible mode retains the allowlist without enforcing it, so it is available when Safe mode is enabled again. An empty allowlist in Safe mode rejects all inbound messages for that bot.
131
131
 
132
- Each WhatsApp bot also has its own access mode. Existing bots migrate to **Only me**, which is also the default for newly linked bots and accepts only self-chat messages from the linked account. **Selected contacts** additionally accepts direct messages from phone numbers in its list and ignores groups. **Open responses** accepts all direct messages, group messages sent by the linked account, and mentions of or replies to that account from members in its separate group number list. Leaving the group number list empty allows every group member; this also lets an owner-only group act as a separate conversation. The two number lists are stored independently. Enter one number with its country or region code per line; a leading `+` is optional. An empty Selected contacts list behaves like Only me, and rejected messages are ignored silently.
132
+ Each WhatsApp bot also has its own access mode. Existing bots migrate to **Only me**, which is also the default for newly linked bots and accepts only self-chat messages from the linked account. **Selected contacts** additionally accepts direct messages from allowlisted phone numbers and ignores groups. Enter one number with its country or region code per line; a leading `+` is optional. **Open responses** accepts all direct messages, group messages sent by the linked account, and mentions of or replies to that account from other group members; this also lets an owner-only group act as a separate conversation. Switching modes retains the allowlist. An empty Selected contacts allowlist behaves like Only me, and rejected messages are ignored silently.
133
133
 
134
134
  ## Bot commands
135
135
 
@@ -194,7 +194,7 @@ If the Slack desktop app has no native Slash Command registered with the same na
194
194
  - `/session` accepts exactly one Session ID obtained from `/sessionlist`. It neither creates a session nor immediately prompts the model; later messages in the current chat continue the bound session. Regular archived sessions can be bound without being unarchived, while subagent sessions cannot be bound.
195
195
  - `/session` locates the session's unique workspace automatically. Binding inside the current workspace replaces only this chat's mapping. A cross-workspace binding switches the bot workspace, clears the old session mappings for all of that bot's chats, and then binds this chat, so it affects the bot's other chats. A reply already being generated may still finish.
196
196
  - Workspace switches and session bindings only clear or replace dsh-im chat mappings. They never delete, empty, or archive old Session contents; an old Session can still be listed and bound again.
197
- - Any user admitted by the current channel access policy can run these commands; there is no separate administrator role. Telegram Compatible mode follows the original DM and group mention/reply rules, while Safe mode admits only allowlisted private users. WhatsApp Only me accepts self-chat only, Selected contacts accepts self-chat plus allowlisted direct messages, and Open responses accepts every direct message, group messages from the linked account, and mentions or replies from listed group members; an empty number list allows every group member.
197
+ - Any user admitted by the current channel access policy can run these commands; there is no separate administrator role. Telegram Compatible mode follows the original DM and group mention/reply rules, while Safe mode admits only allowlisted private users. WhatsApp Only me accepts self-chat only, Selected contacts accepts self-chat plus allowlisted direct messages, and Open responses accepts every direct message, group messages from the linked account, and mentions or replies from other group members.
198
198
  - Agent Preset names and IDs come from the same Harness Host, and any command-authorized user can change the Preset used by all future new Sessions across this bot's chats. Expose `/presetlist` and `/preset` only to trusted users.
199
199
  - The list comes from the Harness Host's global registry and can include local absolute paths for other bots, other channels, or non-IM projects. Restrict the bot's visibility to trusted users.
200
200
  - Session results also come from the global Harness Host. Session IDs and titles can belong to other bots, other channels, or non-IM projects, and may contain sensitive metadata. Enable these commands only when every user in the bot's visibility scope is trusted.
package/README.md CHANGED
@@ -132,7 +132,7 @@ dsh web
132
132
 
133
133
  每个 Telegram 机器人都可以在自己的卡片中切换访问模式。旧机器人和新接入机器人均默认使用**兼容模式**:私聊直接响应,群聊仅在提及机器人或回复机器人消息时响应。只有主动切换到**安全模式(私聊白名单)**后,机器人才会忽略全部群聊,并只接受该机器人白名单中的数字 User ID。白名单每行一个 ID、按机器人独立保存;切回兼容模式时会保留但不使用,再切回安全模式即可继续使用。安全模式的空白名单会拒绝该机器人的所有入站消息。
134
134
 
135
- 每个 WhatsApp 机器人也有独立的访问模式。旧机器人升级后和新接入机器人都默认使用**仅自己模式**,只响应已绑定账号的自聊消息。**指定联系人模式**额外接受其号码列表中联系人的私聊并忽略群聊。**开放响应模式**响应所有私聊、已绑定账号自己发出的群聊消息,以及其独立群聊号码列表中成员对该账号的提及或回复;群聊号码列表留空时允许所有群成员,因此也可以把“仅自己”的群当作独立会话使用。两个号码列表分别保存、互不影响;号码需包含国家或地区代码,每行一个,可带开头的 `+`。指定联系人模式的空列表等同于仅自己模式。未授权消息会被静默忽略。
135
+ 每个 WhatsApp 机器人也有独立的访问模式。旧机器人升级后和新接入机器人都默认使用**仅自己模式**,只响应已绑定账号的自聊消息。**指定联系人模式**额外接受白名单电话号码的私聊并忽略群聊;号码需包含国家或地区代码,每行一个,可带开头的 `+`。**开放响应模式**响应所有私聊、已绑定账号自己发出的群聊消息,以及其他群成员对该账号的提及或回复;因此也可以把“仅自己”的群当作独立会话使用。切换模式会保留白名单;指定联系人模式的空白名单等同于仅自己模式。未授权消息会被静默忽略。
136
136
 
137
137
  ## 机器人命令
138
138
 
@@ -197,7 +197,7 @@ Slack 桌面端若未注册同名的原生 Slash Command,会拦截直接以 `/
197
197
  - `/session` 只接受一个由 `/sessionlist` 获得的 Session ID。它不会新建会话或立即向模型发送消息;绑定成功后,当前聊天的后续消息会继续该会话。普通归档会话可以绑定但不会自动取消归档,子代理会话不能绑定。
198
198
  - `/session` 会自动定位会话唯一所属的工作区。同工作区绑定只替换当前聊天的映射;跨工作区绑定会切换该机器人的工作区、清除该机器人所有聊天的旧会话映射,再绑定当前聊天,因此会影响该机器人的其他聊天。已经开始生成的回复仍可完成。
199
199
  - 工作区切换和会话绑定只会清除或替换 dsh-im 的聊天映射,不会删除、清空或归档任何旧 Session 内容;旧 Session 仍可再次列出和绑定。
200
- - 任何通过当前渠道访问策略的用户都可以执行这些命令,不另行区分管理员和普通用户。Telegram 兼容模式遵循原有私聊及群聊提及/回复规则;安全模式只允许当前机器人白名单中的私聊用户执行。WhatsApp 仅自己模式只接受自聊,指定联系人模式接受自聊和白名单私聊,开放响应模式接受所有私聊、已绑定账号自己发出的群聊消息,以及允许号码对应群成员的提及或回复;号码列表留空时允许所有群成员。
200
+ - 任何通过当前渠道访问策略的用户都可以执行这些命令,不另行区分管理员和普通用户。Telegram 兼容模式遵循原有私聊及群聊提及/回复规则;安全模式只允许当前机器人白名单中的私聊用户执行。WhatsApp 仅自己模式只接受自聊,指定联系人模式接受自聊和白名单私聊,开放响应模式接受所有私聊、已绑定账号自己发出的群聊消息,以及其他群成员的提及或回复。
201
201
  - Agent Preset 名称和 ID 来自同一个 Harness Host,且任何有命令权限的用户都能修改该机器人所有聊天未来新 Session 的 Preset;请只向可信用户开放 `/presetlist` 和 `/preset`。
202
202
  - 工作区列表来自 Harness Host 的全局登记信息,可能包含其他机器人、其他渠道或非 IM 项目的本机绝对路径。请将机器人可见范围限制给可信用户。
203
203
  - 会话列表同样来自该全局 Harness Host;会话 ID 和标题可能属于其他机器人、其他渠道或非 IM 项目,并可能包含敏感元数据。开放命令前请确保所有可见用户都可信。
package/lib/client.js CHANGED
@@ -47,7 +47,7 @@ var React20 = __toESM(require("react"), 1);
47
47
  // package.json
48
48
  var package_default = {
49
49
  name: "@xmanrui/dsh-im",
50
- version: "3.0.3",
50
+ version: "3.0.4",
51
51
  description: "\u628A\u4E5D\u79CD IM \u673A\u5668\u4EBA\u548C\u516C\u7F51 AI Office \u63A5\u5165\u672C\u673A DeepSeek Harness\u3002 Connect nine IM channels and a public AI Office to a local DeepSeek Harness.",
52
52
  keywords: [
53
53
  "deepseek-harness",
@@ -681,12 +681,9 @@ var EN = Object.freeze({
681
681
  "\u53EA\u54CD\u5E94\u5DF2\u7ED1\u5B9A WhatsApp \u8D26\u53F7\u7684\u81EA\u804A\u6D88\u606F\u3002": "Only respond to self-chat messages from the linked WhatsApp account.",
682
682
  "\u54CD\u5E94\u81EA\u804A\u548C\u767D\u540D\u5355\u8054\u7CFB\u4EBA\u7684\u79C1\u804A\uFF0C\u5FFD\u7565\u7FA4\u804A\u3002": "Respond to self-chat and allowlisted direct messages; ignore group messages.",
683
683
  "\u54CD\u5E94\u6240\u6709\u79C1\u804A\u3001\u5DF2\u7ED1\u5B9A\u8D26\u53F7\u81EA\u5DF1\u53D1\u51FA\u7684\u7FA4\u804A\u6D88\u606F\uFF0C\u4EE5\u53CA\u5176\u4ED6\u7FA4\u6210\u5458\u7684\u63D0\u53CA\u6216\u56DE\u590D\u3002": "Respond to all direct messages, group messages sent by the linked account, and mentions or replies from other group members.",
684
- "\u54CD\u5E94\u6240\u6709\u79C1\u804A\u3001\u5DF2\u7ED1\u5B9A\u8D26\u53F7\u81EA\u5DF1\u53D1\u51FA\u7684\u7FA4\u804A\u6D88\u606F\uFF0C\u4EE5\u53CA\u5141\u8BB8\u6210\u5458\u7684\u63D0\u53CA\u6216\u56DE\u590D\uFF1B\u7FA4\u804A\u53F7\u7801\u5217\u8868\u7559\u7A7A\u65F6\u5141\u8BB8\u6240\u6709\u7FA4\u6210\u5458\u3002": "Respond to all direct messages, group messages sent by the linked account, and mentions or replies from allowed members; leaving the group number list empty allows every group member.",
685
684
  "\u5141\u8BB8\u79C1\u804A\u7684 WhatsApp \u7535\u8BDD\u53F7\u7801": "WhatsApp phone numbers allowed to send direct messages",
686
- "\u5141\u8BB8\u5728\u7FA4\u804A\u4E2D\u547C\u53EB\u673A\u5668\u4EBA\u7684 WhatsApp \u7535\u8BDD\u53F7\u7801": "WhatsApp phone numbers allowed to call the bot in group chats",
687
685
  "\u6BCF\u884C\u4E00\u4E2A\u542B\u56FD\u5BB6\u6216\u5730\u533A\u4EE3\u7801\u7684\u53F7\u7801": "One number with country or region code per line",
688
686
  "\u53EF\u4EE5\u5305\u542B\u5F00\u5934\u7684 +\uFF0C\u4FDD\u5B58\u65F6\u4F1A\u81EA\u52A8\u79FB\u9664\u3002": "A leading + is allowed and removed when saved.",
689
- "\u7559\u7A7A\u8868\u793A\u6240\u6709\u7FA4\u6210\u5458\u90FD\u53EF\u4EE5\u901A\u8FC7\u63D0\u53CA\u6216\u56DE\u590D\u547C\u53EB\u673A\u5668\u4EBA\u3002": "Leave empty to let every group member call the bot by mentioning it or replying to it.",
690
687
  "\u4EC5\u6307\u5B9A\u8054\u7CFB\u4EBA\u6A21\u5F0F\u4F7F\u7528\u767D\u540D\u5355\uFF0C\u5207\u6362\u6A21\u5F0F\u65F6\u4F1A\u4FDD\u7559\u3002": "Only Selected contacts uses the allowlist; it is retained when modes change.",
691
688
  "\u767D\u540D\u5355\u4E3A\u7A7A\uFF1B\u4FDD\u5B58\u540E\u5C06\u53EA\u63A5\u53D7\u81EA\u804A\u6D88\u606F\u3002": "The allowlist is empty; only self-chat messages will be accepted after saving.",
692
689
  "\u7535\u8BDD\u53F7\u7801\u5FC5\u987B\u5305\u542B\u56FD\u5BB6\u6216\u5730\u533A\u4EE3\u7801\uFF0C\u6BCF\u884C\u4E00\u4E2A\u3002": "Each phone number must include a country or region code on its own line.",
@@ -9409,8 +9406,7 @@ function normalizeBot6(value) {
9409
9406
  accessMode: ["self-only", "private-allowlist", "open"].includes(
9410
9407
  value.accessPolicy?.accessMode
9411
9408
  ) ? value.accessPolicy.accessMode : "self-only",
9412
- allowedNumbers: Array.isArray(value.accessPolicy?.allowedNumbers) ? [...new Set(value.accessPolicy.allowedNumbers.filter((entry) => typeof entry === "string" && /^[1-9]\d{4,14}$/.test(entry)))] : [],
9413
- groupAllowedNumbers: Array.isArray(value.accessPolicy?.groupAllowedNumbers) ? [...new Set(value.accessPolicy.groupAllowedNumbers.filter((entry) => typeof entry === "string" && /^[1-9]\d{4,14}$/.test(entry)))] : []
9409
+ allowedNumbers: Array.isArray(value.accessPolicy?.allowedNumbers) ? [...new Set(value.accessPolicy.allowedNumbers.filter((entry) => typeof entry === "string" && /^[1-9]\d{4,14}$/.test(entry)))] : []
9414
9410
  },
9415
9411
  bot: {
9416
9412
  name: text5(value.bot?.name, "WhatsApp\u673A\u5668\u4EBA", 100),
@@ -9509,8 +9505,7 @@ function accessPolicyFor(account) {
9509
9505
  ) ? account.accessPolicy.accessMode : "self-only";
9510
9506
  return {
9511
9507
  accessMode,
9512
- allowedNumbers: Array.isArray(account?.accessPolicy?.allowedNumbers) ? account.accessPolicy.allowedNumbers : [],
9513
- groupAllowedNumbers: Array.isArray(account?.accessPolicy?.groupAllowedNumbers) ? account.accessPolicy.groupAllowedNumbers : []
9508
+ allowedNumbers: Array.isArray(account?.accessPolicy?.allowedNumbers) ? account.accessPolicy.allowedNumbers : []
9514
9509
  };
9515
9510
  }
9516
9511
  function allowedNumbersFromText(value) {
@@ -9524,36 +9519,27 @@ function allowedNumbersFromText(value) {
9524
9519
  function WhatsappAccessSettings({ account, busy = false, onSave }) {
9525
9520
  const policy = accessPolicyFor(account);
9526
9521
  const sourceNumbers = policy.allowedNumbers.join("\n");
9527
- const sourceGroupNumbers = policy.groupAllowedNumbers.join("\n");
9528
9522
  const helpId = React19.useId();
9529
9523
  const [accessMode, setAccessMode] = React19.useState(policy.accessMode);
9530
9524
  const [allowedNumbers, setAllowedNumbers] = React19.useState(sourceNumbers);
9531
- const [groupAllowedNumbers, setGroupAllowedNumbers] = React19.useState(sourceGroupNumbers);
9532
9525
  const [error, setError] = React19.useState(null);
9533
9526
  React19.useEffect(() => {
9534
9527
  setAccessMode(policy.accessMode);
9535
9528
  setAllowedNumbers(sourceNumbers);
9536
- setGroupAllowedNumbers(sourceGroupNumbers);
9537
9529
  setError(null);
9538
- }, [policy.accessMode, sourceNumbers, sourceGroupNumbers]);
9530
+ }, [policy.accessMode, sourceNumbers]);
9539
9531
  const save = async (event) => {
9540
9532
  event.preventDefault();
9541
9533
  setError(null);
9542
9534
  try {
9543
9535
  const normalized = allowedNumbersFromText(allowedNumbers);
9544
- const normalizedGroup = allowedNumbersFromText(groupAllowedNumbers);
9545
9536
  if (typeof onSave !== "function") throw new Error("WhatsApp \u8BBF\u95EE\u8BBE\u7F6E\u6682\u4E0D\u53EF\u7528\u3002");
9546
- await onSave({
9547
- accessMode,
9548
- allowedNumbers: normalized,
9549
- groupAllowedNumbers: normalizedGroup
9550
- });
9537
+ await onSave({ accessMode, allowedNumbers: normalized });
9551
9538
  } catch (caught) {
9552
9539
  setError(caught?.message ?? "WhatsApp \u8BBF\u95EE\u8BBE\u7F6E\u4FDD\u5B58\u5931\u8D25\u3002");
9553
9540
  }
9554
9541
  };
9555
9542
  const allowlistEnabled = accessMode === "private-allowlist";
9556
- const groupAllowlistEnabled = accessMode === "open";
9557
9543
  const labels = {
9558
9544
  "self-only": "\u4EC5\u81EA\u5DF1\u6A21\u5F0F",
9559
9545
  "private-allowlist": "\u6307\u5B9A\u8054\u7CFB\u4EBA\u6A21\u5F0F",
@@ -9602,7 +9588,7 @@ function WhatsappAccessSettings({ account, busy = false, onSave }) {
9602
9588
  "span",
9603
9589
  { className: "dwa-accessTooltipItem" },
9604
9590
  h2("strong", null, "\u5F00\u653E\u54CD\u5E94\u6A21\u5F0F"),
9605
- h2("span", null, "\u54CD\u5E94\u6240\u6709\u79C1\u804A\u3001\u5DF2\u7ED1\u5B9A\u8D26\u53F7\u81EA\u5DF1\u53D1\u51FA\u7684\u7FA4\u804A\u6D88\u606F\uFF0C\u4EE5\u53CA\u5141\u8BB8\u6210\u5458\u7684\u63D0\u53CA\u6216\u56DE\u590D\uFF1B\u7FA4\u804A\u53F7\u7801\u5217\u8868\u7559\u7A7A\u65F6\u5141\u8BB8\u6240\u6709\u7FA4\u6210\u5458\u3002")
9591
+ h2("span", null, "\u54CD\u5E94\u6240\u6709\u79C1\u804A\u3001\u5DF2\u7ED1\u5B9A\u8D26\u53F7\u81EA\u5DF1\u53D1\u51FA\u7684\u7FA4\u804A\u6D88\u606F\uFF0C\u4EE5\u53CA\u5176\u4ED6\u7FA4\u6210\u5458\u7684\u63D0\u53CA\u6216\u56DE\u590D\u3002")
9606
9592
  )
9607
9593
  )
9608
9594
  )
@@ -9628,23 +9614,22 @@ function WhatsappAccessSettings({ account, busy = false, onSave }) {
9628
9614
  h2("option", { value: "open" }, "\u5F00\u653E\u54CD\u5E94\u6A21\u5F0F")
9629
9615
  )
9630
9616
  ),
9631
- allowlistEnabled || groupAllowlistEnabled ? h2(
9617
+ allowlistEnabled ? h2(
9632
9618
  "label",
9633
9619
  { className: "dwa-accessField" },
9634
- h2("span", null, allowlistEnabled ? "\u5141\u8BB8\u79C1\u804A\u7684 WhatsApp \u7535\u8BDD\u53F7\u7801" : "\u5141\u8BB8\u5728\u7FA4\u804A\u4E2D\u547C\u53EB\u673A\u5668\u4EBA\u7684 WhatsApp \u7535\u8BDD\u53F7\u7801"),
9620
+ h2("span", null, "\u5141\u8BB8\u79C1\u804A\u7684 WhatsApp \u7535\u8BDD\u53F7\u7801"),
9635
9621
  h2("textarea", {
9636
- value: allowlistEnabled ? allowedNumbers : groupAllowedNumbers,
9622
+ value: allowedNumbers,
9637
9623
  disabled: busy,
9638
9624
  rows: 3,
9639
9625
  placeholder: "\u6BCF\u884C\u4E00\u4E2A\u542B\u56FD\u5BB6\u6216\u5730\u533A\u4EE3\u7801\u7684\u53F7\u7801",
9640
- "aria-label": allowlistEnabled ? "\u5141\u8BB8\u79C1\u804A\u7684 WhatsApp \u7535\u8BDD\u53F7\u7801" : "\u5141\u8BB8\u5728\u7FA4\u804A\u4E2D\u547C\u53EB\u673A\u5668\u4EBA\u7684 WhatsApp \u7535\u8BDD\u53F7\u7801",
9626
+ "aria-label": "\u5141\u8BB8\u79C1\u804A\u7684 WhatsApp \u7535\u8BDD\u53F7\u7801",
9641
9627
  onChange: (event) => {
9642
- if (allowlistEnabled) setAllowedNumbers(event.target.value);
9643
- else setGroupAllowedNumbers(event.target.value);
9628
+ setAllowedNumbers(event.target.value);
9644
9629
  setError(null);
9645
9630
  }
9646
9631
  }),
9647
- h2("small", null, allowlistEnabled ? "\u53EF\u4EE5\u5305\u542B\u5F00\u5934\u7684 +\uFF0C\u4FDD\u5B58\u65F6\u4F1A\u81EA\u52A8\u79FB\u9664\u3002" : "\u7559\u7A7A\u8868\u793A\u6240\u6709\u7FA4\u6210\u5458\u90FD\u53EF\u4EE5\u901A\u8FC7\u63D0\u53CA\u6216\u56DE\u590D\u547C\u53EB\u673A\u5668\u4EBA\u3002")
9632
+ h2("small", null, "\u53EF\u4EE5\u5305\u542B\u5F00\u5934\u7684 +\uFF0C\u4FDD\u5B58\u65F6\u4F1A\u81EA\u52A8\u79FB\u9664\u3002")
9648
9633
  ) : null,
9649
9634
  allowlistEnabled && allowedNumbers.trim() === "" ? h2(
9650
9635
  "p",