@ai-zen/agents-sdk 0.5.1 → 0.5.2

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,11 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.5.2] - 2026-08-03
4
+
5
+ ### 🚀 新功能
6
+
7
+ - **`AgentPlugin` 新增 `onInnerLoopsStart` / `onInnerLoopsEnd` 钩子** — 对应 Core 3.2.0 的整组内循环起止钩子(一次 send 各触发一次)。`SdkAgent.send()` 在委托 `super.send()` 前后将这两个钩子包装为插件遍历调用,与单轮 `onInnerLoopStart` / `onInnerLoopEnd` 同构。插件可通过 `ctx` 拿到当前 agent、发送内容与消息快照
8
+
3
9
  ## [0.5.1] - 2026-08-03
4
10
 
5
11
  ### 🛠 优化
@@ -25,6 +25,8 @@ export interface SendContext {
25
25
  * onAfterSend: Agent.send() 返回后调用。可通过 ctx.agent 替换当前 Agent。
26
26
  * onInnerLoopStart: Agent 内循环开始前触发。由 Core Agent 在内循环中调用。
27
27
  * onInnerLoopEnd: Agent 内循环结束后触发。由 Core Agent 在内循环中调用。
28
+ * onInnerLoopsStart: Agent 整组内循环开始前触发(一次 send 仅一次)。由 Core Agent 在 run() 的 while 循环前调用。
29
+ * onInnerLoopsEnd: Agent 整组内循环结束后触发(一次 send 仅一次)。由 Core Agent 在 run() 的 while 循环后调用。
28
30
  */
29
31
  export interface AgentPlugin {
30
32
  /** Agent.init() 时调用,用于异步初始化 */
@@ -37,6 +39,10 @@ export interface AgentPlugin {
37
39
  onInnerLoopStart?(ctx: SendContext): Promise<void>;
38
40
  /** Agent 内循环结束后触发 */
39
41
  onInnerLoopEnd?(ctx: SendContext): Promise<void>;
42
+ /** Agent 整组内循环开始前触发(一次 send 仅一次) */
43
+ onInnerLoopsStart?(ctx: SendContext): Promise<void>;
44
+ /** Agent 整组内循环结束后触发(一次 send 仅一次) */
45
+ onInnerLoopsEnd?(ctx: SendContext): Promise<void>;
40
46
  }
41
47
  /**
42
48
  * SDK Agent — 继承 Core Agent,携带 SDK 层额外信息。
@@ -110,9 +110,21 @@ export class SdkAgent extends Agent {
110
110
  await plugin.onInnerLoopEnd?.(ctx);
111
111
  }
112
112
  };
113
+ this.onInnerLoopsStart = async () => {
114
+ for (const plugin of this._plugins) {
115
+ await plugin.onInnerLoopsStart?.(ctx);
116
+ }
117
+ };
118
+ this.onInnerLoopsEnd = async () => {
119
+ for (const plugin of this._plugins) {
120
+ await plugin.onInnerLoopsEnd?.(ctx);
121
+ }
122
+ };
113
123
  await super.send(content);
114
124
  this.onInnerLoopStart = undefined;
115
125
  this.onInnerLoopEnd = undefined;
126
+ this.onInnerLoopsStart = undefined;
127
+ this.onInnerLoopsEnd = undefined;
116
128
  for (const plugin of this._plugins) {
117
129
  await plugin.onAfterSend?.(ctx);
118
130
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-zen/agents-sdk",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
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",
@@ -18,7 +18,7 @@
18
18
  "dependencies": {
19
19
  "@modelcontextprotocol/sdk": "^1.29.0",
20
20
  "dayjs": "^1.11.21",
21
- "@ai-zen/agents-core": "^3.1.0"
21
+ "@ai-zen/agents-core": "^3.2.0"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@types/node": "^24.12.2",