@dcrays/dcgchat-test 0.3.16 → 0.3.18
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/package.json +1 -1
- package/src/tool.ts +1 -1
- package/src/utils/searchFile.ts +18 -4
package/package.json
CHANGED
package/src/tool.ts
CHANGED
|
@@ -106,7 +106,7 @@ export function monitoringToolMessage(api: OpenClawPluginApi) {
|
|
|
106
106
|
} else if (item.event) {
|
|
107
107
|
const msgCtx = getEffectiveMsgParams(sk)
|
|
108
108
|
if (item.event === 'llm_output') {
|
|
109
|
-
if (event.lastAssistant?.errorMessage === '
|
|
109
|
+
if (event.lastAssistant?.errorMessage === '1003-额度不足请充值') {
|
|
110
110
|
const message = '您的积分已消耗完,您可以通过充值积分来继续使用'
|
|
111
111
|
sendText(message, msgCtx, { message_tags: { insufficient_balance: 1 }, is_finish: -1 })
|
|
112
112
|
sendFinal(msgCtx, '积分不足')
|
package/src/utils/searchFile.ts
CHANGED
|
@@ -94,11 +94,9 @@ function stripMobookNoise(s: string) {
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
/**
|
|
97
|
-
* 从文本中扫描
|
|
97
|
+
* 从文本中扫描 `.../mobook/...` 或 `...\mobook\...` 片段,按最长后缀匹配合法扩展名(兜底)
|
|
98
98
|
*/
|
|
99
|
-
function
|
|
100
|
-
const lower = text.toLowerCase()
|
|
101
|
-
const needle = '/mobook/'
|
|
99
|
+
function collectMobookPathsAfterNeedle(text: string, lower: string, needle: string, result: Set<string>): void {
|
|
102
100
|
let from = 0
|
|
103
101
|
while (from < text.length) {
|
|
104
102
|
const i = lower.indexOf(needle, from)
|
|
@@ -136,8 +134,16 @@ function collectMobookPathsByScan(text: string, result: Set<string>): void {
|
|
|
136
134
|
}
|
|
137
135
|
}
|
|
138
136
|
|
|
137
|
+
function collectMobookPathsByScan(text: string, result: Set<string>): void {
|
|
138
|
+
const lower = text.toLowerCase()
|
|
139
|
+
collectMobookPathsAfterNeedle(text, lower, '/mobook/', result)
|
|
140
|
+
collectMobookPathsAfterNeedle(text, lower, '\\mobook\\', result)
|
|
141
|
+
}
|
|
142
|
+
|
|
139
143
|
export function extractMobookFiles(text = '') {
|
|
140
144
|
if (typeof text !== 'string' || !text.trim()) return []
|
|
145
|
+
// 全角冒号(中文输入常见)→ 半角,便于匹配 c:\mobook\
|
|
146
|
+
text = text.replace(/\uFF1A/g, ':')
|
|
141
147
|
const result = new Set<string>()
|
|
142
148
|
// ✅ 扩展名(必须长扩展名优先,见 EXT_SORTED_FOR_REGEX)
|
|
143
149
|
const EXT = `(${EXT_SORTED_FOR_REGEX.join('|')})`
|
|
@@ -157,6 +163,14 @@ export function extractMobookFiles(text = '') {
|
|
|
157
163
|
;(text.match(fullPathReg) || []).forEach((p) => {
|
|
158
164
|
result.add(normalizePath(p))
|
|
159
165
|
})
|
|
166
|
+
// 2️⃣b Windows 实际保存路径:C:\mobook\xxx、c:/mobook/xxx、\mobook\xxx(模型常写反斜杠,原先无法识别)
|
|
167
|
+
const winMobookReg = new RegExp(`(?:[a-zA-Z]:)?[/\\\\]mobook[/\\\\]${FILE_NAME}\\.${EXT}`, 'gi')
|
|
168
|
+
;(text.match(winMobookReg) || []).forEach((full) => {
|
|
169
|
+
const name = full.replace(/^(?:[a-zA-Z]:)?[/\\\\]mobook[/\\\\]/i, '').trim()
|
|
170
|
+
if (isValidFileName(name)) {
|
|
171
|
+
result.add(normalizePath(`/mobook/${name}`))
|
|
172
|
+
}
|
|
173
|
+
})
|
|
160
174
|
// 3️⃣ mobook下的 xxx.xxx
|
|
161
175
|
const inlineReg = new RegExp(`mobook下的\\s*(${FILE_NAME}\\.${EXT})`, 'gi')
|
|
162
176
|
;(text.match(inlineReg) || []).forEach((item) => {
|