agentdev 0.1.0 → 0.1.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 (92) hide show
  1. package/dist/BasicAgent-UDSHJE5H.js +2 -2
  2. package/dist/{ExplorerAgent-X6QECX65.js → ExplorerAgent-BITN4IBW.js} +3 -3
  3. package/dist/{chunk-N7J76R5P.js → chunk-4FBF65TC.js} +2 -2
  4. package/dist/{chunk-DI5EGMGG.js → chunk-XCJOXCJ4.js} +2 -2
  5. package/dist/{chunk-XAJ6L4GA.js → chunk-XE5IEUPW.js} +2 -2
  6. package/dist/features/example-feature/templates/example-tool.render.d.ts +3 -0
  7. package/dist/features/example-feature/templates/example-tool.render.js +20 -0
  8. package/dist/features/example-feature/templates/example-tool.render.js.map +1 -0
  9. package/dist/features/mcp/templates/mcp-tool.render.d.ts +12 -0
  10. package/dist/features/mcp/templates/mcp-tool.render.js +37 -0
  11. package/dist/features/mcp/templates/mcp-tool.render.js.map +1 -0
  12. package/dist/features/opencode-basic/templates/edit.render.d.ts +12 -0
  13. package/dist/features/opencode-basic/templates/edit.render.js +44 -0
  14. package/dist/features/opencode-basic/templates/edit.render.js.map +1 -0
  15. package/dist/features/opencode-basic/templates/glob.render.d.ts +13 -0
  16. package/dist/features/opencode-basic/templates/glob.render.js +44 -0
  17. package/dist/features/opencode-basic/templates/glob.render.js.map +1 -0
  18. package/dist/features/opencode-basic/templates/grep.render.d.ts +13 -0
  19. package/dist/features/opencode-basic/templates/grep.render.js +67 -0
  20. package/dist/features/opencode-basic/templates/grep.render.js.map +1 -0
  21. package/dist/features/opencode-basic/templates/ls.render.d.ts +12 -0
  22. package/dist/features/opencode-basic/templates/ls.render.js +35 -0
  23. package/dist/features/opencode-basic/templates/ls.render.js.map +1 -0
  24. package/dist/features/opencode-basic/templates/read.render.d.ts +13 -0
  25. package/dist/features/opencode-basic/templates/read.render.js +83 -0
  26. package/dist/features/opencode-basic/templates/read.render.js.map +1 -0
  27. package/dist/features/opencode-basic/templates/write.render.d.ts +13 -0
  28. package/dist/features/opencode-basic/templates/write.render.js +44 -0
  29. package/dist/features/opencode-basic/templates/write.render.js.map +1 -0
  30. package/dist/features/shell/templates/bash.render.d.ts +12 -0
  31. package/dist/features/shell/templates/bash.render.js +71 -0
  32. package/dist/features/shell/templates/bash.render.js.map +1 -0
  33. package/dist/features/shell/templates/trash-delete.render.d.ts +12 -0
  34. package/dist/features/shell/templates/trash-delete.render.js +61 -0
  35. package/dist/features/shell/templates/trash-delete.render.js.map +1 -0
  36. package/dist/features/shell/templates/trash-list.render.d.ts +12 -0
  37. package/dist/features/shell/templates/trash-list.render.js +84 -0
  38. package/dist/features/shell/templates/trash-list.render.js.map +1 -0
  39. package/dist/features/shell/templates/trash-restore.render.d.ts +12 -0
  40. package/dist/features/shell/templates/trash-restore.render.js +77 -0
  41. package/dist/features/shell/templates/trash-restore.render.js.map +1 -0
  42. package/dist/features/skill/templates/skill.render.d.ts +13 -0
  43. package/dist/features/skill/templates/skill.render.js +33 -0
  44. package/dist/features/skill/templates/skill.render.js.map +1 -0
  45. package/dist/features/subagent/templates/agent-close.render.d.ts +9 -0
  46. package/dist/features/subagent/templates/agent-close.render.js +29 -0
  47. package/dist/features/subagent/templates/agent-close.render.js.map +1 -0
  48. package/dist/features/subagent/templates/agent-list.render.d.ts +9 -0
  49. package/dist/features/subagent/templates/agent-list.render.js +23 -0
  50. package/dist/features/subagent/templates/agent-list.render.js.map +1 -0
  51. package/dist/features/subagent/templates/agent-send.render.d.ts +9 -0
  52. package/dist/features/subagent/templates/agent-send.render.js +37 -0
  53. package/dist/features/subagent/templates/agent-send.render.js.map +1 -0
  54. package/dist/features/subagent/templates/agent-spawn.render.d.ts +9 -0
  55. package/dist/features/subagent/templates/agent-spawn.render.js +38 -0
  56. package/dist/features/subagent/templates/agent-spawn.render.js.map +1 -0
  57. package/dist/features/subagent/templates/wait.render.d.ts +9 -0
  58. package/dist/features/subagent/templates/wait.render.js +29 -0
  59. package/dist/features/subagent/templates/wait.render.js.map +1 -0
  60. package/dist/features/todo/templates/task-clear.render.d.ts +9 -0
  61. package/dist/features/todo/templates/task-clear.render.js +32 -0
  62. package/dist/features/todo/templates/task-clear.render.js.map +1 -0
  63. package/dist/features/todo/templates/task-create.render.d.ts +9 -0
  64. package/dist/features/todo/templates/task-create.render.js +56 -0
  65. package/dist/features/todo/templates/task-create.render.js.map +1 -0
  66. package/dist/features/todo/templates/task-get.render.d.ts +9 -0
  67. package/dist/features/todo/templates/task-get.render.js +60 -0
  68. package/dist/features/todo/templates/task-get.render.js.map +1 -0
  69. package/dist/features/todo/templates/task-list.render.d.ts +9 -0
  70. package/dist/features/todo/templates/task-list.render.js +72 -0
  71. package/dist/features/todo/templates/task-list.render.js.map +1 -0
  72. package/dist/features/todo/templates/task-update.render.d.ts +9 -0
  73. package/dist/features/todo/templates/task-update.render.js +58 -0
  74. package/dist/features/todo/templates/task-update.render.js.map +1 -0
  75. package/dist/features/visual/templates/capture.render.d.ts +9 -0
  76. package/dist/features/visual/templates/capture.render.js +49 -0
  77. package/dist/features/visual/templates/capture.render.js.map +1 -0
  78. package/dist/features/websearch/templates/crawl4ai.render.d.ts +6 -0
  79. package/dist/features/websearch/templates/crawl4ai.render.js +30 -0
  80. package/dist/features/websearch/templates/crawl4ai.render.js.map +1 -0
  81. package/dist/features/websearch/templates/web-fetch.render.d.ts +12 -0
  82. package/dist/features/websearch/templates/web-fetch.render.js +40 -0
  83. package/dist/features/websearch/templates/web-fetch.render.js.map +1 -0
  84. package/dist/index.d.ts +3 -745
  85. package/dist/index.js +7 -7
  86. package/dist/types-DUKIIntb.d.ts +745 -0
  87. package/package.json +71 -74
  88. package/LICENSE +0 -21
  89. /package/dist/{ExplorerAgent-X6QECX65.js.map → ExplorerAgent-BITN4IBW.js.map} +0 -0
  90. /package/dist/{chunk-N7J76R5P.js.map → chunk-4FBF65TC.js.map} +0 -0
  91. /package/dist/{chunk-DI5EGMGG.js.map → chunk-XCJOXCJ4.js.map} +0 -0
  92. /package/dist/{chunk-XAJ6L4GA.js.map → chunk-XE5IEUPW.js.map} +0 -0
package/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { E as EnrichedMessage, M as MessageTag, a as Message, L as LLMResponse, T as ToolCall, b as Tool, c as LogContextRef, A as AgentConfig, I as InlineRenderTemplate, d as ToolRenderConfig, H as HookInspectorSnapshot, e as AgentOverviewSnapshot, f as AgentInfo, N as Notification, U as UserInputRequest, g as UserInputResponse, h as UsageStatsSnapshot, i as TemplateSource, j as TemplateLoader, k as UsageStats, P as PlaceholderContext, l as UsageInfo, m as UserInputAction, n as LLMClient, o as MessageRole, p as AgentSession } from './types-DUKIIntb.js';
2
+ export { C as CacheStats, q as ContextMiddleware, D as DebugHubIPCMessage, r as TemplateComposer, s as TemplateError, t as TemplateLoaderOptions, u as TemplateResult, v as ToolMetadata, w as getDefaultUDSPath } from './types-DUKIIntb.js';
1
3
  import { Client } from '@modelcontextprotocol/sdk/client/index.js';
2
4
  import { IncomingMessage, ServerResponse } from 'http';
3
5
 
@@ -478,750 +480,6 @@ interface ToolFinishedDecisionContext extends ToolResult {
478
480
  toolName: string;
479
481
  }
480
482
 
481
- /**
482
- * 模板加载器
483
- * 从文件系统读取和缓存模板文件
484
- */
485
-
486
- /**
487
- * 模板加载器
488
- */
489
- declare class TemplateLoader {
490
- private cache;
491
- private searchDirs;
492
- private enabled;
493
- private stats;
494
- constructor(options?: TemplateLoaderOptions);
495
- /**
496
- * 加载模板(异步)
497
- */
498
- load(templatePath: string): Promise<string>;
499
- /**
500
- * 加载模板(同步)
501
- */
502
- loadSync(templatePath: string): string;
503
- /**
504
- * 解析路径为绝对路径
505
- * @param templatePath 模板路径
506
- * @returns 解析后的绝对路径
507
- * @throws TemplateError 如果文件格式不支持
508
- */
509
- resolvePath(templatePath: string): string;
510
- /**
511
- * 清除缓存
512
- */
513
- clearCache(pattern?: string): void;
514
- /**
515
- * 批量加载
516
- */
517
- loadMultiple(paths: string[]): Promise<Map<string, string>>;
518
- /**
519
- * 获取缓存统计
520
- */
521
- getStats(): CacheStats;
522
- /**
523
- * 检查是否是绝对路径
524
- */
525
- private isAbsolute;
526
- /**
527
- * 简单检查文件是否存在(同步,不进行实际IO)
528
- */
529
- private fileExists;
530
- }
531
-
532
- /**
533
- * 模板组合器
534
- * 支持流式 API 和灵活拼接
535
- */
536
-
537
- /**
538
- * 模板组合器
539
- */
540
- declare class TemplateComposer {
541
- private parts;
542
- private separator;
543
- private loader;
544
- constructor(loader?: TemplateLoader);
545
- /**
546
- * 添加模板源
547
- */
548
- add(source: TemplateSource | TemplateComposer): this;
549
- /**
550
- * 添加模板源(别名)
551
- */
552
- append(source: TemplateSource | TemplateComposer): this;
553
- /**
554
- * 在头部插入
555
- */
556
- prepend(source: TemplateSource | TemplateComposer): this;
557
- /**
558
- * 添加多个模板源
559
- */
560
- addAll(...sources: (TemplateSource | TemplateComposer)[]): this;
561
- /**
562
- * 设置分隔符
563
- */
564
- joinWith(sep: string): this;
565
- /**
566
- * 条件添加
567
- */
568
- when(condition: boolean | ((ctx: PlaceholderContext) => boolean), source: TemplateSource | TemplateComposer): this;
569
- /**
570
- * 条件分支(三目运算语法糖)
571
- */
572
- either(condition: boolean | ((ctx: PlaceholderContext) => boolean), trueSource: TemplateSource | TemplateComposer, falseSource?: TemplateSource | TemplateComposer): this;
573
- /**
574
- * 嵌套子组合器
575
- */
576
- nest(composer: TemplateComposer): this;
577
- /**
578
- * 条件嵌套
579
- */
580
- nestIf(condition: boolean | ((ctx: PlaceholderContext) => boolean), composer: TemplateComposer): this;
581
- /**
582
- * 清空所有模板
583
- */
584
- clear(): this;
585
- /**
586
- * 获取当前模板数量
587
- */
588
- get size(): number;
589
- /**
590
- * 获取所有模板源
591
- */
592
- getSources(): TemplateSource[];
593
- /**
594
- * 渲染最终模板
595
- */
596
- render(context?: PlaceholderContext): Promise<TemplateResult>;
597
- /**
598
- * 渲染单个片段
599
- */
600
- private renderPart;
601
- /**
602
- * 转换为 TemplatePart
603
- */
604
- private toPart;
605
- }
606
-
607
- /**
608
- * 提示词模板系统 - 核心类型定义
609
- */
610
- /**
611
- * 模板源
612
- * - string: 硬编码字符串
613
- * - { file: string }: 文件路径
614
- * - [dataSourceName: string]: 数据源名称(如 skills, tasks 等)
615
- * - TemplateComposer: 组合模板
616
- *
617
- * @example
618
- * ```typescript
619
- * // 静态字符串
620
- * 'Hello {{name}}'
621
- *
622
- * // 文件
623
- * { file: 'prompts/system.md' }
624
- *
625
- * // 数据源(列表渲染)
626
- * { skills: '- **{{name}}**: {{description}}' }
627
- * { tasks: '- [{{title}}](#{{id}}) ({{priority}})' }
628
- *
629
- * // 条件渲染
630
- * { conditional: { part: { file: 'advanced.md' }, condition: (ctx) => ctx.advanced } }
631
- * ```
632
- */
633
- type TemplateSource = string | {
634
- file: string;
635
- } | {
636
- conditional: ConditionalSource;
637
- } | {
638
- [dataSourceName: string]: string;
639
- } | TemplateComposer;
640
- /**
641
- * 条件源配置
642
- */
643
- interface ConditionalSource {
644
- /** 条件模板源 */
645
- part: TemplateSource;
646
- /** 条件函数(true 时渲染) */
647
- condition: (context: PlaceholderContext) => boolean;
648
- }
649
- /**
650
- * 占位符上下文 - 变量替换的键值对
651
- * 支持原始类型和复杂对象(用于数据源渲染)
652
- */
653
- type PlaceholderContext = Record<string, string | number | boolean | undefined | object>;
654
- /**
655
- * 模板渲染结果
656
- */
657
- interface TemplateResult {
658
- /** 渲染后的内容 */
659
- content: string;
660
- /** 使用的源文件列表(用于调试) */
661
- sources: string[];
662
- }
663
- /**
664
- * 模板加载器配置
665
- */
666
- interface TemplateLoaderOptions {
667
- /** 缓存启用状态,默认 true */
668
- cacheEnabled?: boolean;
669
- /** 模板搜索目录(相对于项目根目录) */
670
- searchDirs?: string[];
671
- /** 项目根目录(自动检测) */
672
- projectRoot?: string;
673
- }
674
- /**
675
- * 缓存统计
676
- */
677
- interface CacheStats {
678
- size: number;
679
- hits: number;
680
- misses: number;
681
- hitRate: number;
682
- }
683
- /**
684
- * 模板相关错误
685
- */
686
- declare class TemplateError extends Error {
687
- code: 'FILE_NOT_FOUND' | 'INVALID_PATH' | 'READ_ERROR' | 'UNSUPPORTED_FORMAT';
688
- path?: string | undefined;
689
- constructor(message: string, code: 'FILE_NOT_FOUND' | 'INVALID_PATH' | 'READ_ERROR' | 'UNSUPPORTED_FORMAT', path?: string | undefined);
690
- }
691
-
692
- /**
693
- * UsageStats - 用量统计系统
694
- *
695
- * 职责:
696
- * - 记录 LLM 调用的 token 用量
697
- * - 聚合 session/call/step 三级统计
698
- * - 提供快照序列化和恢复
699
- * - 格式化用量报告
700
- *
701
- * 设计原则:
702
- * - 框架内置,不是 Feature
703
- * - 自动收集,不需要手动干预
704
- * - 快照包含 session 级数据,用于会话恢复
705
- */
706
- /**
707
- * 统一用量格式(兼容 Anthropic 和 OpenAI)
708
- */
709
- interface UsageInfo$1 {
710
- /** 输入 token 数 */
711
- inputTokens: number;
712
- /** 输出 token 数 */
713
- outputTokens: number;
714
- /** 总 token 数 */
715
- totalTokens: number;
716
- /** 创建缓存消耗的 token 数 */
717
- cacheCreationTokens?: number;
718
- /** 从缓存读取的 token 数 */
719
- cacheReadTokens?: number;
720
- /** 推理 token 数(prompt_tokens_details 或 completion_tokens_details) */
721
- reasoningTokens?: number;
722
- /** 音频 token 数 */
723
- audioTokens?: number;
724
- }
725
- /**
726
- * 单次 Call 用量汇总
727
- */
728
- interface CallUsageSummary {
729
- callIndex: number;
730
- totalUsage: UsageInfo$1;
731
- stepCount: number;
732
- cacheHitRequests: number;
733
- startTime: number;
734
- endTime?: number;
735
- }
736
- /**
737
- * Session 用量快照(用于序列化)
738
- */
739
- interface UsageStatsSnapshot {
740
- /** Session 级累计用量 */
741
- totalUsage: UsageInfo$1;
742
- /** 各 Call 的用量汇总 */
743
- calls: CallUsageSummary[];
744
- /** 总请求数(LLM 调用次数) */
745
- totalRequests: number;
746
- /** 命中缓存的请求数(request-level) */
747
- totalCacheHitRequests: number;
748
- }
749
- /**
750
- * 用量统计类
751
- */
752
- declare class UsageStats {
753
- /** Session 级累计用量 */
754
- private totalUsage;
755
- /** 当前活跃 Call 的用量记录 */
756
- private currentCallUsage;
757
- /** 总 LLM 调用次数 */
758
- private totalRequests;
759
- /** 命中缓存的总请求数 */
760
- private totalCacheHitRequests;
761
- /** 当前 Call 的 Step 记录(临时,用于聚合) */
762
- private currentStepRecords;
763
- /**
764
- * 记录一次 LLM 调用的用量
765
- * @param callIndex Call 序号
766
- * @param step Step 序号
767
- * @param usage 用量数据
768
- */
769
- record(callIndex: number, step: number, usage: UsageInfo$1): void;
770
- /**
771
- * 标记 Call 结束
772
- * @param callIndex Call 序号
773
- */
774
- endCall(callIndex: number): void;
775
- /**
776
- * 获取 Session 级累计用量
777
- */
778
- getTotalUsage(): UsageInfo$1;
779
- /**
780
- * 获取指定 Call 的用量汇总
781
- * @param callIndex Call 序号
782
- */
783
- getCallUsage(callIndex: number): CallUsageSummary | undefined;
784
- /**
785
- * 获取所有 Call 的用量汇总
786
- */
787
- getAllCallUsage(): CallUsageSummary[];
788
- /**
789
- * 获取总请求次数
790
- */
791
- getTotalRequests(): number;
792
- getTotalCacheHitRequests(): number;
793
- /**
794
- * 获取格式化的用量报告
795
- */
796
- getReport(): string;
797
- /**
798
- * 创建快照(用于序列化)
799
- */
800
- toSnapshot(): UsageStatsSnapshot;
801
- /**
802
- * 从快照恢复
803
- */
804
- fromSnapshot(snapshot: UsageStatsSnapshot): void;
805
- /**
806
- * 重置统计(谨慎使用)
807
- */
808
- reset(): void;
809
- }
810
-
811
- /**
812
- * 基础类型定义
813
- * 所有类型集中在这里,简单直观
814
- */
815
- /**
816
- * 通知分类
817
- * - state: 覆盖式更新(如 LLM 字符计数)
818
- * - event: 追加式记录(如工具开始/完成)
819
- */
820
- type NotificationCategory = 'state' | 'event';
821
- /**
822
- * 通知基础接口
823
- */
824
- interface Notification {
825
- type: string;
826
- category: NotificationCategory;
827
- timestamp: number;
828
- data: unknown;
829
- }
830
- type LogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error';
831
- type DebugLogDeliveryReason = 'hub' | 'hub-unavailable' | 'no-agent-context';
832
- interface DebugLogDelivery {
833
- hub: boolean;
834
- console: boolean;
835
- reason: DebugLogDeliveryReason;
836
- }
837
- interface LogContextRef {
838
- agentId?: string;
839
- agentName?: string;
840
- parentAgentId?: string;
841
- callIndex?: number;
842
- step?: number;
843
- toolName?: string;
844
- toolCallId?: string;
845
- feature?: string;
846
- lifecycle?: string;
847
- hookMethod?: string;
848
- hookKind?: 'forward' | 'reverse';
849
- sourceFile?: string;
850
- sourceLine?: number;
851
- tags?: string[];
852
- [key: string]: unknown;
853
- }
854
- interface DebugLogEntry {
855
- id: string;
856
- timestamp: number;
857
- level: LogLevel;
858
- message: string;
859
- namespace: string;
860
- context: LogContextRef;
861
- data?: unknown;
862
- delivery: DebugLogDelivery;
863
- }
864
- type MessageRole = 'system' | 'user' | 'assistant' | 'tool' | string;
865
- interface Message {
866
- role: MessageRole;
867
- content: string;
868
- turn?: number;
869
- toolCallId?: string;
870
- toolCalls?: ToolCall[];
871
- reasoning?: string;
872
- thinkingBlocks?: ThinkingBlock[];
873
- }
874
- interface ThinkingBlock {
875
- signature: string;
876
- thinking: string;
877
- }
878
- interface ToolCall {
879
- id: string;
880
- name: string;
881
- arguments: Record<string, any>;
882
- }
883
- /**
884
- * 统一用量格式(兼容 Anthropic 和 OpenAI)
885
- */
886
- interface UsageInfo {
887
- /** 输入 token 数 */
888
- inputTokens: number;
889
- /** 输出 token 数 */
890
- outputTokens: number;
891
- /** 总 token 数 */
892
- totalTokens: number;
893
- /** 创建缓存消耗的 token 数 */
894
- cacheCreationTokens?: number;
895
- /** 从缓存读取的 token 数 */
896
- cacheReadTokens?: number;
897
- /** 推理 token 数 */
898
- reasoningTokens?: number;
899
- /** 音频 token 数 */
900
- audioTokens?: number;
901
- }
902
- interface LLMResponse {
903
- content: string;
904
- toolCalls?: ToolCall[];
905
- reasoning?: string;
906
- thinkingBlocks?: ThinkingBlock[];
907
- /** 用量统计(可选) */
908
- usage?: UsageInfo;
909
- }
910
- /**
911
- * 渲染模板项
912
- * 可以是字符串模板或函数模板
913
- */
914
- type RenderTemplateItem = string | RenderTemplateFn;
915
- /**
916
- * 渲染模板函数类型
917
- */
918
- type RenderTemplateFn = (data: Record<string, any>, success?: boolean) => string;
919
- /**
920
- * 内联渲染模板
921
- * 直接定义在工具中的渲染模板(无需引用预设模板)
922
- */
923
- interface InlineRenderTemplate {
924
- call: RenderTemplateItem;
925
- result: RenderTemplateItem;
926
- }
927
- interface ToolRenderConfig {
928
- /** 调用时的渲染模板(字符串引用或内联模板) */
929
- call?: string | InlineRenderTemplate;
930
- /** 结果时的渲染模板(字符串引用或内联模板) */
931
- result?: string | InlineRenderTemplate;
932
- }
933
- interface Tool {
934
- name: string;
935
- description: string;
936
- parameters?: Record<string, any>;
937
- execute: (args: any, context?: any) => Promise<any>;
938
- /** 可选:渲染配置 */
939
- render?: ToolRenderConfig;
940
- }
941
- interface LLMClient {
942
- chat(messages: Message[], tools: Tool[]): Promise<LLMResponse>;
943
- }
944
-
945
- interface AgentConfig {
946
- llm: LLMClient;
947
- tools?: Tool[];
948
- maxTurns?: number;
949
- systemMessage?: string | TemplateSource;
950
- name?: string;
951
- /**
952
- * Feature 配置
953
- *
954
- * 新的声明式 Feature 注册方式
955
- */
956
- features?: {
957
- /** 启用的 Feature 列表 */
958
- enabled?: string[];
959
- /** Feature 特定配置 */
960
- [key: string]: unknown;
961
- };
962
- }
963
- type ContextMiddleware = (messages: Message[]) => Message[];
964
- /**
965
- * Agent 注册信息(Hub 端)
966
- */
967
- interface AgentInfo {
968
- id: string;
969
- name: string;
970
- registeredAt: number;
971
- }
972
- /**
973
- * 工具元数据(用于前端渲染)
974
- */
975
- interface ToolMetadata {
976
- name: string;
977
- description: string;
978
- render: {
979
- call: string | InlineRenderTemplate;
980
- result: string | InlineRenderTemplate;
981
- inlineCall?: InlineRenderTemplate;
982
- inlineResult?: InlineRenderTemplate;
983
- };
984
- }
985
- interface HookSourceLocation {
986
- file?: string;
987
- line?: number;
988
- column?: number;
989
- display: string;
990
- }
991
- interface HookEntryMetadata {
992
- order: number;
993
- featureName: string;
994
- methodName: string;
995
- lifecycle: string;
996
- kind: 'decision' | 'notify';
997
- source?: HookSourceLocation;
998
- description?: string;
999
- }
1000
- interface HookLifecycleSnapshot {
1001
- lifecycle: string;
1002
- kind: 'decision' | 'notify';
1003
- entries: HookEntryMetadata[];
1004
- }
1005
- interface FeatureInspectorSnapshot {
1006
- name: string;
1007
- enabled: boolean;
1008
- status: 'enabled' | 'disabled' | 'partial';
1009
- hookCount: number;
1010
- toolCount: number;
1011
- enabledToolCount: number;
1012
- source?: string;
1013
- description?: string;
1014
- tools: Array<{
1015
- name: string;
1016
- description: string;
1017
- enabled: boolean;
1018
- renderCall?: string;
1019
- renderResult?: string;
1020
- }>;
1021
- }
1022
- interface HookInspectorSnapshot {
1023
- lifecycleOrder: string[];
1024
- features: FeatureInspectorSnapshot[];
1025
- hooks: HookLifecycleSnapshot[];
1026
- }
1027
- interface AgentContextMetrics {
1028
- messageCount: number;
1029
- charCount: number;
1030
- toolCallCount: number;
1031
- turnCount: number;
1032
- }
1033
- interface AgentOverviewSnapshot {
1034
- updatedAt: number;
1035
- context: AgentContextMetrics;
1036
- usageStats: UsageStatsSnapshot;
1037
- }
1038
- /**
1039
- * Agent 会话数据(Worker 端)
1040
- */
1041
- interface AgentSession {
1042
- id: string;
1043
- name: string;
1044
- messages: Message[];
1045
- tools: ToolMetadata[];
1046
- createdAt: number;
1047
- lastActive: number;
1048
- projectRoot?: string;
1049
- currentState: Notification | null;
1050
- events: Notification[];
1051
- lastEventCount: number;
1052
- logs: DebugLogEntry[];
1053
- clientId?: string;
1054
- _lastMessageSig?: string;
1055
- hookInspector?: HookInspectorSnapshot;
1056
- overview?: AgentOverviewSnapshot;
1057
- }
1058
- /**
1059
- * DebugHub IPC 消息类型(主进程 → Worker)
1060
- * 使用 discriminated union 确保类型安全
1061
- */
1062
- type DebugHubIPCMessage = RegisterAgentMsg | UpdateAgentInspectorMsg | UpdateAgentOverviewMsg | PushMessagesMsg | RegisterToolsMsg | SetCurrentAgentMsg | UnregisterAgentMsg | PushNotificationMsg | RequestInputMsg | StopMsg;
1063
- /**
1064
- * 注册新 Agent
1065
- */
1066
- interface RegisterAgentMsg {
1067
- type: 'register-agent';
1068
- agentId: string;
1069
- name: string;
1070
- createdAt: number;
1071
- projectRoot?: string;
1072
- featureTemplates?: Record<string, string>;
1073
- hookInspector?: HookInspectorSnapshot;
1074
- overview?: AgentOverviewSnapshot;
1075
- activeInputRequest?: ActiveInputRequest;
1076
- }
1077
- interface UpdateAgentInspectorMsg {
1078
- type: 'update-agent-inspector';
1079
- agentId: string;
1080
- hookInspector: HookInspectorSnapshot;
1081
- }
1082
- interface UpdateAgentOverviewMsg {
1083
- type: 'update-agent-overview';
1084
- agentId: string;
1085
- overview: AgentOverviewSnapshot;
1086
- }
1087
- /**
1088
- * 推送 Agent 消息
1089
- */
1090
- interface PushMessagesMsg {
1091
- type: 'push-messages';
1092
- agentId: string;
1093
- messages: Message[];
1094
- }
1095
- /**
1096
- * 注册 Agent 工具
1097
- */
1098
- interface RegisterToolsMsg {
1099
- type: 'register-tools';
1100
- agentId: string;
1101
- tools: Tool[];
1102
- }
1103
- /**
1104
- * 切换当前选中的 Agent
1105
- */
1106
- interface SetCurrentAgentMsg {
1107
- type: 'set-current-agent';
1108
- agentId: string;
1109
- }
1110
- /**
1111
- * 活跃的输入请求(用于重连后恢复)
1112
- */
1113
- interface ActiveInputRequest {
1114
- requestId: string;
1115
- prompt: string;
1116
- placeholder?: string;
1117
- initialValue?: string;
1118
- actions?: UserInputAction[];
1119
- timestamp: number;
1120
- }
1121
- /**
1122
- * 注销 Agent
1123
- */
1124
- interface UnregisterAgentMsg {
1125
- type: 'unregister-agent';
1126
- agentId: string;
1127
- }
1128
- /**
1129
- * 停止 Worker
1130
- */
1131
- interface StopMsg {
1132
- type: 'stop';
1133
- }
1134
- /**
1135
- * 推送通知
1136
- */
1137
- interface PushNotificationMsg {
1138
- type: 'push-notification';
1139
- agentId: string;
1140
- notification: Notification;
1141
- }
1142
- /**
1143
- * 请求用户输入
1144
- */
1145
- interface RequestInputMsg {
1146
- type: 'request-input';
1147
- agentId: string;
1148
- requestId: string;
1149
- prompt: string;
1150
- timeout?: number;
1151
- placeholder?: string;
1152
- initialValue?: string;
1153
- actions?: UserInputAction[];
1154
- }
1155
- interface UserInputAction {
1156
- id: string;
1157
- label: string;
1158
- kind?: 'rollback' | 'custom';
1159
- variant?: 'primary' | 'secondary' | 'danger';
1160
- payload?: Record<string, unknown>;
1161
- }
1162
- interface UserInputRequest {
1163
- prompt: string;
1164
- placeholder?: string;
1165
- initialValue?: string;
1166
- actions?: UserInputAction[];
1167
- }
1168
- interface UserInputResponse {
1169
- kind: 'text' | 'action';
1170
- text?: string;
1171
- actionId?: string;
1172
- payload?: Record<string, unknown>;
1173
- }
1174
- /**
1175
- * 消息标签枚举
1176
- *
1177
- * 用于快速分类和过滤消息,一条消息可能有多个标签
1178
- */
1179
- type MessageTag = 'user' | 'system' | 'assistant' | 'tool-call' | 'tool-result' | 'sub-agent' | 'reminder';
1180
- /**
1181
- * 解析结果结构
1182
- *
1183
- * 从消息 content 中提取的结构化信息
1184
- */
1185
- interface ParsedContent {
1186
- /** 从 content 提取的任务 ID(正则匹配 "taskId":"xxx") */
1187
- taskIds: string[];
1188
- /** 从 content 提取的工具调用名称(从 toolCalls 或 content 解析) */
1189
- toolCalls: string[];
1190
- /** @ 提及的内容 */
1191
- mentions: string[];
1192
- /** 用户可继承扩展更多字段 */
1193
- [key: string]: any;
1194
- }
1195
- /**
1196
- * 扩展的消息结构
1197
- *
1198
- * 在原始 Message 基础上添加元数据
1199
- * 不破坏现有 Message 类型,保证 LLM 调用兼容性
1200
- */
1201
- interface EnrichedMessage extends Message {
1202
- /** 唯一标识(用于索引关联) */
1203
- id: string;
1204
- /** 消息产生时间戳(毫秒) */
1205
- timestamp: number;
1206
- /** 所属 ReAct 循环轮次(从 0 开始) */
1207
- turn: number;
1208
- /** 全局消息序号(从 0 开始递增) */
1209
- sequence: number;
1210
- /** 来源 Agent ID(子代理消息) */
1211
- agentId?: string;
1212
- /** 来源 Feature(如 'todo-feature',仅 reminder 等) */
1213
- source?: string;
1214
- /** 消息分类标签(用于快速查询) */
1215
- tags: MessageTag[];
1216
- /** 从 content 中提取的结构化信息 */
1217
- parsed: ParsedContent;
1218
- }
1219
-
1220
- /**
1221
- * 平台检测后的 UDS 路径
1222
- */
1223
- declare function getDefaultUDSPath(): string;
1224
-
1225
483
  interface LoggerBindings extends LogContextRef {
1226
484
  tags?: string[];
1227
485
  }
@@ -3833,4 +3091,4 @@ declare function renderMCPToolCall(serverName: string, toolName: string, args: R
3833
3091
  */
3834
3092
  declare function renderMCPToolResult(result: any, success?: boolean): string;
3835
3093
 
3836
- export { AgentBase as Agent, type AgentConfig, type AgentConfigFile, type AgentFeature, type AgentInfo, type AgentInitiateContext, AgentPool, type AgentSession, type AgentSessionSnapshot, AnthropicLLM, BasicAgent, type BasicAgentConfig, type CacheStats, CallStart, type CallStartContext, Context, type ContextInjector, type ContextMiddleware, DataSourceRegistry, type DataSourceRenderer, type DebugCapabilities, DebugHub, type DebugHubIPCMessage, ExampleFeature, type ExampleFeatureConfig, type ExampleFeatureRuntimeState, type ExampleFeatureSnapshot, ExplorerAgent, type ExplorerAgentConfig, type SystemContext as ExplorerSystemContext, type FeatureContext, type FeatureInitContext, type FeatureStateSnapshot, FileSessionStore, type HookResult, type InlineRenderTemplate, type LLMClient, type LLMResponse, type LoadAllMCPConfigsOptions, 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, type Message, type MessageRole, type ModelConfig, OpenAILLM, OpencodeBasicFeature, type PackageInfo, type PlaceholderContext, PlaceholderResolver, type SessionStore, SkillFeature, type SkillFeatureConfig, type SkillMetadata, type SkillsOptions, SubAgentFeature, type SystemContext$1 as SystemContext, type TaskStatus, TemplateComposer, TemplateError, TemplateLoader, type TemplateLoaderOptions, type TemplateResult, type TemplateSource, TodoFeature, type TodoFeatureConfig, type TodoTask, type TodoTaskSummary, type Tool, type ToolCall, type ToolContext, type ToolContextValue, type ToolMetadata, ToolRegistry, type ToolRenderConfig, type ToolResult, UserInputFeature, type UserInputFeatureConfig, ViewerWorker, assistant, compileContextForAnthropic, createAnthropicLLM, createDefaultMCPToolName, createLLM, createListRenderer, createMCPTool, createMCPToolAdapters, createMCPToolsFromClient, createManagedMCPToolsFromClient, createMessage, createOpenAILLM, createTool, discover, discoverMCPTools, discoverManagedMCPTools, getClawRuntimeUrl, getDebugCapabilities, getDefaultMCPConfigDir, getDefaultSessionStore, getDefaultUDSPath, getMCPRenderTemplate, getPackageInfoFromSource, listConfigs, loadAllMCPConfigs, loadConfig, loadConfigSync, loadMCPConfigFromInput, mountMCPToolsFromConfig, renderMCPToolCall, renderMCPToolResult, resolveDebugTransportMode, system, toolResult, user };
3094
+ export { AgentBase as Agent, AgentConfig, type AgentConfigFile, type AgentFeature, AgentInfo, type AgentInitiateContext, AgentPool, AgentSession, type AgentSessionSnapshot, AnthropicLLM, BasicAgent, type BasicAgentConfig, CallStart, type CallStartContext, Context, type ContextInjector, DataSourceRegistry, type DataSourceRenderer, type DebugCapabilities, DebugHub, 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, 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, SubAgentFeature, type SystemContext$1 as SystemContext, type TaskStatus, TemplateLoader, TemplateSource, TodoFeature, type TodoFeatureConfig, type TodoTask, type TodoTaskSummary, Tool, ToolCall, type ToolContext, type ToolContextValue, ToolRegistry, ToolRenderConfig, type ToolResult, UserInputFeature, type UserInputFeatureConfig, ViewerWorker, assistant, compileContextForAnthropic, createAnthropicLLM, createDefaultMCPToolName, createLLM, createListRenderer, createMCPTool, createMCPToolAdapters, createMCPToolsFromClient, createManagedMCPToolsFromClient, createMessage, createOpenAILLM, createTool, discover, discoverMCPTools, discoverManagedMCPTools, getClawRuntimeUrl, getDebugCapabilities, getDefaultMCPConfigDir, getDefaultSessionStore, getMCPRenderTemplate, getPackageInfoFromSource, listConfigs, loadAllMCPConfigs, loadConfig, loadConfigSync, loadMCPConfigFromInput, mountMCPToolsFromConfig, renderMCPToolCall, renderMCPToolResult, resolveDebugTransportMode, system, toolResult, user };