@maiyunnet/kebab 9.29.6 → 10.0.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.
- package/abox/proxy.js +24 -2
- package/abox/response.js +36 -17
- package/abox/session-login.js +1 -13
- package/doc/kebab-rag.md +1522 -1034
- package/index.d.ts +12 -1
- package/index.js +1 -1
- package/lib/ai.d.ts +4 -0
- package/lib/ai.js +32 -16
- package/lib/cookie.d.ts +2 -0
- package/lib/cookie.js +47 -45
- package/lib/core.d.ts +26 -0
- package/lib/core.js +36 -13
- package/lib/cron.js +1 -8
- package/lib/crypto.js +20 -6
- package/lib/db/conn.js +1 -0
- package/lib/fs.js +78 -31
- package/lib/kv.d.ts +182 -79
- package/lib/kv.js +518 -214
- package/lib/s3.d.ts +2 -0
- package/lib/s3.js +14 -27
- package/lib/session.d.ts +7 -0
- package/lib/session.js +23 -2
- package/lib/socket.d.ts +4 -1
- package/lib/socket.js +1 -0
- package/lib/sql.d.ts +0 -5
- package/lib/sql.js +48 -12
- package/lib/text.d.ts +10 -5
- package/lib/text.js +22 -12
- package/lib/turnstile.d.ts +6 -0
- package/lib/turnstile.js +16 -9
- package/lib/undici.d.ts +7 -1
- package/lib/undici.js +72 -36
- package/lib/ws.d.ts +1 -1
- package/lib/ws.js +85 -128
- package/lib/zip.js +46 -45
- package/package.json +2 -2
- package/sys/child.js +178 -146
- package/sys/cmd.js +196 -197
- package/sys/ctr.d.ts +14 -14
- package/sys/ctr.js +145 -59
- package/sys/master.js +111 -80
- package/sys/mod.d.ts +8 -2
- package/sys/mod.js +23 -11
- package/sys/monitor/files.d.ts +2 -1
- package/sys/monitor/files.js +77 -21
- package/sys/monitor/watchdog.d.ts +7 -0
- package/sys/monitor/watchdog.js +311 -203
- package/sys/monitor.d.ts +59 -54
- package/sys/monitor.js +742 -681
- package/sys/route.d.ts +4 -4
- package/sys/route.js +93 -52
- package/www/example/ctr/test.js +8 -8
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
|
-
|
|
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
|
|
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
|
-
|
|
358
|
-
|
|
359
|
-
|
|
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
|
-
|
|
366
|
-
|
|
367
|
-
|
|
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
|
|
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
|
-
|
|
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 >
|
|
1181
|
-
reject({ 'code': 'HEADER_TOO_LARGE', 'limit':
|
|
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.
|
|
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
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
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
|
// --- 文件没写完 ---
|
package/www/example/ctr/test.js
CHANGED
|
@@ -2059,28 +2059,28 @@ echo.push('Added.');</pre>`);
|
|
|
2059
2059
|
echo.push('Added.');
|
|
2060
2060
|
echo.push("<pre>JSON.stringify(await kv.keys('t*'));</pre>" + JSON.stringify(await kv.keys('t*')));
|
|
2061
2061
|
echo.push('<pre>JSON.stringify(await kv.scan());</pre>' + JSON.stringify(await kv.scan()));
|
|
2062
|
-
echo.push(`<pre>let cursor = 0;
|
|
2062
|
+
echo.push(`<pre>let cursor = '0';
|
|
2063
2063
|
while (true) {
|
|
2064
2064
|
echo.push('WHILE (' + JSON.stringify(cursor) + ')<br>');
|
|
2065
2065
|
const r = await kv.scan(cursor, '*2*', 5);
|
|
2066
|
-
if (r === false || r.
|
|
2066
|
+
if (r === false || r.cursor === '0') {
|
|
2067
2067
|
echo.push('DONE<br>');
|
|
2068
2068
|
break;
|
|
2069
2069
|
}
|
|
2070
2070
|
echo.push(JSON.stringify(r.items) + '<br>');
|
|
2071
|
-
cursor = r.
|
|
2071
|
+
cursor = r.cursor;
|
|
2072
2072
|
}
|
|
2073
2073
|
echo[echo.length - 1] = echo[echo.length - 1].slice(0, -4);</pre>`);
|
|
2074
|
-
let cursor = 0;
|
|
2074
|
+
let cursor = '0';
|
|
2075
2075
|
while (true) {
|
|
2076
2076
|
echo.push('WHILE (' + JSON.stringify(cursor) + ')<br>');
|
|
2077
2077
|
const r = await kv.scan(cursor, '*2*', 5);
|
|
2078
|
-
if (r === false || r.
|
|
2078
|
+
if (r === false || r.cursor === '0') {
|
|
2079
2079
|
echo.push('DONE<br>');
|
|
2080
2080
|
break;
|
|
2081
2081
|
}
|
|
2082
2082
|
echo.push(JSON.stringify(r.items) + '<br>');
|
|
2083
|
-
cursor = r.
|
|
2083
|
+
cursor = r.cursor;
|
|
2084
2084
|
}
|
|
2085
2085
|
echo[echo.length - 1] = echo[echo.length - 1].slice(0, -4);
|
|
2086
2086
|
}
|
|
@@ -4434,7 +4434,7 @@ rtn.push(reader.readBCDString());</pre>${JSON.stringify(rtn)}`);
|
|
|
4434
4434
|
}
|
|
4435
4435
|
default: {
|
|
4436
4436
|
// --- CHAT ---
|
|
4437
|
-
let model = ai.service === lAi.ESERVICE.ALICN ? '
|
|
4437
|
+
let model = ai.service === lAi.ESERVICE.ALICN ? 'qwen3.7-flash' : 'doubao-seed-2-0-mini-260215';
|
|
4438
4438
|
if (ai.service === lAi.ESERVICE.AZURE) {
|
|
4439
4439
|
model = 'gpt-4.1-nano';
|
|
4440
4440
|
}
|
|
@@ -4446,7 +4446,7 @@ rtn.push(reader.readBCDString());</pre>${JSON.stringify(rtn)}`);
|
|
|
4446
4446
|
],
|
|
4447
4447
|
});
|
|
4448
4448
|
echo.push(`<pre>await ai.chat({
|
|
4449
|
-
'model': ${model},
|
|
4449
|
+
'model': '${model}',
|
|
4450
4450
|
'messages': [
|
|
4451
4451
|
{ '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
4452
|
{ 'role': 'user', 'content': '你是谁?' },
|