musubi-sdd 3.5.1 → 3.6.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.
- package/README.md +25 -3
- package/bin/musubi-orchestrate.js +309 -0
- package/package.json +1 -1
- package/src/llm-providers/anthropic-provider.js +175 -0
- package/src/llm-providers/base-provider.js +221 -0
- package/src/llm-providers/copilot-provider.js +262 -0
- package/src/llm-providers/index.js +214 -0
- package/src/llm-providers/openai-provider.js +205 -0
- package/src/orchestration/index.js +25 -0
- package/src/orchestration/patterns/swarm.js +111 -4
- package/src/orchestration/replanning/adaptive-goal-modifier.js +1150 -0
- package/src/orchestration/replanning/alternative-generator.js +508 -0
- package/src/orchestration/replanning/config.js +378 -0
- package/src/orchestration/replanning/goal-progress-tracker.js +727 -0
- package/src/orchestration/replanning/index.js +82 -0
- package/src/orchestration/replanning/plan-evaluator.js +455 -0
- package/src/orchestration/replanning/plan-monitor.js +379 -0
- package/src/orchestration/replanning/proactive-path-optimizer.js +972 -0
- package/src/orchestration/replanning/replan-history.js +402 -0
- package/src/orchestration/replanning/replanning-engine.js +706 -0
- package/src/templates/agents/claude-code/CLAUDE.md +45 -0
- package/src/templates/agents/claude-code/skills/orchestrator/SKILL.md +20 -0
- package/src/templates/agents/claude-code/skills/orchestrator/patterns.md +89 -0
- package/src/templates/agents/codex/AGENTS.md +13 -0
- package/src/templates/agents/cursor/AGENTS.md +13 -0
- package/src/templates/agents/gemini-cli/GEMINI.md +13 -0
- package/src/templates/agents/github-copilot/AGENTS.md +13 -0
- package/src/templates/agents/qwen-code/QWEN.md +13 -0
- package/src/templates/agents/windsurf/AGENTS.md +13 -0
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Default configuration for MUSUBI Replanning Engine
|
|
3
|
+
* @module orchestration/replanning/config
|
|
4
|
+
* @version 1.0.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
'use strict';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Replanning trigger types
|
|
11
|
+
* @enum {string}
|
|
12
|
+
*/
|
|
13
|
+
const ReplanTrigger = {
|
|
14
|
+
/** Task execution failed */
|
|
15
|
+
TASK_FAILED: 'task-failed',
|
|
16
|
+
|
|
17
|
+
/** Task execution timed out */
|
|
18
|
+
TIMEOUT: 'timeout',
|
|
19
|
+
|
|
20
|
+
/** Context or requirements changed */
|
|
21
|
+
CONTEXT_CHANGED: 'context-changed',
|
|
22
|
+
|
|
23
|
+
/** A more efficient path was discovered */
|
|
24
|
+
BETTER_PATH_FOUND: 'better-path-found',
|
|
25
|
+
|
|
26
|
+
/** Human operator requested replanning */
|
|
27
|
+
HUMAN_REQUEST: 'human-request',
|
|
28
|
+
|
|
29
|
+
/** Goal determined to be unreachable with current approach */
|
|
30
|
+
GOAL_UNREACHABLE: 'goal-unreachable',
|
|
31
|
+
|
|
32
|
+
/** Resource constraints changed */
|
|
33
|
+
RESOURCE_CHANGED: 'resource-changed'
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Replanning decision types
|
|
38
|
+
* @enum {string}
|
|
39
|
+
*/
|
|
40
|
+
const ReplanDecision = {
|
|
41
|
+
/** Continue with current plan */
|
|
42
|
+
CONTINUE: 'continue',
|
|
43
|
+
|
|
44
|
+
/** Retry the failed task */
|
|
45
|
+
RETRY: 'retry',
|
|
46
|
+
|
|
47
|
+
/** Skip the failed task */
|
|
48
|
+
SKIP: 'skip',
|
|
49
|
+
|
|
50
|
+
/** Replace task with alternative */
|
|
51
|
+
REPLACE: 'replace',
|
|
52
|
+
|
|
53
|
+
/** Insert new tasks into plan */
|
|
54
|
+
INSERT: 'insert',
|
|
55
|
+
|
|
56
|
+
/** Remove tasks from plan */
|
|
57
|
+
REMOVE: 'remove',
|
|
58
|
+
|
|
59
|
+
/** Reorder remaining tasks */
|
|
60
|
+
REORDER: 'reorder',
|
|
61
|
+
|
|
62
|
+
/** Abort execution */
|
|
63
|
+
ABORT: 'abort',
|
|
64
|
+
|
|
65
|
+
/** Request human intervention */
|
|
66
|
+
HUMAN_REVIEW: 'human-review'
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Default replanning configuration
|
|
71
|
+
*/
|
|
72
|
+
const defaultReplanningConfig = {
|
|
73
|
+
/**
|
|
74
|
+
* Enable replanning feature
|
|
75
|
+
* @type {boolean}
|
|
76
|
+
*/
|
|
77
|
+
enabled: true,
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* LLM provider configuration
|
|
81
|
+
*/
|
|
82
|
+
llmProvider: {
|
|
83
|
+
/**
|
|
84
|
+
* Provider selection: 'auto', 'github-copilot', 'anthropic', 'openai'
|
|
85
|
+
* @type {string}
|
|
86
|
+
*/
|
|
87
|
+
provider: 'auto',
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Model override (optional)
|
|
91
|
+
* @type {string|null}
|
|
92
|
+
*/
|
|
93
|
+
model: null,
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Maximum tokens for LLM response
|
|
97
|
+
* @type {number}
|
|
98
|
+
*/
|
|
99
|
+
maxTokens: 2048,
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Temperature for LLM generation
|
|
103
|
+
* @type {number}
|
|
104
|
+
*/
|
|
105
|
+
temperature: 0.7,
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Timeout for LLM requests in milliseconds
|
|
109
|
+
* @type {number}
|
|
110
|
+
*/
|
|
111
|
+
timeout: 60000
|
|
112
|
+
},
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Trigger configuration
|
|
116
|
+
*/
|
|
117
|
+
triggers: {
|
|
118
|
+
/**
|
|
119
|
+
* Enabled trigger types
|
|
120
|
+
* @type {string[]}
|
|
121
|
+
*/
|
|
122
|
+
enabled: [
|
|
123
|
+
ReplanTrigger.TASK_FAILED,
|
|
124
|
+
ReplanTrigger.TIMEOUT,
|
|
125
|
+
ReplanTrigger.CONTEXT_CHANGED,
|
|
126
|
+
ReplanTrigger.HUMAN_REQUEST
|
|
127
|
+
],
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Number of consecutive failures before triggering replanning
|
|
131
|
+
* @type {number}
|
|
132
|
+
*/
|
|
133
|
+
failureThreshold: 2,
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Task timeout in milliseconds
|
|
137
|
+
* @type {number}
|
|
138
|
+
*/
|
|
139
|
+
taskTimeout: 300000, // 5 minutes
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Enable proactive better-path detection
|
|
143
|
+
* @type {boolean}
|
|
144
|
+
*/
|
|
145
|
+
enableBetterPathDetection: false
|
|
146
|
+
},
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Alternative generation configuration
|
|
150
|
+
*/
|
|
151
|
+
alternatives: {
|
|
152
|
+
/**
|
|
153
|
+
* Maximum number of alternatives to generate
|
|
154
|
+
* @type {number}
|
|
155
|
+
*/
|
|
156
|
+
maxAlternatives: 3,
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Minimum confidence score to accept an alternative (0.0 - 1.0)
|
|
160
|
+
* @type {number}
|
|
161
|
+
*/
|
|
162
|
+
minConfidence: 0.5,
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Confidence threshold requiring human approval
|
|
166
|
+
* @type {number}
|
|
167
|
+
*/
|
|
168
|
+
humanApprovalThreshold: 0.7,
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Include original task as fallback option
|
|
172
|
+
* @type {boolean}
|
|
173
|
+
*/
|
|
174
|
+
includeRetryOption: true,
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Consider task dependencies when generating alternatives
|
|
178
|
+
* @type {boolean}
|
|
179
|
+
*/
|
|
180
|
+
respectDependencies: true
|
|
181
|
+
},
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Evaluation configuration
|
|
185
|
+
*/
|
|
186
|
+
evaluation: {
|
|
187
|
+
/**
|
|
188
|
+
* Weight for LLM self-assessment in confidence score
|
|
189
|
+
* @type {number}
|
|
190
|
+
*/
|
|
191
|
+
llmWeight: 0.4,
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Weight for historical success rate
|
|
195
|
+
* @type {number}
|
|
196
|
+
*/
|
|
197
|
+
historyWeight: 0.3,
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Weight for resource availability
|
|
201
|
+
* @type {number}
|
|
202
|
+
*/
|
|
203
|
+
resourceWeight: 0.2,
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Weight for complexity score
|
|
207
|
+
* @type {number}
|
|
208
|
+
*/
|
|
209
|
+
complexityWeight: 0.1
|
|
210
|
+
},
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* History and audit configuration
|
|
214
|
+
*/
|
|
215
|
+
history: {
|
|
216
|
+
/**
|
|
217
|
+
* Enable history tracking
|
|
218
|
+
* @type {boolean}
|
|
219
|
+
*/
|
|
220
|
+
enabled: true,
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Maximum events to keep in memory
|
|
224
|
+
* @type {number}
|
|
225
|
+
*/
|
|
226
|
+
maxEvents: 1000,
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Persist history to file system
|
|
230
|
+
* @type {boolean}
|
|
231
|
+
*/
|
|
232
|
+
persist: false,
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* History file path (relative to project root)
|
|
236
|
+
* @type {string}
|
|
237
|
+
*/
|
|
238
|
+
filePath: 'storage/replanning-history.json',
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Export format for reports
|
|
242
|
+
* @type {string}
|
|
243
|
+
*/
|
|
244
|
+
exportFormat: 'markdown'
|
|
245
|
+
},
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Human-in-the-loop configuration
|
|
249
|
+
*/
|
|
250
|
+
humanInLoop: {
|
|
251
|
+
/**
|
|
252
|
+
* Enable human-in-the-loop for low confidence alternatives
|
|
253
|
+
* @type {boolean}
|
|
254
|
+
*/
|
|
255
|
+
enabled: true,
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Timeout for human response in milliseconds
|
|
259
|
+
* @type {number}
|
|
260
|
+
*/
|
|
261
|
+
timeout: 300000, // 5 minutes
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Default action on timeout
|
|
265
|
+
* @type {string}
|
|
266
|
+
*/
|
|
267
|
+
defaultOnTimeout: 'abort',
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Always require approval for these trigger types
|
|
271
|
+
* @type {string[]}
|
|
272
|
+
*/
|
|
273
|
+
alwaysApprove: [ReplanTrigger.GOAL_UNREACHABLE]
|
|
274
|
+
},
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Integration configuration
|
|
278
|
+
*/
|
|
279
|
+
integration: {
|
|
280
|
+
/**
|
|
281
|
+
* Patterns to enable replanning for
|
|
282
|
+
* @type {string[]}
|
|
283
|
+
*/
|
|
284
|
+
enabledPatterns: ['swarm', 'sequential', 'workflow'],
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Emit events for replanning actions
|
|
288
|
+
* @type {boolean}
|
|
289
|
+
*/
|
|
290
|
+
emitEvents: true,
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Event prefix for replanning events
|
|
294
|
+
* @type {string}
|
|
295
|
+
*/
|
|
296
|
+
eventPrefix: 'replan'
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Merge user configuration with defaults
|
|
302
|
+
* @param {Object} userConfig - User-provided configuration
|
|
303
|
+
* @returns {Object} Merged configuration
|
|
304
|
+
*/
|
|
305
|
+
function mergeConfig(userConfig = {}) {
|
|
306
|
+
return deepMerge(defaultReplanningConfig, userConfig);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Deep merge two objects
|
|
311
|
+
* @param {Object} target - Target object
|
|
312
|
+
* @param {Object} source - Source object
|
|
313
|
+
* @returns {Object} Merged object
|
|
314
|
+
* @private
|
|
315
|
+
*/
|
|
316
|
+
function deepMerge(target, source) {
|
|
317
|
+
const result = { ...target };
|
|
318
|
+
|
|
319
|
+
for (const key of Object.keys(source)) {
|
|
320
|
+
if (source[key] instanceof Object && key in target && target[key] instanceof Object) {
|
|
321
|
+
result[key] = deepMerge(target[key], source[key]);
|
|
322
|
+
} else {
|
|
323
|
+
result[key] = source[key];
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
return result;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Validate configuration
|
|
332
|
+
* @param {Object} config - Configuration to validate
|
|
333
|
+
* @returns {{valid: boolean, errors: string[]}} Validation result
|
|
334
|
+
*/
|
|
335
|
+
function validateConfig(config) {
|
|
336
|
+
const errors = [];
|
|
337
|
+
|
|
338
|
+
// Validate confidence thresholds
|
|
339
|
+
if (config.alternatives?.minConfidence < 0 || config.alternatives?.minConfidence > 1) {
|
|
340
|
+
errors.push('alternatives.minConfidence must be between 0 and 1');
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
if (config.alternatives?.humanApprovalThreshold < 0 || config.alternatives?.humanApprovalThreshold > 1) {
|
|
344
|
+
errors.push('alternatives.humanApprovalThreshold must be between 0 and 1');
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
// Validate evaluation weights sum to 1
|
|
348
|
+
const evaluation = config.evaluation || {};
|
|
349
|
+
const weightSum = (evaluation.llmWeight || 0) +
|
|
350
|
+
(evaluation.historyWeight || 0) +
|
|
351
|
+
(evaluation.resourceWeight || 0) +
|
|
352
|
+
(evaluation.complexityWeight || 0);
|
|
353
|
+
|
|
354
|
+
if (Math.abs(weightSum - 1.0) > 0.01) {
|
|
355
|
+
errors.push(`Evaluation weights must sum to 1.0, got ${weightSum}`);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
// Validate trigger types
|
|
359
|
+
const validTriggers = Object.values(ReplanTrigger);
|
|
360
|
+
for (const trigger of config.triggers?.enabled || []) {
|
|
361
|
+
if (!validTriggers.includes(trigger)) {
|
|
362
|
+
errors.push(`Invalid trigger type: ${trigger}`);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
return {
|
|
367
|
+
valid: errors.length === 0,
|
|
368
|
+
errors
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
module.exports = {
|
|
373
|
+
ReplanTrigger,
|
|
374
|
+
ReplanDecision,
|
|
375
|
+
defaultReplanningConfig,
|
|
376
|
+
mergeConfig,
|
|
377
|
+
validateConfig
|
|
378
|
+
};
|