feat: update skills (migrating-memory, agent-finder, message-search) (#458)
Co-authored-by: Letta <noreply@letta.com>
This commit is contained in:
@@ -270,7 +270,9 @@ export async function skill(args: SkillArgs): Promise<SkillResult> {
|
||||
const skillsToProcess = skillIds as string[];
|
||||
|
||||
if (command === "load") {
|
||||
// Load skills
|
||||
// Load skills - track which ones were prepared successfully
|
||||
const preparedSkills: string[] = [];
|
||||
|
||||
for (const skillId of skillsToProcess) {
|
||||
if (loadedSkillIds.includes(skillId)) {
|
||||
results.push(`"${skillId}" already loaded`);
|
||||
@@ -288,15 +290,21 @@ export async function skill(args: SkillArgs): Promise<SkillResult> {
|
||||
|
||||
// Build skill header with optional path info
|
||||
const skillDir = dirname(skillPath);
|
||||
const pathLine = hasAdditionalFiles(skillPath)
|
||||
const hasExtras = hasAdditionalFiles(skillPath);
|
||||
const pathLine = hasExtras
|
||||
? `# Skill Directory: ${skillDir}\n\n`
|
||||
: "";
|
||||
|
||||
// Replace <SKILL_DIR> placeholder with actual path in skill content
|
||||
const processedContent = hasExtras
|
||||
? skillContent.replace(/<SKILL_DIR>/g, skillDir)
|
||||
: skillContent;
|
||||
|
||||
// Append new skill
|
||||
const separator = currentValue ? "\n\n---\n\n" : "";
|
||||
currentValue = `${currentValue}${separator}# Skill: ${skillId}\n${pathLine}${skillContent}`;
|
||||
currentValue = `${currentValue}${separator}# Skill: ${skillId}\n${pathLine}${processedContent}`;
|
||||
loadedSkillIds.push(skillId);
|
||||
results.push(`"${skillId}" loaded`);
|
||||
preparedSkills.push(skillId);
|
||||
} catch (error) {
|
||||
results.push(
|
||||
`"${skillId}" failed: ${error instanceof Error ? error.message : String(error)}`,
|
||||
@@ -304,14 +312,19 @@ export async function skill(args: SkillArgs): Promise<SkillResult> {
|
||||
}
|
||||
}
|
||||
|
||||
// Update the block
|
||||
await client.agents.blocks.update("loaded_skills", {
|
||||
agent_id: agentId,
|
||||
value: currentValue,
|
||||
});
|
||||
// Update the block - only report success AFTER the update succeeds
|
||||
if (preparedSkills.length > 0) {
|
||||
await client.agents.blocks.update("loaded_skills", {
|
||||
agent_id: agentId,
|
||||
value: currentValue,
|
||||
});
|
||||
|
||||
// Update the cached flag
|
||||
if (loadedSkillIds.length > 0) {
|
||||
// Now we can report success
|
||||
for (const skillId of preparedSkills) {
|
||||
results.push(`"${skillId}" loaded`);
|
||||
}
|
||||
|
||||
// Update the cached flag
|
||||
setHasLoadedSkills(true);
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user