Something went wrong. Try again.
Your thinking partner.
Something went wrong. Try again.
12345678910111213141516171819202122232425import type { LettaAgentClient } from "@letta-ai/letta-agent-sdk/client";
/** Relative to the agent's primary memory repository, not the app checkout. */export const HOME_NOTE_PATH = "home.md";const MAX_NOTE_LENGTH = 20_000;
export function noteText(content: string): string | null { if (content.length > MAX_NOTE_LENGTH) throw new Error("Home note is too long."); return content.trim() || null;}
/** Read only this agent's primary repository. Never fall back to another agent. */export async function readHomeNote(client: Pick<LettaAgentClient, "agents" | "repositories">, agentId: string): Promise<string | null> { const repositories = await client.agents.repositories.list(agentId); const primary = repositories.find(repository => repository.isPrimary); if (!primary) return null; try { const file = await client.repositories.files.read(primary.id, { path: HOME_NOTE_PATH }); return noteText(file.content); } catch (error) { if (typeof error === "object" && error !== null && "status" in error && error.status === 404) return null; throw error; }}