@ai-zen/agents-sdk 1.0.0-alpha.19 → 1.0.0-alpha.20
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
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.0.0-alpha.20] - 2026-10-27
|
|
4
|
+
|
|
5
|
+
### ✨ 新增
|
|
6
|
+
|
|
7
|
+
- **`createAgent(scope, agentId, options?)` 新增第三参,把中断相关策略透传出来** —— 此前 SDK 完全没有暴露 core 的 `abortedToolRoundStrategy` / `abortedToolRoundReason`,调用方只能吃默认值。本轮一并接出三个字段(新增导出类型 `CreateAgentOptions`,`SdkAgent` 构造参数同步支持):
|
|
8
|
+
- `abortedToolRoundStrategy?: "drop" | "fill"` —— 工具轮次被中断(或结果不完整)时的归一策略(core 默认 `fill`);
|
|
9
|
+
- `abortedToolRoundReason?: string` —— `fill` 策略下未完成工具结果的填充原因;
|
|
10
|
+
- `abortedMessageStrategy?: "drop" | "keep"` —— **新增能力**:被中断的 assistant 已输出的内容 / 思考是否保留(core 默认 `drop`)。传 `keep` 后,用户中断时那半句话仍会进入下一轮上下文,模型能接着往下说,而不是「失忆重来」;带工具调用的轮次仍由 `abortedToolRoundStrategy` 决定,不受影响。
|
|
11
|
+
|
|
12
|
+
### 🔧 依赖
|
|
13
|
+
|
|
14
|
+
- 升级 `@ai-zen/agents-core` 至 `4.5.3`(新增 `abortedMessageStrategy` 与 `reconcileAbortedMessages()`)。
|
|
15
|
+
|
|
16
|
+
### ✅ 测试
|
|
17
|
+
|
|
18
|
+
- 全量 **57 文件 / 602 例通过**(6 skipped)。
|
|
19
|
+
|
|
3
20
|
## [1.0.0-alpha.19] - 2026-10-27
|
|
4
21
|
|
|
5
22
|
### 🐛 修复
|
package/dist/index.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ export { createModel } from "./runtime/createModel.js";
|
|
|
30
30
|
export { SdkAgent } from "./runtime/SdkAgent.js";
|
|
31
31
|
export type { AgentPlugin, SendContext } from "./runtime/SdkAgent.js";
|
|
32
32
|
export { createAgent } from "./runtime/createAgent.js";
|
|
33
|
+
export type { CreateAgentOptions } from "./runtime/createAgent.js";
|
|
33
34
|
export { McpConnectionManager } from "./scope/plugins/mcp/McpConnectionManager.js";
|
|
34
35
|
export type { McpConnectOptions } from "./scope/plugins/mcp/McpConnectionManager.js";
|
|
35
36
|
export { SdkCallbackTool } from "./scope/plugins/builtin/SdkCallbackTool.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type OpenAI from "openai";
|
|
2
2
|
import { Agent } from "@ai-zen/agents-core";
|
|
3
|
-
import type { AgentNS, Tool } from "@ai-zen/agents-core";
|
|
3
|
+
import type { AbortedMessageStrategy, AbortedToolRoundStrategy, AgentNS, Tool } from "@ai-zen/agents-core";
|
|
4
4
|
import type { AgentDefinition } from "../types/index.js";
|
|
5
5
|
import type { Scope } from "../scope/Scope.js";
|
|
6
6
|
export type { AgentPlugin, SendContext } from "@ai-zen/agents-core";
|
|
@@ -30,5 +30,11 @@ export declare class SdkAgent extends Agent {
|
|
|
30
30
|
messages?: AgentNS.Message[];
|
|
31
31
|
tools?: Tool[];
|
|
32
32
|
allowJsonParseError?: boolean;
|
|
33
|
+
/** 工具轮次被中断时的归一策略(core 默认 `fill`) */
|
|
34
|
+
abortedToolRoundStrategy?: AbortedToolRoundStrategy;
|
|
35
|
+
/** `fill` 策略下未完成工具结果的填充原因 */
|
|
36
|
+
abortedToolRoundReason?: string;
|
|
37
|
+
/** 被中断的 assistant(内容/思考)是否保留(core 默认 `drop`) */
|
|
38
|
+
abortedMessageStrategy?: AbortedMessageStrategy;
|
|
33
39
|
});
|
|
34
40
|
}
|
package/dist/runtime/SdkAgent.js
CHANGED
|
@@ -24,6 +24,9 @@ export class SdkAgent extends Agent {
|
|
|
24
24
|
messages: params.messages,
|
|
25
25
|
tools: params.tools,
|
|
26
26
|
allowJsonParseError: params.allowJsonParseError,
|
|
27
|
+
abortedToolRoundStrategy: params.abortedToolRoundStrategy,
|
|
28
|
+
abortedToolRoundReason: params.abortedToolRoundReason,
|
|
29
|
+
abortedMessageStrategy: params.abortedMessageStrategy,
|
|
27
30
|
});
|
|
28
31
|
this.scope = params.scope;
|
|
29
32
|
this.definition = params.definition;
|
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
import { SdkAgent } from "./SdkAgent.js";
|
|
2
2
|
import type { Scope } from "../scope/Scope.js";
|
|
3
|
+
import type { AbortedMessageStrategy, AbortedToolRoundStrategy } from "@ai-zen/agents-core";
|
|
4
|
+
/**
|
|
5
|
+
* `createAgent` 的可选行为开关(不传则全部沿用 core 默认值)。
|
|
6
|
+
*/
|
|
7
|
+
export interface CreateAgentOptions {
|
|
8
|
+
/** 工具轮次被中断(或结果不完整)时的归一策略(core 默认 `fill`) */
|
|
9
|
+
abortedToolRoundStrategy?: AbortedToolRoundStrategy;
|
|
10
|
+
/** `fill` 策略下,未完成工具结果的填充原因 */
|
|
11
|
+
abortedToolRoundReason?: string;
|
|
12
|
+
/**
|
|
13
|
+
* 被中断的 assistant 消息(已输出的内容 / 思考)如何处置(core 默认 `drop`)。
|
|
14
|
+
* 传 `keep` 可让模型在下一轮接着半截往下说,而不是忘掉自己说过什么。
|
|
15
|
+
*/
|
|
16
|
+
abortedMessageStrategy?: AbortedMessageStrategy;
|
|
17
|
+
}
|
|
3
18
|
/**
|
|
4
19
|
* 从磁盘创建 Agent。
|
|
5
20
|
*
|
|
@@ -10,4 +25,4 @@ import type { Scope } from "../scope/Scope.js";
|
|
|
10
25
|
* // agent 是 SdkAgent,可直接注册插件、发送消息
|
|
11
26
|
* ```
|
|
12
27
|
*/
|
|
13
|
-
export declare function createAgent(scope: Scope, agentId: string): Promise<SdkAgent>;
|
|
28
|
+
export declare function createAgent(scope: Scope, agentId: string, options?: CreateAgentOptions): Promise<SdkAgent>;
|
|
@@ -11,7 +11,7 @@ import { createModel } from "./createModel.js";
|
|
|
11
11
|
* // agent 是 SdkAgent,可直接注册插件、发送消息
|
|
12
12
|
* ```
|
|
13
13
|
*/
|
|
14
|
-
export async function createAgent(scope, agentId) {
|
|
14
|
+
export async function createAgent(scope, agentId, options = {}) {
|
|
15
15
|
const definition = await new AgentRepository(scope.agentsDir).read(agentId);
|
|
16
16
|
if (!definition)
|
|
17
17
|
throw new Error(`Agent "${agentId}" 不存在`);
|
|
@@ -40,6 +40,10 @@ export async function createAgent(scope, agentId) {
|
|
|
40
40
|
// 快照后,运行时改动只作用于会话副本,模板保持纯净。
|
|
41
41
|
messages: [...(definition.messages ?? [])],
|
|
42
42
|
tools,
|
|
43
|
+
// 中断相关策略:不传则由 core 取默认值(工具轮次 fill / 消息保留 drop)
|
|
44
|
+
abortedToolRoundStrategy: options.abortedToolRoundStrategy,
|
|
45
|
+
abortedToolRoundReason: options.abortedToolRoundReason,
|
|
46
|
+
abortedMessageStrategy: options.abortedMessageStrategy,
|
|
43
47
|
});
|
|
44
48
|
return agent;
|
|
45
49
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-zen/agents-sdk",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.20",
|
|
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",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"author": "LZQCN",
|
|
17
17
|
"license": "MIT",
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@ai-zen/agents-core": "^4.5.
|
|
19
|
+
"@ai-zen/agents-core": "^4.5.3",
|
|
20
20
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
21
21
|
"dayjs": "^1.11.21",
|
|
22
22
|
"openai": "^7.5.0"
|