@vibe-lark/larkpal 0.1.54 → 0.1.55
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 +12 -1
- package/package.json +1 -1
package/dist/main.mjs
CHANGED
|
@@ -1942,6 +1942,7 @@ async function loadSystemPrompt() {
|
|
|
1942
1942
|
}
|
|
1943
1943
|
}
|
|
1944
1944
|
const SCENARIO_MANIFEST_API_PATH = "/api/scenario-manifests";
|
|
1945
|
+
const DEFAULT_AGENT_MCP_TIMEOUT_MS = 1e4;
|
|
1945
1946
|
function loadLLMConfig() {
|
|
1946
1947
|
const baseURL = process.env.LARKPAL_AGENT_LLM_BASE_URL;
|
|
1947
1948
|
const apiKey = process.env.LARKPAL_AGENT_LLM_API_KEY;
|
|
@@ -1956,6 +1957,13 @@ function loadLLMConfig() {
|
|
|
1956
1957
|
function loadScenarioManifestDirs() {
|
|
1957
1958
|
return (process.env.LARKPAL_AGENT_SCENARIO_DIRS || "").split(":").map((entry) => entry.trim()).filter(Boolean);
|
|
1958
1959
|
}
|
|
1960
|
+
function loadAgentMcpTimeoutMs(env = process.env) {
|
|
1961
|
+
const raw = env.LARKPAL_AGENT_MCP_TIMEOUT_MS;
|
|
1962
|
+
if (raw == null || raw.trim() === "") return DEFAULT_AGENT_MCP_TIMEOUT_MS;
|
|
1963
|
+
const timeoutMs = Number.parseInt(raw, 10);
|
|
1964
|
+
if (!Number.isFinite(timeoutMs) || !/^\d+$/.test(raw.trim()) || timeoutMs <= 0) throw new Error("LARKPAL_AGENT_MCP_TIMEOUT_MS 必须是正整数毫秒值");
|
|
1965
|
+
return timeoutMs;
|
|
1966
|
+
}
|
|
1959
1967
|
function loadScenarioProviderConfig(manifestDirs) {
|
|
1960
1968
|
const rawConfig = process.env.LARKPAL_AGENT_SCENARIO_PROVIDER_CONFIG;
|
|
1961
1969
|
if (rawConfig) {
|
|
@@ -2044,10 +2052,12 @@ async function createLarkpalAgentAdapter() {
|
|
|
2044
2052
|
const defaultMaxTurns = parseInt(process.env.LARKPAL_AGENT_MAX_TURNS || "25", 10);
|
|
2045
2053
|
const scenarioManifestDirs = loadScenarioManifestDirs();
|
|
2046
2054
|
const scenarioProviderConfig = loadScenarioProviderConfig(scenarioManifestDirs);
|
|
2055
|
+
const mcpTimeoutMs = loadAgentMcpTimeoutMs();
|
|
2047
2056
|
log$28.info("创建 LarkpalAgentAdapter", {
|
|
2048
2057
|
baseURL: llm.baseURL,
|
|
2049
2058
|
model: llm.defaultModel,
|
|
2050
2059
|
maxTurns: defaultMaxTurns,
|
|
2060
|
+
mcpTimeoutMs,
|
|
2051
2061
|
scenarioProvider: summarizeScenarioProviderConfig(scenarioProviderConfig)
|
|
2052
2062
|
});
|
|
2053
2063
|
const { LarkpalAgentAdapter, ToolRegistry } = await import("@vibe-lark/larkpal-agent");
|
|
@@ -2063,11 +2073,12 @@ async function createLarkpalAgentAdapter() {
|
|
|
2063
2073
|
});
|
|
2064
2074
|
const mcpServerUrl = process.env.LARKPAL_AGENT_MCP_SERVER_URL;
|
|
2065
2075
|
if (mcpServerUrl) try {
|
|
2066
|
-
const toolCount = await registry.connectMcpServer(mcpServerUrl, { timeoutMs:
|
|
2076
|
+
const toolCount = await registry.connectMcpServer(mcpServerUrl, { timeoutMs: mcpTimeoutMs });
|
|
2067
2077
|
const tools = registry.getAll();
|
|
2068
2078
|
adapter.registerTools(tools);
|
|
2069
2079
|
log$28.info("MCP 工具注册完成", {
|
|
2070
2080
|
serverUrl: mcpServerUrl,
|
|
2081
|
+
timeoutMs: mcpTimeoutMs,
|
|
2071
2082
|
toolCount,
|
|
2072
2083
|
toolNames: tools.map((t) => t.name)
|
|
2073
2084
|
});
|