@iqai/adk 0.1.3 → 0.1.4
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/CHANGELOG.md +6 -0
- package/dist/index.d.mts +35 -1
- package/dist/index.d.ts +35 -1
- package/dist/index.js +9 -2
- package/dist/index.mjs +9 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -1500,6 +1500,38 @@ declare function createSamplingHandler(handler: SamplingHandler): SamplingHandle
|
|
|
1500
1500
|
* tools: [...atpTools, ...fraxlendTools],
|
|
1501
1501
|
* });
|
|
1502
1502
|
* ```
|
|
1503
|
+
*
|
|
1504
|
+
* @example
|
|
1505
|
+
* ```typescript
|
|
1506
|
+
* // Using MCP servers with sampling handlers:
|
|
1507
|
+
* import { createSamplingHandler, LlmResponse } from "@iqai/adk";
|
|
1508
|
+
*
|
|
1509
|
+
* const samplingHandler = createSamplingHandler(async (request) => {
|
|
1510
|
+
* // Handle MCP sampling requests
|
|
1511
|
+
* return new LlmResponse({
|
|
1512
|
+
* content: {
|
|
1513
|
+
* role: "model",
|
|
1514
|
+
* parts: [{ text: "Response from sampling handler" }],
|
|
1515
|
+
* },
|
|
1516
|
+
* });
|
|
1517
|
+
* });
|
|
1518
|
+
*
|
|
1519
|
+
* const nearTools = await McpNearAgent({
|
|
1520
|
+
* env: {
|
|
1521
|
+
* ACCOUNT_ID: env.ACCOUNT_ID,
|
|
1522
|
+
* ACCOUNT_KEY: env.ACCOUNT_KEY,
|
|
1523
|
+
* NEAR_NETWORK_ID: "testnet",
|
|
1524
|
+
* PATH: env.PATH
|
|
1525
|
+
* },
|
|
1526
|
+
* samplingHandler
|
|
1527
|
+
* }).getTools();
|
|
1528
|
+
*
|
|
1529
|
+
* const agent = new LlmAgent({
|
|
1530
|
+
* name: "near_assistant",
|
|
1531
|
+
* model: "gemini-2.5-flash",
|
|
1532
|
+
* tools: nearTools,
|
|
1533
|
+
* });
|
|
1534
|
+
* ```
|
|
1503
1535
|
*/
|
|
1504
1536
|
/**
|
|
1505
1537
|
* Base configuration interface for MCP servers
|
|
@@ -1516,6 +1548,8 @@ interface McpServerConfig {
|
|
|
1516
1548
|
maxRetries?: number;
|
|
1517
1549
|
initialDelay?: number;
|
|
1518
1550
|
};
|
|
1551
|
+
/** Sampling handler for processing MCP sampling requests */
|
|
1552
|
+
samplingHandler?: SamplingHandler;
|
|
1519
1553
|
}
|
|
1520
1554
|
/**
|
|
1521
1555
|
* MCP ABI - Smart contract ABI interactions for Ethereum-compatible blockchains
|
|
@@ -1594,7 +1628,7 @@ declare function McpMemory(config?: McpServerConfig): McpToolset;
|
|
|
1594
1628
|
* Generic MCP server function for any package
|
|
1595
1629
|
*
|
|
1596
1630
|
* @param packageName The npm package name of the MCP server
|
|
1597
|
-
* @param config Configuration object with environment variables
|
|
1631
|
+
* @param config Configuration object with environment variables and optional sampling handler
|
|
1598
1632
|
* @param name Optional custom name for the client
|
|
1599
1633
|
*/
|
|
1600
1634
|
declare function McpGeneric(packageName: string, config?: McpServerConfig, name?: string): McpToolset;
|
package/dist/index.d.ts
CHANGED
|
@@ -1500,6 +1500,38 @@ declare function createSamplingHandler(handler: SamplingHandler): SamplingHandle
|
|
|
1500
1500
|
* tools: [...atpTools, ...fraxlendTools],
|
|
1501
1501
|
* });
|
|
1502
1502
|
* ```
|
|
1503
|
+
*
|
|
1504
|
+
* @example
|
|
1505
|
+
* ```typescript
|
|
1506
|
+
* // Using MCP servers with sampling handlers:
|
|
1507
|
+
* import { createSamplingHandler, LlmResponse } from "@iqai/adk";
|
|
1508
|
+
*
|
|
1509
|
+
* const samplingHandler = createSamplingHandler(async (request) => {
|
|
1510
|
+
* // Handle MCP sampling requests
|
|
1511
|
+
* return new LlmResponse({
|
|
1512
|
+
* content: {
|
|
1513
|
+
* role: "model",
|
|
1514
|
+
* parts: [{ text: "Response from sampling handler" }],
|
|
1515
|
+
* },
|
|
1516
|
+
* });
|
|
1517
|
+
* });
|
|
1518
|
+
*
|
|
1519
|
+
* const nearTools = await McpNearAgent({
|
|
1520
|
+
* env: {
|
|
1521
|
+
* ACCOUNT_ID: env.ACCOUNT_ID,
|
|
1522
|
+
* ACCOUNT_KEY: env.ACCOUNT_KEY,
|
|
1523
|
+
* NEAR_NETWORK_ID: "testnet",
|
|
1524
|
+
* PATH: env.PATH
|
|
1525
|
+
* },
|
|
1526
|
+
* samplingHandler
|
|
1527
|
+
* }).getTools();
|
|
1528
|
+
*
|
|
1529
|
+
* const agent = new LlmAgent({
|
|
1530
|
+
* name: "near_assistant",
|
|
1531
|
+
* model: "gemini-2.5-flash",
|
|
1532
|
+
* tools: nearTools,
|
|
1533
|
+
* });
|
|
1534
|
+
* ```
|
|
1503
1535
|
*/
|
|
1504
1536
|
/**
|
|
1505
1537
|
* Base configuration interface for MCP servers
|
|
@@ -1516,6 +1548,8 @@ interface McpServerConfig {
|
|
|
1516
1548
|
maxRetries?: number;
|
|
1517
1549
|
initialDelay?: number;
|
|
1518
1550
|
};
|
|
1551
|
+
/** Sampling handler for processing MCP sampling requests */
|
|
1552
|
+
samplingHandler?: SamplingHandler;
|
|
1519
1553
|
}
|
|
1520
1554
|
/**
|
|
1521
1555
|
* MCP ABI - Smart contract ABI interactions for Ethereum-compatible blockchains
|
|
@@ -1594,7 +1628,7 @@ declare function McpMemory(config?: McpServerConfig): McpToolset;
|
|
|
1594
1628
|
* Generic MCP server function for any package
|
|
1595
1629
|
*
|
|
1596
1630
|
* @param packageName The npm package name of the MCP server
|
|
1597
|
-
* @param config Configuration object with environment variables
|
|
1631
|
+
* @param config Configuration object with environment variables and optional sampling handler
|
|
1598
1632
|
* @param name Optional custom name for the client
|
|
1599
1633
|
*/
|
|
1600
1634
|
declare function McpGeneric(packageName: string, config?: McpServerConfig, name?: string): McpToolset;
|
package/dist/index.js
CHANGED
|
@@ -5177,7 +5177,13 @@ var McpToolAdapter = (_class18 = class extends BaseTool {
|
|
|
5177
5177
|
|
|
5178
5178
|
// src/tools/mcp/servers.ts
|
|
5179
5179
|
function createMcpConfig(name, packageName, config = {}) {
|
|
5180
|
-
const {
|
|
5180
|
+
const {
|
|
5181
|
+
debug,
|
|
5182
|
+
description,
|
|
5183
|
+
retryOptions,
|
|
5184
|
+
env: envVars = {},
|
|
5185
|
+
samplingHandler
|
|
5186
|
+
} = config;
|
|
5181
5187
|
const env = {};
|
|
5182
5188
|
for (const [key, value] of Object.entries(envVars)) {
|
|
5183
5189
|
if (value !== void 0) {
|
|
@@ -5197,7 +5203,8 @@ function createMcpConfig(name, packageName, config = {}) {
|
|
|
5197
5203
|
command: "npx",
|
|
5198
5204
|
args: ["-y", packageName],
|
|
5199
5205
|
env
|
|
5200
|
-
}
|
|
5206
|
+
},
|
|
5207
|
+
samplingHandler
|
|
5201
5208
|
};
|
|
5202
5209
|
}
|
|
5203
5210
|
function McpAbi(config = {}) {
|
package/dist/index.mjs
CHANGED
|
@@ -5177,7 +5177,13 @@ var McpToolAdapter = class extends BaseTool {
|
|
|
5177
5177
|
|
|
5178
5178
|
// src/tools/mcp/servers.ts
|
|
5179
5179
|
function createMcpConfig(name, packageName, config = {}) {
|
|
5180
|
-
const {
|
|
5180
|
+
const {
|
|
5181
|
+
debug,
|
|
5182
|
+
description,
|
|
5183
|
+
retryOptions,
|
|
5184
|
+
env: envVars = {},
|
|
5185
|
+
samplingHandler
|
|
5186
|
+
} = config;
|
|
5181
5187
|
const env = {};
|
|
5182
5188
|
for (const [key, value] of Object.entries(envVars)) {
|
|
5183
5189
|
if (value !== void 0) {
|
|
@@ -5197,7 +5203,8 @@ function createMcpConfig(name, packageName, config = {}) {
|
|
|
5197
5203
|
command: "npx",
|
|
5198
5204
|
args: ["-y", packageName],
|
|
5199
5205
|
env
|
|
5200
|
-
}
|
|
5206
|
+
},
|
|
5207
|
+
samplingHandler
|
|
5201
5208
|
};
|
|
5202
5209
|
}
|
|
5203
5210
|
function McpAbi(config = {}) {
|