@xmanrui/dsh-im 4.8.0 → 4.9.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.
@@ -2,7 +2,6 @@ import { promptContentForMessage } from '../image-prompt.mjs';
2
2
 
3
3
  const REPLY_CONTENT_MAX_CODE_POINTS = 8_000;
4
4
  const REPLY_ATTACHMENTS_MAX = 20;
5
- const REPLY_ID_MAX_CODE_POINTS = 512;
6
5
  const REPLY_AUTHOR_NAME_MAX_CODE_POINTS = 256;
7
6
  const REPLY_ATTACHMENT_NAME_MAX_CODE_POINTS = 255;
8
7
 
@@ -105,8 +104,6 @@ async function resolveReference(reference, signal) {
105
104
  }
106
105
 
107
106
  function normalizeReference(reference) {
108
- const messageId = cleanString(reference.messageId, REPLY_ID_MAX_CODE_POINTS);
109
- const authorId = cleanString(reference.authorId, REPLY_ID_MAX_CODE_POINTS);
110
107
  const authorName = cleanString(reference.authorName, REPLY_AUTHOR_NAME_MAX_CODE_POINTS);
111
108
  const content = cleanString(reference.content, REPLY_CONTENT_MAX_CODE_POINTS, { multiline: true });
112
109
  const { attachments, truncated: attachmentsTruncated } = cleanAttachments(reference.attachments);
@@ -114,19 +111,16 @@ function normalizeReference(reference) {
114
111
  if (!content.value && attachments.length === 0 && !unavailableReason) {
115
112
  unavailableReason = 'not-delivered';
116
113
  }
114
+ const truncated = authorName.truncated
115
+ || content.truncated
116
+ || attachmentsTruncated;
117
117
  return {
118
118
  note: REPLY_NOTE,
119
- ...(messageId.value ? { messageId: messageId.value } : {}),
120
- ...(authorId.value ? { authorId: authorId.value } : {}),
121
119
  ...(authorName.value ? { authorName: authorName.value } : {}),
122
120
  ...(content.value ? { content: content.value } : {}),
123
- attachments,
121
+ ...(attachments.length > 0 ? { attachments } : {}),
124
122
  ...(unavailableReason ? { unavailableReason } : {}),
125
- truncated: messageId.truncated
126
- || authorId.truncated
127
- || authorName.truncated
128
- || content.truncated
129
- || attachmentsTruncated,
123
+ ...(truncated ? { truncated: true } : {}),
130
124
  };
131
125
  }
132
126
 
@@ -596,6 +596,7 @@ export class TextHarnessBridge {
596
596
  t('/history [数量] 查看最近历史消息(默认 3 条,最多 5 条)'),
597
597
  t('/workspace 工作区序号或绝对路径 切换工作区'),
598
598
  t('/workspacelist 列出工作区绝对路径'),
599
+ t('/ws、/wsl、/workspaces 工作区命令别名'),
599
600
  t('/sessionlist 或 /sessions [工作区序号或绝对路径] 列出会话 ID 和标题'),
600
601
  t('/sessionlist --limit N 仅列出当前工作区前 N 个会话'),
601
602
  t('/session Session ID 或当前工作区序号 将当前聊天绑定到指定会话'),
@@ -4,8 +4,8 @@ import { isAbsolute, resolve } from 'node:path';
4
4
  import { t } from './i18n.mjs';
5
5
  import { WORKSPACE_SESSION_STALE } from './workspace-session.mjs';
6
6
 
7
- const WORKSPACE_COMMAND = /^\/workspace(?:\s+([\s\S]+))?$/i;
8
- const WORKSPACE_LIST_COMMAND = /^\/workspacelist(?:\s+([\s\S]+))?$/i;
7
+ const WORKSPACE_COMMAND = /^\/(?:workspace|ws)(?:\s+([\s\S]+))?$/i;
8
+ const WORKSPACE_LIST_COMMAND = /^\/(?:workspacelist|workspaces|wsl)(?:\s+([\s\S]+))?$/i;
9
9
  const SESSION_LIST_COMMAND = /^\/(?:sessionlist|sessions)(?:\s+([\s\S]+))?$/i;
10
10
  const SESSION_BIND_PREFIX = /^\/session(?=$|\s)/i;
11
11
  const SESSION_BIND_COMMAND = /^\/session[ \t]+([^\s]+)$/i;
@@ -21,7 +21,10 @@ export const TELEGRAM_COMMAND_MENU = Object.freeze([
21
21
  { command: 'new', description: '开启一个全新会话' },
22
22
  { command: 'compact', description: '压缩当前会话的较早上下文' },
23
23
  { command: 'workspace', description: '切换工作区' },
24
+ { command: 'ws', description: '切换工作区' },
24
25
  { command: 'workspacelist', description: '列出工作区绝对路径' },
26
+ { command: 'workspaces', description: '列出工作区绝对路径' },
27
+ { command: 'wsl', description: '列出工作区绝对路径' },
25
28
  { command: 'sessionlist', description: '列出会话 ID 和标题' },
26
29
  { command: 'sessions', description: '列出会话 ID 和标题' },
27
30
  { command: 'session', description: '将当前聊天绑定到指定会话' },
@@ -139,11 +142,10 @@ function telegramFileSource(message, loadFile) {
139
142
  };
140
143
  }
141
144
 
142
- function telegramReplyAttachment(kind, file, fallbackName) {
145
+ function telegramReplyAttachment(kind, file) {
143
146
  if (!file || typeof file !== 'object') return null;
144
147
  const name = typeof file.file_name === 'string' && file.file_name
145
- ? file.file_name : typeof fallbackName === 'string' && fallbackName
146
- ? fallbackName : undefined;
148
+ ? file.file_name : undefined;
147
149
  return { kind, ...(name ? { name } : {}) };
148
150
  }
149
151
 
@@ -153,11 +155,7 @@ function telegramReplyAttachments(message) {
153
155
  const largest = message.photo.reduce((best, candidate) => (
154
156
  photoScore(candidate) > photoScore(best) ? candidate : best
155
157
  ));
156
- attachments.push(telegramReplyAttachment(
157
- 'image',
158
- largest,
159
- `${largest.file_unique_id ?? largest.file_id ?? 'telegram-photo'}.jpg`,
160
- ));
158
+ attachments.push(telegramReplyAttachment('image', largest));
161
159
  } else if (message?.document) {
162
160
  attachments.push(telegramReplyAttachment(
163
161
  imageTypeForDocument(message.document) ? 'image' : 'file',
@@ -177,7 +175,6 @@ function telegramReplyAttachments(message) {
177
175
  attachments.push(telegramReplyAttachment(
178
176
  message.sticker.is_video === true ? 'video' : 'image',
179
177
  message.sticker,
180
- message.sticker.file_unique_id ?? message.sticker.file_id,
181
178
  ));
182
179
  }
183
180
  return attachments.filter(Boolean);
@@ -73,6 +73,7 @@ function helpText() {
73
73
  t('/history [数量] 查看最近历史消息(默认 3 条,最多 5 条)'),
74
74
  t('/workspace 工作区序号或绝对路径 切换工作区'),
75
75
  t('/workspacelist 列出工作区绝对路径'),
76
+ t('/ws、/wsl、/workspaces 工作区命令别名'),
76
77
  t('/sessionlist 或 /sessions [工作区序号或绝对路径] 列出会话 ID 和标题'),
77
78
  t('/sessionlist --limit N 仅列出当前工作区前 N 个会话'),
78
79
  t('/session Session ID 或当前工作区序号 将当前聊天绑定到指定会话'),
@@ -87,6 +87,7 @@ const HELP_TEXT = () => [
87
87
  t('/history [数量] 查看最近历史消息(默认 3 条,最多 5 条)'),
88
88
  t('/workspace 工作区序号或绝对路径 切换工作区'),
89
89
  t('/workspacelist 列出工作区绝对路径'),
90
+ t('/ws、/wsl、/workspaces 工作区命令别名'),
90
91
  t('/sessionlist 或 /sessions [工作区序号或绝对路径] 列出会话 ID 和标题'),
91
92
  t('/sessionlist --limit N 仅列出当前工作区前 N 个会话'),
92
93
  t('/session Session ID 或当前工作区序号 将当前聊天绑定到指定会话'),