mycohive-claw 4.0.0

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 (171) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +222 -0
  3. package/dist/circuit-breaker.d.ts +82 -0
  4. package/dist/circuit-breaker.d.ts.map +1 -0
  5. package/dist/circuit-breaker.js +214 -0
  6. package/dist/circuit-breaker.js.map +1 -0
  7. package/dist/context-tree.d.ts +94 -0
  8. package/dist/context-tree.d.ts.map +1 -0
  9. package/dist/context-tree.js +624 -0
  10. package/dist/context-tree.js.map +1 -0
  11. package/dist/event-bus.d.ts +174 -0
  12. package/dist/event-bus.d.ts.map +1 -0
  13. package/dist/event-bus.js +750 -0
  14. package/dist/event-bus.js.map +1 -0
  15. package/dist/i18n.d.ts +91 -0
  16. package/dist/i18n.d.ts.map +1 -0
  17. package/dist/i18n.js +150 -0
  18. package/dist/i18n.js.map +1 -0
  19. package/dist/index.d.ts +38 -0
  20. package/dist/index.d.ts.map +1 -0
  21. package/dist/index.js +301 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/intent-analyzer.d.ts +119 -0
  24. package/dist/intent-analyzer.d.ts.map +1 -0
  25. package/dist/intent-analyzer.js +563 -0
  26. package/dist/intent-analyzer.js.map +1 -0
  27. package/dist/logger.d.ts +46 -0
  28. package/dist/logger.d.ts.map +1 -0
  29. package/dist/logger.js +126 -0
  30. package/dist/logger.js.map +1 -0
  31. package/dist/metrics.d.ts +98 -0
  32. package/dist/metrics.d.ts.map +1 -0
  33. package/dist/metrics.js +192 -0
  34. package/dist/metrics.js.map +1 -0
  35. package/dist/openclaw-api.d.ts +122 -0
  36. package/dist/openclaw-api.d.ts.map +1 -0
  37. package/dist/openclaw-api.js +8 -0
  38. package/dist/openclaw-api.js.map +1 -0
  39. package/dist/rate-limiter.d.ts +46 -0
  40. package/dist/rate-limiter.d.ts.map +1 -0
  41. package/dist/rate-limiter.js +134 -0
  42. package/dist/rate-limiter.js.map +1 -0
  43. package/dist/result-cache.d.ts +76 -0
  44. package/dist/result-cache.d.ts.map +1 -0
  45. package/dist/result-cache.js +158 -0
  46. package/dist/result-cache.js.map +1 -0
  47. package/dist/router.d.ts +90 -0
  48. package/dist/router.d.ts.map +1 -0
  49. package/dist/router.js +447 -0
  50. package/dist/router.js.map +1 -0
  51. package/dist/setup-entry.d.ts +18 -0
  52. package/dist/setup-entry.d.ts.map +1 -0
  53. package/dist/setup-entry.js +64 -0
  54. package/dist/setup-entry.js.map +1 -0
  55. package/dist/token-counter.d.ts +57 -0
  56. package/dist/token-counter.d.ts.map +1 -0
  57. package/dist/token-counter.js +125 -0
  58. package/dist/token-counter.js.map +1 -0
  59. package/dist/tool-handlers.d.ts +52 -0
  60. package/dist/tool-handlers.d.ts.map +1 -0
  61. package/dist/tool-handlers.js +317 -0
  62. package/dist/tool-handlers.js.map +1 -0
  63. package/dist/tools/mycohive-tools.d.ts +11 -0
  64. package/dist/tools/mycohive-tools.d.ts.map +1 -0
  65. package/dist/tools/mycohive-tools.js +160 -0
  66. package/dist/tools/mycohive-tools.js.map +1 -0
  67. package/dist/types.d.ts +58 -0
  68. package/dist/types.d.ts.map +1 -0
  69. package/dist/types.js +57 -0
  70. package/dist/types.js.map +1 -0
  71. package/dist/workspace-loader.d.ts +67 -0
  72. package/dist/workspace-loader.d.ts.map +1 -0
  73. package/dist/workspace-loader.js +175 -0
  74. package/dist/workspace-loader.js.map +1 -0
  75. package/package.json +52 -0
  76. package/workspaces/api_dev/CONFIG.md +31 -0
  77. package/workspaces/api_dev/RULES.md +8 -0
  78. package/workspaces/api_dev/SKILL.md +69 -0
  79. package/workspaces/api_dev/SOUL.md +19 -0
  80. package/workspaces/architect/CONFIG.md +32 -0
  81. package/workspaces/architect/RULES.md +8 -0
  82. package/workspaces/architect/SKILL.md +63 -0
  83. package/workspaces/architect/SOUL.md +19 -0
  84. package/workspaces/backend_dev/CONFIG.md +42 -0
  85. package/workspaces/backend_dev/RULES.md +8 -0
  86. package/workspaces/backend_dev/SKILL.md +41 -0
  87. package/workspaces/backend_dev/SOUL.md +19 -0
  88. package/workspaces/browser/CONFIG.md +42 -0
  89. package/workspaces/browser/RULES.md +8 -0
  90. package/workspaces/browser/SKILL.md +57 -0
  91. package/workspaces/browser/SOUL.md +19 -0
  92. package/workspaces/builder/CONFIG.md +31 -0
  93. package/workspaces/builder/RULES.md +8 -0
  94. package/workspaces/builder/SKILL.md +39 -0
  95. package/workspaces/builder/SOUL.md +18 -0
  96. package/workspaces/coder/CONFIG.md +44 -0
  97. package/workspaces/coder/RULES.md +9 -0
  98. package/workspaces/coder/SKILL.md +53 -0
  99. package/workspaces/coder/SOUL.md +19 -0
  100. package/workspaces/coordinator/CONFIG.md +62 -0
  101. package/workspaces/coordinator/RULES.md +8 -0
  102. package/workspaces/coordinator/SKILL.md +77 -0
  103. package/workspaces/coordinator/SOUL.md +20 -0
  104. package/workspaces/data_engineer/CONFIG.md +32 -0
  105. package/workspaces/data_engineer/RULES.md +8 -0
  106. package/workspaces/data_engineer/SKILL.md +44 -0
  107. package/workspaces/data_engineer/SOUL.md +19 -0
  108. package/workspaces/deployer/CONFIG.md +45 -0
  109. package/workspaces/deployer/RULES.md +8 -0
  110. package/workspaces/deployer/SKILL.md +74 -0
  111. package/workspaces/deployer/SOUL.md +19 -0
  112. package/workspaces/dreamer/CONFIG.md +34 -0
  113. package/workspaces/dreamer/RULES.md +8 -0
  114. package/workspaces/dreamer/SKILL.md +48 -0
  115. package/workspaces/dreamer/SOUL.md +19 -0
  116. package/workspaces/evaluator/CONFIG.md +40 -0
  117. package/workspaces/evaluator/RULES.md +21 -0
  118. package/workspaces/evaluator/SKILL.md +65 -0
  119. package/workspaces/evaluator/SOUL.md +20 -0
  120. package/workspaces/front_director/CONFIG.md +54 -0
  121. package/workspaces/front_director/RULES.md +8 -0
  122. package/workspaces/front_director/SKILL.md +52 -0
  123. package/workspaces/front_director/SOUL.md +20 -0
  124. package/workspaces/frontend_dev/CONFIG.md +33 -0
  125. package/workspaces/frontend_dev/RULES.md +8 -0
  126. package/workspaces/frontend_dev/SKILL.md +42 -0
  127. package/workspaces/frontend_dev/SOUL.md +19 -0
  128. package/workspaces/observer/CONFIG.md +60 -0
  129. package/workspaces/observer/RULES.md +7 -0
  130. package/workspaces/observer/SKILL.md +77 -0
  131. package/workspaces/observer/SOUL.md +19 -0
  132. package/workspaces/planner/CONFIG.md +43 -0
  133. package/workspaces/planner/RULES.md +8 -0
  134. package/workspaces/planner/SKILL.md +65 -0
  135. package/workspaces/planner/SOUL.md +20 -0
  136. package/workspaces/qa/CONFIG.md +32 -0
  137. package/workspaces/qa/RULES.md +8 -0
  138. package/workspaces/qa/SKILL.md +52 -0
  139. package/workspaces/qa/SOUL.md +19 -0
  140. package/workspaces/researcher/CONFIG.md +32 -0
  141. package/workspaces/researcher/RULES.md +8 -0
  142. package/workspaces/researcher/SKILL.md +58 -0
  143. package/workspaces/researcher/SOUL.md +20 -0
  144. package/workspaces/reviewer/CONFIG.md +41 -0
  145. package/workspaces/reviewer/RULES.md +17 -0
  146. package/workspaces/reviewer/SKILL.md +56 -0
  147. package/workspaces/reviewer/SOUL.md +20 -0
  148. package/workspaces/router/CONFIG.md +58 -0
  149. package/workspaces/router/RULES.md +8 -0
  150. package/workspaces/router/SKILL.md +97 -0
  151. package/workspaces/router/SOUL.md +20 -0
  152. package/workspaces/scraper/CONFIG.md +41 -0
  153. package/workspaces/scraper/RULES.md +8 -0
  154. package/workspaces/scraper/SKILL.md +51 -0
  155. package/workspaces/scraper/SOUL.md +19 -0
  156. package/workspaces/scripter/CONFIG.md +42 -0
  157. package/workspaces/scripter/RULES.md +8 -0
  158. package/workspaces/scripter/SKILL.md +54 -0
  159. package/workspaces/scripter/SOUL.md +18 -0
  160. package/workspaces/security/CONFIG.md +47 -0
  161. package/workspaces/security/RULES.md +8 -0
  162. package/workspaces/security/SKILL.md +50 -0
  163. package/workspaces/security/SOUL.md +19 -0
  164. package/workspaces/translator/CONFIG.md +43 -0
  165. package/workspaces/translator/RULES.md +8 -0
  166. package/workspaces/translator/SKILL.md +35 -0
  167. package/workspaces/translator/SOUL.md +19 -0
  168. package/workspaces/writer/CONFIG.md +31 -0
  169. package/workspaces/writer/RULES.md +8 -0
  170. package/workspaces/writer/SKILL.md +40 -0
  171. package/workspaces/writer/SOUL.md +19 -0
@@ -0,0 +1,160 @@
1
+ /**
2
+ * MycoHive Tools 注册
3
+ * 版本: v4.0.0
4
+ *
5
+ * 注册自定义工具供 Agent 使用
6
+ */
7
+ import { getContextTree } from "../context-tree.js";
8
+ import { getEventBus } from "../event-bus.js";
9
+ export function registerTools(api, router) {
10
+ // === Context Tree Tools ===
11
+ api.registerTool({
12
+ name: "mycohive_topic_create",
13
+ description: "创建新的 Topic(话题)",
14
+ inputSchema: {
15
+ type: "object",
16
+ properties: {
17
+ topicId: { type: "string", description: "话题 ID" },
18
+ label: { type: "string", description: "话题标签" },
19
+ },
20
+ required: ["topicId", "label"],
21
+ },
22
+ });
23
+ api.registerTool({
24
+ name: "mycohive_topic_list",
25
+ description: "列出所有活跃 Topic",
26
+ inputSchema: {
27
+ type: "object",
28
+ properties: {},
29
+ },
30
+ });
31
+ api.registerTool({
32
+ name: "mycohive_task_create",
33
+ description: "创建新的 Task(任务)",
34
+ inputSchema: {
35
+ type: "object",
36
+ properties: {
37
+ topicId: { type: "string", description: "所属 Topic ID" },
38
+ taskId: { type: "string", description: "任务 ID" },
39
+ agent: { type: "string", description: "执行的 Agent" },
40
+ taskDesc: { type: "string", description: "任务描述" },
41
+ },
42
+ required: ["topicId", "taskId", "agent", "taskDesc"],
43
+ },
44
+ });
45
+ api.registerTool({
46
+ name: "mycohive_task_update",
47
+ description: "更新 Task 状态",
48
+ inputSchema: {
49
+ type: "object",
50
+ properties: {
51
+ taskId: { type: "string", description: "任务 ID" },
52
+ state: {
53
+ type: "string",
54
+ enum: ["active", "done", "cancelled", "stale", "routed", "running", "compacted"],
55
+ description: "新状态",
56
+ },
57
+ taskStatus: {
58
+ type: "string",
59
+ enum: ["PENDING", "RUNNING", "DONE", "FAILED", "CANCELLED", "SKIPPED", "CANCELLING"],
60
+ description: "任务执行状态",
61
+ },
62
+ },
63
+ required: ["taskId", "state"],
64
+ },
65
+ });
66
+ api.registerTool({
67
+ name: "mycohive_context_tree_stats",
68
+ description: "获取 Context Tree 统计信息",
69
+ inputSchema: {
70
+ type: "object",
71
+ properties: {},
72
+ },
73
+ });
74
+ // === Event Bus Tools ===
75
+ api.registerTool({
76
+ name: "mycohive_event_publish",
77
+ description: "发布自定义事件",
78
+ inputSchema: {
79
+ type: "object",
80
+ properties: {
81
+ type: { type: "string", description: "事件类型" },
82
+ source: { type: "string", description: "事件来源" },
83
+ data: { type: "object", description: "事件数据" },
84
+ },
85
+ required: ["type", "source"],
86
+ },
87
+ });
88
+ api.registerTool({
89
+ name: "mycohive_event_history",
90
+ description: "查询事件历史",
91
+ inputSchema: {
92
+ type: "object",
93
+ properties: {
94
+ eventType: { type: "string", description: "事件类型过滤(可选)" },
95
+ limit: { type: "number", description: "返回数量(默认 100)" },
96
+ },
97
+ },
98
+ });
99
+ // === Router Tools ===
100
+ api.registerTool({
101
+ name: "mycohive_route",
102
+ description: "路由用户消息到对应 Agent(自动意图分析)",
103
+ inputSchema: {
104
+ type: "object",
105
+ properties: {
106
+ message: { type: "string", description: "用户消息" },
107
+ sessionKey: { type: "string", description: "会话 Key" },
108
+ },
109
+ required: ["message", "sessionKey"],
110
+ },
111
+ });
112
+ api.registerTool({
113
+ name: "mycohive_intent_analyze",
114
+ description: "仅分析意图,不执行路由",
115
+ inputSchema: {
116
+ type: "object",
117
+ properties: {
118
+ message: { type: "string", description: "用户消息" },
119
+ },
120
+ required: ["message"],
121
+ },
122
+ });
123
+ // === 系统 Tools ===
124
+ api.registerTool({
125
+ name: "mycohive_health",
126
+ description: "健康检查",
127
+ inputSchema: {
128
+ type: "object",
129
+ properties: {},
130
+ },
131
+ });
132
+ api.registerTool({
133
+ name: "mycohive_diagnose",
134
+ description: "系统诊断",
135
+ inputSchema: {
136
+ type: "object",
137
+ properties: {},
138
+ },
139
+ });
140
+ api.registerTool({
141
+ name: "mycohive_health_check",
142
+ description: "健康检查(供外部监控轮询)",
143
+ inputSchema: {
144
+ type: "object",
145
+ properties: {},
146
+ },
147
+ });
148
+ // === Tool Handlers ===
149
+ // Note: In OpenClaw plugin, tools are registered via registerTool but handlers are called via hook
150
+ // Actual implementation happens in the hook handlers (see index.ts)
151
+ // Tool handlers are invoked via before_tool_call hook
152
+ // See index.ts for the hook registration
153
+ }
154
+ export function registerToolHandlers(api, router) {
155
+ const tree = getContextTree();
156
+ const eventBus = getEventBus();
157
+ // Note: In OpenClaw, tool handlers are invoked through the tool call mechanism
158
+ // This function sets up any additional synchronous handlers if needed
159
+ }
160
+ //# sourceMappingURL=mycohive-tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mycohive-tools.js","sourceRoot":"","sources":["../../src/tools/mycohive-tools.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG9C,MAAM,UAAU,aAAa,CAAC,GAAgB,EAAE,MAAc;IAC5D,6BAA6B;IAE7B,GAAG,CAAC,YAAY,CAAC;QACf,IAAI,EAAE,uBAAuB;QAC7B,WAAW,EAAE,gBAAgB;QAC7B,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE;gBACjD,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE;aAC/C;YACD,QAAQ,EAAE,CAAC,SAAS,EAAE,OAAO,CAAC;SAC/B;KACF,CAAC,CAAC;IAEH,GAAG,CAAC,YAAY,CAAC;QACf,IAAI,EAAE,qB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sEAAsE;AACxE,CAAC"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Context Tree 类型定义
3
+ * 版本: v4.0.0
4
+ *
5
+ * 提供 Session/Topic/Task/Artifact 的层级关系管理
6
+ */
7
+ export type NodeState = "active" | "done" | "cancelled" | "stale" | "routed" | "running" | "compacted";
8
+ export type TaskStatus = "PENDING" | "RUNNING" | "DONE" | "FAILED" | "CANCELLED" | "SKIPPED" | "CANCELLING";
9
+ export type NodeType = "root" | "session" | "topic" | "task" | "artifact" | "message";
10
+ export interface ContextNodeData {
11
+ agent?: string;
12
+ desc?: string;
13
+ role?: string;
14
+ content?: string;
15
+ context_annotation?: Record<string, unknown>;
16
+ task_status?: TaskStatus;
17
+ [key: string]: unknown;
18
+ }
19
+ export interface ProgressStep {
20
+ step: number;
21
+ agent: string;
22
+ action: string;
23
+ task_desc: string;
24
+ completed_at?: number;
25
+ result?: unknown;
26
+ }
27
+ export interface ContextNode {
28
+ id: string;
29
+ type: NodeType;
30
+ label?: string;
31
+ state: NodeState;
32
+ parent_id?: string;
33
+ children: Record<string, ContextNode>;
34
+ data: ContextNodeData;
35
+ reasoning?: string;
36
+ current_step?: string;
37
+ total_steps: number;
38
+ progress_steps: ProgressStep[];
39
+ execution_plan?: Record<string, unknown>;
40
+ office_hours_score?: number;
41
+ user_intervention?: string;
42
+ created_at: number;
43
+ updated_at: number;
44
+ }
45
+ export interface ContextTreeStorage {
46
+ version: string;
47
+ last_updated: number;
48
+ root: ContextNode;
49
+ }
50
+ /**
51
+ * 从 JSON 对象还原 ContextNode
52
+ */
53
+ export declare function nodeFromJSON(data: Record<string, unknown>, parent?: ContextNode): ContextNode;
54
+ /**
55
+ * 将 ContextNode 序列化为 JSON 对象
56
+ */
57
+ export declare function nodeToJSON(node: ContextNode): Record<string, unknown>;
58
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA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tB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,YAAY,EAAE,CAAC;IAC/B,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACzC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,WAAW,CAAC;CACnB;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,WAAW,CA0B7F;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAoBrE"}
package/dist/types.js ADDED
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Context Tree 类型定义
3
+ * 版本: v4.0.0
4
+ *
5
+ * 提供 Session/Topic/Task/Artifact 的层级关系管理
6
+ */
7
+ /**
8
+ * 从 JSON 对象还原 ContextNode
9
+ */
10
+ export function nodeFromJSON(data, parent) {
11
+ const node = {
12
+ id: data.id,
13
+ type: data.type,
14
+ label: data.label,
15
+ state: data.state || "active",
16
+ parent_id: parent?.id,
17
+ children: {},
18
+ data: data.data || {},
19
+ reasoning: data.reasoning,
20
+ current_step: data.current_step,
21
+ total_steps: data.total_steps || 0,
22
+ progress_steps: data.progress_steps || [],
23
+ execution_plan: data.execution_plan,
24
+ office_hours_score: data.office_hours_score,
25
+ user_intervention: data.user_intervention,
26
+ created_at: data.created_at || Date.now(),
27
+ updated_at: data.updated_at || Date.now(),
28
+ };
29
+ const children = data.children || {};
30
+ for (const [childId, childData] of Object.entries(children)) {
31
+ node.children[childId] = nodeFromJSON(childData, node);
32
+ }
33
+ return node;
34
+ }
35
+ /**
36
+ * 将 ContextNode 序列化为 JSON 对象
37
+ */
38
+ export function nodeToJSON(node) {
39
+ return {
40
+ id: node.id,
41
+ type: node.type,
42
+ label: node.label,
43
+ state: node.state,
44
+ data: node.data,
45
+ reasoning: node.reasoning,
46
+ current_step: node.current_step,
47
+ total_steps: node.total_steps,
48
+ progress_steps: node.progress_steps,
49
+ execution_plan: node.execution_plan,
50
+ office_hours_score: node.office_hours_score,
51
+ user_intervention: node.user_intervention,
52
+ created_at: node.created_at,
53
+ updated_at: node.updated_at,
54
+ children: Object.fromEntries(Object.entries(node.children).map(([id, child]) => [id, nodeToJSON(child)])),
55
+ };
56
+ }
57
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAkEH;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,IAA6B,EAAE,MAAoB;IAC9E,MAAM,IAAI,GAAgB;QACxB,EAAE,EAAE,IAAI,CAAC,EAAY;QACrB,IAAI,EAAE,IAAI,CAAC,IAAgB;QAC3B,KAAK,EAAE,IAAI,CAAC,KAA2B;QACvC,KAAK,EAAG,IAAI,CAAC,KAAmB,IAAI,QAAQ;QAC5C,SAAS,EAAE,MAAM,EAAE,EAAE;QACrB,QAAQ,EAAE,EAAE;QACZ,IAAI,EAAG,IAAI,CAAC,IAAwB,IAAI,EAAE;QAC1C,SAAS,EAAE,IAAI,CAAC,SAA+B;QAC/C,YAAY,EAAE,IAAI,CAAC,YAAkC;QACrD,WAAW,EAAG,IAAI,CAAC,WAAsB,IAAI,CAAC;QAC9C,cAAc,EAAG,IAAI,CAAC,cAAiC,IAAI,EAAE;QAC7D,cAAc,EAAE,IAAI,CAAC,cAAqD;QAC1E,kBAAkB,EAAE,IAAI,CAAC,kBAAwC;QACjE,iBAAiB,EAAE,IAAI,CA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CAAC,KAAK,CAAC,CAAC,CAAC,CAC5E;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Workspace Loader 模块
3
+ * 版本: v4.0.0
4
+ *
5
+ * 加载 Agent workspace 文件 (SOUL.md, CONFIG.md, SKILL.md, RULES.md)
6
+ */
7
+ export interface AgentWorkspace {
8
+ agentId: string;
9
+ soul: string;
10
+ config: AgentConfigData;
11
+ skill: string;
12
+ rules: string;
13
+ }
14
+ export interface AgentConfigData {
15
+ agent_id: string;
16
+ agent_type: string;
17
+ model: string;
18
+ timeout: number;
19
+ capabilities: string[];
20
+ events_publish: string[];
21
+ events_subscribe: string[];
22
+ workspace_path?: string;
23
+ description: string;
24
+ routing_priority: number;
25
+ allowed_tools: string[];
26
+ max_retries: number;
27
+ session_mode?: "shared" | "isolated";
28
+ isolation?: {
29
+ initialMessage: string | null;
30
+ context: "artifact_only" | "full";
31
+ };
32
+ }
33
+ export declare class WorkspaceLoader {
34
+ private workspacesDir;
35
+ private cache;
36
+ private cacheEnabled;
37
+ constructor(workspacesDir?: string);
38
+ /**
39
+ * 加载指定 Agent 的 workspace
40
+ */
41
+ load(agentId: string): Promise<AgentWorkspace | null>;
42
+ /**
43
+ * 加载所有 Agent workspaces
44
+ */
45
+ loadAll(): Promise<Map<string, AgentWorkspace>>;
46
+ /**
47
+ * 根据 Agent 类型筛选
48
+ */
49
+ getAgentsByType(type: string): Promise<AgentWorkspace[]>;
50
+ /**
51
+ * 根据 capability 筛选
52
+ */
53
+ getAgentsByCapability(capability: string): Promise<AgentWorkspace[]>;
54
+ /**
55
+ * 清除缓存
56
+ */
57
+ clearCache(): void;
58
+ /**
59
+ * 禁用缓存
60
+ */
61
+ disableCache(): void;
62
+ private readFile;
63
+ private parseConfig;
64
+ private defaultConfig;
65
+ }
66
+ export declare function getWorkspaceLoader(workspacesDir?: string): WorkspaceLoader;
67
+ //# sourceMappingURL=workspace-loader.d.ts.map
@@ -0,0 +1 @@
1
+ {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AAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAK9D;;OAEG;IACG,qBAAqB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAO1E;;OAEG;IACH,UAAU,IAAI,IAAI;IAIlB;;OAEG;IACH,YAAY,IAAI,IAAI;YAKN,QAAQ;IAOtB,OAAO,CAAC,WAAW;IAwCnB,OAAO,CAAC,aAAa;CAgBtB;AAKD,wBAAgB,kBAAkB,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,eAAe,CAK1E"}
@@ -0,0 +1,175 @@
1
+ /**
2
+ * Workspace Loader 模块
3
+ * 版本: v4.0.0
4
+ *
5
+ * 加载 Agent workspace 文件 (SOUL.md, CONFIG.md, SKILL.md, RULES.md)
6
+ */
7
+ import * as fs from "fs";
8
+ import * as path from "path";
9
+ import YAML from "yaml";
10
+ export class WorkspaceLoader {
11
+ workspacesDir;
12
+ cache = new Map();
13
+ cacheEnabled = true;
14
+ constructor(workspacesDir = "workspaces") {
15
+ this.workspacesDir = workspacesDir;
16
+ }
17
+ /**
18
+ * 加载指定 Agent 的 workspace
19
+ */
20
+ async load(agentId) {
21
+ // 检查缓存
22
+ if (this.cacheEnabled && this.cache.has(agentId)) {
23
+ return this.cache.get(agentId);
24
+ }
25
+ const workspacePath = path.join(this.workspacesDir, agentId);
26
+ // 检查目录是否存在
27
+ if (!fs.existsSync(workspacePath)) {
28
+ console.warn(`[WorkspaceLoader] Workspace not found: ${workspacePath}`);
29
+ return null;
30
+ }
31
+ try {
32
+ const [soul, configRaw, skill, rules] = await Promise.all([
33
+ this.readFile(path.join(workspacePath, "SOUL.md")),
34
+ this.readFile(path.join(workspacePath, "CONFIG.md")),
35
+ this.readFile(path.join(workspacePath, "SKILL.md")),
36
+ this.readFile(path.join(workspacePath, "RULES.md")),
37
+ ]);
38
+ const config = this.parseConfig(configRaw);
39
+ const workspace = {
40
+ agentId,
41
+ soul,
42
+ config,
43
+ skill,
44
+ rules,
45
+ };
46
+ // 缓存
47
+ if (this.cacheEnabled) {
48
+ this.cache.set(agentId, workspace);
49
+ }
50
+ return workspace;
51
+ }
52
+ catch (error) {
53
+ console.error(`[WorkspaceLoader] Failed to load workspace ${agentId}:`, error);
54
+ return null;
55
+ }
56
+ }
57
+ /**
58
+ * 加载所有 Agent workspaces
59
+ */
60
+ async loadAll() {
61
+ if (!fs.existsSync(this.workspacesDir)) {
62
+ return new Map();
63
+ }
64
+ const agentIds = fs.readdirSync(this.workspacesDir).filter((dir) => {
65
+ const stat = fs.statSync(path.join(this.workspacesDir, dir));
66
+ return stat.isDirectory() && !dir.startsWith("_");
67
+ });
68
+ const results = await Promise.all(agentIds.map(async (id) => {
69
+ const workspace = await this.load(id);
70
+ return workspace ? [id, workspace] : null;
71
+ }));
72
+ const map = new Map();
73
+ for (const result of results) {
74
+ if (result) {
75
+ map.set(result[0], result[1]);
76
+ }
77
+ }
78
+ return map;
79
+ }
80
+ /**
81
+ * 根据 Agent 类型筛选
82
+ */
83
+ async getAgentsByType(type) {
84
+ const all = await this.loadAll();
85
+ return Array.from(all.values()).filter((w) => w.config.agent_type === type);
86
+ }
87
+ /**
88
+ * 根据 capability 筛选
89
+ */
90
+ async getAgentsByCapability(capability) {
91
+ const all = await this.loadAll();
92
+ return Array.from(all.values()).filter((w) => w.config.capabilities.includes(capability));
93
+ }
94
+ /**
95
+ * 清除缓存
96
+ */
97
+ clearCache() {
98
+ this.cache.clear();
99
+ }
100
+ /**
101
+ * 禁用缓存
102
+ */
103
+ disableCache() {
104
+ this.cacheEnabled = false;
105
+ this.cache.clear();
106
+ }
107
+ async readFile(filePath) {
108
+ if (!fs.existsSync(filePath)) {
109
+ return "";
110
+ }
111
+ return fs.promises.readFile(filePath, "utf-8");
112
+ }
113
+ parseConfig(content) {
114
+ if (!content) {
115
+ return this.defaultConfig();
116
+ }
117
+ try {
118
+ // 尝试解析 YAML frontmatter
119
+ const match = content.match(/^---\n([\s\S]*?)\n---\n/);
120
+ if (match) {
121
+ const yamlContent = match[1];
122
+ // 使用 yaml 包正确解析 YAML
123
+ const config = YAML.parse(yamlContent);
124
+ return {
125
+ agent_id: config?.agent_id || "unknown",
126
+ agent_type: config?.agent_type || "execution",
127
+ model: config?.model || "claude-sonnet-4-20250514",
128
+ timeout: config?.timeout || 60,
129
+ capabilities: config?.capabilities || [],
130
+ events_publish: config?.events_publish || [],
131
+ events_subscribe: config?.events_subscribe || [],
132
+ workspace_path: config?.workspace_path,
133
+ description: config?.description || "",
134
+ routing_priority: config?.routing_priority || 0,
135
+ allowed_tools: config?.allowed_tools || [],
136
+ max_retries: config?.max_retries || 3,
137
+ session_mode: config?.session_mode || "shared",
138
+ isolation: config?.isolation ? {
139
+ initialMessage: config?.isolation.initialMessage ?? null,
140
+ context: config?.isolation.context || "full",
141
+ } : undefined,
142
+ };
143
+ }
144
+ }
145
+ catch (error) {
146
+ console.warn("[WorkspaceLoader] YAML parse failed, using defaults:", error);
147
+ }
148
+ return this.defaultConfig();
149
+ }
150
+ defaultConfig() {
151
+ return {
152
+ agent_id: "unknown",
153
+ agent_type: "execution",
154
+ model: "claude-sonnet-4-20250514",
155
+ timeout: 60,
156
+ capabilities: [],
157
+ events_publish: [],
158
+ events_subscribe: [],
159
+ description: "",
160
+ routing_priority: 0,
161
+ allowed_tools: [],
162
+ max_retries: 3,
163
+ session_mode: "shared",
164
+ };
165
+ }
166
+ }
167
+ // 全局实例
168
+ let globalLoader = null;
169
+ export function getWorkspaceLoader(workspacesDir) {
170
+ if (!globalLoader) {
171
+ globalLoader = new WorkspaceLoader(workspacesDir);
172
+ }
173
+ return globalLoader;
174
+ }
175
+ //# sourceMappingURL=workspace-loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspace-loader.js","sourceRoot":"","sources":["../src/workspace-loader.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;A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AE,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;wBAC7B,cAAc,EAAE,MAAM,EAAE,SAAS,CAAC,cAAc,IAAI,IAAI;wBACxD,OAAO,EAAG,MAAM,EAAE,SAAS,CAAC,OAAoC,IAAI,MAAM;qBAC3E,CAAC,CAAC,CAAC,SAAS;iBACd,CAAC;YACJ,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,IAAI,CAAC,sDAAsD,EAAE,KAAK,CAAC,CAAC;QAC9E,CAAC;QAED,OAAO,IAAI,CAAC,aAAa,EAAE,CAAC;IAC9B,CAAC;IAEO,aAAa;QACnB,OAAO;YACL,QAAQ,EAAE,SAAS;YACnB,UAAU,EAAE,WAAW;YACvB,KAAK,EAAE,0BAA0B;YACjC,OAAO,EAAE,EAAE;YACX,YAAY,EAAE,EAAE;YAChB,cAAc,EAAE,EAAE;YAClB,gBAAgB,EAAE,EAAE;YACpB,WAAW,EAAE,EAAE;YACf,gBAAgB,EAAE,CAAC;YACnB,aAAa,EAAE,EAAE;YACjB,WAAW,EAAE,CAAC;YACd,YAAY,EAAE,QAAQ;SACvB,CAAC;IACJ,CAAC;CACF;AAED,OAAO;AACP,IAAI,YAAY,GAA2B,IAAI,CAAC;AAEhD,MAAM,UAAU,kBAAkB,CAAC,aAAsB;IACvD,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,YAAY,GAAG,IAAI,eAAe,CAAC,aAAa,CAAC,CAAC;IACpD,CAAC;IACD,OAAO,YAAY,CAAC;AACtB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "mycohive-claw",
3
+ "version": "4.0.0",
4
+ "description": "OpenClaw Plugin for Multi-Agent Orchestration with LLM Intent Routing",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "homepage": "https://github.com/LiamLucas-m/MycoHive-Claw#readme",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/LiamLucas-m/MycoHive-Claw.git"
12
+ },
13
+ "keywords": [
14
+ "openclaw",
15
+ "plugin",
16
+ "multi-agent",
17
+ "orchestration",
18
+ "llm",
19
+ "intent-analysis",
20
+ "intent-routing"
21
+ ],
22
+ "exports": {
23
+ ".": {
24
+ "import": "./dist/index.js",
25
+ "types": "./dist/index.d.ts"
26
+ }
27
+ },
28
+ "scripts": {
29
+ "build": "tsc",
30
+ "dev": "tsc --watch",
31
+ "typecheck": "tsc --noEmit"
32
+ },
33
+ "openclaw": {
34
+ "extensions": [
35
+ "./dist/index.js"
36
+ ],
37
+ "setupEntry": "./dist/setup-entry.js",
38
+ "channel": {
39
+ "id": "mycohive",
40
+ "label": "MycoHive",
41
+ "blurb": "Multi-Agent Orchestration with LLM Intent Routing"
42
+ }
43
+ },
44
+ "devDependencies": {
45
+ "@types/node": "^20.11.0",
46
+ "typescript": "^5.3.0"
47
+ },
48
+ "dependencies": {
49
+ "@types/yaml": "^1.9.6",
50
+ "yaml": "^2.8.3"
51
+ }
52
+ }
@@ -0,0 +1,31 @@
1
+ # CONFIG.md — API Developer
2
+
3
+ ## Agent 配置
4
+
5
+ ```yaml
6
+ agent_id: api_dev
7
+ agent_type: execution
8
+ display: 执行类
9
+ model: claude-sonnet-4-20250514
10
+ timeout: 300s
11
+ ```
12
+
13
+ ## 能力声明
14
+
15
+ ### 我能做什么
16
+ - REST API 设计
17
+ - GraphQL Schema 设计
18
+ - API 文档编写 (OpenAPI/Swagger)
19
+ - 接口测试
20
+
21
+ ### 我不能做什么
22
+ - 不实现业务逻辑(由 backend_dev 负责)
23
+ - 不设计数据库(由 data_engineer 负责)
24
+
25
+ ## 工具组
26
+
27
+ ```yaml
28
+ tools:
29
+ allow: [exec, read, write]
30
+ deny: [sessions_spawn, sessions_send]
31
+ ```
@@ -0,0 +1,8 @@
1
+ # RULES.md — API Developer
2
+
3
+ ## 行为红线
4
+
5
+ 1. **遵循 REST 规范** — 正确使用 HTTP 方法和状态码
6
+ 2. **文档同步** — 代码改动必须同步更新 API 文档
7
+ 3. **向后兼容** — API 变更必须考虑兼容策略
8
+ 4. **统一响应格式** — 所有接口使用一致的响应结构