feat: update skills (migrating-memory, agent-finder, message-search) (#458)

Co-authored-by: Letta <noreply@letta.com>
This commit is contained in:
Charles Packer
2026-01-04 16:31:32 -08:00
committed by GitHub
parent d0d45cba5a
commit 9b039b7249
16 changed files with 1482 additions and 146 deletions

View File

@@ -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 {