agent-pulse 1.2.0 → 1.3.0

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/README.md CHANGED
@@ -154,7 +154,8 @@ The `response` event and the `agent.run()` promise resolve to a standardized `Ag
154
154
 
155
155
  ```typescript
156
156
  {
157
- content: string | object, // The Markdown text or parsed JSON
157
+ content: string | object, // The Markdown text, parsed JSON, or tool result (if iterations=1)
158
+ message?: string, // The original LLM text response (useful when a tool is also called)
158
159
  usage: {
159
160
  input_tokens: number,
160
161
  output_tokens: number,
@@ -167,6 +168,9 @@ The `response` event and the `agent.run()` promise resolve to a standardized `Ag
167
168
  }
168
169
  ```
169
170
 
171
+ > [!NOTE]
172
+ > If an LLM responds with both text and a tool call (common in Gemini), `content` stays consistent with legacy behavior (holding the tool result), while the new `message` field preserves the original LLM text.
173
+
170
174
  You can access token usage stats from the `usage` property.
171
175
 
172
176
  ## Error Codes
@@ -226,7 +230,18 @@ if (result.content?.type === 'INTENT_COMPLETE') {
226
230
  }
227
231
  ```
228
232
 
229
- #### Option B: Events (Side Effects)
233
+ #### Option B: Handling Text + Tool (Gemini Style)
234
+ When using models like Gemini that often provide a text explanation *and* a tool call in one turn, use the `message` field to access the text.
235
+
236
+ ```typescript
237
+ const result = await agent.run("Tell me a joke and then get the weather.");
238
+
239
+ // If weatherTool was called:
240
+ console.log(result.message); // "Sure! Here's a joke: ... Now, let me get the weather for you."
241
+ console.log(result.content); // { temp: 20, unit: 'celsius' } (The tool result)
242
+ ```
243
+
244
+ #### Option C: Events (Side Effects)
230
245
  Best for logging, UI updates, or real-time monitoring.
231
246
 
232
247
  ```typescript
package/dist/agent.js CHANGED
@@ -39,6 +39,10 @@ class Agent extends events_1.EventEmitter {
39
39
  iterations++;
40
40
  const response = await this.provider.generate(this.config.system, messages, this.config.files, this.config.tools, this.config.config, this.config.output_schema, (token) => this.emit('token', token));
41
41
  lastResponse = response;
42
+ // Capture the original text as the "message" (LLM's primary text response)
43
+ if (typeof response.content === 'string') {
44
+ lastResponse.message = response.content;
45
+ }
42
46
  // Handle Tool Execution
43
47
  if (response.tool_calls && this.config.tools) {
44
48
  // Add Assistant's tool call message to history
package/dist/types.d.ts CHANGED
@@ -29,6 +29,7 @@ export interface AgentTool {
29
29
  export interface AgentResponse {
30
30
  content: string | object;
31
31
  tool_calls?: any[];
32
+ message?: string;
32
33
  usage: {
33
34
  input_tokens: number;
34
35
  output_tokens: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-pulse",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "A lightweight, agentic AI framework for JavaScript/TypeScript",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",