@ai-setting/roy-agent-core 1.5.17-beta.1 → 1.5.22
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/dist/env/index.js +20 -8
- package/dist/env/log-trace/index.js +1 -1
- package/dist/env/prompt/index.js +1 -1
- package/dist/env/workflow/engine/index.js +1 -1
- package/dist/env/workflow/index.js +2 -2
- package/dist/index.js +6 -7
- package/dist/shared/@ai-setting/{roy-agent-core-xq8hhqb8.js → roy-agent-core-4wjywp3c.js} +4 -2
- package/dist/shared/@ai-setting/roy-agent-core-8jxva565.js +19 -0
- package/dist/shared/@ai-setting/roy-agent-core-avq1x4t7.js +84 -0
- package/dist/shared/@ai-setting/{roy-agent-core-gq20wsgv.js → roy-agent-core-ffb9fq4v.js} +23 -2
- package/dist/shared/@ai-setting/{roy-agent-core-93zfb3r1.js → roy-agent-core-mrcxzpbg.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-rhmtwnw1.js → roy-agent-core-pw7cv1px.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-gbqcyegm.js → roy-agent-core-rccptwv0.js} +512 -673
- package/dist/shared/@ai-setting/{roy-agent-core-wrcy0h6z.js → roy-agent-core-ty94k28r.js} +1 -1
- package/package.json +8 -29
- package/dist/config/index.d.ts +0 -1250
- package/dist/env/agent/index.d.ts +0 -2279
- package/dist/env/commands/index.d.ts +0 -1131
- package/dist/env/debug/formatters/index.d.ts +0 -236
- package/dist/env/debug/index.d.ts +0 -1652
- package/dist/env/hook/index.d.ts +0 -279
- package/dist/env/index.d.ts +0 -3481
- package/dist/env/llm/index.d.ts +0 -1760
- package/dist/env/log-trace/index.d.ts +0 -1574
- package/dist/env/mcp/index.d.ts +0 -1331
- package/dist/env/mcp/tool/index.d.ts +0 -183
- package/dist/env/memory/built-in/index.d.ts +0 -232
- package/dist/env/memory/index.d.ts +0 -1799
- package/dist/env/memory/plugin/index.d.ts +0 -747
- package/dist/env/prompt/index.d.ts +0 -1164
- package/dist/env/session/index.d.ts +0 -1908
- package/dist/env/session/storage/index.d.ts +0 -564
- package/dist/env/skill/index.d.ts +0 -1266
- package/dist/env/skill/tool/index.d.ts +0 -193
- package/dist/env/task/delegate/index.d.ts +0 -1612
- package/dist/env/task/events/index.d.ts +0 -171
- package/dist/env/task/hooks/index.d.ts +0 -624
- package/dist/env/task/index.d.ts +0 -1553
- package/dist/env/task/plugins/index.d.ts +0 -466
- package/dist/env/task/storage/index.d.ts +0 -241
- package/dist/env/task/tools/index.d.ts +0 -1485
- package/dist/env/task/tools/operation/index.d.ts +0 -1484
- package/dist/env/tool/built-in/index.d.ts +0 -218
- package/dist/env/tool/index.d.ts +0 -1396
- package/dist/env/workflow/decorators/index.d.ts +0 -2161
- package/dist/env/workflow/engine/index.d.ts +0 -3453
- package/dist/env/workflow/index.d.ts +0 -3546
- package/dist/env/workflow/nodes/index.d.ts +0 -2092
- package/dist/env/workflow/service/index.d.ts +0 -227
- package/dist/env/workflow/storage/index.d.ts +0 -165
- package/dist/env/workflow/tools/index.d.ts +0 -416
- package/dist/env/workflow/types/index.d.ts +0 -2255
- package/dist/env/workflow/utils/index.d.ts +0 -2031
- package/dist/index.d.ts +0 -7858
package/dist/env/hook/index.d.ts
DELETED
|
@@ -1,279 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Hook 系统统一类型定义
|
|
3
|
-
*
|
|
4
|
-
* 提供所有 Component 使用的统一 Hook 接口
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Hook 执行阶段
|
|
8
|
-
*/
|
|
9
|
-
type HookPhase = "before" | "after" | "error";
|
|
10
|
-
/**
|
|
11
|
-
* Hook 元信息
|
|
12
|
-
*/
|
|
13
|
-
interface HookMeta {
|
|
14
|
-
/** Hook 唯一名称 */
|
|
15
|
-
name: string;
|
|
16
|
-
/** 执行优先级,默认 0,数值越小越先执行 */
|
|
17
|
-
priority?: number;
|
|
18
|
-
/** 描述 */
|
|
19
|
-
description?: string;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* 统一 Hook 上下文
|
|
23
|
-
*
|
|
24
|
-
* 泛型参数 T 表示该 Component 的上下文数据类型
|
|
25
|
-
*/
|
|
26
|
-
interface HookContext<T = unknown> {
|
|
27
|
-
/** 当前组件信息 */
|
|
28
|
-
component: {
|
|
29
|
-
/** 组件名称 */
|
|
30
|
-
name: string;
|
|
31
|
-
/** 组件版本 */
|
|
32
|
-
version: string;
|
|
33
|
-
};
|
|
34
|
-
/** 上下文数据(Component 特定) */
|
|
35
|
-
data: T;
|
|
36
|
-
/** 元数据(可用于传递额外信息) */
|
|
37
|
-
metadata: Record<string, unknown>;
|
|
38
|
-
/** 执行阶段 */
|
|
39
|
-
phase: HookPhase;
|
|
40
|
-
/** 关联的 hook 点名称 */
|
|
41
|
-
hookPoint: string;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* 统一 Hook 接口
|
|
45
|
-
*
|
|
46
|
-
* 所有 Component 的 Hook 都应实现此接口
|
|
47
|
-
*/
|
|
48
|
-
interface Hook<T = unknown> extends HookMeta {
|
|
49
|
-
/** 执行 Hook
|
|
50
|
-
* @param ctx 上下文
|
|
51
|
-
*/
|
|
52
|
-
execute(ctx: HookContext<T>): void | Promise<void>;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Hook 函数类型(便捷别名)
|
|
56
|
-
*/
|
|
57
|
-
type HookFn<T = unknown> = (ctx: HookContext<T>) => void | Promise<void>;
|
|
58
|
-
/**
|
|
59
|
-
* Hook 干预动作类型
|
|
60
|
-
*/
|
|
61
|
-
type HookActionType = "stop" | "retry" | "compress" | "extract_memory" | "inject_message" | "skip_tool" | "custom";
|
|
62
|
-
/**
|
|
63
|
-
* Hook 干预动作
|
|
64
|
-
*/
|
|
65
|
-
interface HookAction {
|
|
66
|
-
/** 动作类型 */
|
|
67
|
-
type: HookActionType;
|
|
68
|
-
/** 动作参数 */
|
|
69
|
-
params?: Record<string, unknown>;
|
|
70
|
-
/** 动作描述 */
|
|
71
|
-
description?: string;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Hook 执行结果
|
|
75
|
-
*/
|
|
76
|
-
interface HookResult {
|
|
77
|
-
/** 是否被停止 */
|
|
78
|
-
stopped?: boolean;
|
|
79
|
-
/** 干预动作(如果有) */
|
|
80
|
-
action?: HookAction;
|
|
81
|
-
/** 执行结果数据 */
|
|
82
|
-
results?: unknown[];
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* 创建 Hook 的工厂函数
|
|
86
|
-
*
|
|
87
|
-
* @param meta Hook 元信息
|
|
88
|
-
* @param fn 执行函数
|
|
89
|
-
* @returns Hook 实例
|
|
90
|
-
*
|
|
91
|
-
* @example
|
|
92
|
-
* ```typescript
|
|
93
|
-
* const hook = createHook(
|
|
94
|
-
* { name: "my-hook", priority: 10 },
|
|
95
|
-
* async (ctx) => { console.log(ctx.data); }
|
|
96
|
-
* );
|
|
97
|
-
* ```
|
|
98
|
-
*/
|
|
99
|
-
declare function createHook<T = unknown>(meta: HookMeta, fn: HookFn<T>): Hook<T>;
|
|
100
|
-
/**
|
|
101
|
-
* 创建带优先级的 Hook 的便捷函数
|
|
102
|
-
*/
|
|
103
|
-
declare function createPriorityHook<T = unknown>(name: string, fn: HookFn<T>, priority: number): Hook<T>;
|
|
104
|
-
/**
|
|
105
|
-
* HookManager 配置
|
|
106
|
-
*/
|
|
107
|
-
interface HookManagerOptions {
|
|
108
|
-
/** 组件名称(用于上下文) */
|
|
109
|
-
componentName?: string;
|
|
110
|
-
/** 组件版本(用于上下文) */
|
|
111
|
-
componentVersion?: string;
|
|
112
|
-
/** 默认优先级 */
|
|
113
|
-
defaultPriority?: number;
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* HookManager
|
|
117
|
-
*
|
|
118
|
-
* 统一管理 Component 的 Hook
|
|
119
|
-
*
|
|
120
|
-
* @example
|
|
121
|
-
* ```typescript
|
|
122
|
-
* const manager = new HookManager<MyContext>();
|
|
123
|
-
*
|
|
124
|
-
* // 注册 Hook
|
|
125
|
-
* manager.register("before-action", {
|
|
126
|
-
* name: "my-hook",
|
|
127
|
-
* priority: 10,
|
|
128
|
-
* execute: async (ctx) => { /* ... *\/ }
|
|
129
|
-
* });
|
|
130
|
-
*
|
|
131
|
-
* // 执行 Hooks
|
|
132
|
-
* await manager.execute("before-action", data);
|
|
133
|
-
* ```
|
|
134
|
-
*/
|
|
135
|
-
declare class HookManager<T = unknown> {
|
|
136
|
-
private _hooks;
|
|
137
|
-
private componentName;
|
|
138
|
-
private componentVersion;
|
|
139
|
-
private defaultPriority;
|
|
140
|
-
constructor(options?: HookManagerOptions);
|
|
141
|
-
/**
|
|
142
|
-
* 注册 Hook 到指定 hook 点
|
|
143
|
-
*/
|
|
144
|
-
register(hookPoint: string, hook: Hook<T>): void;
|
|
145
|
-
/**
|
|
146
|
-
* 注册多个 Hook
|
|
147
|
-
*/
|
|
148
|
-
registerMany(hookPoint: string, hooks: Hook<T>[]): void;
|
|
149
|
-
/**
|
|
150
|
-
* 按名称取消注册 Hook
|
|
151
|
-
* @returns 是否成功取消注册
|
|
152
|
-
*/
|
|
153
|
-
unregister(hookPoint: string, name: string): boolean;
|
|
154
|
-
/**
|
|
155
|
-
* 取消注册所有指定 hook 点的 Hook
|
|
156
|
-
*/
|
|
157
|
-
unregisterAll(hookPoint: string): void;
|
|
158
|
-
/**
|
|
159
|
-
* 执行指定 hook 点的所有 Hook
|
|
160
|
-
*/
|
|
161
|
-
execute(hookPoint: string, data: T, metadata?: Record<string, unknown>): Promise<void>;
|
|
162
|
-
/**
|
|
163
|
-
* 执行指定 hook 点的所有 Hook 并收集返回值
|
|
164
|
-
*/
|
|
165
|
-
executeAndCollect<R>(hookPoint: string, data: T, metadata?: Record<string, unknown>): Promise<R[]>;
|
|
166
|
-
/**
|
|
167
|
-
* 获取指定 hook 点的 Hook 数量
|
|
168
|
-
*/
|
|
169
|
-
count(hookPoint: string): number;
|
|
170
|
-
/**
|
|
171
|
-
* 清空所有 Hook
|
|
172
|
-
*/
|
|
173
|
-
clear(): void;
|
|
174
|
-
/**
|
|
175
|
-
* 获取所有已注册的 hook 点
|
|
176
|
-
*/
|
|
177
|
-
getHookPoints(): string[];
|
|
178
|
-
/**
|
|
179
|
-
* 检查 hook 点是否有任何 Hook
|
|
180
|
-
*/
|
|
181
|
-
hasHooks(hookPoint: string): boolean;
|
|
182
|
-
/**
|
|
183
|
-
* 设置组件信息
|
|
184
|
-
*/
|
|
185
|
-
setComponentInfo(name: string, version: string): void;
|
|
186
|
-
/**
|
|
187
|
-
* 获取所有注册的 hooks(只读副本)
|
|
188
|
-
*/
|
|
189
|
-
get hooks(): ReadonlyMap<string, Hook<T>[]>;
|
|
190
|
-
/**
|
|
191
|
-
* 执行 Hook 并支持干预机制
|
|
192
|
-
*
|
|
193
|
-
* 如果任何一个 Hook 返回 { stop: true },执行会停止
|
|
194
|
-
* Hook 可以通过返回 HookResult 来执行干预动作
|
|
195
|
-
*
|
|
196
|
-
* @param hookPoint Hook 点
|
|
197
|
-
* @param data 数据
|
|
198
|
-
* @param metadata 元数据
|
|
199
|
-
* @returns 执行结果
|
|
200
|
-
*/
|
|
201
|
-
executeWithIntervention(hookPoint: string, data: T, metadata?: Record<string, unknown>): Promise<HookResult>;
|
|
202
|
-
/**
|
|
203
|
-
* 获取或创建 hook 列表
|
|
204
|
-
*/
|
|
205
|
-
private getOrCreateHooks;
|
|
206
|
-
/**
|
|
207
|
-
* 按优先级排序 Hook
|
|
208
|
-
*
|
|
209
|
-
* 优先级相同时保持原顺序(稳定排序)
|
|
210
|
-
*/
|
|
211
|
-
private sortHooks;
|
|
212
|
-
/**
|
|
213
|
-
* 创建 Hook 上下文
|
|
214
|
-
*/
|
|
215
|
-
private createContext;
|
|
216
|
-
/**
|
|
217
|
-
* 安全执行 Hook(错误隔离)
|
|
218
|
-
*/
|
|
219
|
-
private safeExecute;
|
|
220
|
-
/**
|
|
221
|
-
* 安全执行 Hook 并返回结果
|
|
222
|
-
*/
|
|
223
|
-
private safeExecuteAndReturn;
|
|
224
|
-
}
|
|
225
|
-
/**
|
|
226
|
-
* 全局 HookManager 实例
|
|
227
|
-
*
|
|
228
|
-
* 所有 Agent/LLM/Tool hooks 都注册到这个实例
|
|
229
|
-
*/
|
|
230
|
-
declare const globalHookManager: unknown;
|
|
231
|
-
/**
|
|
232
|
-
* Agent Hook 点(新版统一命名)
|
|
233
|
-
*/
|
|
234
|
-
declare const AgentHookPoints: {
|
|
235
|
-
readonly BEFORE_START: "agent:before.start";
|
|
236
|
-
readonly BEFORE_LLM: "agent:before.llm";
|
|
237
|
-
readonly AFTER_LLM: "agent:after.llm";
|
|
238
|
-
readonly BEFORE_TOOL: "agent:before.tool";
|
|
239
|
-
readonly AFTER_TOOL: "agent:after.tool";
|
|
240
|
-
readonly ON_ITERATION: "agent:on.iteration";
|
|
241
|
-
readonly ON_THRESHOLD: "agent:on.threshold";
|
|
242
|
-
readonly AFTER_COMPLETE: "agent:after.complete";
|
|
243
|
-
readonly ON_ERROR: "agent:on.error";
|
|
244
|
-
};
|
|
245
|
-
/**
|
|
246
|
-
* LLM Hook 点
|
|
247
|
-
*/
|
|
248
|
-
declare const LLMHookPoints: {
|
|
249
|
-
readonly BEFORE_INVOKE: "llm:before.invoke";
|
|
250
|
-
readonly AFTER_INVOKE: "llm:after.invoke";
|
|
251
|
-
readonly ON_STREAM: "llm:on.stream";
|
|
252
|
-
};
|
|
253
|
-
/**
|
|
254
|
-
* Tool Hook 点
|
|
255
|
-
*/
|
|
256
|
-
declare const ToolHookPoints: {
|
|
257
|
-
readonly BEFORE_EXECUTE: "tool:before.execute";
|
|
258
|
-
readonly AFTER_EXECUTE: "tool:after.execute";
|
|
259
|
-
readonly BEFORE_REGISTER: "tool:before.register";
|
|
260
|
-
readonly AFTER_REGISTER: "tool:after.register";
|
|
261
|
-
readonly ON_ERROR: "tool:on.error";
|
|
262
|
-
};
|
|
263
|
-
/**
|
|
264
|
-
* 执行 Agent Hook(不带干预)
|
|
265
|
-
*/
|
|
266
|
-
declare function executeAgentHook(hookPoint: string, data: unknown, metadata?: Record<string, unknown>): Promise<void>;
|
|
267
|
-
/**
|
|
268
|
-
* 执行 Agent Hook(带干预检查)
|
|
269
|
-
*/
|
|
270
|
-
declare function executeAgentHookWithIntervention(hookPoint: string, data: unknown, metadata?: Record<string, unknown>): Promise<HookResult>;
|
|
271
|
-
/**
|
|
272
|
-
* 执行 LLM Hook(不带干预)
|
|
273
|
-
*/
|
|
274
|
-
declare function executeLLMHook(hookPoint: string, data: unknown, metadata?: Record<string, unknown>): Promise<void>;
|
|
275
|
-
/**
|
|
276
|
-
* 执行 Tool Hook(不带干预)
|
|
277
|
-
*/
|
|
278
|
-
declare function executeToolHook(hookPoint: string, data: unknown, metadata?: Record<string, unknown>): Promise<void>;
|
|
279
|
-
export { globalHookManager, executeToolHook, executeLLMHook, executeAgentHookWithIntervention, executeAgentHook, createPriorityHook, createHook, ToolHookPoints, LLMHookPoints, HookResult, HookPhase, HookMeta, HookManagerOptions, HookManager, HookFn, HookContext, HookActionType, HookAction, Hook, HookFn as BaseHookFn, HookContext as BaseHookContext, Hook as BaseHook, AgentHookPoints };
|