@shareai-lab/kode-sdk 1.0.0-beta.9 → 2.7.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 (193) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +115 -273
  3. package/README.zh-CN.md +114 -0
  4. package/dist/core/agent/breakpoint-manager.d.ts +16 -0
  5. package/dist/core/agent/breakpoint-manager.js +36 -0
  6. package/dist/core/agent/message-queue.d.ts +26 -0
  7. package/dist/core/agent/message-queue.js +57 -0
  8. package/dist/core/agent/permission-manager.d.ts +9 -0
  9. package/dist/core/agent/permission-manager.js +32 -0
  10. package/dist/core/agent/todo-manager.d.ts +26 -0
  11. package/dist/core/agent/todo-manager.js +91 -0
  12. package/dist/core/agent/tool-runner.d.ts +9 -0
  13. package/dist/core/agent/tool-runner.js +45 -0
  14. package/dist/core/agent.d.ts +228 -62
  15. package/dist/core/agent.js +1890 -615
  16. package/dist/core/config.d.ts +10 -0
  17. package/dist/core/config.js +2 -0
  18. package/dist/core/context-manager.d.ts +82 -0
  19. package/dist/core/context-manager.js +241 -0
  20. package/dist/core/errors.d.ts +22 -0
  21. package/dist/core/errors.js +49 -0
  22. package/dist/core/events.d.ts +41 -10
  23. package/dist/core/events.js +270 -68
  24. package/dist/core/file-pool.d.ts +41 -0
  25. package/dist/core/file-pool.js +102 -0
  26. package/dist/core/hooks.d.ts +3 -3
  27. package/dist/core/hooks.js +1 -1
  28. package/dist/core/permission-modes.d.ts +31 -0
  29. package/dist/core/permission-modes.js +61 -0
  30. package/dist/core/pool.d.ts +56 -13
  31. package/dist/core/pool.js +244 -34
  32. package/dist/core/room.d.ts +2 -2
  33. package/dist/core/room.js +10 -10
  34. package/dist/core/scheduler.d.ts +30 -23
  35. package/dist/core/scheduler.js +42 -168
  36. package/dist/core/skills/index.d.ts +10 -0
  37. package/dist/core/skills/index.js +20 -0
  38. package/dist/core/skills/management-manager.d.ts +130 -0
  39. package/dist/core/skills/management-manager.js +557 -0
  40. package/dist/core/skills/manager.d.ts +47 -0
  41. package/dist/core/skills/manager.js +243 -0
  42. package/dist/core/skills/operation-queue.d.ts +87 -0
  43. package/dist/core/skills/operation-queue.js +113 -0
  44. package/dist/core/skills/sandbox-file-manager.d.ts +82 -0
  45. package/dist/core/skills/sandbox-file-manager.js +183 -0
  46. package/dist/core/skills/types.d.ts +120 -0
  47. package/dist/core/skills/types.js +9 -0
  48. package/dist/core/skills/xml-generator.d.ts +13 -0
  49. package/dist/core/skills/xml-generator.js +70 -0
  50. package/dist/core/template.d.ts +57 -0
  51. package/dist/core/template.js +35 -0
  52. package/dist/core/time-bridge.d.ts +18 -0
  53. package/dist/core/time-bridge.js +100 -0
  54. package/dist/core/todo.d.ts +34 -0
  55. package/dist/core/todo.js +89 -0
  56. package/dist/core/types.d.ts +311 -114
  57. package/dist/core/types.js +1 -12
  58. package/dist/index.d.ts +47 -9
  59. package/dist/index.js +108 -15
  60. package/dist/infra/db/postgres/postgres-store.d.ts +97 -0
  61. package/dist/infra/db/postgres/postgres-store.js +1073 -0
  62. package/dist/infra/db/sqlite/sqlite-store.d.ts +84 -0
  63. package/dist/infra/db/sqlite/sqlite-store.js +800 -0
  64. package/dist/infra/e2b/e2b-fs.d.ts +29 -0
  65. package/dist/infra/e2b/e2b-fs.js +128 -0
  66. package/dist/infra/e2b/e2b-sandbox.d.ts +37 -0
  67. package/dist/infra/e2b/e2b-sandbox.js +156 -0
  68. package/dist/infra/e2b/e2b-template.d.ts +24 -0
  69. package/dist/infra/e2b/e2b-template.js +105 -0
  70. package/dist/infra/e2b/index.d.ts +4 -0
  71. package/dist/infra/e2b/index.js +9 -0
  72. package/dist/infra/e2b/types.d.ts +46 -0
  73. package/dist/infra/e2b/types.js +2 -0
  74. package/dist/infra/provider.d.ts +17 -58
  75. package/dist/infra/provider.js +65 -116
  76. package/dist/infra/providers/anthropic.d.ts +42 -0
  77. package/dist/infra/providers/anthropic.js +308 -0
  78. package/dist/infra/providers/core/errors.d.ts +230 -0
  79. package/dist/infra/providers/core/errors.js +353 -0
  80. package/dist/infra/providers/core/fork.d.ts +106 -0
  81. package/dist/infra/providers/core/fork.js +418 -0
  82. package/dist/infra/providers/core/index.d.ts +10 -0
  83. package/dist/infra/providers/core/index.js +76 -0
  84. package/dist/infra/providers/core/logger.d.ts +186 -0
  85. package/dist/infra/providers/core/logger.js +191 -0
  86. package/dist/infra/providers/core/retry.d.ts +62 -0
  87. package/dist/infra/providers/core/retry.js +189 -0
  88. package/dist/infra/providers/core/usage.d.ts +151 -0
  89. package/dist/infra/providers/core/usage.js +376 -0
  90. package/dist/infra/providers/gemini.d.ts +49 -0
  91. package/dist/infra/providers/gemini.js +493 -0
  92. package/dist/infra/providers/index.d.ts +25 -0
  93. package/dist/infra/providers/index.js +83 -0
  94. package/dist/infra/providers/openai.d.ts +123 -0
  95. package/dist/infra/providers/openai.js +662 -0
  96. package/dist/infra/providers/types.d.ts +334 -0
  97. package/dist/infra/providers/types.js +20 -0
  98. package/dist/infra/providers/utils.d.ts +53 -0
  99. package/dist/infra/providers/utils.js +400 -0
  100. package/dist/infra/sandbox-factory.d.ts +13 -0
  101. package/dist/infra/sandbox-factory.js +30 -0
  102. package/dist/infra/sandbox.d.ts +35 -6
  103. package/dist/infra/sandbox.js +174 -8
  104. package/dist/infra/store/factory.d.ts +45 -0
  105. package/dist/infra/store/factory.js +80 -0
  106. package/dist/infra/store/index.d.ts +3 -0
  107. package/dist/infra/store/index.js +26 -0
  108. package/dist/infra/store/json-store.d.ts +67 -0
  109. package/dist/infra/store/json-store.js +606 -0
  110. package/dist/infra/store/types.d.ts +342 -0
  111. package/dist/infra/store/types.js +2 -0
  112. package/dist/infra/store.d.ts +12 -32
  113. package/dist/infra/store.js +27 -130
  114. package/dist/tools/bash_kill/index.d.ts +1 -0
  115. package/dist/tools/bash_kill/index.js +35 -0
  116. package/dist/tools/bash_kill/prompt.d.ts +2 -0
  117. package/dist/tools/bash_kill/prompt.js +14 -0
  118. package/dist/tools/bash_logs/index.d.ts +1 -0
  119. package/dist/tools/bash_logs/index.js +40 -0
  120. package/dist/tools/bash_logs/prompt.d.ts +2 -0
  121. package/dist/tools/bash_logs/prompt.js +14 -0
  122. package/dist/tools/bash_run/index.d.ts +16 -0
  123. package/dist/tools/bash_run/index.js +61 -0
  124. package/dist/tools/bash_run/prompt.d.ts +2 -0
  125. package/dist/tools/bash_run/prompt.js +18 -0
  126. package/dist/tools/builtin.d.ts +7 -13
  127. package/dist/tools/builtin.js +19 -90
  128. package/dist/tools/define.d.ts +101 -0
  129. package/dist/tools/define.js +214 -0
  130. package/dist/tools/fs_edit/index.d.ts +1 -0
  131. package/dist/tools/fs_edit/index.js +62 -0
  132. package/dist/tools/fs_edit/prompt.d.ts +2 -0
  133. package/dist/tools/fs_edit/prompt.js +15 -0
  134. package/dist/tools/fs_glob/index.d.ts +1 -0
  135. package/dist/tools/fs_glob/index.js +40 -0
  136. package/dist/tools/fs_glob/prompt.d.ts +2 -0
  137. package/dist/tools/fs_glob/prompt.js +15 -0
  138. package/dist/tools/fs_grep/index.d.ts +1 -0
  139. package/dist/tools/fs_grep/index.js +66 -0
  140. package/dist/tools/fs_grep/prompt.d.ts +2 -0
  141. package/dist/tools/fs_grep/prompt.js +16 -0
  142. package/dist/tools/fs_multi_edit/index.d.ts +1 -0
  143. package/dist/tools/fs_multi_edit/index.js +106 -0
  144. package/dist/tools/fs_multi_edit/prompt.d.ts +2 -0
  145. package/dist/tools/fs_multi_edit/prompt.js +16 -0
  146. package/dist/tools/fs_read/index.d.ts +1 -0
  147. package/dist/tools/fs_read/index.js +40 -0
  148. package/dist/tools/fs_read/prompt.d.ts +2 -0
  149. package/dist/tools/fs_read/prompt.js +16 -0
  150. package/dist/tools/fs_write/index.d.ts +1 -0
  151. package/dist/tools/fs_write/index.js +40 -0
  152. package/dist/tools/fs_write/prompt.d.ts +2 -0
  153. package/dist/tools/fs_write/prompt.js +15 -0
  154. package/dist/tools/index.d.ts +11 -0
  155. package/dist/tools/index.js +61 -0
  156. package/dist/tools/mcp.d.ts +69 -0
  157. package/dist/tools/mcp.js +185 -0
  158. package/dist/tools/registry.d.ts +29 -0
  159. package/dist/tools/registry.js +26 -0
  160. package/dist/tools/scripts.d.ts +22 -0
  161. package/dist/tools/scripts.js +205 -0
  162. package/dist/tools/skills.d.ts +20 -0
  163. package/dist/tools/skills.js +115 -0
  164. package/dist/tools/task_run/index.d.ts +7 -0
  165. package/dist/tools/task_run/index.js +58 -0
  166. package/dist/tools/task_run/prompt.d.ts +5 -0
  167. package/dist/tools/task_run/prompt.js +25 -0
  168. package/dist/tools/todo_read/index.d.ts +1 -0
  169. package/dist/tools/todo_read/index.js +29 -0
  170. package/dist/tools/todo_read/prompt.d.ts +2 -0
  171. package/dist/tools/todo_read/prompt.js +18 -0
  172. package/dist/tools/todo_write/index.d.ts +1 -0
  173. package/dist/tools/todo_write/index.js +42 -0
  174. package/dist/tools/todo_write/prompt.d.ts +2 -0
  175. package/dist/tools/todo_write/prompt.js +23 -0
  176. package/dist/tools/tool.d.ts +43 -0
  177. package/dist/tools/tool.js +211 -0
  178. package/dist/tools/toolkit.d.ts +69 -0
  179. package/dist/tools/toolkit.js +98 -0
  180. package/dist/tools/type-inference.d.ts +127 -0
  181. package/dist/tools/type-inference.js +207 -0
  182. package/dist/utils/agent-id.d.ts +1 -0
  183. package/dist/utils/agent-id.js +28 -0
  184. package/dist/utils/logger.d.ts +15 -0
  185. package/dist/utils/logger.js +44 -0
  186. package/dist/utils/session-id.js +16 -16
  187. package/package.json +35 -11
  188. package/dist/tools/bash.d.ts +0 -63
  189. package/dist/tools/bash.js +0 -92
  190. package/dist/tools/fs.d.ts +0 -96
  191. package/dist/tools/fs.js +0 -100
  192. package/dist/tools/task.d.ts +0 -38
  193. package/dist/tools/task.js +0 -45
@@ -1,184 +1,58 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AgentSchedulerHandle = exports.Scheduler = void 0;
3
+ exports.Scheduler = void 0;
4
4
  class Scheduler {
5
- constructor() {
6
- this.tasks = new Map();
7
- this.stepCounters = new Map();
8
- this.timers = [];
9
- }
10
- every(interval, callback) {
11
- const ms = this.parseInterval(interval);
12
- const id = `time-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
13
- const task = {
14
- id,
15
- type: 'time',
16
- spec: interval,
17
- callback,
18
- enabled: true,
19
- };
20
- this.tasks.set(id, task);
21
- const timer = setInterval(() => {
22
- if (task.enabled) {
23
- task.callback({ count: 0, type: 'time', id });
24
- task.lastRun = Date.now();
25
- }
26
- }, ms);
27
- this.timers.push(timer);
28
- return this;
29
- }
30
- everySteps(steps, callback, targetId) {
31
- const id = targetId || `step-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
32
- const task = {
33
- id,
34
- type: 'step',
35
- spec: steps,
36
- callback,
37
- enabled: true,
38
- };
39
- this.tasks.set(id, task);
40
- this.stepCounters.set(id, 0);
41
- return this;
42
- }
43
- daily(time, callback) {
44
- const id = `daily-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
45
- const task = {
46
- id,
47
- type: 'daily',
48
- spec: time,
49
- callback,
50
- enabled: true,
51
- };
52
- this.tasks.set(id, task);
53
- this.scheduleDailyTask(task);
54
- return this;
55
- }
56
- weekly(dayTime, callback) {
57
- const id = `weekly-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
58
- const task = {
5
+ constructor(opts) {
6
+ this.stepTasks = new Map();
7
+ this.listeners = new Set();
8
+ this.queued = Promise.resolve();
9
+ this.onTrigger = opts?.onTrigger;
10
+ }
11
+ everySteps(every, callback) {
12
+ if (!Number.isFinite(every) || every <= 0) {
13
+ throw new Error('everySteps: interval must be positive');
14
+ }
15
+ const id = this.generateId('steps');
16
+ this.stepTasks.set(id, {
59
17
  id,
60
- type: 'weekly',
61
- spec: dayTime,
18
+ every,
62
19
  callback,
63
- enabled: true,
64
- };
65
- this.tasks.set(id, task);
66
- this.scheduleWeeklyTask(task);
67
- return this;
20
+ lastTriggered: 0,
21
+ });
22
+ return id;
68
23
  }
69
- notifyStep(targetId) {
70
- for (const [id, task] of this.tasks) {
71
- if (task.type === 'step' && (!targetId || id === targetId)) {
72
- const count = (this.stepCounters.get(id) || 0) + 1;
73
- this.stepCounters.set(id, count);
74
- if (count >= task.spec) {
75
- task.callback({ count, type: 'step', id });
76
- this.stepCounters.set(id, 0);
77
- task.lastRun = Date.now();
78
- }
79
- }
80
- }
24
+ onStep(callback) {
25
+ this.listeners.add(callback);
26
+ return () => this.listeners.delete(callback);
81
27
  }
82
- stop() {
83
- for (const timer of this.timers) {
84
- clearInterval(timer);
85
- }
86
- this.timers = [];
87
- this.tasks.clear();
88
- this.stepCounters.clear();
89
- }
90
- parseInterval(interval) {
91
- const match = interval.match(/^(\d+)(s|m|h|d)$/);
92
- if (!match)
93
- throw new Error(`Invalid interval: ${interval}`);
94
- const value = parseInt(match[1], 10);
95
- const unit = match[2];
96
- switch (unit) {
97
- case 's':
98
- return value * 1000;
99
- case 'm':
100
- return value * 60 * 1000;
101
- case 'h':
102
- return value * 60 * 60 * 1000;
103
- case 'd':
104
- return value * 24 * 60 * 60 * 1000;
105
- default:
106
- throw new Error(`Unknown unit: ${unit}`);
107
- }
28
+ enqueue(callback) {
29
+ this.queued = this.queued.then(() => Promise.resolve(callback())).catch(() => undefined);
108
30
  }
109
- scheduleDailyTask(task) {
110
- const [hours, minutes] = task.spec.split(':').map(Number);
111
- const now = new Date();
112
- const target = new Date(now.getFullYear(), now.getMonth(), now.getDate(), hours, minutes, 0);
113
- if (target.getTime() <= now.getTime()) {
114
- target.setDate(target.getDate() + 1);
31
+ notifyStep(stepCount) {
32
+ for (const listener of this.listeners) {
33
+ void Promise.resolve(listener({ stepCount }));
115
34
  }
116
- const delay = target.getTime() - now.getTime();
117
- const timeout = setTimeout(() => {
118
- if (task.enabled) {
119
- task.callback({ time: task.spec, type: 'daily', id: task.id });
120
- task.lastRun = Date.now();
121
- }
122
- this.scheduleDailyTask(task);
123
- }, delay);
124
- this.timers.push(timeout);
125
- }
126
- scheduleWeeklyTask(task) {
127
- const [day, time] = task.spec.split(' ');
128
- const [hours, minutes] = time.split(':').map(Number);
129
- const dayMap = {
130
- Sun: 0,
131
- Mon: 1,
132
- Tue: 2,
133
- Wed: 3,
134
- Thu: 4,
135
- Fri: 5,
136
- Sat: 6,
137
- };
138
- const targetDay = dayMap[day];
139
- if (targetDay === undefined)
140
- throw new Error(`Invalid day: ${day}`);
141
- const now = new Date();
142
- const target = new Date(now);
143
- target.setHours(hours, minutes, 0, 0);
144
- const currentDay = now.getDay();
145
- let daysUntilTarget = targetDay - currentDay;
146
- if (daysUntilTarget < 0 || (daysUntilTarget === 0 && target.getTime() <= now.getTime())) {
147
- daysUntilTarget += 7;
35
+ for (const task of this.stepTasks.values()) {
36
+ const shouldTrigger = stepCount - task.lastTriggered >= task.every;
37
+ if (!shouldTrigger)
38
+ continue;
39
+ task.lastTriggered = stepCount;
40
+ void Promise.resolve(task.callback({ stepCount }));
41
+ this.onTrigger?.({ taskId: task.id, spec: `steps:${task.every}`, kind: 'steps' });
148
42
  }
149
- target.setDate(target.getDate() + daysUntilTarget);
150
- const delay = target.getTime() - now.getTime();
151
- const timeout = setTimeout(() => {
152
- if (task.enabled) {
153
- task.callback({ time: task.spec, type: 'weekly', id: task.id });
154
- task.lastRun = Date.now();
155
- }
156
- this.scheduleWeeklyTask(task);
157
- }, delay);
158
- this.timers.push(timeout);
159
43
  }
160
- }
161
- exports.Scheduler = Scheduler;
162
- class AgentSchedulerHandle {
163
- constructor(scheduler, agentId) {
164
- this.scheduler = scheduler;
165
- this.agentId = agentId;
44
+ cancel(taskId) {
45
+ this.stepTasks.delete(taskId);
166
46
  }
167
- every(interval, callback) {
168
- this.scheduler.every(interval, callback);
169
- return this;
47
+ clear() {
48
+ this.stepTasks.clear();
49
+ this.listeners.clear();
170
50
  }
171
- everySteps(steps, callback) {
172
- this.scheduler.everySteps(steps, callback, this.agentId);
173
- return this;
51
+ notifyExternalTrigger(info) {
52
+ this.onTrigger?.(info);
174
53
  }
175
- daily(time, callback) {
176
- this.scheduler.daily(time, callback);
177
- return this;
178
- }
179
- weekly(dayTime, callback) {
180
- this.scheduler.weekly(dayTime, callback);
181
- return this;
54
+ generateId(prefix) {
55
+ return `${prefix}-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
182
56
  }
183
57
  }
184
- exports.AgentSchedulerHandle = AgentSchedulerHandle;
58
+ exports.Scheduler = Scheduler;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Skills 模块导出
3
+ */
4
+ export { SkillsManager } from './manager';
5
+ export type { SkillMetadata, SkillContent, SandboxConfig } from './types';
6
+ export { generateSkillsMetadataXml } from './xml-generator';
7
+ export { SkillsManagementManager } from './management-manager';
8
+ export { OperationQueue, OperationType, OperationStatus } from './operation-queue';
9
+ export { SandboxFileManager } from './sandbox-file-manager';
10
+ export type { SkillInfo, SkillDetail, SkillFileTree, CreateSkillOptions, ArchivedSkillInfo, } from './types';
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ /**
3
+ * Skills 模块导出
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.SandboxFileManager = exports.OperationStatus = exports.OperationType = exports.OperationQueue = exports.SkillsManagementManager = exports.generateSkillsMetadataXml = exports.SkillsManager = void 0;
7
+ // 路径2: Agent使用(现有模块)
8
+ var manager_1 = require("./manager");
9
+ Object.defineProperty(exports, "SkillsManager", { enumerable: true, get: function () { return manager_1.SkillsManager; } });
10
+ var xml_generator_1 = require("./xml-generator");
11
+ Object.defineProperty(exports, "generateSkillsMetadataXml", { enumerable: true, get: function () { return xml_generator_1.generateSkillsMetadataXml; } });
12
+ // 路径1: 技能管理(新增模块)
13
+ var management_manager_1 = require("./management-manager");
14
+ Object.defineProperty(exports, "SkillsManagementManager", { enumerable: true, get: function () { return management_manager_1.SkillsManagementManager; } });
15
+ var operation_queue_1 = require("./operation-queue");
16
+ Object.defineProperty(exports, "OperationQueue", { enumerable: true, get: function () { return operation_queue_1.OperationQueue; } });
17
+ Object.defineProperty(exports, "OperationType", { enumerable: true, get: function () { return operation_queue_1.OperationType; } });
18
+ Object.defineProperty(exports, "OperationStatus", { enumerable: true, get: function () { return operation_queue_1.OperationStatus; } });
19
+ var sandbox_file_manager_1 = require("./sandbox-file-manager");
20
+ Object.defineProperty(exports, "SandboxFileManager", { enumerable: true, get: function () { return sandbox_file_manager_1.SandboxFileManager; } });
@@ -0,0 +1,130 @@
1
+ /**
2
+ * 技能管理器模块(路径1 - 技能管理)
3
+ *
4
+ * 设计原则 (UNIX哲学):
5
+ * - 简洁: 只负责技能文件系统的CRUD操作
6
+ * - 模块化: 协调OperationQueue、SandboxFileManager进行文件系统操作
7
+ * - 隔离: 与Agent运行时完全隔离,不参与Agent使用
8
+ *
9
+ * ⚠️ 重要说明:
10
+ * - 此模块专门用于路径1(技能管理)
11
+ * - 与路径2(Agent运行时)完全独立
12
+ * - 请勿与SkillsManager混淆
13
+ */
14
+ import { OperationTask } from './operation-queue';
15
+ import type { SkillInfo, SkillDetail, SkillFileTree, CreateSkillOptions, ArchivedSkillInfo } from './types';
16
+ import { SandboxFactory } from '../../infra/sandbox-factory';
17
+ /**
18
+ * 技能管理器类
19
+ *
20
+ * 职责:
21
+ * - 提供所有技能管理操作的统一接口(CRUD操作)
22
+ * - 协调OperationQueue、SandboxFileManager进行文件系统操作
23
+ * - 处理业务逻辑和权限验证
24
+ * - ❌ 不参与Agent运行时
25
+ * - ❌ 不提供技能加载、扫描等Agent使用的功能
26
+ */
27
+ export declare class SkillsManagementManager {
28
+ private skillsManager;
29
+ private operationQueue;
30
+ private sandboxFileManager;
31
+ private skillsDir;
32
+ private archivedDir;
33
+ constructor(skillsDir: string, sandboxFactory?: SandboxFactory, archivedDir?: string);
34
+ /**
35
+ * 获取所有在线技能列表(不包含archived技能)
36
+ */
37
+ listSkills(): Promise<SkillInfo[]>;
38
+ /**
39
+ * 获取单个在线技能详细信息
40
+ * @param skillName 技能名称
41
+ */
42
+ getSkillInfo(skillName: string): Promise<SkillDetail | null>;
43
+ /**
44
+ * 获取已归档技能列表(只读,不支持修改)
45
+ */
46
+ listArchivedSkills(): Promise<ArchivedSkillInfo[]>;
47
+ /**
48
+ * 创建新技能
49
+ * @param skillName 技能名称
50
+ * @param options 技能配置(名称、描述等)
51
+ */
52
+ createSkill(skillName: string, options: CreateSkillOptions): Promise<SkillDetail>;
53
+ /**
54
+ * 重命名技能
55
+ * @param oldName 旧技能名称
56
+ * @param newName 新技能名称
57
+ */
58
+ renameSkill(oldName: string, newName: string): Promise<void>;
59
+ /**
60
+ * 编辑技能文件
61
+ * @param skillName 技能名称
62
+ * @param filePath 文件路径(相对于技能根目录,如"SKILL.md")
63
+ * @param content 文件内容
64
+ * @param useSandbox 是否使用sandbox(默认true)
65
+ */
66
+ editSkillFile(skillName: string, filePath: string, content: string, useSandbox?: boolean): Promise<void>;
67
+ /**
68
+ * 删除技能(移动到archived)
69
+ * @param skillName 技能名称
70
+ */
71
+ deleteSkill(skillName: string): Promise<void>;
72
+ /**
73
+ * 恢复已删除的技能
74
+ * @param archivedSkillName archived中的技能名称(含时间戳)
75
+ */
76
+ restoreSkill(archivedSkillName: string): Promise<void>;
77
+ /**
78
+ * 获取技能文件树(仅在线技能)
79
+ * @param skillName 技能名称
80
+ */
81
+ getSkillFileTree(skillName: string): Promise<SkillFileTree>;
82
+ /**
83
+ * 获取队列状态
84
+ */
85
+ getQueueStatus(): {
86
+ length: number;
87
+ processing: boolean;
88
+ tasks: OperationTask[];
89
+ };
90
+ /**
91
+ * 执行创建技能
92
+ */
93
+ private doCreateSkill;
94
+ /**
95
+ * 执行重命名技能
96
+ */
97
+ private doRenameSkill;
98
+ /**
99
+ * 执行编辑技能文件
100
+ */
101
+ private doEditSkillFile;
102
+ /**
103
+ * 执行删除技能
104
+ */
105
+ private doDeleteSkill;
106
+ /**
107
+ * 执行恢复技能
108
+ */
109
+ private doRestoreSkill;
110
+ /**
111
+ * 验证技能名称
112
+ */
113
+ private isValidSkillName;
114
+ /**
115
+ * 生成SKILL.md内容
116
+ */
117
+ private generateSkillMd;
118
+ /**
119
+ * 检查文件是否存在
120
+ */
121
+ private fileExists;
122
+ /**
123
+ * 安全获取文件统计信息
124
+ */
125
+ private safeGetFileStat;
126
+ /**
127
+ * 等待任务完成
128
+ */
129
+ private waitForTask;
130
+ }