@lvx74/openrrouter-ai-agent 1.0.0 → 1.0.2

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/Agent.js +5 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvx74/openrrouter-ai-agent",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
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
@@ -29,6 +29,7 @@ export class Agent extends EventEmitter {
29
29
  this.model = options.model || 'qwen/qwen3-coder:free'
30
30
  this.systemPrompt = (options.instructions || options.systemPrompt || '') + `\n\nALWAYS CALL ONLY 1 tool at a time.\n`
31
31
  this.tools = options.tools || []
32
+ this.session = options.session || null // Aggiunto per supportare sessioni
32
33
  }
33
34
 
34
35
  this.messages = options.messages || []
@@ -47,7 +48,7 @@ export class Agent extends EventEmitter {
47
48
  // Configurazioni aggiuntive
48
49
  this.maxIterations = options.maxIterations || 10
49
50
  this.temperature = options.temperature || 0.7
50
- this.debug = options.debug || true
51
+ this.debug = options.debug !== undefined ? options.debug : true
51
52
  this.verbose = options.verbose !== undefined ? options.verbose : true // Default attivo per mostrare thoughts
52
53
  }
53
54
 
@@ -179,7 +180,7 @@ export class Agent extends EventEmitter {
179
180
 
180
181
  console.log(`⚡ Eseguendo tool: ${name}...`)
181
182
  const startTime = Date.now()
182
- const result = await tool.execute(args)
183
+ const result = await tool.execute(args, this.session)
183
184
 
184
185
  if (this.verbose) {
185
186
  console.log(`📋 Observation (Osservazione da ${name}):`)
@@ -188,14 +189,14 @@ export class Agent extends EventEmitter {
188
189
  toolCall.done = true;
189
190
  toolCall.result = result;
190
191
  toolCall.execution_time = Date.now() - startTime;
191
-
192
+
192
193
  const toolMessage = {
193
194
  role: 'tool',
194
195
  tool_call_id: toolCall.id,
195
196
  tool_calls: msg.tool_calls,
196
197
  name,
197
198
  content: typeof result === 'string' ? result : JSON.stringify(result)
198
-
199
+
199
200
  }
200
201
  this.messages.push(toolMessage)
201
202