agentdev 0.1.10 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/BasicAgent-7TNMYC3X.js +13 -0
  2. package/dist/ExplorerAgent-L3ZTVQGM.js +13 -0
  3. package/dist/{chunk-72H6A6NB.js → chunk-35LBACUK.js} +8 -8
  4. package/dist/{chunk-72H6A6NB.js.map → chunk-35LBACUK.js.map} +1 -1
  5. package/dist/{chunk-NORTAQIL.js → chunk-4WK7UENZ.js} +1011 -11
  6. package/dist/chunk-4WK7UENZ.js.map +1 -0
  7. package/dist/{chunk-BAP2GCYH.js → chunk-7GTVQ55R.js} +1 -1
  8. package/dist/chunk-7GTVQ55R.js.map +1 -0
  9. package/dist/{chunk-G5ECPY4K.js → chunk-EK6KGS2M.js} +87 -8
  10. package/dist/{chunk-G5ECPY4K.js.map → chunk-EK6KGS2M.js.map} +1 -1
  11. package/dist/{chunk-REOJZCSZ.js → chunk-KE3KYZVJ.js} +21 -8
  12. package/dist/chunk-KE3KYZVJ.js.map +1 -0
  13. package/dist/{chunk-EECW6PYP.js → chunk-UL2ZBPBL.js} +60 -4
  14. package/dist/chunk-UL2ZBPBL.js.map +1 -0
  15. package/dist/{chunk-3AR3JBW6.js → chunk-XRB6MD2J.js} +5436 -883
  16. package/dist/chunk-XRB6MD2J.js.map +1 -0
  17. package/dist/cli/server.js +2 -2
  18. package/dist/cli/viewer.js +2 -2
  19. package/dist/features/mcp/templates/mcp-tool.render.js +14 -1
  20. package/dist/features/mcp/templates/mcp-tool.render.js.map +1 -1
  21. package/dist/features/shell/templates/bash.render.d.ts +1 -1
  22. package/dist/features/websearch/templates/web-fetch.render.d.ts +1 -1
  23. package/dist/index.d.ts +752 -20
  24. package/dist/index.js +17 -7
  25. package/dist/index.js.map +1 -1
  26. package/dist/{notification-NWVOS2WR.js → notification-QPH37BHW.js} +29 -6
  27. package/dist/notification-QPH37BHW.js.map +1 -0
  28. package/dist/{tools-LDR3LIJP.js → tools-OKH7SPMP.js} +2 -2
  29. package/dist/{types-CF5UsxD9.d.ts → types-NVwNUVFR.d.ts} +180 -14
  30. package/package.json +6 -13
  31. package/dist/BasicAgent-R7DYGTHF.js +0 -13
  32. package/dist/ExplorerAgent-DXY3OQ5U.js +0 -13
  33. package/dist/chunk-3AR3JBW6.js.map +0 -1
  34. package/dist/chunk-BAP2GCYH.js.map +0 -1
  35. package/dist/chunk-EECW6PYP.js.map +0 -1
  36. package/dist/chunk-NORTAQIL.js.map +0 -1
  37. package/dist/chunk-REOJZCSZ.js.map +0 -1
  38. package/dist/notification-NWVOS2WR.js.map +0 -1
  39. /package/dist/{BasicAgent-R7DYGTHF.js.map → BasicAgent-7TNMYC3X.js.map} +0 -0
  40. /package/dist/{ExplorerAgent-DXY3OQ5U.js.map → ExplorerAgent-L3ZTVQGM.js.map} +0 -0
  41. /package/dist/{tools-LDR3LIJP.js.map → tools-OKH7SPMP.js.map} +0 -0
package/dist/index.d.ts CHANGED
@@ -1,6 +1,8 @@
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';
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 UserInputQuestion, o as UserInputChoiceAnswer, p as LLMClient, q as MessageRole, r as AgentSession } from './types-NVwNUVFR.js';
2
+ export { C as CacheStats, s as ContextMiddleware, D as DebugHubIPCMessage, t as MessageUsage, u as TemplateComposer, v as TemplateError, w as TemplateLoaderOptions, x as TemplateResult, y as ToolMetadata, z as getDefaultUDSPath } from './types-NVwNUVFR.js';
3
3
  import { Client } from '@modelcontextprotocol/sdk/client/index.js';
4
+ import { EventEmitter } from 'events';
5
+ import { Diagnostic } from 'vscode-languageserver-types';
4
6
  import { IncomingMessage, ServerResponse } from 'http';
5
7
 
6
8
  /**
@@ -272,6 +274,54 @@ interface PackageInfo {
272
274
  /** 包根目录绝对路径 */
273
275
  root: string;
274
276
  }
277
+ /**
278
+ * Feature Manifest 配置项
279
+ *
280
+ * 用于声明 Feature 在 Agent Project 级别可配置的静态参数。
281
+ * Claw 等消费端可根据该契约自动渲染表单。
282
+ */
283
+ interface FeatureManifestSettingProperty {
284
+ type: 'string' | 'number' | 'boolean' | 'select' | 'file' | 'directory' | 'group';
285
+ title: string;
286
+ description?: string;
287
+ default?: unknown;
288
+ options?: Array<{
289
+ label: string;
290
+ value: string | number | boolean;
291
+ }>;
292
+ placeholder?: string;
293
+ /** number 类型下的最小值 */
294
+ min?: number;
295
+ /** number 类型下的最大值 */
296
+ max?: number;
297
+ /** number 类型下的步进值 */
298
+ step?: number;
299
+ /** file 类型下的可接受文件类型,如 '.mp3,.wav' 或 'audio/*' */
300
+ accept?: string | string[];
301
+ /** directory 类型下的最大条目数 */
302
+ maxItems?: number;
303
+ /** type: 'group' 时的嵌套子属性 */
304
+ properties?: Record<string, FeatureManifestSettingProperty>;
305
+ /** 条件可见性:仅当同级指定属性值在 values 中时渲染此字段 */
306
+ showWhen?: {
307
+ property: string;
308
+ values: (string | number | boolean)[];
309
+ };
310
+ }
311
+ interface FeatureManifestDefinition {
312
+ schemaVersion: 1;
313
+ settings?: {
314
+ properties: Record<string, FeatureManifestSettingProperty>;
315
+ /** 有序分区,用于 UI 分组渲染。省略则平铺全部属性 */
316
+ sections?: Array<{
317
+ id: string;
318
+ title: string;
319
+ description?: string;
320
+ /** 分区内属性 key 的显示顺序 */
321
+ properties: string[];
322
+ }>;
323
+ };
324
+ }
275
325
  /**
276
326
  * Feature 初始化上下文
277
327
  */
@@ -383,6 +433,13 @@ interface AgentFeature {
383
433
  * ```
384
434
  */
385
435
  getRenderTemplates?(): Record<string, InlineRenderTemplate>;
436
+ /**
437
+ * 声明 Feature 的项目级静态配置契约(Manifest)
438
+ *
439
+ * 该契约回答“这个 Feature 平时怎么工作”,
440
+ * 与 Flow 节点中的 Mode(什么时候、以什么状态工作)是正交的。
441
+ */
442
+ getFeatureManifest?(): FeatureManifestDefinition | null;
386
443
  /**
387
444
  * 声明上下文注入器
388
445
  */
@@ -489,6 +546,13 @@ interface CallStartContext {
489
546
  /** Agent 实例(用于访问 setUserInput/getUserInput 等 API) */
490
547
  agent?: any;
491
548
  }
549
+ /**
550
+ * Call 结束原因
551
+ *
552
+ * 让 @CallFinish 钩子能结构化地判断 call 为什么结束,
553
+ * 不再需要解析 response 字符串前缀。
554
+ */
555
+ type CallFinishReason = 'completed' | 'interrupted' | 'api_error' | 'error' | 'max_steps' | 'continuation' | 'exception';
492
556
  /**
493
557
  * Call 结束上下文
494
558
  */
@@ -503,6 +567,8 @@ interface CallFinishContext {
503
567
  steps: number;
504
568
  /** 是否成功完成 */
505
569
  completed: boolean;
570
+ /** 结束原因 */
571
+ finishReason: CallFinishReason;
506
572
  }
507
573
  /**
508
574
  * Step 开始上下文
@@ -518,6 +584,8 @@ interface StepStartContext {
518
584
  context: Context;
519
585
  /** 原始用户输入 */
520
586
  input: string;
587
+ /** Agent 实例(用于访问当前会话中的 Feature、工具和输入状态) */
588
+ agent?: any;
521
589
  }
522
590
  /**
523
591
  * Step 结束上下文
@@ -719,6 +787,8 @@ declare function createTool(config: {
719
787
  parameters?: Record<string, any>;
720
788
  execute: (args: any, context?: any) => Promise<any>;
721
789
  render?: ToolRenderInput;
790
+ executionMode?: 'normal' | 'exclusive';
791
+ parallelizable?: boolean;
722
792
  }, sourceFile?: string): Tool;
723
793
  /**
724
794
  * 工具注册表 - 管理多个工具
@@ -726,24 +796,51 @@ declare function createTool(config: {
726
796
  declare class ToolRegistry {
727
797
  private tools;
728
798
  private enabled;
799
+ private disabled;
729
800
  private pendingDisabled;
801
+ private pendingRemoved;
730
802
  private sources;
803
+ private superseded;
731
804
  /**
732
805
  * 注册工具(默认启用,记录来源)
733
806
  */
734
807
  register(tool: Tool, source?: string): this;
735
808
  /**
736
- * 禁用工具
809
+ * 禁用工具(LLM 可见,但执行时会被拦截)
737
810
  */
738
811
  disable(name: string): boolean;
739
812
  /**
740
813
  * 启用工具
741
814
  */
742
815
  enable(name: string): boolean;
816
+ /**
817
+ * 移除工具(LLM 不可见,承接旧 disable 行为)
818
+ */
819
+ remove(name: string): boolean;
820
+ /**
821
+ * 取消移除工具,恢复为启用状态
822
+ */
823
+ unremove(name: string): boolean;
743
824
  /**
744
825
  * 检查工具是否启用
745
826
  */
746
827
  isEnabled(name: string): boolean;
828
+ /**
829
+ * 检查工具是否禁用(屏蔽)
830
+ */
831
+ isDisabled(name: string): boolean;
832
+ /**
833
+ * 检查工具是否移除
834
+ */
835
+ isRemoved(name: string): boolean;
836
+ /**
837
+ * 检查工具是否为 exclusive 模式
838
+ */
839
+ isExclusive(name: string): boolean;
840
+ /**
841
+ * 检查工具是否可并行执行
842
+ */
843
+ isParallelizable(name: string): boolean;
747
844
  /**
748
845
  * 获取工具来源(调试用)
749
846
  */
@@ -753,6 +850,7 @@ declare class ToolRegistry {
753
850
  */
754
851
  getEntries(): Array<{
755
852
  tool: Tool;
853
+ state: 'enabled' | 'disabled' | 'removed' | 'superseded';
756
854
  enabled: boolean;
757
855
  source?: string;
758
856
  }>;
@@ -761,7 +859,7 @@ declare class ToolRegistry {
761
859
  */
762
860
  get(name: string): Tool | undefined;
763
861
  /**
764
- * 获取所有工具(只返回启用的)
862
+ * 获取所有 LLM 可见工具(启用 + 禁用)
765
863
  */
766
864
  getAll(): Tool[];
767
865
  /**
@@ -811,11 +909,14 @@ declare class DebugHub {
811
909
  private nextId;
812
910
  private readonly processId;
813
911
  private pendingInputRequests;
912
+ private queuedInputHandler?;
913
+ private interruptHandler?;
814
914
  private activeInputRequests;
815
915
  private udsClient?;
816
916
  private udsPath;
817
917
  private workerPort;
818
918
  private clientReady;
919
+ private stopped;
819
920
  private registrationLock;
820
921
  private messageQueue;
821
922
  private reconnectTimer?;
@@ -889,6 +990,13 @@ declare class DebugHub {
889
990
  getCurrentAgentId(): string | null;
890
991
  getTransportMode(): 'viewer-worker' | 'claw';
891
992
  getCapabilities(): DebugCapabilities;
993
+ setQueuedInputHandler(handler?: (agentId: string, input: {
994
+ id: string;
995
+ text: string;
996
+ timestamp: number;
997
+ }) => void | Promise<void>): void;
998
+ setInterruptHandler(handler?: (agentId: string, clearQueue: boolean) => void | Promise<void>): void;
999
+ consumeQueuedInput(agentId: string, inputId: string): void;
892
1000
  /**
893
1001
  * 根据 Agent 实例获取其 ID
894
1002
  */
@@ -943,6 +1051,45 @@ declare class DebugHub {
943
1051
  private sendToWorker;
944
1052
  }
945
1053
 
1054
+ /**
1055
+ * Continuation Request 类型定义
1056
+ *
1057
+ * 控制工具(如 checkpoint、rollback)通过 registerContinuationRequest()
1058
+ * 登记一个 continuation request,使当前 onCall 在合法边界停止。
1059
+ * 宿主(如 CallArbiter)通过 consumeContinuationRequest() 消费该请求,
1060
+ * 决定是否在同一个逻辑 envelope 内启动下一个 onCall segment。
1061
+ */
1062
+ /**
1063
+ * Checkpoint continuation request
1064
+ *
1065
+ * Agent 建立了一个命名检查点,希望继续执行。
1066
+ * 宿主应捕获当前 runtime snapshot 并将其与 checkpointId 关联,
1067
+ * 然后启动 continuation segment。
1068
+ */
1069
+ interface CheckpointContinuationRequest {
1070
+ kind: 'checkpoint';
1071
+ checkpointId: string;
1072
+ /** 可选附加元数据(如 Agent 的自由备注) */
1073
+ metadata?: Record<string, unknown>;
1074
+ }
1075
+ /**
1076
+ * Rollback continuation request
1077
+ *
1078
+ * Agent 希望回退到指定 checkpoint,并携带一个失败分支的摘要。
1079
+ * 宿主应恢复到 checkpoint 的 runtime snapshot,
1080
+ * 然后以摘要作为 continuation segment 的输入启动新的 onCall。
1081
+ */
1082
+ interface RollbackContinuationRequest {
1083
+ kind: 'rollback';
1084
+ checkpointId: string;
1085
+ /** Agent 生成的失败分支摘要 */
1086
+ summary: string;
1087
+ }
1088
+ /**
1089
+ * 受类型约束的 continuation request
1090
+ */
1091
+ type CallContinuationRequest = CheckpointContinuationRequest | RollbackContinuationRequest;
1092
+
946
1093
  interface FeatureCheckpoint {
947
1094
  featureName: string;
948
1095
  snapshot: FeatureStateSnapshot;
@@ -960,6 +1107,26 @@ interface CallRollbackSnapshot {
960
1107
  draftInput: string;
961
1108
  runtime: AgentRuntimeSnapshot;
962
1109
  }
1110
+ /**
1111
+ * 命名检查点 — 由 Agent 自主建立的可恢复快照
1112
+ *
1113
+ * 与 CallRollbackSnapshot 的区别:
1114
+ * - CallRollbackSnapshot 面向"回到某个用户 call 之前",是 onCall 的副产品
1115
+ * - NamedCheckpoint 面向"Agent 主动建立的恢复点",有稳定 ID,可跨 segment 引用
1116
+ *
1117
+ * checkpoint 表示控制工具执行完成、tool result 已写入、
1118
+ * 当前 segment 已完全结束之后的 runtime 状态(协议完整)。
1119
+ */
1120
+ interface NamedCheckpoint {
1121
+ /** 全局唯一的 checkpoint ID(由 Agent 提供) */
1122
+ id: string;
1123
+ /** 创建时间戳 */
1124
+ createdAt: number;
1125
+ /** 创建时的 callIndex */
1126
+ sourceCallIndex: number;
1127
+ /** 完整的 runtime snapshot */
1128
+ runtime: AgentRuntimeSnapshot;
1129
+ }
963
1130
  interface AgentSessionSnapshot {
964
1131
  version: number;
965
1132
  sessionId: string;
@@ -967,6 +1134,8 @@ interface AgentSessionSnapshot {
967
1134
  agentType: string;
968
1135
  runtime: AgentRuntimeSnapshot;
969
1136
  rollbackHistory: CallRollbackSnapshot[];
1137
+ /** 命名检查点列表(可选,用于 checkpoint/rollback 能力) */
1138
+ namedCheckpoints?: NamedCheckpoint[];
970
1139
  }
971
1140
  interface SessionStore {
972
1141
  save(sessionId: string, snapshot: AgentSessionSnapshot): Promise<string>;
@@ -1023,8 +1192,12 @@ declare class AgentBase {
1023
1192
  protected _callIndex: number;
1024
1193
  protected _callStartTimes: Map<number, number>;
1025
1194
  protected _callCheckpoints: CallRollbackCheckpoint[];
1195
+ protected _namedCheckpoints: NamedCheckpoint[];
1026
1196
  protected usageStats: UsageStats;
1197
+ private _continuationRequest;
1027
1198
  private _pendingInput;
1199
+ private _abortController;
1200
+ private _stepAutoSave?;
1028
1201
  private templateResolver?;
1029
1202
  private toolExecutor?;
1030
1203
  private reactRunner?;
@@ -1051,6 +1224,27 @@ declare class AgentBase {
1051
1224
  * @returns 当前输入缓存,如果未设置则返回空字符串
1052
1225
  */
1053
1226
  getUserInput(): string;
1227
+ /**
1228
+ * 登记一个 continuation request
1229
+ *
1230
+ * 控制工具(如 checkpoint、rollback)在正常完成执行后调用此方法,
1231
+ * 使当前 onCall 在工具结果闭合后停止,并将请求传递给宿主。
1232
+ *
1233
+ * 该方法仅在 onCall 执行期间有效。onCall 开始时会清理上一次的遗留请求。
1234
+ */
1235
+ registerContinuationRequest(request: CallContinuationRequest): void;
1236
+ /**
1237
+ * 消费当前 continuation request(一次性)
1238
+ *
1239
+ * 宿主(如 CallArbiter)在 onCall 返回后调用此方法,
1240
+ * 判断是否需要在同一逻辑 envelope 内启动下一个 segment。
1241
+ *
1242
+ * - 请求只能消费一次,消费后自动清除。
1243
+ * - onCall 开始时也会清理上次未消费的请求。
1244
+ *
1245
+ * @returns 当前 continuation request,如果没有则返回 null
1246
+ */
1247
+ consumeContinuationRequest(): CallContinuationRequest | null;
1054
1248
  /**
1055
1249
  * 唯一的公开入口 - 执行 Agent
1056
1250
  */
@@ -1081,13 +1275,64 @@ declare class AgentBase {
1081
1275
  * 从会话快照恢复
1082
1276
  */
1083
1277
  restoreSessionSnapshot(snapshot: AgentSessionSnapshot): Promise<this>;
1278
+ /**
1279
+ * 中断正在运行的 onCall
1280
+ * 会触发 AbortController,在下一个检查点(step 间或 tool 执行中)优雅停止
1281
+ * 返回 true 表示成功触发中断,false 表示当前没有正在运行的 call
1282
+ */
1283
+ interrupt(): boolean;
1284
+ /**
1285
+ * 当前是否正在执行 onCall
1286
+ */
1287
+ isRunning(): boolean;
1084
1288
  rollbackToCall(callIndex: number): Promise<{
1085
1289
  draftInput: string;
1086
1290
  }>;
1291
+ /**
1292
+ * 创建一个命名检查点
1293
+ *
1294
+ * 捕获当前完整 runtime snapshot 并将其与 checkpointId 关联。
1295
+ * 应在 onCall 完全退出后、由宿主(CallArbiter)的 checkpoint barrier 调用。
1296
+ *
1297
+ * @param id 全局唯一的 checkpoint ID
1298
+ * @returns 创建的 NamedCheckpoint
1299
+ */
1300
+ createNamedCheckpoint(id: string): Promise<NamedCheckpoint>;
1301
+ /**
1302
+ * 回退到命名检查点
1303
+ *
1304
+ * 恢复到指定 checkpoint 的 runtime snapshot,
1305
+ * 并剪除该 checkpoint 之后创建的所有命名检查点。
1306
+ * 应在 onCall 完全退出后、由宿主(CallArbiter)的 rollback barrier 调用。
1307
+ *
1308
+ * @param id 目标 checkpoint ID
1309
+ * @throws 如果 checkpoint 不存在
1310
+ */
1311
+ rollbackToNamedCheckpoint(id: string): Promise<void>;
1312
+ /**
1313
+ * 获取所有命名检查点(只读视图)
1314
+ */
1315
+ getNamedCheckpoints(): readonly NamedCheckpoint[];
1316
+ /**
1317
+ * 清除所有命名检查点
1318
+ *
1319
+ * 用于单 checkpoint 模式:创建新 checkpoint 前清除旧的。
1320
+ */
1321
+ clearNamedCheckpoints(): void;
1087
1322
  /**
1088
1323
  * 保存会话到持久化存储
1089
1324
  */
1090
1325
  saveSession(sessionId: string, store?: SessionStore): Promise<string>;
1326
+ /**
1327
+ * 启用 Step 级自动保存:每个 ReAct step 完成后自动将 session 快照写入磁盘。
1328
+ * 不会替换 CallFinish 后的 saveSession 调用——后者仍作为兜底全量保存。
1329
+ */
1330
+ enableStepAutoSave(sessionId: string, store: SessionStore): void;
1331
+ /**
1332
+ * 禁用 Step 级自动保存
1333
+ */
1334
+ disableStepAutoSave(): void;
1335
+ private _createStepSaveFn;
1091
1336
  /**
1092
1337
  * 从持久化存储加载会话
1093
1338
  */
@@ -1158,6 +1403,13 @@ declare class AgentBase {
1158
1403
  * 使用 Feature(链式调用)
1159
1404
  */
1160
1405
  use(feature: AgentFeature): this;
1406
+ /**
1407
+ * 彻底移除一个 Feature:移除其工具并从 features Map 中删除
1408
+ *
1409
+ * @example
1410
+ * agent.removeFeature('subagent') // 移除 SubAgentFeature
1411
+ */
1412
+ removeFeature(featureName: string): this;
1161
1413
  /**
1162
1414
  * 启用 Feature 的所有工具
1163
1415
  *
@@ -1172,6 +1424,13 @@ declare class AgentBase {
1172
1424
  * agent.disable('mcp') // 禁用 MCP 工具
1173
1425
  */
1174
1426
  disable(featureName: string): this;
1427
+ /**
1428
+ * 移除 Feature 的所有工具(从 LLM 工具列表物理移除)
1429
+ *
1430
+ * @example
1431
+ * agent.remove('mcp') // 移除 MCP 工具
1432
+ */
1433
+ remove(featureName: string): this;
1175
1434
  /**
1176
1435
  * 检查 Feature 是否启用
1177
1436
  *
@@ -1187,6 +1446,30 @@ declare class AgentBase {
1187
1446
  * 确保 Feature 工具已注册
1188
1447
  */
1189
1448
  private ensureFeatureTools;
1449
+ /**
1450
+ * 为单个 Feature 执行工具注册、onInitiate 和 hooks 收集。
1451
+ *
1452
+ * 被 ensureFeatureTools() 和 mountFeature() 共用。
1453
+ */
1454
+ private initSingleFeature;
1455
+ /**
1456
+ * 动态挂载 Feature(运行时)
1457
+ *
1458
+ * 与 use() 不同,mountFeature 会在 agent 已初始化的情况下
1459
+ * 立即对新 feature 执行工具注册、onInitiate 和 hooks 收集。
1460
+ *
1461
+ * 如果 agent 尚未初始化(未发生首次 onCall),feature 会被加入 Map,
1462
+ * 后续由 ensureFeatureTools() 统一处理。
1463
+ *
1464
+ * @example
1465
+ * await agent.mountFeature(new SomeFeature());
1466
+ */
1467
+ mountFeature(feature: AgentFeature): Promise<this>;
1468
+ /**
1469
+ * 在所有 Feature 工具注册完毕后、inspector snapshot 推送之前调用。
1470
+ * 子类可重写此方法注册额外工具(如统一代理工具覆盖同名 feature 工具)。
1471
+ */
1472
+ protected onFeatureToolsReady(): Promise<void>;
1190
1473
  /**
1191
1474
  * 收集所有 Feature 自带的 skills
1192
1475
  * 约定:Feature 目录下存在 skills/ 目录则自动发现
@@ -1485,6 +1768,7 @@ declare class MCPConnectionManager {
1485
1768
  private sendDirectRequest;
1486
1769
  private normalizeToolCallResponse;
1487
1770
  private rejectAllPendingRequests;
1771
+ private stopProcess;
1488
1772
  dispose(): Promise<void>;
1489
1773
  }
1490
1774
 
@@ -1526,6 +1810,8 @@ declare class MCPFeature implements AgentFeature {
1526
1810
  readonly description = "\u8FDE\u63A5 MCP \u670D\u52A1\u5668\u5E76\u628A\u53D1\u73B0\u5230\u7684\u8FDC\u7A0B\u80FD\u529B\u6302\u8F7D\u6210\u6807\u51C6\u5DE5\u5177\u3002";
1527
1811
  private readonly manager;
1528
1812
  private clients;
1813
+ private readonly input?;
1814
+ private readonly options;
1529
1815
  private config?;
1530
1816
  private mcpContext?;
1531
1817
  /**
@@ -1541,6 +1827,9 @@ declare class MCPFeature implements AgentFeature {
1541
1827
  */
1542
1828
  getTemplateNames(): string[];
1543
1829
  constructor(input?: MCPFeatureInput, options?: MCPFeatureOptions);
1830
+ getFeatureManifest(): FeatureManifestDefinition;
1831
+ private resolveFeatureConfig;
1832
+ private resolveRuntimeConfig;
1544
1833
  /**
1545
1834
  * 获取同步工具(无)
1546
1835
  */
@@ -1548,7 +1837,7 @@ declare class MCPFeature implements AgentFeature {
1548
1837
  /**
1549
1838
  * 获取异步工具(需要连接 MCP 服务器)
1550
1839
  */
1551
- getAsyncTools(_ctx: FeatureInitContext): Promise<Tool[]>;
1840
+ getAsyncTools(ctx: FeatureInitContext): Promise<Tool[]>;
1552
1841
  /**
1553
1842
  * 声明上下文注入器
1554
1843
  * 为所有 MCP 工具注入 _mcpContext
@@ -1672,6 +1961,8 @@ declare class AuditFeature implements AgentFeature {
1672
1961
  interface AudioFeedbackConfig {
1673
1962
  /** 音频文件路径(相对于 feature 目录或绝对路径) */
1674
1963
  audioPath?: string;
1964
+ /** 失败时的音频文件路径(留空时使用内置 error.mp3) */
1965
+ errorAudioPath?: string;
1675
1966
  /** 是否启用音频反馈(默认:true) */
1676
1967
  enabled?: boolean;
1677
1968
  /** 音量(0-1,默认:0.5) */
@@ -1692,6 +1983,27 @@ declare class AudioFeedbackFeature implements AgentFeature {
1692
1983
  private readonly runtime;
1693
1984
  private logger?;
1694
1985
  constructor(config?: AudioFeedbackConfig);
1986
+ getFeatureManifest(): FeatureManifestDefinition;
1987
+ getFlowModes(): {
1988
+ id: string;
1989
+ title: string;
1990
+ description: string;
1991
+ }[];
1992
+ getFlowVariables(): ({
1993
+ key: string;
1994
+ type: "boolean";
1995
+ title: string;
1996
+ description: string;
1997
+ resolver: () => boolean;
1998
+ } | {
1999
+ key: string;
2000
+ type: "number";
2001
+ title: string;
2002
+ description: string;
2003
+ resolver: () => number;
2004
+ })[];
2005
+ applyFlowMode(modeId: string): void;
2006
+ resetFlowModes(): void;
1695
2007
  /**
1696
2008
  * 公开 API:启用或禁用音频反馈
1697
2009
  */
@@ -1708,8 +2020,26 @@ declare class AudioFeedbackFeature implements AgentFeature {
1708
2020
  restoreState(snapshot: FeatureStateSnapshot): void;
1709
2021
  /**
1710
2022
  * 核心功能:在 call 完成时播放音频
2023
+ *
2024
+ * 根据 finishReason 区分成功 / 失败,播放不同音效:
2025
+ * - completed → 成功音
2026
+ * - interrupted / api_error / error / exception / max_steps → 失败音
2027
+ * - continuation → 不播放(call 暂停续接,非真正结束)
1711
2028
  */
1712
2029
  playAudioOnCallFinish(ctx: CallFinishContext): Promise<void>;
2030
+ /**
2031
+ * 稳健的跨平台音频播放
2032
+ *
2033
+ * 替代第三方 sound-play 库。sound-play 在 Windows 上使用
2034
+ * `Start-Sleep -s $player.NaturalDuration.TimeSpan.TotalSeconds` 来
2035
+ * 等待播放结束,但 NaturalDuration 在 MediaPlayer.Open() 的异步加载
2036
+ * 完成前会抛出 InvalidOperationException,导致 PowerShell 进程提前
2037
+ * 退出、声音被截断——表现为"有时有声音有时没有"。
2038
+ *
2039
+ * 本方法在 Windows 上使用 Dispatcher.PushFrame 消息循环正确等待
2040
+ * MediaOpened 事件,确保媒体加载完毕后再读取时长。
2041
+ */
2042
+ private _playSound;
1713
2043
  }
1714
2044
 
1715
2045
  interface MemoryFeatureConfig {
@@ -1770,6 +2100,12 @@ interface SkillMetadata {
1770
2100
  interface SkillsOptions {
1771
2101
  /** skills 目录,默认 cwd/.agentdev/skills */
1772
2102
  dir?: string;
2103
+ /** 是否扫描 cwd/.agentdev/skills,默认 true */
2104
+ scanAgentdevDir?: boolean;
2105
+ /** 是否扫描 cwd/.claude/skills,默认 false */
2106
+ scanClaudeDir?: boolean;
2107
+ /** 额外 skills 目录列表,至多 5 个 */
2108
+ extraDirs?: string[];
1773
2109
  }
1774
2110
 
1775
2111
  /**
@@ -1794,6 +2130,12 @@ interface SkillsOptions {
1794
2130
  interface SkillFeatureConfig extends SkillsOptions {
1795
2131
  /** Skills 目录路径 */
1796
2132
  dir?: string;
2133
+ /** 是否扫描 .agentdev/skills,默认 true */
2134
+ scanAgentdevDir?: boolean;
2135
+ /** 是否扫描 .claude/skills,默认 false */
2136
+ scanClaudeDir?: boolean;
2137
+ /** 额外 skills 目录列表 */
2138
+ extraDirs?: string[];
1797
2139
  }
1798
2140
  /**
1799
2141
  * Skill Feature 输入类型
@@ -1810,6 +2152,9 @@ declare class SkillFeature implements AgentFeature {
1810
2152
  private skillsDir?;
1811
2153
  private skills;
1812
2154
  private featureSkills;
2155
+ private scanAgentdevDir;
2156
+ private scanClaudeDir;
2157
+ private extraDirs;
1813
2158
  /**
1814
2159
  * 缓存包信息
1815
2160
  */
@@ -1827,6 +2172,35 @@ declare class SkillFeature implements AgentFeature {
1827
2172
  * 获取同步工具(invoke_skill)
1828
2173
  */
1829
2174
  getTools(): Tool[];
2175
+ /**
2176
+ * 向 Flow 暴露 Skills 相关变量
2177
+ */
2178
+ getFlowVariables(): ({
2179
+ key: string;
2180
+ type: string;
2181
+ title: string;
2182
+ description: string;
2183
+ resolver: () => string[];
2184
+ } | {
2185
+ key: string;
2186
+ type: string;
2187
+ title: string;
2188
+ description: string;
2189
+ resolver: () => string;
2190
+ })[];
2191
+ /**
2192
+ * 向 Flow 暴露可直接复用的节点 Prompt 模板
2193
+ */
2194
+ getFlowNodeTemplates(): {
2195
+ id: string;
2196
+ name: string;
2197
+ description: string;
2198
+ prompt: string;
2199
+ tools: {
2200
+ enable: string[];
2201
+ };
2202
+ }[];
2203
+ getFeatureManifest(): FeatureManifestDefinition;
1830
2204
  /**
1831
2205
  * 声明上下文注入器
1832
2206
  * 为 invoke_skill 工具注入 _context.skills
@@ -2292,7 +2666,15 @@ declare class QQBotFeature implements AgentFeature {
2292
2666
  /**
2293
2667
  * Shell Feature 工具定义
2294
2668
  *
2295
- * 提供 run_shell_command 工具,通过 Git Bash 执行 Shell 命令
2669
+ * 提供 bash 工具,通过 Git Bash 执行 Shell 命令,支持 AbortSignal 中断。
2670
+ *
2671
+ * 改进点(照搬 Claude Code 的优秀实践):
2672
+ * 1. 命令引用:eval + 单引号包裹,彻底解决 syntax error near unexpected token '('
2673
+ * 2. 非 -i 模式:去掉 interactive flag,消除 job control 警告
2674
+ * 3. stdin redirect:自动添加 < /dev/null 防止命令挂起
2675
+ * 4. Windows null rewrite:>nul → >/dev/null
2676
+ * 5. 动态 Git Bash 路径检测
2677
+ * 6. 输出截断:防止大输出撑爆 LLM 上下文
2296
2678
  */
2297
2679
 
2298
2680
  interface ShellExecutionResult {
@@ -2302,10 +2684,10 @@ interface ShellExecutionResult {
2302
2684
  }
2303
2685
 
2304
2686
  /**
2305
- * Shell Feature - Git Bash 命令执行工具 + 安全删除/恢复工具
2687
+ * Shell Feature - Shell 命令执行工具 + 安全删除/恢复工具
2306
2688
  *
2307
- * 通过 Git Bash 执行 Shell 命令,description 从内部配置加载
2308
- * 提供安全删除、列表和恢复功能
2689
+ * 支持 Git Bash PowerShell 两种 Shell 环境。
2690
+ * 根据用户配置和运行时探测结果,条件注册 Bash 和/或 PowerShell 工具。
2309
2691
  *
2310
2692
  * @example
2311
2693
  * ```typescript
@@ -2326,14 +2708,20 @@ declare class ShellFeature implements AgentFeature {
2326
2708
  readonly name = "shell";
2327
2709
  readonly dependencies: string[];
2328
2710
  readonly source: string;
2329
- readonly description = "\u63D0\u4F9B bash \u6267\u884C\u80FD\u529B\uFF0C\u4EE5\u53CA\u5B89\u5168\u5220\u9664\u3001\u6062\u590D\u548C\u67E5\u770B\u5783\u573E\u6876\u5DE5\u5177\u3002";
2711
+ readonly description = "\u63D0\u4F9B Bash/PowerShell \u547D\u4EE4\u6267\u884C\u80FD\u529B\uFF0C\u4EE5\u53CA\u5B89\u5168\u5220\u9664\u3001\u6062\u590D\u548C\u67E5\u770B\u5783\u573E\u6876\u5DE5\u5177\u3002";
2330
2712
  private bashDescription?;
2713
+ private powershellDescription?;
2331
2714
  private _packageInfo;
2332
2715
  private readonly workspaceDir;
2333
2716
  private readonly workdir;
2334
2717
  private readonly resourceRoot;
2335
2718
  constructor(config?: ShellFeatureConfig);
2336
2719
  run(command: string): Promise<ShellExecutionResult>;
2720
+ getFeatureManifest(): FeatureManifestDefinition;
2721
+ /**
2722
+ * 解析 featureConfig 为结构化配置
2723
+ */
2724
+ private resolveShellConfig;
2337
2725
  /**
2338
2726
  * 获取包信息(统一打包方案)
2339
2727
  */
@@ -2347,9 +2735,9 @@ declare class ShellFeature implements AgentFeature {
2347
2735
  */
2348
2736
  getTools(): Tool[];
2349
2737
  /**
2350
- * 获取异步工具(bash 工具,加载 description)
2738
+ * 获取异步工具(bash/powershell 工具,条件注册)
2351
2739
  */
2352
- getAsyncTools(_ctx: FeatureInitContext): Promise<Tool[]>;
2740
+ getAsyncTools(ctx: FeatureInitContext): Promise<Tool[]>;
2353
2741
  }
2354
2742
 
2355
2743
  /**
@@ -2968,6 +3356,8 @@ declare class UserInputFeature implements AgentFeature {
2968
3356
  */
2969
3357
  getUserInput(prompt?: string, timeout?: number): Promise<string>;
2970
3358
  getUserInputEvent(prompt?: string, timeout?: number, actions?: UserInputAction[]): Promise<UserInputResponse>;
3359
+ requestUserChoices(prompt: string, questions: UserInputQuestion[], timeout?: number): Promise<UserInputChoiceAnswer[]>;
3360
+ private normalizeChoiceQuestions;
2971
3361
  getTools(): Tool[];
2972
3362
  onInitiate(_ctx: FeatureInitContext): Promise<void>;
2973
3363
  onDestroy(_ctx: FeatureContext): Promise<void>;
@@ -3499,6 +3889,117 @@ declare class WebSearchFeature implements AgentFeature {
3499
3889
  getTemplateNames(): string[];
3500
3890
  }
3501
3891
 
3892
+ interface DiffStats {
3893
+ filesChanged: string[];
3894
+ insertions: number;
3895
+ deletions: number;
3896
+ }
3897
+
3898
+ /**
3899
+ * FileHistoryFeature - 文件修改历史追踪与回退
3900
+ *
3901
+ * 独立 Feature,无侵入地接入 AgentDev 的 checkpoint/rollback 体系:
3902
+ *
3903
+ * - @ToolUse 反向钩子:在 write/edit 执行前自动备份文件
3904
+ * - @CallStart 反向钩子:在每轮用户输入时创建快照
3905
+ * - captureState/restoreState:与 Agent 的 CallRollback 集成(仅恢复内存状态)
3906
+ * - rewindToSnapshot / rewindToLastSnapshot:用户显式触发的文件回退
3907
+ *
3908
+ * 文件回退是独立于对话回退的操作(与 Claude Code 的设计一致),
3909
+ * 用户可以选择"仅回退代码"/"仅回退对话"/"两者都回退"。
3910
+ *
3911
+ * 使用方式(消费端,如 Claw):
3912
+ * const fh = agent.features?.get('file-history');
3913
+ * if (fh) {
3914
+ * const snapshots = fh.getSnapshotList();
3915
+ * await fh.rewindToSnapshot(selectedId);
3916
+ * }
3917
+ */
3918
+
3919
+ interface FileHistoryFeatureConfig {
3920
+ /** 覆盖工作区目录,默认 process.cwd() */
3921
+ workspaceDir?: string;
3922
+ }
3923
+ type SnapshotInfo = {
3924
+ id: number;
3925
+ timestamp: number;
3926
+ trackedFileCount: number;
3927
+ };
3928
+ declare class FileHistoryFeature implements AgentFeature {
3929
+ readonly name = "file-history";
3930
+ readonly dependencies: string[];
3931
+ readonly source: string;
3932
+ readonly description = "\u8FFD\u8E2A\u6587\u4EF6\u4FEE\u6539\u5386\u53F2\uFF0C\u652F\u6301\u4EE3\u7801\u56DE\u9000\u5230\u4EFB\u610F\u8F6E\u6B21\u7684\u72B6\u6001\u3002";
3933
+ private _packageInfo;
3934
+ private logger;
3935
+ private state;
3936
+ private readonly workspaceDir;
3937
+ constructor(config?: FileHistoryFeatureConfig);
3938
+ getPackageInfo(): PackageInfo | null;
3939
+ onInitiate(ctx: FeatureInitContext): Promise<void>;
3940
+ onDestroy(_ctx: FeatureContext): Promise<void>;
3941
+ /**
3942
+ * @ToolUse 反向钩子:在 write/edit 工具执行前备份文件
3943
+ *
3944
+ * 在所有 Feature 的 @ToolUse 钩子中,本钩子只关注 write/edit 两个工具,
3945
+ * 其余一律放行 (Decision.Continue)。
3946
+ */
3947
+ trackFileEdits(ctx: ToolContext): Promise<DecisionResult>;
3948
+ /**
3949
+ * @CallStart 反向钩子:每轮用户输入时创建文件快照
3950
+ *
3951
+ * 第一次 CallStart 创建空快照,后续 CallStart 检测已追踪文件是否有变化,
3952
+ * 有变化的创建新版本备份。
3953
+ */
3954
+ onCallStart(_ctx: any): Promise<void>;
3955
+ /**
3956
+ * 捕获当前文件历史状态(纯内存,不碰磁盘)
3957
+ *
3958
+ * 由 Agent 的 commitCallCheckpoint 调用。
3959
+ * 保存快照元数据,使得 rollbackToCall 时能恢复到对应的文件历史状态。
3960
+ */
3961
+ captureState(): FeatureStateSnapshot;
3962
+ /**
3963
+ * 恢复文件历史状态(仅恢复内存,不恢复磁盘文件)
3964
+ *
3965
+ * 在三种场景下被调用:step rollback、call rollback、session load。
3966
+ * 这里只恢复内存中的快照索引,不做文件回退。
3967
+ * 文件回退由用户显式调用 rewindToSnapshot / rewindToLastSnapshot 触发。
3968
+ */
3969
+ restoreState(snapshot: FeatureStateSnapshot): void;
3970
+ /**
3971
+ * 获取快照列表(供 UI 展示)
3972
+ */
3973
+ getSnapshotList(): SnapshotInfo[];
3974
+ /**
3975
+ * 获取当前追踪的文件数量
3976
+ */
3977
+ getTrackedFileCount(): number;
3978
+ /**
3979
+ * 获取快照数量
3980
+ */
3981
+ getSnapshotCount(): number;
3982
+ /**
3983
+ * 回退文件到指定快照
3984
+ *
3985
+ * @returns 被修改的文件路径列表
3986
+ */
3987
+ rewindToSnapshot(snapshotId: number): Promise<string[]>;
3988
+ /**
3989
+ * 回退文件到当前内存状态的最后一个快照
3990
+ *
3991
+ * 典型用法:先 rollbackToCall 恢复对话 + 内存状态,再调此方法恢复文件。
3992
+ * await agent.rollbackToCall(targetCallIndex)
3993
+ * const fh = agent.features?.get('file-history')
3994
+ * await fh?.rewindToLastSnapshot()
3995
+ */
3996
+ rewindToLastSnapshot(): Promise<string[]>;
3997
+ /**
3998
+ * 计算回退到指定快照的 diff 统计(预览用,不修改文件)
3999
+ */
4000
+ getDiffStats(snapshotId: number): Promise<DiffStats>;
4001
+ }
4002
+
3502
4003
  interface OpencodeBasicFeatureConfig {
3503
4004
  workspaceDir?: string;
3504
4005
  }
@@ -3613,6 +4114,130 @@ declare class ExampleFeature implements AgentFeature {
3613
4114
  handleStepFinish(ctx: StepFinishDecisionContext): Promise<typeof Decision.Continue>;
3614
4115
  }
3615
4116
 
4117
+ /**
4118
+ * LSP Feature 类型定义
4119
+ */
4120
+ /**
4121
+ * LSP Server handle returned by spawn functions
4122
+ */
4123
+ interface LspServerHandle {
4124
+ process: any;
4125
+ initialization?: Record<string, any>;
4126
+ }
4127
+ /**
4128
+ * Configuration for a single LSP server
4129
+ */
4130
+ interface LspServerConfig {
4131
+ disabled?: boolean;
4132
+ binary?: string;
4133
+ /** Launch mode override */
4134
+ mode?: 'exec' | 'runtime';
4135
+ /** Runtime type, only meaningful when mode='runtime' */
4136
+ runtime?: 'nodejs' | 'uv';
4137
+ /** npm package name for nodejs runtime (npx <package>) */
4138
+ package?: string;
4139
+ /** Package name for uv runtime (uv tool run <package>), if different */
4140
+ uvPackage?: string;
4141
+ /** Additional arguments passed to the server */
4142
+ args?: string[];
4143
+ command?: string[];
4144
+ extensions?: string[];
4145
+ env?: Record<string, string>;
4146
+ initialization?: Record<string, any>;
4147
+ }
4148
+ /**
4149
+ * LSP Feature configuration
4150
+ */
4151
+ interface LspFeatureConfig {
4152
+ workdir?: string;
4153
+ binDir?: string;
4154
+ disableDownload?: boolean;
4155
+ /** Shared runtime binary paths */
4156
+ runtimes?: {
4157
+ nodejs?: string;
4158
+ uv?: string;
4159
+ };
4160
+ servers?: Record<string, LspServerConfig>;
4161
+ }
4162
+
4163
+ /**
4164
+ * LSP Client - 通过 JSON-RPC 与 LSP 服务器通信
4165
+ */
4166
+
4167
+ /**
4168
+ * LSP Client - 处理与 LSP 服务器的 JSON-RPC 通信
4169
+ */
4170
+ declare class LspClient extends EventEmitter {
4171
+ private serverID;
4172
+ private handle;
4173
+ private root;
4174
+ private logger;
4175
+ private connection;
4176
+ private diagnostics;
4177
+ private files;
4178
+ constructor(serverID: string, handle: LspServerHandle, root: string, logger: {
4179
+ info: (msg: string, data?: any) => void;
4180
+ error: (msg: string, data?: any) => void;
4181
+ });
4182
+ private setupHandlers;
4183
+ initialize(): Promise<void>;
4184
+ get serverId(): string;
4185
+ get clientRoot(): string;
4186
+ getDiagnostics(): Map<string, Diagnostic[]>;
4187
+ notifyOpen(filePath: string): Promise<void>;
4188
+ waitForDiagnostics(filePath: string): Promise<void>;
4189
+ definition(filePath: string, line: number, character: number): Promise<unknown>;
4190
+ references(filePath: string, line: number, character: number): Promise<unknown>;
4191
+ hover(filePath: string, line: number, character: number): Promise<unknown>;
4192
+ documentSymbol(uri: string): Promise<unknown>;
4193
+ workspaceSymbol(query: string): Promise<unknown>;
4194
+ implementation(filePath: string, line: number, character: number): Promise<unknown>;
4195
+ prepareCallHierarchy(filePath: string, line: number, character: number): Promise<unknown>;
4196
+ incomingCalls(filePath: string, line: number, character: number): Promise<unknown>;
4197
+ outgoingCalls(filePath: string, line: number, character: number): Promise<unknown>;
4198
+ shutdown(): Promise<void>;
4199
+ }
4200
+
4201
+ /**
4202
+ * LSP Feature - Language Server Protocol 代码智能
4203
+ *
4204
+ * 为 AI agent 提供代码智能能力:跳转定义、查找引用、悬停提示等
4205
+ * 支持 14 种语言的 LSP 服务器,每个支持 exec / runtime 两种启动模式
4206
+ */
4207
+
4208
+ declare class LspFeature implements AgentFeature {
4209
+ readonly name = "lsp";
4210
+ readonly dependencies: string[];
4211
+ readonly source: string;
4212
+ readonly description = "LSP (Language Server Protocol) - \u63D0\u4F9B\u4EE3\u7801\u667A\u80FD\u80FD\u529B\uFF1A\u8DF3\u8F6C\u5B9A\u4E49\u3001\u67E5\u627E\u5F15\u7528\u3001\u60AC\u505C\u63D0\u793A\u7B49";
4213
+ private config;
4214
+ private _packageInfo;
4215
+ private logger;
4216
+ private clients;
4217
+ private spawning;
4218
+ private broken;
4219
+ constructor(config?: LspFeatureConfig);
4220
+ getPackageInfo(): PackageInfo | null;
4221
+ getTemplateNames(): string[];
4222
+ getTools(): Tool[];
4223
+ getAsyncTools(_ctx: FeatureInitContext): Promise<Tool[]>;
4224
+ onInitiate(ctx: FeatureInitContext): Promise<void>;
4225
+ onDestroy(): Promise<void>;
4226
+ getFeatureManifest(): FeatureManifestDefinition;
4227
+ captureState(): {
4228
+ activeServerIds: string[];
4229
+ };
4230
+ restoreState(_state: any): void;
4231
+ getWorkdir(): string;
4232
+ hasServer(file: string): Promise<boolean>;
4233
+ touchFile(file: string): Promise<void>;
4234
+ executeOnFile<T>(file: string, fn: (client: LspClient) => Promise<T>): Promise<T[]>;
4235
+ executeAll<T>(fn: (client: LspClient) => Promise<T>): Promise<T[]>;
4236
+ private getClientsForFile;
4237
+ private spawnServer;
4238
+ private shutdownAll;
4239
+ }
4240
+
3616
4241
  /**
3617
4242
  * 配置加载
3618
4243
  * 从 config 目录读取 JSON 配置文件
@@ -3621,6 +4246,17 @@ declare class ExampleFeature implements AgentFeature {
3621
4246
  * - loadConfig() - 异步加载(用于特殊场景)
3622
4247
  * - loadConfigSync() - 同步加载(推荐,用于 Agent 构造)
3623
4248
  */
4249
+ /**
4250
+ * 自定义请求头条目
4251
+ * - valueMode 'static': 使用 value 原样
4252
+ * - valueMode 'uuid': 每次请求生成新的 UUID v4
4253
+ * - valueMode 'random': 每次请求生成新的随机数
4254
+ */
4255
+ interface CustomHeaderEntry {
4256
+ key: string;
4257
+ value: string;
4258
+ valueMode?: 'static' | 'uuid' | 'random';
4259
+ }
3624
4260
  /**
3625
4261
  * 统一配置类型
3626
4262
  * 字段允许冗余,各 LLM 实现只取自己需要的
@@ -3634,6 +4270,10 @@ interface ModelConfig {
3634
4270
  thinkingBudgetTokens?: number;
3635
4271
  thinkingKeepTurns?: number;
3636
4272
  providerOptions?: Record<string, unknown>;
4273
+ /** 追加到每次 LLM API 请求的自定义请求头 */
4274
+ customHeaders?: CustomHeaderEntry[];
4275
+ /** OpenAI 专用接口面:chat / responses */
4276
+ apiSurface?: 'chat' | 'responses';
3637
4277
  region?: string;
3638
4278
  projectId?: string;
3639
4279
  }
@@ -3709,6 +4349,10 @@ interface BasicAgentConfig {
3709
4349
  tools?: Tool[];
3710
4350
  /** Skills 目录(可选,默认使用 .agentdev/skills) */
3711
4351
  skillsDir?: string;
4352
+ /** SkillFeature 完整配置(可选,覆盖 skillsDir) */
4353
+ skillConfig?: SkillFeatureConfig;
4354
+ /** Feature 特定配置(可选) */
4355
+ features?: AgentConfig['features'];
3712
4356
  /** 调试器和模板解析使用的项目根目录 */
3713
4357
  projectRoot?: string;
3714
4358
  /** 工具默认操作的工作目录 */
@@ -3888,13 +4532,19 @@ interface CompiledAnthropicRequest {
3888
4532
  }
3889
4533
  declare class AnthropicLLM implements LLMClient {
3890
4534
  private readonly apiKey;
3891
- private readonly modelName;
4535
+ private readonly _modelName;
3892
4536
  private readonly baseUrl;
3893
4537
  private readonly maxTokens;
3894
4538
  private readonly thinkingBudgetTokens?;
3895
4539
  private readonly thinkingKeepTurns;
3896
- constructor(apiKey: string, modelName?: string, baseUrl?: string, maxTokens?: number, thinkingBudgetTokens?: number | undefined, thinkingKeepTurns?: number);
3897
- chat(messages: Message[], tools: Tool[]): Promise<LLMResponse>;
4540
+ private readonly customHeaders?;
4541
+ private initPromise;
4542
+ /** 返回当前 LLM 实例使用的模型名 */
4543
+ get modelName(): string;
4544
+ constructor(apiKey: string, _modelName?: string, baseUrl?: string, maxTokens?: number, thinkingBudgetTokens?: number | undefined, thinkingKeepTurns?: number, customHeaders?: CustomHeaderEntry[] | undefined);
4545
+ chat(messages: Message[], tools: Tool[], options?: {
4546
+ signal?: AbortSignal;
4547
+ }): Promise<LLMResponse>;
3898
4548
  }
3899
4549
  declare function compileContextForAnthropic(messages: Message[], tools: Tool[]): CompiledAnthropicRequest;
3900
4550
  declare function createAnthropicLLM(config: AgentConfigFile): AnthropicLLM;
@@ -3908,14 +4558,20 @@ declare function createAnthropicLLM(apiKey: string, modelName: string, baseUrl?:
3908
4558
 
3909
4559
  declare class OpenAILLM implements LLMClient {
3910
4560
  private client;
3911
- private modelName;
4561
+ private _modelName;
3912
4562
  private maxTokens?;
3913
4563
  private providerOptions?;
3914
- constructor(apiKey: string, modelName?: string, baseUrl?: string, maxTokens?: number, providerOptions?: Record<string, unknown>);
4564
+ private customHeaders?;
4565
+ private initPromise;
4566
+ /** 返回当前 LLM 实例使用的模型名 */
4567
+ get modelName(): string;
4568
+ constructor(apiKey: string, modelName?: string, baseUrl?: string, maxTokens?: number, providerOptions?: Record<string, unknown>, customHeaders?: CustomHeaderEntry[]);
3915
4569
  /**
3916
- * 聊天 - 核心方法(内部使用流式处理)
4570
+ * 聊天 - 核心方法(内部使用流式处理,带重试)
3917
4571
  */
3918
- chat(messages: Message[], tools: Tool[]): Promise<LLMResponse>;
4572
+ chat(messages: Message[], tools: Tool[], options?: {
4573
+ signal?: AbortSignal;
4574
+ }): Promise<LLMResponse>;
3919
4575
  }
3920
4576
 
3921
4577
  /**
@@ -3941,6 +4597,53 @@ declare function createOpenAILLM(config: AgentConfigFile): OpenAILLM;
3941
4597
  declare function createOpenAILLM(modelConfig: ModelConfig): OpenAILLM;
3942
4598
  declare function createOpenAILLM(apiKey: string, modelName: string, baseUrl?: string): OpenAILLM;
3943
4599
 
4600
+ /**
4601
+ * OpenAI Responses LLM 适配器
4602
+ *
4603
+ * 只负责把框架的 Message / Tool 编译为 Responses 输入,
4604
+ * 再把 Responses 输出收敛回 LLMResponse。
4605
+ */
4606
+
4607
+ type ResponsesRequest = {
4608
+ model: string;
4609
+ input: any[];
4610
+ tools?: Array<Record<string, unknown>>;
4611
+ max_output_tokens?: number;
4612
+ parallel_tool_calls?: boolean;
4613
+ reasoning?: Record<string, unknown>;
4614
+ previous_response_id?: string;
4615
+ store?: boolean;
4616
+ text?: Record<string, unknown>;
4617
+ include?: Array<string>;
4618
+ [key: string]: unknown;
4619
+ };
4620
+ declare class OpenAIResponsesLLM implements LLMClient {
4621
+ private client;
4622
+ private _modelName;
4623
+ private maxTokens?;
4624
+ private thinkingBudgetTokens?;
4625
+ private providerOptions?;
4626
+ private customHeaders?;
4627
+ private initPromise;
4628
+ /** 返回当前 LLM 实例使用的模型名 */
4629
+ get modelName(): string;
4630
+ constructor(apiKey: string, modelName?: string, baseUrl?: string, maxTokens?: number, thinkingBudgetTokens?: number, providerOptions?: Record<string, unknown>, customHeaders?: CustomHeaderEntry[]);
4631
+ chat(messages: Message[], tools: Tool[], options?: {
4632
+ signal?: AbortSignal;
4633
+ }): Promise<LLMResponse>;
4634
+ private createResponsesCompletion;
4635
+ }
4636
+ interface CompileOpenAIResponsesOptions {
4637
+ modelName?: string;
4638
+ maxTokens?: number;
4639
+ thinkingBudgetTokens?: number;
4640
+ providerOptions?: Record<string, unknown>;
4641
+ }
4642
+ declare function compileContextForOpenAIResponses(messages: Message[], tools: Tool[], options?: CompileOpenAIResponsesOptions): ResponsesRequest;
4643
+ declare function createOpenAIResponsesLLM(config: AgentConfigFile): OpenAIResponsesLLM;
4644
+ declare function createOpenAIResponsesLLM(modelConfig: ModelConfig): OpenAIResponsesLLM;
4645
+ declare function createOpenAIResponsesLLM(apiKey: string, modelName: string, baseUrl?: string): OpenAIResponsesLLM;
4646
+
3944
4647
  declare function createLLM(config: AgentConfigFile): LLMClient;
3945
4648
  declare function createLLM(modelConfig: ModelConfig): LLMClient;
3946
4649
  declare function createLLM(apiKey: string, modelName: string, provider?: string, baseUrl?: string): LLMClient;
@@ -4054,6 +4757,27 @@ declare class ViewerWorker {
4054
4757
  * 提交用户输入
4055
4758
  */
4056
4759
  private handlePostInput;
4760
+ /**
4761
+ * 排队用户输入(运行期间提交的消息)
4762
+ */
4763
+ private handleQueueInput;
4764
+ /**
4765
+ * 获取排队中的用户输入
4766
+ */
4767
+ private handleGetQueuedInputs;
4768
+ /**
4769
+ * 消费第一条排队消息
4770
+ */
4771
+ private handleDequeueInput;
4772
+ private handleConsumeQueuedInput;
4773
+ /**
4774
+ * 中断正在运行的 Agent
4775
+ */
4776
+ private handleInterrupt;
4777
+ /**
4778
+ * 查询 Agent 是否正在运行
4779
+ */
4780
+ private handleGetRunning;
4057
4781
  /**
4058
4782
  * 获取或创建会话
4059
4783
  */
@@ -4087,6 +4811,12 @@ declare class ViewerWorker {
4087
4811
  */
4088
4812
  handlePushMessages(msg: any): void;
4089
4813
  private createEmptyOverview;
4814
+ private createEmptyRuntimeState;
4815
+ private cloneRuntimeState;
4816
+ private getRuntimeStageFromLLMPhase;
4817
+ private updateRuntimeStage;
4818
+ private getSessionRuntimeState;
4819
+ private getMergedOverview;
4090
4820
  /**
4091
4821
  * 检查消息是否发生变化
4092
4822
  */
@@ -4355,6 +5085,8 @@ declare function createListRenderer<T = any>(config: Omit<DataSourceRenderer<T>,
4355
5085
  declare function discover(options?: SkillsOptions): Promise<SkillMetadata[]>;
4356
5086
 
4357
5087
  interface LoadAllMCPConfigsOptions {
5088
+ loadDefaultDir?: boolean;
5089
+ extraConfigFiles?: string[];
4358
5090
  excludeServers?: string[];
4359
5091
  }
4360
5092
  declare function getDefaultMCPConfigDir(rootDir?: string): string;
@@ -4398,4 +5130,4 @@ declare function renderMCPToolCall(serverName: string, toolName: string, args: R
4398
5130
  */
4399
5131
  declare function renderMCPToolResult(result: any, success?: boolean): string;
4400
5132
 
4401
- export { AgentBase as Agent, AgentConfig, type AgentConfigFile, type AgentFeature, AgentInfo, type AgentInitiateContext, AgentPool, AgentSession, type AgentSessionSnapshot, AnthropicLLM, AudioFeedbackFeature, AuditFeature, type AuditFeatureConfig, BasicAgent, type BasicAgentConfig, CallFinish, type CallFinishContext, CallStart, type CallStartContext, type CaptureResult, Context, type ContextInjector, type ContextSnapshot, DataSourceRegistry, type DataSourceRenderer, type DebugCapabilities, DebugHub, Decision, type DecisionResult, ExampleFeature, type ExampleFeatureConfig, type ExampleFeatureRuntimeState, type ExampleFeatureSnapshot, ExplorerAgent, type ExplorerAgentConfig, type SystemContext as ExplorerSystemContext, type FeatureContext, type FeatureInitContext, type FeatureStateSnapshot, FileSessionStore, type HookResult, InlineRenderTemplate, type KnownUser, LLMClient, LLMResponse, type LoadAllMCPConfigsOptions, type Logger, type LoggerBindings, MCPClient, type MCPClientConfig, type MCPConfig, type MCPConfigMountOptions, type MCPConnectionInfo, MCPConnectionManager, MCPConnectionState, type MCPDiscoveredTool, type MCPDiscoveredToolSet, MCPFeature, type MCPFeatureOptions, type MCPHTTPConfig, type MCPMountedConfigResult, type MCPMountedToolSet, type MCPSSEConfig, type MCPServerConfig, type MCPSstdioConfig, type MCPStatistics, MCPToolAdapter, type MCPToolAdapterConfig, type MCPToolCreationOptions, type MCPToolDiscoveryOptions, type MCPToolManagementOptions, type MCPToolPatch, type MCPToolResult, MCP_RENDER_TEMPLATES, MemoryFeature, type MemoryFeatureConfig, Message, MessageRole, type ModelConfig, OpenAILLM, OpencodeBasicFeature, type PackageInfo, PlaceholderContext, PlaceholderResolver, PluginCompatFeature, QQBotFeature, type QQBotFeatureConfig, type QQBotSendOptions, type QQBotSendResult, type SessionStore, ShellFeature, SkillFeature, type SkillFeatureConfig, type SkillMetadata, type SkillsOptions, StepFinish, type StepFinishedContext, StepStart, type StepStartContext, SubAgentFeature, type SystemContext$1 as SystemContext, TTSFeature, type TTSFeatureConfig, type TTSResult, type TTSState, type TaskStatus, TemplateLoader, TemplateSource, TodoFeature, type TodoFeatureConfig, type TodoTask, type TodoTaskSummary, Tool, ToolCall, type ToolContext, type ToolContextValue, ToolFinished, ToolRegistry, ToolRenderConfig, type ToolResult, ToolUse, UserInputFeature, type UserInputFeatureConfig, ViewerWorker, VisualFeature, type VisualFeatureConfig, type VisualUnderstandingResult, WebSearchFeature, type WebSearchFeatureConfig, type WindowInfo, assistant, compileContextForAnthropic, createAnthropicLLM, createDefaultMCPToolName, createLLM, createListRenderer, createLogger, createMCPTool, createMCPToolAdapters, createMCPToolsFromClient, createManagedMCPToolsFromClient, createMessage, createOpenAILLM, createTool, discover, discoverMCPTools, discoverManagedMCPTools, getClawRuntimeUrl, getDebugCapabilities, getDefaultMCPConfigDir, getDefaultSessionStore, getMCPRenderTemplate, getPackageInfoFromSource, installConsoleBridge, listConfigs, loadAllMCPConfigs, loadConfig, loadConfigSync, loadMCPConfigFromInput, mountMCPToolsFromConfig, renderMCPToolCall, renderMCPToolResult, resolveDebugTransportMode, runWithLogScope, system, toolResult, user };
5133
+ export { AgentBase as Agent, AgentConfig, type AgentConfigFile, type AgentFeature, AgentInfo, type AgentInitiateContext, AgentPool, AgentSession, type AgentSessionSnapshot, AnthropicLLM, AudioFeedbackFeature, AuditFeature, type AuditFeatureConfig, BasicAgent, type BasicAgentConfig, type CallContinuationRequest, CallFinish, type CallFinishContext, type CallFinishReason, CallStart, type CallStartContext, type CaptureResult, type CheckpointContinuationRequest, Context, type ContextInjector, type ContextSnapshot, DataSourceRegistry, type DataSourceRenderer, type DebugCapabilities, DebugHub, Decision, type DecisionResult, ExampleFeature, type ExampleFeatureConfig, type ExampleFeatureRuntimeState, type ExampleFeatureSnapshot, ExplorerAgent, type ExplorerAgentConfig, type SystemContext as ExplorerSystemContext, type FeatureContext, type FeatureInitContext, type FeatureManifestDefinition, type FeatureManifestSettingProperty, type FeatureStateSnapshot, FileHistoryFeature, type FileHistoryFeatureConfig, FileSessionStore, type HookResult, InlineRenderTemplate, type KnownUser, LLMClient, LLMResponse, type LoadAllMCPConfigsOptions, type Logger, type LoggerBindings, LspFeature, type LspFeatureConfig, 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, type NamedCheckpoint, OpenAILLM, OpenAIResponsesLLM, OpencodeBasicFeature, type PackageInfo, PlaceholderContext, PlaceholderResolver, PluginCompatFeature, QQBotFeature, type QQBotFeatureConfig, type QQBotSendOptions, type QQBotSendResult, type RollbackContinuationRequest, type SessionStore, ShellFeature, SkillFeature, type SkillFeatureConfig, type SkillMetadata, type SkillsOptions, type SnapshotInfo, 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, compileContextForOpenAIResponses, createAnthropicLLM, createDefaultMCPToolName, createLLM, createListRenderer, createLogger, createMCPTool, createMCPToolAdapters, createMCPToolsFromClient, createManagedMCPToolsFromClient, createMessage, createOpenAILLM, createOpenAIResponsesLLM, createTool, discover, discoverMCPTools, discoverManagedMCPTools, getClawRuntimeUrl, getDebugCapabilities, getDefaultMCPConfigDir, getDefaultSessionStore, getMCPRenderTemplate, getPackageInfoFromSource, installConsoleBridge, listConfigs, loadAllMCPConfigs, loadConfig, loadConfigSync, loadMCPConfigFromInput, mountMCPToolsFromConfig, renderMCPToolCall, renderMCPToolResult, resolveDebugTransportMode, runWithLogScope, system, toolResult, user };