@vibe-lark/larkpal 0.1.30 → 0.1.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/main.mjs +24 -7
- package/package.json +1 -1
package/dist/main.mjs
CHANGED
|
@@ -1654,9 +1654,7 @@ var ClaudeCodeAdapter = class ClaudeCodeAdapter {
|
|
|
1654
1654
|
* 封装 LarkpalAgentAdapter 的构造逻辑:
|
|
1655
1655
|
* 1. 从环境变量读取 LLM 配置(火山方舟)
|
|
1656
1656
|
* 2. 从 persona 文件读取 systemPrompt
|
|
1657
|
-
*
|
|
1658
|
-
* 工具发现/注册由 larkpal-agent 自身的 MCP Client 负责,
|
|
1659
|
-
* larkpal 平台层不涉及工具层。
|
|
1657
|
+
* 3. 连接 MCP Server 自动发现并注册远程工具
|
|
1660
1658
|
*
|
|
1661
1659
|
* 仅当 LARKPAL_RUNTIME=larkpal-agent 时使用。
|
|
1662
1660
|
*/
|
|
@@ -1689,8 +1687,8 @@ function loadLLMConfig() {
|
|
|
1689
1687
|
/**
|
|
1690
1688
|
* 创建 LarkpalAgentAdapter 实例
|
|
1691
1689
|
*
|
|
1692
|
-
*
|
|
1693
|
-
*
|
|
1690
|
+
* 自动连接 MCP Server 发现并注册远程工具。
|
|
1691
|
+
* MCP Server URL 通过环境变量 LARKPAL_AGENT_MCP_SERVER_URL 配置。
|
|
1694
1692
|
*/
|
|
1695
1693
|
async function createLarkpalAgentAdapter() {
|
|
1696
1694
|
const llm = loadLLMConfig();
|
|
@@ -1701,13 +1699,32 @@ async function createLarkpalAgentAdapter() {
|
|
|
1701
1699
|
model: llm.defaultModel,
|
|
1702
1700
|
maxTurns: defaultMaxTurns
|
|
1703
1701
|
});
|
|
1704
|
-
const { LarkpalAgentAdapter } = await import("@vibe-lark/larkpal-agent");
|
|
1705
|
-
|
|
1702
|
+
const { LarkpalAgentAdapter, ToolRegistry } = await import("@vibe-lark/larkpal-agent");
|
|
1703
|
+
const adapter = new LarkpalAgentAdapter({
|
|
1706
1704
|
llm,
|
|
1707
1705
|
systemPrompt,
|
|
1708
1706
|
tools: [],
|
|
1709
1707
|
defaultMaxTurns
|
|
1710
1708
|
});
|
|
1709
|
+
const mcpServerUrl = process.env.LARKPAL_AGENT_MCP_SERVER_URL;
|
|
1710
|
+
if (mcpServerUrl) try {
|
|
1711
|
+
const registry = new ToolRegistry();
|
|
1712
|
+
const toolCount = await registry.connectMcpServer(mcpServerUrl, { timeoutMs: 1e4 });
|
|
1713
|
+
const tools = registry.getAll();
|
|
1714
|
+
adapter.registerTools(tools);
|
|
1715
|
+
log$27.info("MCP 工具注册完成", {
|
|
1716
|
+
serverUrl: mcpServerUrl,
|
|
1717
|
+
toolCount,
|
|
1718
|
+
toolNames: tools.map((t) => t.name)
|
|
1719
|
+
});
|
|
1720
|
+
} catch (err) {
|
|
1721
|
+
log$27.error("MCP Server 连接失败,Agent 将无法使用远程工具", {
|
|
1722
|
+
serverUrl: mcpServerUrl,
|
|
1723
|
+
error: err?.message
|
|
1724
|
+
});
|
|
1725
|
+
}
|
|
1726
|
+
else log$27.warn("未配置 LARKPAL_AGENT_MCP_SERVER_URL,Agent 无远程工具可用");
|
|
1727
|
+
return adapter;
|
|
1711
1728
|
}
|
|
1712
1729
|
//#endregion
|
|
1713
1730
|
//#region src/routing/session-router.ts
|