@ai-zen/agents-sdk 1.2.0-alpha.1 → 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.
Files changed (40) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +3 -3
  3. package/README.zh.md +3 -3
  4. package/dist/agent-plugins/AutoMigratePlugin.d.ts +34 -5
  5. package/dist/agent-plugins/AutoMigratePlugin.js +56 -7
  6. package/dist/agent-plugins/AutoRefreshToolsPlugin.d.ts +8 -5
  7. package/dist/agent-plugins/AutoRefreshToolsPlugin.js +5 -6
  8. package/dist/agent-plugins/ContextGuardPlugin.d.ts +15 -3
  9. package/dist/agent-plugins/ContextGuardPlugin.js +16 -2
  10. package/dist/agent-plugins/SubAgentGuardInstallerPlugin.d.ts +18 -16
  11. package/dist/agent-plugins/SubAgentGuardInstallerPlugin.js +16 -14
  12. package/dist/agent-plugins/UnknownToolHintPlugin.d.ts +12 -3
  13. package/dist/agent-plugins/UnknownToolHintPlugin.js +16 -4
  14. package/dist/config/ConfigManager.d.ts +21 -16
  15. package/dist/config/ConfigManager.js +47 -25
  16. package/dist/index.d.ts +5 -2
  17. package/dist/index.js +3 -0
  18. package/dist/runtime/HandoffGuardPlugin.d.ts +7 -5
  19. package/dist/runtime/HandoffGuardPlugin.js +8 -6
  20. package/dist/runtime/HandoffService.d.ts +51 -12
  21. package/dist/runtime/HandoffService.js +112 -19
  22. package/dist/runtime/SdkAgent.d.ts +2 -3
  23. package/dist/runtime/SdkAgent.js +1 -2
  24. package/dist/scope/Scope.d.ts +35 -8
  25. package/dist/scope/Scope.js +50 -11
  26. package/dist/scope/plugins/mcp/McpConnectionManager.d.ts +7 -0
  27. package/dist/scope/plugins/mcp/McpConnectionManager.js +7 -0
  28. package/dist/scope/plugins/mcp/McpScopePlugin.d.ts +23 -0
  29. package/dist/scope/plugins/mcp/McpScopePlugin.js +68 -1
  30. package/dist/scope/plugins/peers/PeerSessionsScopePlugin.d.ts +28 -0
  31. package/dist/scope/plugins/peers/PeerSessionsScopePlugin.js +35 -0
  32. package/dist/scope/plugins/peers/peerSessionTools.d.ts +122 -0
  33. package/dist/scope/plugins/peers/peerSessionTools.js +266 -0
  34. package/dist/scope/plugins/skills/skillTools.d.ts +1 -1
  35. package/dist/scope/plugins/skills/skillTools.js +6 -2
  36. package/dist/scope/plugins/subagents/subAgentTools.js +3 -0
  37. package/dist/shared/errors.d.ts +10 -3
  38. package/dist/shared/errors.js +10 -3
  39. package/dist/types/index.d.ts +6 -4
  40. package/package.json +2 -2
@@ -0,0 +1,266 @@
1
+ import { CallbackTool } from "@ai-zen/agents-core";
2
+ /**
3
+ * 平级会话(peer session)的三个工具 —— **只负责把模型的话翻译成端口调用**。
4
+ *
5
+ * 端口({@link PeerSessionPort})由宿主实现:开一段会话、开跑、之后接着跟它说话、跑完把结果投回
6
+ * 发起者,全都是宿主的事(会话是宿主的财产,SDK 不认识会话)。SDK 这一侧只有三件东西:参数说明,
7
+ * 以及**给模型看的那几句话**(结果会自动推回来别轮询;接着发的话排在哪;记不住 `sessionId` 就靠
8
+ * `label`)。
9
+ *
10
+ * 为什么这几句话必须同时出现在 description 与返回文案两处:模型只读它拿到的东西 —— 第一次只看
11
+ * 得到 description,之后每次调用只看得到返回值。少写一处,模型就会开始忙等轮询
12
+ * (`read_session_status` 一个接一个),而每轮轮询都要烧一次模型调用。
13
+ */
14
+ /** `create_session`:开一段平级会话,受理即回 */
15
+ export const CREATE_SESSION_TOOL = "create_session";
16
+ /** `read_session_status`:只问状态 + 一条摘要,绝不返回全量消息 */
17
+ export const READ_SESSION_STATUS_TOOL = "read_session_status";
18
+ /** `send_to_session`:继续跟已经存在的那段平级会话说一句(不等结果) */
19
+ export const SEND_TO_SESSION_TOOL = "send_to_session";
20
+ /** 本插件向 `tools` 维度贡献的候选名(顺序即展示顺序) */
21
+ export const PEER_SESSION_TOOL_NAMES = [
22
+ CREATE_SESSION_TOOL,
23
+ READ_SESSION_STATUS_TOOL,
24
+ SEND_TO_SESSION_TOOL,
25
+ ];
26
+ /** ① 结果会自动推回来、别轮询;② 记不住 `sessionId` 就靠 `label` */
27
+ const CREATE_HINT = "The result of this session is pushed back to me automatically when it settles — that push " +
28
+ "wakes me up, so do not poll it (and do not call read_session_status in a loop). Keep `label` " +
29
+ "next to `sessionId`: if I forget the id later, `label` is how I name this session.";
30
+ /** 拒绝各自的一句话:说清「为什么」与「接下来能做什么」(宿主没给 hint 时用它) */
31
+ const REJECT_HINTS = {
32
+ depth_exceeded: "This conversation is itself a peer session, and peer sessions cannot open further peer " +
33
+ "sessions (one level only). Do the work here instead, or report back and let the conversation " +
34
+ "that started this one spawn it.",
35
+ model_unresolved: "No model could be resolved for that peer session (no session override, no modelId on the " +
36
+ "agent definition, no global default model). Pass `modelId`, or pass an `agentId` that has a " +
37
+ "model bound.",
38
+ too_many_peers: "This conversation already has the maximum number of peer sessions running at the same time. " +
39
+ "Wait for some of them to finish (their results are pushed back to me automatically), or give " +
40
+ "the work to fewer sessions instead of opening another one.",
41
+ };
42
+ /**
43
+ * `send_to_session` 被拒绝的两种原因各自的一句话(端口只回原因,不给文案)。
44
+ *
45
+ * `gone` 要说清「不会再有回音」(否则模型会等一条永远不会到的结果),`not_allowed` 要说清
46
+ * 「自己把活干掉」,两者都不建议重试。
47
+ */
48
+ const SEND_REJECT_HINTS = {
49
+ gone: "There is no record of this session any more: it was deleted, or the host restarted and that " +
50
+ "in-process record is gone (it is now an ordinary conversation that still shows up in the " +
51
+ "session list). Nothing was sent and no result will arrive — do the work here instead.",
52
+ not_allowed: "That session is not related to this one: only a conversation and the peer sessions it " +
53
+ "started can talk to each other, and peer sessions cannot message each other. Nothing was " +
54
+ "sent — handle it here, or report back and let the conversation that started this one relay.",
55
+ };
56
+ /**
57
+ * `send_to_session` 成功时每个 `state` 一句给模型的话。
58
+ *
59
+ * 三句必须都在(少一句模型就会开始忙等,或者记不住是哪段会话):
60
+ * ① 对方在跑 → 这一条排在它这一轮末尾;对方空闲 → 这一条会把它叫起来;
61
+ * ② **不要等结果**,跑完会自动推回来;
62
+ * ③ 记不住 `sessionId` 就靠 `label` 认。
63
+ * 「排在末尾 / 叫起来 / 先攒着」只差头一句,后两句三支一模一样。
64
+ */
65
+ const SEND_TAIL = "Do not wait for a result: this message does not come back here, the result of that session " +
66
+ "is pushed back to me automatically when it settles and that push wakes me up. If I forget the " +
67
+ "`sessionId`, the `label` returned by create_session is how I name this session.";
68
+ function sendHint(state) {
69
+ switch (state) {
70
+ case "running":
71
+ return ("It is running, so this message waits in line and is picked up at the end of its current " +
72
+ `turn. ${SEND_TAIL}`);
73
+ case "idle":
74
+ return `It was idle, so this message wakes it up and it starts a new turn. ${SEND_TAIL}`;
75
+ case "settling":
76
+ return ("It is finishing its current turn, so this message is held and delivered as soon as that " +
77
+ `turn settles. ${SEND_TAIL}`);
78
+ }
79
+ }
80
+ /** 每个状态一句给模型的话(同样带着「别轮询」与「靠 label」两句) */
81
+ function statusHint(state) {
82
+ switch (state) {
83
+ case "running":
84
+ return ("It is still running. Its result will be pushed to me automatically when it settles — do " +
85
+ "not poll it. If I forget the `sessionId`, the `label` identifies this session.");
86
+ case "idle":
87
+ return ("It finished and its result was already pushed to me automatically. Do not poll it again. " +
88
+ "If I forget the `sessionId`, the `label` identifies this session.");
89
+ case "failed":
90
+ case "aborted":
91
+ return ("It stopped without finishing; the result (including why it stopped) was already pushed " +
92
+ "to me automatically. Do not poll it again. If I forget the `sessionId`, the `label` " +
93
+ "identifies this session.");
94
+ case "gone":
95
+ return ("There is no record of this session any more: it was deleted, or the host restarted and " +
96
+ "that in-process record is gone (in that case it is now an ordinary conversation that " +
97
+ "still shows up in the session list). Do not wait for a result that will never arrive; if " +
98
+ "I only remember the `label`, that session can no longer be looked up by it.");
99
+ }
100
+ }
101
+ /**
102
+ * 造三个工具(顺序即返回顺序)。
103
+ *
104
+ * 三个工具都是即时返回的 `CallbackTool`:真正的等待在宿主那一侧(子会话自己跑)。
105
+ */
106
+ export function createPeerSessionTools(port) {
107
+ return [createSessionTool(port), readSessionStatusTool(port), sendToSessionTool(port)];
108
+ }
109
+ /** `create_session({ prompt, agentId?, modelId?, label? })` → `{ sessionId, label }` */
110
+ function createSessionTool(port) {
111
+ return new CallbackTool({
112
+ function: {
113
+ name: CREATE_SESSION_TOOL,
114
+ description: [
115
+ "Open a PEER SESSION: a separate, full conversation with its own agent that works on",
116
+ "`prompt` in parallel with me (own context, own usage, and it stays readable in the",
117
+ "session list afterwards). Use it for work that can happen alongside this conversation",
118
+ "instead of blocking it.",
119
+ "This call returns as soon as the session is accepted — it does NOT wait for the work to",
120
+ "finish, so do not expect the result here.",
121
+ "The result is pushed back to me automatically when that session settles, and that push",
122
+ "wakes me up so I can carry on: do not poll it repeatedly.",
123
+ "Remember the returned `label` as well as `sessionId`: in a long conversation I may no",
124
+ "longer recall the id, and the label is how I refer to this session.",
125
+ ].join(" "),
126
+ parameters: {
127
+ type: "object",
128
+ properties: {
129
+ prompt: {
130
+ type: "string",
131
+ description: "What that session should do. Write it as a self-contained task: the peer session " +
132
+ "starts from an empty context and cannot see this conversation.",
133
+ },
134
+ agentId: {
135
+ type: "string",
136
+ description: "Agent (by id) that runs the peer session (optional, defaults to the agent of this " +
137
+ "conversation)",
138
+ },
139
+ modelId: {
140
+ type: "string",
141
+ description: "Model id for the peer session (optional, defaults to the usual resolution: session " +
142
+ "> agent definition > global default)",
143
+ },
144
+ label: {
145
+ type: "string",
146
+ description: 'Short readable name for this session (optional, e.g. "run the tests"). It is what ' +
147
+ "the pushed-back result says and what read_session_status shows.",
148
+ },
149
+ },
150
+ required: ["prompt"],
151
+ additionalProperties: false,
152
+ },
153
+ },
154
+ callback: async (input, ctx) => {
155
+ const created = await port.create({
156
+ caller: ctx.agent,
157
+ prompt: typeof input.prompt === "string" ? input.prompt : String(input.prompt ?? ""),
158
+ ...optionalString("agentId", input.agentId),
159
+ ...optionalString("modelId", input.modelId),
160
+ ...optionalString("label", input.label),
161
+ });
162
+ // 结构化拒绝:模型能按字段分支,不用去读自由文本(宿主没给 hint 时用 SDK 这一份)
163
+ if (!created.ok)
164
+ return { rejected: created.reason, hint: created.hint ?? REJECT_HINTS[created.reason] };
165
+ return { sessionId: created.sessionId, label: created.label, hint: CREATE_HINT };
166
+ },
167
+ });
168
+ }
169
+ /** `read_session_status({ sessionId })` → `{ state, label?, startedAt?, lastMessage?, hint }` */
170
+ function readSessionStatusTool(port) {
171
+ return new CallbackTool({
172
+ function: {
173
+ name: READ_SESSION_STATUS_TOOL,
174
+ description: [
175
+ "Check a peer session created earlier: its state (running / idle / failed / aborted /",
176
+ "gone) plus a short digest of its last assistant message — never the full conversation,",
177
+ "so do not use it to fetch results or context.",
178
+ "The result is pushed back to me automatically when that session settles and that push",
179
+ "wakes me up: this tool is for a single check (is it still running? is it gone?), not for",
180
+ "polling in a loop.",
181
+ "If I no longer remember the `sessionId`, the `label` returned by create_session is what",
182
+ "identifies the session — it comes back in the answer, so I can tell them apart.",
183
+ ].join(" "),
184
+ parameters: {
185
+ type: "object",
186
+ properties: {
187
+ sessionId: {
188
+ type: "string",
189
+ description: "The sessionId returned by create_session (that id is also the conversation id of " +
190
+ "that session)",
191
+ },
192
+ },
193
+ required: ["sessionId"],
194
+ additionalProperties: false,
195
+ },
196
+ },
197
+ callback: async (input, ctx) => {
198
+ const status = await port.status({
199
+ caller: ctx.agent,
200
+ sessionId: typeof input.sessionId === "string" ? input.sessionId : "",
201
+ });
202
+ // 键的出现与否本身就是信息:`label` / `startedAt` / `lastMessage` 拿不到就不出现
203
+ return {
204
+ state: status.state,
205
+ ...(status.label === undefined ? {} : { label: status.label }),
206
+ ...(status.startedAt === undefined ? {} : { startedAt: status.startedAt }),
207
+ ...(status.lastMessage === undefined ? {} : { lastMessage: status.lastMessage }),
208
+ hint: statusHint(status.state),
209
+ };
210
+ },
211
+ });
212
+ }
213
+ /** `send_to_session({ sessionId, content })` → `{ accepted, state }` / `{ rejected, hint }` */
214
+ function sendToSessionTool(port) {
215
+ return new CallbackTool({
216
+ function: {
217
+ name: SEND_TO_SESSION_TOOL,
218
+ description: [
219
+ "Send another message to a PEER SESSION created earlier by create_session — it is how I",
220
+ "carry on with that session instead of starting a new one.",
221
+ "If that session is running, this message is queued and picked up at the end of its",
222
+ "current turn; if it is idle, this message wakes it up and it starts a new turn. Either",
223
+ "way the call returns immediately.",
224
+ "Do not wait for a result here: this message does not come back, and the result of that",
225
+ "session is pushed back to me automatically when it settles (that push wakes me up), so do",
226
+ "not poll it.",
227
+ "If I no longer remember the `sessionId`, the `label` returned by create_session is how I",
228
+ "identify that session.",
229
+ ].join(" "),
230
+ parameters: {
231
+ type: "object",
232
+ properties: {
233
+ sessionId: {
234
+ type: "string",
235
+ description: "The sessionId returned by create_session (that id is also the conversation id of " +
236
+ "that session)",
237
+ },
238
+ content: {
239
+ type: "string",
240
+ description: "What to say to that session. Write it as a self-contained instruction: it cannot " +
241
+ "see this conversation, it only has its own history.",
242
+ },
243
+ },
244
+ required: ["sessionId", "content"],
245
+ additionalProperties: false,
246
+ },
247
+ },
248
+ callback: async (input, ctx) => {
249
+ const sent = await port.send({
250
+ caller: ctx.agent,
251
+ sessionId: typeof input.sessionId === "string" ? input.sessionId : "",
252
+ content: typeof input.content === "string" ? input.content : String(input.content ?? ""),
253
+ });
254
+ // 结构化拒绝:模型能按字段分支,不用去读自由文本
255
+ if (!sent.ok)
256
+ return { rejected: sent.reason, hint: SEND_REJECT_HINTS[sent.reason] };
257
+ return { accepted: true, state: sent.state, hint: sendHint(sent.state) };
258
+ },
259
+ });
260
+ }
261
+ /** 可选的字符串参数:空串与非字符串都当作「没给」,不往端口里塞一个假值 */
262
+ function optionalString(key, value) {
263
+ if (typeof value !== "string" || value.length === 0)
264
+ return {};
265
+ return { [key]: value };
266
+ }
@@ -10,7 +10,7 @@ export declare function createLoadSkillTool(skillDirs: string[], filteredSkills:
10
10
  * 只展示 subAgent: true 的 Skill,枚举中自动排除不支持子 Agent 模式的 skill。
11
11
  *
12
12
  * 工具由 AgentToolLazy 承载:子 Agent 在 exec 时构建,从而复用统一的委派边界
13
- * (onSubAgentStart / onSubAgentEnd 钩子与 sub-agent-start / sub-agent-end 事件)。
13
+ * (onSubAgentStart / onSubAgentEnd 钩子与 subAgentStarted / subAgentFinished 事件)。
14
14
  * 子 Agent 沿用父 Agent 的工具能力(不做权限过滤),但剔除 call_skill_sub_agent 自身,
15
15
  * 避免 skill 链式自递归。
16
16
  */
@@ -75,7 +75,7 @@ export function createLoadSkillTool(skillDirs, filteredSkills) {
75
75
  * 只展示 subAgent: true 的 Skill,枚举中自动排除不支持子 Agent 模式的 skill。
76
76
  *
77
77
  * 工具由 AgentToolLazy 承载:子 Agent 在 exec 时构建,从而复用统一的委派边界
78
- * (onSubAgentStart / onSubAgentEnd 钩子与 sub-agent-start / sub-agent-end 事件)。
78
+ * (onSubAgentStart / onSubAgentEnd 钩子与 subAgentStarted / subAgentFinished 事件)。
79
79
  * 子 Agent 沿用父 Agent 的工具能力(不做权限过滤),但剔除 call_skill_sub_agent 自身,
80
80
  * 避免 skill 链式自递归。
81
81
  */
@@ -112,7 +112,8 @@ export function createCallSkillSubAgentTool(skillDirs, filteredSkills) {
112
112
  },
113
113
  },
114
114
  // 初始消息依赖运行时参数(skill_id → SKILL.md 内容),故不传 messages 模板,
115
- // 由 buildAgent 读取 SKILL.md 后自行决定;abort 联动与委派边界由 AgentToolLazy 统一处理
115
+ // 由 buildAgent 读取 SKILL.md 后自行决定;中断信号与委派边界由 AgentToolLazy 统一处理
116
+ // (父的 `abort` 直接把 signal 交给子 agent 的 `runOnce`,不再有手工联动)
116
117
  buildAgent: async (parsedArgs, ctx) => {
117
118
  const skillId = parsedArgs.skill_id;
118
119
  const task = parsedArgs.task;
@@ -136,6 +137,9 @@ export function createCallSkillSubAgentTool(skillDirs, filteredSkills) {
136
137
  modelConfig: parentAgent.modelConfig,
137
138
  messages: [Message.System(skill.content), Message.User(task)],
138
139
  tools,
140
+ // 技能子 Agent 同样走委派:`buildAgent` 造出来的必须是**一次性**
141
+ // (`CORE.md` §9)。它跑完就死透,不与父会话共用寿命。
142
+ lifetime: "one-shot",
139
143
  });
140
144
  },
141
145
  });
@@ -51,6 +51,9 @@ export function createSubAgentTool(def, scope) {
51
51
  model,
52
52
  modelConfig,
53
53
  tools,
54
+ // 委派就是「干一件已经看得见结果的活」:`buildAgent` 造出来的必须是**一次性**
55
+ // (`CORE.md` §9)。常驻子节点不能走这条路 —— 它得有人给它定地址、有人负责 stop。
56
+ lifetime: "one-shot",
54
57
  });
55
58
  return subAgent;
56
59
  },
@@ -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
- /** 触发中断时的刚用量(usage.prompt_tokens) */
22
+ /** 触发拦截时的用量(usage.prompt_tokens) */
16
23
  readonly promptTokens: number;
17
24
  /** 被越过的强行阻断阈值(`tokenThresholds.guard`,绝对值) */
18
25
  readonly guardTokens: number;
@@ -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
- /** 触发中断时的刚用量(usage.prompt_tokens) */
29
+ /** 触发拦截时的用量(usage.prompt_tokens) */
23
30
  promptTokens;
24
31
  /** 被越过的强行阻断阈值(`tokenThresholds.guard`,绝对值) */
25
32
  guardTokens;
@@ -82,10 +82,11 @@ export interface Endpoint {
82
82
  * 上下文用量阈值 —— 与模型的真实窗口无关,只描述「用量到了这条线该怎么办」。
83
83
  *
84
84
  * 两个阈值语义不同,消费方也不同:
85
- * - `handoff`:软线。`AutoMigratePlugin` 在响应返回后拿 `usage.prompt_tokens` 比它,
85
+ * - `handoff`:软线。`AutoMigratePlugin` 在 agent 闲下来之后拿 `usage.prompt_tokens` 比它,
86
86
  * 超过即触发任务交接(交接本身还要再发 1~2 次请求,所以这条线必须留足余量)。
87
- * - `guard`:硬线。`ContextGuardPlugin` 在**每次请求前**比它,超过即抛
88
- * `ContextOverflowError` 中断本轮——这是最后一道保护,宁可报错也不要发出必然失败的请求。
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`:`onBeforeSend`,整个 `send()` 开头刷一次,要等下一轮才生效,开销最小;
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": "1.2.0-alpha.1",
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": "^4.6.0-alpha.0",
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
  },