@ai-zen/agents-sdk 1.2.0-alpha.2 → 2.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 +20 -0
- package/README.md +3 -3
- package/README.zh.md +3 -3
- package/dist/agent-plugins/AutoMigratePlugin.d.ts +34 -5
- package/dist/agent-plugins/AutoMigratePlugin.js +56 -7
- package/dist/agent-plugins/AutoRefreshToolsPlugin.d.ts +8 -5
- package/dist/agent-plugins/AutoRefreshToolsPlugin.js +5 -6
- package/dist/agent-plugins/ContextGuardPlugin.d.ts +15 -3
- package/dist/agent-plugins/ContextGuardPlugin.js +16 -2
- package/dist/agent-plugins/SubAgentGuardInstallerPlugin.d.ts +18 -16
- package/dist/agent-plugins/SubAgentGuardInstallerPlugin.js +16 -14
- package/dist/agent-plugins/UnknownToolHintPlugin.d.ts +12 -3
- package/dist/agent-plugins/UnknownToolHintPlugin.js +16 -4
- package/dist/index.d.ts +5 -2
- package/dist/index.js +3 -0
- package/dist/runtime/HandoffGuardPlugin.d.ts +7 -5
- package/dist/runtime/HandoffGuardPlugin.js +8 -6
- package/dist/runtime/HandoffService.d.ts +51 -12
- package/dist/runtime/HandoffService.js +112 -19
- package/dist/runtime/SdkAgent.d.ts +2 -3
- package/dist/runtime/SdkAgent.js +1 -2
- package/dist/scope/Scope.d.ts +35 -8
- package/dist/scope/Scope.js +50 -11
- package/dist/scope/plugins/mcp/McpConnectionManager.d.ts +7 -0
- package/dist/scope/plugins/mcp/McpConnectionManager.js +7 -0
- package/dist/scope/plugins/mcp/McpScopePlugin.d.ts +23 -0
- package/dist/scope/plugins/mcp/McpScopePlugin.js +68 -1
- package/dist/scope/plugins/peers/PeerSessionsScopePlugin.d.ts +28 -0
- package/dist/scope/plugins/peers/PeerSessionsScopePlugin.js +35 -0
- package/dist/scope/plugins/peers/peerSessionTools.d.ts +122 -0
- package/dist/scope/plugins/peers/peerSessionTools.js +266 -0
- package/dist/scope/plugins/skills/skillTools.d.ts +1 -1
- package/dist/scope/plugins/skills/skillTools.js +6 -2
- package/dist/scope/plugins/subagents/subAgentTools.js +3 -0
- package/dist/shared/errors.d.ts +10 -3
- package/dist/shared/errors.js +10 -3
- package/dist/types/index.d.ts +6 -4
- package/package.json +2 -2
package/dist/shared/errors.d.ts
CHANGED
|
@@ -7,12 +7,19 @@ export declare class SdkError extends Error {
|
|
|
7
7
|
constructor(code: string, message: string, cause?: Error);
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
|
-
* 上下文超限错误。由 ContextGuardPlugin
|
|
10
|
+
* 上下文超限错误。由 ContextGuardPlugin 在请求前**用来拼拒绝理由**。
|
|
11
|
+
*
|
|
12
|
+
* 注意:它现在不再被抛出。core 重写之后,钩子里的异常会穿到 `start()` 外面把整个循环
|
|
13
|
+
* 打死(agent 变成僵尸),所以护栏改成「返回字符串 = 拒这一圈」(`onInnerLoopStart`),
|
|
14
|
+
* 理由那句文案就来自这个类的 `message`。结构化字段(用量 / 阈值)**没有通道交出去**——
|
|
15
|
+
* 拒绝理由只有字符串这一种形状;宿主若必须按数字渲染文案,需要 core 提供带结构载荷的
|
|
16
|
+
* `denied`。
|
|
17
|
+
*
|
|
11
18
|
* 触发条件通常是上下文 token 用量超过硬线(如读入超大文件),
|
|
12
|
-
*
|
|
19
|
+
* 继续对话已无意义且会持续放大费用/延迟,故由上层向用户显式报错。
|
|
13
20
|
*/
|
|
14
21
|
export declare class ContextOverflowError extends Error {
|
|
15
|
-
/**
|
|
22
|
+
/** 触发拦截时的用量(usage.prompt_tokens) */
|
|
16
23
|
readonly promptTokens: number;
|
|
17
24
|
/** 被越过的强行阻断阈值(`tokenThresholds.guard`,绝对值) */
|
|
18
25
|
readonly guardTokens: number;
|
package/dist/shared/errors.js
CHANGED
|
@@ -14,12 +14,19 @@ export class SdkError extends Error {
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
|
-
* 上下文超限错误。由 ContextGuardPlugin
|
|
17
|
+
* 上下文超限错误。由 ContextGuardPlugin 在请求前**用来拼拒绝理由**。
|
|
18
|
+
*
|
|
19
|
+
* 注意:它现在不再被抛出。core 重写之后,钩子里的异常会穿到 `start()` 外面把整个循环
|
|
20
|
+
* 打死(agent 变成僵尸),所以护栏改成「返回字符串 = 拒这一圈」(`onInnerLoopStart`),
|
|
21
|
+
* 理由那句文案就来自这个类的 `message`。结构化字段(用量 / 阈值)**没有通道交出去**——
|
|
22
|
+
* 拒绝理由只有字符串这一种形状;宿主若必须按数字渲染文案,需要 core 提供带结构载荷的
|
|
23
|
+
* `denied`。
|
|
24
|
+
*
|
|
18
25
|
* 触发条件通常是上下文 token 用量超过硬线(如读入超大文件),
|
|
19
|
-
*
|
|
26
|
+
* 继续对话已无意义且会持续放大费用/延迟,故由上层向用户显式报错。
|
|
20
27
|
*/
|
|
21
28
|
export class ContextOverflowError extends Error {
|
|
22
|
-
/**
|
|
29
|
+
/** 触发拦截时的用量(usage.prompt_tokens) */
|
|
23
30
|
promptTokens;
|
|
24
31
|
/** 被越过的强行阻断阈值(`tokenThresholds.guard`,绝对值) */
|
|
25
32
|
guardTokens;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -82,10 +82,11 @@ export interface Endpoint {
|
|
|
82
82
|
* 上下文用量阈值 —— 与模型的真实窗口无关,只描述「用量到了这条线该怎么办」。
|
|
83
83
|
*
|
|
84
84
|
* 两个阈值语义不同,消费方也不同:
|
|
85
|
-
* - `handoff`:软线。`AutoMigratePlugin`
|
|
85
|
+
* - `handoff`:软线。`AutoMigratePlugin` 在 agent 闲下来之后拿 `usage.prompt_tokens` 比它,
|
|
86
86
|
* 超过即触发任务交接(交接本身还要再发 1~2 次请求,所以这条线必须留足余量)。
|
|
87
|
-
* - `guard`:硬线。`ContextGuardPlugin`
|
|
88
|
-
* `
|
|
87
|
+
* - `guard`:硬线。`ContextGuardPlugin` 在**每次请求前**比它,超过即**拒这一圈**
|
|
88
|
+
* (`onInnerLoopStart` 返回理由 → core 报 `denied`,这一轮压根没发出去)——
|
|
89
|
+
* 这是最后一道保护,宁可报错也不要发出必然失败的请求。
|
|
89
90
|
*
|
|
90
91
|
* 建议 `guard ≈ handoff × 1.5`,给交接留出缓冲;两者都是绝对值,配置里写多少就是多少,
|
|
91
92
|
* 不做任何倍数换算(阈值就该是能直接读懂的数字)。
|
|
@@ -268,7 +269,8 @@ export interface AppConfig {
|
|
|
268
269
|
*
|
|
269
270
|
* - `inner-loop-start`:`onInnerLoopStart`,**每次请求前**刷(每次工具回合都能看见新装的
|
|
270
271
|
* 能力)。**出厂默认**;
|
|
271
|
-
* - `outer-loop-start`:`
|
|
272
|
+
* - `outer-loop-start`:`onOuterLoopStart`,每一批事件开头刷一次(一圈一次),
|
|
273
|
+
* 要等下一轮才生效,开销最小;
|
|
272
274
|
* - `off`:不刷,只靠 `/reload`。
|
|
273
275
|
*
|
|
274
276
|
* 缺省(`undefined`)按 `inner-loop-start` 算 —— 装配方读它时不要写「undefined 就不装」。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-zen/agents-sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-alpha.0",
|
|
4
4
|
"description": "AI-Zen Agents SDK — shared business logic for CLI and Desktop",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"author": "LZQCN",
|
|
26
26
|
"license": "MIT",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@ai-zen/agents-core": "^
|
|
28
|
+
"@ai-zen/agents-core": "^5.0.0-alpha.0",
|
|
29
29
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
30
30
|
"openai": "^7.5.0"
|
|
31
31
|
},
|