agentdev 0.1.8 → 0.1.10

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 (187) hide show
  1. package/dist/BasicAgent-R7DYGTHF.js +13 -0
  2. package/dist/ExplorerAgent-DXY3OQ5U.js +13 -0
  3. package/dist/{chunk-OBOU27DM.js → chunk-3AR3JBW6.js} +6701 -1730
  4. package/dist/chunk-3AR3JBW6.js.map +1 -0
  5. package/dist/{chunk-F3PR7UTL.js → chunk-72H6A6NB.js} +5 -3
  6. package/dist/{chunk-F3PR7UTL.js.map → chunk-72H6A6NB.js.map} +1 -1
  7. package/dist/{chunk-TSASFMRF.js → chunk-BAP2GCYH.js} +1 -1
  8. package/dist/chunk-BAP2GCYH.js.map +1 -0
  9. package/dist/{chunk-3BPSNNK3.js → chunk-EECW6PYP.js} +11 -9
  10. package/dist/chunk-EECW6PYP.js.map +1 -0
  11. package/dist/chunk-G5ECPY4K.js +551 -0
  12. package/dist/chunk-G5ECPY4K.js.map +1 -0
  13. package/dist/{chunk-LLV3W326.js → chunk-NORTAQIL.js} +67 -20
  14. package/dist/chunk-NORTAQIL.js.map +1 -0
  15. package/dist/{chunk-LQTEETML.js → chunk-REOJZCSZ.js} +12 -7
  16. package/dist/chunk-REOJZCSZ.js.map +1 -0
  17. package/dist/cli/server.js +2 -2
  18. package/dist/cli/viewer.js +2 -2
  19. package/dist/create-feature-cli.js +26 -7
  20. package/dist/features/shell/templates/bash.render.d.ts +1 -1
  21. package/dist/features/websearch/templates/web-fetch.render.d.ts +1 -1
  22. package/dist/index.d.ts +1755 -497
  23. package/dist/index.js +30 -8
  24. package/dist/index.js.map +1 -1
  25. package/dist/{notification-3VEAP7YF.js → notification-NWVOS2WR.js} +3 -3
  26. package/dist/tools-LDR3LIJP.js +14 -0
  27. package/dist/tools-LDR3LIJP.js.map +1 -0
  28. package/dist/{types-DUKIIntb.d.ts → types-CF5UsxD9.d.ts} +3 -0
  29. package/node_modules/@sliverp/qqbot/LICENSE +21 -0
  30. package/node_modules/@sliverp/qqbot/README.md +427 -0
  31. package/node_modules/@sliverp/qqbot/README.standalone.zh.md +77 -0
  32. package/node_modules/@sliverp/qqbot/README.zh.md +423 -0
  33. package/node_modules/@sliverp/qqbot/bin/qqbot-cli.js +227 -0
  34. package/node_modules/@sliverp/qqbot/clawdbot.plugin.json +16 -0
  35. package/node_modules/@sliverp/qqbot/dist/index.d.ts +20 -0
  36. package/node_modules/@sliverp/qqbot/dist/index.js +25 -0
  37. package/node_modules/@sliverp/qqbot/dist/src/agent.d.ts +76 -0
  38. package/node_modules/@sliverp/qqbot/dist/src/agent.js +36 -0
  39. package/node_modules/@sliverp/qqbot/dist/src/api.d.ts +138 -0
  40. package/node_modules/@sliverp/qqbot/dist/src/api.js +523 -0
  41. package/node_modules/@sliverp/qqbot/dist/src/channel.d.ts +3 -0
  42. package/node_modules/@sliverp/qqbot/dist/src/channel.js +349 -0
  43. package/node_modules/@sliverp/qqbot/dist/src/config.d.ts +25 -0
  44. package/node_modules/@sliverp/qqbot/dist/src/config.js +156 -0
  45. package/node_modules/@sliverp/qqbot/dist/src/demo-standalone.d.ts +1 -0
  46. package/node_modules/@sliverp/qqbot/dist/src/demo-standalone.js +125 -0
  47. package/node_modules/@sliverp/qqbot/dist/src/gateway.d.ts +20 -0
  48. package/node_modules/@sliverp/qqbot/dist/src/gateway.js +2156 -0
  49. package/node_modules/@sliverp/qqbot/dist/src/image-server.d.ts +62 -0
  50. package/node_modules/@sliverp/qqbot/dist/src/image-server.js +401 -0
  51. package/node_modules/@sliverp/qqbot/dist/src/known-users.d.ts +100 -0
  52. package/node_modules/@sliverp/qqbot/dist/src/known-users.js +263 -0
  53. package/node_modules/@sliverp/qqbot/dist/src/onboarding.d.ts +10 -0
  54. package/node_modules/@sliverp/qqbot/dist/src/onboarding.js +203 -0
  55. package/node_modules/@sliverp/qqbot/dist/src/openclaw-agent-adapter.d.ts +2 -0
  56. package/node_modules/@sliverp/qqbot/dist/src/openclaw-agent-adapter.js +155 -0
  57. package/node_modules/@sliverp/qqbot/dist/src/outbound.d.ts +150 -0
  58. package/node_modules/@sliverp/qqbot/dist/src/outbound.js +1175 -0
  59. package/node_modules/@sliverp/qqbot/dist/src/proactive.d.ts +170 -0
  60. package/node_modules/@sliverp/qqbot/dist/src/proactive.js +399 -0
  61. package/node_modules/@sliverp/qqbot/dist/src/runtime.d.ts +5 -0
  62. package/node_modules/@sliverp/qqbot/dist/src/runtime.js +16 -0
  63. package/node_modules/@sliverp/qqbot/dist/src/session-store.d.ts +52 -0
  64. package/node_modules/@sliverp/qqbot/dist/src/session-store.js +254 -0
  65. package/node_modules/@sliverp/qqbot/dist/src/types.d.ts +145 -0
  66. package/node_modules/@sliverp/qqbot/dist/src/types.js +1 -0
  67. package/node_modules/@sliverp/qqbot/dist/src/utils/audio-convert.d.ts +73 -0
  68. package/node_modules/@sliverp/qqbot/dist/src/utils/audio-convert.js +645 -0
  69. package/node_modules/@sliverp/qqbot/dist/src/utils/file-utils.d.ts +46 -0
  70. package/node_modules/@sliverp/qqbot/dist/src/utils/file-utils.js +107 -0
  71. package/node_modules/@sliverp/qqbot/dist/src/utils/image-size.d.ts +51 -0
  72. package/node_modules/@sliverp/qqbot/dist/src/utils/image-size.js +234 -0
  73. package/node_modules/@sliverp/qqbot/dist/src/utils/media-tags.d.ts +14 -0
  74. package/node_modules/@sliverp/qqbot/dist/src/utils/media-tags.js +120 -0
  75. package/node_modules/@sliverp/qqbot/dist/src/utils/payload.d.ts +112 -0
  76. package/node_modules/@sliverp/qqbot/dist/src/utils/payload.js +186 -0
  77. package/node_modules/@sliverp/qqbot/dist/src/utils/platform.d.ts +126 -0
  78. package/node_modules/@sliverp/qqbot/dist/src/utils/platform.js +358 -0
  79. package/node_modules/@sliverp/qqbot/dist/src/utils/upload-cache.d.ts +34 -0
  80. package/node_modules/@sliverp/qqbot/dist/src/utils/upload-cache.js +93 -0
  81. package/node_modules/@sliverp/qqbot/dist/standalone.d.ts +6 -0
  82. package/node_modules/@sliverp/qqbot/dist/standalone.js +6 -0
  83. package/node_modules/@sliverp/qqbot/index.ts +30 -0
  84. package/node_modules/@sliverp/qqbot/moltbot.plugin.json +16 -0
  85. package/node_modules/@sliverp/qqbot/node_modules/@eshaz/web-worker/LICENSE +201 -0
  86. package/node_modules/@sliverp/qqbot/node_modules/@eshaz/web-worker/README.md +134 -0
  87. package/node_modules/@sliverp/qqbot/node_modules/@eshaz/web-worker/browser.js +17 -0
  88. package/node_modules/@sliverp/qqbot/node_modules/@eshaz/web-worker/cjs/browser.js +16 -0
  89. package/node_modules/@sliverp/qqbot/node_modules/@eshaz/web-worker/cjs/node.js +219 -0
  90. package/node_modules/@sliverp/qqbot/node_modules/@eshaz/web-worker/index.d.ts +4 -0
  91. package/node_modules/@sliverp/qqbot/node_modules/@eshaz/web-worker/node.js +223 -0
  92. package/node_modules/@sliverp/qqbot/node_modules/@eshaz/web-worker/package.json +54 -0
  93. package/node_modules/@sliverp/qqbot/node_modules/@wasm-audio-decoders/common/index.js +5 -0
  94. package/node_modules/@sliverp/qqbot/node_modules/@wasm-audio-decoders/common/package.json +36 -0
  95. package/node_modules/@sliverp/qqbot/node_modules/@wasm-audio-decoders/common/src/WASMAudioDecoderCommon.js +231 -0
  96. package/node_modules/@sliverp/qqbot/node_modules/@wasm-audio-decoders/common/src/WASMAudioDecoderWorker.js +129 -0
  97. package/node_modules/@sliverp/qqbot/node_modules/@wasm-audio-decoders/common/src/puff/README +67 -0
  98. package/node_modules/@sliverp/qqbot/node_modules/@wasm-audio-decoders/common/src/puff/build_puff.js +31 -0
  99. package/node_modules/@sliverp/qqbot/node_modules/@wasm-audio-decoders/common/src/puff/puff.c +863 -0
  100. package/node_modules/@sliverp/qqbot/node_modules/@wasm-audio-decoders/common/src/puff/puff.h +35 -0
  101. package/node_modules/@sliverp/qqbot/node_modules/@wasm-audio-decoders/common/src/utilities.js +3 -0
  102. package/node_modules/@sliverp/qqbot/node_modules/@wasm-audio-decoders/common/types.d.ts +7 -0
  103. package/node_modules/@sliverp/qqbot/node_modules/mpg123-decoder/README.md +265 -0
  104. package/node_modules/@sliverp/qqbot/node_modules/mpg123-decoder/dist/mpg123-decoder.min.js +185 -0
  105. package/node_modules/@sliverp/qqbot/node_modules/mpg123-decoder/dist/mpg123-decoder.min.js.map +1 -0
  106. package/node_modules/@sliverp/qqbot/node_modules/mpg123-decoder/index.js +8 -0
  107. package/node_modules/@sliverp/qqbot/node_modules/mpg123-decoder/package.json +58 -0
  108. package/node_modules/@sliverp/qqbot/node_modules/mpg123-decoder/src/EmscriptenWasm.js +464 -0
  109. package/node_modules/@sliverp/qqbot/node_modules/mpg123-decoder/src/MPEGDecoder.js +200 -0
  110. package/node_modules/@sliverp/qqbot/node_modules/mpg123-decoder/src/MPEGDecoderWebWorker.js +21 -0
  111. package/node_modules/@sliverp/qqbot/node_modules/mpg123-decoder/types.d.ts +30 -0
  112. package/node_modules/@sliverp/qqbot/node_modules/silk-wasm/LICENSE +21 -0
  113. package/node_modules/@sliverp/qqbot/node_modules/silk-wasm/README.md +85 -0
  114. package/node_modules/@sliverp/qqbot/node_modules/silk-wasm/lib/index.cjs +16 -0
  115. package/node_modules/@sliverp/qqbot/node_modules/silk-wasm/lib/index.d.ts +70 -0
  116. package/node_modules/@sliverp/qqbot/node_modules/silk-wasm/lib/index.mjs +16 -0
  117. package/node_modules/@sliverp/qqbot/node_modules/silk-wasm/lib/silk.wasm +0 -0
  118. package/node_modules/@sliverp/qqbot/node_modules/silk-wasm/lib/utils.d.ts +4 -0
  119. package/node_modules/@sliverp/qqbot/node_modules/silk-wasm/package.json +39 -0
  120. package/node_modules/@sliverp/qqbot/node_modules/simple-yenc/.github/FUNDING.yml +1 -0
  121. package/node_modules/@sliverp/qqbot/node_modules/simple-yenc/.prettierignore +1 -0
  122. package/node_modules/@sliverp/qqbot/node_modules/simple-yenc/LICENSE +7 -0
  123. package/node_modules/@sliverp/qqbot/node_modules/simple-yenc/README.md +163 -0
  124. package/node_modules/@sliverp/qqbot/node_modules/simple-yenc/dist/esm.js +1 -0
  125. package/node_modules/@sliverp/qqbot/node_modules/simple-yenc/dist/index.js +1 -0
  126. package/node_modules/@sliverp/qqbot/node_modules/simple-yenc/package.json +50 -0
  127. package/node_modules/@sliverp/qqbot/node_modules/simple-yenc/rollup.config.js +27 -0
  128. package/node_modules/@sliverp/qqbot/node_modules/simple-yenc/src/simple-yenc.js +302 -0
  129. package/node_modules/@sliverp/qqbot/node_modules/ws/LICENSE +20 -0
  130. package/node_modules/@sliverp/qqbot/node_modules/ws/README.md +548 -0
  131. package/node_modules/@sliverp/qqbot/node_modules/ws/browser.js +8 -0
  132. package/node_modules/@sliverp/qqbot/node_modules/ws/index.js +13 -0
  133. package/node_modules/@sliverp/qqbot/node_modules/ws/lib/buffer-util.js +131 -0
  134. package/node_modules/@sliverp/qqbot/node_modules/ws/lib/constants.js +19 -0
  135. package/node_modules/@sliverp/qqbot/node_modules/ws/lib/event-target.js +292 -0
  136. package/node_modules/@sliverp/qqbot/node_modules/ws/lib/extension.js +203 -0
  137. package/node_modules/@sliverp/qqbot/node_modules/ws/lib/limiter.js +55 -0
  138. package/node_modules/@sliverp/qqbot/node_modules/ws/lib/permessage-deflate.js +528 -0
  139. package/node_modules/@sliverp/qqbot/node_modules/ws/lib/receiver.js +706 -0
  140. package/node_modules/@sliverp/qqbot/node_modules/ws/lib/sender.js +602 -0
  141. package/node_modules/@sliverp/qqbot/node_modules/ws/lib/stream.js +161 -0
  142. package/node_modules/@sliverp/qqbot/node_modules/ws/lib/subprotocol.js +62 -0
  143. package/node_modules/@sliverp/qqbot/node_modules/ws/lib/validation.js +152 -0
  144. package/node_modules/@sliverp/qqbot/node_modules/ws/lib/websocket-server.js +554 -0
  145. package/node_modules/@sliverp/qqbot/node_modules/ws/lib/websocket.js +1393 -0
  146. package/node_modules/@sliverp/qqbot/node_modules/ws/package.json +69 -0
  147. package/node_modules/@sliverp/qqbot/node_modules/ws/wrapper.mjs +8 -0
  148. package/node_modules/@sliverp/qqbot/openclaw.plugin.json +16 -0
  149. package/node_modules/@sliverp/qqbot/package.json +81 -0
  150. package/node_modules/@sliverp/qqbot/skills/qqbot-cron/SKILL.md +513 -0
  151. package/node_modules/@sliverp/qqbot/skills/qqbot-media/SKILL.md +194 -0
  152. package/node_modules/@sliverp/qqbot/src/agent.ts +133 -0
  153. package/node_modules/@sliverp/qqbot/src/api.ts +704 -0
  154. package/node_modules/@sliverp/qqbot/src/channel.ts +380 -0
  155. package/node_modules/@sliverp/qqbot/src/config.ts +182 -0
  156. package/node_modules/@sliverp/qqbot/src/demo-standalone.ts +144 -0
  157. package/node_modules/@sliverp/qqbot/src/gateway.ts +2285 -0
  158. package/node_modules/@sliverp/qqbot/src/image-server.ts +474 -0
  159. package/node_modules/@sliverp/qqbot/src/known-users.ts +353 -0
  160. package/node_modules/@sliverp/qqbot/src/onboarding.ts +274 -0
  161. package/node_modules/@sliverp/qqbot/src/openclaw-agent-adapter.ts +168 -0
  162. package/node_modules/@sliverp/qqbot/src/openclaw-plugin-sdk.d.ts +483 -0
  163. package/node_modules/@sliverp/qqbot/src/outbound.ts +1301 -0
  164. package/node_modules/@sliverp/qqbot/src/proactive.ts +530 -0
  165. package/node_modules/@sliverp/qqbot/src/runtime.ts +22 -0
  166. package/node_modules/@sliverp/qqbot/src/session-store.ts +303 -0
  167. package/node_modules/@sliverp/qqbot/src/types.ts +153 -0
  168. package/node_modules/@sliverp/qqbot/src/utils/audio-convert.ts +738 -0
  169. package/node_modules/@sliverp/qqbot/src/utils/file-utils.ts +122 -0
  170. package/node_modules/@sliverp/qqbot/src/utils/image-size.ts +266 -0
  171. package/node_modules/@sliverp/qqbot/src/utils/media-tags.ts +134 -0
  172. package/node_modules/@sliverp/qqbot/src/utils/payload.ts +265 -0
  173. package/node_modules/@sliverp/qqbot/src/utils/platform.ts +404 -0
  174. package/node_modules/@sliverp/qqbot/src/utils/upload-cache.ts +128 -0
  175. package/node_modules/@sliverp/qqbot/standalone.ts +6 -0
  176. package/node_modules/@sliverp/qqbot/tsconfig.json +16 -0
  177. package/package.json +10 -2
  178. package/dist/BasicAgent-QWEYCLV5.js +0 -12
  179. package/dist/ExplorerAgent-4IT22VB7.js +0 -12
  180. package/dist/chunk-3BPSNNK3.js.map +0 -1
  181. package/dist/chunk-LLV3W326.js.map +0 -1
  182. package/dist/chunk-LQTEETML.js.map +0 -1
  183. package/dist/chunk-OBOU27DM.js.map +0 -1
  184. package/dist/chunk-TSASFMRF.js.map +0 -1
  185. /package/dist/{BasicAgent-QWEYCLV5.js.map → BasicAgent-R7DYGTHF.js.map} +0 -0
  186. /package/dist/{ExplorerAgent-4IT22VB7.js.map → ExplorerAgent-DXY3OQ5U.js.map} +0 -0
  187. /package/dist/{notification-3VEAP7YF.js.map → notification-NWVOS2WR.js.map} +0 -0
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { E as EnrichedMessage, M as MessageTag, a as Message, L as LLMResponse, T as ToolCall, b as Tool, c as LogContextRef, A as AgentConfig, I as InlineRenderTemplate, d as ToolRenderConfig, H as HookInspectorSnapshot, e as AgentOverviewSnapshot, f as AgentInfo, N as Notification, U as UserInputRequest, g as UserInputResponse, h as UsageStatsSnapshot, i as TemplateSource, j as TemplateLoader, k as UsageStats, P as PlaceholderContext, l as UsageInfo, m as UserInputAction, n as LLMClient, o as MessageRole, p as AgentSession } from './types-DUKIIntb.js';
2
- export { C as CacheStats, q as ContextMiddleware, D as DebugHubIPCMessage, r as TemplateComposer, s as TemplateError, t as TemplateLoaderOptions, u as TemplateResult, v as ToolMetadata, w as getDefaultUDSPath } from './types-DUKIIntb.js';
1
+ import { E as EnrichedMessage, M as MessageTag, a as Message, L as LLMResponse, T as ToolCall, b as Tool, A as AgentConfig, I as InlineRenderTemplate, c as LogContextRef, d as ToolRenderConfig, H as HookInspectorSnapshot, e as AgentOverviewSnapshot, f as AgentInfo, N as Notification, U as UserInputRequest, g as UserInputResponse, h as UsageStatsSnapshot, i as TemplateSource, j as TemplateLoader, k as UsageStats, P as PlaceholderContext, l as UsageInfo, m as UserInputAction, n as LLMClient, o as MessageRole, p as AgentSession } from './types-CF5UsxD9.js';
2
+ export { C as CacheStats, q as ContextMiddleware, D as DebugHubIPCMessage, r as TemplateComposer, s as TemplateError, t as TemplateLoaderOptions, u as TemplateResult, v as ToolMetadata, w as getDefaultUDSPath } from './types-CF5UsxD9.js';
3
3
  import { Client } from '@modelcontextprotocol/sdk/client/index.js';
4
4
  import { IncomingMessage, ServerResponse } from 'http';
5
5
 
@@ -236,6 +236,203 @@ declare class Context {
236
236
  private generateId;
237
237
  }
238
238
 
239
+ /**
240
+ * Feature 上下文值类型
241
+ */
242
+ type ToolContextValue = Record<string, unknown>;
243
+ /**
244
+ * Feature 上下文注入器
245
+ * 返回要注入到 tool.execute() 的额外参数
246
+ */
247
+ type ContextInjector = (call: ToolCall) => ToolContextValue;
248
+ /**
249
+ * Feature 运行时上下文
250
+ */
251
+ interface FeatureContext {
252
+ agentId: string;
253
+ config: AgentConfig;
254
+ getFeature<T extends AgentFeature>(name: string): T | undefined;
255
+ }
256
+ /**
257
+ * Feature 快照状态
258
+ *
259
+ * 第一阶段只支持显式白名单状态:
260
+ * - Feature 自己决定要保存什么
261
+ * - 未声明的状态一律不保证恢复
262
+ */
263
+ type FeatureStateSnapshot = unknown;
264
+ /**
265
+ * 包信息
266
+ */
267
+ interface PackageInfo {
268
+ /** 包名,如 '@agentdev/shell-feature' 或 'agentdev' */
269
+ name: string;
270
+ /** 版本号(可选) */
271
+ version?: string;
272
+ /** 包根目录绝对路径 */
273
+ root: string;
274
+ }
275
+ /**
276
+ * Feature 初始化上下文
277
+ */
278
+ interface FeatureInitContext {
279
+ /** Agent ID */
280
+ agentId: string;
281
+ /** Agent 配置 */
282
+ config: AgentConfig;
283
+ /** Feature 级结构化日志 */
284
+ logger: Logger;
285
+ /** Feature 特定配置 */
286
+ featureConfig?: unknown;
287
+ /** 获取其他 Feature */
288
+ getFeature<T extends AgentFeature>(name: string): T | undefined;
289
+ /** 注册工具 */
290
+ registerTool(tool: Tool): void;
291
+ }
292
+ /**
293
+ * Feature 初始化上下文
294
+ */
295
+ interface FeatureInitContext {
296
+ /** Agent ID */
297
+ agentId: string;
298
+ /** Agent 配置 */
299
+ config: AgentConfig;
300
+ /** Feature 级结构化日志 */
301
+ logger: Logger;
302
+ /** Feature 特定配置 */
303
+ featureConfig?: unknown;
304
+ /** 获取其他 Feature */
305
+ getFeature<T extends AgentFeature>(name: string): T | undefined;
306
+ /** 注册工具 */
307
+ registerTool(tool: Tool): void;
308
+ }
309
+ /**
310
+ * Agent Feature 接口
311
+ *
312
+ * 可外挂的功能模块,提供工具和上下文注入
313
+ */
314
+ interface AgentFeature {
315
+ /** Feature 名称 */
316
+ readonly name: string;
317
+ /** 依赖的其他 Feature */
318
+ readonly dependencies?: string[];
319
+ /** 可选:用于调试器展示的源码位置 */
320
+ readonly source?: string;
321
+ /** 可选:用于调试器展示的 Feature 描述 */
322
+ readonly description?: string;
323
+ /**
324
+ * 获取同步工具(已知工具列表)
325
+ */
326
+ getTools?(): Tool[];
327
+ /**
328
+ * 获取异步工具(需要连接、发现等)
329
+ */
330
+ getAsyncTools?(ctx: FeatureInitContext): Promise<Tool[]>;
331
+ /**
332
+ * 获取包信息
333
+ *
334
+ * 返回 Feature 所在的包信息(包名、版本、根目录)
335
+ * 用于统一模板路径解析和包管理
336
+ *
337
+ * @returns 包信息,如果 Feature 不属于任何包则返回 null
338
+ *
339
+ * @example
340
+ * ```typescript
341
+ * getPackageInfo(): PackageInfo | null {
342
+ * return {
343
+ * name: '@agentdev/shell-feature',
344
+ * version: '1.0.0',
345
+ * root: '/path/to/package/root'
346
+ * };
347
+ * }
348
+ * ```
349
+ */
350
+ getPackageInfo?(): PackageInfo | null;
351
+ /**
352
+ * 获取模板名称列表
353
+ *
354
+ * 返回 Feature 提供的模板名称列表(不含扩展名)
355
+ * 模板文件必须位于 {packageRoot}/dist/templates/{templateName}.render.js
356
+ *
357
+ * @returns 模板名称数组
358
+ *
359
+ * @example
360
+ * ```typescript
361
+ * getTemplateNames(): string[] {
362
+ * return ['bash', 'trash-delete', 'trash-list'];
363
+ * }
364
+ * ```
365
+ */
366
+ getTemplateNames?(): string[];
367
+ /**
368
+ * 声明渲染模板(推荐方式)
369
+ * 直接返回模板对象,无需文件路径
370
+ *
371
+ * @example
372
+ * ```typescript
373
+ * getRenderTemplates(): Record<string, InlineRenderTemplate> {
374
+ * return {
375
+ * 'bash': {
376
+ * call: (args) => `<div class="bash-command">> ${escapeHtml(args.command)}</div>`,
377
+ * result: (data, success) => success
378
+ * ? `<pre class="bash-output">${escapeHtml(data)}</pre>`
379
+ * : `<div class="tool-error">${escapeHtml(data)}</div>`
380
+ * }
381
+ * };
382
+ * }
383
+ * ```
384
+ */
385
+ getRenderTemplates?(): Record<string, InlineRenderTemplate>;
386
+ /**
387
+ * 声明上下文注入器
388
+ */
389
+ getContextInjectors?(): Map<string | RegExp, ContextInjector>;
390
+ /**
391
+ * 初始化钩子
392
+ */
393
+ onInitiate?(ctx: FeatureInitContext): Promise<void>;
394
+ /**
395
+ * 清理钩子
396
+ */
397
+ onDestroy?(ctx: FeatureContext): Promise<void>;
398
+ /**
399
+ * 捕获可回滚的 Feature 状态
400
+ *
401
+ * 仅返回显式声明、可序列化的状态。
402
+ * 未返回的字段不会参与 rollback。
403
+ */
404
+ captureState?(): FeatureStateSnapshot;
405
+ /**
406
+ * 从快照恢复 Feature 状态
407
+ */
408
+ restoreState?(snapshot: FeatureStateSnapshot): void | Promise<void>;
409
+ /**
410
+ * rollback 前钩子
411
+ */
412
+ beforeRollback?(snapshot: FeatureStateSnapshot): void | Promise<void>;
413
+ /**
414
+ * rollback 后钩子
415
+ */
416
+ afterRollback?(snapshot: FeatureStateSnapshot): void | Promise<void>;
417
+ /**
418
+ * 可选:为调试器提供 hook 的人类可读说明
419
+ */
420
+ getHookDescription?(lifecycle: string, methodName: string): string | undefined;
421
+ }
422
+ /**
423
+ * 从 Feature 的 source 属性获取包信息
424
+ *
425
+ * 通过向上查找 package.json 文件来确定包信息
426
+ * 支持三种场景:
427
+ * 1. 框架内置 Feature:找到 AgentDev 的 package.json
428
+ * 2. 外部 npm 包:找到包的 package.json
429
+ * 3. 用户本地 Feature:找到用户项目的 package.json
430
+ *
431
+ * @param source Feature 的源文件路径(import.meta.url)
432
+ * @returns 包信息,如果找不到 package.json 则返回 null
433
+ */
434
+ declare function getPackageInfoFromSource(source: string | undefined): PackageInfo | null;
435
+
239
436
  /**
240
437
  * 生命周期类型定义
241
438
  * 定义 Agent 生命周期钩子相关的类型
@@ -347,6 +544,8 @@ interface ToolContext {
347
544
  input: string;
348
545
  /** 消息上下文(可读写) */
349
546
  context: Context;
547
+ /** 获取其他 Feature */
548
+ getFeature<T extends AgentFeature>(name: string): T | undefined;
350
549
  }
351
550
  /**
352
551
  * 工具结果 - onToolFinished 钩子的参数
@@ -372,6 +571,8 @@ interface ToolResult {
372
571
  input: string;
373
572
  /** 消息上下文 */
374
573
  context: Context;
574
+ /** 获取其他 Feature */
575
+ getFeature<T extends AgentFeature>(name: string): T | undefined;
375
576
  }
376
577
  /**
377
578
  * 钩子返回值类型(扩展版)
@@ -498,225 +699,29 @@ declare function runWithLogScope<T>(scope: LogContextRef, fn: () => T): T;
498
699
  declare function createLogger(namespace: string, bindings?: LoggerBindings): Logger;
499
700
 
500
701
  /**
501
- * Feature 上下文值类型
502
- */
503
- type ToolContextValue = Record<string, unknown>;
504
- /**
505
- * Feature 上下文注入器
506
- * 返回要注入到 tool.execute() 的额外参数
507
- */
508
- type ContextInjector = (call: ToolCall) => ToolContextValue;
509
- /**
510
- * Feature 运行时上下文
702
+ * 工具定义
703
+ * 简单的工具创建函数
511
704
  */
512
- interface FeatureContext {
513
- agentId: string;
514
- config: AgentConfig;
515
- }
705
+
516
706
  /**
517
- * Feature 快照状态
518
- *
519
- * 第一阶段只支持显式白名单状态:
520
- * - Feature 自己决定要保存什么
521
- * - 未声明的状态一律不保证恢复
707
+ * 渲染配置扩展类型
708
+ * 支持字符串(模板名称)或配置对象
522
709
  */
523
- type FeatureStateSnapshot = unknown;
710
+ type ToolRenderInput = ToolRenderConfig | string;
524
711
  /**
525
- * 包信息
712
+ * 创建一个工具
713
+ * @param config 工具配置
714
+ * @param sourceFile 可选:调用此函数的源文件路径(用于自动查找渲染文件)
526
715
  */
527
- interface PackageInfo {
528
- /** 包名,如 '@agentdev/shell-feature' 或 'agentdev' */
716
+ declare function createTool(config: {
529
717
  name: string;
530
- /** 版本号(可选) */
531
- version?: string;
532
- /** 包根目录绝对路径 */
533
- root: string;
534
- }
718
+ description: string;
719
+ parameters?: Record<string, any>;
720
+ execute: (args: any, context?: any) => Promise<any>;
721
+ render?: ToolRenderInput;
722
+ }, sourceFile?: string): Tool;
535
723
  /**
536
- * Feature 初始化上下文
537
- */
538
- interface FeatureInitContext {
539
- /** Agent ID */
540
- agentId: string;
541
- /** Agent 配置 */
542
- config: AgentConfig;
543
- /** Feature 级结构化日志 */
544
- logger: Logger;
545
- /** Feature 特定配置 */
546
- featureConfig?: unknown;
547
- /** 获取其他 Feature */
548
- getFeature<T extends AgentFeature>(name: string): T | undefined;
549
- /** 注册工具 */
550
- registerTool(tool: Tool): void;
551
- }
552
- /**
553
- * Feature 初始化上下文
554
- */
555
- interface FeatureInitContext {
556
- /** Agent ID */
557
- agentId: string;
558
- /** Agent 配置 */
559
- config: AgentConfig;
560
- /** Feature 级结构化日志 */
561
- logger: Logger;
562
- /** Feature 特定配置 */
563
- featureConfig?: unknown;
564
- /** 获取其他 Feature */
565
- getFeature<T extends AgentFeature>(name: string): T | undefined;
566
- /** 注册工具 */
567
- registerTool(tool: Tool): void;
568
- }
569
- /**
570
- * Agent Feature 接口
571
- *
572
- * 可外挂的功能模块,提供工具和上下文注入
573
- */
574
- interface AgentFeature {
575
- /** Feature 名称 */
576
- readonly name: string;
577
- /** 依赖的其他 Feature */
578
- readonly dependencies?: string[];
579
- /** 可选:用于调试器展示的源码位置 */
580
- readonly source?: string;
581
- /** 可选:用于调试器展示的 Feature 描述 */
582
- readonly description?: string;
583
- /**
584
- * 获取同步工具(已知工具列表)
585
- */
586
- getTools?(): Tool[];
587
- /**
588
- * 获取异步工具(需要连接、发现等)
589
- */
590
- getAsyncTools?(ctx: FeatureInitContext): Promise<Tool[]>;
591
- /**
592
- * 获取包信息
593
- *
594
- * 返回 Feature 所在的包信息(包名、版本、根目录)
595
- * 用于统一模板路径解析和包管理
596
- *
597
- * @returns 包信息,如果 Feature 不属于任何包则返回 null
598
- *
599
- * @example
600
- * ```typescript
601
- * getPackageInfo(): PackageInfo | null {
602
- * return {
603
- * name: '@agentdev/shell-feature',
604
- * version: '1.0.0',
605
- * root: '/path/to/package/root'
606
- * };
607
- * }
608
- * ```
609
- */
610
- getPackageInfo?(): PackageInfo | null;
611
- /**
612
- * 获取模板名称列表
613
- *
614
- * 返回 Feature 提供的模板名称列表(不含扩展名)
615
- * 模板文件必须位于 {packageRoot}/dist/templates/{templateName}.render.js
616
- *
617
- * @returns 模板名称数组
618
- *
619
- * @example
620
- * ```typescript
621
- * getTemplateNames(): string[] {
622
- * return ['bash', 'trash-delete', 'trash-list'];
623
- * }
624
- * ```
625
- */
626
- getTemplateNames?(): string[];
627
- /**
628
- * 声明渲染模板(推荐方式)
629
- * 直接返回模板对象,无需文件路径
630
- *
631
- * @example
632
- * ```typescript
633
- * getRenderTemplates(): Record<string, InlineRenderTemplate> {
634
- * return {
635
- * 'bash': {
636
- * call: (args) => `<div class="bash-command">> ${escapeHtml(args.command)}</div>`,
637
- * result: (data, success) => success
638
- * ? `<pre class="bash-output">${escapeHtml(data)}</pre>`
639
- * : `<div class="tool-error">${escapeHtml(data)}</div>`
640
- * }
641
- * };
642
- * }
643
- * ```
644
- */
645
- getRenderTemplates?(): Record<string, InlineRenderTemplate>;
646
- /**
647
- * 声明上下文注入器
648
- */
649
- getContextInjectors?(): Map<string | RegExp, ContextInjector>;
650
- /**
651
- * 初始化钩子
652
- */
653
- onInitiate?(ctx: FeatureInitContext): Promise<void>;
654
- /**
655
- * 清理钩子
656
- */
657
- onDestroy?(ctx: FeatureContext): Promise<void>;
658
- /**
659
- * 捕获可回滚的 Feature 状态
660
- *
661
- * 仅返回显式声明、可序列化的状态。
662
- * 未返回的字段不会参与 rollback。
663
- */
664
- captureState?(): FeatureStateSnapshot;
665
- /**
666
- * 从快照恢复 Feature 状态
667
- */
668
- restoreState?(snapshot: FeatureStateSnapshot): void | Promise<void>;
669
- /**
670
- * rollback 前钩子
671
- */
672
- beforeRollback?(snapshot: FeatureStateSnapshot): void | Promise<void>;
673
- /**
674
- * rollback 后钩子
675
- */
676
- afterRollback?(snapshot: FeatureStateSnapshot): void | Promise<void>;
677
- /**
678
- * 可选:为调试器提供 hook 的人类可读说明
679
- */
680
- getHookDescription?(lifecycle: string, methodName: string): string | undefined;
681
- }
682
- /**
683
- * 从 Feature 的 source 属性获取包信息
684
- *
685
- * 通过向上查找 package.json 文件来确定包信息
686
- * 支持三种场景:
687
- * 1. 框架内置 Feature:找到 AgentDev 的 package.json
688
- * 2. 外部 npm 包:找到包的 package.json
689
- * 3. 用户本地 Feature:找到用户项目的 package.json
690
- *
691
- * @param source Feature 的源文件路径(import.meta.url)
692
- * @returns 包信息,如果找不到 package.json 则返回 null
693
- */
694
- declare function getPackageInfoFromSource(source: string | undefined): PackageInfo | null;
695
-
696
- /**
697
- * 工具定义
698
- * 简单的工具创建函数
699
- */
700
-
701
- /**
702
- * 渲染配置扩展类型
703
- * 支持字符串(模板名称)或配置对象
704
- */
705
- type ToolRenderInput = ToolRenderConfig | string;
706
- /**
707
- * 创建一个工具
708
- * @param config 工具配置
709
- * @param sourceFile 可选:调用此函数的源文件路径(用于自动查找渲染文件)
710
- */
711
- declare function createTool(config: {
712
- name: string;
713
- description: string;
714
- parameters?: Record<string, any>;
715
- execute: (args: any, context?: any) => Promise<any>;
716
- render?: ToolRenderInput;
717
- }, sourceFile?: string): Tool;
718
- /**
719
- * 工具注册表 - 管理多个工具
724
+ * 工具注册表 - 管理多个工具
720
725
  */
721
726
  declare class ToolRegistry {
722
727
  private tools;
@@ -848,7 +853,7 @@ declare class DebugHub {
848
853
  * @param featureTemplates Feature 模板路径映射(可选)
849
854
  * @returns 分配的 agentId
850
855
  */
851
- registerAgent(agent: Agent, name?: string, featureTemplates?: Record<string, string>, hookInspector?: HookInspectorSnapshot, overview?: AgentOverviewSnapshot): string;
856
+ registerAgent(agent: Agent, name?: string, featureTemplates?: Record<string, string>, hookInspector?: HookInspectorSnapshot, overview?: AgentOverviewSnapshot, projectRoot?: string): string;
852
857
  /**
853
858
  * 注销 Agent
854
859
  * @param agentId Agent ID
@@ -1007,6 +1012,7 @@ declare class AgentBase {
1007
1012
  protected debugEnabled: boolean;
1008
1013
  protected _agentId?: string;
1009
1014
  protected _parentPool?: any;
1015
+ private _agentTypeRegistry;
1010
1016
  private features;
1011
1017
  private contextInjectors;
1012
1018
  private featureToolsReady;
@@ -1052,7 +1058,9 @@ declare class AgentBase {
1052
1058
  /**
1053
1059
  * 启用可视化查看器
1054
1060
  */
1055
- withViewer(name?: string, port?: number, openBrowser?: boolean): Promise<this>;
1061
+ withViewer(name?: string, port?: number, openBrowser?: boolean, options?: {
1062
+ projectRoot?: string;
1063
+ }): Promise<this>;
1056
1064
  /**
1057
1065
  * 设置上下文
1058
1066
  */
@@ -1125,7 +1133,21 @@ declare class AgentBase {
1125
1133
  */
1126
1134
  protected reportToParent(message: string): Promise<void>;
1127
1135
  /**
1128
- * 创建 Agent 实例(子类可覆盖)
1136
+ * 注册一个可创建的子代理类型
1137
+ *
1138
+ * 通常在 Agent 子类的构造函数中调用:
1139
+ * this.registerAgentType('MyAgent', () => new MyAgent({ llm: this.llm }));
1140
+ */
1141
+ registerAgentType(name: string, factory: () => AgentBase | Promise<AgentBase>): this;
1142
+ /**
1143
+ * 获取当前已注册的所有子代理类型名
1144
+ */
1145
+ getRegisteredAgentTypes(): string[];
1146
+ /**
1147
+ * 创建 Agent 实例
1148
+ *
1149
+ * 优先从实例注册表查找,未命中则 fallback 到内置类型(向后兼容)。
1150
+ * 子类无需覆盖此方法,通过 registerAgentType() 即可扩展。
1129
1151
  */
1130
1152
  createAgentByType(type: string): Promise<AgentBase>;
1131
1153
  /**
@@ -1157,10 +1179,19 @@ declare class AgentBase {
1157
1179
  * if (agent.isEnabled('mcp')) { ... }
1158
1180
  */
1159
1181
  isEnabled(featureName: string): boolean;
1182
+ /**
1183
+ * 按名称获取已挂载的 Feature 实例
1184
+ */
1185
+ getFeature<T extends AgentFeature>(featureName: string): T | undefined;
1160
1186
  /**
1161
1187
  * 确保 Feature 工具已注册
1162
1188
  */
1163
1189
  private ensureFeatureTools;
1190
+ /**
1191
+ * 收集所有 Feature 自带的 skills
1192
+ * 约定:Feature 目录下存在 skills/ 目录则自动发现
1193
+ */
1194
+ private collectFeatureSkills;
1164
1195
  /**
1165
1196
  * 解析相对路径(处理 ./ 和 ../)
1166
1197
  * @param baseDir 基础目录
@@ -1538,91 +1569,279 @@ declare class MCPFeature implements AgentFeature {
1538
1569
  }
1539
1570
 
1540
1571
  /**
1541
- * Agent Skills 类型定义
1542
- */
1543
- /**
1544
- * Skill 元数据
1545
- */
1546
- interface SkillMetadata {
1547
- /** Skill 名称 */
1548
- name: string;
1549
- /** Skill 描述 */
1550
- description: string;
1551
- /** SKILL.md 完整路径 */
1552
- path: string;
1553
- }
1554
- /**
1555
- * Skills 加载器配置
1556
- */
1557
- interface SkillsOptions {
1558
- /** skills 目录,默认 cwd/.agentdev/skills */
1559
- dir?: string;
1560
- }
1561
-
1562
- /**
1563
- * Skill Feature - Skills 发现和 invoke_skill 工具
1572
+ * Audit Feature - 安全审计功能模块
1564
1573
  *
1565
- * Skills 集成从 Agent 核心中解耦,实现可外挂功能
1574
+ * 使用本地大模型(OpenAI 兼容 API)审计 bash 命令安全性
1575
+ * 在工具执行前进行安全检查,拦截危险命令
1566
1576
  *
1567
1577
  * @example
1568
1578
  * ```typescript
1569
- * // 使用默认路径 .agentdev/skills
1570
- * agent.use(new SkillFeature());
1571
- *
1572
- * // 使用自定义路径
1573
- * agent.use(new SkillFeature('./custom/skills'));
1574
- * agent.use(new SkillFeature({ dir: './custom/skills' }));
1579
+ * import { AuditFeature } from './features/index.js';
1580
+ * const agent = new Agent({ ... }).use(new AuditFeature());
1575
1581
  * ```
1576
1582
  */
1577
1583
 
1578
1584
  /**
1579
- * Skill Feature 配置类型
1585
+ * AuditFeature 配置
1580
1586
  */
1581
- interface SkillFeatureConfig extends SkillsOptions {
1582
- /** Skills 目录路径 */
1583
- dir?: string;
1587
+ interface AuditFeatureConfig {
1588
+ /** LLM 服务地址(默认 localhost:7575) */
1589
+ baseUrl?: string;
1590
+ /** 审计模型名称(默认 Qwen3.5-4B-Q5_K_M) */
1591
+ model?: string;
1592
+ /** 是否启用审计(默认 true) */
1593
+ enabled?: boolean;
1594
+ /** 是否启用数据库缓存(默认 true) */
1595
+ enableCache?: boolean;
1596
+ /** 数据库文件路径(默认 .agentdev/audit/audit.db) */
1597
+ dbPath?: string;
1598
+ /** 缓存有效期(天数,0 表示永久,默认 0) */
1599
+ cacheTtlDays?: number;
1600
+ /** 工作目录(默认 process.cwd()) */
1601
+ workspaceDir?: string;
1584
1602
  }
1585
1603
  /**
1586
- * Skill Feature 输入类型
1587
- */
1588
- type SkillFeatureInput = SkillFeatureConfig | string | undefined;
1589
- /**
1590
- * Skill Feature 实现
1604
+ * AuditFeature 实现
1605
+ *
1606
+ * 在工具执行前进行安全审计,拦截危险的 bash 命令
1591
1607
  */
1592
- declare class SkillFeature implements AgentFeature {
1593
- readonly name = "skill";
1608
+ declare class AuditFeature implements AgentFeature {
1609
+ readonly name = "audit";
1594
1610
  readonly dependencies: string[];
1595
1611
  readonly source: string;
1596
- readonly description = "\u53D1\u73B0\u672C\u5730 skills\uFF0C\u5E76\u63D0\u4F9B invoke_skill \u5DE5\u5177\u4E0E\u6280\u80FD\u6570\u636E\u6E90\u3002";
1597
- private skillsDir?;
1598
- private skills;
1612
+ readonly description = "\u5728\u5DE5\u5177\u6267\u884C\u524D\u5BA1\u8BA1\u9AD8\u98CE\u9669 shell \u547D\u4EE4\uFF0C\u5FC5\u8981\u65F6\u963B\u65AD\u6267\u884C\u3002";
1613
+ private config;
1614
+ private client;
1615
+ private db?;
1616
+ private dbPath;
1617
+ private logger;
1618
+ constructor(config?: AuditFeatureConfig);
1619
+ getTools(): Tool[];
1620
+ onInitiate(ctx: FeatureInitContext): Promise<void>;
1621
+ onDestroy(_ctx: FeatureContext): Promise<void>;
1622
+ getHookDescription(lifecycle: string, methodName: string): string | undefined;
1599
1623
  /**
1600
- * 缓存包信息
1624
+ * 工具使用前审计
1625
+ *
1626
+ * 触发时机:每次工具执行前
1627
+ * 处理逻辑:
1628
+ * 1. 检查是否是 bash 工具调用
1629
+ * 2. 调用 LLM 审计命令安全性
1630
+ * 3. 恶意则拒绝执行,安全则允许
1601
1631
  */
1602
- private _packageInfo;
1632
+ auditBashCommand(ctx: ToolContext): Promise<DecisionResult>;
1603
1633
  /**
1604
- * 获取包信息(统一打包方案)
1634
+ * 调用 LLM(OpenAI 兼容 API)审计命令
1605
1635
  */
1606
- getPackageInfo(): PackageInfo | null;
1636
+ private auditCommand;
1607
1637
  /**
1608
- * 获取模板名称列表(统一打包方案)
1638
+ * 格式化审计结果消息
1609
1639
  */
1610
- getTemplateNames(): string[];
1611
- constructor(input?: SkillFeatureInput);
1640
+ private formatAuditMessage;
1612
1641
  /**
1613
- * 获取同步工具(invoke_skill)
1642
+ * 初始化数据库
1643
+ *
1644
+ * - 创建数据库目录(如果不存在)
1645
+ * - 打开数据库连接
1646
+ * - 创建表结构(如果不存在)
1647
+ * - 创建索引(如果不存在)
1614
1648
  */
1615
- getTools(): Tool[];
1649
+ private initDatabase;
1616
1650
  /**
1617
- * 声明上下文注入器
1618
- * 为 invoke_skill 工具注入 _context.skills
1651
+ * 查询缓存的审计结果
1652
+ *
1653
+ * @param command - 要审计的命令
1654
+ * @returns 缓存的审计结果,如果不存在则返回 null
1619
1655
  */
1620
- getContextInjectors(): Map<string | RegExp, ContextInjector>;
1656
+ private getCachedAuditResult;
1621
1657
  /**
1622
- * 初始化钩子
1623
- * 执行 Skills 发现并注册数据源
1658
+ * 保存审计结果到数据库
1659
+ *
1660
+ * @param command - 被审计的命令
1661
+ * @param result - 审计结果
1662
+ */
1663
+ private saveAuditResult;
1664
+ /**
1665
+ * 清理过期的缓存记录
1666
+ *
1667
+ * 根据 cacheTtlDays 配置,删除超过有效期的记录
1668
+ */
1669
+ private cleanExpiredCache;
1670
+ }
1671
+
1672
+ interface AudioFeedbackConfig {
1673
+ /** 音频文件路径(相对于 feature 目录或绝对路径) */
1674
+ audioPath?: string;
1675
+ /** 是否启用音频反馈(默认:true) */
1676
+ enabled?: boolean;
1677
+ /** 音量(0-1,默认:0.5) */
1678
+ volume?: number;
1679
+ }
1680
+
1681
+ /**
1682
+ * Audio Feedback Feature
1683
+ *
1684
+ * 在每次 call 完成时播放音频反馈,提供愉悦的交互体验
1685
+ */
1686
+ declare class AudioFeedbackFeature implements AgentFeature {
1687
+ readonly name = "audio-feedback";
1688
+ readonly dependencies: string[];
1689
+ readonly source: string;
1690
+ readonly description = "\u5728 call \u5B8C\u6210\u65F6\u64AD\u653E\u97F3\u9891\u53CD\u9988\uFF0C\u63D0\u4F9B\u6109\u60A6\u7684\u4EA4\u4E92\u4F53\u9A8C\u3002";
1691
+ private readonly config;
1692
+ private readonly runtime;
1693
+ private logger?;
1694
+ constructor(config?: AudioFeedbackConfig);
1695
+ /**
1696
+ * 公开 API:启用或禁用音频反馈
1697
+ */
1698
+ setEnabled(enabled: boolean): void;
1699
+ isEnabled(): boolean;
1700
+ /**
1701
+ * 公开 API:设置音量
1702
+ */
1703
+ setVolume(volume: number): void;
1704
+ getPlayCount(): number;
1705
+ onInitiate(ctx: FeatureInitContext): Promise<void>;
1706
+ onDestroy(_ctx: FeatureContext): Promise<void>;
1707
+ captureState(): FeatureStateSnapshot;
1708
+ restoreState(snapshot: FeatureStateSnapshot): void;
1709
+ /**
1710
+ * 核心功能:在 call 完成时播放音频
1711
+ */
1712
+ playAudioOnCallFinish(ctx: CallFinishContext): Promise<void>;
1713
+ }
1714
+
1715
+ interface MemoryFeatureConfig {
1716
+ /** CLAUDE.md 文件名,默认 'CLAUDE.md' */
1717
+ filename?: string;
1718
+ /** 是否强制注入,即使文件不存在也记录日志 */
1719
+ forceInject?: boolean;
1720
+ /** 读取 CLAUDE.md 的工作目录 */
1721
+ workspaceDir?: string;
1722
+ /** 宿主资源目录;如果提供,优先从这里读取 CLAUDE.md */
1723
+ resourceRoot?: string;
1724
+ }
1725
+ declare class MemoryFeature implements AgentFeature {
1726
+ readonly name = "memory";
1727
+ readonly dependencies: string[];
1728
+ readonly source: string;
1729
+ readonly description = "\u81EA\u52A8\u8BFB\u53D6\u5E76\u6CE8\u5165\u9879\u76EE CLAUDE.md \u6587\u4EF6\u4F5C\u4E3A\u7CFB\u7EDF\u63D0\u793A\u8BCD\u3002";
1730
+ private filename;
1731
+ private sourceRoot;
1732
+ private _packageInfo;
1733
+ constructor(config?: MemoryFeatureConfig);
1734
+ /**
1735
+ * 获取包信息(统一打包方案)
1736
+ */
1737
+ getPackageInfo(): PackageInfo | null;
1738
+ /**
1739
+ * 获取模板名称列表(统一打包方案)
1740
+ * 此 Feature 没有模板,返回空数组
1741
+ */
1742
+ getTemplateNames(): string[];
1743
+ /**
1744
+ * CallStart 钩子:仅在首次对话开始时注入 CLAUDE.md 内容
1745
+ */
1746
+ injectCLAUDEContent(ctx: CallStartContext): Promise<void>;
1747
+ /**
1748
+ * 获取钩子描述(用于调试器)
1749
+ */
1750
+ getHookDescription(lifecycle: string, methodName: string): string | undefined;
1751
+ }
1752
+
1753
+ /**
1754
+ * Agent Skills 类型定义
1755
+ */
1756
+ /**
1757
+ * Skill 元数据
1758
+ */
1759
+ interface SkillMetadata {
1760
+ /** Skill 名称 */
1761
+ name: string;
1762
+ /** Skill 描述 */
1763
+ description: string;
1764
+ /** SKILL.md 完整路径 */
1765
+ path: string;
1766
+ }
1767
+ /**
1768
+ * Skills 加载器配置
1769
+ */
1770
+ interface SkillsOptions {
1771
+ /** skills 目录,默认 cwd/.agentdev/skills */
1772
+ dir?: string;
1773
+ }
1774
+
1775
+ /**
1776
+ * Skill Feature - Skills 发现和 invoke_skill 工具
1777
+ *
1778
+ * 将 Skills 集成从 Agent 核心中解耦,实现可外挂功能
1779
+ *
1780
+ * @example
1781
+ * ```typescript
1782
+ * // 使用默认路径 .agentdev/skills
1783
+ * agent.use(new SkillFeature());
1784
+ *
1785
+ * // 使用自定义路径
1786
+ * agent.use(new SkillFeature('./custom/skills'));
1787
+ * agent.use(new SkillFeature({ dir: './custom/skills' }));
1788
+ * ```
1789
+ */
1790
+
1791
+ /**
1792
+ * Skill Feature 配置类型
1793
+ */
1794
+ interface SkillFeatureConfig extends SkillsOptions {
1795
+ /** Skills 目录路径 */
1796
+ dir?: string;
1797
+ }
1798
+ /**
1799
+ * Skill Feature 输入类型
1800
+ */
1801
+ type SkillFeatureInput = SkillFeatureConfig | string | undefined;
1802
+ /**
1803
+ * Skill Feature 实现
1804
+ */
1805
+ declare class SkillFeature implements AgentFeature {
1806
+ readonly name = "skill";
1807
+ readonly dependencies: string[];
1808
+ readonly source: string;
1809
+ readonly description = "\u53D1\u73B0\u672C\u5730 skills\uFF0C\u5E76\u63D0\u4F9B invoke_skill \u5DE5\u5177\u4E0E\u6280\u80FD\u6570\u636E\u6E90\u3002";
1810
+ private skillsDir?;
1811
+ private skills;
1812
+ private featureSkills;
1813
+ /**
1814
+ * 缓存包信息
1815
+ */
1816
+ private _packageInfo;
1817
+ /**
1818
+ * 获取包信息(统一打包方案)
1819
+ */
1820
+ getPackageInfo(): PackageInfo | null;
1821
+ /**
1822
+ * 获取模板名称列表(统一打包方案)
1823
+ */
1824
+ getTemplateNames(): string[];
1825
+ constructor(input?: SkillFeatureInput);
1826
+ /**
1827
+ * 获取同步工具(invoke_skill)
1828
+ */
1829
+ getTools(): Tool[];
1830
+ /**
1831
+ * 声明上下文注入器
1832
+ * 为 invoke_skill 工具注入 _context.skills
1833
+ */
1834
+ getContextInjectors(): Map<string | RegExp, ContextInjector>;
1835
+ /**
1836
+ * 初始化钩子
1837
+ * 执行 Skills 发现并注册数据源
1624
1838
  */
1625
1839
  onInitiate(ctx: FeatureInitContext): Promise<void>;
1840
+ /**
1841
+ * 注入来自其他 Feature 的 skills
1842
+ * 由 Agent 在 onInitiate 之前调用
1843
+ */
1844
+ addFeatureSkills(skills: SkillMetadata[]): void;
1626
1845
  /**
1627
1846
  * 获取已加载的 Skills
1628
1847
  */
@@ -1633,6 +1852,188 @@ declare class SkillFeature implements AgentFeature {
1633
1852
  setSkillsDir(dir: string): void;
1634
1853
  }
1635
1854
 
1855
+ /**
1856
+ * OpenClaw 兼容层类型定义
1857
+ */
1858
+
1859
+ /**
1860
+ * 支持的兼容钩子名称
1861
+ */
1862
+ type CompatHookName = 'before_tool_call' | 'after_tool_call';
1863
+ /**
1864
+ * before_tool_call 钩子上下文
1865
+ */
1866
+ interface BeforeToolCallContext {
1867
+ /** 工具调用 */
1868
+ call: ToolCall;
1869
+ /** 工具名称 */
1870
+ toolName: string;
1871
+ /** 工具参数 */
1872
+ parameters: Record<string, unknown>;
1873
+ /** 消息历史 */
1874
+ messages: Message[];
1875
+ }
1876
+ /**
1877
+ * before_tool_call 钩子结果
1878
+ */
1879
+ interface BeforeToolCallResult {
1880
+ /** 是否阻止执行 */
1881
+ block?: boolean;
1882
+ /** 拒绝原因 */
1883
+ denyReason?: string;
1884
+ /** 修改后的参数 */
1885
+ rewrittenParameters?: Record<string, unknown>;
1886
+ }
1887
+ /**
1888
+ * after_tool_call 钩子上下文
1889
+ */
1890
+ interface AfterToolCallContext {
1891
+ /** 工具调用 */
1892
+ call: ToolCall;
1893
+ /** 工具名称 */
1894
+ toolName: string;
1895
+ /** 执行是否成功 */
1896
+ success: boolean;
1897
+ /** 执行结果 */
1898
+ result: unknown;
1899
+ /** 错误信息 */
1900
+ error?: string;
1901
+ /** 执行耗时(ms) */
1902
+ duration: number;
1903
+ /** 消息历史 */
1904
+ messages: Message[];
1905
+ }
1906
+ /**
1907
+ * 兼容钩子处理器映射
1908
+ */
1909
+ interface CompatHookHandlerMap {
1910
+ before_tool_call: (ctx: BeforeToolCallContext) => BeforeToolCallResult | Promise<BeforeToolCallResult>;
1911
+ after_tool_call: (ctx: AfterToolCallContext) => void | Promise<void>;
1912
+ }
1913
+ /**
1914
+ * 已注册的兼容钩子
1915
+ */
1916
+ interface RegisteredCompatHook {
1917
+ /** 插件 ID */
1918
+ pluginId: string;
1919
+ /** 钩子名称 */
1920
+ hookName: CompatHookName;
1921
+ /** 处理器 */
1922
+ handler: CompatHookHandlerMap[CompatHookName];
1923
+ /** 优先级(OpenClaw 规则:数值越大越先执行) */
1924
+ priority: number;
1925
+ }
1926
+ /**
1927
+ * 插件诊断信息
1928
+ */
1929
+ interface PluginDiagnostics {
1930
+ /** 插件 ID */
1931
+ pluginId: string;
1932
+ /** 插件名称 */
1933
+ name: string;
1934
+ /** 版本 */
1935
+ version: string;
1936
+ /** 源路径 */
1937
+ source: string;
1938
+ /** 注册的工具 */
1939
+ registeredTools: string[];
1940
+ /** 注册的钩子 */
1941
+ registeredHooks: CompatHookName[];
1942
+ /** 不支持的 API 调用记录 */
1943
+ unsupportedApis: string[];
1944
+ /** 错误信息 */
1945
+ errors: string[];
1946
+ }
1947
+ /**
1948
+ * 兼容层诊断报告
1949
+ */
1950
+ interface CompatDiagnosticsReport {
1951
+ /** 加载的插件列表 */
1952
+ plugins: PluginDiagnostics[];
1953
+ /** 总计注册的工具数 */
1954
+ totalTools: number;
1955
+ /** 总计注册的钩子数 */
1956
+ totalHooks: number;
1957
+ }
1958
+
1959
+ /**
1960
+ * OpenClaw 兼容钩子注册表
1961
+ *
1962
+ * 管理兼容插件的钩子注册和执行
1963
+ * 遵循 OpenClaw 优先级规则:priority 数值越大越先执行
1964
+ */
1965
+
1966
+ /**
1967
+ * 兼容钩子注册表
1968
+ */
1969
+ declare class CompatHookRegistry {
1970
+ /** 钩子存储:hookName -> 按优先级排序的钩子列表 */
1971
+ private hooks;
1972
+ /**
1973
+ * 注册钩子
1974
+ *
1975
+ * @param hookName 钩子名称
1976
+ * @param handler 钩子处理器
1977
+ * @param priority 优先级(数值越大越先执行)
1978
+ * @param pluginId 插件 ID
1979
+ */
1980
+ register<K extends CompatHookName>(hookName: K, handler: CompatHookHandlerMap[K], priority: number, pluginId: string): void;
1981
+ /**
1982
+ * 获取指定钩子的所有处理器(按优先级排序)
1983
+ *
1984
+ * @param hookName 钩子名称
1985
+ * @returns 钩子列表
1986
+ */
1987
+ get(hookName: CompatHookName): RegisteredCompatHook[];
1988
+ /**
1989
+ * 检查是否有指定钩子
1990
+ *
1991
+ * @param hookName 钩子名称
1992
+ * @returns 是否存在
1993
+ */
1994
+ has(hookName: CompatHookName): boolean;
1995
+ /**
1996
+ * 执行 before_tool_call 钩子
1997
+ *
1998
+ * 按优先级顺序执行:
1999
+ * - 如果任何钩子返回 block=true,则立即阻止执行
2000
+ * - 多个插件的参数修改会累积合并
2001
+ *
2002
+ * @param context 钩子上下文
2003
+ * @returns 钩子执行结果(如果任何钩子返回 block=true,则阻止执行)
2004
+ */
2005
+ executeBeforeToolCall(context: BeforeToolCallContext): Promise<BeforeToolCallResult>;
2006
+ /**
2007
+ * 深度合并对象
2008
+ */
2009
+ private deepMerge;
2010
+ /**
2011
+ * 执行 after_tool_call 钩子
2012
+ *
2013
+ * 按优先级顺序执行所有钩子(void 返回值)
2014
+ *
2015
+ * @param context 钩子上下文
2016
+ */
2017
+ executeAfterToolCall(context: AfterToolCallContext): Promise<void>;
2018
+ /**
2019
+ * 获取所有已注册的钩子信息
2020
+ *
2021
+ * @returns 钩子信息映射
2022
+ */
2023
+ getHooksInfo(): Map<CompatHookName, Array<{
2024
+ pluginId: string;
2025
+ priority: number;
2026
+ }>>;
2027
+ /**
2028
+ * 清空所有钩子
2029
+ */
2030
+ clear(): void;
2031
+ /**
2032
+ * 获取钩子总数
2033
+ */
2034
+ get size(): number;
2035
+ }
2036
+
1636
2037
  /**
1637
2038
  * 反向钩子装饰器
1638
2039
  *
@@ -1689,45 +2090,308 @@ declare const ToolUse: (target: any, propertyKey: string, descriptor: PropertyDe
1689
2090
  declare const ToolFinished: (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
1690
2091
 
1691
2092
  /**
1692
- * AgentPool - 子代理管理核心
1693
- * 管理父代理创建的所有子代理实例
1694
- */
1695
-
1696
- /**
1697
- * 子代理实例信息
1698
- */
1699
- interface SubAgentInstance {
1700
- id: string;
1701
- type: string;
1702
- agent: AgentBase;
1703
- status: SubAgentStatus;
1704
- initialInstruction: string;
1705
- createdAt: number;
1706
- completedAt?: number;
1707
- result?: string;
1708
- error?: string;
1709
- }
1710
- /**
1711
- * Agent 创建函数类型(异步)
1712
- */
1713
- type AgentFactory = (type: string) => AgentBase | Promise<AgentBase>;
1714
- /**
1715
- * AgentPool - 子代理管理核心
1716
- * 管理父代理创建的所有子代理实例
2093
+ * PluginCompatFeature
2094
+ *
2095
+ * 加载 OpenClaw 风格插件并将它们转换为 AgentDev 能力
1717
2096
  */
1718
- declare class AgentPool {
1719
- private _instances;
1720
- private _counters;
1721
- private _parent;
1722
- /** 待回传消息队列:agentId -> messages[] */
1723
- private _pendingMessages;
1724
- /** 消息就绪解析器:key -> resolver function */
1725
- private _messageResolvers;
1726
- constructor(parent: AgentBase);
2097
+ declare class PluginCompatFeature implements AgentFeature {
2098
+ name: string;
2099
+ readonly source: string;
2100
+ readonly description = "\u52A0\u8F7D OpenClaw \u98CE\u683C\u63D2\u4EF6\uFF0C\u5E76\u628A\u63D2\u4EF6\u5DE5\u5177\u4E0E\u517C\u5BB9\u94A9\u5B50\u6865\u63A5\u5230 AgentDev\u3002";
2101
+ /** 兼容钩子注册表 */
2102
+ private compatHookRegistry;
2103
+ /** 诊断收集器 */
2104
+ private diagnostics;
2105
+ /** 已加载的插件 */
2106
+ private loadedPlugins;
2107
+ /** Agent 工具注册表(从 FeatureContext 获取) */
2108
+ private agentToolRegistry?;
2109
+ /** Agent ID */
2110
+ private agentId?;
2111
+ /** 插件根目录 */
2112
+ private pluginRoots;
2113
+ /** 是否启用 */
2114
+ private enabled;
2115
+ /** 注册的工具列表(用于 getAsyncTools) */
2116
+ private registeredTools;
1727
2117
  /**
1728
- * 创建子代理(不自动执行,等待 sendTo 激活)
2118
+ * 初始化 Feature
1729
2119
  */
1730
- spawn(type: string, createAgentFn: AgentFactory): Promise<string>;
2120
+ onInitiate(ctx: FeatureInitContext): Promise<void>;
2121
+ /**
2122
+ * 加载所有插件
2123
+ */
2124
+ private loadPlugins;
2125
+ /**
2126
+ * 加载单个插件
2127
+ */
2128
+ private loadPlugin;
2129
+ /**
2130
+ * 注册工具
2131
+ */
2132
+ private registerTool;
2133
+ /**
2134
+ * 获取异步工具列表
2135
+ */
2136
+ getAsyncTools(): Promise<Tool[]>;
2137
+ /**
2138
+ * 注册钩子
2139
+ */
2140
+ private registerHook;
2141
+ /**
2142
+ * 调用工具(用于插件运行时)
2143
+ */
2144
+ private invokeTool;
2145
+ /**
2146
+ * 获取兼容钩子注册表(供内部桥接使用)
2147
+ */
2148
+ getCompatHookRegistry(): CompatHookRegistry;
2149
+ /**
2150
+ * 获取诊断报告
2151
+ */
2152
+ getDiagnostics(): CompatDiagnosticsReport;
2153
+ /**
2154
+ * 清理资源
2155
+ */
2156
+ onDestroy(): Promise<void>;
2157
+ getHookDescription(lifecycle: string, methodName: string): string | undefined;
2158
+ /**
2159
+ * 桥接 before_tool_call 钩子
2160
+ *
2161
+ * 在工具执行前调用兼容插件的 before_tool_call 钩子
2162
+ */
2163
+ handleBeforeToolCall(ctx: ToolContext): Promise<typeof Decision.Deny | typeof Decision.Continue>;
2164
+ /**
2165
+ * 桥接 after_tool_call 钩子
2166
+ *
2167
+ * 在工具执行后调用兼容插件的 after_tool_call 钩子
2168
+ */
2169
+ handleAfterToolCall(result: ToolResult): Promise<void>;
2170
+ }
2171
+
2172
+ /**
2173
+ * QQBotFeature - QQ 机器人对话能力
2174
+ *
2175
+ * 功能:
2176
+ * - 通过 WebSocket 连接 QQ Bot Gateway
2177
+ * - 接收 QQ 消息并转发给 Agent 处理
2178
+ * - 自动将 Agent 的响应发送回 QQ
2179
+ *
2180
+ * 使用 `@sliverp/qqbot/standalone` 独立接入
2181
+ */
2182
+
2183
+ /**
2184
+ * QQ 消息发送选项
2185
+ */
2186
+ interface QQBotSendOptions {
2187
+ /** 目标 OpenID */
2188
+ to: string;
2189
+ /** 消息内容 */
2190
+ content: string;
2191
+ }
2192
+ /**
2193
+ * QQ 消息发送结果
2194
+ */
2195
+ interface QQBotSendResult {
2196
+ /** 是否成功 */
2197
+ success: boolean;
2198
+ /** 消息ID */
2199
+ messageId?: string;
2200
+ /** 时间戳 */
2201
+ timestamp?: string | number;
2202
+ /** 错误信息 */
2203
+ error?: string;
2204
+ }
2205
+ /**
2206
+ * 已知用户信息
2207
+ */
2208
+ interface KnownUser {
2209
+ /** 类型 */
2210
+ type: 'c2c' | 'group' | 'channel';
2211
+ /** OpenID */
2212
+ openid: string;
2213
+ /** 昵称 */
2214
+ nickname?: string;
2215
+ /** 最后交互时间 */
2216
+ lastInteractionAt: number;
2217
+ }
2218
+ /**
2219
+ * QQBot Feature 配置
2220
+ */
2221
+ interface QQBotFeatureConfig {
2222
+ /** QQ Bot AppID(可选,如果不提供则从配置文件读取) */
2223
+ appId?: string;
2224
+ /** QQ Bot AppSecret(可选,如果不提供则从配置文件读取) */
2225
+ clientSecret?: string;
2226
+ /** 配置文件路径(默认 .agentdev/qqbot.config.json) */
2227
+ configPath?: string;
2228
+ /** 账户 ID(默认 "default") */
2229
+ accountId?: string;
2230
+ /** 是否启用 Markdown 消息(默认 true) */
2231
+ markdownSupport?: boolean;
2232
+ /** 系统提示词 */
2233
+ systemPrompt?: string;
2234
+ /** 附加配置(传递给 Gateway) */
2235
+ cfg?: Record<string, unknown>;
2236
+ /** 工作目录(默认 process.cwd()) */
2237
+ workspaceDir?: string;
2238
+ /** 宿主资源目录;默认从这里查找 .agentdev/qqbot.config.json */
2239
+ resourceRoot?: string;
2240
+ }
2241
+ /**
2242
+ * QQBotFeature - QQ 机器人 Feature
2243
+ *
2244
+ * 使用方式:
2245
+ * ```typescript
2246
+ * const qqbotFeature = new QQBotFeature({ appId, clientSecret });
2247
+ * const agent = new BasicAgent({ llm }).use(qqbotFeature);
2248
+ * await agent.withViewer('QQBot', 2026, false);
2249
+ * await qqbotFeature.startGateway(agent);
2250
+ * ```
2251
+ */
2252
+ declare class QQBotFeature implements AgentFeature {
2253
+ readonly name = "qqbot";
2254
+ readonly dependencies: string[];
2255
+ readonly source: string;
2256
+ readonly description = "\u628A Agent \u63A5\u5165 QQ Bot \u7F51\u5173\uFF0C\u63A5\u6536\u6D88\u606F\u5E76\u628A\u56DE\u590D\u56DE\u63A8\u5230 QQ \u4F1A\u8BDD\u3002";
2257
+ private config;
2258
+ private agentRef;
2259
+ private processingLock;
2260
+ private gatewayStarted;
2261
+ private abortController;
2262
+ private _packageInfo;
2263
+ constructor(config?: QQBotFeatureConfig);
2264
+ /**
2265
+ * 显式启动 Gateway(在 Agent 初始化后调用)
2266
+ *
2267
+ * @param agent Agent 实例
2268
+ */
2269
+ startGateway(agent: any): Promise<void>;
2270
+ /**
2271
+ * 创建账户配置
2272
+ */
2273
+ private createAccount;
2274
+ /**
2275
+ * 获取凭据(从配置文件或直接配置)
2276
+ */
2277
+ private getCredentials;
2278
+ getTools(): Tool[];
2279
+ /**
2280
+ * 获取包信息(统一打包方案)
2281
+ */
2282
+ getPackageInfo(): PackageInfo | null;
2283
+ /**
2284
+ * 获取模板名称列表(统一打包方案)
2285
+ * 此 Feature 没有模板,返回空数组
2286
+ */
2287
+ getTemplateNames(): string[];
2288
+ onInitiate(_ctx: FeatureInitContext): Promise<void>;
2289
+ onDestroy(_ctx: FeatureContext): Promise<void>;
2290
+ }
2291
+
2292
+ /**
2293
+ * Shell Feature 工具定义
2294
+ *
2295
+ * 提供 run_shell_command 工具,通过 Git Bash 执行 Shell 命令
2296
+ */
2297
+
2298
+ interface ShellExecutionResult {
2299
+ stdout: string;
2300
+ stderr: string;
2301
+ output: string;
2302
+ }
2303
+
2304
+ /**
2305
+ * Shell Feature - Git Bash 命令执行工具 + 安全删除/恢复工具
2306
+ *
2307
+ * 通过 Git Bash 执行 Shell 命令,description 从内部配置加载
2308
+ * 提供安全删除、列表和恢复功能
2309
+ *
2310
+ * @example
2311
+ * ```typescript
2312
+ * import { ShellFeature } from './features/index.js';
2313
+ * const agent = new Agent({ ... }).use(new ShellFeature());
2314
+ * ```
2315
+ */
2316
+
2317
+ interface ShellFeatureConfig {
2318
+ workspaceDir?: string;
2319
+ workdir?: string;
2320
+ resourceRoot?: string;
2321
+ }
2322
+ /**
2323
+ * Shell Feature 实现
2324
+ */
2325
+ declare class ShellFeature implements AgentFeature {
2326
+ readonly name = "shell";
2327
+ readonly dependencies: string[];
2328
+ readonly source: string;
2329
+ readonly description = "\u63D0\u4F9B bash \u6267\u884C\u80FD\u529B\uFF0C\u4EE5\u53CA\u5B89\u5168\u5220\u9664\u3001\u6062\u590D\u548C\u67E5\u770B\u5783\u573E\u6876\u5DE5\u5177\u3002";
2330
+ private bashDescription?;
2331
+ private _packageInfo;
2332
+ private readonly workspaceDir;
2333
+ private readonly workdir;
2334
+ private readonly resourceRoot;
2335
+ constructor(config?: ShellFeatureConfig);
2336
+ run(command: string): Promise<ShellExecutionResult>;
2337
+ /**
2338
+ * 获取包信息(统一打包方案)
2339
+ */
2340
+ getPackageInfo(): PackageInfo | null;
2341
+ /**
2342
+ * 获取模板名称列表(统一打包方案)
2343
+ */
2344
+ getTemplateNames(): string[];
2345
+ /**
2346
+ * 获取同步工具(垃圾桶工具)
2347
+ */
2348
+ getTools(): Tool[];
2349
+ /**
2350
+ * 获取异步工具(bash 工具,加载 description)
2351
+ */
2352
+ getAsyncTools(_ctx: FeatureInitContext): Promise<Tool[]>;
2353
+ }
2354
+
2355
+ /**
2356
+ * AgentPool - 子代理管理核心
2357
+ * 管理父代理创建的所有子代理实例
2358
+ */
2359
+
2360
+ /**
2361
+ * 子代理实例信息
2362
+ */
2363
+ interface SubAgentInstance {
2364
+ id: string;
2365
+ type: string;
2366
+ agent: AgentBase;
2367
+ status: SubAgentStatus;
2368
+ initialInstruction: string;
2369
+ createdAt: number;
2370
+ completedAt?: number;
2371
+ result?: string;
2372
+ error?: string;
2373
+ }
2374
+ /**
2375
+ * Agent 创建函数类型(异步)
2376
+ */
2377
+ type AgentFactory = (type: string) => AgentBase | Promise<AgentBase>;
2378
+ /**
2379
+ * AgentPool - 子代理管理核心
2380
+ * 管理父代理创建的所有子代理实例
2381
+ */
2382
+ declare class AgentPool {
2383
+ private _instances;
2384
+ private _counters;
2385
+ private _parent;
2386
+ /** 待回传消息队列:agentId -> messages[] */
2387
+ private _pendingMessages;
2388
+ /** 消息就绪解析器:key -> resolver function */
2389
+ private _messageResolvers;
2390
+ constructor(parent: AgentBase);
2391
+ /**
2392
+ * 创建子代理(不自动执行,等待 sendTo 激活)
2393
+ */
2394
+ spawn(type: string, createAgentFn: AgentFactory): Promise<string>;
1731
2395
  /**
1732
2396
  * 获取实例信息
1733
2397
  */
@@ -2048,58 +2712,796 @@ declare class TodoFeature implements AgentFeature {
2048
2712
  }
2049
2713
 
2050
2714
  /**
2051
- * UserInputFeature - 通过调试界面获取用户输入
2715
+ * TTS Feature 类型定义
2716
+ */
2717
+ /**
2718
+ * TTS Feature 配置选项
2719
+ */
2720
+ interface TTSFeatureConfig {
2721
+ /** 工作目录(默认 process.cwd()) */
2722
+ workspaceDir?: string;
2723
+ /**
2724
+ * Python 可执行文件路径
2725
+ * 默认:项目 .venv 中的 Python 或系统 PATH 中的 python
2726
+ */
2727
+ pythonPath?: string;
2728
+ /**
2729
+ * Python 额外参数(如 uv run)
2730
+ * 例如:['run', '--with', 'kokoro', '--with', 'soundfile']
2731
+ */
2732
+ pythonArgs?: string[];
2733
+ /**
2734
+ * 是否在初始化时检查 Python 环境
2735
+ * 默认:true
2736
+ */
2737
+ checkPythonEnv?: boolean;
2738
+ /**
2739
+ * TTS 模型配置
2740
+ */
2741
+ model?: {
2742
+ /**
2743
+ * 默认声音 ID
2744
+ * 中文常用:zf_xiaobei, zf_xiaoxiao, zf_xiaomei
2745
+ * 英文常用:af_bella, af_heart
2746
+ * 默认:zf_xiaobei
2747
+ */
2748
+ voice?: string;
2749
+ /**
2750
+ * 语言代码
2751
+ * 'zh'(中文优先) 或 'a'/'en'(英文优先)
2752
+ * 默认:zh
2753
+ */
2754
+ lang?: string;
2755
+ /**
2756
+ * 语速倍率
2757
+ * 0.8~1.5 之间合理
2758
+ * 默认:1.0
2759
+ */
2760
+ speed?: number;
2761
+ };
2762
+ /**
2763
+ * 音频输出配置
2764
+ */
2765
+ output?: {
2766
+ /**
2767
+ * 输出目录
2768
+ * 默认:.agentdev/tts
2769
+ */
2770
+ outputDir?: string;
2771
+ /**
2772
+ * 是否自动播放生成的音频
2773
+ * 默认:true
2774
+ */
2775
+ autoPlay?: boolean;
2776
+ };
2777
+ /**
2778
+ * TTS 触发条件
2779
+ */
2780
+ triggers?: {
2781
+ /**
2782
+ * 是否启用自动朗读(非工具调用轮)
2783
+ * 默认:true
2784
+ */
2785
+ autoEnabled?: boolean;
2786
+ /**
2787
+ * 最小文本长度(字符数)
2788
+ * 短于此长度的文本不会朗读
2789
+ * 默认:10
2790
+ */
2791
+ minLength?: number;
2792
+ /**
2793
+ * 最大文本长度(字符数)
2794
+ * 长于此长度的文本会被截断
2795
+ * 默认:1000
2796
+ */
2797
+ maxLength?: number;
2798
+ /**
2799
+ * 是否只在非结束轮触发
2800
+ * true: 只在没有工具调用时朗读
2801
+ * false: 所有响应都朗读
2802
+ * 默认:true
2803
+ */
2804
+ onlyOnNonToolCalls?: boolean;
2805
+ };
2806
+ }
2807
+ /**
2808
+ * TTS 生成结果
2809
+ */
2810
+ interface TTSResult {
2811
+ success: boolean;
2812
+ outputPath?: string;
2813
+ duration?: number;
2814
+ error?: string;
2815
+ }
2816
+ /**
2817
+ * TTS 内部状态(用于快照和恢复)
2818
+ */
2819
+ interface TTSState {
2820
+ enabled: boolean;
2821
+ lastUtteranceId: string | null;
2822
+ totalUtterances: number;
2823
+ }
2824
+
2825
+ /**
2826
+ * TTSFeature - 文本朗读功能模块
2827
+ *
2828
+ * 提供:
2829
+ * 1. @StepFinish 钩子:在每个 step 结束时自动朗读模型输出
2830
+ * - 包括工具调用轮和非工具调用轮
2831
+ * - 只要有 assistant 文本回复就会朗读
2832
+ * - 默认自动播放音频(使用 pygame)
2833
+ *
2834
+ * Python 环境要求:
2835
+ * - 需要安装 kokoro、soundfile、pygame 库
2836
+ *
2837
+ * 安装方式:
2838
+ * uv 方式(推荐):
2839
+ * uv pip install kokoro soundfile pygame
2840
+ *
2841
+ * 或使用 pip:
2842
+ * pip install kokoro soundfile pygame
2843
+ *
2844
+ * Python 调用方式:
2845
+ * - 默认使用 'python' 命令(从 PATH 中查找)
2846
+ * - 如果使用 uv,可以配置为 'uv run'
2847
+ *
2848
+ * @example
2849
+ * ```typescript
2850
+ * import { TTSFeature } from './features/index.js';
2851
+ *
2852
+ * // 使用默认配置
2853
+ * const agent = new Agent({ ... }).use(new TTSFeature());
2854
+ *
2855
+ * // 自定义声音和语速
2856
+ * const agent = new Agent({ ... }).use(new TTSFeature({
2857
+ * model: {
2858
+ * voice: 'zf_xiaoxiao',
2859
+ * speed: 1.3
2860
+ * }
2861
+ * }));
2862
+ *
2863
+ * // 禁用自动播放
2864
+ * const agent = new Agent({ ... }).use(new TTSFeature({
2865
+ * output: {
2866
+ * autoPlay: false
2867
+ * }
2868
+ * }));
2869
+ *
2870
+ * // 使用 uv
2871
+ * const agent = new Agent({ ... }).use(new TTSFeature({
2872
+ * pythonPath: 'uv',
2873
+ * pythonArgs: ['run']
2874
+ * }));
2875
+ * ```
2876
+ */
2877
+
2878
+ declare class TTSFeature implements AgentFeature {
2879
+ readonly name = "tts";
2880
+ readonly dependencies: string[];
2881
+ readonly source: string;
2882
+ readonly description = "\u63D0\u4F9B\u6587\u672C\u6717\u8BFB\u80FD\u529B\uFF0C\u652F\u6301\u5728\u975E\u5DE5\u5177\u8C03\u7528\u8F6E\u81EA\u52A8\u6717\u8BFB\u6A21\u578B\u8F93\u51FA\u3002";
2883
+ private config;
2884
+ private state;
2885
+ private _packageInfo;
2886
+ constructor(config?: TTSFeatureConfig);
2887
+ getTools(): never[];
2888
+ getAsyncTools(_ctx: FeatureInitContext): Promise<never[]>;
2889
+ /**
2890
+ * 获取包信息(统一打包方案)
2891
+ */
2892
+ getPackageInfo(): PackageInfo | null;
2893
+ /**
2894
+ * 获取模板名称列表(统一打包方案)
2895
+ * 此 Feature 没有模板,返回空数组
2896
+ */
2897
+ getTemplateNames(): string[];
2898
+ onInitiate(_ctx: FeatureInitContext): Promise<void>;
2899
+ onDestroy(_ctx: FeatureContext): Promise<void>;
2900
+ captureState(): FeatureStateSnapshot;
2901
+ restoreState(snapshot: FeatureStateSnapshot): void;
2902
+ getHookDescription(lifecycle: string, methodName: string): string | undefined;
2903
+ /**
2904
+ * 检测 Python 环境和依赖库
2905
+ */
2906
+ private checkPythonEnvironment;
2907
+ /**
2908
+ * 调用 Python 脚本生成 TTS 音频
2909
+ */
2910
+ private generateTTS;
2911
+ /**
2912
+ * 提取模型输出的正文部分
2913
+ * 过滤掉系统消息、工具调用等,只保留实际的回复内容
2914
+ */
2915
+ private extractMainResponse;
2916
+ /**
2917
+ * 在每个 step 结束时自动朗读模型输出
2918
+ * 包括工具调用轮和非工具调用轮
2919
+ */
2920
+ speakOnStepFinish(ctx: StepFinishedContext): Promise<void>;
2921
+ }
2922
+
2923
+ /**
2924
+ * UserInputFeature - 通过调试界面获取用户输入
2925
+ *
2926
+ * 功能:
2927
+ * - 提供 get_user_input 工具,允许 LLM 请求用户输入
2928
+ * - 通过 DebugHub 的 UDS 通道与 ViewerWorker 通信
2929
+ * - 前端显示输入框,用户提交后返回给 Agent
2930
+ */
2931
+
2932
+ interface UserInputFeatureConfig {
2933
+ /** 默认超时时间(毫秒),默认无限等待 */
2934
+ timeout?: number;
2935
+ }
2936
+ declare class UserInputFeature implements AgentFeature {
2937
+ readonly name = "user-input";
2938
+ readonly dependencies: string[];
2939
+ readonly source: string;
2940
+ readonly description = "\u5141\u8BB8 Agent \u901A\u8FC7\u8C03\u8BD5\u754C\u9762\u5411\u7528\u6237\u53D1\u8D77\u8F93\u5165\u8BF7\u6C42\u5E76\u7B49\u5F85\u56DE\u590D\u3002";
2941
+ private defaultTimeout;
2942
+ private nextDraftInput;
2943
+ /**
2944
+ * 缓存包信息
2945
+ */
2946
+ private _packageInfo;
2947
+ /**
2948
+ * 获取包信息(统一打包方案)
2949
+ */
2950
+ getPackageInfo(): PackageInfo | null;
2951
+ /**
2952
+ * 获取模板名称列表(统一打包方案)
2953
+ * 注意:UserInputFeature 没有渲染模板
2954
+ */
2955
+ getTemplateNames(): string[];
2956
+ constructor(config?: UserInputFeatureConfig);
2957
+ setNextDraftInput(input: string): void;
2958
+ /**
2959
+ * 请求用户输入(核心方法)
2960
+ */
2961
+ requestUserInput(prompt: string, timeout?: number): Promise<string>;
2962
+ requestUserInputEvent(request: UserInputRequest, timeout?: number): Promise<UserInputResponse>;
2963
+ /**
2964
+ * 获取用户输入(公开接口,供主循环直接调用)
2965
+ * @param prompt 提示信息
2966
+ * @param timeout 超时时间(毫秒)
2967
+ * @returns 用户输入内容
2968
+ */
2969
+ getUserInput(prompt?: string, timeout?: number): Promise<string>;
2970
+ getUserInputEvent(prompt?: string, timeout?: number, actions?: UserInputAction[]): Promise<UserInputResponse>;
2971
+ getTools(): Tool[];
2972
+ onInitiate(_ctx: FeatureInitContext): Promise<void>;
2973
+ onDestroy(_ctx: FeatureContext): Promise<void>;
2974
+ }
2975
+
2976
+ /**
2977
+ * VisualFeature 类型定义
2978
+ */
2979
+ /**
2980
+ * 窗口信息(从 Python enum.py 返回)
2981
+ */
2982
+ interface WindowInfo {
2983
+ /** 窗口句柄(16进制格式,如 "0x12345") */
2984
+ hwnd: string;
2985
+ /** 窗口标题 */
2986
+ title: string;
2987
+ /** 窗口类名 */
2988
+ class_name: string;
2989
+ /** 窗口状态 */
2990
+ status: 'Normal' | 'Minimized' | 'Maximized' | 'Unknown';
2991
+ /** 窗口位置和尺寸 */
2992
+ position: {
2993
+ x: number;
2994
+ y: number;
2995
+ width: number;
2996
+ height: number;
2997
+ };
2998
+ /** 进程名称 */
2999
+ process_name: string;
3000
+ /** 进程路径 */
3001
+ process_path: string;
3002
+ /** 进程 ID */
3003
+ pid: number | string;
3004
+ /** 是否置顶 */
3005
+ is_always_on_top: boolean;
3006
+ }
3007
+ /**
3008
+ * 截图结果(从 Python capture.py 返回)
3009
+ */
3010
+ interface CaptureResult {
3011
+ /** 是否成功 */
3012
+ success?: boolean;
3013
+ /** 窗口句柄 */
3014
+ hwnd?: string;
3015
+ /** 图片宽度 */
3016
+ width?: number;
3017
+ /** 图片高度 */
3018
+ height?: number;
3019
+ /** 图片格式 */
3020
+ format?: string;
3021
+ /** base64 编码的图片数据 */
3022
+ data?: string;
3023
+ /** 错误信息 */
3024
+ error?: string;
3025
+ }
3026
+ /**
3027
+ * 视觉理解结果(从 LLM 返回)
3028
+ */
3029
+ interface VisualUnderstandingResult {
3030
+ /** 图片内容的自然语言描述 */
3031
+ description: string;
3032
+ /** 检测到的 UI 元素(可选) */
3033
+ elements?: Array<{
3034
+ type: string;
3035
+ label?: string;
3036
+ position?: {
3037
+ x: number;
3038
+ y: number;
3039
+ width: number;
3040
+ height: number;
3041
+ };
3042
+ }>;
3043
+ /** 图片类型/应用类型识别(可选) */
3044
+ app_type?: string;
3045
+ }
3046
+ /**
3047
+ * VisualFeature 配置
3048
+ */
3049
+ interface VisualFeatureConfig {
3050
+ /** 工作目录(默认 process.cwd()) */
3051
+ workspaceDir?: string;
3052
+ /** LLM 服务地址(默认 localhost:7575) */
3053
+ baseUrl?: string;
3054
+ /** 视觉理解模型名称(默认 Qwen3.5-4B-Q5_K_M) */
3055
+ model?: string;
3056
+ /**
3057
+ * 主动视觉理解服务配置
3058
+ *
3059
+ * 用于用户主动调用 capture_and_understand_window_advanced 工具时使用
3060
+ * 使用更大的模型(如 Qwen3.5-9B-Q4_K_M)提供更准确的理解
3061
+ */
3062
+ advancedVision?: {
3063
+ /** LLM 服务地址(默认 localhost:7577) */
3064
+ baseUrl?: string;
3065
+ /** 视觉理解模型名称(默认 Qwen3.5-9B-Q4_K_M) */
3066
+ model?: string;
3067
+ };
3068
+ /**
3069
+ * Python 可执行文件路径(默认 'python')
3070
+ *
3071
+ * 常用选项:
3072
+ * - 'python' - 系统默认 Python
3073
+ * - 'uv python' - uv 管理的 Python
3074
+ * - 'uv' - 使用 uv run(需要配置 pythonArgs)
3075
+ * - 完整路径如 'C:\\\Python312\\\python.exe'
3076
+ */
3077
+ pythonPath?: string;
3078
+ /**
3079
+ * Python 参数(可选)
3080
+ *
3081
+ * 例如使用 uv run:
3082
+ * pythonArgs: ['run', '--with', 'pywin32', '--with', 'psutil', '--with', 'Pillow', 'script.py']
3083
+ */
3084
+ pythonArgs?: string[];
3085
+ /**
3086
+ * 窗口进程忽略规则文件路径(可选)
3087
+ *
3088
+ * 默认使用项目根目录下的 .agentdev/windows.ignore
3089
+ * 文件格式:每行一个需要忽略的 exe 路径,支持通配符 *
3090
+ *
3091
+ * 示例:
3092
+ * ```
3093
+ * # 系统组件
3094
+ * C:\\Windows\\explorer.exe
3095
+ * # 输入法
3096
+ * C:\\Windows\\System32\\ctfmon.exe
3097
+ * # 通配符匹配
3098
+ * C:\\Program Files\\WindowsApps\\Microsoft.InputApp_*
3099
+ * ```
3100
+ */
3101
+ ignoreFilePath?: string;
3102
+ /** 是否启用 onCallStart 窗口状态注入(默认 true) */
3103
+ enableWindowInfo?: boolean;
3104
+ /** 是否在初始化时检测 Python 环境(默认 true) */
3105
+ checkPythonEnv?: boolean;
3106
+ /**
3107
+ * 后台监控配置
3108
+ */
3109
+ monitoring?: {
3110
+ /** 是否启用后台监控 */
3111
+ enabled?: boolean;
3112
+ /** 轮询间隔(毫秒),默认 250 */
3113
+ pollInterval?: number;
3114
+ /** 截图 Worker 数量,默认 3 */
3115
+ captureWorkerCount?: number;
3116
+ /** 分析 Worker 数量,默认 1(单线程,避免连接压力) */
3117
+ analysisWorkerCount?: number;
3118
+ /** 同一窗口两次截图的最小间隔(毫秒),默认 5 秒 */
3119
+ minCaptureInterval?: number;
3120
+ /** 失去焦点多久后重新获得焦点需要重新截图(毫秒),默认 15 秒 */
3121
+ focusChangeCaptureThreshold?: number;
3122
+ /** 焦点持续多久后需要重新截图(毫秒),默认 30 秒 */
3123
+ longFocusCaptureThreshold?: number;
3124
+ /** 焦点状态持续多久后需要截图(毫秒),默认 10 秒 */
3125
+ focusDurationCaptureThreshold?: number;
3126
+ /** 同一窗口两次分析的最小间隔(毫秒),默认 60 秒 */
3127
+ minAnalysisInterval?: number;
3128
+ /** 失去焦点多久后重新获得焦点需要重新分析(毫秒),默认 30 秒 */
3129
+ focusChangeAnalysisThreshold?: number;
3130
+ /** 焦点持续多久后需要重新分析(毫秒),默认 60 秒 */
3131
+ longFocusAnalysisThreshold?: number;
3132
+ /** 缓存过期时间(毫秒),默认 300 秒(5分钟) */
3133
+ analysisTTL?: number;
3134
+ };
3135
+ /**
3136
+ * 缓存管理配置
3137
+ */
3138
+ cache?: {
3139
+ /** 缓存根目录,默认 .agentdev/visual-cache */
3140
+ cacheDir?: string;
3141
+ /** 最大总大小(字节),默认 500MB */
3142
+ maxSize?: number;
3143
+ /** 最大文件数,默认 100 */
3144
+ maxCount?: number;
3145
+ /** 每个窗口保留的最大截图数量,默认 5 */
3146
+ maxCapturesPerWindow?: number;
3147
+ /** 截图TTL(毫秒),默认 7天 */
3148
+ imageTTL?: number;
3149
+ /** 分析结果TTL(毫秒),默认 7天 */
3150
+ analysisTTL?: number;
3151
+ /** 清理间隔(毫秒),默认 10分钟 */
3152
+ cleanupInterval?: number;
3153
+ };
3154
+ /**
3155
+ * 错误处理配置
3156
+ */
3157
+ errorHandling?: {
3158
+ /** 最大重试次数,默认 1 */
3159
+ maxRetries?: number;
3160
+ /** 任务超时时间(毫秒),默认 30秒 */
3161
+ taskTimeout?: number;
3162
+ /** 是否跳过空图,默认 true */
3163
+ skipEmptyImage?: boolean;
3164
+ };
3165
+ }
3166
+
3167
+ /**
3168
+ * VisualFeature - 视觉理解功能模块
3169
+ *
3170
+ * 提供:
3171
+ * 1. capture_and_understand_window 工具:截图 + 视觉模型理解
3172
+ * 2. onCallStart 钩子:自动注入当前窗口状态信息
3173
+ *
3174
+ * Python 环境要求:
3175
+ * - 需要安装 pywin32、psutil、Pillow 库
3176
+ *
3177
+ * 安装方式:
3178
+ * uv 方式(推荐):
3179
+ * uv pip install pywin32 psutil Pillow
3180
+ *
3181
+ * 或使用 pip:
3182
+ * pip install pywin32 psutil Pillow
3183
+ *
3184
+ * Python 调用方式:
3185
+ * - 默认使用 'python' 命令(从 PATH 中查找)
3186
+ * - 如果使用 uv,可以配置为 'uv python' 或 'uv run --with pywin32 --with psutil --with Pillow'
3187
+ *
3188
+ * @example
3189
+ * ```typescript
3190
+ * import { VisualFeature } from './features/index.js';
3191
+ *
3192
+ * // 使用默认 python 命令
3193
+ * const agent = new Agent({ ... }).use(new VisualFeature());
3194
+ *
3195
+ * // 使用 uv
3196
+ * const agent = new Agent({ ... }).use(new VisualFeature({
3197
+ * pythonPath: 'uv python'
3198
+ * }));
3199
+ *
3200
+ * // 使用 uv run(自动安装依赖)
3201
+ * const agent = new Agent({ ... }).use(new VisualFeature({
3202
+ * pythonPath: 'uv'
3203
+ * pythonArgs: ['run', '--with', 'pywin32', '--with', 'psutil', '--with', 'Pillow']
3204
+ * }));
3205
+ * ```
3206
+ */
3207
+
3208
+ declare class VisualFeature implements AgentFeature {
3209
+ readonly name = "visual";
3210
+ readonly dependencies: string[];
3211
+ readonly source: string;
3212
+ readonly description = "\u63D0\u4F9B\u7A97\u53E3\u622A\u56FE\u3001\u89C6\u89C9\u7406\u89E3\u548C\u5F53\u524D\u5DE5\u4F5C\u533A\u72B6\u6001\u6CE8\u5165\u80FD\u529B\u3002";
3213
+ private config;
3214
+ private client;
3215
+ private advancedClient;
3216
+ private windowMonitorService;
3217
+ private captureWorkerPool;
3218
+ private analysisWorkerPool;
3219
+ private cacheManager;
3220
+ private _visualEnabled;
3221
+ private injectionState;
3222
+ constructor(config?: VisualFeatureConfig);
3223
+ private _packageInfo;
3224
+ /**
3225
+ * 获取包信息(统一打包方案)
3226
+ */
3227
+ getPackageInfo(): PackageInfo | null;
3228
+ /**
3229
+ * 获取模板名称列表(统一打包方案)
3230
+ */
3231
+ getTemplateNames(): string[];
3232
+ getTools(): Tool[];
3233
+ getAsyncTools(_ctx: FeatureInitContext): Promise<Tool[]>;
3234
+ onInitiate(_ctx: FeatureInitContext): Promise<void>;
3235
+ /**
3236
+ * 检测 Python 环境和依赖库
3237
+ */
3238
+ private checkPythonEnvironment;
3239
+ onDestroy(_ctx: FeatureContext): Promise<void>;
3240
+ captureState(): FeatureStateSnapshot;
3241
+ restoreState(snapshot: FeatureStateSnapshot): void;
3242
+ getHookDescription(lifecycle: string, methodName: string): string | undefined;
3243
+ /**
3244
+ * 初始化后台监控服务
3245
+ */
3246
+ private initializeMonitoring;
3247
+ /**
3248
+ * 停止后台监控服务
3249
+ */
3250
+ private stopMonitoring;
3251
+ /**
3252
+ * 处理 /visual 命令并注入窗口信息(增量版本)
3253
+ *
3254
+ * 逻辑:
3255
+ * 1. 检测 /visual 命令,切换视觉模式开关
3256
+ * 2. 如果是命令,更新输入缓存为纯净内容(去除命令前缀)
3257
+ * 3. 如果视觉模式开启(包括刚开启的),立即注入窗口信息
3258
+ *
3259
+ * 增量注入策略:
3260
+ * - 第一次:全量注入(所有窗口 + 所有缓存)
3261
+ * - 后续:只注入变化部分(窗口状态变化 + 新的分析结果)
3262
+ */
3263
+ injectWindowInfo(ctx: CallStartContext): Promise<void>;
3264
+ /**
3265
+ * 调用 Python 脚本枚举所有窗口
3266
+ */
3267
+ private enumerateWindows;
3268
+ /**
3269
+ * 获取当前焦点窗口句柄
3270
+ */
3271
+ private getForegroundWindow;
3272
+ /**
3273
+ * 格式化窗口信息为系统消息(全量版本,用于首次注入)
3274
+ */
3275
+ private formatWindowMessage;
3276
+ /**
3277
+ * 格式化缓存的窗口分析结果(全量版本,用于首次注入)
3278
+ */
3279
+ private formatCachedAnalyses;
3280
+ /**
3281
+ * 计算简单哈希(用于检测内容变化)
3282
+ */
3283
+ private hashDescription;
3284
+ /**
3285
+ * 计算窗口状态变化
3286
+ */
3287
+ private computeWindowChanges;
3288
+ /**
3289
+ * 计算缓存分析结果变化
3290
+ */
3291
+ private computeAnalysisChanges;
3292
+ /**
3293
+ * 格式化窗口变化
3294
+ */
3295
+ private formatWindowChanges;
3296
+ /**
3297
+ * 格式化分析变化
3298
+ */
3299
+ private formatAnalysisChanges;
3300
+ /**
3301
+ * 格式化增量消息(合并窗口状态变化 + 缓存分析变化 + 首次全量)
3302
+ */
3303
+ private formatIncrementalMessage;
3304
+ }
3305
+
3306
+ /**
3307
+ * MCP Tool Adapter - 适配器模式实现
3308
+ *
3309
+ * 将 MCP 工具适配为现有 Tool 接口,保持架构一致性
3310
+ */
3311
+
3312
+ /**
3313
+ * 注册工具的简化接口
3314
+ * 用于适配器包装
3315
+ */
3316
+ interface RegisteredToolLike {
3317
+ name: string;
3318
+ description?: string;
3319
+ inputSchema?: any;
3320
+ outputSchema?: any;
3321
+ annotations?: any;
3322
+ handler?: (args: any, context?: any) => Promise<any> | any;
3323
+ enabled?: boolean;
3324
+ }
3325
+ /**
3326
+ * MCP 工具适配器配置
3327
+ */
3328
+ interface MCPToolAdapterConfig {
3329
+ /** MCP 服务器名称 */
3330
+ serverName: string;
3331
+ /** 是否为只读工具 */
3332
+ readOnly?: boolean;
3333
+ /** 渲染模板覆盖 */
3334
+ render?: {
3335
+ call?: string;
3336
+ result?: string;
3337
+ };
3338
+ }
3339
+ /**
3340
+ * MCP 工具适配器
3341
+ *
3342
+ * 将 MCP RegisteredTool 适配为 Agent 的 Tool 接口
3343
+ * 负责格式转换和生命周期管理
3344
+ */
3345
+ declare class MCPToolAdapter implements Tool {
3346
+ private registeredTool;
3347
+ private config;
3348
+ readonly name: string;
3349
+ readonly description: string;
3350
+ readonly parameters?: Record<string, any>;
3351
+ readonly render?: {
3352
+ call?: string;
3353
+ result?: string;
3354
+ };
3355
+ constructor(registeredTool: RegisteredToolLike, config: MCPToolAdapterConfig);
3356
+ /**
3357
+ * 执行 MCP 工具
3358
+ */
3359
+ execute(args: any, context?: any): Promise<any>;
3360
+ /**
3361
+ * 格式化 MCP 工具结果
3362
+ */
3363
+ private formatResult;
3364
+ /**
3365
+ * 格式化错误
3366
+ */
3367
+ private formatError;
3368
+ /**
3369
+ * 从 RegisteredToolLike 提取参数定义
3370
+ *
3371
+ * MCP 工具的 inputSchema 已经是 JSON Schema 格式
3372
+ * 直接返回,不需要转换
3373
+ */
3374
+ private extractParameters;
3375
+ }
3376
+ /**
3377
+ * 批量创建 MCP 工具适配器
3378
+ */
3379
+ declare function createMCPToolAdapters(registeredTools: RegisteredToolLike[], serverName: string, config?: Omit<MCPToolAdapterConfig, 'serverName'>): Tool[];
3380
+
3381
+ interface MCPDiscoveredTool {
3382
+ name: string;
3383
+ description?: string;
3384
+ inputSchema?: any;
3385
+ }
3386
+ interface MCPToolCreationOptions {
3387
+ name?: string;
3388
+ description?: string;
3389
+ render?: MCPToolAdapterConfig['render'];
3390
+ transformArgs?: (args: Record<string, unknown>, context?: any) => Record<string, unknown>;
3391
+ }
3392
+ interface MCPToolDiscoveryOptions {
3393
+ filter?: (tool: MCPDiscoveredTool) => boolean;
3394
+ mapName?: (tool: MCPDiscoveredTool) => string;
3395
+ render?: MCPToolAdapterConfig['render'];
3396
+ transformArgs?: MCPToolCreationOptions['transformArgs'];
3397
+ }
3398
+ interface MCPDiscoveredToolSet {
3399
+ client: MCPClient;
3400
+ tools: Tool[];
3401
+ }
3402
+ declare function createDefaultMCPToolName(serverId: string, toolName: string): string;
3403
+ declare class MCPClient {
3404
+ readonly serverId: string;
3405
+ private readonly config;
3406
+ private readonly manager;
3407
+ private connected;
3408
+ constructor(serverId: string, config: MCPServerConfig, manager?: MCPConnectionManager);
3409
+ connect(): Promise<void>;
3410
+ listTools(): Promise<MCPDiscoveredTool[]>;
3411
+ callTool(name: string, args: Record<string, unknown>): Promise<any>;
3412
+ getConnectionManager(): MCPConnectionManager;
3413
+ dispose(): Promise<void>;
3414
+ }
3415
+ declare function createMCPTool(client: MCPClient, tool: MCPDiscoveredTool, options?: MCPToolCreationOptions): Tool;
3416
+ declare function createMCPToolsFromClient(client: MCPClient, options?: MCPToolDiscoveryOptions): Promise<Tool[]>;
3417
+ declare function discoverMCPTools(serverId: string, config: MCPServerConfig, options?: MCPToolDiscoveryOptions, manager?: MCPConnectionManager): Promise<MCPDiscoveredToolSet>;
3418
+
3419
+ interface MCPToolPatch {
3420
+ enabled?: boolean;
3421
+ name?: string;
3422
+ description?: string;
3423
+ render?: MCPToolAdapterConfig['render'];
3424
+ transformArgs?: MCPToolCreationOptions['transformArgs'];
3425
+ }
3426
+ interface MCPToolManagementOptions {
3427
+ include?: string[];
3428
+ exclude?: string[];
3429
+ disable?: string[];
3430
+ rename?: Record<string, string>;
3431
+ describe?: Record<string, string>;
3432
+ render?: MCPToolAdapterConfig['render'];
3433
+ toolRender?: Record<string, MCPToolAdapterConfig['render']>;
3434
+ mapName?: (tool: MCPDiscoveredTool, client: MCPClient) => string;
3435
+ transformArgs?: MCPToolCreationOptions['transformArgs'];
3436
+ transform?: (tool: MCPDiscoveredTool, client: MCPClient) => MCPToolPatch | false | null | undefined;
3437
+ }
3438
+ interface MCPConfigMountOptions {
3439
+ manager?: MCPConnectionManager;
3440
+ clients?: Map<string, MCPClient>;
3441
+ getServerOptions?: (serverId: string, serverConfig: MCPServerConfig) => MCPToolManagementOptions | undefined;
3442
+ onError?: (serverId: string, error: unknown) => void;
3443
+ }
3444
+ interface MCPMountedToolSet {
3445
+ client: MCPClient;
3446
+ tools: Tool[];
3447
+ }
3448
+ interface MCPMountedConfigResult {
3449
+ tools: Tool[];
3450
+ clients: Map<string, MCPClient>;
3451
+ }
3452
+ declare function createManagedMCPToolsFromClient(client: MCPClient, options?: MCPToolManagementOptions): Promise<Tool[]>;
3453
+ declare function discoverManagedMCPTools(serverId: string, config: MCPServerConfig, options?: MCPToolManagementOptions, manager?: MCPConnectionManager): Promise<MCPMountedToolSet>;
3454
+ declare function mountMCPToolsFromConfig(config: MCPConfig, options?: MCPConfigMountOptions): Promise<MCPMountedConfigResult>;
3455
+
3456
+ /**
3457
+ * WebSearch Feature - 网页内容获取工具
2052
3458
  *
2053
- * 功能:
2054
- * - 提供 get_user_input 工具,允许 LLM 请求用户输入
2055
- * - 通过 DebugHub 的 UDS 通道与 ViewerWorker 通信
2056
- * - 前端显示输入框,用户提交后返回给 Agent
3459
+ * 提供网页抓取和内容提取功能
3460
+ *
3461
+ * @example
3462
+ * ```typescript
3463
+ * import { WebSearchFeature } from './features/index.js';
3464
+ * const agent = new Agent({ ... }).use(new WebSearchFeature());
3465
+ * ```
2057
3466
  */
2058
3467
 
2059
- interface UserInputFeatureConfig {
2060
- /** 默认超时时间(毫秒),默认无限等待 */
2061
- timeout?: number;
3468
+ interface WebSearchFeatureConfig {
3469
+ crawl4ai?: false | (MCPToolManagementOptions & {
3470
+ server?: MCPSSEConfig;
3471
+ });
2062
3472
  }
2063
- declare class UserInputFeature implements AgentFeature {
2064
- readonly name = "user-input";
3473
+ /**
3474
+ * WebSearch Feature 实现
3475
+ */
3476
+ declare class WebSearchFeature implements AgentFeature {
3477
+ private readonly config;
3478
+ readonly name = "websearch";
2065
3479
  readonly dependencies: string[];
2066
3480
  readonly source: string;
2067
- readonly description = "\u5141\u8BB8 Agent \u901A\u8FC7\u8C03\u8BD5\u754C\u9762\u5411\u7528\u6237\u53D1\u8D77\u8F93\u5165\u8BF7\u6C42\u5E76\u7B49\u5F85\u56DE\u590D\u3002";
2068
- private defaultTimeout;
2069
- private nextDraftInput;
3481
+ readonly description = "\u63D0\u4F9B\u7F51\u9875\u6293\u53D6\u5DE5\u5177\uFF0C\u5E76\u53EF\u6258\u7BA1 crawl4ai MCP \u80FD\u529B\u7528\u4E8E\u6DF1\u5EA6\u7F51\u9875\u8BFB\u53D6\u3002";
3482
+ private readonly manager;
3483
+ private readonly crawl4aiClients;
3484
+ private _packageInfo;
3485
+ constructor(config?: WebSearchFeatureConfig);
2070
3486
  /**
2071
- * 缓存包信息
3487
+ * 获取工具列表
2072
3488
  */
2073
- private _packageInfo;
3489
+ getTools(): Tool[];
3490
+ getAsyncTools(_ctx: FeatureInitContext): Promise<Tool[]>;
3491
+ onDestroy(): Promise<void>;
2074
3492
  /**
2075
3493
  * 获取包信息(统一打包方案)
2076
3494
  */
2077
3495
  getPackageInfo(): PackageInfo | null;
2078
3496
  /**
2079
3497
  * 获取模板名称列表(统一打包方案)
2080
- * 注意:UserInputFeature 没有渲染模板
2081
3498
  */
2082
3499
  getTemplateNames(): string[];
2083
- constructor(config?: UserInputFeatureConfig);
2084
- setNextDraftInput(input: string): void;
2085
- /**
2086
- * 请求用户输入(核心方法)
2087
- */
2088
- requestUserInput(prompt: string, timeout?: number): Promise<string>;
2089
- requestUserInputEvent(request: UserInputRequest, timeout?: number): Promise<UserInputResponse>;
2090
- /**
2091
- * 获取用户输入(公开接口,供主循环直接调用)
2092
- * @param prompt 提示信息
2093
- * @param timeout 超时时间(毫秒)
2094
- * @returns 用户输入内容
2095
- */
2096
- getUserInput(prompt?: string, timeout?: number): Promise<string>;
2097
- getUserInputEvent(prompt?: string, timeout?: number, actions?: UserInputAction[]): Promise<UserInputResponse>;
2098
- getTools(): Tool[];
2099
- onInitiate(_ctx: FeatureInitContext): Promise<void>;
2100
- onDestroy(_ctx: FeatureContext): Promise<void>;
2101
3500
  }
2102
3501
 
3502
+ interface OpencodeBasicFeatureConfig {
3503
+ workspaceDir?: string;
3504
+ }
2103
3505
  /**
2104
3506
  * OpencodeBasic Feature - 基础文件操作工具集
2105
3507
  */
@@ -2129,6 +3531,8 @@ declare class OpencodeBasicFeature implements AgentFeature {
2129
3531
  * Logger 实例,用于记录结构化日志
2130
3532
  */
2131
3533
  private logger;
3534
+ private readonly workspaceDir;
3535
+ constructor(config?: OpencodeBasicFeatureConfig);
2132
3536
  /**
2133
3537
  * Feature 初始化时清空读取历史
2134
3538
  */
@@ -2305,6 +3709,10 @@ interface BasicAgentConfig {
2305
3709
  tools?: Tool[];
2306
3710
  /** Skills 目录(可选,默认使用 .agentdev/skills) */
2307
3711
  skillsDir?: string;
3712
+ /** 调试器和模板解析使用的项目根目录 */
3713
+ projectRoot?: string;
3714
+ /** 工具默认操作的工作目录 */
3715
+ workspaceDir?: string;
2308
3716
  }
2309
3717
  /**
2310
3718
  * 基础 Agent 类
@@ -2595,7 +4003,7 @@ declare class ViewerWorker {
2595
4003
  /**
2596
4004
  * GET /api/templates/feature - 获取 Feature 模板映射
2597
4005
  */
2598
- handleGetFeatureTemplates(req: IncomingMessage, res: ServerResponse): void;
4006
+ handleGetFeatureTemplates(req: IncomingMessage, res: ServerResponse, searchParams?: URLSearchParams): void;
2599
4007
  /**
2600
4008
  * 将模板文件路径转换为 HTTP URL
2601
4009
  * 支持多种来源:
@@ -2946,119 +4354,6 @@ declare function createListRenderer<T = any>(config: Omit<DataSourceRenderer<T>,
2946
4354
  */
2947
4355
  declare function discover(options?: SkillsOptions): Promise<SkillMetadata[]>;
2948
4356
 
2949
- /**
2950
- * MCP Tool Adapter - 适配器模式实现
2951
- *
2952
- * 将 MCP 工具适配为现有 Tool 接口,保持架构一致性
2953
- */
2954
-
2955
- /**
2956
- * 注册工具的简化接口
2957
- * 用于适配器包装
2958
- */
2959
- interface RegisteredToolLike {
2960
- name: string;
2961
- description?: string;
2962
- inputSchema?: any;
2963
- outputSchema?: any;
2964
- annotations?: any;
2965
- handler?: (args: any, context?: any) => Promise<any> | any;
2966
- enabled?: boolean;
2967
- }
2968
- /**
2969
- * MCP 工具适配器配置
2970
- */
2971
- interface MCPToolAdapterConfig {
2972
- /** MCP 服务器名称 */
2973
- serverName: string;
2974
- /** 是否为只读工具 */
2975
- readOnly?: boolean;
2976
- /** 渲染模板覆盖 */
2977
- render?: {
2978
- call?: string;
2979
- result?: string;
2980
- };
2981
- }
2982
- /**
2983
- * MCP 工具适配器
2984
- *
2985
- * 将 MCP RegisteredTool 适配为 Agent 的 Tool 接口
2986
- * 负责格式转换和生命周期管理
2987
- */
2988
- declare class MCPToolAdapter implements Tool {
2989
- private registeredTool;
2990
- private config;
2991
- readonly name: string;
2992
- readonly description: string;
2993
- readonly parameters?: Record<string, any>;
2994
- readonly render?: {
2995
- call?: string;
2996
- result?: string;
2997
- };
2998
- constructor(registeredTool: RegisteredToolLike, config: MCPToolAdapterConfig);
2999
- /**
3000
- * 执行 MCP 工具
3001
- */
3002
- execute(args: any, context?: any): Promise<any>;
3003
- /**
3004
- * 格式化 MCP 工具结果
3005
- */
3006
- private formatResult;
3007
- /**
3008
- * 格式化错误
3009
- */
3010
- private formatError;
3011
- /**
3012
- * 从 RegisteredToolLike 提取参数定义
3013
- *
3014
- * MCP 工具的 inputSchema 已经是 JSON Schema 格式
3015
- * 直接返回,不需要转换
3016
- */
3017
- private extractParameters;
3018
- }
3019
- /**
3020
- * 批量创建 MCP 工具适配器
3021
- */
3022
- declare function createMCPToolAdapters(registeredTools: RegisteredToolLike[], serverName: string, config?: Omit<MCPToolAdapterConfig, 'serverName'>): Tool[];
3023
-
3024
- interface MCPDiscoveredTool {
3025
- name: string;
3026
- description?: string;
3027
- inputSchema?: any;
3028
- }
3029
- interface MCPToolCreationOptions {
3030
- name?: string;
3031
- description?: string;
3032
- render?: MCPToolAdapterConfig['render'];
3033
- transformArgs?: (args: Record<string, unknown>, context?: any) => Record<string, unknown>;
3034
- }
3035
- interface MCPToolDiscoveryOptions {
3036
- filter?: (tool: MCPDiscoveredTool) => boolean;
3037
- mapName?: (tool: MCPDiscoveredTool) => string;
3038
- render?: MCPToolAdapterConfig['render'];
3039
- transformArgs?: MCPToolCreationOptions['transformArgs'];
3040
- }
3041
- interface MCPDiscoveredToolSet {
3042
- client: MCPClient;
3043
- tools: Tool[];
3044
- }
3045
- declare function createDefaultMCPToolName(serverId: string, toolName: string): string;
3046
- declare class MCPClient {
3047
- readonly serverId: string;
3048
- private readonly config;
3049
- private readonly manager;
3050
- private connected;
3051
- constructor(serverId: string, config: MCPServerConfig, manager?: MCPConnectionManager);
3052
- connect(): Promise<void>;
3053
- listTools(): Promise<MCPDiscoveredTool[]>;
3054
- callTool(name: string, args: Record<string, unknown>): Promise<any>;
3055
- getConnectionManager(): MCPConnectionManager;
3056
- dispose(): Promise<void>;
3057
- }
3058
- declare function createMCPTool(client: MCPClient, tool: MCPDiscoveredTool, options?: MCPToolCreationOptions): Tool;
3059
- declare function createMCPToolsFromClient(client: MCPClient, options?: MCPToolDiscoveryOptions): Promise<Tool[]>;
3060
- declare function discoverMCPTools(serverId: string, config: MCPServerConfig, options?: MCPToolDiscoveryOptions, manager?: MCPConnectionManager): Promise<MCPDiscoveredToolSet>;
3061
-
3062
4357
  interface LoadAllMCPConfigsOptions {
3063
4358
  excludeServers?: string[];
3064
4359
  }
@@ -3066,43 +4361,6 @@ declare function getDefaultMCPConfigDir(rootDir?: string): string;
3066
4361
  declare function loadMCPConfigFromInput(input: string, rootDir?: string): MCPConfig | undefined;
3067
4362
  declare function loadAllMCPConfigs(rootDir?: string, options?: LoadAllMCPConfigsOptions): MCPConfig | undefined;
3068
4363
 
3069
- interface MCPToolPatch {
3070
- enabled?: boolean;
3071
- name?: string;
3072
- description?: string;
3073
- render?: MCPToolAdapterConfig['render'];
3074
- transformArgs?: MCPToolCreationOptions['transformArgs'];
3075
- }
3076
- interface MCPToolManagementOptions {
3077
- include?: string[];
3078
- exclude?: string[];
3079
- disable?: string[];
3080
- rename?: Record<string, string>;
3081
- describe?: Record<string, string>;
3082
- render?: MCPToolAdapterConfig['render'];
3083
- toolRender?: Record<string, MCPToolAdapterConfig['render']>;
3084
- mapName?: (tool: MCPDiscoveredTool, client: MCPClient) => string;
3085
- transformArgs?: MCPToolCreationOptions['transformArgs'];
3086
- transform?: (tool: MCPDiscoveredTool, client: MCPClient) => MCPToolPatch | false | null | undefined;
3087
- }
3088
- interface MCPConfigMountOptions {
3089
- manager?: MCPConnectionManager;
3090
- clients?: Map<string, MCPClient>;
3091
- getServerOptions?: (serverId: string, serverConfig: MCPServerConfig) => MCPToolManagementOptions | undefined;
3092
- onError?: (serverId: string, error: unknown) => void;
3093
- }
3094
- interface MCPMountedToolSet {
3095
- client: MCPClient;
3096
- tools: Tool[];
3097
- }
3098
- interface MCPMountedConfigResult {
3099
- tools: Tool[];
3100
- clients: Map<string, MCPClient>;
3101
- }
3102
- declare function createManagedMCPToolsFromClient(client: MCPClient, options?: MCPToolManagementOptions): Promise<Tool[]>;
3103
- declare function discoverManagedMCPTools(serverId: string, config: MCPServerConfig, options?: MCPToolManagementOptions, manager?: MCPConnectionManager): Promise<MCPMountedToolSet>;
3104
- declare function mountMCPToolsFromConfig(config: MCPConfig, options?: MCPConfigMountOptions): Promise<MCPMountedConfigResult>;
3105
-
3106
4364
  /**
3107
4365
  * MCP 工具渲染模板
3108
4366
  *
@@ -3140,4 +4398,4 @@ declare function renderMCPToolCall(serverName: string, toolName: string, args: R
3140
4398
  */
3141
4399
  declare function renderMCPToolResult(result: any, success?: boolean): string;
3142
4400
 
3143
- export { AgentBase as Agent, AgentConfig, type AgentConfigFile, type AgentFeature, AgentInfo, type AgentInitiateContext, AgentPool, AgentSession, type AgentSessionSnapshot, AnthropicLLM, BasicAgent, type BasicAgentConfig, CallFinish, type CallFinishContext, CallStart, type CallStartContext, Context, type ContextInjector, DataSourceRegistry, type DataSourceRenderer, type DebugCapabilities, DebugHub, Decision, type DecisionResult, ExampleFeature, type ExampleFeatureConfig, type ExampleFeatureRuntimeState, type ExampleFeatureSnapshot, ExplorerAgent, type ExplorerAgentConfig, type SystemContext as ExplorerSystemContext, type FeatureContext, type FeatureInitContext, type FeatureStateSnapshot, FileSessionStore, type HookResult, InlineRenderTemplate, LLMClient, LLMResponse, type LoadAllMCPConfigsOptions, type Logger, type LoggerBindings, MCPClient, type MCPClientConfig, type MCPConfig, type MCPConfigMountOptions, type MCPConnectionInfo, MCPConnectionManager, MCPConnectionState, type MCPDiscoveredTool, type MCPDiscoveredToolSet, MCPFeature, type MCPFeatureOptions, type MCPHTTPConfig, type MCPMountedConfigResult, type MCPMountedToolSet, type MCPSSEConfig, type MCPServerConfig, type MCPSstdioConfig, type MCPStatistics, MCPToolAdapter, type MCPToolAdapterConfig, type MCPToolCreationOptions, type MCPToolDiscoveryOptions, type MCPToolManagementOptions, type MCPToolPatch, type MCPToolResult, MCP_RENDER_TEMPLATES, Message, MessageRole, type ModelConfig, OpenAILLM, OpencodeBasicFeature, type PackageInfo, PlaceholderContext, PlaceholderResolver, type SessionStore, SkillFeature, type SkillFeatureConfig, type SkillMetadata, type SkillsOptions, StepFinish, type StepFinishedContext, StepStart, type StepStartContext, SubAgentFeature, type SystemContext$1 as SystemContext, type TaskStatus, TemplateLoader, TemplateSource, TodoFeature, type TodoFeatureConfig, type TodoTask, type TodoTaskSummary, Tool, ToolCall, type ToolContext, type ToolContextValue, ToolFinished, ToolRegistry, ToolRenderConfig, type ToolResult, ToolUse, UserInputFeature, type UserInputFeatureConfig, ViewerWorker, assistant, compileContextForAnthropic, createAnthropicLLM, createDefaultMCPToolName, createLLM, createListRenderer, createLogger, createMCPTool, createMCPToolAdapters, createMCPToolsFromClient, createManagedMCPToolsFromClient, createMessage, createOpenAILLM, createTool, discover, discoverMCPTools, discoverManagedMCPTools, getClawRuntimeUrl, getDebugCapabilities, getDefaultMCPConfigDir, getDefaultSessionStore, getMCPRenderTemplate, getPackageInfoFromSource, installConsoleBridge, listConfigs, loadAllMCPConfigs, loadConfig, loadConfigSync, loadMCPConfigFromInput, mountMCPToolsFromConfig, renderMCPToolCall, renderMCPToolResult, resolveDebugTransportMode, runWithLogScope, system, toolResult, user };
4401
+ export { AgentBase as Agent, AgentConfig, type AgentConfigFile, type AgentFeature, AgentInfo, type AgentInitiateContext, AgentPool, AgentSession, type AgentSessionSnapshot, AnthropicLLM, AudioFeedbackFeature, AuditFeature, type AuditFeatureConfig, BasicAgent, type BasicAgentConfig, CallFinish, type CallFinishContext, CallStart, type CallStartContext, type CaptureResult, Context, type ContextInjector, type ContextSnapshot, DataSourceRegistry, type DataSourceRenderer, type DebugCapabilities, DebugHub, Decision, type DecisionResult, ExampleFeature, type ExampleFeatureConfig, type ExampleFeatureRuntimeState, type ExampleFeatureSnapshot, ExplorerAgent, type ExplorerAgentConfig, type SystemContext as ExplorerSystemContext, type FeatureContext, type FeatureInitContext, type FeatureStateSnapshot, FileSessionStore, type HookResult, InlineRenderTemplate, type KnownUser, LLMClient, LLMResponse, type LoadAllMCPConfigsOptions, type Logger, type LoggerBindings, MCPClient, type MCPClientConfig, type MCPConfig, type MCPConfigMountOptions, type MCPConnectionInfo, MCPConnectionManager, MCPConnectionState, type MCPDiscoveredTool, type MCPDiscoveredToolSet, MCPFeature, type MCPFeatureOptions, type MCPHTTPConfig, type MCPMountedConfigResult, type MCPMountedToolSet, type MCPSSEConfig, type MCPServerConfig, type MCPSstdioConfig, type MCPStatistics, MCPToolAdapter, type MCPToolAdapterConfig, type MCPToolCreationOptions, type MCPToolDiscoveryOptions, type MCPToolManagementOptions, type MCPToolPatch, type MCPToolResult, MCP_RENDER_TEMPLATES, MemoryFeature, type MemoryFeatureConfig, Message, MessageRole, type ModelConfig, OpenAILLM, OpencodeBasicFeature, type PackageInfo, PlaceholderContext, PlaceholderResolver, PluginCompatFeature, QQBotFeature, type QQBotFeatureConfig, type QQBotSendOptions, type QQBotSendResult, type SessionStore, ShellFeature, SkillFeature, type SkillFeatureConfig, type SkillMetadata, type SkillsOptions, StepFinish, type StepFinishedContext, StepStart, type StepStartContext, SubAgentFeature, type SystemContext$1 as SystemContext, TTSFeature, type TTSFeatureConfig, type TTSResult, type TTSState, type TaskStatus, TemplateLoader, TemplateSource, TodoFeature, type TodoFeatureConfig, type TodoTask, type TodoTaskSummary, Tool, ToolCall, type ToolContext, type ToolContextValue, ToolFinished, ToolRegistry, ToolRenderConfig, type ToolResult, ToolUse, UserInputFeature, type UserInputFeatureConfig, ViewerWorker, VisualFeature, type VisualFeatureConfig, type VisualUnderstandingResult, WebSearchFeature, type WebSearchFeatureConfig, type WindowInfo, assistant, compileContextForAnthropic, createAnthropicLLM, createDefaultMCPToolName, createLLM, createListRenderer, createLogger, createMCPTool, createMCPToolAdapters, createMCPToolsFromClient, createManagedMCPToolsFromClient, createMessage, createOpenAILLM, createTool, discover, discoverMCPTools, discoverManagedMCPTools, getClawRuntimeUrl, getDebugCapabilities, getDefaultMCPConfigDir, getDefaultSessionStore, getMCPRenderTemplate, getPackageInfoFromSource, installConsoleBridge, listConfigs, loadAllMCPConfigs, loadConfig, loadConfigSync, loadMCPConfigFromInput, mountMCPToolsFromConfig, renderMCPToolCall, renderMCPToolResult, resolveDebugTransportMode, runWithLogScope, system, toolResult, user };