utilitas 2000.3.49 → 2000.3.53

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/lib/alan.mjs CHANGED
@@ -45,7 +45,7 @@ const _NEED = ['js-tiktoken', 'OpenAI', '@google/genai'];
45
45
  const [
46
46
  OPENAI, GOOGLE, OLLAMA, NOVA, DEEPSEEK_32, MD_CODE, CLOUD_OPUS_45, AUDIO,
47
47
  WAV, OPENAI_VOICE, GPT_REASONING_EFFORT, THINK, THINK_STR, THINK_END,
48
- TOOLS_STR, TOOLS_END, TOOLS, TEXT, OK, FUNC, GPT_51, GPT_51_CODEX,
48
+ TOOLS_STR, TOOLS_END, TOOLS, TEXT, OK, FUNC, GPT_52, GPT_51_CODEX,
49
49
  GPT_5_IMAGE, GEMMA_3_27B, ANTHROPIC, v8k, ais, MAX_TOOL_RECURSION, LOG,
50
50
  name, user, system, assistant, MODEL, JSON_OBJECT, tokenSafeRatio,
51
51
  PROMPT_IS_REQUIRED, OPENAI_HI_RES_SIZE, k, kT, m, minute, hour, gb,
@@ -59,7 +59,7 @@ const [
59
59
  'OpenAI', 'Google', 'Ollama', 'nova', 'deepseek-3.2-speciale', '```',
60
60
  'claude-opus-4.5', 'audio', 'wav', 'OPENAI_VOICE', 'medium', 'think',
61
61
  '<think>', '</think>', '<tools>', '</tools>', 'tools', 'text', 'OK',
62
- 'function', 'gpt-5.1', 'gpt-5.1-codex', 'gpt-5-image', 'gemma3:27b',
62
+ 'function', 'gpt-5.2', 'gpt-5.1-codex', 'gpt-5-image', 'gemma3:27b',
63
63
  'Anthropic', 7680 * 4320, [], 30, { log: true }, 'Alan', 'user',
64
64
  { role: 'system' }, 'assistant', 'model', 'json_object', 1.1,
65
65
  'Prompt is required.', 2048 * 2048, x => 1024 * x, x => 1000 * x,
@@ -137,7 +137,7 @@ const MODELS = {
137
137
  // https://gemini.google.com/app/c680748b3307790b
138
138
  },
139
139
  // strong and fast
140
- [GPT_51]: { ...OPENAI_RULES, fast: true },
140
+ [GPT_52]: { ...OPENAI_RULES, fast: true },
141
141
  // stronger but slow
142
142
  [GEMINI_30_PRO]: {
143
143
  ...GEMINI_RULES, contextWindow: m(1), maxOutputTokens: k(64),
@@ -229,7 +229,7 @@ for (const n in MODELS) {
229
229
  }
230
230
  // Auto model have some issues with tools and reasoning, so we disable them here
231
231
  // MODELS[AUTO] = { name: AUTO, defaultProvider: OPENROUTER, };
232
- // for (const n of [GPT_51, GPT_51_CODEX, GEMINI_30_PRO, GEMINI_25_FLASH]) {
232
+ // for (const n of [GPT_52, GPT_51_CODEX, GEMINI_30_PRO, GEMINI_25_FLASH]) {
233
233
  // // get the most restrictive limits
234
234
  // for (const key of [
235
235
  // 'contextWindow', 'maxInputTokens', 'maxDocumentFile', 'maxAudioLength',
@@ -1220,7 +1220,7 @@ const initChat = async (options = {}) => {
1220
1220
  'Invalid session storage provider.'
1221
1221
  );
1222
1222
  chatConfig.sessions = options.sessions;
1223
- }
1223
+ } else { log(`WARNING: Sessions persistence is not enabled.`); }
1224
1224
  options.instructions && (chatConfig.systemPrompt = options.instructions);
1225
1225
  // Use Gemini instead of ChatGPT because of the longer package.
1226
1226
  const [spTokens, ais] = await Promise.all([countTokens([await buildMessage(
@@ -1425,7 +1425,7 @@ export {
1425
1425
  GEMINI_25_PRO_TTS,
1426
1426
  GEMINI_30_PRO_IMAGE,
1427
1427
  GPT_5_IMAGE,
1428
- GPT_51,
1428
+ GPT_52,
1429
1429
  IMAGEN_4_ULTRA,
1430
1430
  INSTRUCTIONS,
1431
1431
  MODELS,
@@ -1446,6 +1446,7 @@ export {
1446
1446
  prompt,
1447
1447
  promptOpenRouter,
1448
1448
  resetSession,
1449
+ setSession,
1449
1450
  stt,
1450
1451
  talk,
1451
1452
  trimPrompt,
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": "2000.3.49",
4
+ "version": "2000.3.53",
5
5
  "private": false,
6
6
  "homepage": "https://github.com/Leask/utilitas",
7
7
  "main": "index.mjs",
package/lib/storage.mjs CHANGED
@@ -119,18 +119,20 @@ const assertPath = async (path, type, mode, msg, code, options) => {
119
119
  };
120
120
 
121
121
  const isTextFile = async (file, options) => {
122
- const isBuf = Buffer.isBuffer(file);
123
- let [f, bytes, res] = [isBuf ? file : await fs.open(file, 'r'), null, true];
124
- for (let i = 0; i < (~~options?.length || 1000); i++) {
125
- let buf = Buffer.alloc(1);
126
- if (isBuf) { buf[0] = f[i]; bytes = i < f.length ? 1 : 0; }
127
- else { bytes = readSync(f.fd, buf, 0, 1, i); }
128
- if (bytes === 0) { break; } else if (
129
- bytes === 1 && buf.toString().charCodeAt() === 0
130
- ) { res = false; break; }
122
+ const maxBytes = options?.length ?? 1000;
123
+ let buf;
124
+ if (Buffer.isBuffer(file)) {
125
+ buf = file.subarray(0, maxBytes);
126
+ } else {
127
+ const fd = await fs.promises.open(file, 'r');
128
+ buf = Buffer.alloc(maxBytes);
129
+ await fd.read(buf, 0, maxBytes, 0);
130
+ await fd.close();
131
+ }
132
+ for (let i = 0; i < buf.length; i++) {
133
+ if (buf[i] === 0) return false;
131
134
  }
132
- isBuf || f?.close()
133
- return res;
135
+ return true;
134
136
  };
135
137
 
136
138
  const getConfigFilename = async (options) => {
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": "2000.3.49",
4
+ "version": "2000.3.53",
5
5
  "private": false,
6
6
  "homepage": "https://github.com/Leask/utilitas",
7
7
  "main": "index.mjs",