agentdev 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/BasicAgent-UWXLSZP2.js +13 -0
- package/dist/ExplorerAgent-LCM3JQS4.js +13 -0
- package/dist/{chunk-LQTEETML.js → chunk-5T4C2XRT.js} +12 -7
- package/dist/chunk-5T4C2XRT.js.map +1 -0
- package/dist/{chunk-OBOU27DM.js → chunk-A354ZCZF.js} +6735 -1822
- package/dist/chunk-A354ZCZF.js.map +1 -0
- package/dist/{chunk-TSASFMRF.js → chunk-BAP2GCYH.js} +1 -1
- package/dist/chunk-BAP2GCYH.js.map +1 -0
- package/dist/{chunk-3BPSNNK3.js → chunk-EECW6PYP.js} +11 -9
- package/dist/chunk-EECW6PYP.js.map +1 -0
- package/dist/chunk-G5ECPY4K.js +551 -0
- package/dist/chunk-G5ECPY4K.js.map +1 -0
- package/dist/{chunk-LLV3W326.js → chunk-NORTAQIL.js} +67 -20
- package/dist/chunk-NORTAQIL.js.map +1 -0
- package/dist/{chunk-F3PR7UTL.js → chunk-QFHPUAUQ.js} +5 -3
- package/dist/{chunk-F3PR7UTL.js.map → chunk-QFHPUAUQ.js.map} +1 -1
- package/dist/cli/server.js +2 -2
- package/dist/cli/viewer.js +2 -2
- package/dist/features/shell/templates/bash.render.d.ts +1 -1
- package/dist/features/websearch/templates/web-fetch.render.d.ts +1 -1
- package/dist/index.d.ts +1733 -500
- package/dist/index.js +30 -8
- package/dist/index.js.map +1 -1
- package/dist/{notification-3VEAP7YF.js → notification-NWVOS2WR.js} +3 -3
- package/dist/tools-LDR3LIJP.js +14 -0
- package/dist/tools-LDR3LIJP.js.map +1 -0
- package/dist/{types-DUKIIntb.d.ts → types-CF5UsxD9.d.ts} +3 -0
- package/node_modules/@sliverp/qqbot/LICENSE +21 -0
- package/node_modules/@sliverp/qqbot/README.md +427 -0
- package/node_modules/@sliverp/qqbot/README.standalone.zh.md +77 -0
- package/node_modules/@sliverp/qqbot/README.zh.md +423 -0
- package/node_modules/@sliverp/qqbot/bin/qqbot-cli.js +227 -0
- package/node_modules/@sliverp/qqbot/clawdbot.plugin.json +16 -0
- package/node_modules/@sliverp/qqbot/dist/index.d.ts +20 -0
- package/node_modules/@sliverp/qqbot/dist/index.js +25 -0
- package/node_modules/@sliverp/qqbot/dist/src/agent.d.ts +76 -0
- package/node_modules/@sliverp/qqbot/dist/src/agent.js +36 -0
- package/node_modules/@sliverp/qqbot/dist/src/api.d.ts +138 -0
- package/node_modules/@sliverp/qqbot/dist/src/api.js +523 -0
- package/node_modules/@sliverp/qqbot/dist/src/channel.d.ts +3 -0
- package/node_modules/@sliverp/qqbot/dist/src/channel.js +349 -0
- package/node_modules/@sliverp/qqbot/dist/src/config.d.ts +25 -0
- package/node_modules/@sliverp/qqbot/dist/src/config.js +156 -0
- package/node_modules/@sliverp/qqbot/dist/src/demo-standalone.d.ts +1 -0
- package/node_modules/@sliverp/qqbot/dist/src/demo-standalone.js +125 -0
- package/node_modules/@sliverp/qqbot/dist/src/gateway.d.ts +20 -0
- package/node_modules/@sliverp/qqbot/dist/src/gateway.js +2156 -0
- package/node_modules/@sliverp/qqbot/dist/src/image-server.d.ts +62 -0
- package/node_modules/@sliverp/qqbot/dist/src/image-server.js +401 -0
- package/node_modules/@sliverp/qqbot/dist/src/known-users.d.ts +100 -0
- package/node_modules/@sliverp/qqbot/dist/src/known-users.js +263 -0
- package/node_modules/@sliverp/qqbot/dist/src/onboarding.d.ts +10 -0
- package/node_modules/@sliverp/qqbot/dist/src/onboarding.js +203 -0
- package/node_modules/@sliverp/qqbot/dist/src/openclaw-agent-adapter.d.ts +2 -0
- package/node_modules/@sliverp/qqbot/dist/src/openclaw-agent-adapter.js +155 -0
- package/node_modules/@sliverp/qqbot/dist/src/outbound.d.ts +150 -0
- package/node_modules/@sliverp/qqbot/dist/src/outbound.js +1175 -0
- package/node_modules/@sliverp/qqbot/dist/src/proactive.d.ts +170 -0
- package/node_modules/@sliverp/qqbot/dist/src/proactive.js +399 -0
- package/node_modules/@sliverp/qqbot/dist/src/runtime.d.ts +5 -0
- package/node_modules/@sliverp/qqbot/dist/src/runtime.js +16 -0
- package/node_modules/@sliverp/qqbot/dist/src/session-store.d.ts +52 -0
- package/node_modules/@sliverp/qqbot/dist/src/session-store.js +254 -0
- package/node_modules/@sliverp/qqbot/dist/src/types.d.ts +145 -0
- package/node_modules/@sliverp/qqbot/dist/src/types.js +1 -0
- package/node_modules/@sliverp/qqbot/dist/src/utils/audio-convert.d.ts +73 -0
- package/node_modules/@sliverp/qqbot/dist/src/utils/audio-convert.js +645 -0
- package/node_modules/@sliverp/qqbot/dist/src/utils/file-utils.d.ts +46 -0
- package/node_modules/@sliverp/qqbot/dist/src/utils/file-utils.js +107 -0
- package/node_modules/@sliverp/qqbot/dist/src/utils/image-size.d.ts +51 -0
- package/node_modules/@sliverp/qqbot/dist/src/utils/image-size.js +234 -0
- package/node_modules/@sliverp/qqbot/dist/src/utils/media-tags.d.ts +14 -0
- package/node_modules/@sliverp/qqbot/dist/src/utils/media-tags.js +120 -0
- package/node_modules/@sliverp/qqbot/dist/src/utils/payload.d.ts +112 -0
- package/node_modules/@sliverp/qqbot/dist/src/utils/payload.js +186 -0
- package/node_modules/@sliverp/qqbot/dist/src/utils/platform.d.ts +126 -0
- package/node_modules/@sliverp/qqbot/dist/src/utils/platform.js +358 -0
- package/node_modules/@sliverp/qqbot/dist/src/utils/upload-cache.d.ts +34 -0
- package/node_modules/@sliverp/qqbot/dist/src/utils/upload-cache.js +93 -0
- package/node_modules/@sliverp/qqbot/dist/standalone.d.ts +6 -0
- package/node_modules/@sliverp/qqbot/dist/standalone.js +6 -0
- package/node_modules/@sliverp/qqbot/index.ts +30 -0
- package/node_modules/@sliverp/qqbot/moltbot.plugin.json +16 -0
- package/node_modules/@sliverp/qqbot/node_modules/@eshaz/web-worker/LICENSE +201 -0
- package/node_modules/@sliverp/qqbot/node_modules/@eshaz/web-worker/README.md +134 -0
- package/node_modules/@sliverp/qqbot/node_modules/@eshaz/web-worker/browser.js +17 -0
- package/node_modules/@sliverp/qqbot/node_modules/@eshaz/web-worker/cjs/browser.js +16 -0
- package/node_modules/@sliverp/qqbot/node_modules/@eshaz/web-worker/cjs/node.js +219 -0
- package/node_modules/@sliverp/qqbot/node_modules/@eshaz/web-worker/index.d.ts +4 -0
- package/node_modules/@sliverp/qqbot/node_modules/@eshaz/web-worker/node.js +223 -0
- package/node_modules/@sliverp/qqbot/node_modules/@eshaz/web-worker/package.json +54 -0
- package/node_modules/@sliverp/qqbot/node_modules/@wasm-audio-decoders/common/index.js +5 -0
- package/node_modules/@sliverp/qqbot/node_modules/@wasm-audio-decoders/common/package.json +36 -0
- package/node_modules/@sliverp/qqbot/node_modules/@wasm-audio-decoders/common/src/WASMAudioDecoderCommon.js +231 -0
- package/node_modules/@sliverp/qqbot/node_modules/@wasm-audio-decoders/common/src/WASMAudioDecoderWorker.js +129 -0
- package/node_modules/@sliverp/qqbot/node_modules/@wasm-audio-decoders/common/src/puff/README +67 -0
- package/node_modules/@sliverp/qqbot/node_modules/@wasm-audio-decoders/common/src/puff/build_puff.js +31 -0
- package/node_modules/@sliverp/qqbot/node_modules/@wasm-audio-decoders/common/src/puff/puff.c +863 -0
- package/node_modules/@sliverp/qqbot/node_modules/@wasm-audio-decoders/common/src/puff/puff.h +35 -0
- package/node_modules/@sliverp/qqbot/node_modules/@wasm-audio-decoders/common/src/utilities.js +3 -0
- package/node_modules/@sliverp/qqbot/node_modules/@wasm-audio-decoders/common/types.d.ts +7 -0
- package/node_modules/@sliverp/qqbot/node_modules/mpg123-decoder/README.md +265 -0
- package/node_modules/@sliverp/qqbot/node_modules/mpg123-decoder/dist/mpg123-decoder.min.js +185 -0
- package/node_modules/@sliverp/qqbot/node_modules/mpg123-decoder/dist/mpg123-decoder.min.js.map +1 -0
- package/node_modules/@sliverp/qqbot/node_modules/mpg123-decoder/index.js +8 -0
- package/node_modules/@sliverp/qqbot/node_modules/mpg123-decoder/package.json +58 -0
- package/node_modules/@sliverp/qqbot/node_modules/mpg123-decoder/src/EmscriptenWasm.js +464 -0
- package/node_modules/@sliverp/qqbot/node_modules/mpg123-decoder/src/MPEGDecoder.js +200 -0
- package/node_modules/@sliverp/qqbot/node_modules/mpg123-decoder/src/MPEGDecoderWebWorker.js +21 -0
- package/node_modules/@sliverp/qqbot/node_modules/mpg123-decoder/types.d.ts +30 -0
- package/node_modules/@sliverp/qqbot/node_modules/silk-wasm/LICENSE +21 -0
- package/node_modules/@sliverp/qqbot/node_modules/silk-wasm/README.md +85 -0
- package/node_modules/@sliverp/qqbot/node_modules/silk-wasm/lib/index.cjs +16 -0
- package/node_modules/@sliverp/qqbot/node_modules/silk-wasm/lib/index.d.ts +70 -0
- package/node_modules/@sliverp/qqbot/node_modules/silk-wasm/lib/index.mjs +16 -0
- package/node_modules/@sliverp/qqbot/node_modules/silk-wasm/lib/silk.wasm +0 -0
- package/node_modules/@sliverp/qqbot/node_modules/silk-wasm/lib/utils.d.ts +4 -0
- package/node_modules/@sliverp/qqbot/node_modules/silk-wasm/package.json +39 -0
- package/node_modules/@sliverp/qqbot/node_modules/simple-yenc/.github/FUNDING.yml +1 -0
- package/node_modules/@sliverp/qqbot/node_modules/simple-yenc/.prettierignore +1 -0
- package/node_modules/@sliverp/qqbot/node_modules/simple-yenc/LICENSE +7 -0
- package/node_modules/@sliverp/qqbot/node_modules/simple-yenc/README.md +163 -0
- package/node_modules/@sliverp/qqbot/node_modules/simple-yenc/dist/esm.js +1 -0
- package/node_modules/@sliverp/qqbot/node_modules/simple-yenc/dist/index.js +1 -0
- package/node_modules/@sliverp/qqbot/node_modules/simple-yenc/package.json +50 -0
- package/node_modules/@sliverp/qqbot/node_modules/simple-yenc/rollup.config.js +27 -0
- package/node_modules/@sliverp/qqbot/node_modules/simple-yenc/src/simple-yenc.js +302 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/LICENSE +20 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/README.md +548 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/browser.js +8 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/index.js +13 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/lib/buffer-util.js +131 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/lib/constants.js +19 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/lib/event-target.js +292 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/lib/extension.js +203 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/lib/limiter.js +55 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/lib/permessage-deflate.js +528 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/lib/receiver.js +706 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/lib/sender.js +602 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/lib/stream.js +161 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/lib/subprotocol.js +62 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/lib/validation.js +152 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/lib/websocket-server.js +554 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/lib/websocket.js +1393 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/package.json +69 -0
- package/node_modules/@sliverp/qqbot/node_modules/ws/wrapper.mjs +8 -0
- package/node_modules/@sliverp/qqbot/openclaw.plugin.json +16 -0
- package/node_modules/@sliverp/qqbot/package.json +81 -0
- package/node_modules/@sliverp/qqbot/skills/qqbot-cron/SKILL.md +513 -0
- package/node_modules/@sliverp/qqbot/skills/qqbot-media/SKILL.md +194 -0
- package/node_modules/@sliverp/qqbot/src/agent.ts +133 -0
- package/node_modules/@sliverp/qqbot/src/api.ts +704 -0
- package/node_modules/@sliverp/qqbot/src/channel.ts +380 -0
- package/node_modules/@sliverp/qqbot/src/config.ts +182 -0
- package/node_modules/@sliverp/qqbot/src/demo-standalone.ts +144 -0
- package/node_modules/@sliverp/qqbot/src/gateway.ts +2285 -0
- package/node_modules/@sliverp/qqbot/src/image-server.ts +474 -0
- package/node_modules/@sliverp/qqbot/src/known-users.ts +353 -0
- package/node_modules/@sliverp/qqbot/src/onboarding.ts +274 -0
- package/node_modules/@sliverp/qqbot/src/openclaw-agent-adapter.ts +168 -0
- package/node_modules/@sliverp/qqbot/src/openclaw-plugin-sdk.d.ts +483 -0
- package/node_modules/@sliverp/qqbot/src/outbound.ts +1301 -0
- package/node_modules/@sliverp/qqbot/src/proactive.ts +530 -0
- package/node_modules/@sliverp/qqbot/src/runtime.ts +22 -0
- package/node_modules/@sliverp/qqbot/src/session-store.ts +303 -0
- package/node_modules/@sliverp/qqbot/src/types.ts +153 -0
- package/node_modules/@sliverp/qqbot/src/utils/audio-convert.ts +738 -0
- package/node_modules/@sliverp/qqbot/src/utils/file-utils.ts +122 -0
- package/node_modules/@sliverp/qqbot/src/utils/image-size.ts +266 -0
- package/node_modules/@sliverp/qqbot/src/utils/media-tags.ts +134 -0
- package/node_modules/@sliverp/qqbot/src/utils/payload.ts +265 -0
- package/node_modules/@sliverp/qqbot/src/utils/platform.ts +404 -0
- package/node_modules/@sliverp/qqbot/src/utils/upload-cache.ts +128 -0
- package/node_modules/@sliverp/qqbot/standalone.ts +6 -0
- package/node_modules/@sliverp/qqbot/tsconfig.json +16 -0
- package/package.json +9 -1
- package/dist/BasicAgent-QWEYCLV5.js +0 -12
- package/dist/ExplorerAgent-4IT22VB7.js +0 -12
- package/dist/chunk-3BPSNNK3.js.map +0 -1
- package/dist/chunk-LLV3W326.js.map +0 -1
- package/dist/chunk-LQTEETML.js.map +0 -1
- package/dist/chunk-OBOU27DM.js.map +0 -1
- package/dist/chunk-TSASFMRF.js.map +0 -1
- /package/dist/{BasicAgent-QWEYCLV5.js.map → BasicAgent-UWXLSZP2.js.map} +0 -0
- /package/dist/{ExplorerAgent-4IT22VB7.js.map → ExplorerAgent-LCM3JQS4.js.map} +0 -0
- /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,
|
|
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-
|
|
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
|
-
*
|
|
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
|
-
|
|
513
|
-
agentId: string;
|
|
514
|
-
config: AgentConfig;
|
|
515
|
-
}
|
|
705
|
+
|
|
516
706
|
/**
|
|
517
|
-
*
|
|
518
|
-
*
|
|
519
|
-
* 第一阶段只支持显式白名单状态:
|
|
520
|
-
* - Feature 自己决定要保存什么
|
|
521
|
-
* - 未声明的状态一律不保证恢复
|
|
707
|
+
* 渲染配置扩展类型
|
|
708
|
+
* 支持字符串(模板名称)或配置对象
|
|
522
709
|
*/
|
|
523
|
-
type
|
|
710
|
+
type ToolRenderInput = ToolRenderConfig | string;
|
|
524
711
|
/**
|
|
525
|
-
*
|
|
712
|
+
* 创建一个工具
|
|
713
|
+
* @param config 工具配置
|
|
714
|
+
* @param sourceFile 可选:调用此函数的源文件路径(用于自动查找渲染文件)
|
|
526
715
|
*/
|
|
527
|
-
|
|
528
|
-
/** 包名,如 '@agentdev/shell-feature' 或 'agentdev' */
|
|
716
|
+
declare function createTool(config: {
|
|
529
717
|
name: string;
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
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
|
-
*
|
|
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
|
|
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
|
-
*
|
|
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,6 +1179,10 @@ 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
|
*/
|
|
@@ -1538,91 +1564,269 @@ declare class MCPFeature implements AgentFeature {
|
|
|
1538
1564
|
}
|
|
1539
1565
|
|
|
1540
1566
|
/**
|
|
1541
|
-
*
|
|
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 工具
|
|
1567
|
+
* Audit Feature - 安全审计功能模块
|
|
1564
1568
|
*
|
|
1565
|
-
*
|
|
1569
|
+
* 使用本地大模型(OpenAI 兼容 API)审计 bash 命令安全性
|
|
1570
|
+
* 在工具执行前进行安全检查,拦截危险命令
|
|
1566
1571
|
*
|
|
1567
1572
|
* @example
|
|
1568
1573
|
* ```typescript
|
|
1569
|
-
*
|
|
1570
|
-
* agent.use(new
|
|
1571
|
-
*
|
|
1572
|
-
* // 使用自定义路径
|
|
1573
|
-
* agent.use(new SkillFeature('./custom/skills'));
|
|
1574
|
-
* agent.use(new SkillFeature({ dir: './custom/skills' }));
|
|
1574
|
+
* import { AuditFeature } from './features/index.js';
|
|
1575
|
+
* const agent = new Agent({ ... }).use(new AuditFeature());
|
|
1575
1576
|
* ```
|
|
1576
1577
|
*/
|
|
1577
1578
|
|
|
1578
1579
|
/**
|
|
1579
|
-
*
|
|
1580
|
+
* AuditFeature 配置
|
|
1580
1581
|
*/
|
|
1581
|
-
interface
|
|
1582
|
-
/**
|
|
1583
|
-
|
|
1582
|
+
interface AuditFeatureConfig {
|
|
1583
|
+
/** LLM 服务地址(默认 localhost:7575) */
|
|
1584
|
+
baseUrl?: string;
|
|
1585
|
+
/** 审计模型名称(默认 Qwen3.5-4B-Q5_K_M) */
|
|
1586
|
+
model?: string;
|
|
1587
|
+
/** 是否启用审计(默认 true) */
|
|
1588
|
+
enabled?: boolean;
|
|
1589
|
+
/** 是否启用数据库缓存(默认 true) */
|
|
1590
|
+
enableCache?: boolean;
|
|
1591
|
+
/** 数据库文件路径(默认 .agentdev/audit/audit.db) */
|
|
1592
|
+
dbPath?: string;
|
|
1593
|
+
/** 缓存有效期(天数,0 表示永久,默认 0) */
|
|
1594
|
+
cacheTtlDays?: number;
|
|
1584
1595
|
}
|
|
1585
1596
|
/**
|
|
1586
|
-
*
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
/**
|
|
1590
|
-
* Skill Feature 实现
|
|
1597
|
+
* AuditFeature 实现
|
|
1598
|
+
*
|
|
1599
|
+
* 在工具执行前进行安全审计,拦截危险的 bash 命令
|
|
1591
1600
|
*/
|
|
1592
|
-
declare class
|
|
1593
|
-
readonly name = "
|
|
1601
|
+
declare class AuditFeature implements AgentFeature {
|
|
1602
|
+
readonly name = "audit";
|
|
1594
1603
|
readonly dependencies: string[];
|
|
1595
1604
|
readonly source: string;
|
|
1596
|
-
readonly description = "\
|
|
1597
|
-
private
|
|
1598
|
-
private
|
|
1605
|
+
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";
|
|
1606
|
+
private config;
|
|
1607
|
+
private client;
|
|
1608
|
+
private db?;
|
|
1609
|
+
private dbPath;
|
|
1610
|
+
private logger;
|
|
1611
|
+
constructor(config?: AuditFeatureConfig);
|
|
1612
|
+
getTools(): Tool[];
|
|
1613
|
+
onInitiate(ctx: FeatureInitContext): Promise<void>;
|
|
1614
|
+
onDestroy(_ctx: FeatureContext): Promise<void>;
|
|
1615
|
+
getHookDescription(lifecycle: string, methodName: string): string | undefined;
|
|
1599
1616
|
/**
|
|
1600
|
-
*
|
|
1617
|
+
* 工具使用前审计
|
|
1618
|
+
*
|
|
1619
|
+
* 触发时机:每次工具执行前
|
|
1620
|
+
* 处理逻辑:
|
|
1621
|
+
* 1. 检查是否是 bash 工具调用
|
|
1622
|
+
* 2. 调用 LLM 审计命令安全性
|
|
1623
|
+
* 3. 恶意则拒绝执行,安全则允许
|
|
1601
1624
|
*/
|
|
1602
|
-
|
|
1625
|
+
auditBashCommand(ctx: ToolContext): Promise<DecisionResult>;
|
|
1603
1626
|
/**
|
|
1604
|
-
*
|
|
1627
|
+
* 调用 LLM(OpenAI 兼容 API)审计命令
|
|
1605
1628
|
*/
|
|
1606
|
-
|
|
1629
|
+
private auditCommand;
|
|
1607
1630
|
/**
|
|
1608
|
-
*
|
|
1631
|
+
* 格式化审计结果消息
|
|
1609
1632
|
*/
|
|
1610
|
-
|
|
1611
|
-
constructor(input?: SkillFeatureInput);
|
|
1633
|
+
private formatAuditMessage;
|
|
1612
1634
|
/**
|
|
1613
|
-
*
|
|
1635
|
+
* 初始化数据库
|
|
1636
|
+
*
|
|
1637
|
+
* - 创建数据库目录(如果不存在)
|
|
1638
|
+
* - 打开数据库连接
|
|
1639
|
+
* - 创建表结构(如果不存在)
|
|
1640
|
+
* - 创建索引(如果不存在)
|
|
1614
1641
|
*/
|
|
1615
|
-
|
|
1642
|
+
private initDatabase;
|
|
1616
1643
|
/**
|
|
1617
|
-
*
|
|
1618
|
-
*
|
|
1644
|
+
* 查询缓存的审计结果
|
|
1645
|
+
*
|
|
1646
|
+
* @param command - 要审计的命令
|
|
1647
|
+
* @returns 缓存的审计结果,如果不存在则返回 null
|
|
1619
1648
|
*/
|
|
1620
|
-
|
|
1649
|
+
private getCachedAuditResult;
|
|
1621
1650
|
/**
|
|
1622
|
-
*
|
|
1623
|
-
*
|
|
1651
|
+
* 保存审计结果到数据库
|
|
1652
|
+
*
|
|
1653
|
+
* @param command - 被审计的命令
|
|
1654
|
+
* @param result - 审计结果
|
|
1624
1655
|
*/
|
|
1625
|
-
|
|
1656
|
+
private saveAuditResult;
|
|
1657
|
+
/**
|
|
1658
|
+
* 清理过期的缓存记录
|
|
1659
|
+
*
|
|
1660
|
+
* 根据 cacheTtlDays 配置,删除超过有效期的记录
|
|
1661
|
+
*/
|
|
1662
|
+
private cleanExpiredCache;
|
|
1663
|
+
}
|
|
1664
|
+
|
|
1665
|
+
interface AudioFeedbackConfig {
|
|
1666
|
+
/** 音频文件路径(相对于 feature 目录或绝对路径) */
|
|
1667
|
+
audioPath?: string;
|
|
1668
|
+
/** 是否启用音频反馈(默认:true) */
|
|
1669
|
+
enabled?: boolean;
|
|
1670
|
+
/** 音量(0-1,默认:0.5) */
|
|
1671
|
+
volume?: number;
|
|
1672
|
+
}
|
|
1673
|
+
|
|
1674
|
+
/**
|
|
1675
|
+
* Audio Feedback Feature
|
|
1676
|
+
*
|
|
1677
|
+
* 在每次 call 完成时播放音频反馈,提供愉悦的交互体验
|
|
1678
|
+
*/
|
|
1679
|
+
declare class AudioFeedbackFeature implements AgentFeature {
|
|
1680
|
+
readonly name = "audio-feedback";
|
|
1681
|
+
readonly dependencies: string[];
|
|
1682
|
+
readonly source: string;
|
|
1683
|
+
readonly description = "\u5728 call \u5B8C\u6210\u65F6\u64AD\u653E\u97F3\u9891\u53CD\u9988\uFF0C\u63D0\u4F9B\u6109\u60A6\u7684\u4EA4\u4E92\u4F53\u9A8C\u3002";
|
|
1684
|
+
private readonly config;
|
|
1685
|
+
private readonly runtime;
|
|
1686
|
+
private logger?;
|
|
1687
|
+
constructor(config?: AudioFeedbackConfig);
|
|
1688
|
+
/**
|
|
1689
|
+
* 公开 API:启用或禁用音频反馈
|
|
1690
|
+
*/
|
|
1691
|
+
setEnabled(enabled: boolean): void;
|
|
1692
|
+
isEnabled(): boolean;
|
|
1693
|
+
/**
|
|
1694
|
+
* 公开 API:设置音量
|
|
1695
|
+
*/
|
|
1696
|
+
setVolume(volume: number): void;
|
|
1697
|
+
getPlayCount(): number;
|
|
1698
|
+
onInitiate(ctx: FeatureInitContext): Promise<void>;
|
|
1699
|
+
onDestroy(_ctx: FeatureContext): Promise<void>;
|
|
1700
|
+
captureState(): FeatureStateSnapshot;
|
|
1701
|
+
restoreState(snapshot: FeatureStateSnapshot): void;
|
|
1702
|
+
/**
|
|
1703
|
+
* 核心功能:在 call 完成时播放音频
|
|
1704
|
+
*/
|
|
1705
|
+
playAudioOnCallFinish(ctx: CallFinishContext): Promise<void>;
|
|
1706
|
+
}
|
|
1707
|
+
|
|
1708
|
+
interface MemoryFeatureConfig {
|
|
1709
|
+
/** CLAUDE.md 文件名,默认 'CLAUDE.md' */
|
|
1710
|
+
filename?: string;
|
|
1711
|
+
/** 是否强制注入,即使文件不存在也记录日志 */
|
|
1712
|
+
forceInject?: boolean;
|
|
1713
|
+
/** 读取 CLAUDE.md 的工作目录 */
|
|
1714
|
+
workspaceDir?: string;
|
|
1715
|
+
}
|
|
1716
|
+
declare class MemoryFeature implements AgentFeature {
|
|
1717
|
+
readonly name = "memory";
|
|
1718
|
+
readonly dependencies: string[];
|
|
1719
|
+
readonly source: string;
|
|
1720
|
+
readonly description = "\u81EA\u52A8\u8BFB\u53D6\u5E76\u6CE8\u5165\u9879\u76EE CLAUDE.md \u6587\u4EF6\u4F5C\u4E3A\u7CFB\u7EDF\u63D0\u793A\u8BCD\u3002";
|
|
1721
|
+
private filename;
|
|
1722
|
+
private workspaceDir;
|
|
1723
|
+
private _packageInfo;
|
|
1724
|
+
constructor(config?: MemoryFeatureConfig);
|
|
1725
|
+
/**
|
|
1726
|
+
* 获取包信息(统一打包方案)
|
|
1727
|
+
*/
|
|
1728
|
+
getPackageInfo(): PackageInfo | null;
|
|
1729
|
+
/**
|
|
1730
|
+
* 获取模板名称列表(统一打包方案)
|
|
1731
|
+
* 此 Feature 没有模板,返回空数组
|
|
1732
|
+
*/
|
|
1733
|
+
getTemplateNames(): string[];
|
|
1734
|
+
/**
|
|
1735
|
+
* CallStart 钩子:仅在首次对话开始时注入 CLAUDE.md 内容
|
|
1736
|
+
*/
|
|
1737
|
+
injectCLAUDEContent(ctx: CallStartContext): Promise<void>;
|
|
1738
|
+
/**
|
|
1739
|
+
* 获取钩子描述(用于调试器)
|
|
1740
|
+
*/
|
|
1741
|
+
getHookDescription(lifecycle: string, methodName: string): string | undefined;
|
|
1742
|
+
}
|
|
1743
|
+
|
|
1744
|
+
/**
|
|
1745
|
+
* Agent Skills 类型定义
|
|
1746
|
+
*/
|
|
1747
|
+
/**
|
|
1748
|
+
* Skill 元数据
|
|
1749
|
+
*/
|
|
1750
|
+
interface SkillMetadata {
|
|
1751
|
+
/** Skill 名称 */
|
|
1752
|
+
name: string;
|
|
1753
|
+
/** Skill 描述 */
|
|
1754
|
+
description: string;
|
|
1755
|
+
/** SKILL.md 完整路径 */
|
|
1756
|
+
path: string;
|
|
1757
|
+
}
|
|
1758
|
+
/**
|
|
1759
|
+
* Skills 加载器配置
|
|
1760
|
+
*/
|
|
1761
|
+
interface SkillsOptions {
|
|
1762
|
+
/** skills 目录,默认 cwd/.agentdev/skills */
|
|
1763
|
+
dir?: string;
|
|
1764
|
+
}
|
|
1765
|
+
|
|
1766
|
+
/**
|
|
1767
|
+
* Skill Feature - Skills 发现和 invoke_skill 工具
|
|
1768
|
+
*
|
|
1769
|
+
* 将 Skills 集成从 Agent 核心中解耦,实现可外挂功能
|
|
1770
|
+
*
|
|
1771
|
+
* @example
|
|
1772
|
+
* ```typescript
|
|
1773
|
+
* // 使用默认路径 .agentdev/skills
|
|
1774
|
+
* agent.use(new SkillFeature());
|
|
1775
|
+
*
|
|
1776
|
+
* // 使用自定义路径
|
|
1777
|
+
* agent.use(new SkillFeature('./custom/skills'));
|
|
1778
|
+
* agent.use(new SkillFeature({ dir: './custom/skills' }));
|
|
1779
|
+
* ```
|
|
1780
|
+
*/
|
|
1781
|
+
|
|
1782
|
+
/**
|
|
1783
|
+
* Skill Feature 配置类型
|
|
1784
|
+
*/
|
|
1785
|
+
interface SkillFeatureConfig extends SkillsOptions {
|
|
1786
|
+
/** Skills 目录路径 */
|
|
1787
|
+
dir?: string;
|
|
1788
|
+
}
|
|
1789
|
+
/**
|
|
1790
|
+
* Skill Feature 输入类型
|
|
1791
|
+
*/
|
|
1792
|
+
type SkillFeatureInput = SkillFeatureConfig | string | undefined;
|
|
1793
|
+
/**
|
|
1794
|
+
* Skill Feature 实现
|
|
1795
|
+
*/
|
|
1796
|
+
declare class SkillFeature implements AgentFeature {
|
|
1797
|
+
readonly name = "skill";
|
|
1798
|
+
readonly dependencies: string[];
|
|
1799
|
+
readonly source: string;
|
|
1800
|
+
readonly description = "\u53D1\u73B0\u672C\u5730 skills\uFF0C\u5E76\u63D0\u4F9B invoke_skill \u5DE5\u5177\u4E0E\u6280\u80FD\u6570\u636E\u6E90\u3002";
|
|
1801
|
+
private skillsDir?;
|
|
1802
|
+
private skills;
|
|
1803
|
+
/**
|
|
1804
|
+
* 缓存包信息
|
|
1805
|
+
*/
|
|
1806
|
+
private _packageInfo;
|
|
1807
|
+
/**
|
|
1808
|
+
* 获取包信息(统一打包方案)
|
|
1809
|
+
*/
|
|
1810
|
+
getPackageInfo(): PackageInfo | null;
|
|
1811
|
+
/**
|
|
1812
|
+
* 获取模板名称列表(统一打包方案)
|
|
1813
|
+
*/
|
|
1814
|
+
getTemplateNames(): string[];
|
|
1815
|
+
constructor(input?: SkillFeatureInput);
|
|
1816
|
+
/**
|
|
1817
|
+
* 获取同步工具(invoke_skill)
|
|
1818
|
+
*/
|
|
1819
|
+
getTools(): Tool[];
|
|
1820
|
+
/**
|
|
1821
|
+
* 声明上下文注入器
|
|
1822
|
+
* 为 invoke_skill 工具注入 _context.skills
|
|
1823
|
+
*/
|
|
1824
|
+
getContextInjectors(): Map<string | RegExp, ContextInjector>;
|
|
1825
|
+
/**
|
|
1826
|
+
* 初始化钩子
|
|
1827
|
+
* 执行 Skills 发现并注册数据源
|
|
1828
|
+
*/
|
|
1829
|
+
onInitiate(ctx: FeatureInitContext): Promise<void>;
|
|
1626
1830
|
/**
|
|
1627
1831
|
* 获取已加载的 Skills
|
|
1628
1832
|
*/
|
|
@@ -1633,6 +1837,188 @@ declare class SkillFeature implements AgentFeature {
|
|
|
1633
1837
|
setSkillsDir(dir: string): void;
|
|
1634
1838
|
}
|
|
1635
1839
|
|
|
1840
|
+
/**
|
|
1841
|
+
* OpenClaw 兼容层类型定义
|
|
1842
|
+
*/
|
|
1843
|
+
|
|
1844
|
+
/**
|
|
1845
|
+
* 支持的兼容钩子名称
|
|
1846
|
+
*/
|
|
1847
|
+
type CompatHookName = 'before_tool_call' | 'after_tool_call';
|
|
1848
|
+
/**
|
|
1849
|
+
* before_tool_call 钩子上下文
|
|
1850
|
+
*/
|
|
1851
|
+
interface BeforeToolCallContext {
|
|
1852
|
+
/** 工具调用 */
|
|
1853
|
+
call: ToolCall;
|
|
1854
|
+
/** 工具名称 */
|
|
1855
|
+
toolName: string;
|
|
1856
|
+
/** 工具参数 */
|
|
1857
|
+
parameters: Record<string, unknown>;
|
|
1858
|
+
/** 消息历史 */
|
|
1859
|
+
messages: Message[];
|
|
1860
|
+
}
|
|
1861
|
+
/**
|
|
1862
|
+
* before_tool_call 钩子结果
|
|
1863
|
+
*/
|
|
1864
|
+
interface BeforeToolCallResult {
|
|
1865
|
+
/** 是否阻止执行 */
|
|
1866
|
+
block?: boolean;
|
|
1867
|
+
/** 拒绝原因 */
|
|
1868
|
+
denyReason?: string;
|
|
1869
|
+
/** 修改后的参数 */
|
|
1870
|
+
rewrittenParameters?: Record<string, unknown>;
|
|
1871
|
+
}
|
|
1872
|
+
/**
|
|
1873
|
+
* after_tool_call 钩子上下文
|
|
1874
|
+
*/
|
|
1875
|
+
interface AfterToolCallContext {
|
|
1876
|
+
/** 工具调用 */
|
|
1877
|
+
call: ToolCall;
|
|
1878
|
+
/** 工具名称 */
|
|
1879
|
+
toolName: string;
|
|
1880
|
+
/** 执行是否成功 */
|
|
1881
|
+
success: boolean;
|
|
1882
|
+
/** 执行结果 */
|
|
1883
|
+
result: unknown;
|
|
1884
|
+
/** 错误信息 */
|
|
1885
|
+
error?: string;
|
|
1886
|
+
/** 执行耗时(ms) */
|
|
1887
|
+
duration: number;
|
|
1888
|
+
/** 消息历史 */
|
|
1889
|
+
messages: Message[];
|
|
1890
|
+
}
|
|
1891
|
+
/**
|
|
1892
|
+
* 兼容钩子处理器映射
|
|
1893
|
+
*/
|
|
1894
|
+
interface CompatHookHandlerMap {
|
|
1895
|
+
before_tool_call: (ctx: BeforeToolCallContext) => BeforeToolCallResult | Promise<BeforeToolCallResult>;
|
|
1896
|
+
after_tool_call: (ctx: AfterToolCallContext) => void | Promise<void>;
|
|
1897
|
+
}
|
|
1898
|
+
/**
|
|
1899
|
+
* 已注册的兼容钩子
|
|
1900
|
+
*/
|
|
1901
|
+
interface RegisteredCompatHook {
|
|
1902
|
+
/** 插件 ID */
|
|
1903
|
+
pluginId: string;
|
|
1904
|
+
/** 钩子名称 */
|
|
1905
|
+
hookName: CompatHookName;
|
|
1906
|
+
/** 处理器 */
|
|
1907
|
+
handler: CompatHookHandlerMap[CompatHookName];
|
|
1908
|
+
/** 优先级(OpenClaw 规则:数值越大越先执行) */
|
|
1909
|
+
priority: number;
|
|
1910
|
+
}
|
|
1911
|
+
/**
|
|
1912
|
+
* 插件诊断信息
|
|
1913
|
+
*/
|
|
1914
|
+
interface PluginDiagnostics {
|
|
1915
|
+
/** 插件 ID */
|
|
1916
|
+
pluginId: string;
|
|
1917
|
+
/** 插件名称 */
|
|
1918
|
+
name: string;
|
|
1919
|
+
/** 版本 */
|
|
1920
|
+
version: string;
|
|
1921
|
+
/** 源路径 */
|
|
1922
|
+
source: string;
|
|
1923
|
+
/** 注册的工具 */
|
|
1924
|
+
registeredTools: string[];
|
|
1925
|
+
/** 注册的钩子 */
|
|
1926
|
+
registeredHooks: CompatHookName[];
|
|
1927
|
+
/** 不支持的 API 调用记录 */
|
|
1928
|
+
unsupportedApis: string[];
|
|
1929
|
+
/** 错误信息 */
|
|
1930
|
+
errors: string[];
|
|
1931
|
+
}
|
|
1932
|
+
/**
|
|
1933
|
+
* 兼容层诊断报告
|
|
1934
|
+
*/
|
|
1935
|
+
interface CompatDiagnosticsReport {
|
|
1936
|
+
/** 加载的插件列表 */
|
|
1937
|
+
plugins: PluginDiagnostics[];
|
|
1938
|
+
/** 总计注册的工具数 */
|
|
1939
|
+
totalTools: number;
|
|
1940
|
+
/** 总计注册的钩子数 */
|
|
1941
|
+
totalHooks: number;
|
|
1942
|
+
}
|
|
1943
|
+
|
|
1944
|
+
/**
|
|
1945
|
+
* OpenClaw 兼容钩子注册表
|
|
1946
|
+
*
|
|
1947
|
+
* 管理兼容插件的钩子注册和执行
|
|
1948
|
+
* 遵循 OpenClaw 优先级规则:priority 数值越大越先执行
|
|
1949
|
+
*/
|
|
1950
|
+
|
|
1951
|
+
/**
|
|
1952
|
+
* 兼容钩子注册表
|
|
1953
|
+
*/
|
|
1954
|
+
declare class CompatHookRegistry {
|
|
1955
|
+
/** 钩子存储:hookName -> 按优先级排序的钩子列表 */
|
|
1956
|
+
private hooks;
|
|
1957
|
+
/**
|
|
1958
|
+
* 注册钩子
|
|
1959
|
+
*
|
|
1960
|
+
* @param hookName 钩子名称
|
|
1961
|
+
* @param handler 钩子处理器
|
|
1962
|
+
* @param priority 优先级(数值越大越先执行)
|
|
1963
|
+
* @param pluginId 插件 ID
|
|
1964
|
+
*/
|
|
1965
|
+
register<K extends CompatHookName>(hookName: K, handler: CompatHookHandlerMap[K], priority: number, pluginId: string): void;
|
|
1966
|
+
/**
|
|
1967
|
+
* 获取指定钩子的所有处理器(按优先级排序)
|
|
1968
|
+
*
|
|
1969
|
+
* @param hookName 钩子名称
|
|
1970
|
+
* @returns 钩子列表
|
|
1971
|
+
*/
|
|
1972
|
+
get(hookName: CompatHookName): RegisteredCompatHook[];
|
|
1973
|
+
/**
|
|
1974
|
+
* 检查是否有指定钩子
|
|
1975
|
+
*
|
|
1976
|
+
* @param hookName 钩子名称
|
|
1977
|
+
* @returns 是否存在
|
|
1978
|
+
*/
|
|
1979
|
+
has(hookName: CompatHookName): boolean;
|
|
1980
|
+
/**
|
|
1981
|
+
* 执行 before_tool_call 钩子
|
|
1982
|
+
*
|
|
1983
|
+
* 按优先级顺序执行:
|
|
1984
|
+
* - 如果任何钩子返回 block=true,则立即阻止执行
|
|
1985
|
+
* - 多个插件的参数修改会累积合并
|
|
1986
|
+
*
|
|
1987
|
+
* @param context 钩子上下文
|
|
1988
|
+
* @returns 钩子执行结果(如果任何钩子返回 block=true,则阻止执行)
|
|
1989
|
+
*/
|
|
1990
|
+
executeBeforeToolCall(context: BeforeToolCallContext): Promise<BeforeToolCallResult>;
|
|
1991
|
+
/**
|
|
1992
|
+
* 深度合并对象
|
|
1993
|
+
*/
|
|
1994
|
+
private deepMerge;
|
|
1995
|
+
/**
|
|
1996
|
+
* 执行 after_tool_call 钩子
|
|
1997
|
+
*
|
|
1998
|
+
* 按优先级顺序执行所有钩子(void 返回值)
|
|
1999
|
+
*
|
|
2000
|
+
* @param context 钩子上下文
|
|
2001
|
+
*/
|
|
2002
|
+
executeAfterToolCall(context: AfterToolCallContext): Promise<void>;
|
|
2003
|
+
/**
|
|
2004
|
+
* 获取所有已注册的钩子信息
|
|
2005
|
+
*
|
|
2006
|
+
* @returns 钩子信息映射
|
|
2007
|
+
*/
|
|
2008
|
+
getHooksInfo(): Map<CompatHookName, Array<{
|
|
2009
|
+
pluginId: string;
|
|
2010
|
+
priority: number;
|
|
2011
|
+
}>>;
|
|
2012
|
+
/**
|
|
2013
|
+
* 清空所有钩子
|
|
2014
|
+
*/
|
|
2015
|
+
clear(): void;
|
|
2016
|
+
/**
|
|
2017
|
+
* 获取钩子总数
|
|
2018
|
+
*/
|
|
2019
|
+
get size(): number;
|
|
2020
|
+
}
|
|
2021
|
+
|
|
1636
2022
|
/**
|
|
1637
2023
|
* 反向钩子装饰器
|
|
1638
2024
|
*
|
|
@@ -1689,49 +2075,306 @@ declare const ToolUse: (target: any, propertyKey: string, descriptor: PropertyDe
|
|
|
1689
2075
|
declare const ToolFinished: (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
1690
2076
|
|
|
1691
2077
|
/**
|
|
1692
|
-
*
|
|
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
|
-
* 管理父代理创建的所有子代理实例
|
|
2078
|
+
* PluginCompatFeature
|
|
2079
|
+
*
|
|
2080
|
+
* 加载 OpenClaw 风格插件并将它们转换为 AgentDev 能力
|
|
1717
2081
|
*/
|
|
1718
|
-
declare class
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
/**
|
|
1723
|
-
private
|
|
1724
|
-
/**
|
|
1725
|
-
private
|
|
1726
|
-
|
|
2082
|
+
declare class PluginCompatFeature implements AgentFeature {
|
|
2083
|
+
name: string;
|
|
2084
|
+
readonly source: string;
|
|
2085
|
+
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";
|
|
2086
|
+
/** 兼容钩子注册表 */
|
|
2087
|
+
private compatHookRegistry;
|
|
2088
|
+
/** 诊断收集器 */
|
|
2089
|
+
private diagnostics;
|
|
2090
|
+
/** 已加载的插件 */
|
|
2091
|
+
private loadedPlugins;
|
|
2092
|
+
/** Agent 工具注册表(从 FeatureContext 获取) */
|
|
2093
|
+
private agentToolRegistry?;
|
|
2094
|
+
/** Agent ID */
|
|
2095
|
+
private agentId?;
|
|
2096
|
+
/** 插件根目录 */
|
|
2097
|
+
private pluginRoots;
|
|
2098
|
+
/** 是否启用 */
|
|
2099
|
+
private enabled;
|
|
2100
|
+
/** 注册的工具列表(用于 getAsyncTools) */
|
|
2101
|
+
private registeredTools;
|
|
1727
2102
|
/**
|
|
1728
|
-
*
|
|
2103
|
+
* 初始化 Feature
|
|
1729
2104
|
*/
|
|
1730
|
-
|
|
2105
|
+
onInitiate(ctx: FeatureInitContext): Promise<void>;
|
|
1731
2106
|
/**
|
|
1732
|
-
*
|
|
2107
|
+
* 加载所有插件
|
|
1733
2108
|
*/
|
|
1734
|
-
|
|
2109
|
+
private loadPlugins;
|
|
2110
|
+
/**
|
|
2111
|
+
* 加载单个插件
|
|
2112
|
+
*/
|
|
2113
|
+
private loadPlugin;
|
|
2114
|
+
/**
|
|
2115
|
+
* 注册工具
|
|
2116
|
+
*/
|
|
2117
|
+
private registerTool;
|
|
2118
|
+
/**
|
|
2119
|
+
* 获取异步工具列表
|
|
2120
|
+
*/
|
|
2121
|
+
getAsyncTools(): Promise<Tool[]>;
|
|
2122
|
+
/**
|
|
2123
|
+
* 注册钩子
|
|
2124
|
+
*/
|
|
2125
|
+
private registerHook;
|
|
2126
|
+
/**
|
|
2127
|
+
* 调用工具(用于插件运行时)
|
|
2128
|
+
*/
|
|
2129
|
+
private invokeTool;
|
|
2130
|
+
/**
|
|
2131
|
+
* 获取兼容钩子注册表(供内部桥接使用)
|
|
2132
|
+
*/
|
|
2133
|
+
getCompatHookRegistry(): CompatHookRegistry;
|
|
2134
|
+
/**
|
|
2135
|
+
* 获取诊断报告
|
|
2136
|
+
*/
|
|
2137
|
+
getDiagnostics(): CompatDiagnosticsReport;
|
|
2138
|
+
/**
|
|
2139
|
+
* 清理资源
|
|
2140
|
+
*/
|
|
2141
|
+
onDestroy(): Promise<void>;
|
|
2142
|
+
getHookDescription(lifecycle: string, methodName: string): string | undefined;
|
|
2143
|
+
/**
|
|
2144
|
+
* 桥接 before_tool_call 钩子
|
|
2145
|
+
*
|
|
2146
|
+
* 在工具执行前调用兼容插件的 before_tool_call 钩子
|
|
2147
|
+
*/
|
|
2148
|
+
handleBeforeToolCall(ctx: ToolContext): Promise<typeof Decision.Deny | typeof Decision.Continue>;
|
|
2149
|
+
/**
|
|
2150
|
+
* 桥接 after_tool_call 钩子
|
|
2151
|
+
*
|
|
2152
|
+
* 在工具执行后调用兼容插件的 after_tool_call 钩子
|
|
2153
|
+
*/
|
|
2154
|
+
handleAfterToolCall(result: ToolResult): Promise<void>;
|
|
2155
|
+
}
|
|
2156
|
+
|
|
2157
|
+
/**
|
|
2158
|
+
* QQBotFeature - QQ 机器人对话能力
|
|
2159
|
+
*
|
|
2160
|
+
* 功能:
|
|
2161
|
+
* - 通过 WebSocket 连接 QQ Bot Gateway
|
|
2162
|
+
* - 接收 QQ 消息并转发给 Agent 处理
|
|
2163
|
+
* - 自动将 Agent 的响应发送回 QQ
|
|
2164
|
+
*
|
|
2165
|
+
* 使用 `@sliverp/qqbot/standalone` 独立接入
|
|
2166
|
+
*/
|
|
2167
|
+
|
|
2168
|
+
/**
|
|
2169
|
+
* QQ 消息发送选项
|
|
2170
|
+
*/
|
|
2171
|
+
interface QQBotSendOptions {
|
|
2172
|
+
/** 目标 OpenID */
|
|
2173
|
+
to: string;
|
|
2174
|
+
/** 消息内容 */
|
|
2175
|
+
content: string;
|
|
2176
|
+
}
|
|
2177
|
+
/**
|
|
2178
|
+
* QQ 消息发送结果
|
|
2179
|
+
*/
|
|
2180
|
+
interface QQBotSendResult {
|
|
2181
|
+
/** 是否成功 */
|
|
2182
|
+
success: boolean;
|
|
2183
|
+
/** 消息ID */
|
|
2184
|
+
messageId?: string;
|
|
2185
|
+
/** 时间戳 */
|
|
2186
|
+
timestamp?: string | number;
|
|
2187
|
+
/** 错误信息 */
|
|
2188
|
+
error?: string;
|
|
2189
|
+
}
|
|
2190
|
+
/**
|
|
2191
|
+
* 已知用户信息
|
|
2192
|
+
*/
|
|
2193
|
+
interface KnownUser {
|
|
2194
|
+
/** 类型 */
|
|
2195
|
+
type: 'c2c' | 'group' | 'channel';
|
|
2196
|
+
/** OpenID */
|
|
2197
|
+
openid: string;
|
|
2198
|
+
/** 昵称 */
|
|
2199
|
+
nickname?: string;
|
|
2200
|
+
/** 最后交互时间 */
|
|
2201
|
+
lastInteractionAt: number;
|
|
2202
|
+
}
|
|
2203
|
+
/**
|
|
2204
|
+
* QQBot Feature 配置
|
|
2205
|
+
*/
|
|
2206
|
+
interface QQBotFeatureConfig {
|
|
2207
|
+
/** QQ Bot AppID(可选,如果不提供则从配置文件读取) */
|
|
2208
|
+
appId?: string;
|
|
2209
|
+
/** QQ Bot AppSecret(可选,如果不提供则从配置文件读取) */
|
|
2210
|
+
clientSecret?: string;
|
|
2211
|
+
/** 配置文件路径(默认 .agentdev/qqbot.config.json) */
|
|
2212
|
+
configPath?: string;
|
|
2213
|
+
/** 账户 ID(默认 "default") */
|
|
2214
|
+
accountId?: string;
|
|
2215
|
+
/** 是否启用 Markdown 消息(默认 true) */
|
|
2216
|
+
markdownSupport?: boolean;
|
|
2217
|
+
/** 系统提示词 */
|
|
2218
|
+
systemPrompt?: string;
|
|
2219
|
+
/** 附加配置(传递给 Gateway) */
|
|
2220
|
+
cfg?: Record<string, unknown>;
|
|
2221
|
+
}
|
|
2222
|
+
/**
|
|
2223
|
+
* QQBotFeature - QQ 机器人 Feature
|
|
2224
|
+
*
|
|
2225
|
+
* 使用方式:
|
|
2226
|
+
* ```typescript
|
|
2227
|
+
* const qqbotFeature = new QQBotFeature({ appId, clientSecret });
|
|
2228
|
+
* const agent = new BasicAgent({ llm }).use(qqbotFeature);
|
|
2229
|
+
* await agent.withViewer('QQBot', 2026, false);
|
|
2230
|
+
* await qqbotFeature.startGateway(agent);
|
|
2231
|
+
* ```
|
|
2232
|
+
*/
|
|
2233
|
+
declare class QQBotFeature implements AgentFeature {
|
|
2234
|
+
readonly name = "qqbot";
|
|
2235
|
+
readonly dependencies: string[];
|
|
2236
|
+
readonly source: string;
|
|
2237
|
+
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";
|
|
2238
|
+
private config;
|
|
2239
|
+
private agentRef;
|
|
2240
|
+
private processingLock;
|
|
2241
|
+
private gatewayStarted;
|
|
2242
|
+
private abortController;
|
|
2243
|
+
private _packageInfo;
|
|
2244
|
+
constructor(config?: QQBotFeatureConfig);
|
|
2245
|
+
/**
|
|
2246
|
+
* 显式启动 Gateway(在 Agent 初始化后调用)
|
|
2247
|
+
*
|
|
2248
|
+
* @param agent Agent 实例
|
|
2249
|
+
*/
|
|
2250
|
+
startGateway(agent: any): Promise<void>;
|
|
2251
|
+
/**
|
|
2252
|
+
* 创建账户配置
|
|
2253
|
+
*/
|
|
2254
|
+
private createAccount;
|
|
2255
|
+
/**
|
|
2256
|
+
* 获取凭据(从配置文件或直接配置)
|
|
2257
|
+
*/
|
|
2258
|
+
private getCredentials;
|
|
2259
|
+
getTools(): Tool[];
|
|
2260
|
+
/**
|
|
2261
|
+
* 获取包信息(统一打包方案)
|
|
2262
|
+
*/
|
|
2263
|
+
getPackageInfo(): PackageInfo | null;
|
|
2264
|
+
/**
|
|
2265
|
+
* 获取模板名称列表(统一打包方案)
|
|
2266
|
+
* 此 Feature 没有模板,返回空数组
|
|
2267
|
+
*/
|
|
2268
|
+
getTemplateNames(): string[];
|
|
2269
|
+
onInitiate(_ctx: FeatureInitContext): Promise<void>;
|
|
2270
|
+
onDestroy(_ctx: FeatureContext): Promise<void>;
|
|
2271
|
+
}
|
|
2272
|
+
|
|
2273
|
+
/**
|
|
2274
|
+
* Shell Feature 工具定义
|
|
2275
|
+
*
|
|
2276
|
+
* 提供 run_shell_command 工具,通过 Git Bash 执行 Shell 命令
|
|
2277
|
+
*/
|
|
2278
|
+
|
|
2279
|
+
interface ShellExecutionResult {
|
|
2280
|
+
stdout: string;
|
|
2281
|
+
stderr: string;
|
|
2282
|
+
output: string;
|
|
2283
|
+
}
|
|
2284
|
+
|
|
2285
|
+
/**
|
|
2286
|
+
* Shell Feature - Git Bash 命令执行工具 + 安全删除/恢复工具
|
|
2287
|
+
*
|
|
2288
|
+
* 通过 Git Bash 执行 Shell 命令,description 从内部配置加载
|
|
2289
|
+
* 提供安全删除、列表和恢复功能
|
|
2290
|
+
*
|
|
2291
|
+
* @example
|
|
2292
|
+
* ```typescript
|
|
2293
|
+
* import { ShellFeature } from './features/index.js';
|
|
2294
|
+
* const agent = new Agent({ ... }).use(new ShellFeature());
|
|
2295
|
+
* ```
|
|
2296
|
+
*/
|
|
2297
|
+
|
|
2298
|
+
interface ShellFeatureConfig {
|
|
2299
|
+
workspaceDir?: string;
|
|
2300
|
+
resourceRoot?: string;
|
|
2301
|
+
}
|
|
2302
|
+
/**
|
|
2303
|
+
* Shell Feature 实现
|
|
2304
|
+
*/
|
|
2305
|
+
declare class ShellFeature implements AgentFeature {
|
|
2306
|
+
readonly name = "shell";
|
|
2307
|
+
readonly dependencies: string[];
|
|
2308
|
+
readonly source: string;
|
|
2309
|
+
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";
|
|
2310
|
+
private bashDescription?;
|
|
2311
|
+
private _packageInfo;
|
|
2312
|
+
private readonly workspaceDir;
|
|
2313
|
+
private readonly resourceRoot;
|
|
2314
|
+
constructor(config?: ShellFeatureConfig);
|
|
2315
|
+
run(command: string): Promise<ShellExecutionResult>;
|
|
2316
|
+
/**
|
|
2317
|
+
* 获取包信息(统一打包方案)
|
|
2318
|
+
*/
|
|
2319
|
+
getPackageInfo(): PackageInfo | null;
|
|
2320
|
+
/**
|
|
2321
|
+
* 获取模板名称列表(统一打包方案)
|
|
2322
|
+
*/
|
|
2323
|
+
getTemplateNames(): string[];
|
|
2324
|
+
/**
|
|
2325
|
+
* 获取同步工具(垃圾桶工具)
|
|
2326
|
+
*/
|
|
2327
|
+
getTools(): Tool[];
|
|
2328
|
+
/**
|
|
2329
|
+
* 获取异步工具(bash 工具,加载 description)
|
|
2330
|
+
*/
|
|
2331
|
+
getAsyncTools(_ctx: FeatureInitContext): Promise<Tool[]>;
|
|
2332
|
+
}
|
|
2333
|
+
|
|
2334
|
+
/**
|
|
2335
|
+
* AgentPool - 子代理管理核心
|
|
2336
|
+
* 管理父代理创建的所有子代理实例
|
|
2337
|
+
*/
|
|
2338
|
+
|
|
2339
|
+
/**
|
|
2340
|
+
* 子代理实例信息
|
|
2341
|
+
*/
|
|
2342
|
+
interface SubAgentInstance {
|
|
2343
|
+
id: string;
|
|
2344
|
+
type: string;
|
|
2345
|
+
agent: AgentBase;
|
|
2346
|
+
status: SubAgentStatus;
|
|
2347
|
+
initialInstruction: string;
|
|
2348
|
+
createdAt: number;
|
|
2349
|
+
completedAt?: number;
|
|
2350
|
+
result?: string;
|
|
2351
|
+
error?: string;
|
|
2352
|
+
}
|
|
2353
|
+
/**
|
|
2354
|
+
* Agent 创建函数类型(异步)
|
|
2355
|
+
*/
|
|
2356
|
+
type AgentFactory = (type: string) => AgentBase | Promise<AgentBase>;
|
|
2357
|
+
/**
|
|
2358
|
+
* AgentPool - 子代理管理核心
|
|
2359
|
+
* 管理父代理创建的所有子代理实例
|
|
2360
|
+
*/
|
|
2361
|
+
declare class AgentPool {
|
|
2362
|
+
private _instances;
|
|
2363
|
+
private _counters;
|
|
2364
|
+
private _parent;
|
|
2365
|
+
/** 待回传消息队列:agentId -> messages[] */
|
|
2366
|
+
private _pendingMessages;
|
|
2367
|
+
/** 消息就绪解析器:key -> resolver function */
|
|
2368
|
+
private _messageResolvers;
|
|
2369
|
+
constructor(parent: AgentBase);
|
|
2370
|
+
/**
|
|
2371
|
+
* 创建子代理(不自动执行,等待 sendTo 激活)
|
|
2372
|
+
*/
|
|
2373
|
+
spawn(type: string, createAgentFn: AgentFactory): Promise<string>;
|
|
2374
|
+
/**
|
|
2375
|
+
* 获取实例信息
|
|
2376
|
+
*/
|
|
2377
|
+
get(id: string): SubAgentInstance | undefined;
|
|
1735
2378
|
/**
|
|
1736
2379
|
* 列出所有实例
|
|
1737
2380
|
*/
|
|
@@ -2048,58 +2691,792 @@ declare class TodoFeature implements AgentFeature {
|
|
|
2048
2691
|
}
|
|
2049
2692
|
|
|
2050
2693
|
/**
|
|
2051
|
-
*
|
|
2694
|
+
* TTS Feature 类型定义
|
|
2695
|
+
*/
|
|
2696
|
+
/**
|
|
2697
|
+
* TTS Feature 配置选项
|
|
2698
|
+
*/
|
|
2699
|
+
interface TTSFeatureConfig {
|
|
2700
|
+
/**
|
|
2701
|
+
* Python 可执行文件路径
|
|
2702
|
+
* 默认:项目 .venv 中的 Python 或系统 PATH 中的 python
|
|
2703
|
+
*/
|
|
2704
|
+
pythonPath?: string;
|
|
2705
|
+
/**
|
|
2706
|
+
* Python 额外参数(如 uv run)
|
|
2707
|
+
* 例如:['run', '--with', 'kokoro', '--with', 'soundfile']
|
|
2708
|
+
*/
|
|
2709
|
+
pythonArgs?: string[];
|
|
2710
|
+
/**
|
|
2711
|
+
* 是否在初始化时检查 Python 环境
|
|
2712
|
+
* 默认:true
|
|
2713
|
+
*/
|
|
2714
|
+
checkPythonEnv?: boolean;
|
|
2715
|
+
/**
|
|
2716
|
+
* TTS 模型配置
|
|
2717
|
+
*/
|
|
2718
|
+
model?: {
|
|
2719
|
+
/**
|
|
2720
|
+
* 默认声音 ID
|
|
2721
|
+
* 中文常用:zf_xiaobei, zf_xiaoxiao, zf_xiaomei
|
|
2722
|
+
* 英文常用:af_bella, af_heart
|
|
2723
|
+
* 默认:zf_xiaobei
|
|
2724
|
+
*/
|
|
2725
|
+
voice?: string;
|
|
2726
|
+
/**
|
|
2727
|
+
* 语言代码
|
|
2728
|
+
* 'zh'(中文优先) 或 'a'/'en'(英文优先)
|
|
2729
|
+
* 默认:zh
|
|
2730
|
+
*/
|
|
2731
|
+
lang?: string;
|
|
2732
|
+
/**
|
|
2733
|
+
* 语速倍率
|
|
2734
|
+
* 0.8~1.5 之间合理
|
|
2735
|
+
* 默认:1.0
|
|
2736
|
+
*/
|
|
2737
|
+
speed?: number;
|
|
2738
|
+
};
|
|
2739
|
+
/**
|
|
2740
|
+
* 音频输出配置
|
|
2741
|
+
*/
|
|
2742
|
+
output?: {
|
|
2743
|
+
/**
|
|
2744
|
+
* 输出目录
|
|
2745
|
+
* 默认:.agentdev/tts
|
|
2746
|
+
*/
|
|
2747
|
+
outputDir?: string;
|
|
2748
|
+
/**
|
|
2749
|
+
* 是否自动播放生成的音频
|
|
2750
|
+
* 默认:true
|
|
2751
|
+
*/
|
|
2752
|
+
autoPlay?: boolean;
|
|
2753
|
+
};
|
|
2754
|
+
/**
|
|
2755
|
+
* TTS 触发条件
|
|
2756
|
+
*/
|
|
2757
|
+
triggers?: {
|
|
2758
|
+
/**
|
|
2759
|
+
* 是否启用自动朗读(非工具调用轮)
|
|
2760
|
+
* 默认:true
|
|
2761
|
+
*/
|
|
2762
|
+
autoEnabled?: boolean;
|
|
2763
|
+
/**
|
|
2764
|
+
* 最小文本长度(字符数)
|
|
2765
|
+
* 短于此长度的文本不会朗读
|
|
2766
|
+
* 默认:10
|
|
2767
|
+
*/
|
|
2768
|
+
minLength?: number;
|
|
2769
|
+
/**
|
|
2770
|
+
* 最大文本长度(字符数)
|
|
2771
|
+
* 长于此长度的文本会被截断
|
|
2772
|
+
* 默认:1000
|
|
2773
|
+
*/
|
|
2774
|
+
maxLength?: number;
|
|
2775
|
+
/**
|
|
2776
|
+
* 是否只在非结束轮触发
|
|
2777
|
+
* true: 只在没有工具调用时朗读
|
|
2778
|
+
* false: 所有响应都朗读
|
|
2779
|
+
* 默认:true
|
|
2780
|
+
*/
|
|
2781
|
+
onlyOnNonToolCalls?: boolean;
|
|
2782
|
+
};
|
|
2783
|
+
}
|
|
2784
|
+
/**
|
|
2785
|
+
* TTS 生成结果
|
|
2786
|
+
*/
|
|
2787
|
+
interface TTSResult {
|
|
2788
|
+
success: boolean;
|
|
2789
|
+
outputPath?: string;
|
|
2790
|
+
duration?: number;
|
|
2791
|
+
error?: string;
|
|
2792
|
+
}
|
|
2793
|
+
/**
|
|
2794
|
+
* TTS 内部状态(用于快照和恢复)
|
|
2795
|
+
*/
|
|
2796
|
+
interface TTSState {
|
|
2797
|
+
enabled: boolean;
|
|
2798
|
+
lastUtteranceId: string | null;
|
|
2799
|
+
totalUtterances: number;
|
|
2800
|
+
}
|
|
2801
|
+
|
|
2802
|
+
/**
|
|
2803
|
+
* TTSFeature - 文本朗读功能模块
|
|
2804
|
+
*
|
|
2805
|
+
* 提供:
|
|
2806
|
+
* 1. @StepFinish 钩子:在每个 step 结束时自动朗读模型输出
|
|
2807
|
+
* - 包括工具调用轮和非工具调用轮
|
|
2808
|
+
* - 只要有 assistant 文本回复就会朗读
|
|
2809
|
+
* - 默认自动播放音频(使用 pygame)
|
|
2810
|
+
*
|
|
2811
|
+
* Python 环境要求:
|
|
2812
|
+
* - 需要安装 kokoro、soundfile、pygame 库
|
|
2813
|
+
*
|
|
2814
|
+
* 安装方式:
|
|
2815
|
+
* uv 方式(推荐):
|
|
2816
|
+
* uv pip install kokoro soundfile pygame
|
|
2817
|
+
*
|
|
2818
|
+
* 或使用 pip:
|
|
2819
|
+
* pip install kokoro soundfile pygame
|
|
2820
|
+
*
|
|
2821
|
+
* Python 调用方式:
|
|
2822
|
+
* - 默认使用 'python' 命令(从 PATH 中查找)
|
|
2823
|
+
* - 如果使用 uv,可以配置为 'uv run'
|
|
2824
|
+
*
|
|
2825
|
+
* @example
|
|
2826
|
+
* ```typescript
|
|
2827
|
+
* import { TTSFeature } from './features/index.js';
|
|
2828
|
+
*
|
|
2829
|
+
* // 使用默认配置
|
|
2830
|
+
* const agent = new Agent({ ... }).use(new TTSFeature());
|
|
2831
|
+
*
|
|
2832
|
+
* // 自定义声音和语速
|
|
2833
|
+
* const agent = new Agent({ ... }).use(new TTSFeature({
|
|
2834
|
+
* model: {
|
|
2835
|
+
* voice: 'zf_xiaoxiao',
|
|
2836
|
+
* speed: 1.3
|
|
2837
|
+
* }
|
|
2838
|
+
* }));
|
|
2839
|
+
*
|
|
2840
|
+
* // 禁用自动播放
|
|
2841
|
+
* const agent = new Agent({ ... }).use(new TTSFeature({
|
|
2842
|
+
* output: {
|
|
2843
|
+
* autoPlay: false
|
|
2844
|
+
* }
|
|
2845
|
+
* }));
|
|
2846
|
+
*
|
|
2847
|
+
* // 使用 uv
|
|
2848
|
+
* const agent = new Agent({ ... }).use(new TTSFeature({
|
|
2849
|
+
* pythonPath: 'uv',
|
|
2850
|
+
* pythonArgs: ['run']
|
|
2851
|
+
* }));
|
|
2852
|
+
* ```
|
|
2853
|
+
*/
|
|
2854
|
+
|
|
2855
|
+
declare class TTSFeature implements AgentFeature {
|
|
2856
|
+
readonly name = "tts";
|
|
2857
|
+
readonly dependencies: string[];
|
|
2858
|
+
readonly source: string;
|
|
2859
|
+
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";
|
|
2860
|
+
private config;
|
|
2861
|
+
private state;
|
|
2862
|
+
private _packageInfo;
|
|
2863
|
+
constructor(config?: TTSFeatureConfig);
|
|
2864
|
+
getTools(): never[];
|
|
2865
|
+
getAsyncTools(_ctx: FeatureInitContext): Promise<never[]>;
|
|
2866
|
+
/**
|
|
2867
|
+
* 获取包信息(统一打包方案)
|
|
2868
|
+
*/
|
|
2869
|
+
getPackageInfo(): PackageInfo | null;
|
|
2870
|
+
/**
|
|
2871
|
+
* 获取模板名称列表(统一打包方案)
|
|
2872
|
+
* 此 Feature 没有模板,返回空数组
|
|
2873
|
+
*/
|
|
2874
|
+
getTemplateNames(): string[];
|
|
2875
|
+
onInitiate(_ctx: FeatureInitContext): Promise<void>;
|
|
2876
|
+
onDestroy(_ctx: FeatureContext): Promise<void>;
|
|
2877
|
+
captureState(): FeatureStateSnapshot;
|
|
2878
|
+
restoreState(snapshot: FeatureStateSnapshot): void;
|
|
2879
|
+
getHookDescription(lifecycle: string, methodName: string): string | undefined;
|
|
2880
|
+
/**
|
|
2881
|
+
* 检测 Python 环境和依赖库
|
|
2882
|
+
*/
|
|
2883
|
+
private checkPythonEnvironment;
|
|
2884
|
+
/**
|
|
2885
|
+
* 调用 Python 脚本生成 TTS 音频
|
|
2886
|
+
*/
|
|
2887
|
+
private generateTTS;
|
|
2888
|
+
/**
|
|
2889
|
+
* 提取模型输出的正文部分
|
|
2890
|
+
* 过滤掉系统消息、工具调用等,只保留实际的回复内容
|
|
2891
|
+
*/
|
|
2892
|
+
private extractMainResponse;
|
|
2893
|
+
/**
|
|
2894
|
+
* 在每个 step 结束时自动朗读模型输出
|
|
2895
|
+
* 包括工具调用轮和非工具调用轮
|
|
2896
|
+
*/
|
|
2897
|
+
speakOnStepFinish(ctx: StepFinishedContext): Promise<void>;
|
|
2898
|
+
}
|
|
2899
|
+
|
|
2900
|
+
/**
|
|
2901
|
+
* UserInputFeature - 通过调试界面获取用户输入
|
|
2902
|
+
*
|
|
2903
|
+
* 功能:
|
|
2904
|
+
* - 提供 get_user_input 工具,允许 LLM 请求用户输入
|
|
2905
|
+
* - 通过 DebugHub 的 UDS 通道与 ViewerWorker 通信
|
|
2906
|
+
* - 前端显示输入框,用户提交后返回给 Agent
|
|
2907
|
+
*/
|
|
2908
|
+
|
|
2909
|
+
interface UserInputFeatureConfig {
|
|
2910
|
+
/** 默认超时时间(毫秒),默认无限等待 */
|
|
2911
|
+
timeout?: number;
|
|
2912
|
+
}
|
|
2913
|
+
declare class UserInputFeature implements AgentFeature {
|
|
2914
|
+
readonly name = "user-input";
|
|
2915
|
+
readonly dependencies: string[];
|
|
2916
|
+
readonly source: string;
|
|
2917
|
+
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";
|
|
2918
|
+
private defaultTimeout;
|
|
2919
|
+
private nextDraftInput;
|
|
2920
|
+
/**
|
|
2921
|
+
* 缓存包信息
|
|
2922
|
+
*/
|
|
2923
|
+
private _packageInfo;
|
|
2924
|
+
/**
|
|
2925
|
+
* 获取包信息(统一打包方案)
|
|
2926
|
+
*/
|
|
2927
|
+
getPackageInfo(): PackageInfo | null;
|
|
2928
|
+
/**
|
|
2929
|
+
* 获取模板名称列表(统一打包方案)
|
|
2930
|
+
* 注意:UserInputFeature 没有渲染模板
|
|
2931
|
+
*/
|
|
2932
|
+
getTemplateNames(): string[];
|
|
2933
|
+
constructor(config?: UserInputFeatureConfig);
|
|
2934
|
+
setNextDraftInput(input: string): void;
|
|
2935
|
+
/**
|
|
2936
|
+
* 请求用户输入(核心方法)
|
|
2937
|
+
*/
|
|
2938
|
+
requestUserInput(prompt: string, timeout?: number): Promise<string>;
|
|
2939
|
+
requestUserInputEvent(request: UserInputRequest, timeout?: number): Promise<UserInputResponse>;
|
|
2940
|
+
/**
|
|
2941
|
+
* 获取用户输入(公开接口,供主循环直接调用)
|
|
2942
|
+
* @param prompt 提示信息
|
|
2943
|
+
* @param timeout 超时时间(毫秒)
|
|
2944
|
+
* @returns 用户输入内容
|
|
2945
|
+
*/
|
|
2946
|
+
getUserInput(prompt?: string, timeout?: number): Promise<string>;
|
|
2947
|
+
getUserInputEvent(prompt?: string, timeout?: number, actions?: UserInputAction[]): Promise<UserInputResponse>;
|
|
2948
|
+
getTools(): Tool[];
|
|
2949
|
+
onInitiate(_ctx: FeatureInitContext): Promise<void>;
|
|
2950
|
+
onDestroy(_ctx: FeatureContext): Promise<void>;
|
|
2951
|
+
}
|
|
2952
|
+
|
|
2953
|
+
/**
|
|
2954
|
+
* VisualFeature 类型定义
|
|
2955
|
+
*/
|
|
2956
|
+
/**
|
|
2957
|
+
* 窗口信息(从 Python enum.py 返回)
|
|
2958
|
+
*/
|
|
2959
|
+
interface WindowInfo {
|
|
2960
|
+
/** 窗口句柄(16进制格式,如 "0x12345") */
|
|
2961
|
+
hwnd: string;
|
|
2962
|
+
/** 窗口标题 */
|
|
2963
|
+
title: string;
|
|
2964
|
+
/** 窗口类名 */
|
|
2965
|
+
class_name: string;
|
|
2966
|
+
/** 窗口状态 */
|
|
2967
|
+
status: 'Normal' | 'Minimized' | 'Maximized' | 'Unknown';
|
|
2968
|
+
/** 窗口位置和尺寸 */
|
|
2969
|
+
position: {
|
|
2970
|
+
x: number;
|
|
2971
|
+
y: number;
|
|
2972
|
+
width: number;
|
|
2973
|
+
height: number;
|
|
2974
|
+
};
|
|
2975
|
+
/** 进程名称 */
|
|
2976
|
+
process_name: string;
|
|
2977
|
+
/** 进程路径 */
|
|
2978
|
+
process_path: string;
|
|
2979
|
+
/** 进程 ID */
|
|
2980
|
+
pid: number | string;
|
|
2981
|
+
/** 是否置顶 */
|
|
2982
|
+
is_always_on_top: boolean;
|
|
2983
|
+
}
|
|
2984
|
+
/**
|
|
2985
|
+
* 截图结果(从 Python capture.py 返回)
|
|
2986
|
+
*/
|
|
2987
|
+
interface CaptureResult {
|
|
2988
|
+
/** 是否成功 */
|
|
2989
|
+
success?: boolean;
|
|
2990
|
+
/** 窗口句柄 */
|
|
2991
|
+
hwnd?: string;
|
|
2992
|
+
/** 图片宽度 */
|
|
2993
|
+
width?: number;
|
|
2994
|
+
/** 图片高度 */
|
|
2995
|
+
height?: number;
|
|
2996
|
+
/** 图片格式 */
|
|
2997
|
+
format?: string;
|
|
2998
|
+
/** base64 编码的图片数据 */
|
|
2999
|
+
data?: string;
|
|
3000
|
+
/** 错误信息 */
|
|
3001
|
+
error?: string;
|
|
3002
|
+
}
|
|
3003
|
+
/**
|
|
3004
|
+
* 视觉理解结果(从 LLM 返回)
|
|
3005
|
+
*/
|
|
3006
|
+
interface VisualUnderstandingResult {
|
|
3007
|
+
/** 图片内容的自然语言描述 */
|
|
3008
|
+
description: string;
|
|
3009
|
+
/** 检测到的 UI 元素(可选) */
|
|
3010
|
+
elements?: Array<{
|
|
3011
|
+
type: string;
|
|
3012
|
+
label?: string;
|
|
3013
|
+
position?: {
|
|
3014
|
+
x: number;
|
|
3015
|
+
y: number;
|
|
3016
|
+
width: number;
|
|
3017
|
+
height: number;
|
|
3018
|
+
};
|
|
3019
|
+
}>;
|
|
3020
|
+
/** 图片类型/应用类型识别(可选) */
|
|
3021
|
+
app_type?: string;
|
|
3022
|
+
}
|
|
3023
|
+
/**
|
|
3024
|
+
* VisualFeature 配置
|
|
3025
|
+
*/
|
|
3026
|
+
interface VisualFeatureConfig {
|
|
3027
|
+
/** LLM 服务地址(默认 localhost:7575) */
|
|
3028
|
+
baseUrl?: string;
|
|
3029
|
+
/** 视觉理解模型名称(默认 Qwen3.5-4B-Q5_K_M) */
|
|
3030
|
+
model?: string;
|
|
3031
|
+
/**
|
|
3032
|
+
* 主动视觉理解服务配置
|
|
3033
|
+
*
|
|
3034
|
+
* 用于用户主动调用 capture_and_understand_window_advanced 工具时使用
|
|
3035
|
+
* 使用更大的模型(如 Qwen3.5-9B-Q4_K_M)提供更准确的理解
|
|
3036
|
+
*/
|
|
3037
|
+
advancedVision?: {
|
|
3038
|
+
/** LLM 服务地址(默认 localhost:7577) */
|
|
3039
|
+
baseUrl?: string;
|
|
3040
|
+
/** 视觉理解模型名称(默认 Qwen3.5-9B-Q4_K_M) */
|
|
3041
|
+
model?: string;
|
|
3042
|
+
};
|
|
3043
|
+
/**
|
|
3044
|
+
* Python 可执行文件路径(默认 'python')
|
|
3045
|
+
*
|
|
3046
|
+
* 常用选项:
|
|
3047
|
+
* - 'python' - 系统默认 Python
|
|
3048
|
+
* - 'uv python' - uv 管理的 Python
|
|
3049
|
+
* - 'uv' - 使用 uv run(需要配置 pythonArgs)
|
|
3050
|
+
* - 完整路径如 'C:\\\Python312\\\python.exe'
|
|
3051
|
+
*/
|
|
3052
|
+
pythonPath?: string;
|
|
3053
|
+
/**
|
|
3054
|
+
* Python 参数(可选)
|
|
3055
|
+
*
|
|
3056
|
+
* 例如使用 uv run:
|
|
3057
|
+
* pythonArgs: ['run', '--with', 'pywin32', '--with', 'psutil', '--with', 'Pillow', 'script.py']
|
|
3058
|
+
*/
|
|
3059
|
+
pythonArgs?: string[];
|
|
3060
|
+
/**
|
|
3061
|
+
* 窗口进程忽略规则文件路径(可选)
|
|
3062
|
+
*
|
|
3063
|
+
* 默认使用项目根目录下的 .agentdev/windows.ignore
|
|
3064
|
+
* 文件格式:每行一个需要忽略的 exe 路径,支持通配符 *
|
|
3065
|
+
*
|
|
3066
|
+
* 示例:
|
|
3067
|
+
* ```
|
|
3068
|
+
* # 系统组件
|
|
3069
|
+
* C:\\Windows\\explorer.exe
|
|
3070
|
+
* # 输入法
|
|
3071
|
+
* C:\\Windows\\System32\\ctfmon.exe
|
|
3072
|
+
* # 通配符匹配
|
|
3073
|
+
* C:\\Program Files\\WindowsApps\\Microsoft.InputApp_*
|
|
3074
|
+
* ```
|
|
3075
|
+
*/
|
|
3076
|
+
ignoreFilePath?: string;
|
|
3077
|
+
/** 是否启用 onCallStart 窗口状态注入(默认 true) */
|
|
3078
|
+
enableWindowInfo?: boolean;
|
|
3079
|
+
/** 是否在初始化时检测 Python 环境(默认 true) */
|
|
3080
|
+
checkPythonEnv?: boolean;
|
|
3081
|
+
/**
|
|
3082
|
+
* 后台监控配置
|
|
3083
|
+
*/
|
|
3084
|
+
monitoring?: {
|
|
3085
|
+
/** 是否启用后台监控 */
|
|
3086
|
+
enabled?: boolean;
|
|
3087
|
+
/** 轮询间隔(毫秒),默认 250 */
|
|
3088
|
+
pollInterval?: number;
|
|
3089
|
+
/** 截图 Worker 数量,默认 3 */
|
|
3090
|
+
captureWorkerCount?: number;
|
|
3091
|
+
/** 分析 Worker 数量,默认 1(单线程,避免连接压力) */
|
|
3092
|
+
analysisWorkerCount?: number;
|
|
3093
|
+
/** 同一窗口两次截图的最小间隔(毫秒),默认 5 秒 */
|
|
3094
|
+
minCaptureInterval?: number;
|
|
3095
|
+
/** 失去焦点多久后重新获得焦点需要重新截图(毫秒),默认 15 秒 */
|
|
3096
|
+
focusChangeCaptureThreshold?: number;
|
|
3097
|
+
/** 焦点持续多久后需要重新截图(毫秒),默认 30 秒 */
|
|
3098
|
+
longFocusCaptureThreshold?: number;
|
|
3099
|
+
/** 焦点状态持续多久后需要截图(毫秒),默认 10 秒 */
|
|
3100
|
+
focusDurationCaptureThreshold?: number;
|
|
3101
|
+
/** 同一窗口两次分析的最小间隔(毫秒),默认 60 秒 */
|
|
3102
|
+
minAnalysisInterval?: number;
|
|
3103
|
+
/** 失去焦点多久后重新获得焦点需要重新分析(毫秒),默认 30 秒 */
|
|
3104
|
+
focusChangeAnalysisThreshold?: number;
|
|
3105
|
+
/** 焦点持续多久后需要重新分析(毫秒),默认 60 秒 */
|
|
3106
|
+
longFocusAnalysisThreshold?: number;
|
|
3107
|
+
/** 缓存过期时间(毫秒),默认 300 秒(5分钟) */
|
|
3108
|
+
analysisTTL?: number;
|
|
3109
|
+
};
|
|
3110
|
+
/**
|
|
3111
|
+
* 缓存管理配置
|
|
3112
|
+
*/
|
|
3113
|
+
cache?: {
|
|
3114
|
+
/** 缓存根目录,默认 .agentdev/visual-cache */
|
|
3115
|
+
cacheDir?: string;
|
|
3116
|
+
/** 最大总大小(字节),默认 500MB */
|
|
3117
|
+
maxSize?: number;
|
|
3118
|
+
/** 最大文件数,默认 100 */
|
|
3119
|
+
maxCount?: number;
|
|
3120
|
+
/** 每个窗口保留的最大截图数量,默认 5 */
|
|
3121
|
+
maxCapturesPerWindow?: number;
|
|
3122
|
+
/** 截图TTL(毫秒),默认 7天 */
|
|
3123
|
+
imageTTL?: number;
|
|
3124
|
+
/** 分析结果TTL(毫秒),默认 7天 */
|
|
3125
|
+
analysisTTL?: number;
|
|
3126
|
+
/** 清理间隔(毫秒),默认 10分钟 */
|
|
3127
|
+
cleanupInterval?: number;
|
|
3128
|
+
};
|
|
3129
|
+
/**
|
|
3130
|
+
* 错误处理配置
|
|
3131
|
+
*/
|
|
3132
|
+
errorHandling?: {
|
|
3133
|
+
/** 最大重试次数,默认 1 */
|
|
3134
|
+
maxRetries?: number;
|
|
3135
|
+
/** 任务超时时间(毫秒),默认 30秒 */
|
|
3136
|
+
taskTimeout?: number;
|
|
3137
|
+
/** 是否跳过空图,默认 true */
|
|
3138
|
+
skipEmptyImage?: boolean;
|
|
3139
|
+
};
|
|
3140
|
+
}
|
|
3141
|
+
|
|
3142
|
+
/**
|
|
3143
|
+
* VisualFeature - 视觉理解功能模块
|
|
3144
|
+
*
|
|
3145
|
+
* 提供:
|
|
3146
|
+
* 1. capture_and_understand_window 工具:截图 + 视觉模型理解
|
|
3147
|
+
* 2. onCallStart 钩子:自动注入当前窗口状态信息
|
|
3148
|
+
*
|
|
3149
|
+
* Python 环境要求:
|
|
3150
|
+
* - 需要安装 pywin32、psutil、Pillow 库
|
|
3151
|
+
*
|
|
3152
|
+
* 安装方式:
|
|
3153
|
+
* uv 方式(推荐):
|
|
3154
|
+
* uv pip install pywin32 psutil Pillow
|
|
3155
|
+
*
|
|
3156
|
+
* 或使用 pip:
|
|
3157
|
+
* pip install pywin32 psutil Pillow
|
|
3158
|
+
*
|
|
3159
|
+
* Python 调用方式:
|
|
3160
|
+
* - 默认使用 'python' 命令(从 PATH 中查找)
|
|
3161
|
+
* - 如果使用 uv,可以配置为 'uv python' 或 'uv run --with pywin32 --with psutil --with Pillow'
|
|
3162
|
+
*
|
|
3163
|
+
* @example
|
|
3164
|
+
* ```typescript
|
|
3165
|
+
* import { VisualFeature } from './features/index.js';
|
|
3166
|
+
*
|
|
3167
|
+
* // 使用默认 python 命令
|
|
3168
|
+
* const agent = new Agent({ ... }).use(new VisualFeature());
|
|
3169
|
+
*
|
|
3170
|
+
* // 使用 uv
|
|
3171
|
+
* const agent = new Agent({ ... }).use(new VisualFeature({
|
|
3172
|
+
* pythonPath: 'uv python'
|
|
3173
|
+
* }));
|
|
3174
|
+
*
|
|
3175
|
+
* // 使用 uv run(自动安装依赖)
|
|
3176
|
+
* const agent = new Agent({ ... }).use(new VisualFeature({
|
|
3177
|
+
* pythonPath: 'uv'
|
|
3178
|
+
* pythonArgs: ['run', '--with', 'pywin32', '--with', 'psutil', '--with', 'Pillow']
|
|
3179
|
+
* }));
|
|
3180
|
+
* ```
|
|
3181
|
+
*/
|
|
3182
|
+
|
|
3183
|
+
declare class VisualFeature implements AgentFeature {
|
|
3184
|
+
readonly name = "visual";
|
|
3185
|
+
readonly dependencies: string[];
|
|
3186
|
+
readonly source: string;
|
|
3187
|
+
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";
|
|
3188
|
+
private config;
|
|
3189
|
+
private client;
|
|
3190
|
+
private advancedClient;
|
|
3191
|
+
private windowMonitorService;
|
|
3192
|
+
private captureWorkerPool;
|
|
3193
|
+
private analysisWorkerPool;
|
|
3194
|
+
private cacheManager;
|
|
3195
|
+
private _visualEnabled;
|
|
3196
|
+
private injectionState;
|
|
3197
|
+
constructor(config?: VisualFeatureConfig);
|
|
3198
|
+
private _packageInfo;
|
|
3199
|
+
/**
|
|
3200
|
+
* 获取包信息(统一打包方案)
|
|
3201
|
+
*/
|
|
3202
|
+
getPackageInfo(): PackageInfo | null;
|
|
3203
|
+
/**
|
|
3204
|
+
* 获取模板名称列表(统一打包方案)
|
|
3205
|
+
*/
|
|
3206
|
+
getTemplateNames(): string[];
|
|
3207
|
+
getTools(): Tool[];
|
|
3208
|
+
getAsyncTools(_ctx: FeatureInitContext): Promise<Tool[]>;
|
|
3209
|
+
onInitiate(_ctx: FeatureInitContext): Promise<void>;
|
|
3210
|
+
/**
|
|
3211
|
+
* 检测 Python 环境和依赖库
|
|
3212
|
+
*/
|
|
3213
|
+
private checkPythonEnvironment;
|
|
3214
|
+
onDestroy(_ctx: FeatureContext): Promise<void>;
|
|
3215
|
+
captureState(): FeatureStateSnapshot;
|
|
3216
|
+
restoreState(snapshot: FeatureStateSnapshot): void;
|
|
3217
|
+
getHookDescription(lifecycle: string, methodName: string): string | undefined;
|
|
3218
|
+
/**
|
|
3219
|
+
* 初始化后台监控服务
|
|
3220
|
+
*/
|
|
3221
|
+
private initializeMonitoring;
|
|
3222
|
+
/**
|
|
3223
|
+
* 停止后台监控服务
|
|
3224
|
+
*/
|
|
3225
|
+
private stopMonitoring;
|
|
3226
|
+
/**
|
|
3227
|
+
* 处理 /visual 命令并注入窗口信息(增量版本)
|
|
3228
|
+
*
|
|
3229
|
+
* 逻辑:
|
|
3230
|
+
* 1. 检测 /visual 命令,切换视觉模式开关
|
|
3231
|
+
* 2. 如果是命令,更新输入缓存为纯净内容(去除命令前缀)
|
|
3232
|
+
* 3. 如果视觉模式开启(包括刚开启的),立即注入窗口信息
|
|
3233
|
+
*
|
|
3234
|
+
* 增量注入策略:
|
|
3235
|
+
* - 第一次:全量注入(所有窗口 + 所有缓存)
|
|
3236
|
+
* - 后续:只注入变化部分(窗口状态变化 + 新的分析结果)
|
|
3237
|
+
*/
|
|
3238
|
+
injectWindowInfo(ctx: CallStartContext): Promise<void>;
|
|
3239
|
+
/**
|
|
3240
|
+
* 调用 Python 脚本枚举所有窗口
|
|
3241
|
+
*/
|
|
3242
|
+
private enumerateWindows;
|
|
3243
|
+
/**
|
|
3244
|
+
* 获取当前焦点窗口句柄
|
|
3245
|
+
*/
|
|
3246
|
+
private getForegroundWindow;
|
|
3247
|
+
/**
|
|
3248
|
+
* 格式化窗口信息为系统消息(全量版本,用于首次注入)
|
|
3249
|
+
*/
|
|
3250
|
+
private formatWindowMessage;
|
|
3251
|
+
/**
|
|
3252
|
+
* 格式化缓存的窗口分析结果(全量版本,用于首次注入)
|
|
3253
|
+
*/
|
|
3254
|
+
private formatCachedAnalyses;
|
|
3255
|
+
/**
|
|
3256
|
+
* 计算简单哈希(用于检测内容变化)
|
|
3257
|
+
*/
|
|
3258
|
+
private hashDescription;
|
|
3259
|
+
/**
|
|
3260
|
+
* 计算窗口状态变化
|
|
3261
|
+
*/
|
|
3262
|
+
private computeWindowChanges;
|
|
3263
|
+
/**
|
|
3264
|
+
* 计算缓存分析结果变化
|
|
3265
|
+
*/
|
|
3266
|
+
private computeAnalysisChanges;
|
|
3267
|
+
/**
|
|
3268
|
+
* 格式化窗口变化
|
|
3269
|
+
*/
|
|
3270
|
+
private formatWindowChanges;
|
|
3271
|
+
/**
|
|
3272
|
+
* 格式化分析变化
|
|
3273
|
+
*/
|
|
3274
|
+
private formatAnalysisChanges;
|
|
3275
|
+
/**
|
|
3276
|
+
* 格式化增量消息(合并窗口状态变化 + 缓存分析变化 + 首次全量)
|
|
3277
|
+
*/
|
|
3278
|
+
private formatIncrementalMessage;
|
|
3279
|
+
}
|
|
3280
|
+
|
|
3281
|
+
/**
|
|
3282
|
+
* MCP Tool Adapter - 适配器模式实现
|
|
3283
|
+
*
|
|
3284
|
+
* 将 MCP 工具适配为现有 Tool 接口,保持架构一致性
|
|
3285
|
+
*/
|
|
3286
|
+
|
|
3287
|
+
/**
|
|
3288
|
+
* 注册工具的简化接口
|
|
3289
|
+
* 用于适配器包装
|
|
3290
|
+
*/
|
|
3291
|
+
interface RegisteredToolLike {
|
|
3292
|
+
name: string;
|
|
3293
|
+
description?: string;
|
|
3294
|
+
inputSchema?: any;
|
|
3295
|
+
outputSchema?: any;
|
|
3296
|
+
annotations?: any;
|
|
3297
|
+
handler?: (args: any, context?: any) => Promise<any> | any;
|
|
3298
|
+
enabled?: boolean;
|
|
3299
|
+
}
|
|
3300
|
+
/**
|
|
3301
|
+
* MCP 工具适配器配置
|
|
3302
|
+
*/
|
|
3303
|
+
interface MCPToolAdapterConfig {
|
|
3304
|
+
/** MCP 服务器名称 */
|
|
3305
|
+
serverName: string;
|
|
3306
|
+
/** 是否为只读工具 */
|
|
3307
|
+
readOnly?: boolean;
|
|
3308
|
+
/** 渲染模板覆盖 */
|
|
3309
|
+
render?: {
|
|
3310
|
+
call?: string;
|
|
3311
|
+
result?: string;
|
|
3312
|
+
};
|
|
3313
|
+
}
|
|
3314
|
+
/**
|
|
3315
|
+
* MCP 工具适配器
|
|
3316
|
+
*
|
|
3317
|
+
* 将 MCP RegisteredTool 适配为 Agent 的 Tool 接口
|
|
3318
|
+
* 负责格式转换和生命周期管理
|
|
3319
|
+
*/
|
|
3320
|
+
declare class MCPToolAdapter implements Tool {
|
|
3321
|
+
private registeredTool;
|
|
3322
|
+
private config;
|
|
3323
|
+
readonly name: string;
|
|
3324
|
+
readonly description: string;
|
|
3325
|
+
readonly parameters?: Record<string, any>;
|
|
3326
|
+
readonly render?: {
|
|
3327
|
+
call?: string;
|
|
3328
|
+
result?: string;
|
|
3329
|
+
};
|
|
3330
|
+
constructor(registeredTool: RegisteredToolLike, config: MCPToolAdapterConfig);
|
|
3331
|
+
/**
|
|
3332
|
+
* 执行 MCP 工具
|
|
3333
|
+
*/
|
|
3334
|
+
execute(args: any, context?: any): Promise<any>;
|
|
3335
|
+
/**
|
|
3336
|
+
* 格式化 MCP 工具结果
|
|
3337
|
+
*/
|
|
3338
|
+
private formatResult;
|
|
3339
|
+
/**
|
|
3340
|
+
* 格式化错误
|
|
3341
|
+
*/
|
|
3342
|
+
private formatError;
|
|
3343
|
+
/**
|
|
3344
|
+
* 从 RegisteredToolLike 提取参数定义
|
|
3345
|
+
*
|
|
3346
|
+
* MCP 工具的 inputSchema 已经是 JSON Schema 格式
|
|
3347
|
+
* 直接返回,不需要转换
|
|
3348
|
+
*/
|
|
3349
|
+
private extractParameters;
|
|
3350
|
+
}
|
|
3351
|
+
/**
|
|
3352
|
+
* 批量创建 MCP 工具适配器
|
|
3353
|
+
*/
|
|
3354
|
+
declare function createMCPToolAdapters(registeredTools: RegisteredToolLike[], serverName: string, config?: Omit<MCPToolAdapterConfig, 'serverName'>): Tool[];
|
|
3355
|
+
|
|
3356
|
+
interface MCPDiscoveredTool {
|
|
3357
|
+
name: string;
|
|
3358
|
+
description?: string;
|
|
3359
|
+
inputSchema?: any;
|
|
3360
|
+
}
|
|
3361
|
+
interface MCPToolCreationOptions {
|
|
3362
|
+
name?: string;
|
|
3363
|
+
description?: string;
|
|
3364
|
+
render?: MCPToolAdapterConfig['render'];
|
|
3365
|
+
transformArgs?: (args: Record<string, unknown>, context?: any) => Record<string, unknown>;
|
|
3366
|
+
}
|
|
3367
|
+
interface MCPToolDiscoveryOptions {
|
|
3368
|
+
filter?: (tool: MCPDiscoveredTool) => boolean;
|
|
3369
|
+
mapName?: (tool: MCPDiscoveredTool) => string;
|
|
3370
|
+
render?: MCPToolAdapterConfig['render'];
|
|
3371
|
+
transformArgs?: MCPToolCreationOptions['transformArgs'];
|
|
3372
|
+
}
|
|
3373
|
+
interface MCPDiscoveredToolSet {
|
|
3374
|
+
client: MCPClient;
|
|
3375
|
+
tools: Tool[];
|
|
3376
|
+
}
|
|
3377
|
+
declare function createDefaultMCPToolName(serverId: string, toolName: string): string;
|
|
3378
|
+
declare class MCPClient {
|
|
3379
|
+
readonly serverId: string;
|
|
3380
|
+
private readonly config;
|
|
3381
|
+
private readonly manager;
|
|
3382
|
+
private connected;
|
|
3383
|
+
constructor(serverId: string, config: MCPServerConfig, manager?: MCPConnectionManager);
|
|
3384
|
+
connect(): Promise<void>;
|
|
3385
|
+
listTools(): Promise<MCPDiscoveredTool[]>;
|
|
3386
|
+
callTool(name: string, args: Record<string, unknown>): Promise<any>;
|
|
3387
|
+
getConnectionManager(): MCPConnectionManager;
|
|
3388
|
+
dispose(): Promise<void>;
|
|
3389
|
+
}
|
|
3390
|
+
declare function createMCPTool(client: MCPClient, tool: MCPDiscoveredTool, options?: MCPToolCreationOptions): Tool;
|
|
3391
|
+
declare function createMCPToolsFromClient(client: MCPClient, options?: MCPToolDiscoveryOptions): Promise<Tool[]>;
|
|
3392
|
+
declare function discoverMCPTools(serverId: string, config: MCPServerConfig, options?: MCPToolDiscoveryOptions, manager?: MCPConnectionManager): Promise<MCPDiscoveredToolSet>;
|
|
3393
|
+
|
|
3394
|
+
interface MCPToolPatch {
|
|
3395
|
+
enabled?: boolean;
|
|
3396
|
+
name?: string;
|
|
3397
|
+
description?: string;
|
|
3398
|
+
render?: MCPToolAdapterConfig['render'];
|
|
3399
|
+
transformArgs?: MCPToolCreationOptions['transformArgs'];
|
|
3400
|
+
}
|
|
3401
|
+
interface MCPToolManagementOptions {
|
|
3402
|
+
include?: string[];
|
|
3403
|
+
exclude?: string[];
|
|
3404
|
+
disable?: string[];
|
|
3405
|
+
rename?: Record<string, string>;
|
|
3406
|
+
describe?: Record<string, string>;
|
|
3407
|
+
render?: MCPToolAdapterConfig['render'];
|
|
3408
|
+
toolRender?: Record<string, MCPToolAdapterConfig['render']>;
|
|
3409
|
+
mapName?: (tool: MCPDiscoveredTool, client: MCPClient) => string;
|
|
3410
|
+
transformArgs?: MCPToolCreationOptions['transformArgs'];
|
|
3411
|
+
transform?: (tool: MCPDiscoveredTool, client: MCPClient) => MCPToolPatch | false | null | undefined;
|
|
3412
|
+
}
|
|
3413
|
+
interface MCPConfigMountOptions {
|
|
3414
|
+
manager?: MCPConnectionManager;
|
|
3415
|
+
clients?: Map<string, MCPClient>;
|
|
3416
|
+
getServerOptions?: (serverId: string, serverConfig: MCPServerConfig) => MCPToolManagementOptions | undefined;
|
|
3417
|
+
onError?: (serverId: string, error: unknown) => void;
|
|
3418
|
+
}
|
|
3419
|
+
interface MCPMountedToolSet {
|
|
3420
|
+
client: MCPClient;
|
|
3421
|
+
tools: Tool[];
|
|
3422
|
+
}
|
|
3423
|
+
interface MCPMountedConfigResult {
|
|
3424
|
+
tools: Tool[];
|
|
3425
|
+
clients: Map<string, MCPClient>;
|
|
3426
|
+
}
|
|
3427
|
+
declare function createManagedMCPToolsFromClient(client: MCPClient, options?: MCPToolManagementOptions): Promise<Tool[]>;
|
|
3428
|
+
declare function discoverManagedMCPTools(serverId: string, config: MCPServerConfig, options?: MCPToolManagementOptions, manager?: MCPConnectionManager): Promise<MCPMountedToolSet>;
|
|
3429
|
+
declare function mountMCPToolsFromConfig(config: MCPConfig, options?: MCPConfigMountOptions): Promise<MCPMountedConfigResult>;
|
|
3430
|
+
|
|
3431
|
+
/**
|
|
3432
|
+
* WebSearch Feature - 网页内容获取工具
|
|
2052
3433
|
*
|
|
2053
|
-
*
|
|
2054
|
-
*
|
|
2055
|
-
*
|
|
2056
|
-
*
|
|
3434
|
+
* 提供网页抓取和内容提取功能
|
|
3435
|
+
*
|
|
3436
|
+
* @example
|
|
3437
|
+
* ```typescript
|
|
3438
|
+
* import { WebSearchFeature } from './features/index.js';
|
|
3439
|
+
* const agent = new Agent({ ... }).use(new WebSearchFeature());
|
|
3440
|
+
* ```
|
|
2057
3441
|
*/
|
|
2058
3442
|
|
|
2059
|
-
interface
|
|
2060
|
-
|
|
2061
|
-
|
|
3443
|
+
interface WebSearchFeatureConfig {
|
|
3444
|
+
crawl4ai?: false | (MCPToolManagementOptions & {
|
|
3445
|
+
server?: MCPSSEConfig;
|
|
3446
|
+
});
|
|
2062
3447
|
}
|
|
2063
|
-
|
|
2064
|
-
|
|
3448
|
+
/**
|
|
3449
|
+
* WebSearch Feature 实现
|
|
3450
|
+
*/
|
|
3451
|
+
declare class WebSearchFeature implements AgentFeature {
|
|
3452
|
+
private readonly config;
|
|
3453
|
+
readonly name = "websearch";
|
|
2065
3454
|
readonly dependencies: string[];
|
|
2066
3455
|
readonly source: string;
|
|
2067
|
-
readonly description = "\
|
|
2068
|
-
private
|
|
2069
|
-
private
|
|
3456
|
+
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";
|
|
3457
|
+
private readonly manager;
|
|
3458
|
+
private readonly crawl4aiClients;
|
|
3459
|
+
private _packageInfo;
|
|
3460
|
+
constructor(config?: WebSearchFeatureConfig);
|
|
2070
3461
|
/**
|
|
2071
|
-
*
|
|
3462
|
+
* 获取工具列表
|
|
2072
3463
|
*/
|
|
2073
|
-
|
|
3464
|
+
getTools(): Tool[];
|
|
3465
|
+
getAsyncTools(_ctx: FeatureInitContext): Promise<Tool[]>;
|
|
3466
|
+
onDestroy(): Promise<void>;
|
|
2074
3467
|
/**
|
|
2075
3468
|
* 获取包信息(统一打包方案)
|
|
2076
3469
|
*/
|
|
2077
3470
|
getPackageInfo(): PackageInfo | null;
|
|
2078
3471
|
/**
|
|
2079
3472
|
* 获取模板名称列表(统一打包方案)
|
|
2080
|
-
* 注意:UserInputFeature 没有渲染模板
|
|
2081
3473
|
*/
|
|
2082
3474
|
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
3475
|
}
|
|
2102
3476
|
|
|
3477
|
+
interface OpencodeBasicFeatureConfig {
|
|
3478
|
+
workspaceDir?: string;
|
|
3479
|
+
}
|
|
2103
3480
|
/**
|
|
2104
3481
|
* OpencodeBasic Feature - 基础文件操作工具集
|
|
2105
3482
|
*/
|
|
@@ -2129,6 +3506,8 @@ declare class OpencodeBasicFeature implements AgentFeature {
|
|
|
2129
3506
|
* Logger 实例,用于记录结构化日志
|
|
2130
3507
|
*/
|
|
2131
3508
|
private logger;
|
|
3509
|
+
private readonly workspaceDir;
|
|
3510
|
+
constructor(config?: OpencodeBasicFeatureConfig);
|
|
2132
3511
|
/**
|
|
2133
3512
|
* Feature 初始化时清空读取历史
|
|
2134
3513
|
*/
|
|
@@ -2305,6 +3684,10 @@ interface BasicAgentConfig {
|
|
|
2305
3684
|
tools?: Tool[];
|
|
2306
3685
|
/** Skills 目录(可选,默认使用 .agentdev/skills) */
|
|
2307
3686
|
skillsDir?: string;
|
|
3687
|
+
/** 调试器和模板解析使用的项目根目录 */
|
|
3688
|
+
projectRoot?: string;
|
|
3689
|
+
/** 工具默认操作的工作目录 */
|
|
3690
|
+
workspaceDir?: string;
|
|
2308
3691
|
}
|
|
2309
3692
|
/**
|
|
2310
3693
|
* 基础 Agent 类
|
|
@@ -2595,7 +3978,7 @@ declare class ViewerWorker {
|
|
|
2595
3978
|
/**
|
|
2596
3979
|
* GET /api/templates/feature - 获取 Feature 模板映射
|
|
2597
3980
|
*/
|
|
2598
|
-
handleGetFeatureTemplates(req: IncomingMessage, res: ServerResponse): void;
|
|
3981
|
+
handleGetFeatureTemplates(req: IncomingMessage, res: ServerResponse, searchParams?: URLSearchParams): void;
|
|
2599
3982
|
/**
|
|
2600
3983
|
* 将模板文件路径转换为 HTTP URL
|
|
2601
3984
|
* 支持多种来源:
|
|
@@ -2946,119 +4329,6 @@ declare function createListRenderer<T = any>(config: Omit<DataSourceRenderer<T>,
|
|
|
2946
4329
|
*/
|
|
2947
4330
|
declare function discover(options?: SkillsOptions): Promise<SkillMetadata[]>;
|
|
2948
4331
|
|
|
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
4332
|
interface LoadAllMCPConfigsOptions {
|
|
3063
4333
|
excludeServers?: string[];
|
|
3064
4334
|
}
|
|
@@ -3066,43 +4336,6 @@ declare function getDefaultMCPConfigDir(rootDir?: string): string;
|
|
|
3066
4336
|
declare function loadMCPConfigFromInput(input: string, rootDir?: string): MCPConfig | undefined;
|
|
3067
4337
|
declare function loadAllMCPConfigs(rootDir?: string, options?: LoadAllMCPConfigsOptions): MCPConfig | undefined;
|
|
3068
4338
|
|
|
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
4339
|
/**
|
|
3107
4340
|
* MCP 工具渲染模板
|
|
3108
4341
|
*
|
|
@@ -3140,4 +4373,4 @@ declare function renderMCPToolCall(serverName: string, toolName: string, args: R
|
|
|
3140
4373
|
*/
|
|
3141
4374
|
declare function renderMCPToolResult(result: any, success?: boolean): string;
|
|
3142
4375
|
|
|
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 };
|
|
4376
|
+
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, 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 };
|