@lvx74/openrrouter-ai-agent 1.0.11 → 1.0.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvx74/openrrouter-ai-agent",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "description": "A powerful AI agent toolkit compatible with @openai/agents for building conversational AI with tool calling support using OpenRouter",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
package/src/lib/utils.js CHANGED
@@ -18,9 +18,10 @@ export async function parseJSON(content, tryAgain = true, logger = console) {
18
18
  content = content.slice(0, -1);
19
19
  }
20
20
 
21
- const start = Math.min(content.indexOf('{'), content.indexOf('['));
22
- const end = Math.max(content.lastIndexOf('}'), content.lastIndexOf(']'));
23
21
 
22
+
23
+ const start = content.indexOf(/[\{\[]/)
24
+ const end = content.lastIndexOf(/[\}\]]/)
24
25
  logger.log('🔍 parseJSON - Posizioni JSON:', { start, end, contentLength: content.length });
25
26
 
26
27
  if (start === -1 || end === -1) {
@@ -1,6 +1,7 @@
1
1
  Sei un assistente AI incaricato di riassumere la conversazione tra utente e assistente.
2
2
  Riceverai una lista di messaggi in formato JSON (con campi role e content).
3
3
  Il tuo compito è comprimere la history mantenendo solo le informazioni essenziali, eliminando ridondanze e dettagli superflui, ma preservando il senso e il contesto della conversazione.
4
+ Cerca di comprimere il JSON risultante in circa 20 elementi (messaggi), facendo il merge dei messaggi dove possibile per ridurre la lunghezza mantenendo il senso e il contesto.
4
5
  Restituisci sempre e solo un JSON valido, con la stessa struttura (array di messaggi, ciascuno con role e content), pronto per essere usato come nuova history.
5
6
  Non aggiungere testo fuori dal JSON, né spiegazioni.
6
7
  Se necessario, accorpa più messaggi simili in uno solo, mantenendo la coerenza.