@letta-ai/letta-code 0.21.15 → 0.21.16

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.
Files changed (2) hide show
  1. package/letta.js +385 -490
  2. package/package.json +1 -1
package/letta.js CHANGED
@@ -3269,7 +3269,7 @@ var package_default;
3269
3269
  var init_package = __esm(() => {
3270
3270
  package_default = {
3271
3271
  name: "@letta-ai/letta-code",
3272
- version: "0.21.15",
3272
+ version: "0.21.16",
3273
3273
  description: "Letta Code is a CLI tool for interacting with stateful Letta agents from the terminal.",
3274
3274
  type: "module",
3275
3275
  bin: {
@@ -5311,12 +5311,6 @@ var approval_recovery_alert_default = `<system-reminder>Automated keep-alive pin
5311
5311
  `;
5312
5312
  var init_approval_recovery_alert = () => {};
5313
5313
 
5314
- // src/agent/prompts/auto_init_reminder.txt
5315
- var auto_init_reminder_default = `<system-reminder>
5316
- A background agent is initializing this agent's memory system. Briefly let the user know that memory is being set up in the background, then respond to their message normally.
5317
- </system-reminder>`;
5318
- var init_auto_init_reminder = () => {};
5319
-
5320
5314
  // src/agent/prompts/human.mdx
5321
5315
  var human_default = `---
5322
5316
  label: human
@@ -7871,7 +7865,6 @@ __export(exports_promptAssets, {
7871
7865
  MEMORY_PROMPTS: () => MEMORY_PROMPTS,
7872
7866
  MEMORY_CHECK_REMINDER: () => MEMORY_CHECK_REMINDER,
7873
7867
  INTERRUPT_RECOVERY_ALERT: () => INTERRUPT_RECOVERY_ALERT,
7874
- AUTO_INIT_REMINDER: () => AUTO_INIT_REMINDER,
7875
7868
  APPROVAL_RECOVERY_PROMPT: () => APPROVAL_RECOVERY_PROMPT
7876
7869
  });
7877
7870
  function scanHeadingsOutsideFences(text) {
@@ -8002,10 +7995,9 @@ async function resolveSystemPrompt(systemPromptPreset) {
8002
7995
  }
8003
7996
  throw new Error(`Unknown system prompt "${systemPromptPreset}" — does not match any preset or subagent`);
8004
7997
  }
8005
- var SYSTEM_PROMPT, SYSTEM_PROMPT_BLOCKS_ADDON, SYSTEM_PROMPT_MEMFS_ADDON, PLAN_MODE_REMINDER, SKILL_CREATOR_PROMPT, REMEMBER_PROMPT, MEMORY_CHECK_REMINDER, APPROVAL_RECOVERY_PROMPT, AUTO_INIT_REMINDER, INTERRUPT_RECOVERY_ALERT, SLEEPTIME_MEMORY_PERSONA, MEMORY_PROMPTS, SYSTEM_PROMPTS;
7998
+ var SYSTEM_PROMPT, SYSTEM_PROMPT_BLOCKS_ADDON, SYSTEM_PROMPT_MEMFS_ADDON, PLAN_MODE_REMINDER, SKILL_CREATOR_PROMPT, REMEMBER_PROMPT, MEMORY_CHECK_REMINDER, APPROVAL_RECOVERY_PROMPT, INTERRUPT_RECOVERY_ALERT, SLEEPTIME_MEMORY_PERSONA, MEMORY_PROMPTS, SYSTEM_PROMPTS;
8006
7999
  var init_promptAssets = __esm(() => {
8007
8000
  init_approval_recovery_alert();
8008
- init_auto_init_reminder();
8009
8001
  init_human();
8010
8002
  init_human_kawaii();
8011
8003
  init_human_linus();
@@ -8037,7 +8029,6 @@ var init_promptAssets = __esm(() => {
8037
8029
  REMEMBER_PROMPT = remember_default;
8038
8030
  MEMORY_CHECK_REMINDER = memory_check_reminder_default;
8039
8031
  APPROVAL_RECOVERY_PROMPT = approval_recovery_alert_default;
8040
- AUTO_INIT_REMINDER = auto_init_reminder_default;
8041
8032
  INTERRUPT_RECOVERY_ALERT = interrupt_recovery_alert_default;
8042
8033
  SLEEPTIME_MEMORY_PERSONA = sleeptime_default;
8043
8034
  MEMORY_PROMPTS = {
@@ -38319,6 +38310,7 @@ __export(exports_memoryGit, {
38319
38310
  pushMemory: () => pushMemory,
38320
38311
  pullMemory: () => pullMemory,
38321
38312
  normalizeCredentialBaseUrl: () => normalizeCredentialBaseUrl,
38313
+ isRetryableGitTransientError: () => isRetryableGitTransientError,
38322
38314
  isGitRepo: () => isGitRepo,
38323
38315
  getMemoryRepoDir: () => getMemoryRepoDir,
38324
38316
  getMemoryGitStatus: () => getMemoryGitStatus,
@@ -38381,6 +38373,35 @@ async function runGit(cwd2, args, token) {
38381
38373
  stderr: result.stderr?.toString() ?? ""
38382
38374
  };
38383
38375
  }
38376
+ function isRetryableGitTransientError(error) {
38377
+ const message = error instanceof Error ? error.message : String(error);
38378
+ if (RETRYABLE_GIT_HTTP_ERROR_RE.test(message)) {
38379
+ return true;
38380
+ }
38381
+ if (message.includes("RPC failed") && RETRYABLE_GIT_NETWORK_ERROR_RE.test(message)) {
38382
+ return true;
38383
+ }
38384
+ return false;
38385
+ }
38386
+ async function runGitWithRetry(cwd2, args, token, options) {
38387
+ const attempts = options?.attempts ?? 3;
38388
+ const baseDelayMs = options?.baseDelayMs ?? 500;
38389
+ const operation = options?.operation ?? args[0] ?? "git op";
38390
+ for (let attempt = 1;attempt <= attempts; attempt += 1) {
38391
+ try {
38392
+ return await runGit(cwd2, args, token);
38393
+ } catch (error) {
38394
+ if (!isRetryableGitTransientError(error) || attempt >= attempts) {
38395
+ throw error;
38396
+ }
38397
+ const delayMs = baseDelayMs * 2 ** (attempt - 1);
38398
+ const msg = error instanceof Error ? error.message : String(error);
38399
+ debugWarn("memfs-git", `${operation} failed with transient error (attempt ${attempt}/${attempts}): ${msg}. Retrying in ${delayMs}ms`);
38400
+ await new Promise((resolve2) => setTimeout(resolve2, delayMs));
38401
+ }
38402
+ }
38403
+ throw new Error(`Unexpected retry loop exit for ${operation}`);
38404
+ }
38384
38405
  async function configureLocalCredentialHelper(dir, token) {
38385
38406
  const rawBaseUrl = getServerUrl();
38386
38407
  const normalizedBaseUrl = normalizeCredentialBaseUrl(rawBaseUrl);
@@ -38415,7 +38436,9 @@ async function cloneMemoryRepo(agentId) {
38415
38436
  debugLog("memfs-git", `Cloning ${url} → ${dir}`);
38416
38437
  if (!existsSync8(dir)) {
38417
38438
  mkdirSync6(dir, { recursive: true });
38418
- await runGit(dir, ["clone", url, "."], token);
38439
+ await runGitWithRetry(dir, ["clone", url, "."], token, {
38440
+ operation: "clone memory repo"
38441
+ });
38419
38442
  } else if (!existsSync8(join7(dir, ".git"))) {
38420
38443
  const tmpDir = `${dir}-git-clone-tmp`;
38421
38444
  try {
@@ -38423,7 +38446,9 @@ async function cloneMemoryRepo(agentId) {
38423
38446
  rmSync(tmpDir, { recursive: true, force: true });
38424
38447
  }
38425
38448
  mkdirSync6(tmpDir, { recursive: true });
38426
- await runGit(tmpDir, ["clone", url, "."], token);
38449
+ await runGitWithRetry(tmpDir, ["clone", url, "."], token, {
38450
+ operation: "clone memory repo (tmp migration)"
38451
+ });
38427
38452
  renameSync(join7(tmpDir, ".git"), join7(dir, ".git"));
38428
38453
  await runGit(dir, ["checkout", "--", "."], token);
38429
38454
  debugLog("memfs-git", "Migrated existing memory directory to git repo");
@@ -38442,7 +38467,7 @@ async function pullMemory(agentId) {
38442
38467
  await configureLocalCredentialHelper(dir, token);
38443
38468
  installPreCommitHook(dir);
38444
38469
  try {
38445
- const { stdout, stderr } = await runGit(dir, ["pull", "--ff-only"], token);
38470
+ const { stdout, stderr } = await runGitWithRetry(dir, ["pull", "--ff-only"], token, { operation: "pull --ff-only" });
38446
38471
  const output = stdout + stderr;
38447
38472
  const updated = !output.includes("Already up to date");
38448
38473
  return {
@@ -38452,7 +38477,7 @@ async function pullMemory(agentId) {
38452
38477
  } catch {
38453
38478
  debugWarn("memfs-git", "Fast-forward pull failed, trying rebase");
38454
38479
  try {
38455
- const { stdout, stderr } = await runGit(dir, ["pull", "--rebase"], token);
38480
+ const { stdout, stderr } = await runGitWithRetry(dir, ["pull", "--rebase"], token, { operation: "pull --rebase" });
38456
38481
  return { updated: true, summary: (stdout + stderr).trim() };
38457
38482
  } catch (rebaseErr) {
38458
38483
  const msg = rebaseErr instanceof Error ? rebaseErr.message : String(rebaseErr);
@@ -38548,7 +38573,7 @@ async function removeGitMemoryTag(agentId) {
38548
38573
  debugWarn("memfs-git", `Failed to remove git-memory tag: ${err instanceof Error ? err.message : String(err)}`);
38549
38574
  }
38550
38575
  }
38551
- var execFile, GIT_MEMORY_ENABLED_TAG = "git-memory-enabled", PRE_COMMIT_HOOK_SCRIPT = `#!/usr/bin/env bash
38576
+ var execFile, GIT_MEMORY_ENABLED_TAG = "git-memory-enabled", RETRYABLE_GIT_HTTP_ERROR_RE, RETRYABLE_GIT_NETWORK_ERROR_RE, PRE_COMMIT_HOOK_SCRIPT = `#!/usr/bin/env bash
38552
38577
  # Validate frontmatter in staged memory .md files
38553
38578
  # Installed by Letta Code CLI
38554
38579
 
@@ -38686,6 +38711,8 @@ var init_memoryGit = __esm(async () => {
38686
38711
  init_debug();
38687
38712
  await init_client2();
38688
38713
  execFile = promisify(execFileCb);
38714
+ RETRYABLE_GIT_HTTP_ERROR_RE = /(?:\bHTTP\s+(?:520|521|522|523|524)\b|The requested URL returned error:\s*(?:520|521|522|523|524))/i;
38715
+ RETRYABLE_GIT_NETWORK_ERROR_RE = /(remote end hung up unexpectedly|connection reset by peer|operation timed out|timed out)/i;
38689
38716
  });
38690
38717
 
38691
38718
  // src/agent/personality.ts
@@ -57464,7 +57491,6 @@ function createSharedReminderState() {
57464
57491
  lastNotifiedPermissionMode: null,
57465
57492
  turnCount: 0,
57466
57493
  pendingReflectionTrigger: false,
57467
- pendingAutoInitReminder: false,
57468
57494
  pendingCommandIoReminders: [],
57469
57495
  pendingToolsetChangeReminders: []
57470
57496
  };
@@ -73037,13 +73063,6 @@ var init_memoryFilesystem = __esm(() => {
73037
73063
  });
73038
73064
 
73039
73065
  // src/cli/helpers/initCommand.ts
73040
- import { execSync as execSync2 } from "node:child_process";
73041
- import { existsSync as existsSync19, readdirSync as readdirSync8, readFileSync as readFileSync11 } from "node:fs";
73042
- import { join as join23 } from "node:path";
73043
- function hasActiveInitSubagent() {
73044
- const snapshot = getSnapshot2();
73045
- return snapshot.agents.some((agent) => agent.type.toLowerCase() === "init" && (agent.status === "pending" || agent.status === "running"));
73046
- }
73047
73066
  function gatherInitGitContext() {
73048
73067
  try {
73049
73068
  const git = gatherGitContextSnapshot({
@@ -73072,154 +73091,6 @@ ${git.recentCommits || "No commits yet"}
73072
73091
  };
73073
73092
  }
73074
73093
  }
73075
- function gatherExistingMemory(agentId) {
73076
- const systemDir = getMemorySystemDir(agentId);
73077
- if (!existsSync19(systemDir))
73078
- return { paths: [], contents: "" };
73079
- const paths = [];
73080
- const sections = [];
73081
- function walk(dir, prefix) {
73082
- try {
73083
- for (const entry of readdirSync8(dir, { withFileTypes: true })) {
73084
- const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
73085
- if (entry.isDirectory()) {
73086
- walk(join23(dir, entry.name), rel);
73087
- } else if (entry.name.endsWith(".md")) {
73088
- try {
73089
- const content = readFileSync11(join23(dir, entry.name), "utf-8");
73090
- paths.push(rel);
73091
- sections.push(`── ${rel}
73092
- ${content.slice(0, 2000)}`);
73093
- } catch {}
73094
- }
73095
- }
73096
- } catch {}
73097
- }
73098
- walk(systemDir, "");
73099
- return { paths, contents: sections.join(`
73100
-
73101
- `) };
73102
- }
73103
- function getGitIgnored(cwd2, names) {
73104
- if (names.length === 0)
73105
- return new Set;
73106
- try {
73107
- const result = execSync2("git check-ignore --stdin", {
73108
- cwd: cwd2,
73109
- encoding: "utf-8",
73110
- input: names.join(`
73111
- `)
73112
- }).trim();
73113
- return new Set(result.split(`
73114
- `).filter(Boolean));
73115
- } catch {
73116
- return new Set([
73117
- "node_modules",
73118
- "dist",
73119
- "build",
73120
- "__pycache__",
73121
- "target",
73122
- "vendor"
73123
- ]);
73124
- }
73125
- }
73126
- function gatherDirListing() {
73127
- const cwd2 = process.cwd();
73128
- try {
73129
- const entries = readdirSync8(cwd2, { withFileTypes: true });
73130
- const visible = entries.filter((e) => !e.name.startsWith("."));
73131
- const ignored = getGitIgnored(cwd2, visible.map((e) => e.name));
73132
- const dirs = visible.filter((e) => e.isDirectory() && !ignored.has(e.name)).sort((a, b) => a.name.localeCompare(b.name));
73133
- const files = visible.filter((e) => !e.isDirectory() && !ignored.has(e.name)).sort((a, b) => a.name.localeCompare(b.name));
73134
- const lines = [];
73135
- const sorted = [...dirs, ...files];
73136
- for (const [i, entry] of sorted.entries()) {
73137
- const isLast = i === sorted.length - 1;
73138
- const prefix = isLast ? "└── " : "├── ";
73139
- if (entry.isDirectory()) {
73140
- lines.push(`${prefix}${entry.name}/`);
73141
- try {
73142
- const dirPath = join23(cwd2, entry.name);
73143
- const childEntries = readdirSync8(dirPath, {
73144
- withFileTypes: true
73145
- }).filter((e) => !e.name.startsWith("."));
73146
- const childIgnored = getGitIgnored(dirPath, childEntries.map((e) => e.name));
73147
- const children = childEntries.filter((e) => !childIgnored.has(e.name)).sort((a, b) => {
73148
- if (a.isDirectory() !== b.isDirectory())
73149
- return a.isDirectory() ? -1 : 1;
73150
- return a.name.localeCompare(b.name);
73151
- });
73152
- const childPrefix = isLast ? " " : "│ ";
73153
- for (const [j, child] of children.entries()) {
73154
- const childIsLast = j === children.length - 1;
73155
- const connector = childIsLast ? "└── " : "├── ";
73156
- const suffix = child.isDirectory() ? "/" : "";
73157
- lines.push(`${childPrefix}${connector}${child.name}${suffix}`);
73158
- }
73159
- } catch {}
73160
- } else {
73161
- lines.push(`${prefix}${entry.name}`);
73162
- }
73163
- }
73164
- return lines.join(`
73165
- `);
73166
- } catch {
73167
- return "";
73168
- }
73169
- }
73170
- function buildShallowInitPrompt(args) {
73171
- const identityLine = args.gitIdentity ? `- git_user: ${args.gitIdentity}` : "";
73172
- return `
73173
- ## Environment
73174
-
73175
- - working_directory: ${args.workingDirectory}
73176
- - memory_dir: ${args.memoryDir}
73177
- - parent_agent_id: ${args.agentId}
73178
- ${identityLine}
73179
-
73180
- ## Project Structure
73181
-
73182
- \`\`\`
73183
- ${args.dirListing}
73184
- \`\`\`
73185
-
73186
- ## Existing Memory
73187
-
73188
- ${args.existingMemoryPaths.length > 0 ? `Paths:
73189
- ${args.existingMemoryPaths.map((p) => `- ${p}`).join(`
73190
- `)}
73191
-
73192
- Contents:
73193
- ${args.existingMemory}` : "(empty)"}
73194
- `.trim();
73195
- }
73196
- async function fireAutoInit(agentId, onComplete) {
73197
- if (hasActiveInitSubagent())
73198
- return false;
73199
- if (!settingsManager.isMemfsEnabled(agentId))
73200
- return false;
73201
- const gitDetails = gatherInitGitContext();
73202
- const existing = gatherExistingMemory(agentId);
73203
- const dirListing = gatherDirListing();
73204
- const initPrompt = buildShallowInitPrompt({
73205
- agentId,
73206
- workingDirectory: process.cwd(),
73207
- memoryDir: getMemoryFilesystemRoot(agentId),
73208
- gitIdentity: gitDetails.identity,
73209
- existingMemoryPaths: existing.paths,
73210
- existingMemory: existing.contents,
73211
- dirListing
73212
- });
73213
- const { spawnBackgroundSubagentTask: spawnBackgroundSubagentTask2 } = await init_Task2().then(() => exports_Task);
73214
- spawnBackgroundSubagentTask2({
73215
- subagentType: "init",
73216
- prompt: initPrompt,
73217
- description: "Initializing memory",
73218
- silentCompletion: true,
73219
- onComplete
73220
- });
73221
- return true;
73222
- }
73223
73094
  function buildInitMessage(args) {
73224
73095
  const memfsSection = args.memoryDir ? `
73225
73096
  ## Memory filesystem
@@ -73265,12 +73136,10 @@ Once invoked, follow the instructions from the \`context_doctor\` skill.
73265
73136
  ${args.gitContext}
73266
73137
  ${SYSTEM_REMINDER_CLOSE}`;
73267
73138
  }
73268
- var init_initCommand = __esm(async () => {
73269
- init_memoryFilesystem();
73139
+ var init_initCommand = __esm(() => {
73270
73140
  init_constants();
73271
73141
  init_gitContext();
73272
73142
  init_subagentState();
73273
- await init_settings_manager();
73274
73143
  });
73275
73144
 
73276
73145
  // src/cli/helpers/errorFormatter.ts
@@ -74516,7 +74385,7 @@ var init_approval_result_normalization = __esm(() => {
74516
74385
  });
74517
74386
 
74518
74387
  // src/agent/clientSkills.ts
74519
- import { join as join24 } from "node:path";
74388
+ import { join as join23 } from "node:path";
74520
74389
  function toClientSkill(skill2) {
74521
74390
  return {
74522
74391
  name: skill2.id,
@@ -74525,12 +74394,12 @@ function toClientSkill(skill2) {
74525
74394
  };
74526
74395
  }
74527
74396
  function resolveSkillDiscoveryContext(options) {
74528
- const legacySkillsDirectory = options.skillsDirectory ?? getSkillsDirectory() ?? join24(process.cwd(), SKILLS_DIR);
74397
+ const legacySkillsDirectory = options.skillsDirectory ?? getSkillsDirectory() ?? join23(process.cwd(), SKILLS_DIR);
74529
74398
  const skillSources = options.skillSources ?? getSkillSources();
74530
74399
  return { legacySkillsDirectory, skillSources };
74531
74400
  }
74532
74401
  function getPrimaryProjectSkillsDirectory() {
74533
- return join24(process.cwd(), ".agents", "skills");
74402
+ return join23(process.cwd(), ".agents", "skills");
74534
74403
  }
74535
74404
  async function buildClientSkillsPayload(options = {}) {
74536
74405
  const { legacySkillsDirectory, skillSources } = resolveSkillDiscoveryContext(options);
@@ -75979,7 +75848,7 @@ import {
75979
75848
  writeFile as writeFile4
75980
75849
  } from "node:fs/promises";
75981
75850
  import { homedir as homedir20, tmpdir as tmpdir3 } from "node:os";
75982
- import { join as join25 } from "node:path";
75851
+ import { join as join24 } from "node:path";
75983
75852
  function buildReflectionSubagentPrompt(input) {
75984
75853
  const lines = [];
75985
75854
  if (input.cwd) {
@@ -76012,7 +75881,7 @@ async function collectParentMemoryFiles(memoryDir) {
76012
75881
  return a.name.localeCompare(b.name);
76013
75882
  });
76014
75883
  for (const entry of sortedEntries) {
76015
- const entryPath = join25(currentDir, entry.name);
75884
+ const entryPath = join24(currentDir, entry.name);
76016
75885
  const relativePath = relativeDir ? `${relativeDir}/${entry.name}` : entry.name;
76017
75886
  if (entry.isDirectory()) {
76018
75887
  await walk(entryPath, relativePath);
@@ -76172,7 +76041,7 @@ function getTranscriptRoot() {
76172
76041
  if (envRoot) {
76173
76042
  return envRoot;
76174
76043
  }
76175
- return join25(homedir20(), ".letta", DEFAULT_TRANSCRIPT_DIR);
76044
+ return join24(homedir20(), ".letta", DEFAULT_TRANSCRIPT_DIR);
76176
76045
  }
76177
76046
  function defaultState() {
76178
76047
  return { auto_cursor_line: 0 };
@@ -76284,14 +76153,14 @@ async function readTranscriptLines(paths) {
76284
76153
  }
76285
76154
  function buildPayloadPath(kind) {
76286
76155
  const nonce = Math.random().toString(36).slice(2, 8);
76287
- return join25(tmpdir3(), `letta-${kind}-${nonce}.txt`);
76156
+ return join24(tmpdir3(), `letta-${kind}-${nonce}.txt`);
76288
76157
  }
76289
76158
  function getReflectionTranscriptPaths(agentId, conversationId) {
76290
- const rootDir = join25(getTranscriptRoot(), sanitizePathSegment(agentId), sanitizePathSegment(conversationId));
76159
+ const rootDir = join24(getTranscriptRoot(), sanitizePathSegment(agentId), sanitizePathSegment(conversationId));
76291
76160
  return {
76292
76161
  rootDir,
76293
- transcriptPath: join25(rootDir, "transcript.jsonl"),
76294
- statePath: join25(rootDir, "state.json")
76162
+ transcriptPath: join24(rootDir, "transcript.jsonl"),
76163
+ statePath: join24(rootDir, "state.json")
76295
76164
  };
76296
76165
  }
76297
76166
  async function appendTranscriptDeltaJsonl(agentId, conversationId, lines) {
@@ -76355,14 +76224,14 @@ var init_reflectionTranscript = __esm(async () => {
76355
76224
 
76356
76225
  // src/cli/helpers/chunkLog.ts
76357
76226
  import {
76358
- existsSync as existsSync20,
76227
+ existsSync as existsSync19,
76359
76228
  mkdirSync as mkdirSync14,
76360
- readdirSync as readdirSync9,
76229
+ readdirSync as readdirSync8,
76361
76230
  unlinkSync as unlinkSync7,
76362
76231
  writeFileSync as writeFileSync11
76363
76232
  } from "node:fs";
76364
76233
  import { homedir as homedir21 } from "node:os";
76365
- import { join as join26 } from "node:path";
76234
+ import { join as join25 } from "node:path";
76366
76235
  function truncateStr(value, maxLen) {
76367
76236
  if (value === null || value === undefined)
76368
76237
  return "";
@@ -76426,8 +76295,8 @@ class ChunkLog {
76426
76295
  agentDir = null;
76427
76296
  dirCreated = false;
76428
76297
  init(agentId, sessionId) {
76429
- this.agentDir = join26(LOG_BASE_DIR, agentId);
76430
- this.logPath = join26(this.agentDir, `${sessionId}.jsonl`);
76298
+ this.agentDir = join25(LOG_BASE_DIR, agentId);
76299
+ this.logPath = join25(this.agentDir, `${sessionId}.jsonl`);
76431
76300
  this.buffer = [];
76432
76301
  this.dirty = false;
76433
76302
  this.dirCreated = false;
@@ -76456,7 +76325,7 @@ class ChunkLog {
76456
76325
  if (this.dirCreated || !this.agentDir)
76457
76326
  return;
76458
76327
  try {
76459
- if (!existsSync20(this.agentDir)) {
76328
+ if (!existsSync19(this.agentDir)) {
76460
76329
  mkdirSync14(this.agentDir, { recursive: true });
76461
76330
  }
76462
76331
  this.dirCreated = true;
@@ -76481,14 +76350,14 @@ class ChunkLog {
76481
76350
  if (!this.agentDir)
76482
76351
  return;
76483
76352
  try {
76484
- if (!existsSync20(this.agentDir))
76353
+ if (!existsSync19(this.agentDir))
76485
76354
  return;
76486
- const files = readdirSync9(this.agentDir).filter((f) => f.endsWith(".jsonl")).sort();
76355
+ const files = readdirSync8(this.agentDir).filter((f) => f.endsWith(".jsonl")).sort();
76487
76356
  if (files.length >= MAX_SESSION_FILES2) {
76488
76357
  const toDelete = files.slice(0, files.length - MAX_SESSION_FILES2 + 1);
76489
76358
  for (const file of toDelete) {
76490
76359
  try {
76491
- unlinkSync7(join26(this.agentDir, file));
76360
+ unlinkSync7(join25(this.agentDir, file));
76492
76361
  } catch (e) {
76493
76362
  debugWarn("chunkLog", `Failed to delete old session log ${file}: ${e instanceof Error ? e.message : String(e)}`);
76494
76363
  }
@@ -76502,7 +76371,7 @@ class ChunkLog {
76502
76371
  var MAX_ENTRIES = 100, CONTENT_TRUNCATE_LEN = 200, MAX_SESSION_FILES2 = 5, LOG_BASE_DIR, chunkLog;
76503
76372
  var init_chunkLog = __esm(() => {
76504
76373
  init_debug();
76505
- LOG_BASE_DIR = join26(homedir21(), ".letta", "logs", "chunk-logs");
76374
+ LOG_BASE_DIR = join25(homedir21(), ".letta", "logs", "chunk-logs");
76506
76375
  chunkLog = new ChunkLog;
76507
76376
  });
76508
76377
 
@@ -77249,11 +77118,6 @@ var init_catalog = __esm(() => {
77249
77118
  id: "toolset-change",
77250
77119
  description: "Client-side toolset change context",
77251
77120
  modes: ["interactive"]
77252
- },
77253
- {
77254
- id: "auto-init",
77255
- description: "Auto-init background onboarding notification",
77256
- modes: ["interactive"]
77257
77121
  }
77258
77122
  ];
77259
77123
  SHARED_REMINDER_IDS = SHARED_REMINDER_CATALOG.map((entry) => entry.id);
@@ -77385,13 +77249,6 @@ async function buildReflectionCompactionReminder(context3) {
77385
77249
  }
77386
77250
  return buildCompactionMemoryReminder(context3.agent.id);
77387
77251
  }
77388
- async function buildAutoInitReminder(context3) {
77389
- if (!context3.state.pendingAutoInitReminder)
77390
- return null;
77391
- context3.state.pendingAutoInitReminder = false;
77392
- const { AUTO_INIT_REMINDER: AUTO_INIT_REMINDER2 } = await Promise.resolve().then(() => (init_promptAssets(), exports_promptAssets));
77393
- return AUTO_INIT_REMINDER2;
77394
- }
77395
77252
  function escapeXml2(value) {
77396
77253
  return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
77397
77254
  }
@@ -77541,8 +77398,7 @@ var init_engine = __esm(async () => {
77541
77398
  "reflection-step-count": buildReflectionStepReminder,
77542
77399
  "reflection-compaction": buildReflectionCompactionReminder,
77543
77400
  "command-io": buildCommandIoReminder,
77544
- "toolset-change": buildToolsetChangeReminder,
77545
- "auto-init": buildAutoInitReminder
77401
+ "toolset-change": buildToolsetChangeReminder
77546
77402
  };
77547
77403
  assertSharedReminderCoverage();
77548
77404
  });
@@ -77640,7 +77496,7 @@ var init_constants2 = __esm(() => {
77640
77496
  });
77641
77497
 
77642
77498
  // src/websocket/listener/remote-settings.ts
77643
- import { existsSync as existsSync21, readFileSync as readFileSync12 } from "node:fs";
77499
+ import { existsSync as existsSync20, readFileSync as readFileSync11 } from "node:fs";
77644
77500
  import { mkdir as mkdir5, writeFile as writeFile5 } from "node:fs/promises";
77645
77501
  import { homedir as homedir22 } from "node:os";
77646
77502
  import path20 from "node:path";
@@ -77654,8 +77510,8 @@ function loadRemoteSettings() {
77654
77510
  let loaded = {};
77655
77511
  try {
77656
77512
  const settingsPath = getRemoteSettingsPath();
77657
- if (existsSync21(settingsPath)) {
77658
- const raw = readFileSync12(settingsPath, "utf-8");
77513
+ if (existsSync20(settingsPath)) {
77514
+ const raw = readFileSync11(settingsPath, "utf-8");
77659
77515
  const parsed = JSON.parse(raw);
77660
77516
  loaded = parsed;
77661
77517
  }
@@ -77663,7 +77519,7 @@ function loadRemoteSettings() {
77663
77519
  if (loaded.cwdMap) {
77664
77520
  const validCwdMap = {};
77665
77521
  for (const [key, value] of Object.entries(loaded.cwdMap)) {
77666
- if (typeof value === "string" && existsSync21(value)) {
77522
+ if (typeof value === "string" && existsSync20(value)) {
77667
77523
  validCwdMap[key] = value;
77668
77524
  }
77669
77525
  }
@@ -77690,13 +77546,13 @@ function saveRemoteSettings(updates) {
77690
77546
  function loadLegacyCwdCache() {
77691
77547
  try {
77692
77548
  const legacyPath = path20.join(homedir22(), ".letta", "cwd-cache.json");
77693
- if (!existsSync21(legacyPath))
77549
+ if (!existsSync20(legacyPath))
77694
77550
  return {};
77695
- const raw = readFileSync12(legacyPath, "utf-8");
77551
+ const raw = readFileSync11(legacyPath, "utf-8");
77696
77552
  const parsed = JSON.parse(raw);
77697
77553
  const result = {};
77698
77554
  for (const [key, value] of Object.entries(parsed)) {
77699
- if (typeof value === "string" && existsSync21(value)) {
77555
+ if (typeof value === "string" && existsSync20(value)) {
77700
77556
  result[key] = value;
77701
77557
  }
77702
77558
  }
@@ -82327,11 +82183,11 @@ var init_commands = __esm(async () => {
82327
82183
  init_memory();
82328
82184
  init_memoryFilesystem();
82329
82185
  init_promptAssets();
82186
+ init_initCommand();
82330
82187
  init_constants();
82331
82188
  init_runtime();
82332
82189
  await __promiseAll([
82333
82190
  init_client2(),
82334
- init_initCommand(),
82335
82191
  init_settings_manager(),
82336
82192
  init_errorReporting(),
82337
82193
  init_protocol_outbound(),
@@ -83674,6 +83530,18 @@ function isListMemoryCommand(value) {
83674
83530
  const c = value;
83675
83531
  return c.type === "list_memory" && typeof c.request_id === "string" && typeof c.agent_id === "string";
83676
83532
  }
83533
+ function isMemoryHistoryCommand(value) {
83534
+ if (!value || typeof value !== "object")
83535
+ return false;
83536
+ const c = value;
83537
+ return c.type === "memory_history" && typeof c.request_id === "string" && typeof c.agent_id === "string" && typeof c.file_path === "string";
83538
+ }
83539
+ function isMemoryFileAtRefCommand(value) {
83540
+ if (!value || typeof value !== "object")
83541
+ return false;
83542
+ const c = value;
83543
+ return c.type === "memory_file_at_ref" && typeof c.request_id === "string" && typeof c.agent_id === "string" && typeof c.file_path === "string" && typeof c.ref === "string";
83544
+ }
83677
83545
  function isEnableMemfsCommand(value) {
83678
83546
  if (!value || typeof value !== "object")
83679
83547
  return false;
@@ -83786,7 +83654,7 @@ function parseServerMessage(data) {
83786
83654
  try {
83787
83655
  const raw = typeof data === "string" ? data : data.toString();
83788
83656
  const parsed = JSON.parse(raw);
83789
- if (isInputCommand(parsed) || isChangeDeviceStateCommand(parsed) || isAbortMessageCommand(parsed) || isSyncCommand(parsed) || isTerminalSpawnCommand(parsed) || isTerminalInputCommand(parsed) || isTerminalResizeCommand(parsed) || isTerminalKillCommand(parsed) || isSearchFilesCommand(parsed) || isListInDirectoryCommand(parsed) || isReadFileCommand(parsed) || isWriteFileCommand(parsed) || isEditFileCommand(parsed) || isListMemoryCommand(parsed) || isEnableMemfsCommand(parsed) || isListModelsCommand(parsed) || isUpdateModelCommand(parsed) || isCronListCommand(parsed) || isCronAddCommand(parsed) || isCronGetCommand(parsed) || isCronDeleteCommand(parsed) || isCronDeleteAllCommand(parsed) || isSkillEnableCommand(parsed) || isSkillDisableCommand(parsed) || isCreateAgentCommand(parsed) || isGetReflectionSettingsCommand(parsed) || isSetReflectionSettingsCommand(parsed) || isExecuteCommandCommand(parsed) || isSearchBranchesCommand(parsed) || isCheckoutBranchCommand(parsed)) {
83657
+ if (isInputCommand(parsed) || isChangeDeviceStateCommand(parsed) || isAbortMessageCommand(parsed) || isSyncCommand(parsed) || isTerminalSpawnCommand(parsed) || isTerminalInputCommand(parsed) || isTerminalResizeCommand(parsed) || isTerminalKillCommand(parsed) || isSearchFilesCommand(parsed) || isListInDirectoryCommand(parsed) || isReadFileCommand(parsed) || isWriteFileCommand(parsed) || isEditFileCommand(parsed) || isListMemoryCommand(parsed) || isMemoryHistoryCommand(parsed) || isMemoryFileAtRefCommand(parsed) || isEnableMemfsCommand(parsed) || isListModelsCommand(parsed) || isUpdateModelCommand(parsed) || isCronListCommand(parsed) || isCronAddCommand(parsed) || isCronGetCommand(parsed) || isCronDeleteCommand(parsed) || isCronDeleteAllCommand(parsed) || isSkillEnableCommand(parsed) || isSkillDisableCommand(parsed) || isCreateAgentCommand(parsed) || isGetReflectionSettingsCommand(parsed) || isSetReflectionSettingsCommand(parsed) || isExecuteCommandCommand(parsed) || isSearchBranchesCommand(parsed) || isCheckoutBranchCommand(parsed)) {
83790
83658
  return parsed;
83791
83659
  }
83792
83660
  const invalidInput = getInvalidInputReason(parsed);
@@ -83814,21 +83682,21 @@ __export(exports_memoryScanner, {
83814
83682
  readFileContent: () => readFileContent,
83815
83683
  getFileNodes: () => getFileNodes
83816
83684
  });
83817
- import { readdirSync as readdirSync10, readFileSync as readFileSync13, statSync as statSync7 } from "node:fs";
83818
- import { join as join27, relative as relative11 } from "node:path";
83685
+ import { readdirSync as readdirSync9, readFileSync as readFileSync12, statSync as statSync7 } from "node:fs";
83686
+ import { join as join26, relative as relative11 } from "node:path";
83819
83687
  function scanMemoryFilesystem(memoryRoot) {
83820
83688
  const nodes = [];
83821
83689
  const scanDir = (dir, depth, parentIsLast) => {
83822
83690
  let entries;
83823
83691
  try {
83824
- entries = readdirSync10(dir);
83692
+ entries = readdirSync9(dir);
83825
83693
  } catch {
83826
83694
  return;
83827
83695
  }
83828
83696
  const filtered = entries.filter((name) => !name.startsWith("."));
83829
83697
  const sorted = filtered.sort((a, b) => {
83830
- const aPath = join27(dir, a);
83831
- const bPath = join27(dir, b);
83698
+ const aPath = join26(dir, a);
83699
+ const bPath = join26(dir, b);
83832
83700
  let aIsDir = false;
83833
83701
  let bIsDir = false;
83834
83702
  try {
@@ -83848,7 +83716,7 @@ function scanMemoryFilesystem(memoryRoot) {
83848
83716
  return a.localeCompare(b);
83849
83717
  });
83850
83718
  sorted.forEach((name, index) => {
83851
- const fullPath = join27(dir, name);
83719
+ const fullPath = join26(dir, name);
83852
83720
  let isDir = false;
83853
83721
  try {
83854
83722
  isDir = statSync7(fullPath).isDirectory();
@@ -83879,7 +83747,7 @@ function getFileNodes(nodes) {
83879
83747
  }
83880
83748
  function readFileContent(fullPath) {
83881
83749
  try {
83882
- return readFileSync13(fullPath, "utf-8");
83750
+ return readFileSync12(fullPath, "utf-8");
83883
83751
  } catch {
83884
83752
  return "(unable to read file)";
83885
83753
  }
@@ -84325,19 +84193,19 @@ function emitSkillsUpdated(socket) {
84325
84193
  }
84326
84194
  async function handleSkillCommand(parsed, socket) {
84327
84195
  const {
84328
- existsSync: existsSync22,
84196
+ existsSync: existsSync21,
84329
84197
  lstatSync: lstatSync2,
84330
84198
  mkdirSync: mkdirSync15,
84331
84199
  rmdirSync,
84332
84200
  symlinkSync,
84333
84201
  unlinkSync: unlinkSync8
84334
84202
  } = await import("node:fs");
84335
- const { basename: basename5, join: join28 } = await import("node:path");
84336
- const lettaHome = process.env.LETTA_HOME || join28(process.env.HOME || process.env.USERPROFILE || "~", ".letta");
84337
- const globalSkillsDir = join28(lettaHome, "skills");
84203
+ const { basename: basename5, join: join27 } = await import("node:path");
84204
+ const lettaHome = process.env.LETTA_HOME || join27(process.env.HOME || process.env.USERPROFILE || "~", ".letta");
84205
+ const globalSkillsDir = join27(lettaHome, "skills");
84338
84206
  if (parsed.type === "skill_enable") {
84339
84207
  try {
84340
- if (!existsSync22(parsed.skill_path)) {
84208
+ if (!existsSync21(parsed.skill_path)) {
84341
84209
  safeSocketSend(socket, {
84342
84210
  type: "skill_enable_response",
84343
84211
  request_id: parsed.request_id,
@@ -84346,8 +84214,8 @@ async function handleSkillCommand(parsed, socket) {
84346
84214
  }, "listener_skill_send_failed", "listener_skill_command");
84347
84215
  return true;
84348
84216
  }
84349
- const skillMdPath = join28(parsed.skill_path, "SKILL.md");
84350
- if (!existsSync22(skillMdPath)) {
84217
+ const skillMdPath = join27(parsed.skill_path, "SKILL.md");
84218
+ if (!existsSync21(skillMdPath)) {
84351
84219
  safeSocketSend(socket, {
84352
84220
  type: "skill_enable_response",
84353
84221
  request_id: parsed.request_id,
@@ -84357,9 +84225,9 @@ async function handleSkillCommand(parsed, socket) {
84357
84225
  return true;
84358
84226
  }
84359
84227
  const linkName = basename5(parsed.skill_path);
84360
- const linkPath = join28(globalSkillsDir, linkName);
84228
+ const linkPath = join27(globalSkillsDir, linkName);
84361
84229
  mkdirSync15(globalSkillsDir, { recursive: true });
84362
- if (existsSync22(linkPath)) {
84230
+ if (existsSync21(linkPath)) {
84363
84231
  const stat6 = lstatSync2(linkPath);
84364
84232
  if (stat6.isSymbolicLink()) {
84365
84233
  if (process.platform === "win32") {
@@ -84400,8 +84268,8 @@ async function handleSkillCommand(parsed, socket) {
84400
84268
  }
84401
84269
  if (parsed.type === "skill_disable") {
84402
84270
  try {
84403
- const linkPath = join28(globalSkillsDir, parsed.name);
84404
- if (!existsSync22(linkPath)) {
84271
+ const linkPath = join27(globalSkillsDir, parsed.name);
84272
+ if (!existsSync21(linkPath)) {
84405
84273
  safeSocketSend(socket, {
84406
84274
  type: "skill_disable_response",
84407
84275
  request_id: parsed.request_id,
@@ -85381,10 +85249,10 @@ async function connectWithRetry(runtime, opts, attempt = 0, startTime = Date.now
85381
85249
  const { getMemoryFilesystemRoot: getMemoryFilesystemRoot2 } = await Promise.resolve().then(() => (init_memoryFilesystem(), exports_memoryFilesystem));
85382
85250
  const { scanMemoryFilesystem: scanMemoryFilesystem2, getFileNodes: getFileNodes2, readFileContent: readFileContent2 } = await Promise.resolve().then(() => (init_memoryScanner(), exports_memoryScanner));
85383
85251
  const { parseFrontmatter: parseFrontmatter2 } = await Promise.resolve().then(() => exports_frontmatter);
85384
- const { existsSync: existsSync22 } = await import("node:fs");
85385
- const { join: join28 } = await import("node:path");
85252
+ const { existsSync: existsSync21 } = await import("node:fs");
85253
+ const { join: join27 } = await import("node:path");
85386
85254
  const memoryRoot = getMemoryFilesystemRoot2(parsed.agent_id);
85387
- const memfsInitialized = existsSync22(join28(memoryRoot, ".git"));
85255
+ const memfsInitialized = existsSync21(join27(memoryRoot, ".git"));
85388
85256
  if (!memfsInitialized) {
85389
85257
  safeSocketSend(socket, {
85390
85258
  type: "list_memory_response",
@@ -85541,6 +85409,72 @@ async function connectWithRetry(runtime, opts, attempt = 0, startTime = Date.now
85541
85409
  });
85542
85410
  return;
85543
85411
  }
85412
+ if (isMemoryHistoryCommand(parsed)) {
85413
+ runDetachedListenerTask("memory_history", async () => {
85414
+ const { getMemoryFilesystemRoot: getMemoryFilesystemRoot2 } = await Promise.resolve().then(() => (init_memoryFilesystem(), exports_memoryFilesystem));
85415
+ const { execFile: execFileCb5 } = await import("node:child_process");
85416
+ const { promisify: promisify13 } = await import("node:util");
85417
+ const execFileAsync7 = promisify13(execFileCb5);
85418
+ const memoryRoot = getMemoryFilesystemRoot2(parsed.agent_id);
85419
+ const limit2 = parsed.limit ?? 50;
85420
+ const { stdout } = await execFileAsync7("git", [
85421
+ "log",
85422
+ `--max-count=${limit2}`,
85423
+ "--format=%H|%s|%aI|%an",
85424
+ "--",
85425
+ parsed.file_path
85426
+ ], { cwd: memoryRoot, timeout: 1e4 });
85427
+ const commits = stdout.trim().split(`
85428
+ `).filter((line) => line.length > 0).map((line) => {
85429
+ const [sha, message, timestamp, authorName] = line.split("|");
85430
+ return {
85431
+ sha: sha ?? "",
85432
+ message: message ?? "",
85433
+ timestamp: timestamp ?? "",
85434
+ author_name: authorName ?? null
85435
+ };
85436
+ });
85437
+ safeSocketSend(socket, {
85438
+ type: "memory_history_response",
85439
+ request_id: parsed.request_id,
85440
+ file_path: parsed.file_path,
85441
+ commits,
85442
+ success: true
85443
+ }, "listener_memory_history_send_failed", "listener_memory_history");
85444
+ });
85445
+ return;
85446
+ }
85447
+ if (isMemoryFileAtRefCommand(parsed)) {
85448
+ runDetachedListenerTask("memory_file_at_ref", async () => {
85449
+ const { getMemoryFilesystemRoot: getMemoryFilesystemRoot2 } = await Promise.resolve().then(() => (init_memoryFilesystem(), exports_memoryFilesystem));
85450
+ const { execFile: execFileCb5 } = await import("node:child_process");
85451
+ const { promisify: promisify13 } = await import("node:util");
85452
+ const execFileAsync7 = promisify13(execFileCb5);
85453
+ const memoryRoot = getMemoryFilesystemRoot2(parsed.agent_id);
85454
+ try {
85455
+ const { stdout } = await execFileAsync7("git", ["show", `${parsed.ref}:${parsed.file_path}`], { cwd: memoryRoot, timeout: 1e4 });
85456
+ safeSocketSend(socket, {
85457
+ type: "memory_file_at_ref_response",
85458
+ request_id: parsed.request_id,
85459
+ file_path: parsed.file_path,
85460
+ ref: parsed.ref,
85461
+ content: stdout,
85462
+ success: true
85463
+ }, "listener_memory_file_at_ref_send_failed", "listener_memory_file_at_ref");
85464
+ } catch (err) {
85465
+ safeSocketSend(socket, {
85466
+ type: "memory_file_at_ref_response",
85467
+ request_id: parsed.request_id,
85468
+ file_path: parsed.file_path,
85469
+ ref: parsed.ref,
85470
+ content: null,
85471
+ success: false,
85472
+ error: err instanceof Error ? err.message : "Failed to read file at ref"
85473
+ }, "listener_memory_file_at_ref_send_failed", "listener_memory_file_at_ref");
85474
+ }
85475
+ });
85476
+ return;
85477
+ }
85544
85478
  if (isCronListCommand(parsed) || isCronAddCommand(parsed) || isCronGetCommand(parsed) || isCronDeleteCommand(parsed) || isCronDeleteAllCommand(parsed)) {
85545
85479
  runDetachedListenerTask("cron_command", async () => {
85546
85480
  await handleCronCommand(parsed, socket);
@@ -86070,14 +86004,14 @@ __export(exports_debug2, {
86070
86004
  });
86071
86005
  import {
86072
86006
  appendFileSync as appendFileSync3,
86073
- existsSync as existsSync23,
86007
+ existsSync as existsSync22,
86074
86008
  mkdirSync as mkdirSync16,
86075
- readdirSync as readdirSync11,
86076
- readFileSync as readFileSync14,
86009
+ readdirSync as readdirSync10,
86010
+ readFileSync as readFileSync13,
86077
86011
  unlinkSync as unlinkSync8
86078
86012
  } from "node:fs";
86079
86013
  import { homedir as homedir26 } from "node:os";
86080
- import { join as join31 } from "node:path";
86014
+ import { join as join30 } from "node:path";
86081
86015
  import { format as format2 } from "node:util";
86082
86016
  function isDebugEnabled2() {
86083
86017
  const lettaDebug = process.env.LETTA_DEBUG;
@@ -86108,8 +86042,8 @@ class DebugLogFile2 {
86108
86042
  const telem = process.env.LETTA_CODE_TELEM;
86109
86043
  if (telem === "0" || telem === "false")
86110
86044
  return;
86111
- this.agentDir = join31(DEBUG_LOG_DIR2, agentId);
86112
- this.logPath = join31(this.agentDir, `${sessionId}.log`);
86045
+ this.agentDir = join30(DEBUG_LOG_DIR2, agentId);
86046
+ this.logPath = join30(this.agentDir, `${sessionId}.log`);
86113
86047
  this.dirCreated = false;
86114
86048
  this.pruneOldSessions();
86115
86049
  }
@@ -86125,9 +86059,9 @@ class DebugLogFile2 {
86125
86059
  if (!this.logPath)
86126
86060
  return;
86127
86061
  try {
86128
- if (!existsSync23(this.logPath))
86062
+ if (!existsSync22(this.logPath))
86129
86063
  return;
86130
- const content = readFileSync14(this.logPath, "utf8");
86064
+ const content = readFileSync13(this.logPath, "utf8");
86131
86065
  const lines = content.trimEnd().split(`
86132
86066
  `);
86133
86067
  return lines.slice(-maxLines).join(`
@@ -86140,7 +86074,7 @@ class DebugLogFile2 {
86140
86074
  if (this.dirCreated || !this.agentDir)
86141
86075
  return;
86142
86076
  try {
86143
- if (!existsSync23(this.agentDir)) {
86077
+ if (!existsSync22(this.agentDir)) {
86144
86078
  mkdirSync16(this.agentDir, { recursive: true });
86145
86079
  }
86146
86080
  this.dirCreated = true;
@@ -86150,14 +86084,14 @@ class DebugLogFile2 {
86150
86084
  if (!this.agentDir)
86151
86085
  return;
86152
86086
  try {
86153
- if (!existsSync23(this.agentDir))
86087
+ if (!existsSync22(this.agentDir))
86154
86088
  return;
86155
- const files = readdirSync11(this.agentDir).filter((f) => f.endsWith(".log")).sort();
86089
+ const files = readdirSync10(this.agentDir).filter((f) => f.endsWith(".log")).sort();
86156
86090
  if (files.length >= MAX_SESSION_FILES3) {
86157
86091
  const toDelete = files.slice(0, files.length - MAX_SESSION_FILES3 + 1);
86158
86092
  for (const file of toDelete) {
86159
86093
  try {
86160
- unlinkSync8(join31(this.agentDir, file));
86094
+ unlinkSync8(join30(this.agentDir, file));
86161
86095
  } catch {}
86162
86096
  }
86163
86097
  }
@@ -86182,7 +86116,7 @@ function debugWarn2(prefix, message, ...args) {
86182
86116
  }
86183
86117
  var DEBUG_LOG_DIR2, MAX_SESSION_FILES3 = 5, DEFAULT_TAIL_LINES2 = 50, debugLogFile2;
86184
86118
  var init_debug2 = __esm(() => {
86185
- DEBUG_LOG_DIR2 = join31(homedir26(), ".letta", "logs", "debug");
86119
+ DEBUG_LOG_DIR2 = join30(homedir26(), ".letta", "logs", "debug");
86186
86120
  debugLogFile2 = new DebugLogFile2;
86187
86121
  });
86188
86122
 
@@ -86209,22 +86143,22 @@ __export(exports_skills2, {
86209
86143
  SKILLS_DIR: () => SKILLS_DIR2,
86210
86144
  GLOBAL_SKILLS_DIR: () => GLOBAL_SKILLS_DIR2
86211
86145
  });
86212
- import { existsSync as existsSync24 } from "node:fs";
86146
+ import { existsSync as existsSync23 } from "node:fs";
86213
86147
  import { readdir as readdir7, readFile as readFile8, realpath as realpath4, stat as stat6 } from "node:fs/promises";
86214
- import { dirname as dirname13, join as join32 } from "node:path";
86148
+ import { dirname as dirname13, join as join31 } from "node:path";
86215
86149
  import { fileURLToPath as fileURLToPath8 } from "node:url";
86216
86150
  function getBundledSkillsPath2() {
86217
86151
  const thisDir = dirname13(fileURLToPath8(import.meta.url));
86218
86152
  if (thisDir.includes("src/agent") || thisDir.includes("src\\agent")) {
86219
- return join32(thisDir, "../skills/builtin");
86153
+ return join31(thisDir, "../skills/builtin");
86220
86154
  }
86221
- return join32(thisDir, "skills");
86155
+ return join31(thisDir, "skills");
86222
86156
  }
86223
86157
  function compareSkills2(a, b) {
86224
86158
  return a.id.localeCompare(b.id) || a.source.localeCompare(b.source) || a.path.localeCompare(b.path);
86225
86159
  }
86226
86160
  function getAgentSkillsDir2(agentId) {
86227
- return join32(process.env.HOME || process.env.USERPROFILE || "~", ".letta/agents", agentId, "skills");
86161
+ return join31(process.env.HOME || process.env.USERPROFILE || "~", ".letta/agents", agentId, "skills");
86228
86162
  }
86229
86163
  async function getBundledSkills2() {
86230
86164
  const bundledPath = getBundledSkillsPath2();
@@ -86233,7 +86167,7 @@ async function getBundledSkills2() {
86233
86167
  }
86234
86168
  async function discoverSkillsFromDir2(skillsPath, source) {
86235
86169
  const errors = [];
86236
- if (!existsSync24(skillsPath)) {
86170
+ if (!existsSync23(skillsPath)) {
86237
86171
  return { skills: [], errors: [] };
86238
86172
  }
86239
86173
  const skills = [];
@@ -86247,7 +86181,7 @@ async function discoverSkillsFromDir2(skillsPath, source) {
86247
86181
  }
86248
86182
  return { skills, errors };
86249
86183
  }
86250
- async function discoverSkills2(projectSkillsPath = join32(process.cwd(), SKILLS_DIR2), agentId, options) {
86184
+ async function discoverSkills2(projectSkillsPath = join31(process.cwd(), SKILLS_DIR2), agentId, options) {
86251
86185
  const allErrors = [];
86252
86186
  const skillsById = new Map;
86253
86187
  const sourceSet = new Set(options?.sources ?? ALL_SKILL_SOURCES);
@@ -86302,7 +86236,7 @@ async function findSkillFiles2(currentPath, rootPath, skills, errors, source, vi
86302
86236
  try {
86303
86237
  const entries = await readdir7(currentPath, { withFileTypes: true });
86304
86238
  for (const entry of entries) {
86305
- const fullPath = join32(currentPath, entry.name);
86239
+ const fullPath = join31(currentPath, entry.name);
86306
86240
  try {
86307
86241
  let isDirectory = entry.isDirectory();
86308
86242
  let isFile = entry.isFile();
@@ -86391,7 +86325,7 @@ ${lines.join(`
86391
86325
  var SKILLS_DIR2 = ".skills", GLOBAL_SKILLS_DIR2;
86392
86326
  var init_skills2 = __esm(() => {
86393
86327
  init_skillSources();
86394
- GLOBAL_SKILLS_DIR2 = join32(process.env.HOME || process.env.USERPROFILE || "~", ".letta/skills");
86328
+ GLOBAL_SKILLS_DIR2 = join31(process.env.HOME || process.env.USERPROFILE || "~", ".letta/skills");
86395
86329
  });
86396
86330
 
86397
86331
  // src/utils/fs.ts
@@ -86405,7 +86339,7 @@ __export(exports_fs, {
86405
86339
  exists: () => exists2
86406
86340
  });
86407
86341
  import {
86408
- existsSync as existsSync25,
86342
+ existsSync as existsSync24,
86409
86343
  readFileSync as fsReadFileSync2,
86410
86344
  writeFileSync as fsWriteFileSync2,
86411
86345
  mkdirSync as mkdirSync17
@@ -86416,13 +86350,13 @@ async function readFile9(path23) {
86416
86350
  }
86417
86351
  async function writeFile7(path23, content) {
86418
86352
  const dir = dirname14(path23);
86419
- if (!existsSync25(dir)) {
86353
+ if (!existsSync24(dir)) {
86420
86354
  mkdirSync17(dir, { recursive: true });
86421
86355
  }
86422
86356
  fsWriteFileSync2(path23, content, { encoding: "utf-8", flush: true });
86423
86357
  }
86424
86358
  function exists2(path23) {
86425
- return existsSync25(path23);
86359
+ return existsSync24(path23);
86426
86360
  }
86427
86361
  async function mkdir6(path23, options) {
86428
86362
  mkdirSync17(path23, options);
@@ -86745,7 +86679,7 @@ __export(exports_auto_update, {
86745
86679
  import { execFile as execFile13 } from "node:child_process";
86746
86680
  import { realpathSync as realpathSync2 } from "node:fs";
86747
86681
  import { readdir as readdir8, rm as rm3 } from "node:fs/promises";
86748
- import { join as join33 } from "node:path";
86682
+ import { join as join32 } from "node:path";
86749
86683
  import { promisify as promisify13 } from "node:util";
86750
86684
  function debugLog3(...args) {
86751
86685
  if (DEBUG) {
@@ -86910,12 +86844,12 @@ async function getNpmGlobalPath() {
86910
86844
  }
86911
86845
  }
86912
86846
  async function cleanupOrphanedDirs(globalPath) {
86913
- const lettaAiDir = join33(globalPath, "lib/node_modules/@letta-ai");
86847
+ const lettaAiDir = join32(globalPath, "lib/node_modules/@letta-ai");
86914
86848
  try {
86915
86849
  const entries = await readdir8(lettaAiDir);
86916
86850
  for (const entry of entries) {
86917
86851
  if (entry.startsWith(".letta-code-")) {
86918
- const orphanPath = join33(lettaAiDir, entry);
86852
+ const orphanPath = join32(lettaAiDir, entry);
86919
86853
  debugLog3("Cleaning orphaned temp directory:", orphanPath);
86920
86854
  await rm3(orphanPath, { recursive: true, force: true });
86921
86855
  }
@@ -87270,7 +87204,6 @@ __export(exports_promptAssets2, {
87270
87204
  MEMORY_PROMPTS: () => MEMORY_PROMPTS2,
87271
87205
  MEMORY_CHECK_REMINDER: () => MEMORY_CHECK_REMINDER2,
87272
87206
  INTERRUPT_RECOVERY_ALERT: () => INTERRUPT_RECOVERY_ALERT2,
87273
- AUTO_INIT_REMINDER: () => AUTO_INIT_REMINDER2,
87274
87207
  APPROVAL_RECOVERY_PROMPT: () => APPROVAL_RECOVERY_PROMPT2
87275
87208
  });
87276
87209
  function scanHeadingsOutsideFences2(text) {
@@ -87401,10 +87334,9 @@ async function resolveSystemPrompt2(systemPromptPreset) {
87401
87334
  }
87402
87335
  throw new Error(`Unknown system prompt "${systemPromptPreset}" — does not match any preset or subagent`);
87403
87336
  }
87404
- var SYSTEM_PROMPT2, SYSTEM_PROMPT_BLOCKS_ADDON2, SYSTEM_PROMPT_MEMFS_ADDON2, PLAN_MODE_REMINDER2, SKILL_CREATOR_PROMPT2, REMEMBER_PROMPT2, MEMORY_CHECK_REMINDER2, APPROVAL_RECOVERY_PROMPT2, AUTO_INIT_REMINDER2, INTERRUPT_RECOVERY_ALERT2, SLEEPTIME_MEMORY_PERSONA2, MEMORY_PROMPTS2, SYSTEM_PROMPTS2;
87337
+ var SYSTEM_PROMPT2, SYSTEM_PROMPT_BLOCKS_ADDON2, SYSTEM_PROMPT_MEMFS_ADDON2, PLAN_MODE_REMINDER2, SKILL_CREATOR_PROMPT2, REMEMBER_PROMPT2, MEMORY_CHECK_REMINDER2, APPROVAL_RECOVERY_PROMPT2, INTERRUPT_RECOVERY_ALERT2, SLEEPTIME_MEMORY_PERSONA2, MEMORY_PROMPTS2, SYSTEM_PROMPTS2;
87405
87338
  var init_promptAssets2 = __esm(() => {
87406
87339
  init_approval_recovery_alert();
87407
- init_auto_init_reminder();
87408
87340
  init_human();
87409
87341
  init_human_kawaii();
87410
87342
  init_human_linus();
@@ -87436,7 +87368,6 @@ var init_promptAssets2 = __esm(() => {
87436
87368
  REMEMBER_PROMPT2 = remember_default;
87437
87369
  MEMORY_CHECK_REMINDER2 = memory_check_reminder_default;
87438
87370
  APPROVAL_RECOVERY_PROMPT2 = approval_recovery_alert_default;
87439
- AUTO_INIT_REMINDER2 = auto_init_reminder_default;
87440
87371
  INTERRUPT_RECOVERY_ALERT2 = interrupt_recovery_alert_default;
87441
87372
  SLEEPTIME_MEMORY_PERSONA2 = sleeptime_default;
87442
87373
  MEMORY_PROMPTS2 = {
@@ -88212,8 +88143,8 @@ __export(exports_github_utils, {
88212
88143
  async function fetchGitHubContents(owner, repo, branch, path25) {
88213
88144
  const apiPath = path25 ? `repos/${owner}/${repo}/contents/${path25}?ref=${branch}` : `repos/${owner}/${repo}/contents?ref=${branch}`;
88214
88145
  try {
88215
- const { execSync: execSync3 } = await import("node:child_process");
88216
- const result = execSync3(`gh api ${apiPath}`, {
88146
+ const { execSync: execSync2 } = await import("node:child_process");
88147
+ const result = execSync2(`gh api ${apiPath}`, {
88217
88148
  encoding: "utf-8",
88218
88149
  stdio: ["pipe", "pipe", "ignore"]
88219
88150
  });
@@ -88356,7 +88287,7 @@ function parseRegistryHandle(handle) {
88356
88287
  }
88357
88288
  async function importAgentFromRegistry(options) {
88358
88289
  const { tmpdir: tmpdir4 } = await import("node:os");
88359
- const { join: join35 } = await import("node:path");
88290
+ const { join: join34 } = await import("node:path");
88360
88291
  const { writeFile: writeFile9, unlink: unlink3 } = await import("node:fs/promises");
88361
88292
  const { author, name } = parseRegistryHandle(options.handle);
88362
88293
  const rawUrl = `https://raw.githubusercontent.com/${AGENT_REGISTRY_OWNER}/${AGENT_REGISTRY_REPO}/refs/heads/${AGENT_REGISTRY_BRANCH}/agents/@${author}/${name}/${name}.af`;
@@ -88368,7 +88299,7 @@ async function importAgentFromRegistry(options) {
88368
88299
  throw new Error(`Failed to download agent @${author}/${name}: ${response.statusText}`);
88369
88300
  }
88370
88301
  const afContent = await response.text();
88371
- const tempPath = join35(tmpdir4(), `letta-import-${author}-${name}-${Date.now()}.af`);
88302
+ const tempPath = join34(tmpdir4(), `letta-import-${author}-${name}-${Date.now()}.af`);
88372
88303
  await writeFile9(tempPath, afContent, "utf-8");
88373
88304
  try {
88374
88305
  const result = await importAgentFromFile({
@@ -91558,9 +91489,9 @@ __export(exports_settings, {
91558
91489
  getSetting: () => getSetting
91559
91490
  });
91560
91491
  import { homedir as homedir29 } from "node:os";
91561
- import { join as join36 } from "node:path";
91492
+ import { join as join35 } from "node:path";
91562
91493
  function getSettingsPath() {
91563
- return join36(homedir29(), ".letta", "settings.json");
91494
+ return join35(homedir29(), ".letta", "settings.json");
91564
91495
  }
91565
91496
  async function loadSettings() {
91566
91497
  const settingsPath = getSettingsPath();
@@ -91597,7 +91528,7 @@ async function getSetting(key) {
91597
91528
  return settings[key];
91598
91529
  }
91599
91530
  function getProjectSettingsPath() {
91600
- return join36(process.cwd(), ".letta", "settings.local.json");
91531
+ return join35(process.cwd(), ".letta", "settings.local.json");
91601
91532
  }
91602
91533
  async function loadProjectSettings() {
91603
91534
  const settingsPath = getProjectSettingsPath();
@@ -91615,7 +91546,7 @@ async function loadProjectSettings() {
91615
91546
  }
91616
91547
  async function saveProjectSettings(settings) {
91617
91548
  const settingsPath = getProjectSettingsPath();
91618
- const dirPath = join36(process.cwd(), ".letta");
91549
+ const dirPath = join35(process.cwd(), ".letta");
91619
91550
  try {
91620
91551
  if (!exists(dirPath)) {
91621
91552
  await mkdir(dirPath, { recursive: true });
@@ -108243,9 +108174,9 @@ function getFileEditHeader(toolName, toolArgs) {
108243
108174
  const relPath = relative15(cwd2, filePath);
108244
108175
  const displayPath = relPath.startsWith("..") ? filePath : relPath;
108245
108176
  if (t === "write" || t === "write_file" || t === "writefile" || t === "write_file_gemini" || t === "writefilegemini") {
108246
- const { existsSync: existsSync28 } = __require("node:fs");
108177
+ const { existsSync: existsSync27 } = __require("node:fs");
108247
108178
  try {
108248
- if (existsSync28(filePath)) {
108179
+ if (existsSync27(filePath)) {
108249
108180
  return `Overwrite ${displayPath}?`;
108250
108181
  }
108251
108182
  } catch {}
@@ -109022,9 +108953,9 @@ function getHeaderText(fileEdit) {
109022
108953
  const relPath = relative15(cwd2, fileEdit.filePath);
109023
108954
  const displayPath = relPath.startsWith("..") ? fileEdit.filePath : relPath;
109024
108955
  if (t === "write" || t === "write_file" || t === "writefile" || t === "write_file_gemini" || t === "writefilegemini") {
109025
- const { existsSync: existsSync28 } = __require("node:fs");
108956
+ const { existsSync: existsSync27 } = __require("node:fs");
109026
108957
  try {
109027
- if (existsSync28(fileEdit.filePath)) {
108958
+ if (existsSync27(fileEdit.filePath)) {
109028
108959
  return `Overwrite ${displayPath}?`;
109029
108960
  }
109030
108961
  } catch {}
@@ -111110,9 +111041,9 @@ html.dark .agent-name { color: var(--text-dim); }
111110
111041
  var init_plan_viewer_template = () => {};
111111
111042
 
111112
111043
  // src/web/generate-plan-viewer.ts
111113
- import { chmodSync as chmodSync2, existsSync as existsSync28, mkdirSync as mkdirSync20, writeFileSync as writeFileSync14 } from "node:fs";
111044
+ import { chmodSync as chmodSync2, existsSync as existsSync27, mkdirSync as mkdirSync20, writeFileSync as writeFileSync14 } from "node:fs";
111114
111045
  import { homedir as homedir30 } from "node:os";
111115
- import { join as join37 } from "node:path";
111046
+ import { join as join36 } from "node:path";
111116
111047
  async function generateAndOpenPlanViewer(planContent, planFilePath, options) {
111117
111048
  const data = {
111118
111049
  agent: { name: options?.agentName ?? "" },
@@ -111122,13 +111053,13 @@ async function generateAndOpenPlanViewer(planContent, planFilePath, options) {
111122
111053
  };
111123
111054
  const jsonPayload = JSON.stringify(data).replace(/</g, "\\u003c");
111124
111055
  const html = plan_viewer_template_default.replace("<!--LETTA_PLAN_DATA_PLACEHOLDER-->", () => jsonPayload);
111125
- if (!existsSync28(VIEWERS_DIR)) {
111056
+ if (!existsSync27(VIEWERS_DIR)) {
111126
111057
  mkdirSync20(VIEWERS_DIR, { recursive: true, mode: 448 });
111127
111058
  }
111128
111059
  try {
111129
111060
  chmodSync2(VIEWERS_DIR, 448);
111130
111061
  } catch {}
111131
- const filePath = join37(VIEWERS_DIR, "plan.html");
111062
+ const filePath = join36(VIEWERS_DIR, "plan.html");
111132
111063
  writeFileSync14(filePath, html);
111133
111064
  chmodSync2(filePath, 384);
111134
111065
  const skipOpen = Boolean(process.env.TMUX) || Boolean(process.env.SSH_CONNECTION) || Boolean(process.env.SSH_TTY);
@@ -111145,7 +111076,7 @@ async function generateAndOpenPlanViewer(planContent, planFilePath, options) {
111145
111076
  var VIEWERS_DIR;
111146
111077
  var init_generate_plan_viewer = __esm(() => {
111147
111078
  init_plan_viewer_template();
111148
- VIEWERS_DIR = join37(homedir30(), ".letta", "viewers");
111079
+ VIEWERS_DIR = join36(homedir30(), ".letta", "viewers");
111149
111080
  });
111150
111081
 
111151
111082
  // src/cli/components/StaticPlanApproval.tsx
@@ -113383,9 +113314,9 @@ var init_pasteRegistry = __esm(() => {
113383
113314
 
113384
113315
  // src/cli/helpers/clipboard.ts
113385
113316
  import { execFileSync as execFileSync3 } from "node:child_process";
113386
- import { existsSync as existsSync29, readFileSync as readFileSync16, statSync as statSync10, unlinkSync as unlinkSync10 } from "node:fs";
113317
+ import { existsSync as existsSync28, readFileSync as readFileSync15, statSync as statSync10, unlinkSync as unlinkSync10 } from "node:fs";
113387
113318
  import { tmpdir as tmpdir4 } from "node:os";
113388
- import { basename as basename5, extname as extname5, isAbsolute as isAbsolute19, join as join38, resolve as resolve27 } from "node:path";
113319
+ import { basename as basename5, extname as extname5, isAbsolute as isAbsolute19, join as join37, resolve as resolve27 } from "node:path";
113389
113320
  function countLines2(text) {
113390
113321
  return (text.match(/\r\n|\r|\n/g) || []).length + 1;
113391
113322
  }
@@ -113435,8 +113366,8 @@ function translatePasteForImages(paste) {
113435
113366
  if (!isAbsolute19(filePath))
113436
113367
  filePath = resolve27(process.cwd(), filePath);
113437
113368
  const ext3 = extname5(filePath || "").toLowerCase();
113438
- if (IMAGE_EXTS.has(ext3) && existsSync29(filePath) && statSync10(filePath).isFile()) {
113439
- const buf = readFileSync16(filePath);
113369
+ if (IMAGE_EXTS.has(ext3) && existsSync28(filePath) && statSync10(filePath).isFile()) {
113370
+ const buf = readFileSync15(filePath);
113440
113371
  const b64 = buf.toString("base64");
113441
113372
  const mt = ext3 === ".png" ? "image/png" : ext3 === ".jpg" || ext3 === ".jpeg" ? "image/jpeg" : ext3 === ".gif" ? "image/gif" : ext3 === ".webp" ? "image/webp" : ext3 === ".bmp" ? "image/bmp" : ext3 === ".svg" ? "image/svg+xml" : ext3 === ".tif" || ext3 === ".tiff" ? "image/tiff" : ext3 === ".heic" ? "image/heic" : ext3 === ".heif" ? "image/heif" : ext3 === ".avif" ? "image/avif" : "application/octet-stream";
113442
113373
  const id = allocateImage({
@@ -113453,7 +113384,7 @@ function translatePasteForImages(paste) {
113453
113384
  function getClipboardImageToTempFile() {
113454
113385
  if (process.platform !== "darwin")
113455
113386
  return null;
113456
- const tempPath = join38(tmpdir4(), `letta-clipboard-${Date.now()}.bin`);
113387
+ const tempPath = join37(tmpdir4(), `letta-clipboard-${Date.now()}.bin`);
113457
113388
  try {
113458
113389
  const jxa = `
113459
113390
  ObjC.import('AppKit');
@@ -113476,11 +113407,11 @@ function getClipboardImageToTempFile() {
113476
113407
  encoding: "utf8",
113477
113408
  stdio: ["ignore", "pipe", "ignore"]
113478
113409
  }).trim();
113479
- if (!uti || !existsSync29(tempPath))
113410
+ if (!uti || !existsSync28(tempPath))
113480
113411
  return null;
113481
113412
  return { tempPath, uti };
113482
113413
  } catch {
113483
- if (existsSync29(tempPath)) {
113414
+ if (existsSync28(tempPath)) {
113484
113415
  try {
113485
113416
  unlinkSync10(tempPath);
113486
113417
  } catch {}
@@ -113496,7 +113427,7 @@ async function tryImportClipboardImageMac() {
113496
113427
  return null;
113497
113428
  const { tempPath, uti } = clipboardResult;
113498
113429
  try {
113499
- const buffer = readFileSync16(tempPath);
113430
+ const buffer = readFileSync15(tempPath);
113500
113431
  try {
113501
113432
  unlinkSync10(tempPath);
113502
113433
  } catch {}
@@ -113513,7 +113444,7 @@ async function tryImportClipboardImageMac() {
113513
113444
  height: resized.height
113514
113445
  };
113515
113446
  } catch (err) {
113516
- if (existsSync29(tempPath)) {
113447
+ if (existsSync28(tempPath)) {
113517
113448
  try {
113518
113449
  unlinkSync10(tempPath);
113519
113450
  } catch {}
@@ -114203,13 +114134,13 @@ __export(exports_terminalKeybindingInstaller, {
114203
114134
  });
114204
114135
  import {
114205
114136
  copyFileSync,
114206
- existsSync as existsSync30,
114137
+ existsSync as existsSync29,
114207
114138
  mkdirSync as mkdirSync21,
114208
- readFileSync as readFileSync17,
114139
+ readFileSync as readFileSync16,
114209
114140
  writeFileSync as writeFileSync15
114210
114141
  } from "node:fs";
114211
114142
  import { homedir as homedir31, platform as platform5 } from "node:os";
114212
- import { dirname as dirname16, join as join39 } from "node:path";
114143
+ import { dirname as dirname16, join as join38 } from "node:path";
114213
114144
  function detectTerminalType() {
114214
114145
  if (process.env.CURSOR_TRACE_ID || process.env.CURSOR_CHANNEL) {
114215
114146
  return "cursor";
@@ -114241,16 +114172,16 @@ function getKeybindingsPath(terminal) {
114241
114172
  }[terminal];
114242
114173
  const os7 = platform5();
114243
114174
  if (os7 === "darwin") {
114244
- return join39(homedir31(), "Library", "Application Support", appName, "User", "keybindings.json");
114175
+ return join38(homedir31(), "Library", "Application Support", appName, "User", "keybindings.json");
114245
114176
  }
114246
114177
  if (os7 === "win32") {
114247
114178
  const appData = process.env.APPDATA;
114248
114179
  if (!appData)
114249
114180
  return null;
114250
- return join39(appData, appName, "User", "keybindings.json");
114181
+ return join38(appData, appName, "User", "keybindings.json");
114251
114182
  }
114252
114183
  if (os7 === "linux") {
114253
- return join39(homedir31(), ".config", appName, "User", "keybindings.json");
114184
+ return join38(homedir31(), ".config", appName, "User", "keybindings.json");
114254
114185
  }
114255
114186
  return null;
114256
114187
  }
@@ -114272,10 +114203,10 @@ function parseKeybindings(content) {
114272
114203
  }
114273
114204
  }
114274
114205
  function keybindingExists(keybindingsPath) {
114275
- if (!existsSync30(keybindingsPath))
114206
+ if (!existsSync29(keybindingsPath))
114276
114207
  return false;
114277
114208
  try {
114278
- const content = readFileSync17(keybindingsPath, { encoding: "utf-8" });
114209
+ const content = readFileSync16(keybindingsPath, { encoding: "utf-8" });
114279
114210
  const keybindings = parseKeybindings(content);
114280
114211
  if (!keybindings)
114281
114212
  return false;
@@ -114285,7 +114216,7 @@ function keybindingExists(keybindingsPath) {
114285
114216
  }
114286
114217
  }
114287
114218
  function createBackup(keybindingsPath) {
114288
- if (!existsSync30(keybindingsPath))
114219
+ if (!existsSync29(keybindingsPath))
114289
114220
  return null;
114290
114221
  const backupPath = `${keybindingsPath}.letta-backup`;
114291
114222
  try {
@@ -114301,14 +114232,14 @@ function installKeybinding(keybindingsPath) {
114301
114232
  return { success: true, alreadyExists: true };
114302
114233
  }
114303
114234
  const parentDir = dirname16(keybindingsPath);
114304
- if (!existsSync30(parentDir)) {
114235
+ if (!existsSync29(parentDir)) {
114305
114236
  mkdirSync21(parentDir, { recursive: true });
114306
114237
  }
114307
114238
  let keybindings = [];
114308
114239
  let backupPath = null;
114309
- if (existsSync30(keybindingsPath)) {
114240
+ if (existsSync29(keybindingsPath)) {
114310
114241
  backupPath = createBackup(keybindingsPath);
114311
- const content = readFileSync17(keybindingsPath, { encoding: "utf-8" });
114242
+ const content = readFileSync16(keybindingsPath, { encoding: "utf-8" });
114312
114243
  const parsed = parseKeybindings(content);
114313
114244
  if (parsed === null) {
114314
114245
  return {
@@ -114336,10 +114267,10 @@ function installKeybinding(keybindingsPath) {
114336
114267
  }
114337
114268
  function removeKeybinding(keybindingsPath) {
114338
114269
  try {
114339
- if (!existsSync30(keybindingsPath)) {
114270
+ if (!existsSync29(keybindingsPath)) {
114340
114271
  return { success: true };
114341
114272
  }
114342
- const content = readFileSync17(keybindingsPath, { encoding: "utf-8" });
114273
+ const content = readFileSync16(keybindingsPath, { encoding: "utf-8" });
114343
114274
  const keybindings = parseKeybindings(content);
114344
114275
  if (!keybindings) {
114345
114276
  return {
@@ -114403,20 +114334,20 @@ function getWezTermConfigPath() {
114403
114334
  }
114404
114335
  const xdgConfig = process.env.XDG_CONFIG_HOME;
114405
114336
  if (xdgConfig) {
114406
- const xdgPath = join39(xdgConfig, "wezterm", "wezterm.lua");
114407
- if (existsSync30(xdgPath))
114337
+ const xdgPath = join38(xdgConfig, "wezterm", "wezterm.lua");
114338
+ if (existsSync29(xdgPath))
114408
114339
  return xdgPath;
114409
114340
  }
114410
- const configPath = join39(homedir31(), ".config", "wezterm", "wezterm.lua");
114411
- if (existsSync30(configPath))
114341
+ const configPath = join38(homedir31(), ".config", "wezterm", "wezterm.lua");
114342
+ if (existsSync29(configPath))
114412
114343
  return configPath;
114413
- return join39(homedir31(), ".wezterm.lua");
114344
+ return join38(homedir31(), ".wezterm.lua");
114414
114345
  }
114415
114346
  function wezTermDeleteFixExists(configPath) {
114416
- if (!existsSync30(configPath))
114347
+ if (!existsSync29(configPath))
114417
114348
  return false;
114418
114349
  try {
114419
- const content = readFileSync17(configPath, { encoding: "utf-8" });
114350
+ const content = readFileSync16(configPath, { encoding: "utf-8" });
114420
114351
  return content.includes("Letta Code: Fix Delete key") || content.includes("key = 'Delete'") && content.includes("SendString") && content.includes("\\x1b[3~");
114421
114352
  } catch {
114422
114353
  return false;
@@ -114430,10 +114361,10 @@ function installWezTermDeleteFix() {
114430
114361
  }
114431
114362
  let content = "";
114432
114363
  let backupPath = null;
114433
- if (existsSync30(configPath)) {
114364
+ if (existsSync29(configPath)) {
114434
114365
  backupPath = `${configPath}.letta-backup`;
114435
114366
  copyFileSync(configPath, backupPath);
114436
- content = readFileSync17(configPath, { encoding: "utf-8" });
114367
+ content = readFileSync16(configPath, { encoding: "utf-8" });
114437
114368
  }
114438
114369
  if (content.includes("return {") && !content.includes("local config")) {
114439
114370
  content = content.replace(/return\s*\{/, "local config = {");
@@ -114460,7 +114391,7 @@ ${WEZTERM_DELETE_FIX}
114460
114391
  `;
114461
114392
  }
114462
114393
  const parentDir = dirname16(configPath);
114463
- if (!existsSync30(parentDir)) {
114394
+ if (!existsSync29(parentDir)) {
114464
114395
  mkdirSync21(parentDir, { recursive: true });
114465
114396
  }
114466
114397
  writeFileSync15(configPath, content, { encoding: "utf-8" });
@@ -115040,9 +114971,9 @@ __export(exports_custom, {
115040
114971
  GLOBAL_COMMANDS_DIR: () => GLOBAL_COMMANDS_DIR,
115041
114972
  COMMANDS_DIR: () => COMMANDS_DIR
115042
114973
  });
115043
- import { existsSync as existsSync31 } from "node:fs";
114974
+ import { existsSync as existsSync30 } from "node:fs";
115044
114975
  import { readdir as readdir9, readFile as readFile11 } from "node:fs/promises";
115045
- import { basename as basename6, dirname as dirname17, join as join40 } from "node:path";
114976
+ import { basename as basename6, dirname as dirname17, join as join39 } from "node:path";
115046
114977
  async function getCustomCommands() {
115047
114978
  if (cachedCommands !== null) {
115048
114979
  return cachedCommands;
@@ -115053,7 +114984,7 @@ async function getCustomCommands() {
115053
114984
  function refreshCustomCommands() {
115054
114985
  cachedCommands = null;
115055
114986
  }
115056
- async function discoverCustomCommands(projectPath = join40(process.cwd(), COMMANDS_DIR)) {
114987
+ async function discoverCustomCommands(projectPath = join39(process.cwd(), COMMANDS_DIR)) {
115057
114988
  const commandsById = new Map;
115058
114989
  const userCommands = await discoverFromDirectory(GLOBAL_COMMANDS_DIR, "user");
115059
114990
  for (const cmd of userCommands) {
@@ -115074,7 +115005,7 @@ async function discoverCustomCommands(projectPath = join40(process.cwd(), COMMAN
115074
115005
  return result;
115075
115006
  }
115076
115007
  async function discoverFromDirectory(dirPath, source2) {
115077
- if (!existsSync31(dirPath)) {
115008
+ if (!existsSync30(dirPath)) {
115078
115009
  return [];
115079
115010
  }
115080
115011
  const commands2 = [];
@@ -115085,7 +115016,7 @@ async function findCommandFiles(currentPath, rootPath, commands2, source2) {
115085
115016
  try {
115086
115017
  const entries = await readdir9(currentPath, { withFileTypes: true });
115087
115018
  for (const entry of entries) {
115088
- const fullPath = join40(currentPath, entry.name);
115019
+ const fullPath = join39(currentPath, entry.name);
115089
115020
  if (entry.isDirectory()) {
115090
115021
  await findCommandFiles(fullPath, rootPath, commands2, source2);
115091
115022
  } else if (entry.isFile() && entry.name.endsWith(".md")) {
@@ -115170,7 +115101,7 @@ async function findCustomCommand(commandName) {
115170
115101
  }
115171
115102
  var COMMANDS_DIR = ".commands", GLOBAL_COMMANDS_DIR, cachedCommands = null;
115172
115103
  var init_custom = __esm(() => {
115173
- GLOBAL_COMMANDS_DIR = join40(process.env.HOME || process.env.USERPROFILE || "~", ".letta/commands");
115104
+ GLOBAL_COMMANDS_DIR = join39(process.env.HOME || process.env.USERPROFILE || "~", ".letta/commands");
115174
115105
  });
115175
115106
 
115176
115107
  // src/cli/components/HelpDialog.tsx
@@ -118093,17 +118024,17 @@ var init_AgentInfoBar = __esm(async () => {
118093
118024
  });
118094
118025
 
118095
118026
  // src/cli/helpers/fileSearch.ts
118096
- import { readdirSync as readdirSync13, statSync as statSync11 } from "node:fs";
118097
- import { join as join41, relative as relative15, resolve as resolve29 } from "node:path";
118027
+ import { readdirSync as readdirSync12, statSync as statSync11 } from "node:fs";
118028
+ import { join as join40, relative as relative15, resolve as resolve29 } from "node:path";
118098
118029
  function searchDirectoryRecursive(dir, pattern, maxResults = 200, results = [], depth = 0, maxDepth = 10, lowerPattern = pattern.toLowerCase()) {
118099
118030
  if (results.length >= maxResults || depth >= maxDepth) {
118100
118031
  return results;
118101
118032
  }
118102
118033
  try {
118103
- const entries = readdirSync13(dir);
118034
+ const entries = readdirSync12(dir);
118104
118035
  for (const entry of entries) {
118105
118036
  try {
118106
- const fullPath = join41(dir, entry);
118037
+ const fullPath = join40(dir, entry);
118107
118038
  const relativePath = relative15(getIndexRoot(), fullPath);
118108
118039
  if (shouldHardExcludeEntry(entry, getIndexRoot())) {
118109
118040
  continue;
@@ -118173,7 +118104,7 @@ async function searchFiles(query, deep = false) {
118173
118104
  } else {
118174
118105
  let entries = [];
118175
118106
  try {
118176
- entries = readdirSync13(searchDir);
118107
+ entries = readdirSync12(searchDir);
118177
118108
  } catch {
118178
118109
  return [];
118179
118110
  }
@@ -118181,7 +118112,7 @@ async function searchFiles(query, deep = false) {
118181
118112
  const matchingEntries = entries.filter((entry) => !shouldHardExcludeEntry(entry, getIndexRoot()) && (searchPattern.length === 0 || entry.toLowerCase().includes(lowerPattern)));
118182
118113
  for (const entry of matchingEntries.slice(0, 50)) {
118183
118114
  try {
118184
- const fullPath = join41(searchDir, entry);
118115
+ const fullPath = join40(searchDir, entry);
118185
118116
  const stats = statSync11(fullPath);
118186
118117
  const relativePath = relative15(getIndexRoot(), fullPath);
118187
118118
  results.push({
@@ -120257,15 +120188,15 @@ var init_InputRich = __esm(async () => {
120257
120188
  // src/cli/commands/install-github-app.ts
120258
120189
  import { execFileSync as execFileSync4 } from "node:child_process";
120259
120190
  import {
120260
- existsSync as existsSync32,
120191
+ existsSync as existsSync31,
120261
120192
  mkdirSync as mkdirSync22,
120262
120193
  mkdtempSync,
120263
- readFileSync as readFileSync18,
120194
+ readFileSync as readFileSync17,
120264
120195
  rmSync as rmSync4,
120265
120196
  writeFileSync as writeFileSync16
120266
120197
  } from "node:fs";
120267
120198
  import { tmpdir as tmpdir5 } from "node:os";
120268
- import { dirname as dirname18, join as join42 } from "node:path";
120199
+ import { dirname as dirname18, join as join41 } from "node:path";
120269
120200
  function runCommand(command, args, cwd2, input) {
120270
120201
  try {
120271
120202
  return execFileSync4(command, args, {
@@ -120499,8 +120430,8 @@ async function createLettaAgent(apiKey, name) {
120499
120430
  return { id: data.id, name: data.name };
120500
120431
  }
120501
120432
  function cloneRepoToTemp(repo) {
120502
- const tempDir = mkdtempSync(join42(tmpdir5(), "letta-install-github-app-"));
120503
- const repoDir = join42(tempDir, "repo");
120433
+ const tempDir = mkdtempSync(join41(tmpdir5(), "letta-install-github-app-"));
120434
+ const repoDir = join41(tempDir, "repo");
120504
120435
  runCommand("gh", ["repo", "clone", repo, repoDir, "--", "--depth=1"]);
120505
120436
  return { tempDir, repoDir };
120506
120437
  }
@@ -120511,14 +120442,14 @@ function runGit6(args, cwd2) {
120511
120442
  return runCommand("git", args, cwd2);
120512
120443
  }
120513
120444
  function writeWorkflow(repoDir, workflowPath, content) {
120514
- const absolutePath = join42(repoDir, workflowPath);
120515
- if (!existsSync32(dirname18(absolutePath))) {
120445
+ const absolutePath = join41(repoDir, workflowPath);
120446
+ if (!existsSync31(dirname18(absolutePath))) {
120516
120447
  mkdirSync22(dirname18(absolutePath), { recursive: true });
120517
120448
  }
120518
120449
  const next = `${content.trimEnd()}
120519
120450
  `;
120520
- if (existsSync32(absolutePath)) {
120521
- const previous = readFileSync18(absolutePath, "utf8");
120451
+ if (existsSync31(absolutePath)) {
120452
+ const previous = readFileSync17(absolutePath, "utf8");
120522
120453
  if (previous === next) {
120523
120454
  return false;
120524
120455
  }
@@ -124418,9 +124349,9 @@ __export(exports_generate_memory_viewer, {
124418
124349
  generateAndOpenMemoryViewer: () => generateAndOpenMemoryViewer
124419
124350
  });
124420
124351
  import { execFile as execFileCb5 } from "node:child_process";
124421
- import { chmodSync as chmodSync3, existsSync as existsSync33, mkdirSync as mkdirSync23, writeFileSync as writeFileSync17 } from "node:fs";
124352
+ import { chmodSync as chmodSync3, existsSync as existsSync32, mkdirSync as mkdirSync23, writeFileSync as writeFileSync17 } from "node:fs";
124422
124353
  import { homedir as homedir33 } from "node:os";
124423
- import { join as join43 } from "node:path";
124354
+ import { join as join42 } from "node:path";
124424
124355
  import { promisify as promisify14 } from "node:util";
124425
124356
  async function runGitSafe(cwd2, args) {
124426
124357
  try {
@@ -124703,13 +124634,13 @@ async function generateAndOpenMemoryViewer(agentId, options) {
124703
124634
  }
124704
124635
  const jsonPayload = JSON.stringify(data).replace(/</g, "\\u003c");
124705
124636
  const html = memory_viewer_template_default.replace("<!--LETTA_DATA_PLACEHOLDER-->", () => jsonPayload);
124706
- if (!existsSync33(VIEWERS_DIR2)) {
124637
+ if (!existsSync32(VIEWERS_DIR2)) {
124707
124638
  mkdirSync23(VIEWERS_DIR2, { recursive: true, mode: 448 });
124708
124639
  }
124709
124640
  try {
124710
124641
  chmodSync3(VIEWERS_DIR2, 448);
124711
124642
  } catch {}
124712
- const filePath = join43(VIEWERS_DIR2, `memory-${encodeURIComponent(agentId)}.html`);
124643
+ const filePath = join42(VIEWERS_DIR2, `memory-${encodeURIComponent(agentId)}.html`);
124713
124644
  writeFileSync17(filePath, html);
124714
124645
  chmodSync3(filePath, 384);
124715
124646
  const skipOpen = Boolean(process.env.TMUX) || Boolean(process.env.SSH_CONNECTION) || Boolean(process.env.SSH_TTY);
@@ -124733,12 +124664,12 @@ var init_generate_memory_viewer = __esm(async () => {
124733
124664
  init_memoryGit()
124734
124665
  ]);
124735
124666
  execFile14 = promisify14(execFileCb5);
124736
- VIEWERS_DIR2 = join43(homedir33(), ".letta", "viewers");
124667
+ VIEWERS_DIR2 = join42(homedir33(), ".letta", "viewers");
124737
124668
  REFLECTION_PATTERN = /\(reflection\)|🔮|reflection:/i;
124738
124669
  });
124739
124670
 
124740
124671
  // src/cli/components/MemfsTreeViewer.tsx
124741
- import { existsSync as existsSync34 } from "node:fs";
124672
+ import { existsSync as existsSync33 } from "node:fs";
124742
124673
  function renderTreePrefix(node) {
124743
124674
  let prefix = "";
124744
124675
  for (let i = 0;i < node.depth; i++) {
@@ -124764,7 +124695,7 @@ function MemfsTreeViewer({
124764
124695
  const [status, setStatus] = import_react78.useState(null);
124765
124696
  const statusTimerRef = import_react78.useRef(null);
124766
124697
  const memoryRoot = getMemoryFilesystemRoot(agentId);
124767
- const memoryExists = existsSync34(memoryRoot);
124698
+ const memoryExists = existsSync33(memoryRoot);
124768
124699
  const hasGitRepo = import_react78.useMemo(() => isGitRepo(agentId), [agentId]);
124769
124700
  function showStatus(msg, durationMs) {
124770
124701
  if (statusTimerRef.current)
@@ -127452,10 +127383,10 @@ var init_PersonalitySelector = __esm(async () => {
127452
127383
  // src/utils/aws-credentials.ts
127453
127384
  import { readFile as readFile12 } from "node:fs/promises";
127454
127385
  import { homedir as homedir34 } from "node:os";
127455
- import { join as join44 } from "node:path";
127386
+ import { join as join43 } from "node:path";
127456
127387
  async function parseAwsCredentials() {
127457
- const credentialsPath = join44(homedir34(), ".aws", "credentials");
127458
- const configPath = join44(homedir34(), ".aws", "config");
127388
+ const credentialsPath = join43(homedir34(), ".aws", "credentials");
127389
+ const configPath = join43(homedir34(), ".aws", "config");
127459
127390
  const profiles = new Map;
127460
127391
  try {
127461
127392
  const content = await readFile12(credentialsPath, "utf-8");
@@ -128563,8 +128494,8 @@ function SkillsDialog({ onClose, agentId }) {
128563
128494
  try {
128564
128495
  const { discoverSkills: discoverSkills3, SKILLS_DIR: SKILLS_DIR3 } = await Promise.resolve().then(() => (init_skills(), exports_skills));
128565
128496
  const { getSkillsDirectory: getSkillsDirectory2, getSkillSources: getSkillSources2 } = await Promise.resolve().then(() => (init_context(), exports_context));
128566
- const { join: join45 } = await import("node:path");
128567
- const skillsDir = getSkillsDirectory2() || join45(process.cwd(), SKILLS_DIR3);
128497
+ const { join: join44 } = await import("node:path");
128498
+ const skillsDir = getSkillsDirectory2() || join44(process.cwd(), SKILLS_DIR3);
128568
128499
  const result = await discoverSkills3(skillsDir, agentId, {
128569
128500
  sources: getSkillSources2()
128570
128501
  });
@@ -132555,27 +132486,27 @@ var init_reasoningTabToggle = __esm(() => {
132555
132486
  });
132556
132487
 
132557
132488
  // src/cli/helpers/startupSystemPromptWarning.ts
132558
- import { existsSync as existsSync35, readdirSync as readdirSync14, readFileSync as readFileSync19 } from "node:fs";
132559
- import { join as join45 } from "node:path";
132489
+ import { existsSync as existsSync34, readdirSync as readdirSync13, readFileSync as readFileSync18 } from "node:fs";
132490
+ import { join as join44 } from "node:path";
132560
132491
  function estimateSystemTokens(text) {
132561
132492
  return Math.ceil(Buffer.byteLength(text, "utf8") / STARTUP_SYSTEM_PROMPT_ESTIMATED_BYTES_PER_TOKEN);
132562
132493
  }
132563
132494
  function estimateSystemPromptTokensFromMemoryDir(memoryDir) {
132564
- const systemDir = join45(memoryDir, "system");
132565
- if (!existsSync35(systemDir)) {
132495
+ const systemDir = join44(memoryDir, "system");
132496
+ if (!existsSync34(systemDir)) {
132566
132497
  return 0;
132567
132498
  }
132568
132499
  const walkMarkdownFiles = (dir) => {
132569
- if (!existsSync35(dir)) {
132500
+ if (!existsSync34(dir)) {
132570
132501
  return [];
132571
132502
  }
132572
132503
  const out = [];
132573
- const entries = readdirSync14(dir, { withFileTypes: true });
132504
+ const entries = readdirSync13(dir, { withFileTypes: true });
132574
132505
  for (const entry of entries) {
132575
132506
  if (entry.name.startsWith(".")) {
132576
132507
  continue;
132577
132508
  }
132578
- const full = join45(dir, entry.name);
132509
+ const full = join44(dir, entry.name);
132579
132510
  if (entry.isDirectory()) {
132580
132511
  if (entry.name === ".git") {
132581
132512
  continue;
@@ -132590,7 +132521,7 @@ function estimateSystemPromptTokensFromMemoryDir(memoryDir) {
132590
132521
  return out;
132591
132522
  };
132592
132523
  return walkMarkdownFiles(systemDir).sort().reduce((sum, filePath) => {
132593
- const text = readFileSync19(filePath, "utf8");
132524
+ const text = readFileSync18(filePath, "utf8");
132594
132525
  return sum + estimateSystemTokens(text);
132595
132526
  }, 0);
132596
132527
  }
@@ -133394,16 +133325,16 @@ __export(exports_shellAliases, {
133394
133325
  expandAliases: () => expandAliases,
133395
133326
  clearAliasCache: () => clearAliasCache
133396
133327
  });
133397
- import { existsSync as existsSync36, readFileSync as readFileSync20 } from "node:fs";
133328
+ import { existsSync as existsSync35, readFileSync as readFileSync19 } from "node:fs";
133398
133329
  import { homedir as homedir35 } from "node:os";
133399
- import { join as join46 } from "node:path";
133330
+ import { join as join45 } from "node:path";
133400
133331
  function parseAliasesFromFile(filePath) {
133401
133332
  const aliases = new Map;
133402
- if (!existsSync36(filePath)) {
133333
+ if (!existsSync35(filePath)) {
133403
133334
  return aliases;
133404
133335
  }
133405
133336
  try {
133406
- const content = readFileSync20(filePath, "utf-8");
133337
+ const content = readFileSync19(filePath, "utf-8");
133407
133338
  const lines = content.split(`
133408
133339
  `);
133409
133340
  let inFunction = false;
@@ -133468,7 +133399,7 @@ function loadAliases(forceReload = false) {
133468
133399
  const home = homedir35();
133469
133400
  const allAliases = new Map;
133470
133401
  for (const file of ALIAS_FILES) {
133471
- const filePath = join46(home, file);
133402
+ const filePath = join45(home, file);
133472
133403
  const fileAliases = parseAliasesFromFile(filePath);
133473
133404
  for (const [name, value] of fileAliases) {
133474
133405
  allAliases.set(name, value);
@@ -134318,9 +134249,9 @@ __export(exports_App, {
134318
134249
  default: () => App2
134319
134250
  });
134320
134251
  import { randomUUID as randomUUID9 } from "node:crypto";
134321
- import { existsSync as existsSync37, readFileSync as readFileSync21, renameSync as renameSync3, writeFileSync as writeFileSync18 } from "node:fs";
134252
+ import { existsSync as existsSync36, readFileSync as readFileSync20, renameSync as renameSync3, writeFileSync as writeFileSync18 } from "node:fs";
134322
134253
  import { homedir as homedir36, tmpdir as tmpdir6 } from "node:os";
134323
- import { join as join47, relative as relative17 } from "node:path";
134254
+ import { join as join46, relative as relative17 } from "node:path";
134324
134255
  function deriveReasoningEffort(modelSettings, llmConfig) {
134325
134256
  if (modelSettings && "provider_type" in modelSettings) {
134326
134257
  if (modelSettings.provider_type === "openai" && "reasoning" in modelSettings && modelSettings.reasoning) {
@@ -134572,18 +134503,18 @@ function saveLastSessionBeforeExit(conversationId) {
134572
134503
  }
134573
134504
  function planFileExists(fallbackPlanFilePath) {
134574
134505
  const planFilePath = permissionMode.getPlanFilePath() ?? fallbackPlanFilePath;
134575
- return !!planFilePath && existsSync37(planFilePath);
134506
+ return !!planFilePath && existsSync36(planFilePath);
134576
134507
  }
134577
134508
  function _readPlanFile(fallbackPlanFilePath) {
134578
134509
  const planFilePath = permissionMode.getPlanFilePath() ?? fallbackPlanFilePath;
134579
134510
  if (!planFilePath) {
134580
134511
  return "No plan file path set.";
134581
134512
  }
134582
- if (!existsSync37(planFilePath)) {
134513
+ if (!existsSync36(planFilePath)) {
134583
134514
  return `Plan file not found at ${planFilePath}`;
134584
134515
  }
134585
134516
  try {
134586
- return readFileSync21(planFilePath, "utf-8");
134517
+ return readFileSync20(planFilePath, "utf-8");
134587
134518
  } catch {
134588
134519
  return `Failed to read plan file at ${planFilePath}`;
134589
134520
  }
@@ -134729,8 +134660,6 @@ function App2({
134729
134660
  const lastRunIdRef = import_react103.useRef(null);
134730
134661
  const resumeKey = useSuspend();
134731
134662
  const pendingConversationSwitchRef = import_react103.useRef(null);
134732
- const autoInitPendingAgentIdsRef = import_react103.useRef(new Set);
134733
- const startupAutoInitConsumedRef = import_react103.useRef(false);
134734
134663
  const prevInitialAgentIdRef = import_react103.useRef(initialAgentId);
134735
134664
  const prevInitialAgentStateRef = import_react103.useRef(initialAgentState);
134736
134665
  const prevInitialConversationIdRef = import_react103.useRef(initialConversationId);
@@ -135912,10 +135841,10 @@ function App2({
135912
135841
  if (!planFilePath)
135913
135842
  return;
135914
135843
  try {
135915
- const { readFileSync: readFileSync22, existsSync: existsSync38 } = __require("node:fs");
135916
- if (!existsSync38(planFilePath))
135844
+ const { readFileSync: readFileSync21, existsSync: existsSync37 } = __require("node:fs");
135845
+ if (!existsSync37(planFilePath))
135917
135846
  return;
135918
- const planContent = readFileSync22(planFilePath, "utf-8");
135847
+ const planContent = readFileSync21(planFilePath, "utf-8");
135919
135848
  const previewItem = {
135920
135849
  kind: "approval_preview",
135921
135850
  id: `approval-preview-${toolCallId}`,
@@ -136327,9 +136256,9 @@ Memory may be stale. Try running: git -C ~/.letta/agents/${agentId}/memory pull`
136327
136256
  (async () => {
136328
136257
  try {
136329
136258
  const { watch } = await import("node:fs");
136330
- const { existsSync: existsSync38 } = await import("node:fs");
136259
+ const { existsSync: existsSync37 } = await import("node:fs");
136331
136260
  const memRoot = getMemoryFilesystemRoot(agentId);
136332
- if (!existsSync38(memRoot))
136261
+ if (!existsSync37(memRoot))
136333
136262
  return;
136334
136263
  watcher = watch(memRoot, { recursive: true }, () => {});
136335
136264
  memfsWatcherRef.current = watcher;
@@ -138275,14 +138204,11 @@ ${feedback}
138275
138204
  memoryPromptMode: willAutoEnableMemfs ? "memfs" : undefined
138276
138205
  });
138277
138206
  await enableMemfsIfCloud2(agent.id);
138278
- if (settingsManager.isMemfsEnabled(agent.id)) {
138279
- autoInitPendingAgentIdsRef.current.add(agent.id);
138280
- }
138281
138207
  await updateProjectSettings({ lastAgent: agent.id });
138282
138208
  const targetConversationId = "default";
138283
138209
  settingsManager.persistSession(agent.id, targetConversationId);
138284
138210
  const agentUrl = buildChatUrl(agent.id);
138285
- const memfsTip = settingsManager.isMemfsEnabled(agent.id) ? "Memory will be auto-initialized on your first message." : "Tip: use /init to initialize your agent's memory system!";
138211
+ const memfsTip = "Tip: use /init to initialize your agent's memory system!";
138286
138212
  const successOutput = [
138287
138213
  `Created **${agent.name || agent.id}** (use /pin to save)`,
138288
138214
  `⎿ ${agentUrl}`,
@@ -138725,12 +138651,12 @@ ${SYSTEM_REMINDER_CLOSE}` : "";
138725
138651
  try {
138726
138652
  const memoryRoot = getMemoryFilesystemRoot(agentId);
138727
138653
  const personaCandidates = [
138728
- join47(memoryRoot, "system", "persona.md"),
138729
- join47(memoryRoot, "memory", "system", "persona.md")
138654
+ join46(memoryRoot, "system", "persona.md"),
138655
+ join46(memoryRoot, "memory", "system", "persona.md")
138730
138656
  ];
138731
- const personaPath = personaCandidates.find((candidate) => existsSync37(candidate));
138657
+ const personaPath = personaCandidates.find((candidate) => existsSync36(candidate));
138732
138658
  if (personaPath) {
138733
- const personaContent = readFileSync21(personaPath, "utf-8");
138659
+ const personaContent = readFileSync20(personaPath, "utf-8");
138734
138660
  setCurrentPersonalityId(detectPersonalityFromPersonaFile(personaContent));
138735
138661
  } else {
138736
138662
  setCurrentPersonalityId(null);
@@ -140026,11 +139952,11 @@ Path: ${result2.memoryDir}`, true, msg);
140026
139952
  setCommandRunning(true);
140027
139953
  try {
140028
139954
  const memoryDir = getMemoryFilesystemRoot(agentId);
140029
- if (!existsSync37(memoryDir)) {
139955
+ if (!existsSync36(memoryDir)) {
140030
139956
  updateMemorySyncCommand(cmdId, "No local memory filesystem found to reset.", true, msg);
140031
139957
  return { submitted: true };
140032
139958
  }
140033
- const backupDir = join47(tmpdir6(), `letta-memfs-reset-${agentId}-${Date.now()}`);
139959
+ const backupDir = join46(tmpdir6(), `letta-memfs-reset-${agentId}-${Date.now()}`);
140034
139960
  renameSync3(memoryDir, backupDir);
140035
139961
  ensureMemoryFilesystemDirs(agentId);
140036
139962
  updateMemorySyncCommand(cmdId, `Memory filesystem reset.
@@ -140058,8 +139984,8 @@ Run \`/memfs sync\` to repopulate from API.`, true, msg);
140058
139984
  await removeGitMemoryTag2(agentId);
140059
139985
  let backupInfo = "";
140060
139986
  const memoryDir = getMemoryFilesystemRoot(agentId);
140061
- if (existsSync37(memoryDir)) {
140062
- const backupDir = join47(tmpdir6(), `letta-memfs-disable-${agentId}-${Date.now()}`);
139987
+ if (existsSync36(memoryDir)) {
139988
+ const backupDir = join46(tmpdir6(), `letta-memfs-disable-${agentId}-${Date.now()}`);
140063
139989
  renameSync3(memoryDir, backupDir);
140064
139990
  backupInfo = `
140065
139991
  Local files backed up to ${backupDir}`;
@@ -140229,7 +140155,6 @@ ${SYSTEM_REMINDER_CLOSE}`;
140229
140155
  cmd.fail("Pending approval(s). Resolve approvals before running /init.");
140230
140156
  return { submitted: false };
140231
140157
  }
140232
- autoInitPendingAgentIdsRef.current.delete(agentId);
140233
140158
  setCommandRunning(true);
140234
140159
  try {
140235
140160
  cmd.finish("Building your memory palace... Start a new conversation with `letta --new` to work in parallel.", true);
@@ -140420,28 +140345,6 @@ ${SYSTEM_REMINDER_CLOSE}`),
140420
140345
  return { submitted: true };
140421
140346
  }
140422
140347
  }
140423
- if (autoInitPendingAgentIdsRef.current.has(agentId) && !isSystemOnly) {
140424
- try {
140425
- const fired = await fireAutoInit(agentId, async ({ success, error }) => {
140426
- const msg2 = await handleMemorySubagentCompletion({
140427
- agentId,
140428
- conversationId: conversationIdRef.current,
140429
- subagentType: "init",
140430
- success,
140431
- error
140432
- }, {
140433
- recompileByConversation: systemPromptRecompileByConversationRef.current,
140434
- recompileQueuedByConversation: queuedSystemPromptRecompileByConversationRef.current,
140435
- logRecompileFailure: (message2) => debugWarn("memory", message2)
140436
- });
140437
- appendTaskNotificationEvents([msg2]);
140438
- });
140439
- if (fired) {
140440
- autoInitPendingAgentIdsRef.current.delete(agentId);
140441
- sharedReminderStateRef.current.pendingAutoInitReminder = true;
140442
- }
140443
- } catch {}
140444
- }
140445
140348
  const contentParts = overrideContentParts ?? buildMessageContentFromDisplay(msg);
140446
140349
  let ralphModeReminder = "";
140447
140350
  if (ralphMode.getState().isActive) {
@@ -142483,7 +142386,7 @@ ${guidance}`);
142483
142386
  }
142484
142387
  if (mode === "bypassPermissions") {
142485
142388
  const planFilePath = activePlanPath ?? fallbackPlanPath;
142486
- const plansDir = join47(homedir36(), ".letta", "plans");
142389
+ const plansDir = join46(homedir36(), ".letta", "plans");
142487
142390
  handlePlanKeepPlanning(`You must write your plan to a plan file before exiting plan mode.
142488
142391
  ` + (planFilePath ? `Plan file path: ${planFilePath}
142489
142392
  ` : "") + `Use a write tool to create your plan in ${plansDir}, then use ExitPlanMode to present the plan to the user.`);
@@ -142518,7 +142421,7 @@ ${guidance}`);
142518
142421
  if (!hasUsablePlan) {
142519
142422
  lastAutoHandledExitPlanToolCallIdRef.current = approval.toolCallId;
142520
142423
  const planFilePath = activePlanPath ?? fallbackPlanPath;
142521
- const plansDir = join47(homedir36(), ".letta", "plans");
142424
+ const plansDir = join46(homedir36(), ".letta", "plans");
142522
142425
  handlePlanKeepPlanning(`You must write your plan to a plan file before exiting plan mode.
142523
142426
  ` + (planFilePath ? `Plan file path: ${planFilePath}
142524
142427
  ` : "") + `Use a write tool to create your plan in ${plansDir}, then use ExitPlanMode to present the plan to the user.`);
@@ -142750,14 +142653,6 @@ If using apply_patch, use this exact relative patch path: ${applyPatchRelativePa
142750
142653
  return estimatedLiveHeight < resumeThreshold;
142751
142654
  });
142752
142655
  }, [estimatedLiveHeight, terminalRows]);
142753
- import_react103.useEffect(() => {
142754
- if (loadingState === "ready" && agentProvenance?.isNew && agentId && !startupAutoInitConsumedRef.current) {
142755
- startupAutoInitConsumedRef.current = true;
142756
- if (settingsManager.isMemfsEnabled(agentId)) {
142757
- autoInitPendingAgentIdsRef.current.add(agentId);
142758
- }
142759
- }
142760
- }, [loadingState, agentProvenance, agentId]);
142761
142656
  import_react103.useEffect(() => {
142762
142657
  if (loadingState === "ready" && !welcomeCommittedRef.current && messageHistory.length === 0) {
142763
142658
  if (!continueSession && !agentProvenance) {
@@ -143750,6 +143645,7 @@ var init_App2 = __esm(async () => {
143750
143645
  init_diff2();
143751
143646
  init_errorContext();
143752
143647
  init_errorFormatter();
143648
+ init_initCommand();
143753
143649
  init_messageQueueBridge();
143754
143650
  init_pasteRegistry();
143755
143651
  init_planName();
@@ -143827,7 +143723,6 @@ var init_App2 = __esm(async () => {
143827
143723
  init_accumulator(),
143828
143724
  init_approvalClassification(),
143829
143725
  init_formatArgsDisplay(),
143830
- init_initCommand(),
143831
143726
  init_memoryReminder(),
143832
143727
  init_memorySubagentCompletion(),
143833
143728
  init_reflectionTranscript(),
@@ -143925,13 +143820,13 @@ __export(exports_terminalKeybindingInstaller2, {
143925
143820
  });
143926
143821
  import {
143927
143822
  copyFileSync as copyFileSync2,
143928
- existsSync as existsSync38,
143823
+ existsSync as existsSync37,
143929
143824
  mkdirSync as mkdirSync24,
143930
- readFileSync as readFileSync22,
143825
+ readFileSync as readFileSync21,
143931
143826
  writeFileSync as writeFileSync19
143932
143827
  } from "node:fs";
143933
143828
  import { homedir as homedir37, platform as platform6 } from "node:os";
143934
- import { dirname as dirname19, join as join48 } from "node:path";
143829
+ import { dirname as dirname19, join as join47 } from "node:path";
143935
143830
  function detectTerminalType2() {
143936
143831
  if (process.env.CURSOR_TRACE_ID || process.env.CURSOR_CHANNEL) {
143937
143832
  return "cursor";
@@ -143963,16 +143858,16 @@ function getKeybindingsPath2(terminal) {
143963
143858
  }[terminal];
143964
143859
  const os8 = platform6();
143965
143860
  if (os8 === "darwin") {
143966
- return join48(homedir37(), "Library", "Application Support", appName, "User", "keybindings.json");
143861
+ return join47(homedir37(), "Library", "Application Support", appName, "User", "keybindings.json");
143967
143862
  }
143968
143863
  if (os8 === "win32") {
143969
143864
  const appData = process.env.APPDATA;
143970
143865
  if (!appData)
143971
143866
  return null;
143972
- return join48(appData, appName, "User", "keybindings.json");
143867
+ return join47(appData, appName, "User", "keybindings.json");
143973
143868
  }
143974
143869
  if (os8 === "linux") {
143975
- return join48(homedir37(), ".config", appName, "User", "keybindings.json");
143870
+ return join47(homedir37(), ".config", appName, "User", "keybindings.json");
143976
143871
  }
143977
143872
  return null;
143978
143873
  }
@@ -143994,10 +143889,10 @@ function parseKeybindings2(content) {
143994
143889
  }
143995
143890
  }
143996
143891
  function keybindingExists2(keybindingsPath) {
143997
- if (!existsSync38(keybindingsPath))
143892
+ if (!existsSync37(keybindingsPath))
143998
143893
  return false;
143999
143894
  try {
144000
- const content = readFileSync22(keybindingsPath, { encoding: "utf-8" });
143895
+ const content = readFileSync21(keybindingsPath, { encoding: "utf-8" });
144001
143896
  const keybindings = parseKeybindings2(content);
144002
143897
  if (!keybindings)
144003
143898
  return false;
@@ -144007,7 +143902,7 @@ function keybindingExists2(keybindingsPath) {
144007
143902
  }
144008
143903
  }
144009
143904
  function createBackup2(keybindingsPath) {
144010
- if (!existsSync38(keybindingsPath))
143905
+ if (!existsSync37(keybindingsPath))
144011
143906
  return null;
144012
143907
  const backupPath = `${keybindingsPath}.letta-backup`;
144013
143908
  try {
@@ -144023,14 +143918,14 @@ function installKeybinding2(keybindingsPath) {
144023
143918
  return { success: true, alreadyExists: true };
144024
143919
  }
144025
143920
  const parentDir = dirname19(keybindingsPath);
144026
- if (!existsSync38(parentDir)) {
143921
+ if (!existsSync37(parentDir)) {
144027
143922
  mkdirSync24(parentDir, { recursive: true });
144028
143923
  }
144029
143924
  let keybindings = [];
144030
143925
  let backupPath = null;
144031
- if (existsSync38(keybindingsPath)) {
143926
+ if (existsSync37(keybindingsPath)) {
144032
143927
  backupPath = createBackup2(keybindingsPath);
144033
- const content = readFileSync22(keybindingsPath, { encoding: "utf-8" });
143928
+ const content = readFileSync21(keybindingsPath, { encoding: "utf-8" });
144034
143929
  const parsed = parseKeybindings2(content);
144035
143930
  if (parsed === null) {
144036
143931
  return {
@@ -144058,10 +143953,10 @@ function installKeybinding2(keybindingsPath) {
144058
143953
  }
144059
143954
  function removeKeybinding2(keybindingsPath) {
144060
143955
  try {
144061
- if (!existsSync38(keybindingsPath)) {
143956
+ if (!existsSync37(keybindingsPath)) {
144062
143957
  return { success: true };
144063
143958
  }
144064
- const content = readFileSync22(keybindingsPath, { encoding: "utf-8" });
143959
+ const content = readFileSync21(keybindingsPath, { encoding: "utf-8" });
144065
143960
  const keybindings = parseKeybindings2(content);
144066
143961
  if (!keybindings) {
144067
143962
  return {
@@ -144125,20 +144020,20 @@ function getWezTermConfigPath2() {
144125
144020
  }
144126
144021
  const xdgConfig = process.env.XDG_CONFIG_HOME;
144127
144022
  if (xdgConfig) {
144128
- const xdgPath = join48(xdgConfig, "wezterm", "wezterm.lua");
144129
- if (existsSync38(xdgPath))
144023
+ const xdgPath = join47(xdgConfig, "wezterm", "wezterm.lua");
144024
+ if (existsSync37(xdgPath))
144130
144025
  return xdgPath;
144131
144026
  }
144132
- const configPath = join48(homedir37(), ".config", "wezterm", "wezterm.lua");
144133
- if (existsSync38(configPath))
144027
+ const configPath = join47(homedir37(), ".config", "wezterm", "wezterm.lua");
144028
+ if (existsSync37(configPath))
144134
144029
  return configPath;
144135
- return join48(homedir37(), ".wezterm.lua");
144030
+ return join47(homedir37(), ".wezterm.lua");
144136
144031
  }
144137
144032
  function wezTermDeleteFixExists2(configPath) {
144138
- if (!existsSync38(configPath))
144033
+ if (!existsSync37(configPath))
144139
144034
  return false;
144140
144035
  try {
144141
- const content = readFileSync22(configPath, { encoding: "utf-8" });
144036
+ const content = readFileSync21(configPath, { encoding: "utf-8" });
144142
144037
  return content.includes("Letta Code: Fix Delete key") || content.includes("key = 'Delete'") && content.includes("SendString") && content.includes("\\x1b[3~");
144143
144038
  } catch {
144144
144039
  return false;
@@ -144152,10 +144047,10 @@ function installWezTermDeleteFix2() {
144152
144047
  }
144153
144048
  let content = "";
144154
144049
  let backupPath = null;
144155
- if (existsSync38(configPath)) {
144050
+ if (existsSync37(configPath)) {
144156
144051
  backupPath = `${configPath}.letta-backup`;
144157
144052
  copyFileSync2(configPath, backupPath);
144158
- content = readFileSync22(configPath, { encoding: "utf-8" });
144053
+ content = readFileSync21(configPath, { encoding: "utf-8" });
144159
144054
  }
144160
144055
  if (content.includes("return {") && !content.includes("local config")) {
144161
144056
  content = content.replace(/return\s*\{/, "local config = {");
@@ -144182,7 +144077,7 @@ ${WEZTERM_DELETE_FIX2}
144182
144077
  `;
144183
144078
  }
144184
144079
  const parentDir = dirname19(configPath);
144185
- if (!existsSync38(parentDir)) {
144080
+ if (!existsSync37(parentDir)) {
144186
144081
  mkdirSync24(parentDir, { recursive: true });
144187
144082
  }
144188
144083
  writeFileSync19(configPath, content, { encoding: "utf-8" });
@@ -144231,9 +144126,9 @@ __export(exports_settings2, {
144231
144126
  getSetting: () => getSetting2
144232
144127
  });
144233
144128
  import { homedir as homedir38 } from "node:os";
144234
- import { join as join49 } from "node:path";
144129
+ import { join as join48 } from "node:path";
144235
144130
  function getSettingsPath2() {
144236
- return join49(homedir38(), ".letta", "settings.json");
144131
+ return join48(homedir38(), ".letta", "settings.json");
144237
144132
  }
144238
144133
  async function loadSettings2() {
144239
144134
  const settingsPath = getSettingsPath2();
@@ -144270,7 +144165,7 @@ async function getSetting2(key) {
144270
144165
  return settings[key];
144271
144166
  }
144272
144167
  function getProjectSettingsPath2() {
144273
- return join49(process.cwd(), ".letta", "settings.local.json");
144168
+ return join48(process.cwd(), ".letta", "settings.local.json");
144274
144169
  }
144275
144170
  async function loadProjectSettings2() {
144276
144171
  const settingsPath = getProjectSettingsPath2();
@@ -144288,7 +144183,7 @@ async function loadProjectSettings2() {
144288
144183
  }
144289
144184
  async function saveProjectSettings2(settings) {
144290
144185
  const settingsPath = getProjectSettingsPath2();
144291
- const dirPath = join49(process.cwd(), ".letta");
144186
+ const dirPath = join48(process.cwd(), ".letta");
144292
144187
  try {
144293
144188
  if (!exists(dirPath)) {
144294
144189
  await mkdir(dirPath, { recursive: true });
@@ -144867,7 +144762,7 @@ function parseRegistryHandle2(handle) {
144867
144762
  }
144868
144763
  async function importAgentFromRegistry2(options) {
144869
144764
  const { tmpdir: tmpdir7 } = await import("node:os");
144870
- const { join: join50 } = await import("node:path");
144765
+ const { join: join49 } = await import("node:path");
144871
144766
  const { writeFile: writeFile10, unlink: unlink3 } = await import("node:fs/promises");
144872
144767
  const { author, name } = parseRegistryHandle2(options.handle);
144873
144768
  const rawUrl = `https://raw.githubusercontent.com/${AGENT_REGISTRY_OWNER2}/${AGENT_REGISTRY_REPO2}/refs/heads/${AGENT_REGISTRY_BRANCH2}/agents/@${author}/${name}/${name}.af`;
@@ -144879,7 +144774,7 @@ async function importAgentFromRegistry2(options) {
144879
144774
  throw new Error(`Failed to download agent @${author}/${name}: ${response.statusText}`);
144880
144775
  }
144881
144776
  const afContent = await response.text();
144882
- const tempPath = join50(tmpdir7(), `letta-import-${author}-${name}-${Date.now()}.af`);
144777
+ const tempPath = join49(tmpdir7(), `letta-import-${author}-${name}-${Date.now()}.af`);
144883
144778
  await writeFile10(tempPath, afContent, "utf-8");
144884
144779
  try {
144885
144780
  const result = await importAgentFromFile2({
@@ -144923,22 +144818,22 @@ __export(exports_memoryFilesystem2, {
144923
144818
  MEMORY_FS_MEMORY_DIR: () => MEMORY_FS_MEMORY_DIR2,
144924
144819
  MEMORY_FS_AGENTS_DIR: () => MEMORY_FS_AGENTS_DIR2
144925
144820
  });
144926
- import { existsSync as existsSync39, mkdirSync as mkdirSync25 } from "node:fs";
144821
+ import { existsSync as existsSync38, mkdirSync as mkdirSync25 } from "node:fs";
144927
144822
  import { homedir as homedir39 } from "node:os";
144928
- import { join as join50 } from "node:path";
144823
+ import { join as join49 } from "node:path";
144929
144824
  function getMemoryFilesystemRoot2(agentId, homeDir = homedir39()) {
144930
- return join50(homeDir, MEMORY_FS_ROOT2, MEMORY_FS_AGENTS_DIR2, agentId, MEMORY_FS_MEMORY_DIR2);
144825
+ return join49(homeDir, MEMORY_FS_ROOT2, MEMORY_FS_AGENTS_DIR2, agentId, MEMORY_FS_MEMORY_DIR2);
144931
144826
  }
144932
144827
  function getMemorySystemDir2(agentId, homeDir = homedir39()) {
144933
- return join50(getMemoryFilesystemRoot2(agentId, homeDir), MEMORY_SYSTEM_DIR2);
144828
+ return join49(getMemoryFilesystemRoot2(agentId, homeDir), MEMORY_SYSTEM_DIR2);
144934
144829
  }
144935
144830
  function ensureMemoryFilesystemDirs2(agentId, homeDir = homedir39()) {
144936
144831
  const root = getMemoryFilesystemRoot2(agentId, homeDir);
144937
144832
  const systemDir = getMemorySystemDir2(agentId, homeDir);
144938
- if (!existsSync39(root)) {
144833
+ if (!existsSync38(root)) {
144939
144834
  mkdirSync25(root, { recursive: true });
144940
144835
  }
144941
- if (!existsSync39(systemDir)) {
144836
+ if (!existsSync38(systemDir)) {
144942
144837
  mkdirSync25(systemDir, { recursive: true });
144943
144838
  }
144944
144839
  }
@@ -149576,10 +149471,10 @@ async function runListenSubcommand(argv) {
149576
149471
 
149577
149472
  // src/cli/subcommands/memfs.ts
149578
149473
  await init_memoryGit();
149579
- import { cpSync, existsSync as existsSync22, mkdirSync as mkdirSync15, rmSync as rmSync3, statSync as statSync8 } from "node:fs";
149474
+ import { cpSync, existsSync as existsSync21, mkdirSync as mkdirSync15, rmSync as rmSync3, statSync as statSync8 } from "node:fs";
149580
149475
  import { readdir as readdir6 } from "node:fs/promises";
149581
149476
  import { homedir as homedir23 } from "node:os";
149582
- import { join as join28 } from "node:path";
149477
+ import { join as join27 } from "node:path";
149583
149478
  import { parseArgs as parseArgs7 } from "node:util";
149584
149479
  function printUsage4() {
149585
149480
  console.log(`
@@ -149624,10 +149519,10 @@ function parseMemfsArgs(argv) {
149624
149519
  });
149625
149520
  }
149626
149521
  function getMemoryRoot(agentId) {
149627
- return join28(homedir23(), ".letta", "agents", agentId, "memory");
149522
+ return join27(homedir23(), ".letta", "agents", agentId, "memory");
149628
149523
  }
149629
149524
  function getAgentRoot(agentId) {
149630
- return join28(homedir23(), ".letta", "agents", agentId);
149525
+ return join27(homedir23(), ".letta", "agents", agentId);
149631
149526
  }
149632
149527
  function formatBackupTimestamp(date = new Date) {
149633
149528
  const pad = (value) => String(value).padStart(2, "0");
@@ -149641,7 +149536,7 @@ function formatBackupTimestamp(date = new Date) {
149641
149536
  }
149642
149537
  async function listBackups(agentId) {
149643
149538
  const agentRoot = getAgentRoot(agentId);
149644
- if (!existsSync22(agentRoot)) {
149539
+ if (!existsSync21(agentRoot)) {
149645
149540
  return [];
149646
149541
  }
149647
149542
  const entries = await readdir6(agentRoot, { withFileTypes: true });
@@ -149651,7 +149546,7 @@ async function listBackups(agentId) {
149651
149546
  continue;
149652
149547
  if (!entry.name.startsWith("memory-backup-"))
149653
149548
  continue;
149654
- const path23 = join28(agentRoot, entry.name);
149549
+ const path23 = join27(agentRoot, entry.name);
149655
149550
  let createdAt = null;
149656
149551
  try {
149657
149552
  const stat6 = statSync8(path23);
@@ -149668,7 +149563,7 @@ function resolveBackupPath(agentId, from) {
149668
149563
  if (from.startsWith("/") || /^[A-Za-z]:[/\\]/.test(from)) {
149669
149564
  return from;
149670
149565
  }
149671
- return join28(getAgentRoot(agentId), from);
149566
+ return join27(getAgentRoot(agentId), from);
149672
149567
  }
149673
149568
  async function runMemfsSubcommand(argv) {
149674
149569
  let parsed;
@@ -149728,14 +149623,14 @@ async function runMemfsSubcommand(argv) {
149728
149623
  }
149729
149624
  if (action === "backup") {
149730
149625
  const root = getMemoryRoot(agentId);
149731
- if (!existsSync22(root)) {
149626
+ if (!existsSync21(root)) {
149732
149627
  console.error(`Memory directory not found for agent ${agentId}.`);
149733
149628
  return 1;
149734
149629
  }
149735
149630
  const agentRoot = getAgentRoot(agentId);
149736
149631
  const backupName = `memory-backup-${formatBackupTimestamp()}`;
149737
- const backupPath = join28(agentRoot, backupName);
149738
- if (existsSync22(backupPath)) {
149632
+ const backupPath = join27(agentRoot, backupName);
149633
+ if (existsSync21(backupPath)) {
149739
149634
  console.error(`Backup already exists at ${backupPath}`);
149740
149635
  return 1;
149741
149636
  }
@@ -149759,7 +149654,7 @@ async function runMemfsSubcommand(argv) {
149759
149654
  return 1;
149760
149655
  }
149761
149656
  const backupPath = resolveBackupPath(agentId, from);
149762
- if (!existsSync22(backupPath)) {
149657
+ if (!existsSync21(backupPath)) {
149763
149658
  console.error(`Backup not found: ${backupPath}`);
149764
149659
  return 1;
149765
149660
  }
@@ -149781,11 +149676,11 @@ async function runMemfsSubcommand(argv) {
149781
149676
  return 1;
149782
149677
  }
149783
149678
  const root = getMemoryRoot(agentId);
149784
- if (!existsSync22(root)) {
149679
+ if (!existsSync21(root)) {
149785
149680
  console.error(`Memory directory not found for agent ${agentId}.`);
149786
149681
  return 1;
149787
149682
  }
149788
- if (existsSync22(out)) {
149683
+ if (existsSync21(out)) {
149789
149684
  const stat6 = statSync8(out);
149790
149685
  if (stat6.isDirectory()) {
149791
149686
  const contents = await readdir6(out);
@@ -150180,7 +150075,7 @@ init_memoryScope();
150180
150075
  init_readOnlyShell();
150181
150076
  init_shell_command_normalization();
150182
150077
  import { homedir as homedir24 } from "node:os";
150183
- import { isAbsolute as isAbsolute17, join as join29, relative as relative12 } from "node:path";
150078
+ import { isAbsolute as isAbsolute17, join as join28, relative as relative12 } from "node:path";
150184
150079
  var MODE_KEY2 = Symbol.for("@letta/permissionMode");
150185
150080
  var PLAN_FILE_KEY2 = Symbol.for("@letta/planFilePath");
150186
150081
  var MODE_BEFORE_PLAN_KEY2 = Symbol.for("@letta/permissionModeBeforePlan");
@@ -150411,7 +150306,7 @@ class PermissionModeManager2 {
150411
150306
  return "allow";
150412
150307
  }
150413
150308
  if (writeTools.includes(toolName)) {
150414
- const plansDir = join29(homedir24(), ".letta", "plans");
150309
+ const plansDir = join28(homedir24(), ".letta", "plans");
150415
150310
  const targetPath = toolArgs?.file_path || toolArgs?.path;
150416
150311
  let candidatePaths = [];
150417
150312
  if ((toolName === "ApplyPatch" || toolName === "apply_patch" || toolName === "memory_apply_patch") && toolArgs?.input) {
@@ -150462,7 +150357,7 @@ class PermissionModeManager2 {
150462
150357
  }
150463
150358
  const planWritePath = extractPlanFileWritePathFromShellCommand2(command);
150464
150359
  if (planWritePath) {
150465
- const plansDir = join29(homedir24(), ".letta", "plans");
150360
+ const plansDir = join28(homedir24(), ".letta", "plans");
150466
150361
  const resolvedPath = resolvePlanTargetPath2(planWritePath, workingDirectory);
150467
150362
  if (resolvedPath && isPathInPlansDir2(resolvedPath, plansDir)) {
150468
150363
  return "allow";
@@ -150582,7 +150477,7 @@ await __promiseAll([
150582
150477
  ]);
150583
150478
  import { randomUUID as randomUUID4 } from "node:crypto";
150584
150479
  import { homedir as homedir25 } from "node:os";
150585
- import { join as join30, resolve as resolve24 } from "node:path";
150480
+ import { join as join29, resolve as resolve24 } from "node:path";
150586
150481
  var DEFAULT_SETTINGS3 = {
150587
150482
  lastAgent: null,
150588
150483
  tokenStreaming: false,
@@ -150969,7 +150864,7 @@ class SettingsManager2 {
150969
150864
  return;
150970
150865
  const settingsPath = this.getSettingsPath();
150971
150866
  const home = process.env.HOME || homedir25();
150972
- const dirPath = join30(home, ".letta");
150867
+ const dirPath = join29(home, ".letta");
150973
150868
  try {
150974
150869
  if (!exists(dirPath)) {
150975
150870
  await mkdir(dirPath, { recursive: true });
@@ -151008,7 +150903,7 @@ class SettingsManager2 {
151008
150903
  if (!settings)
151009
150904
  return;
151010
150905
  const settingsPath = this.getProjectSettingsPath(workingDirectory);
151011
- const dirPath = join30(workingDirectory, ".letta");
150906
+ const dirPath = join29(workingDirectory, ".letta");
151012
150907
  try {
151013
150908
  let existingSettings = {};
151014
150909
  if (exists(settingsPath)) {
@@ -151030,16 +150925,16 @@ class SettingsManager2 {
151030
150925
  }
151031
150926
  getSettingsPath() {
151032
150927
  const home = process.env.HOME || homedir25();
151033
- return join30(home, ".letta", "settings.json");
150928
+ return join29(home, ".letta", "settings.json");
151034
150929
  }
151035
150930
  getProjectSettingsPath(workingDirectory) {
151036
- return join30(workingDirectory, ".letta", "settings.json");
150931
+ return join29(workingDirectory, ".letta", "settings.json");
151037
150932
  }
151038
150933
  isProjectSettingsPathCollidingWithGlobal(workingDirectory) {
151039
150934
  return resolve24(this.getProjectSettingsPath(workingDirectory)) === resolve24(this.getSettingsPath());
151040
150935
  }
151041
150936
  getLocalProjectSettingsPath(workingDirectory) {
151042
- return join30(workingDirectory, ".letta", "settings.local.json");
150937
+ return join29(workingDirectory, ".letta", "settings.local.json");
151043
150938
  }
151044
150939
  async loadLocalProjectSettings(workingDirectory = process.cwd()) {
151045
150940
  const cached = this.localProjectSettings.get(workingDirectory);
@@ -151100,7 +150995,7 @@ class SettingsManager2 {
151100
150995
  if (!settings)
151101
150996
  return;
151102
150997
  const settingsPath = this.getLocalProjectSettingsPath(workingDirectory);
151103
- const dirPath = join30(workingDirectory, ".letta");
150998
+ const dirPath = join29(workingDirectory, ".letta");
151104
150999
  try {
151105
151000
  if (!exists(dirPath)) {
151106
151001
  await mkdir(dirPath, { recursive: true });
@@ -151454,7 +151349,7 @@ class SettingsManager2 {
151454
151349
  this.upsertAgentSettings(agentId, { systemPromptPreset: "" });
151455
151350
  }
151456
151351
  hasLocalLettaDir(workingDirectory = process.cwd()) {
151457
- const dirPath = join30(workingDirectory, ".letta");
151352
+ const dirPath = join29(workingDirectory, ".letta");
151458
151353
  return exists(dirPath);
151459
151354
  }
151460
151355
  storeOAuthState(state, codeVerifier, redirectUri, provider) {
@@ -152309,12 +152204,12 @@ EXAMPLES
152309
152204
  console.log(usage);
152310
152205
  }
152311
152206
  async function printInfo() {
152312
- const { join: join51 } = await import("path");
152207
+ const { join: join50 } = await import("path");
152313
152208
  const { getVersion: getVersion3 } = await Promise.resolve().then(() => (init_version2(), exports_version));
152314
152209
  const { SKILLS_DIR: SKILLS_DIR3 } = await Promise.resolve().then(() => (init_skills2(), exports_skills2));
152315
152210
  const { exists: exists3 } = await Promise.resolve().then(() => (init_fs2(), exports_fs));
152316
152211
  const cwd2 = process.cwd();
152317
- const skillsDir = join51(cwd2, SKILLS_DIR3);
152212
+ const skillsDir = join50(cwd2, SKILLS_DIR3);
152318
152213
  const skillsExist = exists3(skillsDir);
152319
152214
  await settingsManager2.loadLocalProjectSettings(cwd2);
152320
152215
  const localPinned = settingsManager2.getLocalPinnedAgents(cwd2);
@@ -152707,9 +152602,9 @@ Note: Flags should use double dashes for full names (e.g., --yolo, not -yolo)`);
152707
152602
  }
152708
152603
  } else {
152709
152604
  const { resolve: resolve32 } = await import("path");
152710
- const { existsSync: existsSync40 } = await import("fs");
152605
+ const { existsSync: existsSync39 } = await import("fs");
152711
152606
  const resolvedPath = resolve32(fromAfFile);
152712
- if (!existsSync40(resolvedPath)) {
152607
+ if (!existsSync39(resolvedPath)) {
152713
152608
  console.error(`Error: AgentFile not found: ${resolvedPath}`);
152714
152609
  process.exit(1);
152715
152610
  }
@@ -153584,4 +153479,4 @@ Error during initialization: ${message}`);
153584
153479
  }
153585
153480
  main();
153586
153481
 
153587
- //# debugId=5769741D74E7325364756E2164756E21
153482
+ //# debugId=CC952798FB2DAADB64756E2164756E21