@ai-zen/agents-sdk 0.12.0 → 1.0.0-alpha.0
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 +77 -36
- package/README.md +29 -21
- package/README.zh.md +29 -21
- package/dist/{plugin → agent-plugins}/AutoRefreshToolsPlugin.js +2 -2
- package/dist/{plugin → agent-plugins}/UnknownToolHintPlugin.d.ts +7 -5
- package/dist/{plugin → agent-plugins}/UnknownToolHintPlugin.js +9 -5
- package/dist/index.d.ts +37 -29
- package/dist/index.js +28 -21
- package/dist/runtime/SdkAgent.d.ts +5 -5
- package/dist/runtime/SdkAgent.js +4 -4
- package/dist/runtime/TaskMigrationService.d.ts +1 -1
- package/dist/runtime/TaskMigrationService.js +2 -2
- package/dist/runtime/createAgent.d.ts +4 -4
- package/dist/runtime/createAgent.js +8 -8
- package/dist/runtime/createModel.d.ts +3 -3
- package/dist/runtime/createModel.js +3 -3
- package/dist/scope/Scope.d.ts +111 -0
- package/dist/scope/Scope.js +165 -0
- package/dist/scope/ScopePlugin.d.ts +51 -0
- package/dist/scope/ScopePlugin.js +1 -0
- package/dist/scope/plugins/allInOne.d.ts +18 -0
- package/dist/scope/plugins/allInOne.js +23 -0
- package/dist/{capabilities/implements → scope/plugins}/builtin/BatchEditTool.d.ts +1 -1
- package/dist/{capabilities/implements → scope/plugins}/builtin/BatchEditTool.js +1 -1
- package/dist/scope/plugins/builtin/BuiltinToolsScopePlugin.d.ts +20 -0
- package/dist/scope/plugins/builtin/BuiltinToolsScopePlugin.js +30 -0
- package/dist/{capabilities/implements → scope/plugins}/builtin/CopyTool.d.ts +1 -1
- package/dist/{capabilities/implements → scope/plugins}/builtin/CopyTool.js +1 -1
- package/dist/{capabilities/implements → scope/plugins}/builtin/CwdTool.d.ts +1 -1
- package/dist/{capabilities/implements → scope/plugins}/builtin/CwdTool.js +1 -1
- package/dist/{capabilities/implements → scope/plugins}/builtin/DownloadFileTool.d.ts +1 -1
- package/dist/{capabilities/implements → scope/plugins}/builtin/DownloadFileTool.js +1 -1
- package/dist/{capabilities/implements → scope/plugins}/builtin/EditTool.d.ts +1 -1
- package/dist/{capabilities/implements → scope/plugins}/builtin/EditTool.js +1 -1
- package/dist/{capabilities/implements → scope/plugins}/builtin/ExecAsyncTool.d.ts +1 -1
- package/dist/{capabilities/implements → scope/plugins}/builtin/ExecAsyncTool.js +1 -1
- package/dist/{capabilities/implements → scope/plugins}/builtin/ExecTool.d.ts +1 -1
- package/dist/{capabilities/implements → scope/plugins}/builtin/ExecTool.js +1 -1
- package/dist/{capabilities/implements → scope/plugins}/builtin/ExistTool.d.ts +1 -1
- package/dist/{capabilities/implements → scope/plugins}/builtin/ExistTool.js +1 -1
- package/dist/{capabilities/implements → scope/plugins}/builtin/FindTextTool.d.ts +1 -1
- package/dist/{capabilities/implements → scope/plugins}/builtin/FindTextTool.js +1 -1
- package/dist/{capabilities/implements → scope/plugins}/builtin/GenerateImageTool.d.ts +1 -1
- package/dist/{capabilities/implements → scope/plugins}/builtin/GenerateImageTool.js +1 -1
- package/dist/{capabilities/implements → scope/plugins}/builtin/GlobTool.d.ts +1 -1
- package/dist/{capabilities/implements → scope/plugins}/builtin/GlobTool.js +1 -1
- package/dist/{capabilities/implements → scope/plugins}/builtin/InspectFileTool.d.ts +1 -1
- package/dist/{capabilities/implements → scope/plugins}/builtin/InspectFileTool.js +1 -1
- package/dist/{capabilities/implements → scope/plugins}/builtin/LsTool.d.ts +1 -1
- package/dist/{capabilities/implements → scope/plugins}/builtin/LsTool.js +1 -1
- package/dist/{capabilities/implements → scope/plugins}/builtin/MkdirTool.d.ts +1 -1
- package/dist/{capabilities/implements → scope/plugins}/builtin/MkdirTool.js +1 -1
- package/dist/{capabilities/implements → scope/plugins}/builtin/ReadFileTool.d.ts +1 -1
- package/dist/{capabilities/implements → scope/plugins}/builtin/ReadFileTool.js +1 -1
- package/dist/{capabilities/implements → scope/plugins}/builtin/RenameTool.d.ts +1 -1
- package/dist/{capabilities/implements → scope/plugins}/builtin/RenameTool.js +1 -1
- package/dist/{capabilities/implements → scope/plugins}/builtin/RmTool.d.ts +1 -1
- package/dist/{capabilities/implements → scope/plugins}/builtin/RmTool.js +1 -1
- package/dist/{runtime → scope/plugins/builtin}/SdkCallbackTool.d.ts +1 -1
- package/dist/{capabilities/implements → scope/plugins}/builtin/SleepTool.d.ts +1 -1
- package/dist/{capabilities/implements → scope/plugins}/builtin/SleepTool.js +1 -1
- package/dist/{capabilities/implements → scope/plugins}/builtin/ViewImageTool.d.ts +1 -1
- package/dist/{capabilities/implements → scope/plugins}/builtin/ViewImageTool.js +1 -1
- package/dist/{capabilities/implements → scope/plugins}/builtin/WriteFileTool.d.ts +1 -1
- package/dist/{capabilities/implements → scope/plugins}/builtin/WriteFileTool.js +1 -1
- package/dist/{capabilities/discovery/builtin.d.ts → scope/plugins/builtin/discover.d.ts} +1 -1
- package/dist/{capabilities/discovery/builtin.js → scope/plugins/builtin/discover.js} +1 -1
- package/dist/{capabilities/implements → scope/plugins}/builtin/index.d.ts +2 -2
- package/dist/{capabilities/implements → scope/plugins}/builtin/index.js +1 -1
- package/dist/{runtime → scope/plugins/mcp}/McpConnectionManager.d.ts +1 -1
- package/dist/{runtime → scope/plugins/mcp}/McpConnectionManager.js +1 -1
- package/dist/scope/plugins/mcp/McpScopePlugin.d.ts +29 -0
- package/dist/scope/plugins/mcp/McpScopePlugin.js +60 -0
- package/dist/{capabilities/discovery/mcp.d.ts → scope/plugins/mcp/discover.d.ts} +1 -1
- package/dist/{capabilities/discovery/mcp.js → scope/plugins/mcp/discover.js} +1 -1
- package/dist/{capabilities/implements → scope/plugins/mcp}/mcpTools.d.ts +2 -2
- package/dist/{capabilities/implements → scope/plugins/mcp}/mcpTools.js +2 -2
- package/dist/scope/plugins/skills/SkillsScopePlugin.d.ts +28 -0
- package/dist/scope/plugins/skills/SkillsScopePlugin.js +48 -0
- package/dist/{capabilities/discovery/skills.js → scope/plugins/skills/discover.js} +1 -1
- package/dist/{capabilities/implements → scope/plugins/skills}/skillTools.d.ts +1 -1
- package/dist/{capabilities/implements → scope/plugins/skills}/skillTools.js +3 -3
- package/dist/scope/plugins/subagents/SubAgentsScopePlugin.d.ts +20 -0
- package/dist/scope/plugins/subagents/SubAgentsScopePlugin.js +34 -0
- package/dist/{capabilities/discovery/subagents.d.ts → scope/plugins/subagents/discover.d.ts} +1 -1
- package/dist/{capabilities/implements → scope/plugins/subagents}/subAgentTools.d.ts +3 -3
- package/dist/{capabilities/implements → scope/plugins/subagents}/subAgentTools.js +5 -5
- package/dist/scope/plugins/usertools/UserToolsScopePlugin.d.ts +24 -0
- package/dist/scope/plugins/usertools/UserToolsScopePlugin.js +28 -0
- package/dist/{capabilities/discovery/usertools.js → scope/plugins/usertools/discover.js} +1 -1
- package/dist/types/index.d.ts +2 -2
- package/package.json +3 -3
- package/dist/runtime/Provider.d.ts +0 -119
- package/dist/runtime/Provider.js +0 -218
- /package/dist/{plugin → agent-plugins}/AutoMigratePlugin.d.ts +0 -0
- /package/dist/{plugin → agent-plugins}/AutoMigratePlugin.js +0 -0
- /package/dist/{plugin → agent-plugins}/AutoRefreshToolsPlugin.d.ts +0 -0
- /package/dist/{plugin → agent-plugins}/ContextGuardPlugin.d.ts +0 -0
- /package/dist/{plugin → agent-plugins}/ContextGuardPlugin.js +0 -0
- /package/dist/{capabilities → scope}/PermissionEvaluator.d.ts +0 -0
- /package/dist/{capabilities → scope}/PermissionEvaluator.js +0 -0
- /package/dist/{capabilities → scope}/disclosure.d.ts +0 -0
- /package/dist/{capabilities → scope}/disclosure.js +0 -0
- /package/dist/{runtime → scope/plugins/builtin}/SdkCallbackTool.js +0 -0
- /package/dist/{capabilities/implements → scope/plugins}/builtin/outputGuard.d.ts +0 -0
- /package/dist/{capabilities/implements → scope/plugins}/builtin/outputGuard.js +0 -0
- /package/dist/{capabilities/implements → scope/plugins}/builtin/test-helpers.d.ts +0 -0
- /package/dist/{capabilities/implements → scope/plugins}/builtin/test-helpers.js +0 -0
- /package/dist/{capabilities/discovery/skills.d.ts → scope/plugins/skills/discover.d.ts} +0 -0
- /package/dist/{capabilities/discovery/subagents.js → scope/plugins/subagents/discover.js} +0 -0
- /package/dist/{capabilities/discovery/usertools.d.ts → scope/plugins/usertools/discover.d.ts} +0 -0
package/dist/index.js
CHANGED
|
@@ -1,38 +1,45 @@
|
|
|
1
1
|
// 能力管线
|
|
2
|
-
export { PermissionEvaluator } from "./
|
|
3
|
-
export { createDisclosureParam } from "./
|
|
2
|
+
export { PermissionEvaluator } from "./scope/PermissionEvaluator.js";
|
|
3
|
+
export { createDisclosureParam } from "./scope/disclosure.js";
|
|
4
4
|
// 发现
|
|
5
|
-
export { discoverBuiltinTools } from "./
|
|
6
|
-
export { discoverSubAgents } from "./
|
|
7
|
-
export { discoverSkills, readSkill } from "./
|
|
8
|
-
export { discoverMcpServers } from "./
|
|
9
|
-
export { discoverUserTools } from "./
|
|
5
|
+
export { discoverBuiltinTools } from "./scope/plugins/builtin/discover.js";
|
|
6
|
+
export { discoverSubAgents } from "./scope/plugins/subagents/discover.js";
|
|
7
|
+
export { discoverSkills, readSkill } from "./scope/plugins/skills/discover.js";
|
|
8
|
+
export { discoverMcpServers } from "./scope/plugins/mcp/discover.js";
|
|
9
|
+
export { discoverUserTools } from "./scope/plugins/usertools/discover.js";
|
|
10
|
+
// Scope — 全局上下文 + 能力装配编排容器
|
|
11
|
+
export { Scope } from "./scope/Scope.js";
|
|
12
|
+
export { BuiltinToolsScopePlugin } from "./scope/plugins/builtin/BuiltinToolsScopePlugin.js";
|
|
13
|
+
export { UserToolsScopePlugin } from "./scope/plugins/usertools/UserToolsScopePlugin.js";
|
|
14
|
+
export { SkillsScopePlugin } from "./scope/plugins/skills/SkillsScopePlugin.js";
|
|
15
|
+
export { McpScopePlugin } from "./scope/plugins/mcp/McpScopePlugin.js";
|
|
16
|
+
export { SubAgentsScopePlugin } from "./scope/plugins/subagents/SubAgentsScopePlugin.js";
|
|
17
|
+
export { allInOne } from "./scope/plugins/allInOne.js";
|
|
10
18
|
// 配置 — ConfigManager
|
|
11
19
|
export { ConfigManager, DEFAULT_AGENT_ID, DEFAULT_AGENT_DEFINITION, DEFAULT_SUBAGENT_ID, DEFAULT_SUBAGENT_DEFINITION, DEFAULT_APP_CONFIG, DEFAULT_MCP_CONFIG, CONFIG_SUB_DIRS, } from "./config/ConfigManager.js";
|
|
12
20
|
// CRUD — 实体仓储(仅 Agent 定义等能力实体)
|
|
13
21
|
export { EntityRepository } from "./shared/EntityRepository.js";
|
|
14
22
|
export { AgentRepository } from "./crud/AgentRepository.js";
|
|
15
23
|
// 运行时
|
|
16
|
-
export { Provider } from "./runtime/Provider.js";
|
|
17
24
|
export { createModel } from "./runtime/createModel.js";
|
|
18
25
|
export { SdkAgent } from "./runtime/SdkAgent.js";
|
|
19
26
|
export { createAgent } from "./runtime/createAgent.js";
|
|
20
|
-
export { McpConnectionManager } from "./
|
|
21
|
-
export { SdkCallbackTool } from "./
|
|
27
|
+
export { McpConnectionManager } from "./scope/plugins/mcp/McpConnectionManager.js";
|
|
28
|
+
export { SdkCallbackTool } from "./scope/plugins/builtin/SdkCallbackTool.js";
|
|
22
29
|
export { TaskMigrationService } from "./runtime/TaskMigrationService.js";
|
|
23
30
|
// 插件
|
|
24
|
-
export { AutoMigratePlugin } from "./
|
|
25
|
-
export { AutoRefreshToolsPlugin } from "./
|
|
26
|
-
export { ContextGuardPlugin } from "./
|
|
27
|
-
export { UnknownToolHintPlugin } from "./
|
|
31
|
+
export { AutoMigratePlugin } from "./agent-plugins/AutoMigratePlugin.js";
|
|
32
|
+
export { AutoRefreshToolsPlugin } from "./agent-plugins/AutoRefreshToolsPlugin.js";
|
|
33
|
+
export { ContextGuardPlugin } from "./agent-plugins/ContextGuardPlugin.js";
|
|
34
|
+
export { UnknownToolHintPlugin } from "./agent-plugins/UnknownToolHintPlugin.js";
|
|
28
35
|
// 工具 — 内置工具类 + 动态工具工厂
|
|
29
|
-
export { BUILTIN_TOOL_CLASSES } from "./
|
|
30
|
-
export { CwdTool, ReadFileTool, InspectFileTool, WriteFileTool, ExecTool, MkdirTool, RmTool, GlobTool, LsTool, ExistTool, FindTextTool, DownloadFileTool, RenameTool, CopyTool, BatchEditTool, EditTool, ExecAsyncTool, SleepTool, } from "./
|
|
31
|
-
export { GenerateImageTool } from "./
|
|
32
|
-
export { ViewImageTool } from "./
|
|
33
|
-
export { createLoadSkillTool, createCallSkillSubAgentTool } from "./
|
|
34
|
-
export { createLoadMcpTool, createCallMcpTool, createReadMcpResourceTool } from "./
|
|
35
|
-
export { createSubAgentTool } from "./
|
|
36
|
+
export { BUILTIN_TOOL_CLASSES } from "./scope/plugins/builtin/index.js";
|
|
37
|
+
export { CwdTool, ReadFileTool, InspectFileTool, WriteFileTool, ExecTool, MkdirTool, RmTool, GlobTool, LsTool, ExistTool, FindTextTool, DownloadFileTool, RenameTool, CopyTool, BatchEditTool, EditTool, ExecAsyncTool, SleepTool, } from "./scope/plugins/builtin/index.js";
|
|
38
|
+
export { GenerateImageTool } from "./scope/plugins/builtin/GenerateImageTool.js";
|
|
39
|
+
export { ViewImageTool } from "./scope/plugins/builtin/ViewImageTool.js";
|
|
40
|
+
export { createLoadSkillTool, createCallSkillSubAgentTool } from "./scope/plugins/skills/skillTools.js";
|
|
41
|
+
export { createLoadMcpTool, createCallMcpTool, createReadMcpResourceTool } from "./scope/plugins/mcp/mcpTools.js";
|
|
42
|
+
export { createSubAgentTool } from "./scope/plugins/subagents/subAgentTools.js";
|
|
36
43
|
// 共享
|
|
37
44
|
export { getLogger, setLogger } from "./shared/logger.js";
|
|
38
45
|
export { SdkError, ContextOverflowError } from "./shared/errors.js";
|
|
@@ -2,14 +2,14 @@ import type OpenAI from "openai";
|
|
|
2
2
|
import { Agent } from "@ai-zen/agents-core";
|
|
3
3
|
import type { AgentNS, Tool } from "@ai-zen/agents-core";
|
|
4
4
|
import type { AgentDefinition } from "../types/index.js";
|
|
5
|
-
import type {
|
|
5
|
+
import type { Scope } from "../scope/Scope.js";
|
|
6
6
|
export type { AgentPlugin, SendContext } from "@ai-zen/agents-core";
|
|
7
7
|
/**
|
|
8
8
|
* SDK Agent — 继承 Core Agent,携带 SDK 层额外信息。
|
|
9
9
|
*
|
|
10
10
|
* Core Agent 不感知权限、文件系统等业务逻辑;
|
|
11
11
|
* SdkAgent 在 Core Agent 基础上增加了 SDK 层需要的元数据:
|
|
12
|
-
* -
|
|
12
|
+
* - scope:全局 Scope 实例
|
|
13
13
|
* - definition:Agent 原始定义(含权限 permissions)
|
|
14
14
|
*
|
|
15
15
|
* 插件能力(use / init / send 钩子分发)继承自 Core Agent,此处不再重复实现。
|
|
@@ -17,12 +17,12 @@ export type { AgentPlugin, SendContext } from "@ai-zen/agents-core";
|
|
|
17
17
|
* 权限统一从 `definition.permissions` 读取,不再单独持有。
|
|
18
18
|
*/
|
|
19
19
|
export declare class SdkAgent extends Agent {
|
|
20
|
-
/** 全局
|
|
21
|
-
readonly
|
|
20
|
+
/** 全局 Scope 实例 */
|
|
21
|
+
readonly scope: Scope;
|
|
22
22
|
/** Agent 原始定义 */
|
|
23
23
|
readonly definition: AgentDefinition;
|
|
24
24
|
constructor(params: {
|
|
25
|
-
|
|
25
|
+
scope: Scope;
|
|
26
26
|
definition: AgentDefinition;
|
|
27
27
|
client: OpenAI;
|
|
28
28
|
model: string;
|
package/dist/runtime/SdkAgent.js
CHANGED
|
@@ -4,7 +4,7 @@ import { Agent } from "@ai-zen/agents-core";
|
|
|
4
4
|
*
|
|
5
5
|
* Core Agent 不感知权限、文件系统等业务逻辑;
|
|
6
6
|
* SdkAgent 在 Core Agent 基础上增加了 SDK 层需要的元数据:
|
|
7
|
-
* -
|
|
7
|
+
* - scope:全局 Scope 实例
|
|
8
8
|
* - definition:Agent 原始定义(含权限 permissions)
|
|
9
9
|
*
|
|
10
10
|
* 插件能力(use / init / send 钩子分发)继承自 Core Agent,此处不再重复实现。
|
|
@@ -12,8 +12,8 @@ import { Agent } from "@ai-zen/agents-core";
|
|
|
12
12
|
* 权限统一从 `definition.permissions` 读取,不再单独持有。
|
|
13
13
|
*/
|
|
14
14
|
export class SdkAgent extends Agent {
|
|
15
|
-
/** 全局
|
|
16
|
-
|
|
15
|
+
/** 全局 Scope 实例 */
|
|
16
|
+
scope;
|
|
17
17
|
/** Agent 原始定义 */
|
|
18
18
|
definition;
|
|
19
19
|
constructor(params) {
|
|
@@ -25,7 +25,7 @@ export class SdkAgent extends Agent {
|
|
|
25
25
|
tools: params.tools,
|
|
26
26
|
allowJsonParseError: params.allowJsonParseError,
|
|
27
27
|
});
|
|
28
|
-
this.
|
|
28
|
+
this.scope = params.scope;
|
|
29
29
|
this.definition = params.definition;
|
|
30
30
|
}
|
|
31
31
|
}
|
|
@@ -55,7 +55,7 @@ export interface TaskMigrationServiceOptions {
|
|
|
55
55
|
*
|
|
56
56
|
* 一个服务实例对应一次迁移上下文。它**不持有**任何模型调用——生成交接文档时
|
|
57
57
|
* 默认复用传入 `agent`(`SdkAgent`)自身的 `client` / `model` / `modelConfig`,
|
|
58
|
-
* 因此无需
|
|
58
|
+
* 因此无需 Scope、无需独立「迁移 Agent」对象,也无需自建 OpenAI 客户端。
|
|
59
59
|
* 如需用不同模型生成交接文档,可在构造时显式传入 `client` / `model` / `modelConfig`,
|
|
60
60
|
* 未传则 migrate 时回退到 agent 自带的配置。
|
|
61
61
|
*
|
|
@@ -5,7 +5,7 @@ import { getLogger } from "../shared/logger.js";
|
|
|
5
5
|
*
|
|
6
6
|
* 一个服务实例对应一次迁移上下文。它**不持有**任何模型调用——生成交接文档时
|
|
7
7
|
* 默认复用传入 `agent`(`SdkAgent`)自身的 `client` / `model` / `modelConfig`,
|
|
8
|
-
* 因此无需
|
|
8
|
+
* 因此无需 Scope、无需独立「迁移 Agent」对象,也无需自建 OpenAI 客户端。
|
|
9
9
|
* 如需用不同模型生成交接文档,可在构造时显式传入 `client` / `model` / `modelConfig`,
|
|
10
10
|
* 未传则 migrate 时回退到 agent 自带的配置。
|
|
11
11
|
*
|
|
@@ -143,7 +143,7 @@ export class TaskMigrationService {
|
|
|
143
143
|
const historyText = TaskMigrationService.serializeMessages(agent.messages.filter((m) => !m.omit));
|
|
144
144
|
const messageCountBefore = agent.messages.length;
|
|
145
145
|
// 生成交接文档所用模型调用:优先使用构造时传入的 client/model/modelConfig,
|
|
146
|
-
// 未传则回退到 agent 自带的(无需
|
|
146
|
+
// 未传则回退到 agent 自带的(无需 Scope / 独立迁移 Agent)。
|
|
147
147
|
const client = this.client ?? agent.client;
|
|
148
148
|
const model = this.model ?? agent.model;
|
|
149
149
|
const modelConfig = this.modelConfig ?? agent.modelConfig;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { SdkAgent } from "./SdkAgent.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { Scope } from "../scope/Scope.js";
|
|
3
3
|
/**
|
|
4
4
|
* 从磁盘创建 Agent。
|
|
5
5
|
*
|
|
6
|
-
* 通过
|
|
6
|
+
* 通过 Scope 获取已发现的能力,读取 Agent 定义,过滤并实例化工具,产出 SdkAgent。
|
|
7
7
|
*
|
|
8
8
|
* ```ts
|
|
9
|
-
* const agent = await createAgent(
|
|
9
|
+
* const agent = await createAgent(scope, "my-agent");
|
|
10
10
|
* // agent 是 SdkAgent,可直接注册插件、发送消息
|
|
11
11
|
* ```
|
|
12
12
|
*/
|
|
13
|
-
export declare function createAgent(
|
|
13
|
+
export declare function createAgent(scope: Scope, agentId: string): Promise<SdkAgent>;
|
|
@@ -4,22 +4,22 @@ import { createModel } from "./createModel.js";
|
|
|
4
4
|
/**
|
|
5
5
|
* 从磁盘创建 Agent。
|
|
6
6
|
*
|
|
7
|
-
* 通过
|
|
7
|
+
* 通过 Scope 获取已发现的能力,读取 Agent 定义,过滤并实例化工具,产出 SdkAgent。
|
|
8
8
|
*
|
|
9
9
|
* ```ts
|
|
10
|
-
* const agent = await createAgent(
|
|
10
|
+
* const agent = await createAgent(scope, "my-agent");
|
|
11
11
|
* // agent 是 SdkAgent,可直接注册插件、发送消息
|
|
12
12
|
* ```
|
|
13
13
|
*/
|
|
14
|
-
export async function createAgent(
|
|
15
|
-
const definition = await new AgentRepository(
|
|
14
|
+
export async function createAgent(scope, agentId) {
|
|
15
|
+
const definition = await new AgentRepository(scope.agentsDir).read(agentId);
|
|
16
16
|
if (!definition)
|
|
17
17
|
throw new Error(`Agent "${agentId}" 不存在`);
|
|
18
|
-
const modelId = definition.modelId ??
|
|
18
|
+
const modelId = definition.modelId ?? scope.config.defaultModel;
|
|
19
19
|
if (!modelId)
|
|
20
20
|
throw new Error("未指定模型且无默认模型");
|
|
21
|
-
const { client, model, modelConfig } = createModel(
|
|
22
|
-
const tools =
|
|
21
|
+
const { client, model, modelConfig } = createModel(scope, modelId);
|
|
22
|
+
const tools = scope.buildTools(definition, {
|
|
23
23
|
exclude: {
|
|
24
24
|
subagents: definition.function?.name
|
|
25
25
|
? [definition.function.name]
|
|
@@ -27,7 +27,7 @@ export async function createAgent(provider, agentId) {
|
|
|
27
27
|
},
|
|
28
28
|
});
|
|
29
29
|
const agent = new SdkAgent({
|
|
30
|
-
|
|
30
|
+
scope,
|
|
31
31
|
definition,
|
|
32
32
|
client,
|
|
33
33
|
model,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import OpenAI from "openai";
|
|
2
|
-
import type {
|
|
2
|
+
import type { Scope } from "../scope/Scope.js";
|
|
3
3
|
/**
|
|
4
4
|
* Agent 模型装配结果:openai SDK client + 模型名 + 模型参数。
|
|
5
5
|
* Agent 构造时直接消费此结构。
|
|
@@ -13,9 +13,9 @@ export interface AgentModel {
|
|
|
13
13
|
modelConfig?: Record<string, unknown>;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
-
* 模型工厂 — 根据 modelId 和
|
|
16
|
+
* 模型工厂 — 根据 modelId 和 Scope 装配 openai SDK client。
|
|
17
17
|
*
|
|
18
18
|
* 端点(baseUrl / apiKey)来自 config.endpoints,发送给 API 的模型名 = modelName || id。
|
|
19
19
|
* 任何 OpenAI 兼容端点(OpenAI / 智谱 BigModel / DeepSeek 等)均可通过 baseURL 接入。
|
|
20
20
|
*/
|
|
21
|
-
export declare function createModel(
|
|
21
|
+
export declare function createModel(scope: Scope, modelId: string): AgentModel;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import OpenAI from "openai";
|
|
2
2
|
/**
|
|
3
|
-
* 模型工厂 — 根据 modelId 和
|
|
3
|
+
* 模型工厂 — 根据 modelId 和 Scope 装配 openai SDK client。
|
|
4
4
|
*
|
|
5
5
|
* 端点(baseUrl / apiKey)来自 config.endpoints,发送给 API 的模型名 = modelName || id。
|
|
6
6
|
* 任何 OpenAI 兼容端点(OpenAI / 智谱 BigModel / DeepSeek 等)均可通过 baseURL 接入。
|
|
7
7
|
*/
|
|
8
|
-
export function createModel(
|
|
9
|
-
const config =
|
|
8
|
+
export function createModel(scope, modelId) {
|
|
9
|
+
const config = scope.config;
|
|
10
10
|
const modelConfig = config.models.find((m) => m.id === modelId);
|
|
11
11
|
if (!modelConfig)
|
|
12
12
|
throw new Error(`模型 "${modelId}" 不存在`);
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import type { Tool } from "@ai-zen/agents-core";
|
|
2
|
+
import type { AppConfig, AgentDefinition, ToolEnv } from "../types/index.js";
|
|
3
|
+
import type { ScopePlugin } from "./ScopePlugin.js";
|
|
4
|
+
/**
|
|
5
|
+
* 能力过滤系统的公共类型。
|
|
6
|
+
* FilterOutput 由 filter() 产出,由 instantiate() 消费。
|
|
7
|
+
*/
|
|
8
|
+
export interface FilterOutput {
|
|
9
|
+
tools: string[];
|
|
10
|
+
subagents: string[];
|
|
11
|
+
skills: string[];
|
|
12
|
+
mcps: string[];
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* 排除项黑名单(优先级高于 permissions)。
|
|
16
|
+
* 与 permissions 四维对称,用于安全预过滤。
|
|
17
|
+
*/
|
|
18
|
+
export interface ExcludeOptions {
|
|
19
|
+
tools?: string[];
|
|
20
|
+
skills?: string[];
|
|
21
|
+
mcps?: string[];
|
|
22
|
+
subagents?: string[];
|
|
23
|
+
}
|
|
24
|
+
/** filter / buildTools 的过滤选项 */
|
|
25
|
+
export interface FilterOptions {
|
|
26
|
+
/** 排除项黑名单(优先级高于 permissions) */
|
|
27
|
+
exclude?: ExcludeOptions;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Scope — 全局上下文 + 能力装配编排容器(v1)。
|
|
31
|
+
*
|
|
32
|
+
* Scope 是 SDK 的唯一入口对象,持有:
|
|
33
|
+
* - 应用配置(端点、模型等)
|
|
34
|
+
* - 当前工作目录 cwd(相对路径解析基准,ToolEnv.cwd 的来源)
|
|
35
|
+
* - Agent 定义目录 agentsDir(createAgent 用)
|
|
36
|
+
* - 一组 ScopePlugin(能力插件)
|
|
37
|
+
*
|
|
38
|
+
* 装配方式(插件必须显式注入,Scope 不装任何默认插件):
|
|
39
|
+
* ```ts
|
|
40
|
+
* const scope = new Scope({ config, cwd, agentsDir })
|
|
41
|
+
* .use(...allInOne({ skillsPaths, toolsPaths, subAgentsPaths, mcpPaths }));
|
|
42
|
+
* await scope.init();
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* 设计原则:
|
|
46
|
+
* - Scope 只做编排:三阶段管线骨架(发现 → 过滤 → 实例化)+ 生命周期
|
|
47
|
+
* - 能力来源(内置/用户工具、Skill、MCP、SubAgent)全部疏散到 ScopePlugin,各自自持
|
|
48
|
+
* - Scope 实例一旦创建,config/cwd/agentsDir/env 不变;refresh() 只让插件重新发现
|
|
49
|
+
*/
|
|
50
|
+
export declare class Scope {
|
|
51
|
+
/** 应用配置(端点、模型等) */
|
|
52
|
+
readonly config: AppConfig;
|
|
53
|
+
/** 当前工作目录 — 相对路径解析基准,也是 ToolEnv.cwd 的来源 */
|
|
54
|
+
readonly cwd: string;
|
|
55
|
+
/** 工具环境 — 插件实例化内置工具时注入 */
|
|
56
|
+
readonly env: ToolEnv;
|
|
57
|
+
/** Agent 定义目录(createAgent 用) */
|
|
58
|
+
readonly agentsDir: string;
|
|
59
|
+
/** 已注册的插件 */
|
|
60
|
+
private _plugins;
|
|
61
|
+
/** 是否已 init(init 之后禁止再 use) */
|
|
62
|
+
private _initialized;
|
|
63
|
+
constructor(options: {
|
|
64
|
+
config: AppConfig;
|
|
65
|
+
agentsDir: string;
|
|
66
|
+
cwd?: string;
|
|
67
|
+
});
|
|
68
|
+
/** 已注册插件(只读视图) */
|
|
69
|
+
get plugins(): readonly ScopePlugin[];
|
|
70
|
+
/**
|
|
71
|
+
* 注册能力插件(链式,可变参数)。
|
|
72
|
+
*
|
|
73
|
+
* 支持两种用法:
|
|
74
|
+
* scope.use(plugin)
|
|
75
|
+
* scope.use(...allInOne({ ... })) // 展开批量注册
|
|
76
|
+
*
|
|
77
|
+
* 必须在 init() 之前调用;init() 之后再 use() 会抛错。
|
|
78
|
+
*/
|
|
79
|
+
use(...plugins: ScopePlugin[]): this;
|
|
80
|
+
/** 按 id 查找插件(供外部代码/其它插件查询插件状态) */
|
|
81
|
+
getPluginById<T extends ScopePlugin>(id: string): T | undefined;
|
|
82
|
+
/**
|
|
83
|
+
* 初始化:执行首次全局能力发现(遍历插件 discover()),随后锁定插件注册。
|
|
84
|
+
*/
|
|
85
|
+
init(): Promise<void>;
|
|
86
|
+
/**
|
|
87
|
+
* 重新执行全局发现(遍历插件 discover())。
|
|
88
|
+
*/
|
|
89
|
+
refresh(options?: {
|
|
90
|
+
silent?: boolean;
|
|
91
|
+
}): Promise<void>;
|
|
92
|
+
/**
|
|
93
|
+
* 释放:逆序调用各插件 dispose()(如 MCP 断开所有连接)。与 init() 对称。
|
|
94
|
+
*/
|
|
95
|
+
dispose(): Promise<void>;
|
|
96
|
+
/**
|
|
97
|
+
* 按权限过滤候选集,返回过滤后的名称列表。
|
|
98
|
+
* 汇总各插件 candidates() → 应用 exclude 安全预过滤 → 四维权限过滤。
|
|
99
|
+
* 纯名称操作,不涉及 Tool 实例化。
|
|
100
|
+
*/
|
|
101
|
+
filter(definition: AgentDefinition, options?: FilterOptions): FilterOutput;
|
|
102
|
+
/**
|
|
103
|
+
* 快捷方法:filter + instantiate 一步完成。
|
|
104
|
+
*/
|
|
105
|
+
buildTools(definition: AgentDefinition, options?: FilterOptions): Tool[];
|
|
106
|
+
/**
|
|
107
|
+
* 将过滤后的名称列表实例化为 Tool 数组。
|
|
108
|
+
* 遍历各插件 instantiate(),收集后去重(后注册覆盖先注册)。
|
|
109
|
+
*/
|
|
110
|
+
instantiate(filtered: FilterOutput): Tool[];
|
|
111
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { PermissionEvaluator } from "./PermissionEvaluator.js";
|
|
2
|
+
/**
|
|
3
|
+
* Scope — 全局上下文 + 能力装配编排容器(v1)。
|
|
4
|
+
*
|
|
5
|
+
* Scope 是 SDK 的唯一入口对象,持有:
|
|
6
|
+
* - 应用配置(端点、模型等)
|
|
7
|
+
* - 当前工作目录 cwd(相对路径解析基准,ToolEnv.cwd 的来源)
|
|
8
|
+
* - Agent 定义目录 agentsDir(createAgent 用)
|
|
9
|
+
* - 一组 ScopePlugin(能力插件)
|
|
10
|
+
*
|
|
11
|
+
* 装配方式(插件必须显式注入,Scope 不装任何默认插件):
|
|
12
|
+
* ```ts
|
|
13
|
+
* const scope = new Scope({ config, cwd, agentsDir })
|
|
14
|
+
* .use(...allInOne({ skillsPaths, toolsPaths, subAgentsPaths, mcpPaths }));
|
|
15
|
+
* await scope.init();
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* 设计原则:
|
|
19
|
+
* - Scope 只做编排:三阶段管线骨架(发现 → 过滤 → 实例化)+ 生命周期
|
|
20
|
+
* - 能力来源(内置/用户工具、Skill、MCP、SubAgent)全部疏散到 ScopePlugin,各自自持
|
|
21
|
+
* - Scope 实例一旦创建,config/cwd/agentsDir/env 不变;refresh() 只让插件重新发现
|
|
22
|
+
*/
|
|
23
|
+
export class Scope {
|
|
24
|
+
/** 应用配置(端点、模型等) */
|
|
25
|
+
config;
|
|
26
|
+
/** 当前工作目录 — 相对路径解析基准,也是 ToolEnv.cwd 的来源 */
|
|
27
|
+
cwd;
|
|
28
|
+
/** 工具环境 — 插件实例化内置工具时注入 */
|
|
29
|
+
env;
|
|
30
|
+
/** Agent 定义目录(createAgent 用) */
|
|
31
|
+
agentsDir;
|
|
32
|
+
/** 已注册的插件 */
|
|
33
|
+
_plugins = [];
|
|
34
|
+
/** 是否已 init(init 之后禁止再 use) */
|
|
35
|
+
_initialized = false;
|
|
36
|
+
constructor(options) {
|
|
37
|
+
this.config = options.config;
|
|
38
|
+
this.cwd = options.cwd ?? process.cwd();
|
|
39
|
+
this.env = { cwd: this.cwd, config: this.config };
|
|
40
|
+
this.agentsDir = options.agentsDir;
|
|
41
|
+
}
|
|
42
|
+
// ==================================================================
|
|
43
|
+
// 插件注册与生命周期
|
|
44
|
+
// ==================================================================
|
|
45
|
+
/** 已注册插件(只读视图) */
|
|
46
|
+
get plugins() {
|
|
47
|
+
return this._plugins;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* 注册能力插件(链式,可变参数)。
|
|
51
|
+
*
|
|
52
|
+
* 支持两种用法:
|
|
53
|
+
* scope.use(plugin)
|
|
54
|
+
* scope.use(...allInOne({ ... })) // 展开批量注册
|
|
55
|
+
*
|
|
56
|
+
* 必须在 init() 之前调用;init() 之后再 use() 会抛错。
|
|
57
|
+
*/
|
|
58
|
+
use(...plugins) {
|
|
59
|
+
if (this._initialized) {
|
|
60
|
+
throw new Error("Scope.use() 必须在 init() 之前调用");
|
|
61
|
+
}
|
|
62
|
+
for (const plugin of plugins) {
|
|
63
|
+
this._plugins.push(plugin);
|
|
64
|
+
}
|
|
65
|
+
return this;
|
|
66
|
+
}
|
|
67
|
+
/** 按 id 查找插件(供外部代码/其它插件查询插件状态) */
|
|
68
|
+
getPluginById(id) {
|
|
69
|
+
return this._plugins.find((p) => p.id === id);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* 初始化:执行首次全局能力发现(遍历插件 discover()),随后锁定插件注册。
|
|
73
|
+
*/
|
|
74
|
+
async init() {
|
|
75
|
+
await this.refresh();
|
|
76
|
+
this._initialized = true;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* 重新执行全局发现(遍历插件 discover())。
|
|
80
|
+
*/
|
|
81
|
+
async refresh(options) {
|
|
82
|
+
const opts = { silent: options?.silent ?? false };
|
|
83
|
+
for (const plugin of this._plugins) {
|
|
84
|
+
await plugin.discover?.(this, opts);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* 释放:逆序调用各插件 dispose()(如 MCP 断开所有连接)。与 init() 对称。
|
|
89
|
+
*/
|
|
90
|
+
async dispose() {
|
|
91
|
+
for (let i = this._plugins.length - 1; i >= 0; i--) {
|
|
92
|
+
await this._plugins[i].dispose?.();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
// ==================================================================
|
|
96
|
+
// 能力过滤与实例化
|
|
97
|
+
// ==================================================================
|
|
98
|
+
/**
|
|
99
|
+
* 按权限过滤候选集,返回过滤后的名称列表。
|
|
100
|
+
* 汇总各插件 candidates() → 应用 exclude 安全预过滤 → 四维权限过滤。
|
|
101
|
+
* 纯名称操作,不涉及 Tool 实例化。
|
|
102
|
+
*/
|
|
103
|
+
filter(definition, options) {
|
|
104
|
+
const exclude = options?.exclude ?? {};
|
|
105
|
+
const excludeTools = new Set(exclude.tools ?? []);
|
|
106
|
+
const excludeSkills = new Set(exclude.skills ?? []);
|
|
107
|
+
const excludeMcps = new Set(exclude.mcps ?? []);
|
|
108
|
+
const excludeSubAgents = new Set(exclude.subagents ?? []);
|
|
109
|
+
// 1. 汇总各插件候选(插件已在 candidates 内完成自身可用性判断)
|
|
110
|
+
const tools = new Set();
|
|
111
|
+
const skills = new Set();
|
|
112
|
+
const mcps = new Set();
|
|
113
|
+
const subagents = new Set();
|
|
114
|
+
for (const plugin of this._plugins) {
|
|
115
|
+
const c = plugin.candidates(this, definition);
|
|
116
|
+
c.tools?.forEach((n) => tools.add(n));
|
|
117
|
+
c.skills?.forEach((n) => skills.add(n));
|
|
118
|
+
c.mcps?.forEach((n) => mcps.add(n));
|
|
119
|
+
c.subagents?.forEach((n) => subagents.add(n));
|
|
120
|
+
}
|
|
121
|
+
// 2 + 3. exclude 预过滤 + 四维权限过滤
|
|
122
|
+
const evaluator = new PermissionEvaluator(definition.permissions);
|
|
123
|
+
const filtered = evaluator.filter({
|
|
124
|
+
tools: [...tools].filter((n) => !excludeTools.has(n)),
|
|
125
|
+
skills: [...skills].filter((n) => !excludeSkills.has(n)),
|
|
126
|
+
mcps: [...mcps].filter((n) => !excludeMcps.has(n)),
|
|
127
|
+
subagents: [...subagents].filter((n) => !excludeSubAgents.has(n)),
|
|
128
|
+
});
|
|
129
|
+
return {
|
|
130
|
+
tools: filtered.tools,
|
|
131
|
+
subagents: filtered.subagents,
|
|
132
|
+
skills: filtered.skills,
|
|
133
|
+
mcps: filtered.mcps,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* 快捷方法:filter + instantiate 一步完成。
|
|
138
|
+
*/
|
|
139
|
+
buildTools(definition, options) {
|
|
140
|
+
return this.instantiate(this.filter(definition, options));
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* 将过滤后的名称列表实例化为 Tool 数组。
|
|
144
|
+
* 遍历各插件 instantiate(),收集后去重(后注册覆盖先注册)。
|
|
145
|
+
*/
|
|
146
|
+
instantiate(filtered) {
|
|
147
|
+
const result = [];
|
|
148
|
+
for (const plugin of this._plugins) {
|
|
149
|
+
result.push(...plugin.instantiate(this, filtered));
|
|
150
|
+
}
|
|
151
|
+
return dedupTools(result);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
function dedupTools(tools) {
|
|
155
|
+
const seen = new Set();
|
|
156
|
+
const result = [];
|
|
157
|
+
for (let i = tools.length - 1; i >= 0; i--) {
|
|
158
|
+
const name = tools[i].function.name;
|
|
159
|
+
if (!seen.has(name)) {
|
|
160
|
+
seen.add(name);
|
|
161
|
+
result.unshift(tools[i]);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return result;
|
|
165
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { Tool } from "@ai-zen/agents-core";
|
|
2
|
+
import type { AgentDefinition } from "../types/index.js";
|
|
3
|
+
import type { Scope, FilterOutput } from "./Scope.js";
|
|
4
|
+
/**
|
|
5
|
+
* 插件向四维权限体系贡献的候选名称(任意子集)。
|
|
6
|
+
*/
|
|
7
|
+
export interface ScopeCandidates {
|
|
8
|
+
tools?: string[];
|
|
9
|
+
skills?: string[];
|
|
10
|
+
mcps?: string[];
|
|
11
|
+
subagents?: string[];
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* ScopePlugin — 能力插件契约(v1 核心扩展点)。
|
|
15
|
+
*
|
|
16
|
+
* 一个插件**自持一类能力**的完整生命周期:自己发现、自己持有发现结果、
|
|
17
|
+
* 自己声明候选名、自己按过滤结果实例化工具、自己负责释放。
|
|
18
|
+
* `Scope` 只做编排,不感知任何具体能力的发现状态。
|
|
19
|
+
*
|
|
20
|
+
* 与 `AgentPlugin`(core,挂在 Agent 运行时 send/loop/toolcall)不同,
|
|
21
|
+
* `ScopePlugin` 挂在**能力装配管线**(discover/filter/instantiate)。二者互不相关。
|
|
22
|
+
*
|
|
23
|
+
* 生命周期与三阶段管线的对应:
|
|
24
|
+
* discover —— 阶段 1 · 发现
|
|
25
|
+
* candidates —— 阶段 2 · 候选(供权限过滤)
|
|
26
|
+
* instantiate —— 阶段 3 · 实例化
|
|
27
|
+
* dispose —— 释放
|
|
28
|
+
*/
|
|
29
|
+
export interface ScopePlugin {
|
|
30
|
+
/** 唯一标识,如 "builtin" / "user-tools" / "skills" / "mcp" / "subagents" */
|
|
31
|
+
readonly id: string;
|
|
32
|
+
/**
|
|
33
|
+
* 阶段 1 · 发现:扫描来源、刷新自身状态(每次内部重新扫描,不跨 refresh 累积)。
|
|
34
|
+
* 相对路径应在此基于 `scope.cwd` 解析。
|
|
35
|
+
*/
|
|
36
|
+
discover?(scope: Scope, options: {
|
|
37
|
+
silent?: boolean;
|
|
38
|
+
}): Promise<void> | void;
|
|
39
|
+
/**
|
|
40
|
+
* 阶段 2 · 候选:返回本插件向四维贡献的候选名。
|
|
41
|
+
* 可结合 `definition` 做可用性判断(如内置工具的 isAvailable)。同步返回。
|
|
42
|
+
*/
|
|
43
|
+
candidates(scope: Scope, definition: AgentDefinition): ScopeCandidates;
|
|
44
|
+
/**
|
|
45
|
+
* 阶段 3 · 实例化:按过滤后的允许名产出 Tool 实例。
|
|
46
|
+
* `filtered` 为 `Scope.filter()` 的产物(四维允许名)。
|
|
47
|
+
*/
|
|
48
|
+
instantiate(scope: Scope, filtered: FilterOutput): Tool[];
|
|
49
|
+
/** 可选 · 释放:逆序于注册顺序调用。如 MCP 断开所有连接。 */
|
|
50
|
+
dispose?(): Promise<void> | void;
|
|
51
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ScopePlugin } from "../ScopePlugin.js";
|
|
2
|
+
/** allInOne 的装配选项:各类能力来源的路径(绝对或相对 scope.cwd) */
|
|
3
|
+
export interface AllInOneOptions {
|
|
4
|
+
skillsPaths?: string[];
|
|
5
|
+
toolsPaths?: string[];
|
|
6
|
+
subAgentsPaths?: string[];
|
|
7
|
+
mcpPaths?: string[];
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* 标准能力插件工厂 —— 恒返回 5 个标准插件("全家桶")。
|
|
11
|
+
*
|
|
12
|
+
* 顺序即优先级(去重时后注册覆盖先注册):
|
|
13
|
+
* builtin → user-tools → skills → mcp → subagents
|
|
14
|
+
* 因此用户工具可覆盖同名内置工具(与 v0 一致)。
|
|
15
|
+
*
|
|
16
|
+
* 想裁剪/替换某一类,改用手工逐个 `new XxxScopePlugin(...)` 后 `.use()`。
|
|
17
|
+
*/
|
|
18
|
+
export declare function allInOne(options?: AllInOneOptions): ScopePlugin[];
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { BuiltinToolsScopePlugin } from "./builtin/BuiltinToolsScopePlugin.js";
|
|
2
|
+
import { UserToolsScopePlugin } from "./usertools/UserToolsScopePlugin.js";
|
|
3
|
+
import { SkillsScopePlugin } from "./skills/SkillsScopePlugin.js";
|
|
4
|
+
import { McpScopePlugin } from "./mcp/McpScopePlugin.js";
|
|
5
|
+
import { SubAgentsScopePlugin } from "./subagents/SubAgentsScopePlugin.js";
|
|
6
|
+
/**
|
|
7
|
+
* 标准能力插件工厂 —— 恒返回 5 个标准插件("全家桶")。
|
|
8
|
+
*
|
|
9
|
+
* 顺序即优先级(去重时后注册覆盖先注册):
|
|
10
|
+
* builtin → user-tools → skills → mcp → subagents
|
|
11
|
+
* 因此用户工具可覆盖同名内置工具(与 v0 一致)。
|
|
12
|
+
*
|
|
13
|
+
* 想裁剪/替换某一类,改用手工逐个 `new XxxScopePlugin(...)` 后 `.use()`。
|
|
14
|
+
*/
|
|
15
|
+
export function allInOne(options) {
|
|
16
|
+
return [
|
|
17
|
+
new BuiltinToolsScopePlugin(),
|
|
18
|
+
new UserToolsScopePlugin({ paths: options?.toolsPaths }),
|
|
19
|
+
new SkillsScopePlugin({ paths: options?.skillsPaths }),
|
|
20
|
+
new McpScopePlugin({ paths: options?.mcpPaths }),
|
|
21
|
+
new SubAgentsScopePlugin({ paths: options?.subAgentsPaths }),
|
|
22
|
+
];
|
|
23
|
+
}
|