@ai-setting/roy-agent-core 1.5.14-test → 1.5.15-test

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 (141) hide show
  1. package/package.json +1 -1
  2. package/dist/config/index.d.ts +0 -1250
  3. package/dist/config/index.js +0 -32
  4. package/dist/env/agent/index.d.ts +0 -2279
  5. package/dist/env/agent/index.js +0 -24
  6. package/dist/env/commands/index.d.ts +0 -1131
  7. package/dist/env/commands/index.js +0 -14
  8. package/dist/env/debug/formatters/index.d.ts +0 -236
  9. package/dist/env/debug/formatters/index.js +0 -11
  10. package/dist/env/debug/index.d.ts +0 -1652
  11. package/dist/env/debug/index.js +0 -26
  12. package/dist/env/hook/index.d.ts +0 -279
  13. package/dist/env/hook/index.js +0 -29
  14. package/dist/env/index.d.ts +0 -3481
  15. package/dist/env/index.js +0 -82
  16. package/dist/env/llm/index.d.ts +0 -1760
  17. package/dist/env/llm/index.js +0 -40
  18. package/dist/env/log-trace/index.d.ts +0 -1574
  19. package/dist/env/log-trace/index.js +0 -83
  20. package/dist/env/mcp/index.d.ts +0 -1331
  21. package/dist/env/mcp/index.js +0 -39
  22. package/dist/env/mcp/tool/index.d.ts +0 -183
  23. package/dist/env/mcp/tool/index.js +0 -14
  24. package/dist/env/memory/built-in/index.d.ts +0 -232
  25. package/dist/env/memory/built-in/index.js +0 -11
  26. package/dist/env/memory/index.d.ts +0 -1799
  27. package/dist/env/memory/index.js +0 -56
  28. package/dist/env/memory/plugin/index.d.ts +0 -747
  29. package/dist/env/memory/plugin/index.js +0 -36
  30. package/dist/env/prompt/index.d.ts +0 -1164
  31. package/dist/env/prompt/index.js +0 -20
  32. package/dist/env/session/index.d.ts +0 -1908
  33. package/dist/env/session/index.js +0 -25
  34. package/dist/env/session/storage/index.d.ts +0 -564
  35. package/dist/env/session/storage/index.js +0 -18
  36. package/dist/env/skill/index.d.ts +0 -1266
  37. package/dist/env/skill/index.js +0 -34
  38. package/dist/env/skill/tool/index.d.ts +0 -193
  39. package/dist/env/skill/tool/index.js +0 -9
  40. package/dist/env/task/delegate/index.d.ts +0 -1612
  41. package/dist/env/task/delegate/index.js +0 -18
  42. package/dist/env/task/events/index.d.ts +0 -171
  43. package/dist/env/task/events/index.js +0 -7
  44. package/dist/env/task/hooks/index.d.ts +0 -624
  45. package/dist/env/task/hooks/index.js +0 -7
  46. package/dist/env/task/index.d.ts +0 -1553
  47. package/dist/env/task/index.js +0 -34
  48. package/dist/env/task/plugins/index.d.ts +0 -466
  49. package/dist/env/task/plugins/index.js +0 -23
  50. package/dist/env/task/storage/index.d.ts +0 -241
  51. package/dist/env/task/storage/index.js +0 -14
  52. package/dist/env/task/tools/index.d.ts +0 -1485
  53. package/dist/env/task/tools/index.js +0 -17
  54. package/dist/env/task/tools/operation/index.d.ts +0 -1484
  55. package/dist/env/task/tools/operation/index.js +0 -15
  56. package/dist/env/tool/built-in/index.d.ts +0 -218
  57. package/dist/env/tool/built-in/index.js +0 -25
  58. package/dist/env/tool/index.d.ts +0 -1396
  59. package/dist/env/tool/index.js +0 -39
  60. package/dist/env/workflow/decorators/index.d.ts +0 -2161
  61. package/dist/env/workflow/decorators/index.js +0 -27
  62. package/dist/env/workflow/engine/index.d.ts +0 -3453
  63. package/dist/env/workflow/engine/index.js +0 -28
  64. package/dist/env/workflow/index.d.ts +0 -3546
  65. package/dist/env/workflow/index.js +0 -136
  66. package/dist/env/workflow/nodes/index.d.ts +0 -2092
  67. package/dist/env/workflow/nodes/index.js +0 -19
  68. package/dist/env/workflow/service/index.d.ts +0 -227
  69. package/dist/env/workflow/service/index.js +0 -13
  70. package/dist/env/workflow/storage/index.d.ts +0 -165
  71. package/dist/env/workflow/storage/index.js +0 -27
  72. package/dist/env/workflow/tools/index.d.ts +0 -416
  73. package/dist/env/workflow/tools/index.js +0 -159
  74. package/dist/env/workflow/types/index.d.ts +0 -2255
  75. package/dist/env/workflow/types/index.js +0 -98
  76. package/dist/env/workflow/utils/index.d.ts +0 -2031
  77. package/dist/env/workflow/utils/index.js +0 -637
  78. package/dist/index.d.ts +0 -7858
  79. package/dist/index.js +0 -399
  80. package/dist/shared/@ai-setting/roy-agent-core-0rtxwr28.js +0 -258
  81. package/dist/shared/@ai-setting/roy-agent-core-0vbdz0x7.js +0 -36
  82. package/dist/shared/@ai-setting/roy-agent-core-1akcqxj9.js +0 -349
  83. package/dist/shared/@ai-setting/roy-agent-core-1ce3fqrk.js +0 -117
  84. package/dist/shared/@ai-setting/roy-agent-core-2dhd60aw.js +0 -11
  85. package/dist/shared/@ai-setting/roy-agent-core-3jywqmdd.js +0 -393
  86. package/dist/shared/@ai-setting/roy-agent-core-3rr5k71j.js +0 -200
  87. package/dist/shared/@ai-setting/roy-agent-core-44hnfb02.js +0 -299
  88. package/dist/shared/@ai-setting/roy-agent-core-4t40mkpv.js +0 -206
  89. package/dist/shared/@ai-setting/roy-agent-core-4txzpsbt.js +0 -393
  90. package/dist/shared/@ai-setting/roy-agent-core-5x94xmt6.js +0 -350
  91. package/dist/shared/@ai-setting/roy-agent-core-69jskqjg.js +0 -180
  92. package/dist/shared/@ai-setting/roy-agent-core-6kvtahqv.js +0 -408
  93. package/dist/shared/@ai-setting/roy-agent-core-7fgf85wc.js +0 -284
  94. package/dist/shared/@ai-setting/roy-agent-core-81w1963m.js +0 -762
  95. package/dist/shared/@ai-setting/roy-agent-core-8gxth0eh.js +0 -10
  96. package/dist/shared/@ai-setting/roy-agent-core-92z6t4he.js +0 -14
  97. package/dist/shared/@ai-setting/roy-agent-core-93zfb3r1.js +0 -922
  98. package/dist/shared/@ai-setting/roy-agent-core-9yxb3ty9.js +0 -15
  99. package/dist/shared/@ai-setting/roy-agent-core-b0x5dda6.js +0 -1130
  100. package/dist/shared/@ai-setting/roy-agent-core-bcbqy27c.js +0 -14
  101. package/dist/shared/@ai-setting/roy-agent-core-bvr1761x.js +0 -653
  102. package/dist/shared/@ai-setting/roy-agent-core-ctdhjv68.js +0 -93
  103. package/dist/shared/@ai-setting/roy-agent-core-d7cyjkf7.js +0 -872
  104. package/dist/shared/@ai-setting/roy-agent-core-dh9d7a3m.js +0 -11
  105. package/dist/shared/@ai-setting/roy-agent-core-e25xkv53.js +0 -64
  106. package/dist/shared/@ai-setting/roy-agent-core-eajcvp4e.js +0 -378
  107. package/dist/shared/@ai-setting/roy-agent-core-f7q2x5z6.js +0 -492
  108. package/dist/shared/@ai-setting/roy-agent-core-fs0mn2jk.js +0 -52
  109. package/dist/shared/@ai-setting/roy-agent-core-g1s2h0e5.js +0 -171
  110. package/dist/shared/@ai-setting/roy-agent-core-g99pxzn5.js +0 -862
  111. package/dist/shared/@ai-setting/roy-agent-core-gbqcyegm.js +0 -1387
  112. package/dist/shared/@ai-setting/roy-agent-core-gjq1yk68.js +0 -208
  113. package/dist/shared/@ai-setting/roy-agent-core-gq20wsgv.js +0 -139
  114. package/dist/shared/@ai-setting/roy-agent-core-gwc4h96n.js +0 -534
  115. package/dist/shared/@ai-setting/roy-agent-core-jfh9q2qh.js +0 -204
  116. package/dist/shared/@ai-setting/roy-agent-core-jvatggbb.js +0 -603
  117. package/dist/shared/@ai-setting/roy-agent-core-kkbwepqb.js +0 -97
  118. package/dist/shared/@ai-setting/roy-agent-core-pjr12nnd.js +0 -587
  119. package/dist/shared/@ai-setting/roy-agent-core-psv4v63c.js +0 -176
  120. package/dist/shared/@ai-setting/roy-agent-core-psvxt4c9.js +0 -60
  121. package/dist/shared/@ai-setting/roy-agent-core-qqceba6k.js +0 -442
  122. package/dist/shared/@ai-setting/roy-agent-core-qxhq8ven.js +0 -57
  123. package/dist/shared/@ai-setting/roy-agent-core-qxnbvgwe.js +0 -66
  124. package/dist/shared/@ai-setting/roy-agent-core-r9ezzemr.js +0 -10
  125. package/dist/shared/@ai-setting/roy-agent-core-rhmtwnw1.js +0 -267
  126. package/dist/shared/@ai-setting/roy-agent-core-rvv6ydff.js +0 -584
  127. package/dist/shared/@ai-setting/roy-agent-core-rvxg1wps.js +0 -102
  128. package/dist/shared/@ai-setting/roy-agent-core-satmq6sh.js +0 -549
  129. package/dist/shared/@ai-setting/roy-agent-core-sx7wsvnn.js +0 -15
  130. package/dist/shared/@ai-setting/roy-agent-core-t94ktchq.js +0 -213
  131. package/dist/shared/@ai-setting/roy-agent-core-vf215qfv.js +0 -812
  132. package/dist/shared/@ai-setting/roy-agent-core-vkz81f7v.js +0 -1316
  133. package/dist/shared/@ai-setting/roy-agent-core-vn2bc59q.js +0 -1205
  134. package/dist/shared/@ai-setting/roy-agent-core-wa1kzqky.js +0 -328
  135. package/dist/shared/@ai-setting/roy-agent-core-wft9ra24.js +0 -20
  136. package/dist/shared/@ai-setting/roy-agent-core-wrcy0h6z.js +0 -2098
  137. package/dist/shared/@ai-setting/roy-agent-core-xq8hhqb8.js +0 -419
  138. package/dist/shared/@ai-setting/roy-agent-core-xs5rsgat.js +0 -368
  139. package/dist/shared/@ai-setting/roy-agent-core-zbkpc41z.js +0 -377
  140. package/dist/shared/@ai-setting/roy-agent-core-zgypchmt.js +0 -172
  141. package/dist/shared/@ai-setting/roy-agent-core-zpn0bqa8.js +0 -103
@@ -1,1266 +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
- * HookManager 配置
86
- */
87
- interface HookManagerOptions {
88
- /** 组件名称(用于上下文) */
89
- componentName?: string;
90
- /** 组件版本(用于上下文) */
91
- componentVersion?: string;
92
- /** 默认优先级 */
93
- defaultPriority?: number;
94
- }
95
- /**
96
- * HookManager
97
- *
98
- * 统一管理 Component 的 Hook
99
- *
100
- * @example
101
- * ```typescript
102
- * const manager = new HookManager<MyContext>();
103
- *
104
- * // 注册 Hook
105
- * manager.register("before-action", {
106
- * name: "my-hook",
107
- * priority: 10,
108
- * execute: async (ctx) => { /* ... *\/ }
109
- * });
110
- *
111
- * // 执行 Hooks
112
- * await manager.execute("before-action", data);
113
- * ```
114
- */
115
- declare class HookManager<T = unknown> {
116
- private _hooks;
117
- private componentName;
118
- private componentVersion;
119
- private defaultPriority;
120
- constructor(options?: HookManagerOptions);
121
- /**
122
- * 注册 Hook 到指定 hook 点
123
- */
124
- register(hookPoint: string, hook: Hook<T>): void;
125
- /**
126
- * 注册多个 Hook
127
- */
128
- registerMany(hookPoint: string, hooks: Hook<T>[]): void;
129
- /**
130
- * 按名称取消注册 Hook
131
- * @returns 是否成功取消注册
132
- */
133
- unregister(hookPoint: string, name: string): boolean;
134
- /**
135
- * 取消注册所有指定 hook 点的 Hook
136
- */
137
- unregisterAll(hookPoint: string): void;
138
- /**
139
- * 执行指定 hook 点的所有 Hook
140
- */
141
- execute(hookPoint: string, data: T, metadata?: Record<string, unknown>): Promise<void>;
142
- /**
143
- * 执行指定 hook 点的所有 Hook 并收集返回值
144
- */
145
- executeAndCollect<R>(hookPoint: string, data: T, metadata?: Record<string, unknown>): Promise<R[]>;
146
- /**
147
- * 获取指定 hook 点的 Hook 数量
148
- */
149
- count(hookPoint: string): number;
150
- /**
151
- * 清空所有 Hook
152
- */
153
- clear(): void;
154
- /**
155
- * 获取所有已注册的 hook 点
156
- */
157
- getHookPoints(): string[];
158
- /**
159
- * 检查 hook 点是否有任何 Hook
160
- */
161
- hasHooks(hookPoint: string): boolean;
162
- /**
163
- * 设置组件信息
164
- */
165
- setComponentInfo(name: string, version: string): void;
166
- /**
167
- * 获取所有注册的 hooks(只读副本)
168
- */
169
- get hooks(): ReadonlyMap<string, Hook<T>[]>;
170
- /**
171
- * 执行 Hook 并支持干预机制
172
- *
173
- * 如果任何一个 Hook 返回 { stop: true },执行会停止
174
- * Hook 可以通过返回 HookResult 来执行干预动作
175
- *
176
- * @param hookPoint Hook 点
177
- * @param data 数据
178
- * @param metadata 元数据
179
- * @returns 执行结果
180
- */
181
- executeWithIntervention(hookPoint: string, data: T, metadata?: Record<string, unknown>): Promise<HookResult>;
182
- /**
183
- * 获取或创建 hook 列表
184
- */
185
- private getOrCreateHooks;
186
- /**
187
- * 按优先级排序 Hook
188
- *
189
- * 优先级相同时保持原顺序(稳定排序)
190
- */
191
- private sortHooks;
192
- /**
193
- * 创建 Hook 上下文
194
- */
195
- private createContext;
196
- /**
197
- * 安全执行 Hook(错误隔离)
198
- */
199
- private safeExecute;
200
- /**
201
- * 安全执行 Hook 并返回结果
202
- */
203
- private safeExecuteAndReturn;
204
- }
205
- import { z, ZodType, ZodError } from "zod";
206
- /**
207
- * 沙箱配置
208
- */
209
- interface SandboxConfig {
210
- /** 是否启用沙箱 */
211
- enabled: boolean;
212
- /** 沙箱类型 */
213
- type: "native" | "docker";
214
- /** 动作过滤 */
215
- actionFilter?: {
216
- /** 包含的动作 */
217
- include?: string[];
218
- /** 排除的动作 */
219
- exclude?: string[];
220
- };
221
- /** 文件系统限制 */
222
- filesystem?: {
223
- /** 允许读取 */
224
- allowRead?: string[];
225
- /** 禁止读取 */
226
- denyRead?: string[];
227
- /** 允许写入 */
228
- allowWrite?: string[];
229
- /** 禁止写入 */
230
- denyWrite?: string[];
231
- };
232
- /** 网络限制 */
233
- network?: {
234
- /** 允许的域名 */
235
- allowedDomains?: string[];
236
- /** 禁止的域名 */
237
- deniedDomains?: string[];
238
- };
239
- /** Docker 配置 */
240
- docker?: {
241
- /** 镜像 */
242
- image?: string;
243
- /** 网络模式 */
244
- networkMode?: "bridge" | "host" | "none";
245
- /** 卷挂载 */
246
- volumes?: Record<string, string>;
247
- };
248
- }
249
- /**
250
- * 工具执行上下文
251
- */
252
- interface ToolContext {
253
- /** 工作目录 */
254
- workdir?: string;
255
- /** 用户 ID */
256
- user_id?: string;
257
- /** 会话 ID */
258
- session_id?: string;
259
- /** 消息 ID */
260
- message_id?: string;
261
- /** 中断信号 */
262
- abort?: AbortSignal;
263
- /** 额外元数据 */
264
- metadata?: Record<string, unknown>;
265
- /** 沙箱配置 */
266
- sandbox?: SandboxConfig;
267
- /** 沙箱 Provider */
268
- sandboxProvider?: unknown | null;
269
- }
270
- /**
271
- * 工具结果元数据
272
- */
273
- interface ToolResultMetadata {
274
- /** 执行时间(毫秒) */
275
- execution_time_ms: number;
276
- /** 输出大小(字节) */
277
- output_size?: number;
278
- /** 标准输出 */
279
- stdout?: string;
280
- /** 标准错误 */
281
- stderr?: string;
282
- /** 退出码 */
283
- exit_code?: number;
284
- /** Token 使用量 */
285
- usage?: {
286
- inputTokens: number;
287
- outputTokens: number;
288
- totalTokens?: number;
289
- };
290
- /** 额外元数据 */
291
- [key: string]: unknown;
292
- }
293
- /**
294
- * 工具执行结果
295
- */
296
- interface ToolResult {
297
- /** 是否成功 */
298
- success: boolean;
299
- /** 输出内容 */
300
- output: string | Record<string, unknown>;
301
- /** 错误信息 */
302
- error?: string;
303
- /** 结果元数据 */
304
- metadata?: ToolResultMetadata;
305
- }
306
- /**
307
- * 工具元数据
308
- */
309
- interface ToolMetadata {
310
- /** 分类 */
311
- category?: string;
312
- /** 标签 */
313
- tags?: string[];
314
- /** 版本 */
315
- version?: string;
316
- /** 作者 */
317
- author?: string;
318
- /** 是否实验性 */
319
- experimental?: boolean;
320
- /** MCP 工具信息(MCP adapter 使用) */
321
- mcpTool?: {
322
- originalName: string;
323
- originalDescription: string;
324
- inputSchema?: unknown;
325
- };
326
- }
327
- /**
328
- * 工具沙箱配置
329
- */
330
- interface ToolSandboxConfig {
331
- /** 是否启用沙箱 */
332
- enabled: boolean;
333
- /** 沙箱配置 */
334
- config?: Partial<SandboxConfig>;
335
- }
336
- /**
337
- * 工具权限配置
338
- */
339
- interface ToolPermissionConfig {
340
- /** 是否需要用户确认 */
341
- requireConfirmation?: boolean;
342
- /** 权限级别 */
343
- level?: "safe" | "dangerous" | "critical";
344
- }
345
- /**
346
- * 工具信息
347
- */
348
- interface ToolInfo<Parameters extends ZodType = ZodType> {
349
- /** 工具名称 */
350
- name: string;
351
- /** 工具描述 */
352
- description: string;
353
- /** 参数 Schema */
354
- parameters: Parameters;
355
- /** 初始化函数(可选) */
356
- init?: (ctx?: ToolContext) => Promise<void>;
357
- /** 执行函数 */
358
- execute: (args: z.infer<Parameters>, ctx: ToolContext) => Promise<ToolResult>;
359
- /** 参数验证错误格式化(可选) */
360
- formatValidationError?: (error: ZodError) => string;
361
- /** 沙箱配置 */
362
- sandbox?: ToolSandboxConfig;
363
- /** 权限配置 */
364
- permission?: ToolPermissionConfig;
365
- /** 工具元数据 */
366
- metadata?: ToolMetadata;
367
- }
368
- /**
369
- * 工具类型别名
370
- */
371
- type Tool = ToolInfo;
372
- import { z as z2 } from "zod";
373
- /**
374
- * Skill 来源类型
375
- */
376
- type SkillSource = "built-in" | "user" | "project";
377
- /**
378
- * Skill 条目
379
- */
380
- interface SkillEntry {
381
- /** Skill 名称(唯一标识) */
382
- name: string;
383
- /** Skill 描述 */
384
- description: string;
385
- /** SKILL.md 文件路径 */
386
- filePath: string;
387
- /** 完整 markdown 内容 */
388
- content: string;
389
- /** 来源类型 */
390
- source: SkillSource;
391
- /** 加载时间戳 */
392
- loadedAt: number;
393
- }
394
- /**
395
- * Skill 列表项(用于 list 和 description)
396
- */
397
- interface SkillListItem {
398
- name: string;
399
- description: string;
400
- source: SkillSource;
401
- }
402
- /**
403
- * Skill 路径配置
404
- */
405
- interface SkillPath {
406
- /** 来源类型 */
407
- type: SkillSource;
408
- /** 绝对路径 */
409
- path: string;
410
- }
411
- /**
412
- * SkillComponent 配置
413
- */
414
- interface SkillConfig {
415
- /** 多路径配置 */
416
- skillPaths: SkillPath[];
417
- /** 是否递归扫描子目录 */
418
- recursive: boolean;
419
- /** 是否启用缓存 */
420
- cacheEnabled: boolean;
421
- }
422
- /**
423
- * SkillTool 参数 Schema
424
- */
425
- declare const SkillToolSchema: unknown;
426
- type SkillToolParams = z2.infer<typeof SkillToolSchema>;
427
- /**
428
- * 构建 SkillTool 的 description
429
- */
430
- declare function buildSkillDescription(items: SkillListItem[]): string;
431
- /**
432
- * 创建 SkillTool
433
- *
434
- * @param getSkillList - 获取 skill 列表的回调
435
- * @param getSkill - 获取单个 skill 的回调
436
- */
437
- declare function createSkillTool(getSkillList: () => SkillListItem[], getSkill: (name: string) => {
438
- content: string;
439
- } | undefined): Tool;
440
- import { ZodType as ZodType3, ZodTypeDef as ZodTypeDef2 } from "zod";
441
- /**
442
- * @fileoverview Environment types and interfaces
443
- *
444
- * 定义 Environment 的核心类型,包括:
445
- * - Environment 配置
446
- * - EnvEvent 事件类型
447
- */
448
- /**
449
- * Environment Config
450
- */
451
- interface EnvironmentConfig {
452
- /** 环境名称 */
453
- name: string;
454
- /** 环境版本 */
455
- version: string;
456
- /** 是否启用 */
457
- enabled: boolean;
458
- }
459
- /**
460
- * EnvEvent 元信息
461
- */
462
- interface EnvEventMetadata {
463
- /** 触发事件的 session ID */
464
- trigger_session_id?: string;
465
- /** 触发事件的 agent ID */
466
- trigger_agent_id?: string;
467
- /** Agent 名称 */
468
- trigger_agent_name?: string;
469
- /** 环境名称 */
470
- env_name?: string;
471
- /** 事件来源 */
472
- source?: string;
473
- /** 其他元数据 */
474
- [key: string]: unknown;
475
- }
476
- /**
477
- * EnvEvent
478
- *
479
- * 统一的事件机制,用于:
480
- * - Stream 事件(stream.start, stream.text, stream.completed 等)
481
- * - 工具调用事件(tool.call, tool.result 等)
482
- * - 会话事件(session.created, session.updated 等)
483
- * - Agent 事件(agent.thinking, agent.acting 等)
484
- */
485
- interface EnvEvent<T = unknown> {
486
- /** 事件 ID */
487
- id: string;
488
- /** 事件类型 */
489
- type: string;
490
- /** 时间戳 */
491
- timestamp: number;
492
- /** 元信息 */
493
- metadata: EnvEventMetadata;
494
- /** 事件负载 */
495
- payload: T;
496
- }
497
- /**
498
- * EnvEvent Handler
499
- */
500
- type EnvEventHandler = (event: EnvEvent) => void | Promise<void>;
501
- /**
502
- * EnvEvent 创建参数(部分属性,可选)
503
- *
504
- * 用于 pushEnvEvent 方法,允许传入部分属性,自动补全必填字段
505
- */
506
- interface EnvEventInput {
507
- /** 事件类型(必填) */
508
- type: string;
509
- /** 事件 ID(可选,自动生成) */
510
- id?: string;
511
- /** 时间戳(可选,自动生成) */
512
- timestamp?: number;
513
- /** 元信息(可选,自动创建) */
514
- metadata?: EnvEventMetadata;
515
- /** 事件负载(可选) */
516
- payload?: unknown;
517
- }
518
- /**
519
- * Action 类型
520
- */
521
- interface Action {
522
- /** Action 类型 */
523
- type: string;
524
- /** Action 参数 */
525
- params?: Record<string, unknown>;
526
- }
527
- /**
528
- * Tool Result
529
- */
530
- interface ToolResult2 {
531
- /** 是否成功 */
532
- success: boolean;
533
- /** 输出内容 */
534
- output: string | Record<string, unknown>;
535
- /** 错误信息 */
536
- error?: string;
537
- }
538
- /**
539
- * Context
540
- */
541
- interface Context {
542
- /** 会话 ID */
543
- sessionId?: string;
544
- /** 用户 ID */
545
- userId?: string;
546
- /** 工作目录 */
547
- workdir?: string;
548
- /** 中断信号 */
549
- abort?: AbortSignal;
550
- /** 元数据 */
551
- metadata?: Record<string, unknown>;
552
- }
553
- type AbortSignalType = AbortSignal;
554
- /**
555
- * Agent 执行上下文
556
- */
557
- interface AgentContext {
558
- /** 会话 ID */
559
- sessionId?: string;
560
- /** 消息 ID */
561
- messageId?: string;
562
- /** 中断信号 */
563
- abort?: AbortSignalType;
564
- /** 额外的上下文信息(会添加到 system prompt) */
565
- additionInfo?: string;
566
- /** 元数据 */
567
- metadata?: Record<string, unknown>;
568
- /** Agent 类型(用于选择 Behavior Spec) */
569
- agentType?: string;
570
- /** 使用的模型 */
571
- model?: string;
572
- /** 允许的工具列表(上下文级别,会覆盖 agent 配置) */
573
- allowedTools?: string[];
574
- /** 拒绝的工具列表(上下文级别,会覆盖 agent 配置) */
575
- deniedTools?: string[];
576
- /** 是否过滤 history 中的 tool 消息(上下文级别,会覆盖 agent 配置) */
577
- filterHistory?: boolean;
578
- }
579
- import { ZodType as ZodType2, ZodTypeDef } from "zod";
580
- /**
581
- * ConfigSource 类型
582
- */
583
- type ConfigSourceType = "memory" | "file" | "env" | "remote";
584
- /**
585
- * SourceRegistration - Source 注册配置
586
- */
587
- interface SourceRegistration {
588
- /** Source 类型 */
589
- type: ConfigSourceType;
590
- /** 相对路径(file 类型使用,基于 XDG_DATA_HOME) */
591
- relativePath?: string;
592
- /** 环境变量前缀(env 类型使用) */
593
- envPrefix?: string;
594
- /** 优先级,默认值:memory=0, file=10, env=20 */
595
- priority?: number;
596
- /** 是否可选(file 类型使用,文件不存在时不报错) */
597
- optional?: boolean;
598
- /** 是否启用文件监听(file 类型使用,默认 true) */
599
- watch?: boolean;
600
- }
601
- /**
602
- * KeyRegistration - 配置 Key 注册
603
- */
604
- interface KeyRegistration {
605
- /** 配置 Key(支持点号嵌套,如 "llm.provider") */
606
- key: string;
607
- /** 优先使用的 Source 列表(按优先级从低到高) */
608
- sources: ConfigSourceType[];
609
- /** 自定义优先级(覆盖默认优先级) */
610
- priority?: number;
611
- /** 默认值 */
612
- default?: unknown;
613
- }
614
- /**
615
- * ComponentRegistration - Component 注册配置
616
- */
617
- interface ComponentRegistration {
618
- /** Component 名称 */
619
- name: string;
620
- /** 声明需要的 Source */
621
- sources: SourceRegistration[];
622
- /** 声明需要的配置 Key */
623
- keys: KeyRegistration[];
624
- /** 配置 Schema(用于验证,可选) */
625
- schema?: ZodType2<unknown, ZodTypeDef, unknown>;
626
- /** 默认值 */
627
- defaults?: Record<string, unknown>;
628
- }
629
- /**
630
- * ConfigSource 接口
631
- */
632
- interface ConfigSource {
633
- readonly name: ConfigSourceType;
634
- readonly priority: number;
635
- read(key: string): unknown | undefined;
636
- write?(key: string, value: unknown): boolean;
637
- delete?(key: string): boolean;
638
- list(): Array<{
639
- key: string;
640
- value: unknown;
641
- }>;
642
- watch?(callback: (event: ConfigChangeEvent) => void): () => void;
643
- }
644
- /**
645
- * Config 变更事件
646
- */
647
- interface ConfigChangeEvent {
648
- type: "change" | "add" | "delete";
649
- key: string;
650
- oldValue: unknown;
651
- newValue: unknown;
652
- source: ConfigSourceType;
653
- timestamp: number;
654
- }
655
- /**
656
- * ConfigComponent 配置
657
- */
658
- interface ConfigComponentOptions {
659
- /** 持久化文件路径 */
660
- persistFile?: string;
661
- /** 防抖延迟(ms) */
662
- debounceMs?: number;
663
- /** 最大批量大小 */
664
- maxBatchSize?: number;
665
- }
666
- /**
667
- * ConfigComponent
668
- */
669
- declare class ConfigComponent extends BaseComponent {
670
- readonly name = "config";
671
- readonly version = "1.0.0";
672
- private memorySource;
673
- private sources;
674
- private componentSchemas;
675
- private componentPaths;
676
- private watchers;
677
- /** Source watch unsubscribe 函数 */
678
- private sourceUnwatchFns;
679
- private persistQueue;
680
- private persistFile?;
681
- /** Key 注册表:key -> KeyRegistration */
682
- private keyRegistry;
683
- /** Component 注册表:name -> ComponentRegistration */
684
- private componentRegistrations;
685
- /** 协议解析器 */
686
- private protocolResolver?;
687
- /** XDG_DATA_HOME 缓存(用于测试注入) */
688
- private __xdgDataHome?;
689
- /** Source 注册配置(延迟创建) */
690
- private pendingSources;
691
- /** Source 唯一标识缓存:type:relativePath -> true */
692
- private sourceKeys;
693
- /**
694
- * 获取 XDG_DATA_HOME(动态获取,支持运行时覆盖)
695
- */
696
- getXdgDataHome(): string;
697
- /**
698
- * 设置 XDG_DATA_HOME(用于测试)
699
- */
700
- setXdgDataHome(path: string): void;
701
- constructor(options?: ConfigComponentOptions);
702
- /**
703
- * 注册 Component Schema
704
- */
705
- register(schema: ComponentSchema): void;
706
- /**
707
- * 注销 Component
708
- */
709
- unregister(name: string): boolean;
710
- /**
711
- * 检查是否已注册
712
- */
713
- isRegistered(name: string): boolean;
714
- /**
715
- * 列出所有注册的 Component
716
- */
717
- listComponents(): string[];
718
- /**
719
- * 获取配置值(支持 xxx.yyy.zzz 嵌套访问)
720
- * 支持两种模式:
721
- * 1. 完整 key:直接查找,如 "component.key" -> 读取 "component.key"
722
- * 2. 嵌套对象:查找 component 对象后从中获取属性,如 "component.nested.deep"
723
- * -> 先找 "component.nested",再获取其 "deep" 属性
724
- */
725
- get(key: string): unknown;
726
- /**
727
- * 批量获取
728
- */
729
- getMany(keys: string[]): Record<string, unknown>;
730
- /**
731
- * 设置配置值(内存级别 + 异步持久化)
732
- */
733
- set(key: string, value: unknown): Promise<void>;
734
- /**
735
- * 批量设置
736
- */
737
- setMany(config: Record<string, unknown>): Promise<void>;
738
- /**
739
- * 获取 Component 的路径
740
- */
741
- getPath(component: string, subPath?: string): string;
742
- /**
743
- * 手动持久化
744
- */
745
- save(key?: string): Promise<void>;
746
- /**
747
- * 重置到默认值
748
- */
749
- reset(key: string): Promise<void>;
750
- /**
751
- * 监听配置变更
752
- */
753
- watch(pattern: string, callback: ComponentWatchCallback): () => void;
754
- /**
755
- * 添加配置源
756
- */
757
- addSource(source: ConfigSource): void;
758
- /**
759
- * 获取 Source 唯一标识
760
- */
761
- private getSourceKey;
762
- /**
763
- * 移除配置源
764
- */
765
- removeSource(name: ConfigSourceType): boolean;
766
- /**
767
- * 关闭所有配置源的 watcher(用于优雅退出)
768
- */
769
- unwatchAll(): void;
770
- /**
771
- * 获取配置源列表
772
- */
773
- getSources(): ConfigSource[];
774
- private getNestedValue;
775
- private notifyWatchers;
776
- private persistToFile;
777
- /**
778
- * 注册配置 Source
779
- *
780
- * Source 会在首次 load() 时被创建
781
- *
782
- * @example
783
- * config.registerSource({ type: "file", relativePath: "llm-config.jsonc" });
784
- * config.registerSource({ type: "env", envPrefix: "LLM" });
785
- */
786
- registerSource(registration: SourceRegistration): void;
787
- /**
788
- * 创建 Source 实例
789
- */
790
- private createSource;
791
- /**
792
- * 确保所有待创建的 Source 已被创建
793
- */
794
- private ensureSourcesCreated;
795
- /**
796
- * 注册配置 Key
797
- *
798
- * @example
799
- * config.registerKeys([
800
- * { key: "llm.provider", sources: ["file", "memory"], default: "openai" },
801
- * { key: "llm.model", sources: ["file"] },
802
- * ]);
803
- */
804
- registerKeys(keys: KeyRegistration[]): void;
805
- /**
806
- * 注册 Component(一次性注册 Source 和 Keys)
807
- *
808
- * @example
809
- * config.registerComponent({
810
- * name: "llm",
811
- * sources: [
812
- * { type: "file", relativePath: "llm-config.jsonc" },
813
- * { type: "env", envPrefix: "LLM" },
814
- * ],
815
- * keys: [
816
- * { key: "llm.provider", sources: ["file", "env", "memory"] },
817
- * ],
818
- * });
819
- */
820
- registerComponent(registration: ComponentRegistration): void;
821
- /**
822
- * 按需加载配置
823
- *
824
- * 从注册的 Source 加载已注册 Keys 的配置值到内存中
825
- *
826
- * @param componentName - 可选,指定要加载的 Component 名称
827
- *
828
- * @example
829
- * // 加载所有已注册的 Keys
830
- * await config.load();
831
- *
832
- * // 只加载指定 Component 的 Keys
833
- * await config.load("llm");
834
- */
835
- load(componentName?: string): Promise<void>;
836
- /**
837
- * 获取已注册的 Source 列表
838
- */
839
- getRegisteredSources(): ConfigSource[];
840
- }
841
- /**
842
- * 服务配置接口
843
- */
844
- interface ServiceConfig {
845
- /** 环境配置 */
846
- environment?: {
847
- name?: string;
848
- version?: string;
849
- };
850
- /** 组件配置映射 */
851
- components?: Record<string, ComponentConfigEntry>;
852
- }
853
- /**
854
- * 组件配置项
855
- */
856
- interface ComponentConfigEntry {
857
- /** 配置文件路径(可选) */
858
- configPath?: string;
859
- /** 环境变量前缀(可选) */
860
- envPrefix?: string;
861
- /** 直接配置对象(可选) */
862
- config?: Record<string, unknown>;
863
- /** 是否启用(可选,默认 true) */
864
- enabled?: boolean;
865
- }
866
- /**
867
- * 组件初始化选项(由 generateComponentOptions 生成)
868
- */
869
- interface GeneratedComponentOptions {
870
- /** ConfigComponent 实例 */
871
- configComponent: ConfigComponent;
872
- /** 配置文件路径 */
873
- configPath?: string;
874
- /** 环境变量前缀 */
875
- envPrefix?: string;
876
- /** 直接配置对象 */
877
- config?: Record<string, unknown>;
878
- /** 允许的其他属性 */
879
- [key: string]: unknown;
880
- }
881
- /**
882
- * Environment 接口
883
- *
884
- * 定义 Agent 运行时的核心能力接口。
885
- */
886
- interface Environment {
887
- /** 环境名称 */
888
- readonly name: string;
889
- /** 环境版本 */
890
- readonly version: string;
891
- /** 获取环境配置 */
892
- getConfig(): EnvironmentConfig;
893
- /**
894
- * 注册组件
895
- */
896
- registerComponent(component: Component): void;
897
- /**
898
- * 注销组件
899
- */
900
- unregisterComponent(name: string): void;
901
- /**
902
- * 获取组件
903
- */
904
- getComponent<T extends Component>(name: string): T | undefined;
905
- /**
906
- * 列出所有组件
907
- */
908
- listComponents(): Component[];
909
- /**
910
- * 处理自然语言查询(核心入口)
911
- *
912
- * @param query 用户查询文本
913
- * @param context 执行上下文(可选)
914
- * @returns 完整的文本响应
915
- */
916
- handle_query(query: string, context?: AgentContext): Promise<string>;
917
- /**
918
- * 处理动作
919
- */
920
- handle_action(action: Action, context: Context): Promise<ToolResult2>;
921
- /**
922
- * 订阅 EnvEvent(返回取消订阅函数)
923
- */
924
- subscribe(handler: EnvEventHandler): () => void;
925
- /**
926
- * 订阅指定类型事件
927
- */
928
- subscribeTo(eventType: string | string[], handler: EnvEventHandler): () => void;
929
- /**
930
- * 订阅所有事件(通配符)
931
- */
932
- subscribeAll(handler: EnvEventHandler): () => void;
933
- /**
934
- * 推送事件
935
- *
936
- * @param event EnvEvent 或 EnvEventInput(部分属性)
937
- */
938
- pushEnvEvent(event: EnvEvent | EnvEventInput): void;
939
- /**
940
- * 从配置文件加载服务配置
941
- *
942
- * @param configPath 配置文件路径(基于 XDG_DATA_HOME)
943
- * @returns 解析后的服务配置对象
944
- */
945
- loadServiceConfig(configPath: string): Promise<ServiceConfig>;
946
- /**
947
- * 生成组件初始化选项
948
- *
949
- * 根据组件配置项生成可用于初始化的选项对象。
950
- *
951
- * @param componentName 组件名称
952
- * @param configEntry 组件配置项
953
- * @returns 生成的组件初始化选项
954
- */
955
- generateComponentOptions(componentName: string, configEntry: ComponentConfigEntry): GeneratedComponentOptions;
956
- /**
957
- * 注册组件并用配置初始化
958
- *
959
- * 便捷方法:注册组件并通过 ConfigComponent 初始化。
960
- *
961
- * @param component 要注册的组件实例
962
- * @param configEntry 组件配置项
963
- */
964
- registerComponentWithConfig(component: Component, configEntry: ComponentConfigEntry): Promise<void>;
965
- /**
966
- * 从配置文件初始化整个环境
967
- *
968
- * 加载服务配置,注册并初始化所有配置的组件。
969
- *
970
- * @param configPath 配置文件路径(基于 XDG_DATA_HOME)
971
- */
972
- initFromConfig(configPath: string): Promise<void>;
973
- }
974
- /**
975
- * Component 状态
976
- */
977
- type ComponentStatus = "created" | "initializing" | "running" | "stopping" | "stopped" | "error";
978
- /**
979
- * Component 配置
980
- */
981
- interface ComponentConfig {
982
- name: string;
983
- version: string;
984
- enabled: boolean;
985
- options?: Record<string, unknown>;
986
- /**
987
- * Environment 实例(可选)
988
- *
989
- * 推荐在 init 时接收 env 实例,以便:
990
- * - 通过 env.getComponent() 获取其他组件
991
- * - 通过 env.pushEnvEvent() 发布事件
992
- * - 通过 env.handle_query() 处理查询
993
- *
994
- * 如果未提供,部分 Component 仍可正常工作(如测试场景)
995
- *
996
- * @example
997
- * ```typescript
998
- * async onInit(): Promise<void> {
999
- * if (this.env) {
1000
- * const configComp = this.env.getComponent("config");
1001
- * }
1002
- * }
1003
- * ```
1004
- */
1005
- env?: Environment;
1006
- }
1007
- /**
1008
- * Component 路径声明
1009
- */
1010
- interface ComponentPaths {
1011
- base: "config" | "state" | "data" | "cache";
1012
- subPath: string;
1013
- isDirectory: boolean;
1014
- }
1015
- /**
1016
- * Component Schema(注册配置)
1017
- */
1018
- interface ComponentSchema {
1019
- /** Component 名称 */
1020
- name: string;
1021
- /** 配置 Schema(Zod) */
1022
- schema: ZodType3<unknown, ZodTypeDef2, unknown>;
1023
- /** 默认值(从 Schema 提取) */
1024
- defaults: Record<string, unknown>;
1025
- /** 路径声明 */
1026
- paths?: Record<string, ComponentPaths>;
1027
- /** 元信息 */
1028
- metadata?: {
1029
- description?: string;
1030
- version?: string;
1031
- author?: string;
1032
- };
1033
- }
1034
- /**
1035
- * Component 配置变更事件
1036
- */
1037
- interface ComponentConfigChangeEvent {
1038
- /** Component 名称 */
1039
- component: string;
1040
- /** 变更的配置键 */
1041
- key: string;
1042
- /** 旧值 */
1043
- oldValue: unknown;
1044
- /** 新值 */
1045
- newValue: unknown;
1046
- /** 是否持久化 */
1047
- persisted: boolean;
1048
- /** 时间戳 */
1049
- timestamp: number;
1050
- }
1051
- /**
1052
- * Component 配置监听回调
1053
- */
1054
- type ComponentWatchCallback = (event: ComponentConfigChangeEvent) => void | Promise<void>;
1055
- /**
1056
- * Component 基类接口
1057
- */
1058
- interface Component {
1059
- /** Component 名称 */
1060
- readonly name: string;
1061
- /** Component 版本 */
1062
- readonly version: string;
1063
- /** 获取状态 */
1064
- getStatus(): ComponentStatus;
1065
- /** 获取配置 */
1066
- getConfig(): ComponentConfig;
1067
- /** 初始化 */
1068
- init(config: ComponentConfig): Promise<void>;
1069
- /** 启动 */
1070
- start(): Promise<void>;
1071
- /** 停止 */
1072
- stop(): Promise<void>;
1073
- }
1074
- /**
1075
- * Component 基类实现
1076
- */
1077
- declare abstract class BaseComponent implements Component {
1078
- abstract readonly name: string;
1079
- abstract readonly version: string;
1080
- protected _status: ComponentStatus;
1081
- protected _enabled: boolean;
1082
- protected env: Environment;
1083
- /** Hook 管理器 - 子类初始化时由构造函数设置 */
1084
- readonly hookManager: HookManager;
1085
- constructor();
1086
- getStatus(): ComponentStatus;
1087
- getConfig(): ComponentConfig;
1088
- /**
1089
- * 检查 Environment 是否已初始化
1090
- */
1091
- protected isEnvInitialized(): boolean;
1092
- protected setStatus(status: ComponentStatus): void;
1093
- /**
1094
- * 获取 Environment 实例
1095
- */
1096
- protected getEnv(): Environment;
1097
- init(config?: ComponentConfig): Promise<void>;
1098
- start(): Promise<void>;
1099
- stop(): Promise<void>;
1100
- /**
1101
- * 子类可覆盖的钩子方法
1102
- */
1103
- protected onInit(): Promise<void>;
1104
- protected onStart(): Promise<void>;
1105
- protected onStop(): Promise<void>;
1106
- /**
1107
- * 注册 Hook
1108
- *
1109
- * @param hookPoint Hook 点名称
1110
- * @param hook Hook 实例
1111
- */
1112
- protected registerHook<T = unknown>(hookPoint: string, hook: Hook<T>): void;
1113
- /**
1114
- * 便捷方法:快速注册 Hook
1115
- */
1116
- protected addHook<T = unknown>(hookPoint: string, name: string, fn: HookFn<T>, priority?: number): void;
1117
- /**
1118
- * 便捷方法:按名称取消注册 Hook
1119
- */
1120
- protected removeHook(hookPoint: string, name: string): boolean;
1121
- /**
1122
- * 执行 Hook
1123
- */
1124
- protected executeHooks<T = unknown>(hookPoint: string, data: T, metadata?: Record<string, unknown>): Promise<void>;
1125
- /**
1126
- * 获取 ConfigComponent 实例
1127
- *
1128
- * 子类可使用此方法获取配置组件,支持热更新
1129
- */
1130
- protected getConfigComponent(): {
1131
- get(key: string): unknown;
1132
- } | undefined;
1133
- /**
1134
- * 动态获取运行时配置值
1135
- *
1136
- * 优先从 ConfigComponent 获取(支持热更新),否则返回默认值
1137
- * 适用于运行时可能变化的配置(如 API Keys、模型参数)
1138
- *
1139
- * @param key 配置键(支持点号分隔的路径,如 "llm.temperature")
1140
- * @param defaultValue 默认值
1141
- * @returns 配置值或默认值
1142
- *
1143
- * @example
1144
- * ```typescript
1145
- * // 获取 LLM 温度配置(可能支持热更新)
1146
- * const temperature = this.getRuntimeConfig("llm.temperature", 0.7);
1147
- *
1148
- * // 获取 API Key
1149
- * const apiKey = this.getRuntimeConfig<string>("llm.providers.openai.apiKey");
1150
- * ```
1151
- */
1152
- protected getRuntimeConfig<T>(key: string, defaultValue: T): T;
1153
- }
1154
- declare class SkillComponent extends BaseComponent {
1155
- name: string;
1156
- version: string;
1157
- private config;
1158
- private toolComponent?;
1159
- private scanner;
1160
- private skillsMap;
1161
- private configComponent?;
1162
- private configWatcher?;
1163
- init(config?: ComponentConfig): Promise<void>;
1164
- /**
1165
- * 注册配置到 ConfigComponent
1166
- *
1167
- * 配置加载顺序(优先级从低到高):
1168
- * 1. Defaults - 默认值(最低)
1169
- * 2. FileSource - 从配置文件加载
1170
- * 3. EnvSource - 从环境变量加载
1171
- * 4. config 对象 - 直接传入的配置(最高)
1172
- */
1173
- private registerConfig;
1174
- /**
1175
- * 构建最终配置对象
1176
- */
1177
- private buildConfig;
1178
- /**
1179
- * 将配置对象展平为点号路径
1180
- */
1181
- private flattenConfig;
1182
- /**
1183
- * 注册配置热更新监听
1184
- */
1185
- private registerConfigWatcher;
1186
- /**
1187
- * 处理配置变更
1188
- */
1189
- protected onConfigChange(event: {
1190
- key: string;
1191
- oldValue?: unknown;
1192
- newValue?: unknown;
1193
- }): void;
1194
- start(): Promise<void>;
1195
- stop(): Promise<void>;
1196
- /**
1197
- * 获取指定 skill
1198
- */
1199
- getSkill(name: string): SkillEntry | undefined;
1200
- /**
1201
- * 获取所有 skill 列表(用于 tool description)
1202
- */
1203
- getSkillList(): SkillListItem[];
1204
- /**
1205
- * 检查 skill 是否存在
1206
- */
1207
- hasSkill(name: string): boolean;
1208
- /**
1209
- * 获取所有 skills
1210
- */
1211
- getAllSkills(): SkillEntry[];
1212
- /**
1213
- * 扫描所有 skillPaths 并加载 skills
1214
- */
1215
- scanSkills(): Promise<void>;
1216
- /**
1217
- * 重新扫描并更新 Tool
1218
- */
1219
- reload(): Promise<void>;
1220
- private registerTool;
1221
- }
1222
- /**
1223
- * 默认配置
1224
- */
1225
- declare const DEFAULT_SKILL_CONFIG: SkillConfig;
1226
- /**
1227
- * 优先级映射(后面的优先级更高)
1228
- */
1229
- declare const SOURCE_PRIORITY: Record<string, number>;
1230
- /**
1231
- * 获取来源优先级
1232
- */
1233
- declare function getSourcePriority(source: string): number;
1234
- /**
1235
- * 解析 frontmatter 文本
1236
- */
1237
- declare function parseFrontmatter(text: string): Record<string, string>;
1238
- /**
1239
- * 解析 SKILL.md 文件
1240
- */
1241
- declare function parseSkillFile(filePath: string, source: SkillSource): Promise<SkillEntry | null>;
1242
- /**
1243
- * Skill 扫描器
1244
- */
1245
- declare class SkillScanner {
1246
- private config;
1247
- private skillsMap;
1248
- constructor(config: SkillConfig);
1249
- /**
1250
- * 扫描所有 skillPaths 并加载 skills
1251
- */
1252
- scan(): Promise<Map<string, SkillEntry>>;
1253
- /**
1254
- * 扫描单个路径
1255
- */
1256
- private scanPath;
1257
- /**
1258
- * 处理单个 SKILL.md 文件
1259
- */
1260
- private processFile;
1261
- /**
1262
- * 获取扫描结果
1263
- */
1264
- getSkills(): Map<string, SkillEntry>;
1265
- }
1266
- export { parseSkillFile, parseFrontmatter, getSourcePriority, createSkillTool, buildSkillDescription, SkillToolSchema, SkillToolParams, SkillSource, SkillScanner, SkillPath, SkillListItem, SkillEntry, SkillConfig, SkillComponent, SOURCE_PRIORITY, DEFAULT_SKILL_CONFIG };