@ai-zen/agents-sdk 0.2.3 → 0.2.5
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 +21 -0
- package/dist/capabilities/discovery/skills.d.ts +2 -0
- package/dist/capabilities/discovery/skills.js +1 -0
- package/dist/capabilities/implements/skillTools.js +21 -6
- package/dist/config/constants.js +6 -0
- package/dist/runtime/McpConnectionManager.js +44 -18
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.2.5] - 2026-07-20
|
|
4
|
+
|
|
5
|
+
### 🔧 修复
|
|
6
|
+
|
|
7
|
+
- **`DEFAULT_SUBAGENT_DEFINITION` 缺少 `permissions` 配置** — 默认 SubAgent `general-assistant` 未配置权限,导致所有维度等同于 `deny: ['*']`,完全无法使用任何工具/skill/MCP/SubAgent。现已按设计规范补全,仅 `subagents` 维度设为 `deny: ['*']` 防止递归调用
|
|
8
|
+
|
|
9
|
+
## [0.2.4] - 2026-07-20
|
|
10
|
+
|
|
11
|
+
### 🔧 修复
|
|
12
|
+
|
|
13
|
+
- **`load_skill` 不再注入 System 消息** — 改为在工具返回值中直接返回完整 SKILL.md 内容和 Skill 目录路径、文件列表,LLM 完全透明可见
|
|
14
|
+
- **`SkillInfo` 新增 `dirPath` 字段** — 记录 SKILL.md 所在目录的绝对路径
|
|
15
|
+
- **`McpConnectionManager.doConnect` 按 Server capabilities 按需调用** — 仅对声明了的能力调用对应方法,避免未声明时返回 Method not found
|
|
16
|
+
- **`McpConnectionManager.doConnect` 各 list 调用加 try/catch 保护** — 单个能力获取失败不影响其他能力
|
|
17
|
+
|
|
18
|
+
## [0.2.3] - 2026-07-20
|
|
19
|
+
|
|
20
|
+
### 🔧 修复
|
|
21
|
+
|
|
22
|
+
- **`AgentRepository` — 使用 `EntityRepository` 替代直接文件操作** — 采用基础仓储统一逻辑
|
|
23
|
+
|
|
3
24
|
## [0.2.2] - 2026-07-20
|
|
4
25
|
|
|
5
26
|
### 🔧 修复
|
|
@@ -75,6 +75,7 @@ function readSkillFromPath(skillId, skillMdPath, silent) {
|
|
|
75
75
|
description: fm.description ?? "",
|
|
76
76
|
subAgent: fm.subAgent ?? false,
|
|
77
77
|
content,
|
|
78
|
+
dirPath: skillMdPath.replace(/\/SKILL\.md$/, ""),
|
|
78
79
|
license: fm.license,
|
|
79
80
|
compatibility: fm.compatibility,
|
|
80
81
|
metadata: fm.metadata,
|
|
@@ -3,6 +3,7 @@ import { SdkAgent } from "../../runtime/SdkAgent.js";
|
|
|
3
3
|
import { createDisclosureParam } from "../disclosure.js";
|
|
4
4
|
import { readSkill } from "../discovery/skills.js";
|
|
5
5
|
import { createLogger } from "../../shared/logger.js";
|
|
6
|
+
import { readdirSync } from "node:fs";
|
|
6
7
|
const log = createLogger();
|
|
7
8
|
const EMPTY_HINT = "(当前没有可用的 Skill,请联系用户添加)";
|
|
8
9
|
/**
|
|
@@ -40,14 +41,28 @@ export function createLoadSkillTool(skillDirs, filteredSkills) {
|
|
|
40
41
|
if (!skill) {
|
|
41
42
|
return `❌ Skill "${skillId}" 不存在,请确认名称是否正确`;
|
|
42
43
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
// 扫描 skill 目录下的文件列表
|
|
45
|
+
let fileList = "";
|
|
46
|
+
try {
|
|
47
|
+
const entries = readdirSync(skill.dirPath, { withFileTypes: true });
|
|
48
|
+
const files = entries.map((e) => {
|
|
49
|
+
const suffix = e.isDirectory() ? "/" : "";
|
|
50
|
+
return ` - ${e.name}${suffix}`;
|
|
51
|
+
});
|
|
52
|
+
fileList = `\n\nSkill 目录文件列表:\n${files.join("\n")}`;
|
|
46
53
|
}
|
|
47
|
-
|
|
48
|
-
|
|
54
|
+
catch {
|
|
55
|
+
fileList = "";
|
|
49
56
|
}
|
|
50
|
-
return
|
|
57
|
+
return [
|
|
58
|
+
`Skill "${skillId}" 已加载:`,
|
|
59
|
+
``,
|
|
60
|
+
`Skill 目录路径: ${skill.dirPath}`,
|
|
61
|
+
fileList,
|
|
62
|
+
``,
|
|
63
|
+
`--- Skill 内容开始 ---`,
|
|
64
|
+
skill.content,
|
|
65
|
+
].join("\n");
|
|
51
66
|
},
|
|
52
67
|
});
|
|
53
68
|
}
|
package/dist/config/constants.js
CHANGED
|
@@ -39,6 +39,12 @@ export const DEFAULT_SUBAGENT_DEFINITION = {
|
|
|
39
39
|
},
|
|
40
40
|
{ role: AgentNS.Role.User, content: "{{query}}" },
|
|
41
41
|
],
|
|
42
|
+
permissions: {
|
|
43
|
+
tools: { allow: ["*"] },
|
|
44
|
+
skills: { allow: ["*"] },
|
|
45
|
+
mcps: { allow: ["*"] },
|
|
46
|
+
subagents: { deny: ["*"] },
|
|
47
|
+
},
|
|
42
48
|
function: {
|
|
43
49
|
name: "general_assistant",
|
|
44
50
|
description: "通用助手,可独立完成各类任务",
|
|
@@ -122,26 +122,52 @@ export class McpConnectionManager {
|
|
|
122
122
|
? this._clientFactory()
|
|
123
123
|
: new Client({ name: "ai-zen-agents", version: "0.1.0" }, { capabilities: {} });
|
|
124
124
|
await client.connect(transport);
|
|
125
|
-
|
|
126
|
-
const
|
|
127
|
-
const promptsResult = await client.listPrompts();
|
|
125
|
+
// 根据 Server 声明的 capabilities 按需调用,避免调用未声明的方法
|
|
126
|
+
const serverCaps = client.getServerCapabilities();
|
|
128
127
|
const manifest = {
|
|
129
|
-
tools:
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
inputSchema: t.inputSchema,
|
|
133
|
-
})),
|
|
134
|
-
resources: (resourcesResult.resources ?? []).map((r) => ({
|
|
135
|
-
uri: r.uri,
|
|
136
|
-
name: r.name,
|
|
137
|
-
description: r.description,
|
|
138
|
-
mimeType: r.mimeType,
|
|
139
|
-
})),
|
|
140
|
-
prompts: (promptsResult.prompts ?? []).map((p) => ({
|
|
141
|
-
name: p.name,
|
|
142
|
-
description: p.description,
|
|
143
|
-
})),
|
|
128
|
+
tools: [],
|
|
129
|
+
resources: [],
|
|
130
|
+
prompts: [],
|
|
144
131
|
};
|
|
132
|
+
if (serverCaps?.tools) {
|
|
133
|
+
try {
|
|
134
|
+
const toolsResult = await client.listTools();
|
|
135
|
+
manifest.tools = (toolsResult.tools ?? []).map((t) => ({
|
|
136
|
+
name: t.name,
|
|
137
|
+
description: t.description ?? "",
|
|
138
|
+
inputSchema: t.inputSchema,
|
|
139
|
+
}));
|
|
140
|
+
}
|
|
141
|
+
catch (err) {
|
|
142
|
+
console.error(`[McpConnectionManager] 获取 "${name}" 工具列表失败:`, err);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
if (serverCaps?.resources) {
|
|
146
|
+
try {
|
|
147
|
+
const resourcesResult = await client.listResources();
|
|
148
|
+
manifest.resources = (resourcesResult.resources ?? []).map((r) => ({
|
|
149
|
+
uri: r.uri,
|
|
150
|
+
name: r.name,
|
|
151
|
+
description: r.description,
|
|
152
|
+
mimeType: r.mimeType,
|
|
153
|
+
}));
|
|
154
|
+
}
|
|
155
|
+
catch (err) {
|
|
156
|
+
console.error(`[McpConnectionManager] 获取 "${name}" 资源列表失败:`, err);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
if (serverCaps?.prompts) {
|
|
160
|
+
try {
|
|
161
|
+
const promptsResult = await client.listPrompts();
|
|
162
|
+
manifest.prompts = (promptsResult.prompts ?? []).map((p) => ({
|
|
163
|
+
name: p.name,
|
|
164
|
+
description: p.description,
|
|
165
|
+
}));
|
|
166
|
+
}
|
|
167
|
+
catch (err) {
|
|
168
|
+
console.error(`[McpConnectionManager] 获取 "${name}" 提示列表失败:`, err);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
145
171
|
const entry = this.servers.get(name) ?? { state: "connecting" };
|
|
146
172
|
this.servers.set(name, {
|
|
147
173
|
...entry,
|