claude-flow-novice 2.10.8 → 2.10.9
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/.claude/hooks/cfn-invoke-pre-edit.sh +88 -0
- package/.claude/skills/cfn-agent-spawning/spawn-worker.sh +176 -0
- package/claude-assets/agents/csuite/cto-agent.md +371 -0
- package/claude-assets/agents/marketing_hybrid/cost_tracker.md +13 -0
- package/claude-assets/agents/marketing_hybrid/docker_deployer.md +13 -0
- package/claude-assets/agents/marketing_hybrid/zai_worker_spawner.md +13 -0
- package/claude-assets/hooks/cfn-invoke-pre-edit.sh +88 -0
- package/claude-assets/hooks/post-edit.config.json +19 -8
- package/claude-assets/skills/cfn-agent-spawning/spawn-worker.sh +176 -0
- package/claude-assets/skills/pre-edit-backup/backup.sh +130 -0
- package/claude-assets/skills/pre-edit-backup/cleanup.sh +155 -0
- package/claude-assets/skills/pre-edit-backup/restore.sh +128 -0
- package/claude-assets/skills/pre-edit-backup/revert-file.sh +168 -0
- package/dist/agents/agent-loader.js +315 -0
- package/dist/agents/agent-loader.js.map +1 -1
- package/dist/cli/config-manager.js +91 -109
- package/dist/cli/config-manager.js.map +1 -1
- package/package.json +1 -1
- package/scripts/marketing_hybrid_deployment.sh +45 -0
- package/scripts/redis-prometheus-exporter.sh +33 -0
- package/scripts/track-zai-costs.sh +19 -0
- package/claude-assets/skills/team-provider-routing/spawn-worker.sh +0 -91
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Pre-Edit Restore Script
|
|
4
|
+
# Restores file from backup and updates metadata
|
|
5
|
+
#
|
|
6
|
+
# Usage: restore.sh BACKUP_DIR [--list FILE_PATH AGENT_ID]
|
|
7
|
+
#
|
|
8
|
+
# Arguments:
|
|
9
|
+
# BACKUP_DIR - Path to backup directory containing backup_metadata.json
|
|
10
|
+
# --list - List available backups for a file (requires FILE_PATH and AGENT_ID)
|
|
11
|
+
#
|
|
12
|
+
# Returns:
|
|
13
|
+
# Exit code 0 on success
|
|
14
|
+
# Exit code 1 on failure
|
|
15
|
+
#
|
|
16
|
+
# Example:
|
|
17
|
+
# ./.claude/skills/pre-edit-backup/restore.sh ".backups/backend-dev-1/1698764800000_abc123"
|
|
18
|
+
# ./.claude/skills/pre-edit-backup/restore.sh --list "/path/to/file.txt" "backend-dev-1"
|
|
19
|
+
|
|
20
|
+
set -euo pipefail
|
|
21
|
+
|
|
22
|
+
# === Handle --list Mode ===
|
|
23
|
+
|
|
24
|
+
if [[ "${1:-}" == "--list" ]]; then
|
|
25
|
+
FILE_PATH="$2"
|
|
26
|
+
AGENT_ID="$3"
|
|
27
|
+
|
|
28
|
+
if [[ -z "$FILE_PATH" ]] || [[ -z "$AGENT_ID" ]]; then
|
|
29
|
+
echo "Error: --list requires FILE_PATH and AGENT_ID" >&2
|
|
30
|
+
exit 1
|
|
31
|
+
fi
|
|
32
|
+
|
|
33
|
+
BACKUP_BASE_DIR=".backups"
|
|
34
|
+
AGENT_BACKUP_DIR="${BACKUP_BASE_DIR}/${AGENT_ID}"
|
|
35
|
+
|
|
36
|
+
if [[ ! -d "$AGENT_BACKUP_DIR" ]]; then
|
|
37
|
+
echo "No backups found for agent: $AGENT_ID" >&2
|
|
38
|
+
exit 1
|
|
39
|
+
fi
|
|
40
|
+
|
|
41
|
+
echo "Available backups for $FILE_PATH (agent: $AGENT_ID):"
|
|
42
|
+
echo "---"
|
|
43
|
+
|
|
44
|
+
FOUND_BACKUPS=0
|
|
45
|
+
for backup_dir in "$AGENT_BACKUP_DIR"/*; do
|
|
46
|
+
if [[ -f "${backup_dir}/backup_metadata.json" ]]; then
|
|
47
|
+
ORIGINAL=$(jq -r '.original_path' "${backup_dir}/backup_metadata.json" 2>/dev/null || echo "")
|
|
48
|
+
if [[ "$ORIGINAL" == "$FILE_PATH" ]]; then
|
|
49
|
+
TIMESTAMP=$(jq -r '.backup_timestamp' "${backup_dir}/backup_metadata.json" 2>/dev/null || echo "unknown")
|
|
50
|
+
STATUS=$(jq -r '.backup_status' "${backup_dir}/backup_metadata.json" 2>/dev/null || echo "unknown")
|
|
51
|
+
echo "Backup: $(basename "$backup_dir")"
|
|
52
|
+
echo " Timestamp: $TIMESTAMP"
|
|
53
|
+
echo " Status: $STATUS"
|
|
54
|
+
echo " Path: $backup_dir"
|
|
55
|
+
echo "---"
|
|
56
|
+
FOUND_BACKUPS=$((FOUND_BACKUPS + 1))
|
|
57
|
+
fi
|
|
58
|
+
fi
|
|
59
|
+
done
|
|
60
|
+
|
|
61
|
+
if [[ $FOUND_BACKUPS -eq 0 ]]; then
|
|
62
|
+
echo "No backups found for this file."
|
|
63
|
+
exit 1
|
|
64
|
+
fi
|
|
65
|
+
|
|
66
|
+
exit 0
|
|
67
|
+
fi
|
|
68
|
+
|
|
69
|
+
# === Restore Mode ===
|
|
70
|
+
|
|
71
|
+
BACKUP_DIR="$1"
|
|
72
|
+
|
|
73
|
+
if [[ -z "$BACKUP_DIR" ]]; then
|
|
74
|
+
echo "Error: No backup directory provided" >&2
|
|
75
|
+
echo "Usage: restore.sh BACKUP_DIR" >&2
|
|
76
|
+
exit 1
|
|
77
|
+
fi
|
|
78
|
+
|
|
79
|
+
if [[ ! -d "$BACKUP_DIR" ]]; then
|
|
80
|
+
echo "Error: Backup directory does not exist: $BACKUP_DIR" >&2
|
|
81
|
+
exit 1
|
|
82
|
+
fi
|
|
83
|
+
|
|
84
|
+
METADATA_FILE="${BACKUP_DIR}/backup_metadata.json"
|
|
85
|
+
BACKUP_FILE="${BACKUP_DIR}/original_file"
|
|
86
|
+
|
|
87
|
+
if [[ ! -f "$METADATA_FILE" ]]; then
|
|
88
|
+
echo "Error: Backup metadata not found: $METADATA_FILE" >&2
|
|
89
|
+
exit 1
|
|
90
|
+
fi
|
|
91
|
+
|
|
92
|
+
if [[ ! -f "$BACKUP_FILE" ]]; then
|
|
93
|
+
echo "Error: Backup file not found: $BACKUP_FILE" >&2
|
|
94
|
+
exit 1
|
|
95
|
+
fi
|
|
96
|
+
|
|
97
|
+
# Check for jq availability
|
|
98
|
+
if ! command -v jq &>/dev/null; then
|
|
99
|
+
echo "Error: jq is required for restore operations" >&2
|
|
100
|
+
exit 1
|
|
101
|
+
fi
|
|
102
|
+
|
|
103
|
+
# Extract original path
|
|
104
|
+
ORIGINAL_PATH=$(jq -r '.original_path' "$METADATA_FILE" 2>/dev/null)
|
|
105
|
+
|
|
106
|
+
if [[ -z "$ORIGINAL_PATH" ]] || [[ "$ORIGINAL_PATH" == "null" ]]; then
|
|
107
|
+
echo "Error: Failed to read original path from metadata" >&2
|
|
108
|
+
exit 1
|
|
109
|
+
fi
|
|
110
|
+
|
|
111
|
+
# Restore file
|
|
112
|
+
if ! cp "$BACKUP_FILE" "$ORIGINAL_PATH" 2>/dev/null; then
|
|
113
|
+
echo "Error: Failed to restore file to: $ORIGINAL_PATH" >&2
|
|
114
|
+
exit 1
|
|
115
|
+
fi
|
|
116
|
+
|
|
117
|
+
# Update backup status
|
|
118
|
+
TEMP_FILE=$(mktemp)
|
|
119
|
+
if jq '.backup_status = "restored"' "$METADATA_FILE" > "$TEMP_FILE" 2>/dev/null; then
|
|
120
|
+
mv "$TEMP_FILE" "$METADATA_FILE"
|
|
121
|
+
else
|
|
122
|
+
echo "Warning: Failed to update backup status in metadata" >&2
|
|
123
|
+
rm -f "$TEMP_FILE"
|
|
124
|
+
fi
|
|
125
|
+
|
|
126
|
+
echo "File restored from backup: ${BACKUP_DIR}"
|
|
127
|
+
echo "Restored to: ${ORIGINAL_PATH}"
|
|
128
|
+
exit 0
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
#
|
|
3
|
+
# Revert File Utility
|
|
4
|
+
# High-level revert interface for agents to use instead of git operations
|
|
5
|
+
#
|
|
6
|
+
# Usage:
|
|
7
|
+
# ./.claude/skills/pre-edit-backup/revert-file.sh <file_path> [--agent-id <id>] [--interactive]
|
|
8
|
+
#
|
|
9
|
+
# Examples:
|
|
10
|
+
# # Revert to most recent backup (auto-select)
|
|
11
|
+
# ./.claude/skills/pre-edit-backup/revert-file.sh src/file.ts --agent-id "coder-1"
|
|
12
|
+
#
|
|
13
|
+
# # Interactive mode (shows list of backups)
|
|
14
|
+
# ./.claude/skills/pre-edit-backup/revert-file.sh src/file.ts --agent-id "coder-1" --interactive
|
|
15
|
+
#
|
|
16
|
+
# # List available backups without reverting
|
|
17
|
+
# ./.claude/skills/pre-edit-backup/revert-file.sh src/file.ts --agent-id "coder-1" --list-only
|
|
18
|
+
|
|
19
|
+
set -euo pipefail
|
|
20
|
+
|
|
21
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
22
|
+
BACKUP_BASE_DIR=".backups"
|
|
23
|
+
|
|
24
|
+
# Parse arguments
|
|
25
|
+
FILE_PATH=""
|
|
26
|
+
AGENT_ID="${AGENT_ID:-unknown}"
|
|
27
|
+
INTERACTIVE=false
|
|
28
|
+
LIST_ONLY=false
|
|
29
|
+
|
|
30
|
+
while [[ $# -gt 0 ]]; do
|
|
31
|
+
case $1 in
|
|
32
|
+
--agent-id)
|
|
33
|
+
AGENT_ID="$2"
|
|
34
|
+
shift 2
|
|
35
|
+
;;
|
|
36
|
+
--interactive)
|
|
37
|
+
INTERACTIVE=true
|
|
38
|
+
shift
|
|
39
|
+
;;
|
|
40
|
+
--list-only)
|
|
41
|
+
LIST_ONLY=true
|
|
42
|
+
shift
|
|
43
|
+
;;
|
|
44
|
+
*)
|
|
45
|
+
FILE_PATH="$1"
|
|
46
|
+
shift
|
|
47
|
+
;;
|
|
48
|
+
esac
|
|
49
|
+
done
|
|
50
|
+
|
|
51
|
+
# Validate inputs
|
|
52
|
+
if [ -z "$FILE_PATH" ]; then
|
|
53
|
+
echo "Error: File path required"
|
|
54
|
+
echo "Usage: $0 <file_path> [--agent-id <id>] [--interactive] [--list-only]"
|
|
55
|
+
exit 1
|
|
56
|
+
fi
|
|
57
|
+
|
|
58
|
+
# Normalize file path
|
|
59
|
+
FILE_PATH=$(realpath "$FILE_PATH" 2>/dev/null || echo "$FILE_PATH")
|
|
60
|
+
|
|
61
|
+
# Find backups for this file
|
|
62
|
+
AGENT_BACKUP_DIR="$BACKUP_BASE_DIR/$AGENT_ID"
|
|
63
|
+
|
|
64
|
+
if [ ! -d "$AGENT_BACKUP_DIR" ]; then
|
|
65
|
+
echo "❌ No backups found for agent: $AGENT_ID"
|
|
66
|
+
exit 1
|
|
67
|
+
fi
|
|
68
|
+
|
|
69
|
+
# Search for backups matching this file
|
|
70
|
+
MATCHING_BACKUPS=()
|
|
71
|
+
while IFS= read -r backup_dir; do
|
|
72
|
+
metadata_file="$backup_dir/backup_metadata.json"
|
|
73
|
+
|
|
74
|
+
if [ -f "$metadata_file" ]; then
|
|
75
|
+
original_path=$(jq -r '.original_path' "$metadata_file" 2>/dev/null || echo "")
|
|
76
|
+
|
|
77
|
+
# Normalize original path for comparison
|
|
78
|
+
original_path=$(realpath "$original_path" 2>/dev/null || echo "$original_path")
|
|
79
|
+
|
|
80
|
+
if [ "$original_path" = "$FILE_PATH" ]; then
|
|
81
|
+
MATCHING_BACKUPS+=("$backup_dir")
|
|
82
|
+
fi
|
|
83
|
+
fi
|
|
84
|
+
done < <(find "$AGENT_BACKUP_DIR" -mindepth 1 -maxdepth 1 -type d | sort -r)
|
|
85
|
+
|
|
86
|
+
# Check if any backups found
|
|
87
|
+
if [ ${#MATCHING_BACKUPS[@]} -eq 0 ]; then
|
|
88
|
+
echo "❌ No backups found for file: $FILE_PATH"
|
|
89
|
+
exit 1
|
|
90
|
+
fi
|
|
91
|
+
|
|
92
|
+
# List backups function
|
|
93
|
+
list_backups() {
|
|
94
|
+
echo "Available backups for: $FILE_PATH"
|
|
95
|
+
echo "----------------------------------------"
|
|
96
|
+
|
|
97
|
+
local index=1
|
|
98
|
+
for backup_dir in "${MATCHING_BACKUPS[@]}"; do
|
|
99
|
+
metadata_file="$backup_dir/backup_metadata.json"
|
|
100
|
+
|
|
101
|
+
timestamp=$(jq -r '.backup_timestamp' "$metadata_file")
|
|
102
|
+
status=$(jq -r '.backup_status' "$metadata_file")
|
|
103
|
+
|
|
104
|
+
# Convert timestamp to readable date
|
|
105
|
+
if command -v date >/dev/null 2>&1; then
|
|
106
|
+
# Handle millisecond timestamps
|
|
107
|
+
timestamp_seconds=$((timestamp / 1000))
|
|
108
|
+
date_str=$(date -d "@$timestamp_seconds" '+%Y-%m-%d %H:%M:%S' 2>/dev/null || date -r "$timestamp_seconds" '+%Y-%m-%d %H:%M:%S' 2>/dev/null || echo "Unknown")
|
|
109
|
+
else
|
|
110
|
+
date_str="$timestamp"
|
|
111
|
+
fi
|
|
112
|
+
|
|
113
|
+
echo "[$index] $date_str (Status: $status)"
|
|
114
|
+
echo " Path: $backup_dir"
|
|
115
|
+
|
|
116
|
+
((index++))
|
|
117
|
+
done
|
|
118
|
+
echo "----------------------------------------"
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
# List-only mode
|
|
122
|
+
if [ "$LIST_ONLY" = true ]; then
|
|
123
|
+
list_backups
|
|
124
|
+
exit 0
|
|
125
|
+
fi
|
|
126
|
+
|
|
127
|
+
# Interactive mode
|
|
128
|
+
if [ "$INTERACTIVE" = true ]; then
|
|
129
|
+
list_backups
|
|
130
|
+
echo ""
|
|
131
|
+
echo -n "Select backup to restore [1-${#MATCHING_BACKUPS[@]}] (or 0 to cancel): "
|
|
132
|
+
read -r selection
|
|
133
|
+
|
|
134
|
+
if [ "$selection" = "0" ]; then
|
|
135
|
+
echo "❌ Revert cancelled"
|
|
136
|
+
exit 0
|
|
137
|
+
fi
|
|
138
|
+
|
|
139
|
+
if ! [[ "$selection" =~ ^[0-9]+$ ]] || [ "$selection" -lt 1 ] || [ "$selection" -gt ${#MATCHING_BACKUPS[@]} ]; then
|
|
140
|
+
echo "❌ Invalid selection: $selection"
|
|
141
|
+
exit 1
|
|
142
|
+
fi
|
|
143
|
+
|
|
144
|
+
SELECTED_BACKUP="${MATCHING_BACKUPS[$((selection - 1))]}"
|
|
145
|
+
else
|
|
146
|
+
# Auto-select most recent backup (first in sorted list)
|
|
147
|
+
SELECTED_BACKUP="${MATCHING_BACKUPS[0]}"
|
|
148
|
+
|
|
149
|
+
metadata_file="$SELECTED_BACKUP/backup_metadata.json"
|
|
150
|
+
timestamp=$(jq -r '.backup_timestamp' "$metadata_file")
|
|
151
|
+
timestamp_seconds=$((timestamp / 1000))
|
|
152
|
+
date_str=$(date -d "@$timestamp_seconds" '+%Y-%m-%d %H:%M:%S' 2>/dev/null || date -r "$timestamp_seconds" '+%Y-%m-%d %H:%M:%S' 2>/dev/null || echo "timestamp: $timestamp")
|
|
153
|
+
|
|
154
|
+
echo "🔄 Auto-selecting most recent backup: $date_str"
|
|
155
|
+
fi
|
|
156
|
+
|
|
157
|
+
# Restore using restore.sh
|
|
158
|
+
echo "🔄 Restoring file from backup..."
|
|
159
|
+
"$SCRIPT_DIR/restore.sh" "$SELECTED_BACKUP"
|
|
160
|
+
|
|
161
|
+
if [ $? -eq 0 ]; then
|
|
162
|
+
echo "✅ File successfully reverted to backup"
|
|
163
|
+
echo " Backup: $SELECTED_BACKUP"
|
|
164
|
+
exit 0
|
|
165
|
+
else
|
|
166
|
+
echo "❌ Failed to revert file"
|
|
167
|
+
exit 1
|
|
168
|
+
fi
|
|
@@ -191,4 +191,319 @@ export const isValidAgentType = (name)=>agentLoader.isValidAgentType(name);
|
|
|
191
191
|
export const getAgentsByCategory = (category)=>agentLoader.getAgentsByCategory(category);
|
|
192
192
|
export const refreshAgents = ()=>agentLoader.refresh();
|
|
193
193
|
|
|
194
|
+
//# sourceMappingURL=agent-loader.js.map.isArray(input)) return input.map(String);
|
|
195
|
+
if (typeof input === 'string') {
|
|
196
|
+
return input.split(/[,\s]+/).map(function(t) {
|
|
197
|
+
return t.trim();
|
|
198
|
+
}).filter(function(t) {
|
|
199
|
+
return t.length > 0;
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
return [];
|
|
203
|
+
};
|
|
204
|
+
// Safely handle tools and capabilities.tools
|
|
205
|
+
var toolsFromFrontmatter = frontmatter.tools ? extractTools(frontmatter.tools) : [];
|
|
206
|
+
var toolsFromCapabilities = frontmatter.capabilities && typeof frontmatter.capabilities === 'object' ? extractTools(Object(frontmatter.capabilities).tools) : [];
|
|
207
|
+
return __spreadArray(__spreadArray([], toolsFromFrontmatter, true), toolsFromCapabilities, true);
|
|
208
|
+
};
|
|
209
|
+
AgentLoader.prototype.loadAgents = function() {
|
|
210
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
211
|
+
var agentsDir, agentFiles, categoryMap, _i, agentFiles_1, filePath, agent, relativePath, pathParts, category;
|
|
212
|
+
return __generator(this, function(_a) {
|
|
213
|
+
switch(_a.label){
|
|
214
|
+
case 0:
|
|
215
|
+
agentsDir = this.getAgentsDirectory();
|
|
216
|
+
if (!(0, node_fs_1.existsSync)(agentsDir)) {
|
|
217
|
+
console.warn("Agents directory not found: ".concat(agentsDir));
|
|
218
|
+
return [
|
|
219
|
+
2 /*return*/
|
|
220
|
+
];
|
|
221
|
+
}
|
|
222
|
+
return [
|
|
223
|
+
4 /*yield*/ ,
|
|
224
|
+
new Promise(function(resolve, reject) {
|
|
225
|
+
(0, glob_1.glob)('**/*.md', {
|
|
226
|
+
cwd: agentsDir,
|
|
227
|
+
ignore: [
|
|
228
|
+
'**/README.md',
|
|
229
|
+
'**/MIGRATION_SUMMARY.md'
|
|
230
|
+
],
|
|
231
|
+
absolute: true
|
|
232
|
+
}, function(err, matches) {
|
|
233
|
+
if (err) reject(err);
|
|
234
|
+
else resolve(matches);
|
|
235
|
+
});
|
|
236
|
+
})
|
|
237
|
+
];
|
|
238
|
+
case 1:
|
|
239
|
+
agentFiles = _a.sent();
|
|
240
|
+
this.agentCache.clear();
|
|
241
|
+
this.categoriesCache = [];
|
|
242
|
+
categoryMap = new Map();
|
|
243
|
+
for(_i = 0, agentFiles_1 = agentFiles; _i < agentFiles_1.length; _i++){
|
|
244
|
+
filePath = agentFiles_1[_i];
|
|
245
|
+
agent = this.parseAgentFile(filePath);
|
|
246
|
+
if (agent) {
|
|
247
|
+
this.agentCache.set(agent.name, agent);
|
|
248
|
+
relativePath = filePath.replace(agentsDir, '');
|
|
249
|
+
pathParts = relativePath.split('/');
|
|
250
|
+
category = pathParts[1] || 'uncategorized';
|
|
251
|
+
if (!categoryMap.has(category)) {
|
|
252
|
+
categoryMap.set(category, []);
|
|
253
|
+
}
|
|
254
|
+
categoryMap.get(category).push(agent);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
this.categoriesCache = Array.from(categoryMap.entries()).map(function(_a) {
|
|
258
|
+
var name = _a[0], agents = _a[1];
|
|
259
|
+
return {
|
|
260
|
+
name: name,
|
|
261
|
+
agents: agents.sort(function(a, b) {
|
|
262
|
+
return a.name.localeCompare(b.name);
|
|
263
|
+
})
|
|
264
|
+
};
|
|
265
|
+
});
|
|
266
|
+
this.lastLoadTime = Date.now();
|
|
267
|
+
return [
|
|
268
|
+
2 /*return*/
|
|
269
|
+
];
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
});
|
|
273
|
+
};
|
|
274
|
+
// Rest of the methods remain similar to the original implementation
|
|
275
|
+
AgentLoader.prototype.needsRefresh = function() {
|
|
276
|
+
return Date.now() - this.lastLoadTime > this.CACHE_EXPIRY;
|
|
277
|
+
};
|
|
278
|
+
AgentLoader.prototype.ensureLoaded = function() {
|
|
279
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
280
|
+
return __generator(this, function(_a) {
|
|
281
|
+
switch(_a.label){
|
|
282
|
+
case 0:
|
|
283
|
+
if (!(this.agentCache.size === 0 || this.needsRefresh())) return [
|
|
284
|
+
3 /*break*/ ,
|
|
285
|
+
2
|
|
286
|
+
];
|
|
287
|
+
return [
|
|
288
|
+
4 /*yield*/ ,
|
|
289
|
+
this.loadAgents()
|
|
290
|
+
];
|
|
291
|
+
case 1:
|
|
292
|
+
_a.sent();
|
|
293
|
+
_a.label = 2;
|
|
294
|
+
case 2:
|
|
295
|
+
return [
|
|
296
|
+
2 /*return*/
|
|
297
|
+
];
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
});
|
|
301
|
+
};
|
|
302
|
+
AgentLoader.prototype.getAvailableAgentTypes = function() {
|
|
303
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
304
|
+
var currentTypes, legacyTypes;
|
|
305
|
+
return __generator(this, function(_a) {
|
|
306
|
+
switch(_a.label){
|
|
307
|
+
case 0:
|
|
308
|
+
return [
|
|
309
|
+
4 /*yield*/ ,
|
|
310
|
+
this.ensureLoaded()
|
|
311
|
+
];
|
|
312
|
+
case 1:
|
|
313
|
+
_a.sent();
|
|
314
|
+
currentTypes = Array.from(this.agentCache.keys());
|
|
315
|
+
legacyTypes = Object.keys(LEGACY_AGENT_MAPPING);
|
|
316
|
+
return [
|
|
317
|
+
2 /*return*/ ,
|
|
318
|
+
Array.from(new Set(__spreadArray(__spreadArray([], currentTypes, true), legacyTypes, true))).sort()
|
|
319
|
+
];
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
});
|
|
323
|
+
};
|
|
324
|
+
AgentLoader.prototype.getAgent = function(name) {
|
|
325
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
326
|
+
return __generator(this, function(_a) {
|
|
327
|
+
switch(_a.label){
|
|
328
|
+
case 0:
|
|
329
|
+
return [
|
|
330
|
+
4 /*yield*/ ,
|
|
331
|
+
this.ensureLoaded()
|
|
332
|
+
];
|
|
333
|
+
case 1:
|
|
334
|
+
_a.sent();
|
|
335
|
+
return [
|
|
336
|
+
2 /*return*/ ,
|
|
337
|
+
this.agentCache.get(name) || this.agentCache.get(resolveLegacyAgentType(name)) || null
|
|
338
|
+
];
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
});
|
|
342
|
+
};
|
|
343
|
+
AgentLoader.prototype.getAllAgents = function() {
|
|
344
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
345
|
+
return __generator(this, function(_a) {
|
|
346
|
+
switch(_a.label){
|
|
347
|
+
case 0:
|
|
348
|
+
return [
|
|
349
|
+
4 /*yield*/ ,
|
|
350
|
+
this.ensureLoaded()
|
|
351
|
+
];
|
|
352
|
+
case 1:
|
|
353
|
+
_a.sent();
|
|
354
|
+
return [
|
|
355
|
+
2 /*return*/ ,
|
|
356
|
+
Array.from(this.agentCache.values()).sort(function(a, b) {
|
|
357
|
+
return a.name.localeCompare(b.name);
|
|
358
|
+
})
|
|
359
|
+
];
|
|
360
|
+
}
|
|
361
|
+
});
|
|
362
|
+
});
|
|
363
|
+
};
|
|
364
|
+
AgentLoader.prototype.getAgentCategories = function() {
|
|
365
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
366
|
+
return __generator(this, function(_a) {
|
|
367
|
+
switch(_a.label){
|
|
368
|
+
case 0:
|
|
369
|
+
return [
|
|
370
|
+
4 /*yield*/ ,
|
|
371
|
+
this.ensureLoaded()
|
|
372
|
+
];
|
|
373
|
+
case 1:
|
|
374
|
+
_a.sent();
|
|
375
|
+
return [
|
|
376
|
+
2 /*return*/ ,
|
|
377
|
+
this.categoriesCache
|
|
378
|
+
];
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
});
|
|
382
|
+
};
|
|
383
|
+
AgentLoader.prototype.searchAgents = function(query) {
|
|
384
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
385
|
+
var lowerQuery;
|
|
386
|
+
return __generator(this, function(_a) {
|
|
387
|
+
switch(_a.label){
|
|
388
|
+
case 0:
|
|
389
|
+
return [
|
|
390
|
+
4 /*yield*/ ,
|
|
391
|
+
this.ensureLoaded()
|
|
392
|
+
];
|
|
393
|
+
case 1:
|
|
394
|
+
_a.sent();
|
|
395
|
+
lowerQuery = query.toLowerCase();
|
|
396
|
+
return [
|
|
397
|
+
2 /*return*/ ,
|
|
398
|
+
Array.from(this.agentCache.values()).filter(function(agent) {
|
|
399
|
+
var _a;
|
|
400
|
+
return agent.name.toLowerCase().includes(lowerQuery) || agent.description.toLowerCase().includes(lowerQuery) || ((_a = agent.capabilities) === null || _a === void 0 ? void 0 : _a.some(function(cap) {
|
|
401
|
+
return cap.toLowerCase().includes(lowerQuery);
|
|
402
|
+
}));
|
|
403
|
+
})
|
|
404
|
+
];
|
|
405
|
+
}
|
|
406
|
+
});
|
|
407
|
+
});
|
|
408
|
+
};
|
|
409
|
+
AgentLoader.prototype.isValidAgentType = function(name) {
|
|
410
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
411
|
+
return __generator(this, function(_a) {
|
|
412
|
+
switch(_a.label){
|
|
413
|
+
case 0:
|
|
414
|
+
return [
|
|
415
|
+
4 /*yield*/ ,
|
|
416
|
+
this.ensureLoaded()
|
|
417
|
+
];
|
|
418
|
+
case 1:
|
|
419
|
+
_a.sent();
|
|
420
|
+
return [
|
|
421
|
+
2 /*return*/ ,
|
|
422
|
+
this.agentCache.has(name) || this.agentCache.has(resolveLegacyAgentType(name))
|
|
423
|
+
];
|
|
424
|
+
}
|
|
425
|
+
});
|
|
426
|
+
});
|
|
427
|
+
};
|
|
428
|
+
AgentLoader.prototype.getAgentsByCategory = function(category) {
|
|
429
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
430
|
+
var categories, found;
|
|
431
|
+
return __generator(this, function(_a) {
|
|
432
|
+
switch(_a.label){
|
|
433
|
+
case 0:
|
|
434
|
+
return [
|
|
435
|
+
4 /*yield*/ ,
|
|
436
|
+
this.getAgentCategories()
|
|
437
|
+
];
|
|
438
|
+
case 1:
|
|
439
|
+
categories = _a.sent();
|
|
440
|
+
found = categories.find(function(cat) {
|
|
441
|
+
return cat.name === category;
|
|
442
|
+
});
|
|
443
|
+
return [
|
|
444
|
+
2 /*return*/ ,
|
|
445
|
+
(found === null || found === void 0 ? void 0 : found.agents) || []
|
|
446
|
+
];
|
|
447
|
+
}
|
|
448
|
+
});
|
|
449
|
+
});
|
|
450
|
+
};
|
|
451
|
+
AgentLoader.prototype.refresh = function() {
|
|
452
|
+
return __awaiter(this, void 0, void 0, function() {
|
|
453
|
+
return __generator(this, function(_a) {
|
|
454
|
+
switch(_a.label){
|
|
455
|
+
case 0:
|
|
456
|
+
this.lastLoadTime = 0;
|
|
457
|
+
return [
|
|
458
|
+
4 /*yield*/ ,
|
|
459
|
+
this.loadAgents()
|
|
460
|
+
];
|
|
461
|
+
case 1:
|
|
462
|
+
_a.sent();
|
|
463
|
+
return [
|
|
464
|
+
2 /*return*/
|
|
465
|
+
];
|
|
466
|
+
}
|
|
467
|
+
});
|
|
468
|
+
});
|
|
469
|
+
};
|
|
470
|
+
return AgentLoader;
|
|
471
|
+
}();
|
|
472
|
+
exports.AgentLoader = AgentLoader;
|
|
473
|
+
// Singleton instance
|
|
474
|
+
exports.agentLoader = new AgentLoader();
|
|
475
|
+
// Convenience exports for use in other modules
|
|
476
|
+
var getAvailableAgentTypes = function() {
|
|
477
|
+
return exports.agentLoader.getAvailableAgentTypes();
|
|
478
|
+
};
|
|
479
|
+
exports.getAvailableAgentTypes = getAvailableAgentTypes;
|
|
480
|
+
var getAgent = function(name) {
|
|
481
|
+
return exports.agentLoader.getAgent(name);
|
|
482
|
+
};
|
|
483
|
+
exports.getAgent = getAgent;
|
|
484
|
+
var getAllAgents = function() {
|
|
485
|
+
return exports.agentLoader.getAllAgents();
|
|
486
|
+
};
|
|
487
|
+
exports.getAllAgents = getAllAgents;
|
|
488
|
+
var getAgentCategories = function() {
|
|
489
|
+
return exports.agentLoader.getAgentCategories();
|
|
490
|
+
};
|
|
491
|
+
exports.getAgentCategories = getAgentCategories;
|
|
492
|
+
var searchAgents = function(query) {
|
|
493
|
+
return exports.agentLoader.searchAgents(query);
|
|
494
|
+
};
|
|
495
|
+
exports.searchAgents = searchAgents;
|
|
496
|
+
var isValidAgentType = function(name) {
|
|
497
|
+
return exports.agentLoader.isValidAgentType(name);
|
|
498
|
+
};
|
|
499
|
+
exports.isValidAgentType = isValidAgentType;
|
|
500
|
+
var getAgentsByCategory = function(category) {
|
|
501
|
+
return exports.agentLoader.getAgentsByCategory(category);
|
|
502
|
+
};
|
|
503
|
+
exports.getAgentsByCategory = getAgentsByCategory;
|
|
504
|
+
var refreshAgents = function() {
|
|
505
|
+
return exports.agentLoader.refresh();
|
|
506
|
+
};
|
|
507
|
+
exports.refreshAgents = refreshAgents;
|
|
508
|
+
|
|
194
509
|
//# sourceMappingURL=agent-loader.js.map
|