@qzsy/dsh-bridge 2.18.0 → 3.0.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 +15 -1094
- package/LICENSE +21 -21
- package/README.md +73 -476
- package/client/build.mjs +1 -3
- package/client/client.js +381 -9747
- package/client/index.js +242 -6828
- package/client/locales.mjs +99 -233
- package/cordis.patch.yml +5 -3
- package/lib/config.js +93 -0
- package/lib/data-dir.js +16 -0
- package/lib/dsh-cookie.js +111 -0
- package/lib/gate.js +414 -0
- package/lib/identity.js +23 -0
- package/lib/index.js +303 -3496
- package/lib/saas/tunnel-client.mjs +529 -467
- package/locale/en.json +3 -3
- package/locale/zh.json +3 -3
- package/package.json +15 -70
- package/README.en.md +0 -488
- package/client/host-families.js +0 -442
- package/client/mobile-styles.js +0 -1299
- package/client/mobile-yield.js +0 -219
- package/client/panel-locales.mjs +0 -777
- package/client/picker-yield.js +0 -77
- package/client/resource-url-compat.js +0 -90
- package/client/settings-nav-icon.js +0 -105
- package/client/theme-tokens.js +0 -49
- package/client/tunnel-guard.js +0 -46
- package/client/unlock-manager.js +0 -144
- package/lib/auth/dsh-native-cookie.js +0 -148
- package/lib/auth/login-template.js +0 -516
- package/lib/auth/manager.js +0 -596
- package/lib/bridge-rpc-constants.js +0 -66
- package/lib/bridge-rpc.js +0 -722
- package/lib/cloudflared-manager.mjs +0 -1277
- package/lib/cloudflared-network-args.js +0 -99
- package/lib/cloudflared-process-scan.js +0 -153
- package/lib/compat.js +0 -172
- package/lib/connection-compat.js +0 -115
- package/lib/feishu/comment.js +0 -50
- package/lib/feishu/gateway.js +0 -644
- package/lib/feishu/index.js +0 -432
- package/lib/feishu/lark-bundled.mjs +0 -131929
- package/lib/feishu/markdown.js +0 -148
- package/lib/feishu/node.js +0 -1152
- package/lib/feishu/slash-commands.js +0 -255
- package/lib/platform/account-ops.js +0 -248
- package/lib/platform/activity.js +0 -169
- package/lib/platform/ask-user.js +0 -293
- package/lib/platform/base.js +0 -147
- package/lib/platform/changes-digest.js +0 -93
- package/lib/platform/commands.js +0 -267
- package/lib/platform/config-restore.js +0 -78
- package/lib/platform/conversation-bridge.js +0 -1544
- package/lib/platform/dsh-storage.js +0 -222
- package/lib/platform/index.js +0 -10
- package/lib/platform/instances.js +0 -458
- package/lib/platform/manager.js +0 -130
- package/lib/platform/message-split.js +0 -229
- package/lib/platform/session-catalog.js +0 -405
- package/lib/platform/session-config.js +0 -52
- package/lib/platform/stream-slices.js +0 -21
- package/lib/qq/gateway.js +0 -1107
- package/lib/qq/index.js +0 -561
- package/lib/qq/node.js +0 -1153
- package/lib/qq/qqbot-bundled.mjs +0 -8273
- package/lib/restart-helper.mjs +0 -133
- package/lib/security/log-sanitize.js +0 -50
- package/lib/security/path-validator.js +0 -195
- package/lib/security/rate-limiter.js +0 -93
- package/lib/session-strip.js +0 -100
- package/lib/sse-keepalive.js +0 -115
- package/lib/telegram/gateway.js +0 -643
- package/lib/telegram/index.js +0 -255
- package/lib/telegram/node.js +0 -410
- package/lib/tunnel-client.mjs +0 -537
- package/lib/wechat/gateway.js +0 -1000
- package/lib/wechat/index.js +0 -282
- package/lib/wechat/media.js +0 -302
- package/lib/wechat/node.js +0 -360
- package/llms.txt +0 -36
package/lib/feishu/markdown.js
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
// 飞书 Markdown 发送前的归一化(post 的 `md` 元素 / 卡片的 markdown 元素共用同一套解析规则)
|
|
2
|
-
//
|
|
3
|
-
// 官方依据:「发送消息内容结构」文档(docs/dev/lark-sdk/official-message-content.md)
|
|
4
|
-
// - `md` 标签支持 CommonMark 0.31 + GFM,**包括表格**;
|
|
5
|
-
// - 但明确要求:**表格前后必须使用 `\n\n` 与其他块级元素分隔**;
|
|
6
|
-
// "如果只使用单个 `\n`,后续内容可能被解析为表格的续行";
|
|
7
|
-
// - 同样要求:**引用块后面如需接其他块级元素,必须使用 `\n\n` 分隔**。
|
|
8
|
-
//
|
|
9
|
-
// 实测:本插件的 `/help`(`### 标题\n| 指令 | …`)正是"标题后紧跟表格、只有一个 \n"的写法,
|
|
10
|
-
// 结果表格整块不显示、只剩标题(issue 反馈截图实证)。此处统一补齐空行,避免各调用点各修一遍。
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* 归一化飞书 Markdown:补齐官方要求的块级元素空行分隔。
|
|
14
|
-
* - 表格:前后都要空行(否则表格会被解析异常,实测会整块丢失)
|
|
15
|
-
* - 引用块:后面接其他块级元素时空行分隔
|
|
16
|
-
* - 幂等:已有空行时不重复插入
|
|
17
|
-
* - 跳过围栏代码块内的内容(代码里的 `|` / `>` 不算块级元素)
|
|
18
|
-
*
|
|
19
|
-
* @param {string} text
|
|
20
|
-
* @returns {string}
|
|
21
|
-
*/
|
|
22
|
-
export function normalizeFeishuMarkdown(text) {
|
|
23
|
-
const lines = String(text ?? '').split('\n')
|
|
24
|
-
const out = []
|
|
25
|
-
let inFence = false
|
|
26
|
-
let prevWasTable = false
|
|
27
|
-
let prevWasQuote = false
|
|
28
|
-
|
|
29
|
-
for (const line of lines) {
|
|
30
|
-
const isFence = /^\s*(```|~~~)/.test(line)
|
|
31
|
-
const isTable = !inFence && /^\s{0,3}\|/.test(line)
|
|
32
|
-
const isQuote = !inFence && /^\s{0,3}>/.test(line)
|
|
33
|
-
|
|
34
|
-
if (isTable && !prevWasTable) {
|
|
35
|
-
// 表格开始:与上一个块级元素之间必须有空行
|
|
36
|
-
const last = out[out.length - 1]
|
|
37
|
-
if (last !== undefined && last.trim() !== '') out.push('')
|
|
38
|
-
} else if (!isTable && prevWasTable && line.trim() !== '') {
|
|
39
|
-
// 表格结束:与后续块级元素之间同样要有空行
|
|
40
|
-
out.push('')
|
|
41
|
-
} else if (!isQuote && prevWasQuote && line.trim() !== '') {
|
|
42
|
-
// 引用块结束:后面接其他块级元素必须有空行
|
|
43
|
-
out.push('')
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
out.push(line)
|
|
47
|
-
if (isFence) inFence = !inFence
|
|
48
|
-
prevWasTable = isTable
|
|
49
|
-
prevWasQuote = isQuote
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return out.join('\n')
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* 内容里是否含 Markdown 表格(跳过围栏代码块)。
|
|
57
|
-
* 用于选择渲染器:表格走交互卡片(卡片渲染器对表格兼容性更好,见下方注释),其余走 post 富文本。
|
|
58
|
-
*/
|
|
59
|
-
export function hasMarkdownTable(text) {
|
|
60
|
-
let inFence = false
|
|
61
|
-
for (const line of String(text ?? '').split('\n')) {
|
|
62
|
-
if (/^\s*(```|~~~)/.test(line)) { inFence = !inFence; continue }
|
|
63
|
-
if (!inFence && /^\s{0,3}\|/.test(line)) return true
|
|
64
|
-
}
|
|
65
|
-
return false
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* 按"单条消息上限"把 Markdown 切成多张卡片的内容片。
|
|
70
|
-
*
|
|
71
|
-
* 与 SDK 的 post 分片(`splitWithCodeFences`)目标一致,但额外保证:
|
|
72
|
-
* - **表格跨片时自动补表头**(表头 + 分隔行),否则续片会被渲染成普通文本;
|
|
73
|
-
* - 围栏代码块跨片时自动补 ```(与 SDK 行为一致,代码块不被截断语义);
|
|
74
|
-
* - 单行超长时不切在行中间(宁可略超上限,也不破坏结构)。
|
|
75
|
-
*
|
|
76
|
-
* @param {string} text
|
|
77
|
-
* @param {number} [limit] 单张卡片的字符上限
|
|
78
|
-
* @returns {string[]}
|
|
79
|
-
*/
|
|
80
|
-
export function splitMarkdownForCards(text, limit = 2000) {
|
|
81
|
-
const source = String(text ?? '')
|
|
82
|
-
if (source.length <= limit) return [source]
|
|
83
|
-
|
|
84
|
-
const lines = source.split('\n')
|
|
85
|
-
const chunks = []
|
|
86
|
-
let buf = []
|
|
87
|
-
let size = 0
|
|
88
|
-
let inFence = false
|
|
89
|
-
let fenceLang = ''
|
|
90
|
-
let tableHeader = null
|
|
91
|
-
let lastWasRow = false
|
|
92
|
-
|
|
93
|
-
const append = (line) => {
|
|
94
|
-
size += line.length + (buf.length > 0 ? 1 : 0)
|
|
95
|
-
buf.push(line)
|
|
96
|
-
}
|
|
97
|
-
const flush = () => {
|
|
98
|
-
if (buf.length === 0) return
|
|
99
|
-
chunks.push(buf.join('\n') + (inFence ? '\n```' : ''))
|
|
100
|
-
buf = []
|
|
101
|
-
size = 0
|
|
102
|
-
if (inFence) append('```' + fenceLang)
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
for (let i = 0; i < lines.length; i++) {
|
|
106
|
-
const line = lines[i]
|
|
107
|
-
const isFence = /^\s*(```|~~~)/.test(line)
|
|
108
|
-
const isRow = !inFence && /^\s{0,3}\|/.test(line)
|
|
109
|
-
|
|
110
|
-
if (isRow && !lastWasRow) {
|
|
111
|
-
// 表格起始:本行 + 下一行(分隔行)记为表头
|
|
112
|
-
const next = lines[i + 1] ?? ''
|
|
113
|
-
tableHeader = /^\s{0,3}\|[\s:|-]+\|?\s*$/.test(next) && next.includes('-') ? [line, next] : null
|
|
114
|
-
}
|
|
115
|
-
if (!isRow && !isFence && line.trim() !== '') tableHeader = null
|
|
116
|
-
|
|
117
|
-
if (buf.length === 0 && isRow && lastWasRow && tableHeader) {
|
|
118
|
-
append(tableHeader[0])
|
|
119
|
-
append(tableHeader[1])
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
if (size + line.length + (buf.length > 0 ? 1 : 0) > limit && buf.length > 0) {
|
|
123
|
-
flush()
|
|
124
|
-
if (isRow && tableHeader) {
|
|
125
|
-
append(tableHeader[0])
|
|
126
|
-
append(tableHeader[1])
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
append(line)
|
|
131
|
-
if (isFence) {
|
|
132
|
-
inFence = !inFence
|
|
133
|
-
if (inFence) fenceLang = line.replace(/^\s*(```|~~~)/, '')
|
|
134
|
-
}
|
|
135
|
-
lastWasRow = isRow
|
|
136
|
-
}
|
|
137
|
-
flush()
|
|
138
|
-
return chunks
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
/** 构造"Markdown 单元素"交互卡片(与重构前的卡片结构一致) */
|
|
142
|
-
export function buildMarkdownCard(markdownText) {
|
|
143
|
-
return {
|
|
144
|
-
schema: '2.0',
|
|
145
|
-
config: { wide_screen_mode: true, update_multi: true },
|
|
146
|
-
body: { elements: [{ tag: 'markdown', content: String(markdownText ?? '') }] },
|
|
147
|
-
}
|
|
148
|
-
}
|