@agentforge/tools 0.5.1 → 0.5.3

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
@@ -1,6 +1,6 @@
1
1
  # @agentforge/tools
2
2
 
3
- > Production-ready tools collection for AgentForge - 69 tools for web, data, file, and utility operations
3
+ > Production-ready tools collection for AgentForge - 70 tools for web, data, file, utility, and agent operations
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/@agentforge/tools)](https://www.npmjs.com/package/@agentforge/tools)
6
6
  [![TypeScript](https://img.shields.io/badge/TypeScript-5.9-blue)](https://www.typescriptlang.org/)
@@ -8,7 +8,7 @@
8
8
 
9
9
  ## 🎉 Status: Production Ready & Published
10
10
 
11
- **69 production-ready tools** | **Full TypeScript support** | **Comprehensive documentation** | **LangChain compatible**
11
+ **70 production-ready tools** | **Full TypeScript support** | **Comprehensive documentation** | **LangChain compatible**
12
12
 
13
13
  ## 📦 Installation
14
14
 
@@ -22,12 +22,13 @@ yarn add @agentforge/tools
22
22
 
23
23
  ## 🎯 Overview
24
24
 
25
- This package provides **69 ready-to-use tools** organized into 4 categories:
25
+ This package provides **70 ready-to-use tools** organized into 5 categories:
26
26
 
27
27
  - **🌐 Web Tools** (11 tools) - HTTP requests, web search, web scraping, HTML parsing, URL manipulation
28
28
  - **📊 Data Tools** (18 tools) - JSON, CSV, XML processing and data transformation
29
29
  - **📁 File Tools** (18 tools) - File operations, directory management, path utilities
30
30
  - **🔧 Utility Tools** (22 tools) - Date/time, strings, math, validation
31
+ - **🤖 Agent Tools** (1 tool) - Human-in-the-loop and agent interaction
31
32
 
32
33
  All tools feature:
33
34
  - ✅ Full TypeScript support with type inference
package/dist/index.cjs CHANGED
@@ -10,6 +10,7 @@ var fastXmlParser = require('fast-xml-parser');
10
10
  var fs = require('fs');
11
11
  var path3 = require('path');
12
12
  var dateFns = require('date-fns');
13
+ var crypto = require('crypto');
13
14
 
14
15
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
15
16
 
@@ -1993,14 +1994,94 @@ var uuidValidator = core.toolBuilder().name("uuid-validator").description("Valid
1993
1994
  message: valid ? `Valid UUID v${version}` : "Invalid UUID format"
1994
1995
  };
1995
1996
  }).build();
1997
+ var AskHumanInputSchema = zod.z.object({
1998
+ /**
1999
+ * The question to ask the human
2000
+ */
2001
+ question: zod.z.string().min(1).describe("The question to ask the human"),
2002
+ /**
2003
+ * Optional context to help the human understand the question
2004
+ */
2005
+ context: zod.z.record(zod.z.any()).optional().describe("Additional context for the question"),
2006
+ /**
2007
+ * Priority level for this request
2008
+ */
2009
+ priority: zod.z.enum(["low", "normal", "high", "critical"]).default("normal").describe("Priority level for this request"),
2010
+ /**
2011
+ * Timeout in milliseconds (0 = no timeout)
2012
+ */
2013
+ timeout: zod.z.number().min(0).default(0).describe("Timeout in milliseconds (0 = no timeout)"),
2014
+ /**
2015
+ * Default response if timeout occurs
2016
+ */
2017
+ defaultResponse: zod.z.string().optional().describe("Default response if timeout occurs"),
2018
+ /**
2019
+ * Suggested responses (for UI to show as options)
2020
+ */
2021
+ suggestions: zod.z.array(zod.z.string()).optional().describe("Suggested responses for the human")
2022
+ });
2023
+ function createAskHumanTool() {
2024
+ return core.toolBuilder().name("ask-human").description(
2025
+ "Ask a human for input or approval. Use this when you need human guidance, approval for a critical action, or clarification on ambiguous requirements. The agent execution will pause until the human responds."
2026
+ ).category(core.ToolCategory.UTILITY).schema(AskHumanInputSchema).implement(async (input) => {
2027
+ const validatedInput = input;
2028
+ const requestId = crypto.randomUUID();
2029
+ const requestedAt = Date.now();
2030
+ let interrupt;
2031
+ try {
2032
+ const langgraph = await import('@langchain/langgraph');
2033
+ interrupt = langgraph.interrupt;
2034
+ } catch (error) {
2035
+ throw new Error(
2036
+ "askHuman tool requires @langchain/langgraph to be installed. Install it with: npm install @langchain/langgraph"
2037
+ );
2038
+ }
2039
+ if (!interrupt) {
2040
+ throw new Error(
2041
+ "interrupt function not found in @langchain/langgraph. Make sure you are using a compatible version of LangGraph."
2042
+ );
2043
+ }
2044
+ const humanRequest = {
2045
+ id: requestId,
2046
+ question: validatedInput.question,
2047
+ context: validatedInput.context,
2048
+ priority: validatedInput.priority,
2049
+ createdAt: requestedAt,
2050
+ timeout: validatedInput.timeout,
2051
+ defaultResponse: validatedInput.defaultResponse,
2052
+ suggestions: validatedInput.suggestions,
2053
+ status: "pending"
2054
+ };
2055
+ const response = interrupt(humanRequest);
2056
+ const respondedAt = Date.now();
2057
+ const duration = respondedAt - requestedAt;
2058
+ const timedOut = validatedInput.timeout > 0 && duration >= validatedInput.timeout;
2059
+ const finalResponse = timedOut && validatedInput.defaultResponse ? validatedInput.defaultResponse : response || "";
2060
+ return {
2061
+ response: finalResponse,
2062
+ metadata: {
2063
+ requestId,
2064
+ requestedAt,
2065
+ respondedAt,
2066
+ duration,
2067
+ timedOut,
2068
+ priority: validatedInput.priority
2069
+ }
2070
+ };
2071
+ }).build();
2072
+ }
2073
+ var askHumanTool = createAskHumanTool();
1996
2074
 
2075
+ exports.AskHumanInputSchema = AskHumanInputSchema;
1997
2076
  exports.DuckDuckGoProvider = DuckDuckGoProvider;
1998
2077
  exports.SerperProvider = SerperProvider;
1999
2078
  exports.arrayFilter = arrayFilter;
2000
2079
  exports.arrayGroupBy = arrayGroupBy;
2001
2080
  exports.arrayMap = arrayMap;
2002
2081
  exports.arraySort = arraySort;
2082
+ exports.askHumanTool = askHumanTool;
2003
2083
  exports.calculator = calculator;
2084
+ exports.createAskHumanTool = createAskHumanTool;
2004
2085
  exports.createDuckDuckGoProvider = createDuckDuckGoProvider;
2005
2086
  exports.createSerperProvider = createSerperProvider;
2006
2087
  exports.creditCardValidator = creditCardValidator;