cortico-world-fish-sing 0.4.6 → 0.4.8

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 CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  格式参考 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/);版本号遵循语义化。
4
4
 
5
+ ## [0.4.8] - 2026-11-02
6
+
7
+ ### 修复
8
+ - **「停止训练」点了没停住,面板却显示已停止**:取消请求发出后不再无条件宣布成功——现在会轮询 worker 的 `/current` 实测 12 秒,真停了才说"已停止",没停住会明确告诉你("worker 还有任务在跑,可能是重启前留下的孤儿")并写 warn 日志。面板也会把这句话显示出来。
9
+ - `worker.cancel()` 的返回值(HTTP 状态 / worker 的答复 / 网络错误)全部带出来并记日志,不再静默吞掉。
10
+
11
+ ## [0.4.7] - 2026-11-02
12
+
13
+ ### 新增
14
+ - **「测试通知」按钮**:训练页工具栏点一下立刻发一条测试通知,看它落在哪个渠道(QQ / 桌宠),不用等下一次训练结束才知道 QQ 通不通。
15
+
16
+ ### 修复
17
+ - 文本通知的 OneBot 超时从 120 秒收紧到 **15 秒**:SnowLuma 端口开着但不响应时,不会再让「训练完成」等两分钟才退桌宠(发语音条仍是 120 秒,mp3→SILK 转换本来就慢)。
18
+
5
19
  ## [0.4.6] - 2026-11-02
6
20
 
7
21
  ### 修复
@@ -722,7 +722,9 @@ function mountTrain(ctx) {
722
722
  const pathIn = el('input', 'fs-tpath');
723
723
  pathIn.placeholder = '粘贴素材文件夹或单个文件路径,可多个用 ; 分隔';
724
724
  const scanBtn = el('button', 'fs-btn', '扫描');
725
- bar.append(pathIn, scanBtn);
725
+ const notifyTest = el('button', 'fs-btn', '测试通知');
726
+ notifyTest.title = '立刻发一条测试通知:QQ 通就发 QQ,不通就退桌宠——点了就知道渠道状态';
727
+ bar.append(pathIn, scanBtn, notifyTest);
726
728
 
727
729
  const dsBar = el('div', 'fs-bar');
728
730
  const dsSel = el('select', 'fs-btn');
@@ -1459,7 +1461,9 @@ function mountTrain(ctx) {
1459
1461
  stopT.addEventListener('click', async () => {
1460
1462
  stopT.disabled = true;
1461
1463
  try {
1462
- await call('trainStop', []);
1464
+ const r = await call('trainStop', []);
1465
+ // 把 world 的实话显示出来:真停了 / 没停住 都要看得见
1466
+ if (r && r.text) say(r.text, !/^已停止/.test(String(r.text)));
1463
1467
  } catch {
1464
1468
  /* 已显示 */
1465
1469
  }
@@ -1512,6 +1516,20 @@ function mountTrain(ctx) {
1512
1516
  appendLabel.textContent = appendChk.checked ? '追加到当前数据集' : '新建数据集';
1513
1517
  });
1514
1518
 
1519
+ notifyTest.addEventListener('click', async () => {
1520
+ notifyTest.disabled = true;
1521
+ notifyTest.textContent = '发送中…';
1522
+ try {
1523
+ const r = await ctx.invoke('trainNotifyTest');
1524
+ say((r && r.note) ? `通知:${r.note}${r.via ? `(${r.via})` : ''}` : '通知已发');
1525
+ } catch (e) {
1526
+ say(`测试通知失败:${(e && e.message) || e}`, true);
1527
+ } finally {
1528
+ notifyTest.disabled = false;
1529
+ notifyTest.textContent = '测试通知';
1530
+ }
1531
+ });
1532
+
1515
1533
  scanBtn.addEventListener('click', async () => {
1516
1534
  const raw = String(pathIn.value || '').trim();
1517
1535
  if (!raw) {
package/dist/webui.js CHANGED
@@ -722,7 +722,9 @@ function mountTrain(ctx) {
722
722
  const pathIn = el('input', 'fs-tpath');
723
723
  pathIn.placeholder = '粘贴素材文件夹或单个文件路径,可多个用 ; 分隔';
724
724
  const scanBtn = el('button', 'fs-btn', '扫描');
725
- bar.append(pathIn, scanBtn);
725
+ const notifyTest = el('button', 'fs-btn', '测试通知');
726
+ notifyTest.title = '立刻发一条测试通知:QQ 通就发 QQ,不通就退桌宠——点了就知道渠道状态';
727
+ bar.append(pathIn, scanBtn, notifyTest);
726
728
 
727
729
  const dsBar = el('div', 'fs-bar');
728
730
  const dsSel = el('select', 'fs-btn');
@@ -1459,7 +1461,9 @@ function mountTrain(ctx) {
1459
1461
  stopT.addEventListener('click', async () => {
1460
1462
  stopT.disabled = true;
1461
1463
  try {
1462
- await call('trainStop', []);
1464
+ const r = await call('trainStop', []);
1465
+ // 把 world 的实话显示出来:真停了 / 没停住 都要看得见
1466
+ if (r && r.text) say(r.text, !/^已停止/.test(String(r.text)));
1463
1467
  } catch {
1464
1468
  /* 已显示 */
1465
1469
  }
@@ -1512,6 +1516,20 @@ function mountTrain(ctx) {
1512
1516
  appendLabel.textContent = appendChk.checked ? '追加到当前数据集' : '新建数据集';
1513
1517
  });
1514
1518
 
1519
+ notifyTest.addEventListener('click', async () => {
1520
+ notifyTest.disabled = true;
1521
+ notifyTest.textContent = '发送中…';
1522
+ try {
1523
+ const r = await ctx.invoke('trainNotifyTest');
1524
+ say((r && r.note) ? `通知:${r.note}${r.via ? `(${r.via})` : ''}` : '通知已发');
1525
+ } catch (e) {
1526
+ say(`测试通知失败:${(e && e.message) || e}`, true);
1527
+ } finally {
1528
+ notifyTest.disabled = false;
1529
+ notifyTest.textContent = '测试通知';
1530
+ }
1531
+ });
1532
+
1515
1533
  scanBtn.addEventListener('click', async () => {
1516
1534
  const raw = String(pathIn.value || '').trim();
1517
1535
  if (!raw) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cortico-world-fish-sing",
3
- "version": "0.4.6",
3
+ "version": "0.4.8",
4
4
  "description": "让她真的开口唱:B 站点歌或本地文件 → 分离 → 换声 → 混音,本机出声或发 QQ 语音条",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -36,7 +36,7 @@
36
36
  "local"
37
37
  ],
38
38
  "describe": "describe.json",
39
- "webUiClient": "dist/webui-4d01e72b.js"
39
+ "webUiClient": "dist/webui-efe43ccf.js"
40
40
  },
41
41
  "scripts": {
42
42
  "doctor": "node tools/doctor.mjs"
package/src/deliver.ts CHANGED
@@ -99,7 +99,12 @@ export function parseTarget(to: string): OneBotTarget | null {
99
99
  : { action: 'send_private_msg', params: { user_id: id }, label: `私聊 ${id}` };
100
100
  }
101
101
 
102
- async function callOneBot(opts: OneBotOptions, action: string, params: Record<string, unknown>): Promise<void> {
102
+ async function callOneBot(
103
+ opts: OneBotOptions,
104
+ action: string,
105
+ params: Record<string, unknown>,
106
+ timeoutMs = 120_000,
107
+ ): Promise<void> {
103
108
  const res = await fetch(`${opts.httpUrl.replace(/\/+$/, '')}/${action}`, {
104
109
  method: 'POST',
105
110
  headers: {
@@ -107,7 +112,7 @@ async function callOneBot(opts: OneBotOptions, action: string, params: Record<st
107
112
  ...(opts.token ? { authorization: `Bearer ${opts.token}` } : {}),
108
113
  },
109
114
  body: JSON.stringify(params),
110
- signal: AbortSignal.timeout(120_000),
115
+ signal: AbortSignal.timeout(timeoutMs),
111
116
  });
112
117
  const body = (await res.json().catch(() => ({}))) as Record<string, unknown>;
113
118
  if (!res.ok) throw new Error(`OneBot HTTP ${res.status}`);
@@ -126,8 +131,12 @@ export async function sendRecord(opts: OneBotOptions, target: OneBotTarget, file
126
131
  }
127
132
 
128
133
  export async function sendText(opts: OneBotOptions, target: OneBotTarget, text: string): Promise<void> {
129
- await callOneBot(opts, target.action, {
130
- ...target.params,
131
- message: [{ type: 'text', data: { text } }],
132
- });
134
+ // 文本通知给短超时:SnowLuma 端口开着但不响应时,别让"训练完成"等两分钟才退桌宠。
135
+ // 语音条(sendRecord)仍用 120 秒——大文件 + mp3→SILK 转换本来就慢。
136
+ await callOneBot(
137
+ opts,
138
+ target.action,
139
+ { ...target.params, message: [{ type: 'text', data: { text } }] },
140
+ 15_000,
141
+ );
133
142
  }
package/src/worker.ts CHANGED
@@ -313,16 +313,28 @@ export class WorkerClient {
313
313
  }
314
314
  }
315
315
 
316
- async cancel(): Promise<void> {
316
+ async cancel(): Promise<{ ok: boolean; message: string }> {
317
+ // 返回值要带出去:以前这里吞掉一切,面板点「停止训练」失败也显示"已停止",
318
+ // 结果训练继续跑(0.4.7 那次真实事故),排查时完全看不到线索。
317
319
  try {
318
- await fetch(`${this.baseUrl}/stop`, {
320
+ const res = await fetch(`${this.baseUrl}/stop`, {
319
321
  method: 'POST',
320
322
  headers: this.authHeaders(),
321
323
  body: '{}',
322
324
  signal: AbortSignal.timeout(5000),
323
325
  });
324
- } catch {
325
- /* 没在跑就算了 */
326
+ const body = (await res.json().catch(() => ({}))) as { ok?: boolean; message?: string };
327
+ const message = String(body.message ?? `HTTP ${res.status}`);
328
+ if (!res.ok || body.ok === false) {
329
+ this.log.warn(`取消请求没被接受:HTTP ${res.status} ${message}`);
330
+ return { ok: false, message };
331
+ }
332
+ this.log.info(`取消请求已送达:${message}`);
333
+ return { ok: true, message };
334
+ } catch (e) {
335
+ const message = e instanceof Error ? e.message : String(e);
336
+ this.log.warn(`取消请求发不出去(worker 没响应):${message}`);
337
+ return { ok: false, message: `连不上 worker:${message}` };
326
338
  }
327
339
  }
328
340
 
package/src/world.ts CHANGED
@@ -1171,15 +1171,40 @@ export class FishSingWorld implements World {
1171
1171
  return { text: text || `没生成:${exp} 只找到一个可用存档(中间档可能已被清理)` };
1172
1172
  }
1173
1173
 
1174
+ if (method === 'trainNotifyTest') {
1175
+ // 「QQ 通不通」不用等下一次训练结束才知道:手动发一条,看落在哪个渠道。
1176
+ const out = (await this.notifyEvent(
1177
+ '测试通知(唱歌插件)',
1178
+ '这是一条测试消息:收到就说明通知渠道通了。',
1179
+ )) as { via?: string; note?: string };
1180
+ return { via: out?.via ?? '', note: out?.note ?? '' };
1181
+ }
1182
+
1174
1183
  if (method === 'trainStop') {
1175
- await this.worker.cancel();
1184
+ const cres = await this.worker.cancel();
1185
+ // 送达 ≠ 停住:取消请求成功,也可能因为训练是"重启前留下的孤儿"而落空
1186
+ // (worker 当前任务为 null,它只会回"当前没有任务")。所以实测 worker 还在不在跑。
1187
+ let left: { kind?: string } | null = null;
1188
+ for (let i = 0; i < 5; i += 1) {
1189
+ await new Promise((r) => setTimeout(r, 2500));
1190
+ left = await this.worker.currentJob().catch(() => null);
1191
+ if (!left) break;
1192
+ }
1193
+ if (left) {
1194
+ this.host?.log.warn(
1195
+ `[fish-sing] 停止训练:取消请求已发(${cres.message}),但 worker 还有任务在跑(${left.kind ?? '?'})`,
1196
+ );
1197
+ return {
1198
+ text: `取消请求发出去了(${cres.message}),但 worker 那边还有任务在跑——这个训练可能是重启前启动的、worker 管不到它。重启 Coo 后再试。`,
1199
+ };
1200
+ }
1176
1201
  if (this.trainJob?.state === 'running') {
1177
1202
  // 立刻落状态:子进程可能还在收尾,面板会一直显示"训练中",用户以为没停
1178
1203
  this.trainJob.state = 'error';
1179
1204
  this.trainJob.error = '已手动停止';
1180
1205
  this.trainJob.msg = '已手动停止';
1181
1206
  }
1182
- return { text: '已停止训练。最近的存档还在 logs 里,可以勾「从上次存档继续」接着练。' };
1207
+ return { text: `已停止训练(${cres.message})。最近的存档还在 logs 里,可以勾「从上次存档继续」接着练。` };
1183
1208
  }
1184
1209
 
1185
1210
  if (method === 'cancel') {