@agentforge/testing 0.16.27 → 0.16.28

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/dist/index.d.cts CHANGED
@@ -3,7 +3,7 @@ import { BaseMessage } from '@langchain/core/messages';
3
3
  import { ChatResult } from '@langchain/core/outputs';
4
4
  import { CallbackManagerForLLMRun } from '@langchain/core/callbacks/manager';
5
5
  import * as _agentforge_core from '@agentforge/core';
6
- import { ToolCategory, Tool } from '@agentforge/core';
6
+ import { ToolCategory, Tool, Logger } from '@agentforge/core';
7
7
  import { z } from 'zod';
8
8
 
9
9
  /**
@@ -616,6 +616,10 @@ interface ConversationSimulatorConfig {
616
616
  * Whether to log conversation
617
617
  */
618
618
  verbose?: boolean;
619
+ /**
620
+ * Structured logger used for verbose conversation output
621
+ */
622
+ logger?: Logger;
619
623
  /**
620
624
  * Stop condition
621
625
  */
@@ -685,6 +689,7 @@ declare class ConversationSimulator<TState = unknown> {
685
689
  * Simulate a conversation with dynamic user input generation
686
690
  */
687
691
  simulateDynamic(inputGenerator: (messages: BaseMessage[]) => string | null, maxTurns?: number): Promise<ConversationResult>;
692
+ private logVerboseTurn;
688
693
  }
689
694
  /**
690
695
  * Create a conversation simulator
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@ import { BaseMessage } from '@langchain/core/messages';
3
3
  import { ChatResult } from '@langchain/core/outputs';
4
4
  import { CallbackManagerForLLMRun } from '@langchain/core/callbacks/manager';
5
5
  import * as _agentforge_core from '@agentforge/core';
6
- import { ToolCategory, Tool } from '@agentforge/core';
6
+ import { ToolCategory, Tool, Logger } from '@agentforge/core';
7
7
  import { z } from 'zod';
8
8
 
9
9
  /**
@@ -616,6 +616,10 @@ interface ConversationSimulatorConfig {
616
616
  * Whether to log conversation
617
617
  */
618
618
  verbose?: boolean;
619
+ /**
620
+ * Structured logger used for verbose conversation output
621
+ */
622
+ logger?: Logger;
619
623
  /**
620
624
  * Stop condition
621
625
  */
@@ -685,6 +689,7 @@ declare class ConversationSimulator<TState = unknown> {
685
689
  * Simulate a conversation with dynamic user input generation
686
690
  */
687
691
  simulateDynamic(inputGenerator: (messages: BaseMessage[]) => string | null, maxTurns?: number): Promise<ConversationResult>;
692
+ private logVerboseTurn;
688
693
  }
689
694
  /**
690
695
  * Create a conversation simulator
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { BaseChatModel } from '@langchain/core/language_models/chat_models';
2
2
  import { HumanMessage, AIMessage, SystemMessage, BaseMessage } from '@langchain/core/messages';
3
3
  import { z } from 'zod';
4
- import { toolBuilder, ToolCategory } from '@agentforge/core';
4
+ import { toolBuilder, ToolCategory, createLogger } from '@agentforge/core';
5
5
  import { isatty } from 'tty';
6
6
  import { isDeepStrictEqual } from 'util';
7
7
 
@@ -18663,6 +18663,9 @@ function extractMessages(state) {
18663
18663
  const { messages } = state;
18664
18664
  return Array.isArray(messages) ? messages : [];
18665
18665
  }
18666
+ var conversationSimulatorLogger = createLogger(
18667
+ "agentforge:testing:runners:conversation-simulator"
18668
+ );
18666
18669
  var ConversationSimulator = class {
18667
18670
  constructor(agent, config2 = {}) {
18668
18671
  this.agent = agent;
@@ -18687,15 +18690,11 @@ var ConversationSimulator = class {
18687
18690
  }
18688
18691
  const userMessage = new HumanMessage(input);
18689
18692
  messages.push(userMessage);
18690
- if (this.config.verbose) {
18691
- console.log(`User: ${input}`);
18692
- }
18693
+ this.logVerboseTurn("User", input);
18693
18694
  const result = await this.agent.invoke({ messages });
18694
18695
  const aiMessage = extractLatestMessage(result);
18695
18696
  messages.push(aiMessage);
18696
- if (this.config.verbose) {
18697
- console.log(`AI: ${aiMessage.content}`);
18698
- }
18697
+ this.logVerboseTurn("AI", aiMessage.content);
18699
18698
  turns++;
18700
18699
  if (this.config.stopCondition && this.config.stopCondition(messages)) {
18701
18700
  stopReason = "stop_condition";
@@ -18759,6 +18758,13 @@ var ConversationSimulator = class {
18759
18758
  error
18760
18759
  };
18761
18760
  }
18761
+ logVerboseTurn(role, content) {
18762
+ if (!this.config.verbose) {
18763
+ return;
18764
+ }
18765
+ const logger = this.config.logger ?? conversationSimulatorLogger;
18766
+ logger.info(`${role}: ${String(content)}`);
18767
+ }
18762
18768
  };
18763
18769
  function createConversationSimulator(agent, config2) {
18764
18770
  return new ConversationSimulator(agent, config2);