@lvx74/openrrouter-ai-agent 1.0.5 → 1.0.8

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.5",
3
+ "version": "1.0.8",
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/Agent.js CHANGED
@@ -90,7 +90,11 @@ export class Agent extends EventEmitter {
90
90
  */
91
91
  async step() {
92
92
  const toolDefinitions = this.getToolDefinitions()
93
-
93
+ if (this.verbose) {
94
+ console.log('Esecuzione step con', this.messages.length, 'messaggi e', toolDefinitions.length, 'tools')
95
+ console.log('Ultimo messaggio:', this.getLastMessage())
96
+ console.log('Tools:', toolDefinitions.map(t => t.name).join(', '))
97
+ }
94
98
  const res = await this.openai.chat.completions.create({
95
99
  model: this.model,
96
100
  messages: this.messages,
package/src/Tool.js CHANGED
@@ -71,24 +71,25 @@ export class Tool {
71
71
  /**
72
72
  * Esegue il tool con gli argomenti forniti
73
73
  */
74
- async execute(args) {
74
+ async execute(args, session) {
75
75
  // Validazione con schema Zod se disponibile
76
76
  if (this.schema) {
77
77
  try {
78
78
  const validatedArgs = this.schema.parse(args)
79
- return await this.handler(validatedArgs)
79
+
80
+ return await this.handler(validatedArgs, session)
80
81
  } catch (error) {
81
82
  throw new Error(`Validation error: ${error.message}`)
82
83
  }
83
84
  }
84
85
 
85
- return await this.handler(args)
86
+ return await this.handler(args, session)
86
87
  }
87
88
 
88
89
  /**
89
90
  * Alias per compatibilità con @openai/agents
90
91
  */
91
- async run(args) {
92
- return await this.execute(args)
92
+ async run(args, session) {
93
+ return await this.execute(args, session)
93
94
  }
94
95
  }
package/src/cli.js CHANGED
@@ -18,14 +18,16 @@ export function createChatInterface(agent, options = {}) {
18
18
  historyFile = null
19
19
  } = options
20
20
 
21
- if (historyFile && !fs.existsSync(historyFile)) {
21
+ if (historyFile && fs.existsSync(historyFile)) {
22
22
  try {
23
- agent.setHistory(fs.readFileSync(historyFile, 'utf8'))
23
+ agent.setHistory(JSON.parse(fs.readFileSync(historyFile, 'utf8')))
24
24
  console.log(`\n📜 Cronologia caricata da ${historyFile}`)
25
25
  } catch (error) {
26
26
  console.error(`\n❌ Errore nel caricamento della cronologia: ${error.message}`)
27
27
  return
28
28
  }
29
+ }else if (historyFile) {
30
+ console.log(`\n📜 Cronologia non trovata, ne verrà creata una nuova in ${historyFile}`)
29
31
  }
30
32
 
31
33
  const rl = readline.createInterface({