utilitas 2001.1.149 → 2001.1.151
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/README.md +1 -1
- package/dist/utilitas.lite.mjs +1 -1
- package/dist/utilitas.lite.mjs.map +1 -1
- package/lib/alan.mjs +14 -6
- package/lib/bot.mjs +11 -2
- package/lib/manifest.mjs +2 -2
- package/package.json +2 -2
package/lib/alan.mjs
CHANGED
|
@@ -320,7 +320,7 @@ const tools = [
|
|
|
320
320
|
}
|
|
321
321
|
},
|
|
322
322
|
func: async args => (await distill(args?.url))?.summary,
|
|
323
|
-
showReq:
|
|
323
|
+
showReq: ['url'],
|
|
324
324
|
},
|
|
325
325
|
{
|
|
326
326
|
def: {
|
|
@@ -344,7 +344,7 @@ const tools = [
|
|
|
344
344
|
num: args?.num || 10, start: args?.start || 1,
|
|
345
345
|
image: args?.image || false
|
|
346
346
|
}),
|
|
347
|
-
showReq:
|
|
347
|
+
showReq: ['keyword'], depend: checkSearch,
|
|
348
348
|
},
|
|
349
349
|
];
|
|
350
350
|
|
|
@@ -812,10 +812,18 @@ const handleToolsCall = async (msg, options) => {
|
|
|
812
812
|
await resp(rt);
|
|
813
813
|
continue;
|
|
814
814
|
}
|
|
815
|
-
|
|
816
|
-
description
|
|
817
|
-
|
|
818
|
-
|
|
815
|
+
// Disable description for now, reduce noise
|
|
816
|
+
// const description = f.def?.function?.description || f.def?.description;
|
|
817
|
+
// description && await resp(`Description: ${description}`);
|
|
818
|
+
if (f.showReq && isSet(input, true) && Object.keys(input).length) {
|
|
819
|
+
if (Array.isArray(f.showReq)) {
|
|
820
|
+
for (const key of f.showReq) {
|
|
821
|
+
await resp(`${key}: ${JSON.stringify(input[key])}`);
|
|
822
|
+
};
|
|
823
|
+
} else {
|
|
824
|
+
await resp(`Input: ${JSON.stringify(input)}`);
|
|
825
|
+
}
|
|
826
|
+
}
|
|
819
827
|
try {
|
|
820
828
|
const output = JSON.stringify((await f?.func(input)) ?? OK);
|
|
821
829
|
content.push(packMsg(output));
|
package/lib/bot.mjs
CHANGED
|
@@ -3,7 +3,13 @@ import { isPrimary, on, report } from './callosum.mjs';
|
|
|
3
3
|
|
|
4
4
|
const _NEED = ['telegraf'];
|
|
5
5
|
const log = (cnt, opt) => _log(cnt, import.meta.url, { time: 1, ...opt || {} });
|
|
6
|
-
const
|
|
6
|
+
const isLaunchStopError = err => err?.name === 'AbortError'
|
|
7
|
+
|| `${err?.message || err}`.includes('Cannot set property message');
|
|
8
|
+
const end = async options => {
|
|
9
|
+
if (!bot) { return; }
|
|
10
|
+
bot.stop(options?.signal);
|
|
11
|
+
await launch;
|
|
12
|
+
};
|
|
7
13
|
const lines = (arr, sep = '\n') => arr.join(sep);
|
|
8
14
|
const sendMd = (cId, cnt, opt) => send(cId, cnt, { parse_mode, ...opt || {} });
|
|
9
15
|
|
|
@@ -18,6 +24,7 @@ const [ // https://limits.tginfo.me/en
|
|
|
18
24
|
const parse_mode = PARSE_MODE_MD;
|
|
19
25
|
|
|
20
26
|
let bot;
|
|
27
|
+
let launch;
|
|
21
28
|
|
|
22
29
|
const send = async (chatId, content, options) => {
|
|
23
30
|
try {
|
|
@@ -39,7 +46,9 @@ const init = async (options) => {
|
|
|
39
46
|
bot = new Telegraf(options?.botToken, { handlerTimeout: 1000 * 60 * 10 }); // 10 minutes
|
|
40
47
|
bot.use(useNewReplies());
|
|
41
48
|
bot.catch(console.error);
|
|
42
|
-
bot.launch()
|
|
49
|
+
launch = bot.launch().catch(err => {
|
|
50
|
+
if (!isLaunchStopError(err)) { console.error(err); }
|
|
51
|
+
});
|
|
43
52
|
bot.botInfo = await bot.telegram.getMe();
|
|
44
53
|
log(`Initialized: ${BOT}${bot.botInfo.first_name} @${bot.botInfo.username} #${bot.botInfo.id}`);
|
|
45
54
|
on(BOT_SEND, data => send(...data || []));
|
package/lib/manifest.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const manifest = {
|
|
2
2
|
"name": "utilitas",
|
|
3
3
|
"description": "Just another common utility for JavaScript.",
|
|
4
|
-
"version": "2001.1.
|
|
4
|
+
"version": "2001.1.151",
|
|
5
5
|
"private": false,
|
|
6
6
|
"homepage": "https://github.com/Leask/utilitas",
|
|
7
7
|
"main": "index.mjs",
|
|
@@ -59,7 +59,7 @@ const manifest = {
|
|
|
59
59
|
"process": "^0.11.10",
|
|
60
60
|
"puppeteer": "^24.42.0",
|
|
61
61
|
"say": "^0.16.0",
|
|
62
|
-
"telegraf": "
|
|
62
|
+
"telegraf": "npm:@leask/telegraf@6.0.0",
|
|
63
63
|
"telesignsdk": "^5.0.0",
|
|
64
64
|
"tesseract.js": "^7.0.0",
|
|
65
65
|
"twilio": "^6.0.0",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "utilitas",
|
|
3
3
|
"description": "Just another common utility for JavaScript.",
|
|
4
|
-
"version": "2001.1.
|
|
4
|
+
"version": "2001.1.151",
|
|
5
5
|
"private": false,
|
|
6
6
|
"homepage": "https://github.com/Leask/utilitas",
|
|
7
7
|
"main": "index.mjs",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"process": "^0.11.10",
|
|
71
71
|
"puppeteer": "^24.42.0",
|
|
72
72
|
"say": "^0.16.0",
|
|
73
|
-
"telegraf": "
|
|
73
|
+
"telegraf": "npm:@leask/telegraf@6.0.0",
|
|
74
74
|
"telesignsdk": "^5.0.0",
|
|
75
75
|
"tesseract.js": "^7.0.0",
|
|
76
76
|
"twilio": "^6.0.0",
|