@maiyunnet/kebab 9.29.6 → 10.1.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.
Files changed (61) hide show
  1. package/abox/proxy.js +24 -2
  2. package/abox/response.js +36 -17
  3. package/abox/session-login.js +1 -13
  4. package/doc/kebab-rag.md +1687 -1061
  5. package/index.d.ts +14 -2
  6. package/index.js +1 -1
  7. package/lib/ai.d.ts +4 -0
  8. package/lib/ai.js +32 -16
  9. package/lib/cookie.d.ts +2 -0
  10. package/lib/cookie.js +47 -45
  11. package/lib/core.d.ts +26 -0
  12. package/lib/core.js +36 -13
  13. package/lib/cron.js +1 -8
  14. package/lib/crypto.js +20 -6
  15. package/lib/db/conn.d.ts +4 -2
  16. package/lib/db/conn.js +1 -0
  17. package/lib/db/pool.d.ts +17 -4
  18. package/lib/db/pool.js +41 -23
  19. package/lib/db/tran.d.ts +6 -4
  20. package/lib/db.d.ts +10 -5
  21. package/lib/db.js +36 -6
  22. package/lib/fs.js +78 -31
  23. package/lib/kv.d.ts +182 -79
  24. package/lib/kv.js +518 -214
  25. package/lib/s3.d.ts +2 -0
  26. package/lib/s3.js +14 -27
  27. package/lib/session.d.ts +7 -0
  28. package/lib/session.js +23 -2
  29. package/lib/socket.d.ts +4 -1
  30. package/lib/socket.js +1 -0
  31. package/lib/sql.d.ts +0 -5
  32. package/lib/sql.js +48 -12
  33. package/lib/text.d.ts +10 -5
  34. package/lib/text.js +22 -12
  35. package/lib/turnstile.d.ts +6 -0
  36. package/lib/turnstile.js +16 -9
  37. package/lib/undici/response.d.ts +1 -1
  38. package/lib/undici.d.ts +7 -1
  39. package/lib/undici.js +72 -36
  40. package/lib/ws.d.ts +1 -1
  41. package/lib/ws.js +85 -128
  42. package/lib/zip.js +46 -45
  43. package/package.json +2 -2
  44. package/sys/child.js +178 -146
  45. package/sys/cmd.js +196 -210
  46. package/sys/ctr.d.ts +16 -16
  47. package/sys/ctr.js +147 -61
  48. package/sys/master.js +111 -80
  49. package/sys/mod.d.ts +24 -2
  50. package/sys/mod.js +56 -26
  51. package/sys/monitor/files.d.ts +2 -1
  52. package/sys/monitor/files.js +77 -21
  53. package/sys/monitor/watchdog.d.ts +7 -0
  54. package/sys/monitor/watchdog.js +311 -203
  55. package/sys/monitor.d.ts +59 -54
  56. package/sys/monitor.js +742 -681
  57. package/sys/route.d.ts +4 -4
  58. package/sys/route.js +93 -52
  59. package/www/example/ctr/test.d.ts +1 -1
  60. package/www/example/ctr/test.js +34 -15
  61. package/www/example/mod/test.js +0 -1
package/sys/route.d.ts CHANGED
@@ -67,13 +67,13 @@ export interface IFormDataError {
67
67
  /** --- multipart 文件处理及失败通知 --- */
68
68
  export interface IFormDataEvents {
69
69
  /** --- 文件开始上传时触发,返回 true 则跳过该文件的保存 --- */
70
- onfilestart?: (name: string) => boolean | undefined;
70
+ 'onfilestart'?: (name: string) => boolean | undefined;
71
71
  /** --- 文件上传时触发,仅 start 返回 true 时触发 --- */
72
- onfiledata?: (chunk: Buffer) => void;
72
+ 'onfiledata'?: (chunk: Buffer) => void;
73
73
  /** --- 文件上传结束时触发,仅 start 返回 true 时触发 --- */
74
- onfileend?: () => void;
74
+ 'onfileend'?: () => void;
75
75
  /** --- 首次失败时调用一次,getFormData 返回 false;若连接已断开,可能无法回复客户端 --- */
76
- onerror?: (error: IFormDataError) => void;
76
+ 'onerror'?: (error: IFormDataError) => void;
77
77
  }
78
78
  /** --- multipart 上传限制 --- */
79
79
  export interface IFormDataLimits {
package/sys/route.js CHANGED
@@ -3,7 +3,9 @@
3
3
  * Date: 2019-4-15 13:40
4
4
  * Last: 2020-4-14 13:52:00, 2022-09-07 01:43:31, 2023-12-29 17:24:03, 2024-2-7 00:28:50, 2024-6-6 15:15:54, 2025-6-13 19:23:53, 2025-9-22 15:48:53, 2025-9-23 11:26:50, 2025-10-30 17:44:41, 2026-8-22
5
5
  */
6
+ // --- 系统 ---
6
7
  import * as http from 'http';
8
+ import * as nodePath from 'path';
7
9
  import * as stream from 'stream';
8
10
  // --- 库和定义 ---
9
11
  import * as lFs from '#kebab/lib/fs.js';
@@ -64,6 +66,34 @@ function setInputValue(target, key, value) {
64
66
  'writable': true,
65
67
  });
66
68
  }
69
+ /**
70
+ * --- 校验并解析控制器模块路径,防止目录穿越、特殊 URL 字符及访问保留 middle 控制器 ---
71
+ * @param baseDir ctr/ 或 ws/ 绝对目录
72
+ * @param relName 控制器相对路径(不含 .js)
73
+ * @param blockMiddle 是否禁止 middle 控制器
74
+ * @returns 位于基目录内的绝对 .js 路径;不合法返回 null
75
+ */
76
+ function resolveCtrFile(baseDir, relName, blockMiddle) {
77
+ if (!relName || /[\0\\?#%]/.test(relName) || nodePath.isAbsolute(relName)) {
78
+ return null;
79
+ }
80
+ const segs = relName.split('/');
81
+ for (const seg of segs) {
82
+ if (!seg || seg === '.' || seg === '..') {
83
+ return null;
84
+ }
85
+ if (blockMiddle && seg.toLowerCase() === 'middle') {
86
+ return null;
87
+ }
88
+ }
89
+ const base = nodePath.resolve(baseDir);
90
+ const target = nodePath.resolve(base, `${relName}.js`);
91
+ const diff = nodePath.relative(base, target);
92
+ if (!diff || diff === '..' || diff.startsWith(`..${nodePath.sep}`) || nodePath.isAbsolute(diff)) {
93
+ return null;
94
+ }
95
+ return target;
96
+ }
67
97
  /**
68
98
  * --- 输出 404 错误响应 ---
69
99
  * @param res 响应对象
@@ -203,9 +233,10 @@ export async function run(data) {
203
233
  // --- 检测是否托管语言页面 ---
204
234
  const param = [];
205
235
  if (config.lang && data.res && !stcPaths.test(path)) {
206
- // --- 仅仅 res 模式支持 config.lang ---
207
- if (path[2] !== '/') {
208
- // --- 不管是首页还是 @ 页,都会到此处(已经有语言目录不会到这里) ---
236
+ // --- 仅仅 res 模式支持 config.lang;仅当首段在白名单语种中才视为已带语言前缀 ---
237
+ const langPrefix = path.slice(0, 2);
238
+ if (path[2] !== '/' || !config.lang.list.includes(langPrefix)) {
239
+ // --- 不管是首页还是 @ 页,都会到此处(已经有合法语言目录不会到这里) ---
209
240
  if (config.lang.direct.every(item => !path.startsWith(item))) {
210
241
  // --- 不放行 ---
211
242
  /** --- 浏览器语种 --- */
@@ -299,10 +330,10 @@ export async function run(data) {
299
330
  let rtn;
300
331
  if (data.socket && (data.req instanceof http.IncomingMessage)) {
301
332
  // --- socket 模式 ---
302
- // --- 判断真实控制器文件是否存在 ---
303
- let filePath = config.const.wsPath + pathLeft + '.js';
304
- if (!await lFs.isFile(filePath)) {
305
- // --- 指定的控制器不存在 ---
333
+ // --- 判断真实控制器文件是否存在(校验路径在 wsPath 内) ---
334
+ let filePath = resolveCtrFile(config.const.wsPath, pathLeft, false);
335
+ if (!filePath || !await lFs.isFile(filePath)) {
336
+ // --- 指定的控制器不存在,回退默认 handler.js ---
306
337
  filePath = config.const.wsPath + 'handler.js';
307
338
  if (!await lFs.isFile(filePath)) {
308
339
  // --- 默认 handler 也不存在 ---
@@ -354,19 +385,29 @@ export async function run(data) {
354
385
  wsSocket.on('message', async function (msg) {
355
386
  switch (msg.opcode) {
356
387
  case lWs.EOpcode.CLOSE: {
357
- const r = await cctr['onMessage'](msg.data, msg.opcode);
358
- if (r === false) {
359
- break;
388
+ try {
389
+ const r = await cctr['onMessage'](msg.data, msg.opcode);
390
+ if (r === false) {
391
+ break;
392
+ }
393
+ }
394
+ catch (e) {
395
+ lCore.log(cctr, lText.stringifyError(e), '-error');
360
396
  }
361
397
  wsSocket.end();
362
398
  break;
363
399
  }
364
400
  case lWs.EOpcode.PING: {
365
- const r = await cctr['onMessage'](msg.data, msg.opcode);
366
- if (r === false) {
367
- break;
401
+ try {
402
+ const r = await cctr['onMessage'](msg.data, msg.opcode);
403
+ if (r === false) {
404
+ break;
405
+ }
406
+ wsSocket.pong();
407
+ }
408
+ catch (e) {
409
+ lCore.log(cctr, lText.stringifyError(e), '-error');
368
410
  }
369
- wsSocket.pong();
370
411
  break;
371
412
  }
372
413
  case lWs.EOpcode.BINARY:
@@ -462,6 +503,7 @@ export async function run(data) {
462
503
  middle.setPrototype('_action', pathRight);
463
504
  middle.setPrototype('_headers', headers);
464
505
  middle.setPrototype('_get', get);
506
+ middle.setPrototype('_cookie', cookies);
465
507
  /** --- 是否让框架自动获取 post,1 为自动(默认) --- */
466
508
  const reqStartRtn = await middle.onReqStart();
467
509
  if (reqStartRtn === -1) {
@@ -511,9 +553,9 @@ export async function run(data) {
511
553
  cacheTTL = middle.getPrototype('_cacheTTL');
512
554
  httpCode = middle.getPrototype('_httpCode');
513
555
  if (rtn === undefined || rtn === true) {
514
- // --- 判断真实控制器文件是否存在 ---
515
- const filePath = config.const.ctrPath + pathLeft + '.js';
516
- if (!await lFs.isFile(filePath)) {
556
+ // --- 判断真实控制器文件是否存在(校验路径在 ctrPath 内且禁止 middle) ---
557
+ const filePath = resolveCtrFile(config.const.ctrPath, pathLeft, true);
558
+ if (!filePath || !await lFs.isFile(filePath)) {
517
559
  // --- 指定的控制器不存在 ---
518
560
  respond404(data.res, config);
519
561
  return true;
@@ -541,9 +583,10 @@ export async function run(data) {
541
583
  cctr.setPrototype('_cacheTTL', middle.getPrototype('_cacheTTL'));
542
584
  cctr.setPrototype('_xsrf', middle.getPrototype('_xsrf'));
543
585
  cctr.setPrototype('_httpCode', middle.getPrototype('_httpCode'));
544
- // --- 强制 HTTPS ---
586
+ // --- 强制 HTTPS(构造规范化 https 目标地址,防止死循环与 // 开放重定向) ---
545
587
  if (config.set.mustHttps && !config.const.https) {
546
- data.res.setHeader('location', data.req.url ?? '');
588
+ const safePath = `${config.const.urlBase}${config.const.path.replace(/^\/+/, '')}${config.const.qss}`;
589
+ data.res.setHeader('location', `https://${config.const.hostname}${safePath}`);
547
590
  lCore.writeHead(data.res, 302);
548
591
  data.res.end('');
549
592
  return true;
@@ -1057,11 +1100,7 @@ export function getFormData(req, events = {}, limits = {}) {
1057
1100
  let readEnd = false;
1058
1101
  /** --- 本次上传是否已经失败,失败后返回 false --- */
1059
1102
  let rejected = false;
1060
- /**
1061
- * --- 拒绝本次上传,继续读取请求以便正常返回错误响应 ---
1062
- * @param error 首次失败原因及对应限制
1063
- * @returns 无返回值
1064
- */
1103
+ // --- 拒绝本次上传,继续消费请求流以便正常返回错误响应 ---
1065
1104
  function reject(error) {
1066
1105
  if (rejected) {
1067
1106
  return;
@@ -1081,11 +1120,7 @@ export function getFormData(req, events = {}, limits = {}) {
1081
1120
  const fileStreams = new Map();
1082
1121
  /** --- 已安排删除的文件,避免给同一个文件重复添加 close 回调 --- */
1083
1122
  const discardedFiles = new Set();
1084
- /**
1085
- * --- 等文件流关闭后再删临时文件,避免文件还没创建就先删 ---
1086
- * @param filePath 本次上传创建的临时文件路径
1087
- * @returns 无返回值
1088
- */
1123
+ // --- 等文件流关闭后再删除临时文件 ---
1089
1124
  function discardFile(filePath) {
1090
1125
  if (discardedFiles.has(filePath)) {
1091
1126
  return;
@@ -1175,14 +1210,20 @@ export function getFormData(req, events = {}, limits = {}) {
1175
1210
  switch (state) {
1176
1211
  case EState.WAIT: {
1177
1212
  /** --- 中断符位置 --- */
1213
+ const maxHeader = limits.maxHeaderSize ?? 16 * 1024;
1178
1214
  const io = buffer.indexOf('\r\n\r\n');
1179
1215
  if (io === -1) {
1180
- if (buffer.length > (limits.maxHeaderSize ?? 16 * 1024)) {
1181
- reject({ 'code': 'HEADER_TOO_LARGE', 'limit': limits.maxHeaderSize ?? 16 * 1024 });
1216
+ if (buffer.length > maxHeader) {
1217
+ reject({ 'code': 'HEADER_TOO_LARGE', 'limit': maxHeader });
1182
1218
  buffer = Buffer.from('');
1183
1219
  }
1184
1220
  return;
1185
1221
  }
1222
+ if (io > maxHeader) {
1223
+ reject({ 'code': 'HEADER_TOO_LARGE', 'limit': maxHeader });
1224
+ buffer = Buffer.from('');
1225
+ return;
1226
+ }
1186
1227
  // --- 头部已经读取完毕 ---
1187
1228
  ++partCount;
1188
1229
  if (partCount > (limits.maxParts ?? 1000)) {
@@ -1212,17 +1253,24 @@ export function getFormData(req, events = {}, limits = {}) {
1212
1253
  ftmpName = '';
1213
1254
  break;
1214
1255
  }
1215
- // --- 检查文件扩展名限制 ---
1256
+ // --- 拒绝含空字符的畸形文件名 ---
1257
+ if (fileName.includes('\0')) {
1258
+ reject({ 'code': 'FILE_TYPE' });
1259
+ ftmpName = '';
1260
+ break;
1261
+ }
1262
+ // --- 检查文件扩展名限制(忽略配置大小写) ---
1216
1263
  if (limits.allowedExts?.length) {
1217
1264
  const extIo = fileName.lastIndexOf('.');
1218
1265
  const ext = extIo !== -1 ? fileName.slice(extIo).toLowerCase() : '';
1219
- if (!limits.allowedExts.includes(ext)) {
1266
+ if (!limits.allowedExts.some(item => item.toLowerCase() === ext)) {
1220
1267
  // --- 扩展名不允许,拒绝整体上传 ---
1221
1268
  reject({ 'code': 'FILE_TYPE' });
1222
1269
  ftmpName = '';
1223
1270
  break;
1224
1271
  }
1225
1272
  }
1273
+ ftmpSize = 0;
1226
1274
  const fr = events.onfilestart?.(name);
1227
1275
  if (fr !== true) {
1228
1276
  // --- 创建文件流 ---
@@ -1256,7 +1304,6 @@ export function getFormData(req, events = {}, limits = {}) {
1256
1304
  finalize();
1257
1305
  }
1258
1306
  });
1259
- ftmpSize = 0;
1260
1307
  }
1261
1308
  else {
1262
1309
  ftmpName = '';
@@ -1266,10 +1313,10 @@ export function getFormData(req, events = {}, limits = {}) {
1266
1313
  }
1267
1314
  case EState.POST: {
1268
1315
  // --- POST 模式 ---
1316
+ const maxField = limits.maxFieldSize ?? 1_048_576;
1269
1317
  const io = buffer.indexOf('\r\n--' + boundary);
1270
1318
  if (io === -1) {
1271
1319
  // --- 检查字段大小限制,防止畸形数据导致 buffer 无限增长 ---
1272
- const maxField = limits.maxFieldSize ?? 1_048_576;
1273
1320
  if (buffer.length > maxField + boundary.length + 4) {
1274
1321
  reject({ 'code': 'FIELD_TOO_LARGE', 'limit': maxField });
1275
1322
  buffer = Buffer.from('');
@@ -1277,6 +1324,11 @@ export function getFormData(req, events = {}, limits = {}) {
1277
1324
  }
1278
1325
  return;
1279
1326
  }
1327
+ if (io > maxField) {
1328
+ reject({ 'code': 'FIELD_TOO_LARGE', 'limit': maxField });
1329
+ buffer = Buffer.from('');
1330
+ return;
1331
+ }
1280
1332
  // --- 找到结束标语,写入 POST ---
1281
1333
  const val = buffer.subarray(0, io).toString();
1282
1334
  if (Object.hasOwn(rtn.post, name)) {
@@ -1432,23 +1484,12 @@ export function getFormData(req, events = {}, limits = {}) {
1432
1484
  finalize();
1433
1485
  return;
1434
1486
  }
1435
- if (state === EState.FILE) {
1436
- if (ftmpName) {
1437
- ftmpStream.end((error) => {
1438
- if (error) {
1439
- return;
1440
- }
1441
- --writeFileLength;
1442
- if (!writeFileLength) {
1443
- // --- 文件也写完了 ---
1444
- finalize();
1445
- }
1446
- });
1447
- return;
1448
- }
1449
- // --- 跳过该文件 ---
1450
- events.onfileend?.();
1451
- --writeFileLength;
1487
+ // --- 未收到结束 boundary 即结束流,视为截断上传,清理临时文件并拒绝 ---
1488
+ if (state !== EState.WAIT) {
1489
+ reject({ 'code': 'REQUEST_ABORTED' });
1490
+ cleanupActiveFile();
1491
+ finalize();
1492
+ return;
1452
1493
  }
1453
1494
  if (writeFileLength) {
1454
1495
  // --- 文件没写完 ---
@@ -72,7 +72,7 @@ export default class extends sCtr.Ctr {
72
72
  /**
73
73
  * --- 数据库读写分离测试 ---
74
74
  */
75
- dbRead(): string;
75
+ dbRead(): Promise<string>;
76
76
  private _dbTable;
77
77
  vector(): Promise<any>;
78
78
  kv(): Promise<kebab.Json>;
@@ -197,7 +197,7 @@ export default class extends sCtr.Ctr {
197
197
  `<br><br><a href="${this._config.const.urlBase}test/crypto">View "test/crypto"</a>`,
198
198
  '<br><br><b>Db:</b>',
199
199
  `<br><br><a href="${this._config.const.urlBase}test/db">View "test/db"</a> <a href="${this._config.const.urlBase}test/db?s=pgsql">pgsql</a>`,
200
- `<br><a href="${this._config.const.urlBase}test/db-read">View "test/db-read"</a>`,
200
+ `<br><a href="${this._config.const.urlBase}test/db-read">View "test/db-read"</a> <a href="${this._config.const.urlBase}test/db-read?s=pgsql">pgsql</a>`,
201
201
  `<br><br><b>Vector:</b>`,
202
202
  `<br><br><a href="${this._config.const.urlBase}test/vector">View "test/vector"</a>`,
203
203
  '<br><br><b>Kv:</b>',
@@ -1916,16 +1916,35 @@ exec: ${JSON.stringify(exec)}<br><br>`);
1916
1916
  /**
1917
1917
  * --- 数据库读写分离测试 ---
1918
1918
  */
1919
- dbRead() {
1919
+ async dbRead() {
1920
1920
  const echo = [];
1921
- echo.push('<b>DB Read Separation Test</b><hr>');
1922
- echo.push('<pre>const db = lDb.get(this);\nconst dbRead = lDb.get(this, { \'read\': true });</pre>');
1921
+ const isPgsql = this._get['s'] === 'pgsql';
1922
+ const service = isPgsql ? 'PGSQL' : 'MYSQL';
1923
+ const db = lDb.get(this, {
1924
+ 'service': isPgsql ? lDb.ESERVICE.PGSQL : lDb.ESERVICE.MYSQL,
1925
+ });
1926
+ const sql = isPgsql ?
1927
+ 'SELECT * FROM "m"."test" ORDER BY "id" DESC LIMIT 10;' :
1928
+ 'SELECT * FROM `m_test` ORDER BY `id` DESC LIMIT 10;';
1923
1929
  const config = this._config;
1924
- const service = config.db.default;
1930
+ const readCfg = config.db[service]?.read;
1931
+ const readHosts = (Array.isArray(readCfg) ? readCfg : (readCfg ? [readCfg] : []))
1932
+ .map(item => item.host)
1933
+ .filter((host) => Boolean(host));
1934
+ echo.push('<b>DB Read Separation Test</b><hr>');
1935
+ echo.push(`<pre>const db = lDb.get(this, { 'service': lDb.ESERVICE.${service} });
1936
+ const stmt = await db.query('${sql}', [], { 'read': true });</pre>`);
1925
1937
  echo.push(`Service: ${service}`);
1926
1938
  echo.push(`<br>Default host: ${config.db[service]?.default?.host ?? '(not configured)'}`);
1927
- echo.push(`<br>Read host: ${config.db[service]?.read?.host ?? '(not configured, will fallback to default)'}`);
1928
- return echo.join('') + '<br><br>' + this._getEnd();
1939
+ echo.push(`<br>Read host: ${readHosts.length ? readHosts.join(', ') : '(not configured, will fallback to default)'}<br><br>`);
1940
+ const stmt = await db.query(sql, [], { 'read': true });
1941
+ if (stmt.rows) {
1942
+ this._dbTable(stmt, echo);
1943
+ }
1944
+ else {
1945
+ echo.push(`Query error: ${lText.htmlescape(stmt.error ? `${stmt.error.message} (${stmt.error.errno})` : 'Failed')}<br>`);
1946
+ }
1947
+ return echo.join('') + `<br>queries: ${db.getQueries()}<br><br>` + this._getEnd();
1929
1948
  }
1930
1949
  _dbTable(stmt, echo) {
1931
1950
  echo.push('<table style="width: 100%;"><tr>');
@@ -2059,28 +2078,28 @@ echo.push('Added.');</pre>`);
2059
2078
  echo.push('Added.');
2060
2079
  echo.push("<pre>JSON.stringify(await kv.keys('t*'));</pre>" + JSON.stringify(await kv.keys('t*')));
2061
2080
  echo.push('<pre>JSON.stringify(await kv.scan());</pre>' + JSON.stringify(await kv.scan()));
2062
- echo.push(`<pre>let cursor = 0;
2081
+ echo.push(`<pre>let cursor = '0';
2063
2082
  while (true) {
2064
2083
  echo.push('WHILE (' + JSON.stringify(cursor) + ')&lt;br&gt;');
2065
2084
  const r = await kv.scan(cursor, '*2*', 5);
2066
- if (r === false || r.nextCursor === 0) {
2085
+ if (r === false || r.cursor === '0') {
2067
2086
  echo.push('DONE&lt;br&gt;');
2068
2087
  break;
2069
2088
  }
2070
2089
  echo.push(JSON.stringify(r.items) + '&lt;br&gt;');
2071
- cursor = r.nextCursor;
2090
+ cursor = r.cursor;
2072
2091
  }
2073
2092
  echo[echo.length - 1] = echo[echo.length - 1].slice(0, -4);</pre>`);
2074
- let cursor = 0;
2093
+ let cursor = '0';
2075
2094
  while (true) {
2076
2095
  echo.push('WHILE (' + JSON.stringify(cursor) + ')<br>');
2077
2096
  const r = await kv.scan(cursor, '*2*', 5);
2078
- if (r === false || r.nextCursor === 0) {
2097
+ if (r === false || r.cursor === '0') {
2079
2098
  echo.push('DONE<br>');
2080
2099
  break;
2081
2100
  }
2082
2101
  echo.push(JSON.stringify(r.items) + '<br>');
2083
- cursor = r.nextCursor;
2102
+ cursor = r.cursor;
2084
2103
  }
2085
2104
  echo[echo.length - 1] = echo[echo.length - 1].slice(0, -4);
2086
2105
  }
@@ -4434,7 +4453,7 @@ rtn.push(reader.readBCDString());</pre>${JSON.stringify(rtn)}`);
4434
4453
  }
4435
4454
  default: {
4436
4455
  // --- CHAT ---
4437
- let model = ai.service === lAi.ESERVICE.ALICN ? 'qwen-plus' : 'doubao-seed-2-0-mini-260215';
4456
+ let model = ai.service === lAi.ESERVICE.ALICN ? 'qwen3.7-flash' : 'doubao-seed-2-0-mini-260215';
4438
4457
  if (ai.service === lAi.ESERVICE.AZURE) {
4439
4458
  model = 'gpt-4.1-nano';
4440
4459
  }
@@ -4446,7 +4465,7 @@ rtn.push(reader.readBCDString());</pre>${JSON.stringify(rtn)}`);
4446
4465
  ],
4447
4466
  });
4448
4467
  echo.push(`<pre>await ai.chat({
4449
- 'model': ${model},
4468
+ 'model': '${model}',
4450
4469
  'messages': [
4451
4470
  { 'role': 'system', 'content': 'You are Kebab, a friendly and knowledgeable assistant based on an open-source Node framework. You do not mention any model names or AI identity. You can chat casually, answer questions, and provide guidance naturally. Respond in a human-like, approachable manner, as if you are a helpful companion rather than a traditional AI assistant.' },
4452
4471
  { 'role': 'user', 'content': '你是谁?' },
@@ -42,7 +42,6 @@ export default class default_1 extends sMod {
42
42
  static _$primary = 'id';
43
43
  static _$key = 'token';
44
44
  static _$index = 'token';
45
- /* eslint-enable */
46
45
  _keyGenerator() {
47
46
  return 'test_' + lCore.rand(0, 3).toString();
48
47
  }