@agentforge/testing 0.16.30 → 0.16.31

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.cjs CHANGED
@@ -1540,58 +1540,81 @@ function createErrorLLM(errorMessage = "Mock error") {
1540
1540
  errorMessage
1541
1541
  });
1542
1542
  }
1543
- function createMockTool(config2 = {}) {
1544
- const {
1545
- name = "mock_tool",
1546
- description = "A mock tool for testing",
1547
- category = core.ToolCategory.UTILITY,
1548
- schema,
1549
- implementation,
1550
- shouldError = false,
1551
- errorMessage = "Mock tool error",
1552
- delay = 0
1553
- } = config2;
1554
- const actualSchema = schema || zod.z.object({ input: zod.z.string().describe("Input parameter") });
1543
+ var defaultMockToolSchema = zod.z.object({
1544
+ input: zod.z.string().describe("Input parameter")
1545
+ });
1546
+ function buildMockTool(config2) {
1547
+ const { name, description, category, schema, implementation, shouldError, errorMessage, delay } = config2;
1555
1548
  const defaultImplementation = async (input) => {
1549
+ return `Mock result: ${JSON.stringify(input)}`;
1550
+ };
1551
+ const actualImplementation = async (input) => {
1556
1552
  if (delay > 0) {
1557
1553
  await new Promise((resolve4) => setTimeout(resolve4, delay));
1558
1554
  }
1559
1555
  if (shouldError) {
1560
1556
  throw new Error(errorMessage);
1561
1557
  }
1562
- return `Mock result: ${JSON.stringify(input)}`;
1563
- };
1564
- const actualImplementation = async (input) => {
1565
1558
  if (implementation) {
1566
1559
  const result = await Promise.resolve(implementation(input));
1567
1560
  return result;
1568
1561
  }
1569
1562
  return defaultImplementation(input);
1570
1563
  };
1571
- return core.toolBuilder().name(name).description(description).category(category).schema(actualSchema).implement(actualImplementation).build();
1564
+ return core.toolBuilder().name(name).description(description).category(category).schema(schema).implement(actualImplementation).build();
1572
1565
  }
1573
- function createEchoTool(name = "echo_tool") {
1574
- return createMockTool({
1566
+ function createMockTool(config2 = {}) {
1567
+ const name = config2.name ?? "mock-tool";
1568
+ const description = config2.description ?? "A mock tool for testing";
1569
+ const category = config2.category ?? core.ToolCategory.UTILITY;
1570
+ const shouldError = config2.shouldError ?? false;
1571
+ const errorMessage = config2.errorMessage ?? "Mock tool error";
1572
+ const delay = config2.delay ?? 0;
1573
+ if ("schema" in config2 && config2.schema) {
1574
+ return buildMockTool({
1575
+ name,
1576
+ description,
1577
+ category,
1578
+ schema: config2.schema,
1579
+ implementation: config2.implementation,
1580
+ shouldError,
1581
+ errorMessage,
1582
+ delay
1583
+ });
1584
+ }
1585
+ return buildMockTool({
1575
1586
  name,
1587
+ description,
1588
+ category,
1589
+ schema: defaultMockToolSchema,
1590
+ implementation: config2.implementation,
1591
+ shouldError,
1592
+ errorMessage,
1593
+ delay
1594
+ });
1595
+ }
1596
+ function createEchoTool(name = "echo-tool") {
1597
+ return createMockTool({
1598
+ name: name.replace(/_/g, "-"),
1576
1599
  description: "Echoes the input",
1577
1600
  schema: zod.z.object({ message: zod.z.string().describe("Message to echo") }),
1578
1601
  implementation: async ({ message }) => `Echo: ${message}`
1579
1602
  });
1580
1603
  }
1581
- function createErrorTool(name = "error_tool", errorMessage = "Tool error") {
1604
+ function createErrorTool(name = "error-tool", errorMessage = "Tool error") {
1582
1605
  return createMockTool({
1583
- name,
1606
+ name: name.replace(/_/g, "-"),
1584
1607
  description: "A tool that always errors",
1585
1608
  shouldError: true,
1586
1609
  errorMessage
1587
1610
  });
1588
1611
  }
1589
- function createDelayedTool(name = "delayed_tool", delay = 100) {
1612
+ function createDelayedTool(name = "delayed-tool", delay = 100) {
1590
1613
  return createMockTool({
1591
- name,
1614
+ name: name.replace(/_/g, "-"),
1592
1615
  description: "A tool with artificial delay",
1593
1616
  delay,
1594
- schema: zod.z.object({ input: zod.z.string().describe("Input parameter") }),
1617
+ schema: defaultMockToolSchema,
1595
1618
  implementation: async ({ input }) => `Delayed result: ${input}`
1596
1619
  });
1597
1620
  }