mcp-agent-foundry 1.3.1 → 2.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.
- package/README.md +232 -1
- package/dist/background/index.d.ts +33 -0
- package/dist/background/index.d.ts.map +1 -0
- package/dist/background/index.js +33 -0
- package/dist/background/index.js.map +1 -0
- package/dist/background/task-runner.d.ts +177 -0
- package/dist/background/task-runner.d.ts.map +1 -0
- package/dist/background/task-runner.js +551 -0
- package/dist/background/task-runner.js.map +1 -0
- package/dist/background/types.d.ts +135 -0
- package/dist/background/types.d.ts.map +1 -0
- package/dist/background/types.js +8 -0
- package/dist/background/types.js.map +1 -0
- package/dist/failover/health-tracker.d.ts +81 -1
- package/dist/failover/health-tracker.d.ts.map +1 -1
- package/dist/failover/health-tracker.js +229 -1
- package/dist/failover/health-tracker.js.map +1 -1
- package/dist/hooks/hook-executor.d.ts +77 -0
- package/dist/hooks/hook-executor.d.ts.map +1 -0
- package/dist/hooks/hook-executor.js +308 -0
- package/dist/hooks/hook-executor.js.map +1 -0
- package/dist/hooks/hook-manager.d.ts +140 -0
- package/dist/hooks/hook-manager.d.ts.map +1 -0
- package/dist/hooks/hook-manager.js +520 -0
- package/dist/hooks/hook-manager.js.map +1 -0
- package/dist/hooks/index.d.ts +10 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +10 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/types.d.ts +221 -0
- package/dist/hooks/types.d.ts.map +1 -0
- package/dist/hooks/types.js +31 -0
- package/dist/hooks/types.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/mcp/auto-mode.d.ts +221 -0
- package/dist/mcp/auto-mode.d.ts.map +1 -0
- package/dist/mcp/auto-mode.js +436 -0
- package/dist/mcp/auto-mode.js.map +1 -0
- package/dist/mcp/index.d.ts +14 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +22 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/tools/tasks/delete-task.d.ts +25 -0
- package/dist/mcp/tools/tasks/delete-task.d.ts.map +1 -0
- package/dist/mcp/tools/tasks/delete-task.js +148 -0
- package/dist/mcp/tools/tasks/delete-task.js.map +1 -0
- package/dist/mcp/tools/tasks/index.d.ts +2 -0
- package/dist/mcp/tools/tasks/index.d.ts.map +1 -1
- package/dist/mcp/tools/tasks/index.js +6 -0
- package/dist/mcp/tools/tasks/index.js.map +1 -1
- package/dist/observability/debug-logger.d.ts +209 -0
- package/dist/observability/debug-logger.d.ts.map +1 -0
- package/dist/observability/debug-logger.js +430 -0
- package/dist/observability/debug-logger.js.map +1 -0
- package/dist/observability/index.d.ts +12 -0
- package/dist/observability/index.d.ts.map +1 -0
- package/dist/observability/index.js +12 -0
- package/dist/observability/index.js.map +1 -0
- package/dist/observability/logger.d.ts +180 -0
- package/dist/observability/logger.d.ts.map +1 -1
- package/dist/observability/logger.js +158 -0
- package/dist/observability/logger.js.map +1 -1
- package/dist/router/context-manager.d.ts +214 -1
- package/dist/router/context-manager.d.ts.map +1 -1
- package/dist/router/context-manager.js +759 -2
- package/dist/router/context-manager.js.map +1 -1
- package/dist/router/context-types.d.ts +182 -0
- package/dist/router/context-types.d.ts.map +1 -0
- package/dist/router/context-types.js +8 -0
- package/dist/router/context-types.js.map +1 -0
- package/dist/server.d.ts +41 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +165 -0
- package/dist/server.js.map +1 -1
- package/dist/skills/hot-reloader.d.ts +104 -0
- package/dist/skills/hot-reloader.d.ts.map +1 -0
- package/dist/skills/hot-reloader.js +314 -0
- package/dist/skills/hot-reloader.js.map +1 -0
- package/dist/skills/index.d.ts +14 -0
- package/dist/skills/index.d.ts.map +1 -0
- package/dist/skills/index.js +16 -0
- package/dist/skills/index.js.map +1 -0
- package/dist/skills/skill-executor.d.ts +96 -0
- package/dist/skills/skill-executor.d.ts.map +1 -0
- package/dist/skills/skill-executor.js +289 -0
- package/dist/skills/skill-executor.js.map +1 -0
- package/dist/skills/skill-loader.d.ts +147 -0
- package/dist/skills/skill-loader.d.ts.map +1 -0
- package/dist/skills/skill-loader.js +579 -0
- package/dist/skills/skill-loader.js.map +1 -0
- package/dist/skills/types.d.ts +198 -0
- package/dist/skills/types.d.ts.map +1 -0
- package/dist/skills/types.js +21 -0
- package/dist/skills/types.js.map +1 -0
- package/dist/tasks/coordinator.d.ts +22 -1
- package/dist/tasks/coordinator.d.ts.map +1 -1
- package/dist/tasks/coordinator.js +83 -0
- package/dist/tasks/coordinator.js.map +1 -1
- package/dist/tasks/state-coordinator.d.ts +19 -0
- package/dist/tasks/state-coordinator.d.ts.map +1 -1
- package/dist/tasks/state-coordinator.js +40 -0
- package/dist/tasks/state-coordinator.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skill Executor
|
|
3
|
+
*
|
|
4
|
+
* Executes skills with proper context handling.
|
|
5
|
+
* Supports forked, inherited, and isolated context modes.
|
|
6
|
+
*/
|
|
7
|
+
import { randomUUID } from 'crypto';
|
|
8
|
+
import { DEFAULT_SKILLS_CONFIG } from './types.js';
|
|
9
|
+
// ============================================================================
|
|
10
|
+
// Skill Executor Class
|
|
11
|
+
// ============================================================================
|
|
12
|
+
/**
|
|
13
|
+
* Executes skills with proper context handling.
|
|
14
|
+
* Manages context isolation, forking, and inheritance.
|
|
15
|
+
*/
|
|
16
|
+
export class SkillExecutor {
|
|
17
|
+
logger;
|
|
18
|
+
defaultContextMode;
|
|
19
|
+
constructor(logger, defaultContextMode) {
|
|
20
|
+
this.logger = logger.child({ component: 'SkillExecutor' });
|
|
21
|
+
this.defaultContextMode = defaultContextMode ?? DEFAULT_SKILLS_CONFIG.defaultContextMode;
|
|
22
|
+
this.logger.debug('SkillExecutor initialized', {
|
|
23
|
+
defaultContextMode: this.defaultContextMode,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
// ==========================================================================
|
|
27
|
+
// Execution Methods
|
|
28
|
+
// ==========================================================================
|
|
29
|
+
/**
|
|
30
|
+
* Execute a skill with the given context and input.
|
|
31
|
+
*
|
|
32
|
+
* @param skill - Skill definition to execute
|
|
33
|
+
* @param context - Execution context
|
|
34
|
+
* @param input - Input data for the skill
|
|
35
|
+
* @returns Execution result
|
|
36
|
+
*/
|
|
37
|
+
async execute(skill, context, input) {
|
|
38
|
+
const startTime = Date.now();
|
|
39
|
+
const contextMode = skill.context ?? this.defaultContextMode;
|
|
40
|
+
this.logger.debug('Executing skill', {
|
|
41
|
+
name: skill.name,
|
|
42
|
+
contextMode,
|
|
43
|
+
hasPrompt: !!input.prompt,
|
|
44
|
+
hasData: !!input.data,
|
|
45
|
+
});
|
|
46
|
+
try {
|
|
47
|
+
// Prepare execution context based on context mode
|
|
48
|
+
const executionContext = this.prepareContext(context, contextMode);
|
|
49
|
+
// Build system prompt
|
|
50
|
+
const systemPrompt = this.buildSystemPrompt(skill);
|
|
51
|
+
// Execute the skill
|
|
52
|
+
// Note: Actual execution would involve calling the provider
|
|
53
|
+
// This is a placeholder for the integration point
|
|
54
|
+
const output = await this.executeSkillLogic(skill, executionContext, input, systemPrompt);
|
|
55
|
+
const durationMs = Date.now() - startTime;
|
|
56
|
+
// Handle context modifications for inherit mode
|
|
57
|
+
const contextModifications = contextMode === 'inherit' ? this.extractContextModifications(output) : undefined;
|
|
58
|
+
this.logger.debug('Skill execution completed', {
|
|
59
|
+
name: skill.name,
|
|
60
|
+
durationMs,
|
|
61
|
+
success: true,
|
|
62
|
+
});
|
|
63
|
+
return {
|
|
64
|
+
success: true,
|
|
65
|
+
output,
|
|
66
|
+
contextModifications,
|
|
67
|
+
durationMs,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
const durationMs = Date.now() - startTime;
|
|
72
|
+
const errorInstance = error instanceof Error ? error : new Error(String(error));
|
|
73
|
+
this.logger.error('Skill execution failed', {
|
|
74
|
+
name: skill.name,
|
|
75
|
+
durationMs,
|
|
76
|
+
error: errorInstance,
|
|
77
|
+
});
|
|
78
|
+
return {
|
|
79
|
+
success: false,
|
|
80
|
+
error: errorInstance,
|
|
81
|
+
durationMs,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// ==========================================================================
|
|
86
|
+
// Context Methods
|
|
87
|
+
// ==========================================================================
|
|
88
|
+
/**
|
|
89
|
+
* Create forked context from parent context.
|
|
90
|
+
* Child context is a deep copy with reference to parent.
|
|
91
|
+
*
|
|
92
|
+
* @param parentContext - Parent context to fork from
|
|
93
|
+
* @returns Forked child context
|
|
94
|
+
*/
|
|
95
|
+
forkContext(parentContext) {
|
|
96
|
+
return {
|
|
97
|
+
sessionId: parentContext.sessionId,
|
|
98
|
+
taskId: parentContext.taskId,
|
|
99
|
+
worktreePath: parentContext.worktreePath,
|
|
100
|
+
parentContext,
|
|
101
|
+
variables: { ...parentContext.variables },
|
|
102
|
+
messages: parentContext.messages ? [...parentContext.messages] : undefined,
|
|
103
|
+
metadata: parentContext.metadata ? { ...parentContext.metadata } : undefined,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Create isolated context with no parent data.
|
|
108
|
+
* Only includes session ID for correlation.
|
|
109
|
+
*
|
|
110
|
+
* @param sessionId - Session ID to use
|
|
111
|
+
* @returns Fresh isolated context
|
|
112
|
+
*/
|
|
113
|
+
createIsolatedContext(sessionId) {
|
|
114
|
+
return {
|
|
115
|
+
sessionId,
|
|
116
|
+
variables: {},
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Create a new context for a session.
|
|
121
|
+
*
|
|
122
|
+
* @param sessionId - Optional session ID (generated if not provided)
|
|
123
|
+
* @returns New skill context
|
|
124
|
+
*/
|
|
125
|
+
createContext(sessionId) {
|
|
126
|
+
return {
|
|
127
|
+
sessionId: sessionId ?? randomUUID(),
|
|
128
|
+
variables: {},
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Prepare execution context based on context mode.
|
|
133
|
+
*
|
|
134
|
+
* @param context - Original context
|
|
135
|
+
* @param mode - Context handling mode
|
|
136
|
+
* @returns Prepared execution context
|
|
137
|
+
*/
|
|
138
|
+
prepareContext(context, mode) {
|
|
139
|
+
switch (mode) {
|
|
140
|
+
case 'fork':
|
|
141
|
+
return this.forkContext(context);
|
|
142
|
+
case 'isolated':
|
|
143
|
+
return this.createIsolatedContext(context.sessionId);
|
|
144
|
+
case 'inherit':
|
|
145
|
+
default:
|
|
146
|
+
return context;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
// ==========================================================================
|
|
150
|
+
// System Prompt Methods
|
|
151
|
+
// ==========================================================================
|
|
152
|
+
/**
|
|
153
|
+
* Build system prompt for skill execution.
|
|
154
|
+
* Combines skill's system prompt with role information.
|
|
155
|
+
*
|
|
156
|
+
* @param skill - Skill definition
|
|
157
|
+
* @returns Built system prompt
|
|
158
|
+
*/
|
|
159
|
+
buildSystemPrompt(skill) {
|
|
160
|
+
const parts = [];
|
|
161
|
+
// Add skill context
|
|
162
|
+
if (skill.displayName) {
|
|
163
|
+
parts.push(`You are executing the "${skill.displayName}" skill.`);
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
parts.push(`You are executing the "${skill.name}" skill.`);
|
|
167
|
+
}
|
|
168
|
+
if (skill.description) {
|
|
169
|
+
parts.push(`\nSkill purpose: ${skill.description}`);
|
|
170
|
+
}
|
|
171
|
+
// Add skill's custom system prompt
|
|
172
|
+
if (skill.systemPrompt) {
|
|
173
|
+
parts.push(`\n${skill.systemPrompt}`);
|
|
174
|
+
}
|
|
175
|
+
// Add tool restrictions if specified
|
|
176
|
+
if (skill.allowedTools && skill.allowedTools.length > 0) {
|
|
177
|
+
parts.push(`\nYou are restricted to using only the following tools: ${skill.allowedTools.join(', ')}`);
|
|
178
|
+
}
|
|
179
|
+
return parts.join('');
|
|
180
|
+
}
|
|
181
|
+
// ==========================================================================
|
|
182
|
+
// Context Modification Methods
|
|
183
|
+
// ==========================================================================
|
|
184
|
+
/**
|
|
185
|
+
* Apply context modifications back to parent context.
|
|
186
|
+
* Used when inherit mode skill execution completes.
|
|
187
|
+
*
|
|
188
|
+
* @param parentContext - Parent context to modify
|
|
189
|
+
* @param modifications - Modifications to apply
|
|
190
|
+
*/
|
|
191
|
+
applyContextModifications(parentContext, modifications) {
|
|
192
|
+
if (!modifications) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
// Apply variable modifications
|
|
196
|
+
if (modifications['variables'] && typeof modifications['variables'] === 'object') {
|
|
197
|
+
Object.assign(parentContext.variables, modifications['variables']);
|
|
198
|
+
}
|
|
199
|
+
// Apply metadata modifications
|
|
200
|
+
if (modifications['metadata'] && typeof modifications['metadata'] === 'object') {
|
|
201
|
+
parentContext.metadata = {
|
|
202
|
+
...parentContext.metadata,
|
|
203
|
+
...modifications['metadata'],
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
// Apply messages modifications (append)
|
|
207
|
+
if (Array.isArray(modifications['messages'])) {
|
|
208
|
+
if (!parentContext.messages) {
|
|
209
|
+
parentContext.messages = [];
|
|
210
|
+
}
|
|
211
|
+
parentContext.messages.push(...modifications['messages']);
|
|
212
|
+
}
|
|
213
|
+
this.logger.debug('Applied context modifications', {
|
|
214
|
+
sessionId: parentContext.sessionId,
|
|
215
|
+
modifiedKeys: Object.keys(modifications),
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
// ==========================================================================
|
|
219
|
+
// Private Methods
|
|
220
|
+
// ==========================================================================
|
|
221
|
+
/**
|
|
222
|
+
* Execute the actual skill logic.
|
|
223
|
+
* This is a placeholder for integration with the provider system.
|
|
224
|
+
*
|
|
225
|
+
* @param skill - Skill definition
|
|
226
|
+
* @param context - Execution context
|
|
227
|
+
* @param input - Input data
|
|
228
|
+
* @param systemPrompt - Built system prompt
|
|
229
|
+
* @returns Skill output
|
|
230
|
+
*/
|
|
231
|
+
async executeSkillLogic(skill, context, input, systemPrompt) {
|
|
232
|
+
// This is a placeholder for actual execution
|
|
233
|
+
// In a real implementation, this would:
|
|
234
|
+
// 1. Resolve the provider/model based on skill.role, skill.provider, skill.model
|
|
235
|
+
// 2. Build messages from context.messages and input.prompt
|
|
236
|
+
// 3. Call the provider's complete() method
|
|
237
|
+
// 4. Return the response
|
|
238
|
+
this.logger.debug('Skill logic execution (placeholder)', {
|
|
239
|
+
name: skill.name,
|
|
240
|
+
role: skill.role,
|
|
241
|
+
provider: skill.provider,
|
|
242
|
+
model: skill.model,
|
|
243
|
+
systemPromptLength: systemPrompt.length,
|
|
244
|
+
inputPrompt: input.prompt?.substring(0, 100),
|
|
245
|
+
});
|
|
246
|
+
// Return placeholder result
|
|
247
|
+
// The actual implementation should be connected to ProviderManager
|
|
248
|
+
return {
|
|
249
|
+
status: 'executed',
|
|
250
|
+
skill: skill.name,
|
|
251
|
+
sessionId: context.sessionId,
|
|
252
|
+
timestamp: new Date().toISOString(),
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Extract context modifications from skill output.
|
|
257
|
+
* Looks for a specific structure in the output.
|
|
258
|
+
*
|
|
259
|
+
* @param output - Skill execution output
|
|
260
|
+
* @returns Extracted modifications or undefined
|
|
261
|
+
*/
|
|
262
|
+
extractContextModifications(output) {
|
|
263
|
+
if (!output || typeof output !== 'object') {
|
|
264
|
+
return undefined;
|
|
265
|
+
}
|
|
266
|
+
const outputObj = output;
|
|
267
|
+
// Check for explicit context modifications
|
|
268
|
+
if (outputObj['contextModifications'] && typeof outputObj['contextModifications'] === 'object') {
|
|
269
|
+
return outputObj['contextModifications'];
|
|
270
|
+
}
|
|
271
|
+
// Check for implicit modifications (variables, metadata, messages keys at top level)
|
|
272
|
+
const implicitMods = {};
|
|
273
|
+
let hasImplicit = false;
|
|
274
|
+
if (outputObj['variables'] && typeof outputObj['variables'] === 'object') {
|
|
275
|
+
implicitMods['variables'] = outputObj['variables'];
|
|
276
|
+
hasImplicit = true;
|
|
277
|
+
}
|
|
278
|
+
if (outputObj['metadata'] && typeof outputObj['metadata'] === 'object') {
|
|
279
|
+
implicitMods['metadata'] = outputObj['metadata'];
|
|
280
|
+
hasImplicit = true;
|
|
281
|
+
}
|
|
282
|
+
if (Array.isArray(outputObj['messages'])) {
|
|
283
|
+
implicitMods['messages'] = outputObj['messages'];
|
|
284
|
+
hasImplicit = true;
|
|
285
|
+
}
|
|
286
|
+
return hasImplicit ? implicitMods : undefined;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
//# sourceMappingURL=skill-executor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skill-executor.js","sourceRoot":"","sources":["../../src/skills/skill-executor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAQpC,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEnD,+EAA+E;AAC/E,uBAAuB;AACvB,+EAA+E;AAE/E;;;GAGG;AACH,MAAM,OAAO,aAAa;IAChB,MAAM,CAAS;IACf,kBAAkB,CAAmB;IAE7C,YAAY,MAAc,EAAE,kBAAqC;QAC/D,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC,CAAC;QAC3D,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,IAAI,qBAAqB,CAAC,kBAAkB,CAAC;QAEzF,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,2BAA2B,EAAE;YAC7C,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;SAC5C,CAAC,CAAC;IACL,CAAC;IAED,6EAA6E;IAC7E,oBAAoB;IACpB,6EAA6E;IAE7E;;;;;;;OAOG;IACH,KAAK,CAAC,OAAO,CACX,KAAsB,EACtB,OAAqB,E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G,SAAS,CAAC,WAAW,CAAC,CAAC;YACnD,WAAW,GAAG,IAAI,CAAC;QACrB,CAAC;QAED,IAAI,SAAS,CAAC,UAAU,CAAC,IAAI,OAAO,SAAS,CAAC,UAAU,CAAC,KAAK,QAAQ,EAAE,CAAC;YACvE,YAAY,CAAC,UAAU,CAAC,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC;YACjD,WAAW,GAAG,IAAI,CAAC;QACrB,CAAC;QAED,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC;YACzC,YAAY,CAAC,UAAU,CAAC,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC;YACjD,WAAW,GAAG,IAAI,CAAC;QACrB,CAAC;QAED,OAAO,WAAW,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC;IAChD,CAAC;CACF"}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skill Loader
|
|
3
|
+
*
|
|
4
|
+
* Loads and manages skill definitions from YAML/JSON files.
|
|
5
|
+
* Handles file discovery, parsing, validation, and registration.
|
|
6
|
+
*/
|
|
7
|
+
import type { Logger } from '../observability/logger.js';
|
|
8
|
+
import type { SkillDefinition, SkillsConfig, SkillValidationResult, SkillMatch } from './types.js';
|
|
9
|
+
/**
|
|
10
|
+
* Loads and manages skill definitions from files.
|
|
11
|
+
* Provides methods for discovery, parsing, validation, and querying.
|
|
12
|
+
*/
|
|
13
|
+
export declare class SkillLoader {
|
|
14
|
+
private skills;
|
|
15
|
+
private config;
|
|
16
|
+
private logger;
|
|
17
|
+
private cooldownTracker;
|
|
18
|
+
constructor(config: Partial<SkillsConfig>, logger: Logger);
|
|
19
|
+
/**
|
|
20
|
+
* Load all skills from configured search paths.
|
|
21
|
+
* Searches each path in order and registers found skills.
|
|
22
|
+
*/
|
|
23
|
+
loadAll(): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Load skills from a specific directory.
|
|
26
|
+
* Returns array of successfully loaded skill definitions.
|
|
27
|
+
*
|
|
28
|
+
* @param dirPath - Directory path to search
|
|
29
|
+
* @returns Array of loaded skill definitions
|
|
30
|
+
*/
|
|
31
|
+
loadFromDirectory(dirPath: string): Promise<SkillDefinition[]>;
|
|
32
|
+
/**
|
|
33
|
+
* Load a single skill file.
|
|
34
|
+
* Parses, validates, and registers the skill.
|
|
35
|
+
*
|
|
36
|
+
* @param filePath - Path to the skill file
|
|
37
|
+
* @returns Loaded skill definition or null if failed
|
|
38
|
+
*/
|
|
39
|
+
loadSkillFile(filePath: string): Promise<SkillDefinition | null>;
|
|
40
|
+
/**
|
|
41
|
+
* Parse skill definition from file content.
|
|
42
|
+
* Supports YAML and JSON formats.
|
|
43
|
+
*
|
|
44
|
+
* @param content - File content
|
|
45
|
+
* @param filePath - Path to file (for error messages and format detection)
|
|
46
|
+
* @returns Parsed skill definition
|
|
47
|
+
*/
|
|
48
|
+
parseSkill(content: string, filePath: string): SkillDefinition;
|
|
49
|
+
/**
|
|
50
|
+
* Normalize parsed skill object to SkillDefinition.
|
|
51
|
+
* Applies defaults and type coercion.
|
|
52
|
+
*/
|
|
53
|
+
private normalizeSkill;
|
|
54
|
+
/**
|
|
55
|
+
* Parse triggers array from raw data.
|
|
56
|
+
*/
|
|
57
|
+
private parseTriggers;
|
|
58
|
+
/**
|
|
59
|
+
* Parse context mode from raw value.
|
|
60
|
+
*/
|
|
61
|
+
private parseContextMode;
|
|
62
|
+
/**
|
|
63
|
+
* Validate a skill definition.
|
|
64
|
+
* Returns validation result with errors and warnings.
|
|
65
|
+
*
|
|
66
|
+
* @param skill - Skill definition to validate
|
|
67
|
+
* @returns Validation result
|
|
68
|
+
*/
|
|
69
|
+
validateSkill(skill: SkillDefinition): SkillValidationResult;
|
|
70
|
+
/**
|
|
71
|
+
* Register a skill programmatically.
|
|
72
|
+
* Overwrites existing skill with same name.
|
|
73
|
+
*
|
|
74
|
+
* @param skill - Skill definition to register
|
|
75
|
+
*/
|
|
76
|
+
register(skill: SkillDefinition): void;
|
|
77
|
+
/**
|
|
78
|
+
* Unregister a skill by name.
|
|
79
|
+
*
|
|
80
|
+
* @param name - Skill name to unregister
|
|
81
|
+
* @returns True if skill was found and removed
|
|
82
|
+
*/
|
|
83
|
+
unregister(name: string): boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Check if a skill exists.
|
|
86
|
+
*
|
|
87
|
+
* @param name - Skill name
|
|
88
|
+
* @returns True if skill is registered
|
|
89
|
+
*/
|
|
90
|
+
has(name: string): boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Clear all loaded skills.
|
|
93
|
+
*/
|
|
94
|
+
clear(): void;
|
|
95
|
+
/**
|
|
96
|
+
* Get all loaded skills.
|
|
97
|
+
*
|
|
98
|
+
* @returns Array of all skill definitions
|
|
99
|
+
*/
|
|
100
|
+
getAllSkills(): SkillDefinition[];
|
|
101
|
+
/**
|
|
102
|
+
* Get skill by name.
|
|
103
|
+
*
|
|
104
|
+
* @param name - Skill name
|
|
105
|
+
* @returns Skill definition or undefined if not found
|
|
106
|
+
*/
|
|
107
|
+
getSkill(name: string): SkillDefinition | undefined;
|
|
108
|
+
/**
|
|
109
|
+
* Get the file path for a skill.
|
|
110
|
+
*
|
|
111
|
+
* @param name - Skill name
|
|
112
|
+
* @returns Source file path or undefined
|
|
113
|
+
*/
|
|
114
|
+
getSkillPath(name: string): string | undefined;
|
|
115
|
+
/**
|
|
116
|
+
* Get skills matching trigger conditions.
|
|
117
|
+
* Returns skills sorted by confidence score (highest first).
|
|
118
|
+
*
|
|
119
|
+
* @param context - Trigger context to match against
|
|
120
|
+
* @returns Array of matching skills with confidence scores
|
|
121
|
+
*/
|
|
122
|
+
getMatchingSkills(context: {
|
|
123
|
+
keywords?: string[];
|
|
124
|
+
event?: string;
|
|
125
|
+
text?: string;
|
|
126
|
+
}): SkillMatch[];
|
|
127
|
+
/**
|
|
128
|
+
* Reload a specific skill from its source file.
|
|
129
|
+
*
|
|
130
|
+
* @param name - Skill name to reload
|
|
131
|
+
* @returns True if skill was successfully reloaded
|
|
132
|
+
*/
|
|
133
|
+
reloadSkill(name: string): Promise<boolean>;
|
|
134
|
+
/**
|
|
135
|
+
* Expand ~ in paths to home directory.
|
|
136
|
+
*/
|
|
137
|
+
private expandPath;
|
|
138
|
+
/**
|
|
139
|
+
* Check if filename matches skill file patterns.
|
|
140
|
+
*/
|
|
141
|
+
private isSkillFile;
|
|
142
|
+
/**
|
|
143
|
+
* Match a trigger against the provided context.
|
|
144
|
+
*/
|
|
145
|
+
private matchTrigger;
|
|
146
|
+
}
|
|
147
|
+
//# sourceMappingURL=skill-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skill-loader.d.ts","sourceRoot":"","sources":["../../src/skills/skill-loader.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,KAAK,EACV,eAAe,EACf,YAAY,EAEZ,qBAAqB,EACrB,UAAU,EAEX,MAAM,YAAY,CAAC;AAOpB;;;GAGG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,MAAM,CAA2C;IACzD,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,eAAe,CAAkC;gBAE7C,MAAM,EAAE,OAAO,CAAC,YAAY,CAAC,EAAE,MAAM,EAAE,MAAM;IAezD;;;OAGG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAkC9B;;;;;;OAMG;IACG,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;IA4CpE;;;;;;OAMG;IACG,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;IAmDtE;;;;;;;OAOG;IACH,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,Q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