@agentforge/testing 0.16.22 → 0.16.23
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 +17 -17
- package/dist/index.cjs +10 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -3
- package/dist/index.d.ts +6 -3
- package/dist/index.js +10 -2
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -650,6 +650,9 @@ interface ConversationResult {
|
|
|
650
650
|
*/
|
|
651
651
|
error?: Error;
|
|
652
652
|
}
|
|
653
|
+
interface ConversationSimulatorInput {
|
|
654
|
+
messages: BaseMessage[];
|
|
655
|
+
}
|
|
653
656
|
/**
|
|
654
657
|
* Conversation simulator for testing multi-turn interactions
|
|
655
658
|
*
|
|
@@ -670,10 +673,10 @@ interface ConversationResult {
|
|
|
670
673
|
* expect(result.completed).toBe(true);
|
|
671
674
|
* ```
|
|
672
675
|
*/
|
|
673
|
-
declare class ConversationSimulator {
|
|
676
|
+
declare class ConversationSimulator<TState = unknown> {
|
|
674
677
|
private agent;
|
|
675
678
|
private config;
|
|
676
|
-
constructor(agent:
|
|
679
|
+
constructor(agent: AgentTestAgent<ConversationSimulatorInput, TState>, config?: ConversationSimulatorConfig);
|
|
677
680
|
/**
|
|
678
681
|
* Simulate a conversation with predefined user inputs
|
|
679
682
|
*/
|
|
@@ -686,7 +689,7 @@ declare class ConversationSimulator {
|
|
|
686
689
|
/**
|
|
687
690
|
* Create a conversation simulator
|
|
688
691
|
*/
|
|
689
|
-
declare function createConversationSimulator(agent:
|
|
692
|
+
declare function createConversationSimulator<TState = unknown>(agent: AgentTestAgent<ConversationSimulatorInput, TState>, config?: ConversationSimulatorConfig): ConversationSimulator<TState>;
|
|
690
693
|
|
|
691
694
|
type SnapshotObject = Record<string, unknown>;
|
|
692
695
|
interface SnapshotDiff {
|
package/dist/index.d.ts
CHANGED
|
@@ -650,6 +650,9 @@ interface ConversationResult {
|
|
|
650
650
|
*/
|
|
651
651
|
error?: Error;
|
|
652
652
|
}
|
|
653
|
+
interface ConversationSimulatorInput {
|
|
654
|
+
messages: BaseMessage[];
|
|
655
|
+
}
|
|
653
656
|
/**
|
|
654
657
|
* Conversation simulator for testing multi-turn interactions
|
|
655
658
|
*
|
|
@@ -670,10 +673,10 @@ interface ConversationResult {
|
|
|
670
673
|
* expect(result.completed).toBe(true);
|
|
671
674
|
* ```
|
|
672
675
|
*/
|
|
673
|
-
declare class ConversationSimulator {
|
|
676
|
+
declare class ConversationSimulator<TState = unknown> {
|
|
674
677
|
private agent;
|
|
675
678
|
private config;
|
|
676
|
-
constructor(agent:
|
|
679
|
+
constructor(agent: AgentTestAgent<ConversationSimulatorInput, TState>, config?: ConversationSimulatorConfig);
|
|
677
680
|
/**
|
|
678
681
|
* Simulate a conversation with predefined user inputs
|
|
679
682
|
*/
|
|
@@ -686,7 +689,7 @@ declare class ConversationSimulator {
|
|
|
686
689
|
/**
|
|
687
690
|
* Create a conversation simulator
|
|
688
691
|
*/
|
|
689
|
-
declare function createConversationSimulator(agent:
|
|
692
|
+
declare function createConversationSimulator<TState = unknown>(agent: AgentTestAgent<ConversationSimulatorInput, TState>, config?: ConversationSimulatorConfig): ConversationSimulator<TState>;
|
|
690
693
|
|
|
691
694
|
type SnapshotObject = Record<string, unknown>;
|
|
692
695
|
interface SnapshotDiff {
|
package/dist/index.js
CHANGED
|
@@ -18691,7 +18691,7 @@ var ConversationSimulator = class {
|
|
|
18691
18691
|
console.log(`User: ${input}`);
|
|
18692
18692
|
}
|
|
18693
18693
|
const result = await this.agent.invoke({ messages });
|
|
18694
|
-
const aiMessage = result
|
|
18694
|
+
const aiMessage = extractLatestMessage(result);
|
|
18695
18695
|
messages.push(aiMessage);
|
|
18696
18696
|
if (this.config.verbose) {
|
|
18697
18697
|
console.log(`AI: ${aiMessage.content}`);
|
|
@@ -18740,7 +18740,7 @@ var ConversationSimulator = class {
|
|
|
18740
18740
|
const userMessage = new HumanMessage(input);
|
|
18741
18741
|
messages.push(userMessage);
|
|
18742
18742
|
const result = await this.agent.invoke({ messages });
|
|
18743
|
-
const aiMessage = result
|
|
18743
|
+
const aiMessage = extractLatestMessage(result);
|
|
18744
18744
|
messages.push(aiMessage);
|
|
18745
18745
|
turns++;
|
|
18746
18746
|
}
|
|
@@ -18763,6 +18763,14 @@ var ConversationSimulator = class {
|
|
|
18763
18763
|
function createConversationSimulator(agent, config2) {
|
|
18764
18764
|
return new ConversationSimulator(agent, config2);
|
|
18765
18765
|
}
|
|
18766
|
+
function extractLatestMessage(state) {
|
|
18767
|
+
const messages = extractMessages(state);
|
|
18768
|
+
const latestMessage = messages[messages.length - 1];
|
|
18769
|
+
if (!latestMessage) {
|
|
18770
|
+
throw new Error("Agent response did not include any messages");
|
|
18771
|
+
}
|
|
18772
|
+
return latestMessage;
|
|
18773
|
+
}
|
|
18766
18774
|
var ROOT_SNAPSHOT_DIFF_KEY = "$root";
|
|
18767
18775
|
function createSnapshotObject() {
|
|
18768
18776
|
return /* @__PURE__ */ Object.create(null);
|