@hashgraphonline/conversational-agent 0.2.110 → 0.2.200
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/cjs/index.cjs +1 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/mcp/types.d.ts +14 -3
- package/dist/esm/index10.js +1 -1
- package/dist/esm/index15.js +11 -6
- package/dist/esm/index15.js.map +1 -1
- package/dist/esm/index23.js +3 -3
- package/dist/esm/index33.js +2 -2
- package/dist/esm/index41.js +11 -4
- package/dist/esm/index41.js.map +1 -1
- package/dist/esm/index42.js +4 -11
- package/dist/esm/index42.js.map +1 -1
- package/dist/esm/index47.js +4 -1
- package/dist/esm/index47.js.map +1 -1
- package/dist/types/mcp/types.d.ts +14 -3
- package/package.json +2 -1
- package/src/mcp/mcp-client-manager.ts +14 -7
- package/src/mcp/types.ts +15 -3
- package/src/plugins/hbar/AccountBuilder.ts +16 -16
package/dist/cjs/mcp/types.d.ts
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Minimal MCP Tool shape used internally to avoid external type dependency resolution issues.
|
|
3
|
+
* Aligns with MCP tool metadata returned by listTools.
|
|
4
|
+
*/
|
|
5
|
+
export interface BaseMCPTool {
|
|
6
|
+
name: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
/**
|
|
9
|
+
* JSON Schema describing input parameters for the tool.
|
|
10
|
+
* Kept as unknown and validated/converted at the boundary.
|
|
11
|
+
*/
|
|
12
|
+
inputSchema?: unknown;
|
|
13
|
+
}
|
|
3
14
|
export interface MCPServerConfig {
|
|
4
15
|
name: string;
|
|
5
16
|
command: string;
|
|
@@ -16,7 +27,7 @@ export interface MCPServerConfig {
|
|
|
16
27
|
*/
|
|
17
28
|
toolDescriptions?: Record<string, string>;
|
|
18
29
|
}
|
|
19
|
-
export interface MCPToolInfo extends
|
|
30
|
+
export interface MCPToolInfo extends BaseMCPTool {
|
|
20
31
|
serverName: string;
|
|
21
32
|
}
|
|
22
33
|
export interface MCPConnectionStatus {
|
package/dist/esm/index10.js
CHANGED
|
@@ -3,7 +3,7 @@ import { extractRenderConfigs, generateFieldOrdering } from "@hashgraphonline/st
|
|
|
3
3
|
import { Logger } from "@hashgraphonline/standards-sdk";
|
|
4
4
|
import { fieldTypeRegistry } from "./index12.js";
|
|
5
5
|
import { fieldGuidanceRegistry } from "./index13.js";
|
|
6
|
-
import "./
|
|
6
|
+
import "./index41.js";
|
|
7
7
|
import { FIELD_PRIORITIES } from "./index45.js";
|
|
8
8
|
function isZodObjectSchema(schema) {
|
|
9
9
|
return typeof schema === "object" && schema !== null && "shape" in schema;
|
package/dist/esm/index15.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Client } from "@modelcontextprotocol/sdk/client/index";
|
|
2
|
-
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio";
|
|
1
|
+
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
2
|
+
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
|
|
3
3
|
import { MCPContentProcessor } from "./index16.js";
|
|
4
4
|
class MCPClientManager {
|
|
5
5
|
constructor(logger, contentStorage) {
|
|
@@ -40,10 +40,15 @@ class MCPClientManager {
|
|
|
40
40
|
await client.connect(transport);
|
|
41
41
|
this.clients.set(config.name, client);
|
|
42
42
|
const toolsResponse = await client.listTools();
|
|
43
|
-
const toolsWithServer = toolsResponse.tools.map((tool) =>
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
const toolsWithServer = toolsResponse.tools.map((tool) => {
|
|
44
|
+
const t = tool;
|
|
45
|
+
const { description, ...rest } = t;
|
|
46
|
+
const base = description !== void 0 && typeof description === "string" ? { ...rest, description } : { ...rest };
|
|
47
|
+
return {
|
|
48
|
+
...base,
|
|
49
|
+
serverName: config.name
|
|
50
|
+
};
|
|
51
|
+
});
|
|
47
52
|
this.tools.set(config.name, toolsWithServer);
|
|
48
53
|
this.logger.info(`Connected to MCP server ${config.name} with ${toolsWithServer.length} tools`);
|
|
49
54
|
return {
|
package/dist/esm/index15.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index15.js","sources":["../../src/mcp/mcp-client-manager.ts"],"sourcesContent":["import { Client } from '@modelcontextprotocol/sdk/client/index';\nimport { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio';\nimport type { MCPServerConfig, MCPToolInfo, MCPConnectionStatus } from './types';\nimport { Logger } from '@hashgraphonline/standards-sdk';\nimport type { ContentStorage } from '../memory/content-storage';\nimport { MCPContentProcessor } from './content-processor';\n\n/**\n * Manages connections to MCP servers and tool discovery\n */\nexport class MCPClientManager {\n private clients: Map<string, Client> = new Map();\n private tools: Map<string, MCPToolInfo[]> = new Map();\n private logger: Logger;\n private contentProcessor?: MCPContentProcessor;\n\n constructor(logger: Logger, contentStorage?: ContentStorage) {\n this.logger = logger;\n if (contentStorage) {\n this.contentProcessor = new MCPContentProcessor(contentStorage, logger);\n }\n }\n\n /**\n * Connect to an MCP server and discover its tools\n */\n async connectServer(config: MCPServerConfig): Promise<MCPConnectionStatus> {\n try {\n if (this.isServerConnected(config.name)) {\n return {\n serverName: config.name,\n connected: false,\n error: `Server ${config.name} is already connected`,\n tools: [],\n };\n }\n\n if (config.transport && config.transport !== 'stdio') {\n throw new Error(`Transport ${config.transport} not yet supported`);\n }\n\n const transport = new StdioClientTransport({\n command: config.command,\n args: config.args,\n ...(config.env && { env: config.env }),\n });\n\n const client = new Client({\n name: `conversational-agent-${config.name}`,\n version: '1.0.0',\n }, {\n capabilities: {},\n });\n\n await client.connect(transport);\n this.clients.set(config.name, client);\n\n const toolsResponse = await client.listTools();\n const toolsWithServer: MCPToolInfo[] = toolsResponse.tools.map(tool => ({\n ...tool,\n serverName: config.name,\n }));\n\n this.tools.set(config.name, toolsWithServer);\n this.logger.info(`Connected to MCP server ${config.name} with ${toolsWithServer.length} tools`);\n\n return {\n serverName: config.name,\n connected: true,\n tools: toolsWithServer,\n };\n } catch (error) {\n this.logger.error(`Failed to connect to MCP server ${config.name}:`, error);\n return {\n serverName: config.name,\n connected: false,\n error: error instanceof Error ? error.message : 'Unknown error',\n tools: [],\n };\n }\n }\n\n /**\n * Execute a tool on a specific MCP server\n */\n async executeTool(serverName: string, toolName: string, args: Record<string, unknown>): Promise<unknown> {\n const client = this.clients.get(serverName);\n if (!client) {\n throw new Error(`MCP server ${serverName} not connected`);\n }\n\n this.logger.debug(`Executing MCP tool ${toolName} on server ${serverName}`, args);\n\n try {\n const result = await client.callTool({\n name: toolName,\n arguments: args,\n });\n\n if (this.contentProcessor) {\n const processed = await this.contentProcessor.processResponse(result, serverName, toolName);\n \n if (processed.wasProcessed) {\n this.logger.debug(\n `Processed MCP response from ${serverName}::${toolName}`,\n {\n referenceCreated: processed.referenceCreated,\n originalSize: processed.originalSize,\n errors: processed.errors\n }\n );\n\n if (processed.errors && processed.errors.length > 0) {\n this.logger.warn(`Content processing warnings for ${serverName}::${toolName}:`, processed.errors);\n }\n }\n\n return processed.content;\n }\n\n return result;\n } catch (error) {\n this.logger.error(`Error executing MCP tool ${toolName}:`, error);\n throw error;\n }\n }\n\n /**\n * Disconnect all MCP servers\n */\n async disconnectAll(): Promise<void> {\n for (const [name, client] of this.clients) {\n try {\n await client.close();\n this.logger.info(`Disconnected from MCP server ${name}`);\n } catch (error) {\n this.logger.error(`Error disconnecting MCP server ${name}:`, error);\n }\n }\n this.clients.clear();\n this.tools.clear();\n }\n\n /**\n * Get all discovered tools from all connected servers\n */\n getAllTools(): MCPToolInfo[] {\n const allTools: MCPToolInfo[] = [];\n for (const tools of this.tools.values()) {\n allTools.push(...tools);\n }\n return allTools;\n }\n\n /**\n * Get tools from a specific server\n */\n getServerTools(serverName: string): MCPToolInfo[] {\n return this.tools.get(serverName) || [];\n }\n\n /**\n * Check if a server is connected\n */\n isServerConnected(serverName: string): boolean {\n return this.clients.has(serverName);\n }\n\n /**\n * Get list of connected server names\n */\n getConnectedServers(): string[] {\n return Array.from(this.clients.keys());\n }\n\n /**\n * Enable content processing with content storage\n */\n enableContentProcessing(contentStorage: ContentStorage): void {\n this.contentProcessor = new MCPContentProcessor(contentStorage, this.logger);\n this.logger.info('Content processing enabled for MCP responses');\n }\n\n /**\n * Disable content processing\n */\n disableContentProcessing(): void {\n delete this.contentProcessor;\n this.logger.info('Content processing disabled for MCP responses');\n }\n\n /**\n * Check if content processing is enabled\n */\n isContentProcessingEnabled(): boolean {\n return this.contentProcessor !== undefined;\n }\n\n /**\n * Analyze a response without processing it (for testing/debugging)\n */\n analyzeResponseContent(response: unknown): unknown {\n if (!this.contentProcessor) {\n throw new Error('Content processing is not enabled');\n }\n return this.contentProcessor.analyzeResponse(response);\n }\n}"],"names":[],"mappings":";;;AAUO,MAAM,iBAAiB;AAAA,EAM5B,YAAY,QAAgB,gBAAiC;AAL7D,SAAQ,8BAAmC,IAAA;AAC3C,SAAQ,4BAAwC,IAAA;AAK9C,SAAK,SAAS;AACd,QAAI,gBAAgB;AAClB,WAAK,mBAAmB,IAAI,oBAAoB,gBAAgB,MAAM;AAAA,IACxE;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,cAAc,QAAuD;AACzE,QAAI;AACF,UAAI,KAAK,kBAAkB,OAAO,IAAI,GAAG;AACvC,eAAO;AAAA,UACL,YAAY,OAAO;AAAA,UACnB,WAAW;AAAA,UACX,OAAO,UAAU,OAAO,IAAI;AAAA,UAC5B,OAAO,CAAA;AAAA,QAAC;AAAA,MAEZ;AAEA,UAAI,OAAO,aAAa,OAAO,cAAc,SAAS;AACpD,cAAM,IAAI,MAAM,aAAa,OAAO,SAAS,oBAAoB;AAAA,MACnE;AAEA,YAAM,YAAY,IAAI,qBAAqB;AAAA,QACzC,SAAS,OAAO;AAAA,QAChB,MAAM,OAAO;AAAA,QACb,GAAI,OAAO,OAAO,EAAE,KAAK,OAAO,IAAA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AAA;AAAA,EAKA,sBAAgC;AAC9B,WAAO,MAAM,KAAK,KAAK,QAAQ,MAAM;AAAA,EACvC;AAAA;AAAA;AAAA;AAAA,EAKA,wBAAwB,gBAAsC;AAC5D,SAAK,mBAAmB,IAAI,oBAAoB,gBAAgB,KAAK,MAAM;AAC3E,SAAK,OAAO,KAAK,8CAA8C;AAAA,EACjE;AAAA;AAAA;AAAA;AAAA,EAKA,2BAAiC;AAC/B,WAAO,KAAK;AACZ,SAAK,OAAO,KAAK,+CAA+C;AAAA,EAClE;AAAA;AAAA;AAAA;AAAA,EAKA,6BAAsC;AACpC,WAAO,KAAK,qBAAqB;AAAA,EACnC;AAAA;AAAA;AAAA;AAAA,EAKA,uBAAuB,UAA4B;AACjD,QAAI,CAAC,KAAK,kBAAkB;AAC1B,YAAM,IAAI,MAAM,mCAAmC;AAAA,IACrD;AACA,WAAO,KAAK,iBAAiB,gBAAgB,QAAQ;AAAA,EACvD;AACF;"}
|
|
1
|
+
{"version":3,"file":"index15.js","sources":["../../src/mcp/mcp-client-manager.ts"],"sourcesContent":["import { Client } from '@modelcontextprotocol/sdk/client/index.js';\nimport { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';\nimport type { MCPServerConfig, MCPToolInfo, MCPConnectionStatus } from './types';\nimport { Logger } from '@hashgraphonline/standards-sdk';\nimport type { ContentStorage } from '../memory/content-storage';\nimport { MCPContentProcessor } from './content-processor';\n\n/**\n * Manages connections to MCP servers and tool discovery\n */\nexport class MCPClientManager {\n private clients: Map<string, Client> = new Map();\n private tools: Map<string, MCPToolInfo[]> = new Map();\n private logger: Logger;\n private contentProcessor?: MCPContentProcessor;\n\n constructor(logger: Logger, contentStorage?: ContentStorage) {\n this.logger = logger;\n if (contentStorage) {\n this.contentProcessor = new MCPContentProcessor(contentStorage, logger);\n }\n }\n\n /**\n * Connect to an MCP server and discover its tools\n */\n async connectServer(config: MCPServerConfig): Promise<MCPConnectionStatus> {\n try {\n if (this.isServerConnected(config.name)) {\n return {\n serverName: config.name,\n connected: false,\n error: `Server ${config.name} is already connected`,\n tools: [],\n };\n }\n\n if (config.transport && config.transport !== 'stdio') {\n throw new Error(`Transport ${config.transport} not yet supported`);\n }\n\n const transport = new StdioClientTransport({\n command: config.command,\n args: config.args,\n ...(config.env && { env: config.env }),\n });\n\n const client = new Client({\n name: `conversational-agent-${config.name}`,\n version: '1.0.0',\n }, {\n capabilities: {},\n });\n\n await client.connect(transport);\n this.clients.set(config.name, client);\n\n const toolsResponse = await client.listTools();\n const toolsWithServer: MCPToolInfo[] = toolsResponse.tools.map((tool: unknown) => {\n const t = tool as { description?: string } & Record<string, unknown>;\n const { description, ...rest } = t;\n const base = description !== undefined && typeof description === 'string'\n ? { ...rest, description }\n : { ...rest };\n return {\n ...(base as Omit<MCPToolInfo, 'serverName'>),\n serverName: config.name,\n } as MCPToolInfo;\n });\n\n this.tools.set(config.name, toolsWithServer);\n this.logger.info(`Connected to MCP server ${config.name} with ${toolsWithServer.length} tools`);\n\n return {\n serverName: config.name,\n connected: true,\n tools: toolsWithServer,\n };\n } catch (error) {\n this.logger.error(`Failed to connect to MCP server ${config.name}:`, error);\n return {\n serverName: config.name,\n connected: false,\n error: error instanceof Error ? error.message : 'Unknown error',\n tools: [],\n };\n }\n }\n\n /**\n * Execute a tool on a specific MCP server\n */\n async executeTool(serverName: string, toolName: string, args: Record<string, unknown>): Promise<unknown> {\n const client = this.clients.get(serverName);\n if (!client) {\n throw new Error(`MCP server ${serverName} not connected`);\n }\n\n this.logger.debug(`Executing MCP tool ${toolName} on server ${serverName}`, args);\n\n try {\n const result = await client.callTool({\n name: toolName,\n arguments: args,\n });\n\n if (this.contentProcessor) {\n const processed = await this.contentProcessor.processResponse(result, serverName, toolName);\n \n if (processed.wasProcessed) {\n this.logger.debug(\n `Processed MCP response from ${serverName}::${toolName}`,\n {\n referenceCreated: processed.referenceCreated,\n originalSize: processed.originalSize,\n errors: processed.errors\n }\n );\n\n if (processed.errors && processed.errors.length > 0) {\n this.logger.warn(`Content processing warnings for ${serverName}::${toolName}:`, processed.errors);\n }\n }\n\n return processed.content;\n }\n\n return result;\n } catch (error) {\n this.logger.error(`Error executing MCP tool ${toolName}:`, error);\n throw error;\n }\n }\n\n /**\n * Disconnect all MCP servers\n */\n async disconnectAll(): Promise<void> {\n for (const [name, client] of this.clients) {\n try {\n await client.close();\n this.logger.info(`Disconnected from MCP server ${name}`);\n } catch (error) {\n this.logger.error(`Error disconnecting MCP server ${name}:`, error);\n }\n }\n this.clients.clear();\n this.tools.clear();\n }\n\n /**\n * Get all discovered tools from all connected servers\n */\n getAllTools(): MCPToolInfo[] {\n const allTools: MCPToolInfo[] = [];\n for (const tools of this.tools.values()) {\n allTools.push(...tools);\n }\n return allTools;\n }\n\n /**\n * Get tools from a specific server\n */\n getServerTools(serverName: string): MCPToolInfo[] {\n return this.tools.get(serverName) || [];\n }\n\n /**\n * Check if a server is connected\n */\n isServerConnected(serverName: string): boolean {\n return this.clients.has(serverName);\n }\n\n /**\n * Get list of connected server names\n */\n getConnectedServers(): string[] {\n return Array.from(this.clients.keys());\n }\n\n /**\n * Enable content processing with content storage\n */\n enableContentProcessing(contentStorage: ContentStorage): void {\n this.contentProcessor = new MCPContentProcessor(contentStorage, this.logger);\n this.logger.info('Content processing enabled for MCP responses');\n }\n\n /**\n * Disable content processing\n */\n disableContentProcessing(): void {\n delete this.contentProcessor;\n this.logger.info('Content processing disabled for MCP responses');\n }\n\n /**\n * Check if content processing is enabled\n */\n isContentProcessingEnabled(): boolean {\n return this.contentProcessor !== undefined;\n }\n\n /**\n * Analyze a response without processing it (for testing/debugging)\n */\n analyzeResponseContent(response: unknown): unknown {\n if (!this.contentProcessor) {\n throw new Error('Content processing is not enabled');\n }\n return this.contentProcessor.analyzeResponse(response);\n }\n}\n"],"names":[],"mappings":";;;AAUO,MAAM,iBAAiB;AAAA,EAM5B,YAAY,QAAgB,gBAAiC;AAL7D,SAAQ,8BAAmC,IAAA;AAC3C,SAAQ,4BAAw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B;AACjD,QAAI,CAAC,KAAK,kBAAkB;AAC1B,YAAM,IAAI,MAAM,mCAAmC;AAAA,IACrD;AACA,WAAO,KAAK,iBAAiB,gBAAgB,QAAQ;AAAA,EACvD;AACF;"}
|
package/dist/esm/index23.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ChatOpenAI } from "@langchain/openai";
|
|
2
2
|
import { Logger } from "@hashgraphonline/standards-sdk";
|
|
3
|
-
import { ENTITY_PATTERNS } from "./
|
|
3
|
+
import { ENTITY_PATTERNS } from "./index41.js";
|
|
4
4
|
import "hedera-agent-kit";
|
|
5
5
|
import "@hashgraphonline/standards-agent-kit";
|
|
6
6
|
import "./index13.js";
|
|
@@ -12,8 +12,8 @@ import "langchain/agents";
|
|
|
12
12
|
import "zod-to-json-schema";
|
|
13
13
|
import "./index12.js";
|
|
14
14
|
import "@langchain/core/prompts";
|
|
15
|
-
import "@modelcontextprotocol/sdk/client/index";
|
|
16
|
-
import "@modelcontextprotocol/sdk/client/stdio";
|
|
15
|
+
import "@modelcontextprotocol/sdk/client/index.js";
|
|
16
|
+
import "@modelcontextprotocol/sdk/client/stdio.js";
|
|
17
17
|
import "./index18.js";
|
|
18
18
|
import "@langchain/core/messages";
|
|
19
19
|
import "./index19.js";
|
package/dist/esm/index33.js
CHANGED
|
@@ -8,8 +8,8 @@ import { MCPClientManager } from "./index15.js";
|
|
|
8
8
|
import { convertMCPToolToLangChain } from "./index17.js";
|
|
9
9
|
import { SmartMemoryManager } from "./index18.js";
|
|
10
10
|
import { ResponseFormatter } from "./index35.js";
|
|
11
|
-
import { ERROR_MESSAGES } from "./
|
|
12
|
-
import "./
|
|
11
|
+
import { ERROR_MESSAGES } from "./index42.js";
|
|
12
|
+
import "./index41.js";
|
|
13
13
|
import { SystemMessage, AIMessage, HumanMessage } from "@langchain/core/messages";
|
|
14
14
|
import { ToolRegistry } from "./index43.js";
|
|
15
15
|
import { ExecutionPipeline } from "./index44.js";
|
package/dist/esm/index41.js
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { EntityFormat } from "./index26.js";
|
|
2
|
+
const ENTITY_PATTERNS = {
|
|
3
|
+
TOPIC_REFERENCE: "the topic",
|
|
4
|
+
TOKEN_REFERENCE: "the token"
|
|
4
5
|
};
|
|
6
|
+
({
|
|
7
|
+
TOPIC: EntityFormat.TOPIC_ID,
|
|
8
|
+
TOKEN: EntityFormat.TOKEN_ID,
|
|
9
|
+
ACCOUNT: EntityFormat.ACCOUNT_ID,
|
|
10
|
+
CONTRACT: EntityFormat.CONTRACT_ID
|
|
11
|
+
});
|
|
5
12
|
export {
|
|
6
|
-
|
|
13
|
+
ENTITY_PATTERNS
|
|
7
14
|
};
|
|
8
15
|
//# sourceMappingURL=index41.js.map
|
package/dist/esm/index41.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index41.js","sources":["../../src/constants/
|
|
1
|
+
{"version":3,"file":"index41.js","sources":["../../src/constants/entity-references.ts"],"sourcesContent":["/**\n * Common entity reference patterns used across the application\n */\nexport const ENTITY_PATTERNS = {\n TOPIC_REFERENCE: 'the topic',\n TOKEN_REFERENCE: 'the token',\n ACCOUNT_REFERENCE: 'the account',\n TRANSACTION_REFERENCE: 'the transaction',\n CONTRACT_REFERENCE: 'the contract',\n} as const;\n\n/**\n * Entity type identifiers\n */\nimport { EntityFormat } from '../services/formatters/types';\n\nexport const ENTITY_TYPES = {\n TOPIC: EntityFormat.TOPIC_ID,\n TOKEN: EntityFormat.TOKEN_ID,\n ACCOUNT: EntityFormat.ACCOUNT_ID,\n TRANSACTION: 'transaction',\n CONTRACT: EntityFormat.CONTRACT_ID,\n} as const;\n"],"names":[],"mappings":";AAGO,MAAM,kBAAkB;AAAA,EAC7B,iBAAiB;AAAA,EACjB,iBAAiB;AAInB;AAAA,CAO4B;AAAA,EAC1B,OAAO,aAAa;AAAA,EACpB,OAAO,aAAa;AAAA,EACpB,SAAS,aAAa;AAAA,EAEtB,UAAU,aAAa;AACzB;"}
|
package/dist/esm/index42.js
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
TOKEN_REFERENCE: "the token"
|
|
1
|
+
const ERROR_MESSAGES = {
|
|
2
|
+
TOO_MANY_REQUESTS: "Too many requests. Please wait a moment and try again.",
|
|
3
|
+
RATE_LIMITED: "I'm receiving too many requests right now. Please wait a moment and try again."
|
|
5
4
|
};
|
|
6
|
-
({
|
|
7
|
-
TOPIC: EntityFormat.TOPIC_ID,
|
|
8
|
-
TOKEN: EntityFormat.TOKEN_ID,
|
|
9
|
-
ACCOUNT: EntityFormat.ACCOUNT_ID,
|
|
10
|
-
CONTRACT: EntityFormat.CONTRACT_ID
|
|
11
|
-
});
|
|
12
5
|
export {
|
|
13
|
-
|
|
6
|
+
ERROR_MESSAGES
|
|
14
7
|
};
|
|
15
8
|
//# sourceMappingURL=index42.js.map
|
package/dist/esm/index42.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index42.js","sources":["../../src/constants/
|
|
1
|
+
{"version":3,"file":"index42.js","sources":["../../src/constants/messages.ts"],"sourcesContent":["/**\n * Common error messages and user feedback strings\n */\nexport const ERROR_MESSAGES = {\n TOO_MANY_REQUESTS: 'Too many requests. Please wait a moment and try again.',\n RATE_LIMITED: \"I'm receiving too many requests right now. Please wait a moment and try again.\",\n SYSTEM_ERROR: 'System error occurred',\n INVALID_INPUT: 'Invalid input provided',\n NETWORK_ERROR: 'Network error occurred',\n} as const;\n\n/**\n * Common success and status messages\n */\nexport const STATUS_MESSAGES = {\n OPERATION_SUCCESSFUL: 'Operation completed successfully',\n PROCESSING: 'Processing your request...',\n READY: 'Ready to process requests',\n INITIALIZING: 'Initializing...',\n} as const;"],"names":[],"mappings":"AAGO,MAAM,iBAAiB;AAAA,EAC5B,mBAAmB;AAAA,EACnB,cAAc;AAIhB;"}
|
package/dist/esm/index47.js
CHANGED
|
@@ -67,7 +67,10 @@ class AccountBuilder extends BaseServiceBuilder {
|
|
|
67
67
|
const lastTransfer = processedTransfers[processedTransfers.length - 1];
|
|
68
68
|
const adjustment = netZeroInTinybars.dividedBy(-1e8);
|
|
69
69
|
const adjustedAmount = lastTransfer.amount.plus(adjustment);
|
|
70
|
-
const adjustedRounded = adjustedAmount.toFixed(
|
|
70
|
+
const adjustedRounded = adjustedAmount.toFixed(
|
|
71
|
+
8,
|
|
72
|
+
BigNumber.ROUND_DOWN
|
|
73
|
+
);
|
|
71
74
|
lastTransfer.hbar = Hbar.fromString(adjustedRounded);
|
|
72
75
|
this.logger.info(
|
|
73
76
|
`Adjusted last transfer for ${lastTransfer.accountId.toString()} to ${adjustedRounded} HBAR`
|
package/dist/esm/index47.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index47.js","sources":["../../src/plugins/hbar/AccountBuilder.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"index47.js","sources":["../../src/plugins/hbar/AccountBuilder.ts"],"sourcesContent":["import { AccountId, Hbar, TransferTransaction } from '@hashgraph/sdk';\nimport BigNumber from 'bignumber';\nimport { HederaAgentKit, BaseServiceBuilder } from 'hedera-agent-kit';\nimport { HbarTransferParams } from './types';\n\n/**\n * Custom AccountBuilder that properly handles HBAR decimal conversion\n */\nexport class AccountBuilder extends BaseServiceBuilder {\n constructor(hederaKit: HederaAgentKit) {\n super(hederaKit);\n }\n\n /**\n * Transfers HBAR between accounts with proper decimal handling\n */\n public transferHbar(\n params: HbarTransferParams,\n isUserInitiated: boolean = true\n ): this {\n this.clearNotes();\n const transaction = new TransferTransaction();\n\n if (!params.transfers || params.transfers.length === 0) {\n throw new Error('HbarTransferParams must include at least one transfer.');\n }\n\n let netZeroInTinybars = new BigNumber(0);\n let userTransferProcessedForScheduling = false;\n\n if (\n isUserInitiated &&\n this.kit.userAccountId &&\n (this.kit.operationalMode as string) === 'provideBytes' &&\n params.transfers.length === 1\n ) {\n const receiverTransfer = params.transfers[0];\n const amountValue =\n typeof receiverTransfer.amount === 'string' ||\n typeof receiverTransfer.amount === 'number'\n ? receiverTransfer.amount\n : receiverTransfer.amount.toString();\n\n const amountBigNum = new BigNumber(amountValue);\n\n if (amountBigNum.isPositive()) {\n const recipientAccountId =\n typeof receiverTransfer.accountId === 'string'\n ? AccountId.fromString(receiverTransfer.accountId)\n : receiverTransfer.accountId;\n\n const roundedAmount = amountBigNum.toFixed(8, BigNumber.ROUND_DOWN);\n const sdkHbarAmount = Hbar.fromString(roundedAmount);\n\n this.logger.info(\n `[AccountBuilder.transferHbar] Configuring user-initiated scheduled transfer: ${sdkHbarAmount.toString()} from ${\n this.kit.userAccountId\n } to ${recipientAccountId.toString()}`\n );\n\n this.addNote(\n `Configured HBAR transfer from your account (${\n this.kit.userAccountId\n }) to ${recipientAccountId.toString()} for ${sdkHbarAmount.toString()}.`\n );\n\n transaction.addHbarTransfer(recipientAccountId, sdkHbarAmount);\n transaction.addHbarTransfer(\n AccountId.fromString(this.kit.userAccountId),\n sdkHbarAmount.negated()\n );\n\n userTransferProcessedForScheduling = true;\n }\n }\n\n if (!userTransferProcessedForScheduling) {\n const processedTransfers: Array<{\n accountId: AccountId;\n amount: BigNumber;\n hbar: Hbar;\n }> = [];\n\n for (const transferInput of params.transfers) {\n const accountId =\n typeof transferInput.accountId === 'string'\n ? AccountId.fromString(transferInput.accountId)\n : transferInput.accountId;\n\n const amountValue =\n typeof transferInput.amount === 'string' ||\n typeof transferInput.amount === 'number'\n ? transferInput.amount\n : transferInput.amount.toString();\n\n const amountBigNum = new BigNumber(amountValue);\n const roundedAmount = amountBigNum.toFixed(8, BigNumber.ROUND_DOWN);\n\n this.logger.info(\n `Processing transfer: ${amountValue} HBAR (rounded to ${roundedAmount}) for account ${accountId.toString()}`\n );\n\n const sdkHbarAmount = Hbar.fromString(roundedAmount);\n processedTransfers.push({\n accountId,\n amount: amountBigNum,\n hbar: sdkHbarAmount,\n });\n\n const tinybarsContribution = sdkHbarAmount.toTinybars();\n netZeroInTinybars = netZeroInTinybars.plus(\n tinybarsContribution.toString()\n );\n }\n\n if (!netZeroInTinybars.isZero()) {\n this.logger.warn(\n `Transfer sum not zero: ${netZeroInTinybars.toString()} tinybars off. Adjusting last transfer.`\n );\n\n if (processedTransfers.length > 0) {\n const lastTransfer =\n processedTransfers[processedTransfers.length - 1];\n const adjustment = netZeroInTinybars.dividedBy(-100000000);\n const adjustedAmount = lastTransfer.amount.plus(adjustment);\n const adjustedRounded = adjustedAmount.toFixed(\n 8,\n BigNumber.ROUND_DOWN\n );\n lastTransfer.hbar = Hbar.fromString(adjustedRounded);\n\n this.logger.info(\n `Adjusted last transfer for ${lastTransfer.accountId.toString()} to ${adjustedRounded} HBAR`\n );\n }\n }\n\n for (const transfer of processedTransfers) {\n transaction.addHbarTransfer(transfer.accountId, transfer.hbar);\n }\n }\n\n if (typeof params.memo !== 'undefined') {\n if (params.memo === null) {\n this.logger.warn('Received null for memo in transferHbar.');\n } else {\n transaction.setTransactionMemo(params.memo);\n }\n }\n\n this.setCurrentTransaction(transaction);\n return this;\n }\n}\n"],"names":[],"mappings":";;;AAQO,MAAM,uBAAuB,mBAAmB;AAAA,EACrD,YAAY,WAA2B;AACrC,UAAM,SAAS;AAAA,EACjB;AAAA;AAAA;AAAA;AAAA,EAKO,aACL,QACA,kBAA2B,MACrB;AACN,SAAK,WAAA;AACL,UAAM,cAAc,IAAI,oBAAA;AAExB,QAAI,CAAC,OAAO,aAAa,OAAO,UAAU,WAAW,GAAG;AACtD,YAAM,IAAI,MAAM,wDAAwD;AAAA,IAC1E;AAEA,QAAI,oBAAoB,IAAI,UAAU,CAAC;AACvC,QAAI,qCAAqC;AAEzC,QACE,mBACA,KAAK,IAAI,iBACR,KAAK,IAAI,oBAA+B,kBACzC,OAAO,UAAU,WAAW,GAC5B;AACA,YAAM,mBAAmB,OAAO,UAAU,CAAC;AAC3C,YAA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AAmB,KAAK;AAAA,UACtB;AAAA,UACA,QAAQ;AAAA,UACR,MAAM;AAAA,QAAA,CACP;AAED,cAAM,uBAAuB,cAAc,WAAA;AAC3C,4BAAoB,kBAAkB;AAAA,UACpC,qBAAqB,SAAA;AAAA,QAAS;AAAA,MAElC;AAEA,UAAI,CAAC,kBAAkB,UAAU;AAC/B,aAAK,OAAO;AAAA,UACV,0BAA0B,kBAAkB,SAAA,CAAU;AAAA,QAAA;AAGxD,YAAI,mBAAmB,SAAS,GAAG;AACjC,gBAAM,eACJ,mBAAmB,mBAAmB,SAAS,CAAC;AAClD,gBAAM,aAAa,kBAAkB,UAAU,IAAU;AACzD,gBAAM,iBAAiB,aAAa,OAAO,KAAK,UAAU;AAC1D,gBAAM,kBAAkB,eAAe;AAAA,YACrC;AAAA,YACA,UAAU;AAAA,UAAA;AAEZ,uBAAa,OAAO,KAAK,WAAW,eAAe;AAEnD,eAAK,OAAO;AAAA,YACV,8BAA8B,aAAa,UAAU,SAAA,CAAU,OAAO,eAAe;AAAA,UAAA;AAAA,QAEzF;AAAA,MACF;AAEA,iBAAW,YAAY,oBAAoB;AACzC,oBAAY,gBAAgB,SAAS,WAAW,SAAS,IAAI;AAAA,MAC/D;AAAA,IACF;AAEA,QAAI,OAAO,OAAO,SAAS,aAAa;AACtC,UAAI,OAAO,SAAS,MAAM;AACxB,aAAK,OAAO,KAAK,yCAAyC;AAAA,MAC5D,OAAO;AACL,oBAAY,mBAAmB,OAAO,IAAI;AAAA,MAC5C;AAAA,IACF;AAEA,SAAK,sBAAsB,WAAW;AACtC,WAAO;AAAA,EACT;AACF;"}
|
|
@@ -1,5 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Minimal MCP Tool shape used internally to avoid external type dependency resolution issues.
|
|
3
|
+
* Aligns with MCP tool metadata returned by listTools.
|
|
4
|
+
*/
|
|
5
|
+
export interface BaseMCPTool {
|
|
6
|
+
name: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
/**
|
|
9
|
+
* JSON Schema describing input parameters for the tool.
|
|
10
|
+
* Kept as unknown and validated/converted at the boundary.
|
|
11
|
+
*/
|
|
12
|
+
inputSchema?: unknown;
|
|
13
|
+
}
|
|
3
14
|
export interface MCPServerConfig {
|
|
4
15
|
name: string;
|
|
5
16
|
command: string;
|
|
@@ -16,7 +27,7 @@ export interface MCPServerConfig {
|
|
|
16
27
|
*/
|
|
17
28
|
toolDescriptions?: Record<string, string>;
|
|
18
29
|
}
|
|
19
|
-
export interface MCPToolInfo extends
|
|
30
|
+
export interface MCPToolInfo extends BaseMCPTool {
|
|
20
31
|
serverName: string;
|
|
21
32
|
}
|
|
22
33
|
export interface MCPConnectionStatus {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hashgraphonline/conversational-agent",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.200",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/cjs/index.cjs",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -107,6 +107,7 @@
|
|
|
107
107
|
"@langchain/openai": "^0.6.13",
|
|
108
108
|
"@modelcontextprotocol/sdk": "^1.17.5",
|
|
109
109
|
"axios": "^1.11.0",
|
|
110
|
+
"bignumber": "^1.1.0",
|
|
110
111
|
"bignumber.js": "^9.3.1",
|
|
111
112
|
"ethers": "^6.15.0",
|
|
112
113
|
"hedera-agent-kit": "^2.0.3",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Client } from '@modelcontextprotocol/sdk/client/index';
|
|
2
|
-
import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio';
|
|
1
|
+
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
2
|
+
import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
|
|
3
3
|
import type { MCPServerConfig, MCPToolInfo, MCPConnectionStatus } from './types';
|
|
4
4
|
import { Logger } from '@hashgraphonline/standards-sdk';
|
|
5
5
|
import type { ContentStorage } from '../memory/content-storage';
|
|
@@ -56,10 +56,17 @@ export class MCPClientManager {
|
|
|
56
56
|
this.clients.set(config.name, client);
|
|
57
57
|
|
|
58
58
|
const toolsResponse = await client.listTools();
|
|
59
|
-
const toolsWithServer: MCPToolInfo[] = toolsResponse.tools.map(tool =>
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
const toolsWithServer: MCPToolInfo[] = toolsResponse.tools.map((tool: unknown) => {
|
|
60
|
+
const t = tool as { description?: string } & Record<string, unknown>;
|
|
61
|
+
const { description, ...rest } = t;
|
|
62
|
+
const base = description !== undefined && typeof description === 'string'
|
|
63
|
+
? { ...rest, description }
|
|
64
|
+
: { ...rest };
|
|
65
|
+
return {
|
|
66
|
+
...(base as Omit<MCPToolInfo, 'serverName'>),
|
|
67
|
+
serverName: config.name,
|
|
68
|
+
} as MCPToolInfo;
|
|
69
|
+
});
|
|
63
70
|
|
|
64
71
|
this.tools.set(config.name, toolsWithServer);
|
|
65
72
|
this.logger.info(`Connected to MCP server ${config.name} with ${toolsWithServer.length} tools`);
|
|
@@ -205,4 +212,4 @@ export class MCPClientManager {
|
|
|
205
212
|
}
|
|
206
213
|
return this.contentProcessor.analyzeResponse(response);
|
|
207
214
|
}
|
|
208
|
-
}
|
|
215
|
+
}
|
package/src/mcp/types.ts
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Minimal MCP Tool shape used internally to avoid external type dependency resolution issues.
|
|
3
|
+
* Aligns with MCP tool metadata returned by listTools.
|
|
4
|
+
*/
|
|
5
|
+
export interface BaseMCPTool {
|
|
6
|
+
name: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
/**
|
|
9
|
+
* JSON Schema describing input parameters for the tool.
|
|
10
|
+
* Kept as unknown and validated/converted at the boundary.
|
|
11
|
+
*/
|
|
12
|
+
inputSchema?: unknown;
|
|
13
|
+
}
|
|
2
14
|
|
|
3
15
|
export interface MCPServerConfig {
|
|
4
16
|
name: string;
|
|
@@ -17,7 +29,7 @@ export interface MCPServerConfig {
|
|
|
17
29
|
toolDescriptions?: Record<string, string>;
|
|
18
30
|
}
|
|
19
31
|
|
|
20
|
-
export interface MCPToolInfo extends
|
|
32
|
+
export interface MCPToolInfo extends BaseMCPTool {
|
|
21
33
|
serverName: string;
|
|
22
34
|
}
|
|
23
35
|
|
|
@@ -26,4 +38,4 @@ export interface MCPConnectionStatus {
|
|
|
26
38
|
connected: boolean;
|
|
27
39
|
error?: string;
|
|
28
40
|
tools: MCPToolInfo[];
|
|
29
|
-
}
|
|
41
|
+
}
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AccountId,
|
|
3
|
-
Hbar,
|
|
4
|
-
TransferTransaction,
|
|
5
|
-
} from '@hashgraph/sdk';
|
|
1
|
+
import { AccountId, Hbar, TransferTransaction } from '@hashgraph/sdk';
|
|
6
2
|
import BigNumber from 'bignumber';
|
|
7
3
|
import { HederaAgentKit, BaseServiceBuilder } from 'hedera-agent-kit';
|
|
8
4
|
import { HbarTransferParams } from './types';
|
|
@@ -24,7 +20,7 @@ export class AccountBuilder extends BaseServiceBuilder {
|
|
|
24
20
|
): this {
|
|
25
21
|
this.clearNotes();
|
|
26
22
|
const transaction = new TransferTransaction();
|
|
27
|
-
|
|
23
|
+
|
|
28
24
|
if (!params.transfers || params.transfers.length === 0) {
|
|
29
25
|
throw new Error('HbarTransferParams must include at least one transfer.');
|
|
30
26
|
}
|
|
@@ -61,7 +57,7 @@ export class AccountBuilder extends BaseServiceBuilder {
|
|
|
61
57
|
this.kit.userAccountId
|
|
62
58
|
} to ${recipientAccountId.toString()}`
|
|
63
59
|
);
|
|
64
|
-
|
|
60
|
+
|
|
65
61
|
this.addNote(
|
|
66
62
|
`Configured HBAR transfer from your account (${
|
|
67
63
|
this.kit.userAccountId
|
|
@@ -84,7 +80,7 @@ export class AccountBuilder extends BaseServiceBuilder {
|
|
|
84
80
|
amount: BigNumber;
|
|
85
81
|
hbar: Hbar;
|
|
86
82
|
}> = [];
|
|
87
|
-
|
|
83
|
+
|
|
88
84
|
for (const transferInput of params.transfers) {
|
|
89
85
|
const accountId =
|
|
90
86
|
typeof transferInput.accountId === 'string'
|
|
@@ -99,7 +95,7 @@ export class AccountBuilder extends BaseServiceBuilder {
|
|
|
99
95
|
|
|
100
96
|
const amountBigNum = new BigNumber(amountValue);
|
|
101
97
|
const roundedAmount = amountBigNum.toFixed(8, BigNumber.ROUND_DOWN);
|
|
102
|
-
|
|
98
|
+
|
|
103
99
|
this.logger.info(
|
|
104
100
|
`Processing transfer: ${amountValue} HBAR (rounded to ${roundedAmount}) for account ${accountId.toString()}`
|
|
105
101
|
);
|
|
@@ -108,7 +104,7 @@ export class AccountBuilder extends BaseServiceBuilder {
|
|
|
108
104
|
processedTransfers.push({
|
|
109
105
|
accountId,
|
|
110
106
|
amount: amountBigNum,
|
|
111
|
-
hbar: sdkHbarAmount
|
|
107
|
+
hbar: sdkHbarAmount,
|
|
112
108
|
});
|
|
113
109
|
|
|
114
110
|
const tinybarsContribution = sdkHbarAmount.toTinybars();
|
|
@@ -121,20 +117,24 @@ export class AccountBuilder extends BaseServiceBuilder {
|
|
|
121
117
|
this.logger.warn(
|
|
122
118
|
`Transfer sum not zero: ${netZeroInTinybars.toString()} tinybars off. Adjusting last transfer.`
|
|
123
119
|
);
|
|
124
|
-
|
|
120
|
+
|
|
125
121
|
if (processedTransfers.length > 0) {
|
|
126
|
-
const lastTransfer =
|
|
122
|
+
const lastTransfer =
|
|
123
|
+
processedTransfers[processedTransfers.length - 1];
|
|
127
124
|
const adjustment = netZeroInTinybars.dividedBy(-100000000);
|
|
128
125
|
const adjustedAmount = lastTransfer.amount.plus(adjustment);
|
|
129
|
-
const adjustedRounded = adjustedAmount.toFixed(
|
|
126
|
+
const adjustedRounded = adjustedAmount.toFixed(
|
|
127
|
+
8,
|
|
128
|
+
BigNumber.ROUND_DOWN
|
|
129
|
+
);
|
|
130
130
|
lastTransfer.hbar = Hbar.fromString(adjustedRounded);
|
|
131
|
-
|
|
131
|
+
|
|
132
132
|
this.logger.info(
|
|
133
133
|
`Adjusted last transfer for ${lastTransfer.accountId.toString()} to ${adjustedRounded} HBAR`
|
|
134
134
|
);
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
|
-
|
|
137
|
+
|
|
138
138
|
for (const transfer of processedTransfers) {
|
|
139
139
|
transaction.addHbarTransfer(transfer.accountId, transfer.hbar);
|
|
140
140
|
}
|
|
@@ -151,4 +151,4 @@ export class AccountBuilder extends BaseServiceBuilder {
|
|
|
151
151
|
this.setCurrentTransaction(transaction);
|
|
152
152
|
return this;
|
|
153
153
|
}
|
|
154
|
-
}
|
|
154
|
+
}
|