symposium 1.2.5 → 1.2.7

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/Agent.js CHANGED
@@ -252,6 +252,14 @@ export default class Agent {
252
252
 
253
253
  try {
254
254
  thread = await this.afterExecute(thread, completion, emitter);
255
+
256
+ for (let message of completion) {
257
+ if (message.role === 'assistant' && message.content.some(c => c.type === 'reasoning')) {
258
+ const reasoning = message.content.find(c => c.type === 'reasoning').content;
259
+ emitter.emit('reasoning', reasoning);
260
+ }
261
+ }
262
+
255
263
  const response = await this.handleCompletion(thread, completion, emitter);
256
264
 
257
265
  switch (this.type) {
@@ -470,20 +478,18 @@ export default class Agent {
470
478
  throw new Error('Unrecognized function ' + function_call.name);
471
479
 
472
480
  const func = functions.get(function_call.name);
473
- const partialOutput = func.partialOutput ? ((typeof func.partialOutput) === 'text' ? func.partialOutput : func.partialOutput.call(this, function_call.arguments)) : 'Uso lo strumento ' + function_call.name + '...';
474
- if (emitter)
475
- emitter.emit('partial', partialOutput);
476
-
477
481
  await this.log('function_call', function_call);
478
482
 
483
+ emitter.emit('tool', function_call);
484
+
479
485
  try {
480
486
  const response = await func.tool.callFunction(thread, function_call.name, function_call.arguments);
481
487
  if (emitter)
482
- emitter.emit('partial', 'Risposta ricevuta da ' + func.tool.name);
488
+ emitter.emit('tool_response', {name: func.tool.name, success: true, response});
483
489
  return response;
484
490
  } catch (error) {
485
491
  if (emitter)
486
- emitter.emit('partial', 'Ricevuto errore da ' + func.tool.name);
492
+ emitter.emit('tool_response', {name: func.tool.name, success: false, error: error.message || error});
487
493
  return {error};
488
494
  }
489
495
  }
package/README.md CHANGED
@@ -137,8 +137,15 @@ async function main() {
137
137
  console.error(`\nAn error occurred: ${error.message}`);
138
138
  });
139
139
 
140
- emitter.on('partial', (text) => {
141
- console.log(`\n> ${text}\n`);
140
+ emitter.on('tool', (tool) => {
141
+ console.log(`\n> Using tool: ${tool.name} with arguments ${JSON.stringify(tool.arguments)}\n`);
142
+ });
143
+
144
+ emitter.on('tool_response', (tool_response) => {
145
+ if (tool_response.success)
146
+ console.log(`\n> Tool ${tool_response.name} completed successfully with response: ${JSON.stringify(tool_response.response)}\n`);
147
+ else
148
+ console.log(`\n> Tool ${tool_response.name} failed with error: ${tool_response.error}\n`);
142
149
  });
143
150
  }
144
151
 
@@ -149,7 +156,9 @@ When you run this, the agent will respond to your message, and the response will
149
156
 
150
157
  - `start`: Emitted when the agent begins processing the message. The `thread` object is passed as an argument.
151
158
  - `output`: Emitted for each chunk of text in the response stream.
152
- - `partial`: Emitted to provide insight into the agent's internal state, like when it decides to use a tool.
159
+ - `reasoning`: Emitted when the agent generates reasoning steps (if applicable).
160
+ - `tool`: Emitted when the agent decides to use a tool. The tool name and arguments are provided.
161
+ - `tool_response`: Emitted when a tool call completes, with the response or error
153
162
  - `error`: Emitted if an error occurs during processing.
154
163
 
155
164
  ## Advanced Usage
@@ -78,7 +78,8 @@ export default class AnthropicModel extends Model {
78
78
  case 'thinking':
79
79
  message_content.push({
80
80
  type: 'reasoning',
81
- content: message.original,
81
+ content: m.thinking,
82
+ original: m,
82
83
  });
83
84
  break;
84
85
 
@@ -172,11 +173,7 @@ export default class AnthropicModel extends Model {
172
173
  break;
173
174
 
174
175
  case 'reasoning':
175
- content.push({
176
- type: 'thinking',
177
- content: c.thinking,
178
- original: c,
179
- });
176
+ content.push(c.original);
180
177
  break;
181
178
 
182
179
  default:
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "symposium",
4
- "version": "1.2.5",
4
+ "version": "1.2.7",
5
5
  "description": "Agents",
6
6
  "main": "index.js",
7
7
  "author": "Domenico Giambra",