@letta-ai/letta-code 0.32.9 → 0.32.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/letta.js CHANGED
@@ -5530,7 +5530,7 @@ var package_default;
5530
5530
  var init_package = __esm(() => {
5531
5531
  package_default = {
5532
5532
  name: "@letta-ai/letta-code",
5533
- version: "0.32.9",
5533
+ version: "0.32.10",
5534
5534
  lettaStartupLogProtocol: 1,
5535
5535
  description: "Letta Code is a CLI tool for interacting with stateful Letta agents from the terminal.",
5536
5536
  type: "module",
@@ -218713,6 +218713,7 @@ __export(exports_environments2, {
218713
218713
  resolveAgentSandboxConnectionId: () => resolveAgentSandboxConnectionId,
218714
218714
  listEnvironments: () => listEnvironments,
218715
218715
  isEnvironmentOnline: () => isEnvironmentOnline,
218716
+ getTeleportStatus: () => getTeleportStatus,
218716
218717
  getEnvironmentConnection: () => getEnvironmentConnection,
218717
218718
  describeEnvironment: () => describeEnvironment,
218718
218719
  createAgentSandbox: () => createAgentSandbox
@@ -218815,6 +218816,9 @@ async function resolveAgentSandboxConnectionId(agentId, options = {}) {
218815
218816
  }
218816
218817
  throw new Error(`Timed out waiting for cloud sandbox ${sandbox.connectionName} to register${lastError instanceof Error ? `: ${lastError.message}` : ""}`);
218817
218818
  }
218819
+ function getTeleportStatus(agentId, conversationId, teleportId, request = apiRequest) {
218820
+ return request("GET", `/v1/environments/runtimes/${encodeURIComponent(agentId)}/${encodeURIComponent(conversationId)}/teleports/${encodeURIComponent(teleportId)}`, undefined, { signal: AbortSignal.timeout(5000) });
218821
+ }
218818
218822
  async function teleportToEnvironment(agentId, conversationId, targetConnectionId, request = apiRequest) {
218819
218823
  return request("POST", `/v1/environments/runtimes/${encodeURIComponent(agentId)}/${encodeURIComponent(conversationId)}/teleport`, {
218820
218824
  targetConnectionId,
@@ -397854,6 +397858,108 @@ var init_teleport_guard = __esm(() => {
397854
397858
  init_routing();
397855
397859
  });
397856
397860
 
397861
+ // src/websocket/listener/interrupted-turn-record.ts
397862
+ import { createHash as createHash9, randomUUID as randomUUID29 } from "node:crypto";
397863
+ import {
397864
+ mkdirSync as mkdirSync36,
397865
+ readdirSync as readdirSync18,
397866
+ readFileSync as readFileSync37,
397867
+ renameSync as renameSync7,
397868
+ rmSync as rmSync13,
397869
+ writeFileSync as writeFileSync27
397870
+ } from "node:fs";
397871
+ import { homedir as homedir34 } from "node:os";
397872
+ import { join as join57 } from "node:path";
397873
+ function createInterruptedTurnStore(directory = join57(homedir34(), ".letta", "listener-state", createHash9("sha256").update(getServerUrl()).digest("hex").slice(0, 24))) {
397874
+ function path43(agentId, conversationId) {
397875
+ return join57(directory, `${encodeURIComponent(agentId)}_${encodeURIComponent(conversationId)}.json`);
397876
+ }
397877
+ function readRecord(file) {
397878
+ try {
397879
+ const value = JSON.parse(readFileSync37(file, "utf8"));
397880
+ if (!value || typeof value.agentId !== "string" || typeof value.conversationId !== "string" || path43(value.agentId, value.conversationId) !== file || !Array.isArray(value.toolCallIds) || !value.toolCallIds.every((id2) => typeof id2 === "string") || !Array.isArray(value.results) || !value.results.every((result2) => result2 && typeof result2.tool_call_id === "string") || typeof value.requestOtid !== "string" || typeof value.workingDirectory !== "string") {
397881
+ throw new Error("Invalid interrupted-turn record");
397882
+ }
397883
+ return value;
397884
+ } catch (error4) {
397885
+ if (error4.code !== "ENOENT") {
397886
+ debugWarn("recovery", "Ignoring unreadable interrupted-turn record", file);
397887
+ }
397888
+ return null;
397889
+ }
397890
+ }
397891
+ return {
397892
+ list() {
397893
+ try {
397894
+ return readdirSync18(directory).filter((file) => file.endsWith(".json")).map((file) => readRecord(join57(directory, file))).filter((record3) => record3 !== null);
397895
+ } catch (error4) {
397896
+ if (error4.code === "ENOENT")
397897
+ return [];
397898
+ throw error4;
397899
+ }
397900
+ },
397901
+ read(agentId, conversationId) {
397902
+ return readRecord(path43(agentId, conversationId));
397903
+ },
397904
+ write(record3) {
397905
+ mkdirSync36(directory, { recursive: true, mode: 448 });
397906
+ const destination = path43(record3.agentId, record3.conversationId);
397907
+ const temporary = `${destination}.${randomUUID29()}.tmp`;
397908
+ try {
397909
+ writeFileSync27(temporary, JSON.stringify({ ...record3, revision: randomUUID29() }), {
397910
+ mode: 384,
397911
+ flush: true
397912
+ });
397913
+ renameSync7(temporary, destination);
397914
+ } finally {
397915
+ rmSync13(temporary, { force: true });
397916
+ }
397917
+ },
397918
+ remove(agentId, conversationId) {
397919
+ rmSync13(path43(agentId, conversationId), { force: true });
397920
+ }
397921
+ };
397922
+ }
397923
+ function readInterruptedTurn(runtime) {
397924
+ if (!runtime.agentId || !runtime.listener.connectionId?.startsWith("conn-"))
397925
+ return null;
397926
+ return createInterruptedTurnStore().read(runtime.agentId, runtime.conversationId);
397927
+ }
397928
+ function recordListenerWork(runtime, update3) {
397929
+ if (!runtime.agentId || !runtime.listener.connectionId?.startsWith("conn-"))
397930
+ return;
397931
+ const previous = readInterruptedTurn(runtime);
397932
+ createInterruptedTurnStore().write({
397933
+ agentId: runtime.agentId,
397934
+ conversationId: runtime.conversationId,
397935
+ runId: previous?.runId ?? null,
397936
+ toolCallIds: previous?.toolCallIds ?? [],
397937
+ results: previous?.results ?? [],
397938
+ requestOtid: previous?.requestOtid ?? randomUUID29(),
397939
+ actingUserId: previous?.actingUserId,
397940
+ workingDirectory: runtime.activeWorkingDirectory ?? previous?.workingDirectory ?? process.cwd(),
397941
+ ...update3
397942
+ });
397943
+ }
397944
+ function forgetListenerWork(runtime) {
397945
+ if (runtime.agentId && runtime.listener.connectionId?.startsWith("conn-")) {
397946
+ createInterruptedTurnStore().remove(runtime.agentId, runtime.conversationId);
397947
+ }
397948
+ }
397949
+ function recordedToolResults(record3, pendingToolCallIds) {
397950
+ return pendingToolCallIds.map((id2) => record3.results.find((result2) => result2.tool_call_id === id2) ?? {
397951
+ type: "approval",
397952
+ tool_call_id: id2,
397953
+ approve: false,
397954
+ reason: STALE_APPROVAL_RECOVERY_DENIAL_REASON
397955
+ });
397956
+ }
397957
+ var init_interrupted_turn_record = __esm(() => {
397958
+ init_turn_recovery_policy();
397959
+ init_server_url();
397960
+ init_debug();
397961
+ });
397962
+
397857
397963
  // src/websocket/listener/recoverable-notices.ts
397858
397964
  function getRecoverableStatusNoticeVisibility(kind) {
397859
397965
  switch (kind) {
@@ -398068,7 +398174,7 @@ function buildTeleportContinuationMessages(params) {
398068
398174
  otid: params.teleportId
398069
398175
  },
398070
398176
  {
398071
- role: "system",
398177
+ role: "user",
398072
398178
  content: "<system-reminder>Teleportation to this environment is complete. Continue the existing task from this environment now.</system-reminder>",
398073
398179
  otid: `${params.teleportId}:continue`
398074
398180
  }
@@ -398087,7 +398193,7 @@ function buildTeleportFailureMessages(params) {
398087
398193
  });
398088
398194
  }
398089
398195
  messages.push({
398090
- role: "system",
398196
+ role: "user",
398091
398197
  content: `<system-reminder>Teleportation failed.
398092
398198
 
398093
398199
  Error: ${escapeSystemReminderText(params.error)}
@@ -398220,9 +398326,8 @@ function handleTeleportRequest(params) {
398220
398326
  const conversationRuntime = getConversationRuntime(listener, pending.agentId, pending.conversationId);
398221
398327
  pending.drainAcceptedInputs = conversationRuntime ? hasAcceptedInputsWaiting(conversationRuntime, true) : false;
398222
398328
  if (!conversationRuntime?.isProcessing && !pending.drainAcceptedInputs) {
398223
- if (sendTeleportReady(listener, pending, { success: true })) {
398329
+ if (emitClaimedTeleportReady(listener, pending)) {
398224
398330
  pending.readyAt = Date.now();
398225
- retainTeleportForRecovery(listener, pending);
398226
398331
  }
398227
398332
  }
398228
398333
  }
@@ -398246,12 +398351,25 @@ function claimPendingTeleportAtBoundary(params) {
398246
398351
  return pending;
398247
398352
  }
398248
398353
  function emitClaimedTeleportReady(listener, pending) {
398354
+ if (listener.connectionId?.startsWith("conn-"))
398355
+ suspendRecordedTeleport(pending, true);
398249
398356
  const sent = sendTeleportReady(listener, pending, { success: true });
398250
398357
  if (sent) {
398251
398358
  retainTeleportForRecovery(listener, pending);
398359
+ } else if (listener.connectionId?.startsWith("conn-")) {
398360
+ suspendRecordedTeleport(pending, false);
398252
398361
  }
398253
398362
  return sent;
398254
398363
  }
398364
+ function suspendRecordedTeleport(pending, suspended) {
398365
+ const store3 = createInterruptedTurnStore();
398366
+ const record3 = store3.read(pending.agentId, pending.conversationId);
398367
+ if (record3)
398368
+ store3.write({
398369
+ ...record3,
398370
+ teleportId: suspended ? pending.teleportId : undefined
398371
+ });
398372
+ }
398255
398373
  function finishTeleport(runtime, lease, pending) {
398256
398374
  const transition = runtime.turnLifecycle.finish(lease, "cancelled");
398257
398375
  if (!transition.finished)
@@ -398323,6 +398441,7 @@ var init_teleport = __esm(() => {
398323
398441
  init_backend_mode();
398324
398442
  init_teleport_guard();
398325
398443
  init_connection();
398444
+ init_interrupted_turn_record();
398326
398445
  init_permission_mode();
398327
398446
  init_protocol_outbound();
398328
398447
  init_recoverable_notices();
@@ -398779,14 +398898,14 @@ async function handleSkillCommand(parsed, socket, safeSocketSend) {
398779
398898
  const {
398780
398899
  existsSync: existsSync50,
398781
398900
  lstatSync: lstatSync3,
398782
- mkdirSync: mkdirSync36,
398901
+ mkdirSync: mkdirSync37,
398783
398902
  rmdirSync,
398784
398903
  symlinkSync: symlinkSync2,
398785
398904
  unlinkSync: unlinkSync10
398786
398905
  } = await import("node:fs");
398787
- const { basename: basename18, join: join57 } = await import("node:path");
398788
- const lettaHome = process.env.LETTA_HOME || join57(process.env.HOME || process.env.USERPROFILE || "~", ".letta");
398789
- const globalSkillsDir = join57(lettaHome, "skills");
398906
+ const { basename: basename18, join: join58 } = await import("node:path");
398907
+ const lettaHome = process.env.LETTA_HOME || join58(process.env.HOME || process.env.USERPROFILE || "~", ".letta");
398908
+ const globalSkillsDir = join58(lettaHome, "skills");
398790
398909
  if (parsed.type === "skill_enable") {
398791
398910
  try {
398792
398911
  if (!existsSync50(parsed.skill_path)) {
@@ -398798,7 +398917,7 @@ async function handleSkillCommand(parsed, socket, safeSocketSend) {
398798
398917
  }, "listener_skill_send_failed", "listener_skill_command");
398799
398918
  return true;
398800
398919
  }
398801
- const skillMdPath = join57(parsed.skill_path, "SKILL.md");
398920
+ const skillMdPath = join58(parsed.skill_path, "SKILL.md");
398802
398921
  if (!existsSync50(skillMdPath)) {
398803
398922
  safeSocketSend(socket, {
398804
398923
  type: "skill_enable_response",
@@ -398809,8 +398928,8 @@ async function handleSkillCommand(parsed, socket, safeSocketSend) {
398809
398928
  return true;
398810
398929
  }
398811
398930
  const linkName = basename18(parsed.skill_path);
398812
- const linkPath = join57(globalSkillsDir, linkName);
398813
- mkdirSync36(globalSkillsDir, { recursive: true });
398931
+ const linkPath = join58(globalSkillsDir, linkName);
398932
+ mkdirSync37(globalSkillsDir, { recursive: true });
398814
398933
  if (existsSync50(linkPath)) {
398815
398934
  const stat12 = lstatSync3(linkPath);
398816
398935
  if (stat12.isSymbolicLink()) {
@@ -398852,7 +398971,7 @@ async function handleSkillCommand(parsed, socket, safeSocketSend) {
398852
398971
  }
398853
398972
  if (parsed.type === "skill_disable") {
398854
398973
  try {
398855
- const linkPath = join57(globalSkillsDir, parsed.name);
398974
+ const linkPath = join58(globalSkillsDir, parsed.name);
398856
398975
  if (!existsSync50(linkPath)) {
398857
398976
  safeSocketSend(socket, {
398858
398977
  type: "skill_disable_response",
@@ -400670,7 +400789,7 @@ var init_accumulator = __esm(async () => {
400670
400789
  });
400671
400790
 
400672
400791
  // src/utils/tui-perf.ts
400673
- import { appendFileSync as appendFileSync8, mkdirSync as mkdirSync36 } from "node:fs";
400792
+ import { appendFileSync as appendFileSync8, mkdirSync as mkdirSync37 } from "node:fs";
400674
400793
  import { dirname as dirname28 } from "node:path";
400675
400794
  function ensureExitHook() {
400676
400795
  if (tuiPerfExitHookRegistered) {
@@ -400762,7 +400881,7 @@ function flushTuiPerfTelemetry() {
400762
400881
  try {
400763
400882
  const dir = dirname28(filePath);
400764
400883
  if (tuiPerfFileDirEnsured !== dir) {
400765
- mkdirSync36(dir, { recursive: true });
400884
+ mkdirSync37(dir, { recursive: true });
400766
400885
  tuiPerfFileDirEnsured = dir;
400767
400886
  }
400768
400887
  appendFileSync8(filePath, `${JSON.stringify({
@@ -400794,13 +400913,13 @@ var init_tui_perf = __esm(() => {
400794
400913
  // src/cli/helpers/chunk-log.ts
400795
400914
  import {
400796
400915
  existsSync as existsSync50,
400797
- mkdirSync as mkdirSync37,
400798
- readdirSync as readdirSync18,
400916
+ mkdirSync as mkdirSync38,
400917
+ readdirSync as readdirSync19,
400799
400918
  unlinkSync as unlinkSync10,
400800
- writeFileSync as writeFileSync27
400919
+ writeFileSync as writeFileSync28
400801
400920
  } from "node:fs";
400802
- import { homedir as homedir34 } from "node:os";
400803
- import { join as join57 } from "node:path";
400921
+ import { homedir as homedir35 } from "node:os";
400922
+ import { join as join58 } from "node:path";
400804
400923
  function truncateStr(value, maxLen) {
400805
400924
  if (value === null || value === undefined)
400806
400925
  return "";
@@ -400864,8 +400983,8 @@ class ChunkLog {
400864
400983
  agentDir = null;
400865
400984
  dirCreated = false;
400866
400985
  init(agentId, sessionId) {
400867
- this.agentDir = join57(LOG_BASE_DIR, agentId);
400868
- this.logPath = join57(this.agentDir, `${sessionId}.jsonl`);
400986
+ this.agentDir = join58(LOG_BASE_DIR, agentId);
400987
+ this.logPath = join58(this.agentDir, `${sessionId}.jsonl`);
400869
400988
  this.buffer = [];
400870
400989
  this.dirty = false;
400871
400990
  this.dirCreated = false;
@@ -400895,7 +401014,7 @@ class ChunkLog {
400895
401014
  return;
400896
401015
  try {
400897
401016
  if (!existsSync50(this.agentDir)) {
400898
- mkdirSync37(this.agentDir, { recursive: true });
401017
+ mkdirSync38(this.agentDir, { recursive: true });
400899
401018
  }
400900
401019
  this.dirCreated = true;
400901
401020
  } catch (e2) {
@@ -400909,7 +401028,7 @@ class ChunkLog {
400909
401028
  try {
400910
401029
  const content = this.buffer.map((entry) => JSON.stringify(entry)).join(`
400911
401030
  `);
400912
- writeFileSync27(this.logPath, `${content}
401031
+ writeFileSync28(this.logPath, `${content}
400913
401032
  `, "utf8");
400914
401033
  } catch (e2) {
400915
401034
  debugWarn("chunkLog", `Failed to write ${this.logPath}: ${e2 instanceof Error ? e2.message : String(e2)}`);
@@ -400921,12 +401040,12 @@ class ChunkLog {
400921
401040
  try {
400922
401041
  if (!existsSync50(this.agentDir))
400923
401042
  return;
400924
- const files = readdirSync18(this.agentDir).filter((f4) => f4.endsWith(".jsonl")).sort();
401043
+ const files = readdirSync19(this.agentDir).filter((f4) => f4.endsWith(".jsonl")).sort();
400925
401044
  if (files.length >= MAX_SESSION_FILES2) {
400926
401045
  const toDelete = files.slice(0, files.length - MAX_SESSION_FILES2 + 1);
400927
401046
  for (const file of toDelete) {
400928
401047
  try {
400929
- unlinkSync10(join57(this.agentDir, file));
401048
+ unlinkSync10(join58(this.agentDir, file));
400930
401049
  } catch (e2) {
400931
401050
  debugWarn("chunkLog", `Failed to delete old session log ${file}: ${e2 instanceof Error ? e2.message : String(e2)}`);
400932
401051
  }
@@ -400940,7 +401059,7 @@ class ChunkLog {
400940
401059
  var MAX_ENTRIES = 100, CONTENT_TRUNCATE_LEN = 200, MAX_SESSION_FILES2 = 5, LOG_BASE_DIR, chunkLog;
400941
401060
  var init_chunk_log = __esm(() => {
400942
401061
  init_debug();
400943
- LOG_BASE_DIR = join57(homedir34(), ".letta", "logs", "chunk-logs");
401062
+ LOG_BASE_DIR = join58(homedir35(), ".letta", "logs", "chunk-logs");
400944
401063
  chunkLog = new ChunkLog;
400945
401064
  });
400946
401065
 
@@ -402312,6 +402431,9 @@ function finishListenerTurn(runtime, lease, options) {
402312
402431
  if (!transition.finished) {
402313
402432
  return transition;
402314
402433
  }
402434
+ if (options.stopReason === "end_turn" || options.stopReason === "cancelled") {
402435
+ forgetListenerWork(runtime);
402436
+ }
402315
402437
  if (options.stopReason === "cancelled" && transition.previousKind === "active" && options.socket) {
402316
402438
  emitInterruptedStatusDelta(options.socket, runtime, {
402317
402439
  runId: options.runId ?? transition.runId,
@@ -402342,6 +402464,7 @@ function finishListenerTurn(runtime, lease, options) {
402342
402464
  }
402343
402465
  var init_turn_terminal = __esm(() => {
402344
402466
  init_connection();
402467
+ init_interrupted_turn_record();
402345
402468
  init_protocol_outbound();
402346
402469
  });
402347
402470
 
@@ -406016,6 +406139,11 @@ async function handleApprovalStop(params) {
406016
406139
  return interruptTermination();
406017
406140
  }
406018
406141
  lastExecutingToolCallIds = approvedDecisions.map((decision) => decision.approval.toolCallId);
406142
+ recordListenerWork(runtime, {
406143
+ toolCallIds: decisions.map((decision) => decision.approval.toolCallId),
406144
+ results: [],
406145
+ requestOtid: crypto.randomUUID()
406146
+ });
406019
406147
  runtime.turnLifecycle.setExecutingToolCallIds(turnLease, lastExecutingToolCallIds);
406020
406148
  setTurnLoopStatus(runtime, turnLease, "EXECUTING_CLIENT_SIDE_TOOL", {
406021
406149
  agent_id: agentId,
@@ -406105,6 +406233,7 @@ async function handleApprovalStop(params) {
406105
406233
  conversationId
406106
406234
  });
406107
406235
  lastExecutionResults = persistedExecutionResults;
406236
+ recordListenerWork(runtime, { results: persistedExecutionResults });
406108
406237
  emitInterruptToolReturnMessage(socket, runtime, persistedExecutionResults, executionRunId, "tool-return");
406109
406238
  if (shouldInterrupt()) {
406110
406239
  return interruptTermination();
@@ -406135,7 +406264,7 @@ async function handleApprovalStop(params) {
406135
406264
  {
406136
406265
  type: "approval",
406137
406266
  approvals: persistedExecutionResults,
406138
- otid: crypto.randomUUID()
406267
+ otid: readInterruptedTurn(runtime)?.requestOtid ?? crypto.randomUUID()
406139
406268
  }
406140
406269
  ]);
406141
406270
  let continuationBatchId = dequeuedBatchId;
@@ -406229,6 +406358,7 @@ var init_turn_approval = __esm(async () => {
406229
406358
  init_interactive_policy();
406230
406359
  init_approval();
406231
406360
  init_connection();
406361
+ init_interrupted_turn_record();
406232
406362
  init_interrupts();
406233
406363
  init_protocol_outbound();
406234
406364
  init_secrets_sync();
@@ -406250,7 +406380,7 @@ var init_turn_approval = __esm(async () => {
406250
406380
 
406251
406381
  // src/agent/attached-repository-git-sync.ts
406252
406382
  import { existsSync as existsSync51 } from "node:fs";
406253
- import { join as join58 } from "node:path";
406383
+ import { join as join59 } from "node:path";
406254
406384
  async function getPendingCommitCount(path44) {
406255
406385
  const divergence = await getMemoryAheadBehind(path44);
406256
406386
  if (divergence) {
@@ -406280,7 +406410,7 @@ async function syncPendingAttachedRepositoryCommitsUnlocked(params) {
406280
406410
  path: path44,
406281
406411
  permissions: params.repository.permissions ?? "unknown"
406282
406412
  };
406283
- if (!existsSync51(join58(path44, ".git"))) {
406413
+ if (!existsSync51(join59(path44, ".git"))) {
406284
406414
  return {
406285
406415
  ...resultBase,
406286
406416
  status: "skipped",
@@ -408741,8 +408871,8 @@ var init_core3 = __esm(() => {
408741
408871
  // node_modules/@letta-ai/trajectory/dist/adapters/deepagents/index.js
408742
408872
  import { spawn as spawn9 } from "node:child_process";
408743
408873
  import { accessSync as accessSync2, constants as constants6 } from "node:fs";
408744
- import { homedir as homedir35 } from "node:os";
408745
- import { join as join59 } from "node:path";
408874
+ import { homedir as homedir36 } from "node:os";
408875
+ import { join as join60 } from "node:path";
408746
408876
  import { fileURLToPath as fileURLToPath9 } from "node:url";
408747
408877
  async function normalizeCheckpoint(input) {
408748
408878
  const { decoded, bounds, filters } = await decodeCheckpoint(input);
@@ -408766,7 +408896,7 @@ async function decodeCheckpoint(input) {
408766
408896
  }
408767
408897
  async function loadDeepAgentsCheckpoint(checkpoint) {
408768
408898
  validateLocation(checkpoint);
408769
- const path44 = checkpoint.path ?? join59(homedir35(), ".deepagents", "sessions.db");
408899
+ const path44 = checkpoint.path ?? join60(homedir36(), ".deepagents", "sessions.db");
408770
408900
  const python = checkpoint.pythonExecutable ?? process.env.PYTHON ?? "python3";
408771
408901
  const helper = resolveHelperPath();
408772
408902
  return await new Promise((resolve36, reject2) => {
@@ -408985,8 +409115,8 @@ var init_deepagents = __esm(() => {
408985
409115
  });
408986
409116
 
408987
409117
  // node_modules/@letta-ai/trajectory/dist/adapters/listing-shared.js
408988
- import { readdirSync as readdirSync19, statSync as statSync18 } from "node:fs";
408989
- import { join as join60 } from "node:path";
409118
+ import { readdirSync as readdirSync20, statSync as statSync18 } from "node:fs";
409119
+ import { join as join61 } from "node:path";
408990
409120
  function sortListings(items3) {
408991
409121
  return items3.sort((left, right) => {
408992
409122
  const l3 = left.updatedAt ?? "";
@@ -408998,7 +409128,7 @@ function sortListings(items3) {
408998
409128
  }
408999
409129
  function safeReadDir(path44) {
409000
409130
  try {
409001
- return readdirSync19(path44, { withFileTypes: true }).map((entry) => ({
409131
+ return readdirSync20(path44, { withFileTypes: true }).map((entry) => ({
409002
409132
  name: entry.name,
409003
409133
  isDirectory: entry.isDirectory(),
409004
409134
  isFile: entry.isFile()
@@ -409031,7 +409161,7 @@ function collectFiles(root2, extension, depth) {
409031
409161
  return [];
409032
409162
  const collected = [];
409033
409163
  for (const entry of safeReadDir(root2)) {
409034
- const full = join60(root2, entry.name);
409164
+ const full = join61(root2, entry.name);
409035
409165
  if (entry.isFile && entry.name.endsWith(extension)) {
409036
409166
  collected.push(full);
409037
409167
  } else if (entry.isDirectory) {
@@ -409115,19 +409245,19 @@ var init_listing_shared = __esm(() => {
409115
409245
  });
409116
409246
 
409117
409247
  // node_modules/@letta-ai/trajectory/dist/adapters/claude-code/list.js
409118
- import { homedir as homedir36 } from "node:os";
409119
- import { basename as basename20, join as join61 } from "node:path";
409248
+ import { homedir as homedir37 } from "node:os";
409249
+ import { basename as basename20, join as join62 } from "node:path";
409120
409250
  async function listClaudeCodeTrajectories(root2) {
409121
- const base2 = root2 ?? join61(homedir36(), ".claude", "projects");
409251
+ const base2 = root2 ?? join62(homedir37(), ".claude", "projects");
409122
409252
  const items3 = [];
409123
409253
  for (const project of safeReadDir(base2)) {
409124
409254
  if (!project.isDirectory)
409125
409255
  continue;
409126
- const projectPath = join61(base2, project.name);
409256
+ const projectPath = join62(base2, project.name);
409127
409257
  for (const entry of safeReadDir(projectPath)) {
409128
409258
  if (!entry.isFile || !entry.name.endsWith(".jsonl"))
409129
409259
  continue;
409130
- const path44 = join61(projectPath, entry.name);
409260
+ const path44 = join62(projectPath, entry.name);
409131
409261
  const listing = listingFromFile(basename20(entry.name, ".jsonl"), path44);
409132
409262
  if (listing)
409133
409263
  items3.push(listing);
@@ -409140,10 +409270,10 @@ var init_list = __esm(() => {
409140
409270
  });
409141
409271
 
409142
409272
  // node_modules/@letta-ai/trajectory/dist/adapters/codex/list.js
409143
- import { homedir as homedir37 } from "node:os";
409144
- import { basename as basename21, join as join62 } from "node:path";
409273
+ import { homedir as homedir38 } from "node:os";
409274
+ import { basename as basename21, join as join63 } from "node:path";
409145
409275
  async function listCodexTrajectories(root2) {
409146
- const base2 = root2 ?? join62(homedir37(), ".codex", "sessions");
409276
+ const base2 = root2 ?? join63(homedir38(), ".codex", "sessions");
409147
409277
  const items3 = [];
409148
409278
  for (const path44 of collectFiles(base2, ".jsonl", 4)) {
409149
409279
  const listing = listingFromFile(basename21(path44, ".jsonl"), path44);
@@ -409157,8 +409287,8 @@ var init_list2 = __esm(() => {
409157
409287
  });
409158
409288
 
409159
409289
  // node_modules/@letta-ai/trajectory/dist/adapters/deepagents/list.js
409160
- import { homedir as homedir38 } from "node:os";
409161
- import { join as join63 } from "node:path";
409290
+ import { homedir as homedir39 } from "node:os";
409291
+ import { join as join64 } from "node:path";
409162
409292
  async function listDeepAgentsTrajectories(root2) {
409163
409293
  const path44 = resolveStorePath(root2);
409164
409294
  if (!safeStat(path44))
@@ -409179,16 +409309,16 @@ async function listDeepAgentsTrajectories(root2) {
409179
409309
  }
409180
409310
  function resolveStorePath(root2) {
409181
409311
  if (root2 === undefined)
409182
- return join63(homedir38(), ".deepagents", "sessions.db");
409183
- return root2.endsWith(".db") ? root2 : join63(root2, "sessions.db");
409312
+ return join64(homedir39(), ".deepagents", "sessions.db");
409313
+ return root2.endsWith(".db") ? root2 : join64(root2, "sessions.db");
409184
409314
  }
409185
409315
  var init_list3 = __esm(() => {
409186
409316
  init_listing_shared();
409187
409317
  });
409188
409318
 
409189
409319
  // node_modules/@letta-ai/trajectory/dist/adapters/hermes/list.js
409190
- import { homedir as homedir39 } from "node:os";
409191
- import { join as join64 } from "node:path";
409320
+ import { homedir as homedir40 } from "node:os";
409321
+ import { join as join65 } from "node:path";
409192
409322
  async function listHermesTrajectories(root2) {
409193
409323
  const path44 = resolveStorePath2(root2);
409194
409324
  if (!safeStat(path44))
@@ -409215,8 +409345,8 @@ async function listHermesTrajectories(root2) {
409215
409345
  }
409216
409346
  function resolveStorePath2(root2) {
409217
409347
  if (root2 === undefined)
409218
- return join64(homedir39(), ".hermes", "state.db");
409219
- return root2.endsWith(".db") ? root2 : join64(root2, "state.db");
409348
+ return join65(homedir40(), ".hermes", "state.db");
409349
+ return root2.endsWith(".db") ? root2 : join65(root2, "state.db");
409220
409350
  }
409221
409351
  function numeric2(value) {
409222
409352
  return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : undefined;
@@ -409226,19 +409356,19 @@ var init_list4 = __esm(() => {
409226
409356
  });
409227
409357
 
409228
409358
  // node_modules/@letta-ai/trajectory/dist/adapters/letta-code/list.js
409229
- import { homedir as homedir40 } from "node:os";
409230
- import { join as join65 } from "node:path";
409359
+ import { homedir as homedir41 } from "node:os";
409360
+ import { join as join66 } from "node:path";
409231
409361
  async function listLettaCodeTrajectories(root2) {
409232
- const base2 = root2 ?? join65(homedir40(), ".letta", "transcripts");
409362
+ const base2 = root2 ?? join66(homedir41(), ".letta", "transcripts");
409233
409363
  const items3 = [];
409234
409364
  for (const agent of safeReadDir(base2)) {
409235
409365
  if (!agent.isDirectory)
409236
409366
  continue;
409237
- const agentPath = join65(base2, agent.name);
409367
+ const agentPath = join66(base2, agent.name);
409238
409368
  for (const conversation of safeReadDir(agentPath)) {
409239
409369
  if (!conversation.isDirectory)
409240
409370
  continue;
409241
- const path44 = join65(agentPath, conversation.name, "transcript.jsonl");
409371
+ const path44 = join66(agentPath, conversation.name, "transcript.jsonl");
409242
409372
  const listing = listingFromFile(`${agent.name}/${conversation.name}`, path44);
409243
409373
  if (listing && (listing.sizeBytes ?? 0) > 0)
409244
409374
  items3.push(listing);
@@ -409252,20 +409382,20 @@ var init_list5 = __esm(() => {
409252
409382
 
409253
409383
  // node_modules/@letta-ai/trajectory/dist/adapters/openclaw/list.js
409254
409384
  import { existsSync as existsSync52 } from "node:fs";
409255
- import { homedir as homedir41 } from "node:os";
409256
- import { basename as basename22, join as join66 } from "node:path";
409385
+ import { homedir as homedir42 } from "node:os";
409386
+ import { basename as basename22, join as join67 } from "node:path";
409257
409387
  async function listOpenClawTrajectories(root2) {
409258
409388
  const base2 = root2 ?? defaultStateDir();
409259
409389
  const items3 = [];
409260
- const agentsPath = join66(base2, "agents");
409390
+ const agentsPath = join67(base2, "agents");
409261
409391
  for (const agent of safeReadDir(agentsPath)) {
409262
409392
  if (!agent.isDirectory)
409263
409393
  continue;
409264
- const sessionsPath = join66(agentsPath, agent.name, "sessions");
409394
+ const sessionsPath = join67(agentsPath, agent.name, "sessions");
409265
409395
  for (const entry of safeReadDir(sessionsPath)) {
409266
409396
  if (!entry.isFile || !entry.name.endsWith(".jsonl"))
409267
409397
  continue;
409268
- const path44 = join66(sessionsPath, entry.name);
409398
+ const path44 = join67(sessionsPath, entry.name);
409269
409399
  const listing = listingFromFile(basename22(entry.name, ".jsonl"), path44);
409270
409400
  if (listing)
409271
409401
  items3.push(listing);
@@ -409277,25 +409407,25 @@ function defaultStateDir() {
409277
409407
  const override = process.env.OPENCLAW_STATE_DIR?.trim() || process.env.CLAWDBOT_STATE_DIR?.trim();
409278
409408
  if (override)
409279
409409
  return override;
409280
- const current = join66(homedir41(), ".openclaw");
409410
+ const current = join67(homedir42(), ".openclaw");
409281
409411
  if (existsSync52(current))
409282
409412
  return current;
409283
- return join66(homedir41(), ".clawdbot");
409413
+ return join67(homedir42(), ".clawdbot");
409284
409414
  }
409285
409415
  var init_list6 = __esm(() => {
409286
409416
  init_listing_shared();
409287
409417
  });
409288
409418
 
409289
409419
  // node_modules/@letta-ai/trajectory/dist/adapters/openhands/list.js
409290
- import { homedir as homedir42 } from "node:os";
409291
- import { join as join67 } from "node:path";
409420
+ import { homedir as homedir43 } from "node:os";
409421
+ import { join as join68 } from "node:path";
409292
409422
  async function listOpenHandsTrajectories(root2) {
409293
- const base2 = root2 ?? join67(homedir42(), ".openhands", "sessions");
409423
+ const base2 = root2 ?? join68(homedir43(), ".openhands", "sessions");
409294
409424
  const items3 = [];
409295
409425
  for (const entry of safeReadDir(base2)) {
409296
409426
  if (!entry.isDirectory)
409297
409427
  continue;
409298
- const path44 = join67(base2, entry.name);
409428
+ const path44 = join68(base2, entry.name);
409299
409429
  const facts = safeStat(path44);
409300
409430
  items3.push({
409301
409431
  id: entry.name,
@@ -409720,7 +409850,7 @@ import {
409720
409850
  stat as stat13,
409721
409851
  writeFile as writeFile14
409722
409852
  } from "node:fs/promises";
409723
- import { join as join68 } from "node:path";
409853
+ import { join as join69 } from "node:path";
409724
409854
  function buildReflectionSelectorPrompt(options) {
409725
409855
  const lines = [
409726
409856
  'You are selecting conversation transcripts for memory reflection. The transcript candidates path is available as the `$TRANSCRIPT_PATH` env var — read it via Bash (e.g. `wc -c "$TRANSCRIPT_PATH"`). Note: `$TRANSCRIPT_PATH` only expands in shell commands; Edit file_path is literal and does NOT expand env vars.',
@@ -409754,7 +409884,7 @@ async function collectParentMemoryFiles(memoryDir) {
409754
409884
  return a2.name.localeCompare(b3.name);
409755
409885
  });
409756
409886
  for (const entry of sortedEntries) {
409757
- const entryPath = join68(currentDir, entry.name);
409887
+ const entryPath = join69(currentDir, entry.name);
409758
409888
  const relativePath = relativeDir ? `${relativeDir}/${entry.name}` : entry.name;
409759
409889
  if (entry.isDirectory()) {
409760
409890
  await walk3(entryPath, relativePath);
@@ -410170,17 +410300,17 @@ async function writeState(paths, state) {
410170
410300
  }
410171
410301
  function buildPayloadPath(rootDir, kind) {
410172
410302
  const nonce = Math.random().toString(36).slice(2, 8);
410173
- return join68(rootDir, `payload-${kind}-${nonce}.json`);
410303
+ return join69(rootDir, `payload-${kind}-${nonce}.json`);
410174
410304
  }
410175
410305
  function getAgentTranscriptRoot(agentId) {
410176
- return join68(getTranscriptRoot(), sanitizePathSegment2(agentId));
410306
+ return join69(getTranscriptRoot(), sanitizePathSegment2(agentId));
410177
410307
  }
410178
410308
  function getReflectionTranscriptPaths(agentId, conversationId) {
410179
- const rootDir = join68(getTranscriptRoot(), sanitizePathSegment2(agentId), sanitizePathSegment2(conversationId));
410309
+ const rootDir = join69(getTranscriptRoot(), sanitizePathSegment2(agentId), sanitizePathSegment2(conversationId));
410180
410310
  return {
410181
410311
  rootDir,
410182
- transcriptPath: join68(rootDir, "transcript.jsonl"),
410183
- statePath: join68(rootDir, "state.json")
410312
+ transcriptPath: join69(rootDir, "transcript.jsonl"),
410313
+ statePath: join69(rootDir, "state.json")
410184
410314
  };
410185
410315
  }
410186
410316
  async function appendTranscriptDeltaJsonl(agentId, conversationId, lines) {
@@ -410270,7 +410400,7 @@ async function getTranscriptLastUpdatedAt(paths) {
410270
410400
  }
410271
410401
  }
410272
410402
  async function ensureAgentPayloadRoot(agentId) {
410273
- const root2 = join68(getAgentTranscriptRoot(agentId), "multi-reflection-payloads");
410403
+ const root2 = join69(getAgentTranscriptRoot(agentId), "multi-reflection-payloads");
410274
410404
  await mkdir13(root2, { recursive: true });
410275
410405
  return root2;
410276
410406
  }
@@ -410831,10 +410961,10 @@ var init_post_turn_reflection = __esm(() => {
410831
410961
 
410832
410962
  // src/agent/memory-worktree.ts
410833
410963
  import { execFile as execFileCb4 } from "node:child_process";
410834
- import { randomUUID as randomUUID29 } from "node:crypto";
410964
+ import { randomUUID as randomUUID30 } from "node:crypto";
410835
410965
  import { existsSync as existsSync53 } from "node:fs";
410836
410966
  import { mkdir as mkdir14 } from "node:fs/promises";
410837
- import { dirname as dirname29, isAbsolute as isAbsolute28, join as join69, resolve as resolve36 } from "node:path";
410967
+ import { dirname as dirname29, isAbsolute as isAbsolute28, join as join70, resolve as resolve36 } from "node:path";
410838
410968
  import { promisify as promisify14 } from "node:util";
410839
410969
  async function runGit4(cwd2, args) {
410840
410970
  try {
@@ -410875,7 +411005,7 @@ function normalizeGitPath(path44, cwd2) {
410875
411005
  }
410876
411006
  function buildReflectionWorktreeId(now2 = new Date) {
410877
411007
  const timestamp = now2.toISOString().replace(/[^0-9]/g, "").slice(0, 14);
410878
- return `${timestamp}-${randomUUID29().slice(0, 8)}`;
411008
+ return `${timestamp}-${randomUUID30().slice(0, 8)}`;
410879
411009
  }
410880
411010
  function summarizeReflectionCommitSubject(subject) {
410881
411011
  const summary = subject.trim().replace(/^[a-z]+(?:\([^)]+\))?!?:\s*/i, "").trim();
@@ -410894,8 +411024,8 @@ async function buildReflectionMergeMessage(parentMemoryDir, branchName) {
410894
411024
  async function createReflectionMemoryWorktree(options) {
410895
411025
  const parentMemoryDir = resolve36(options.parentMemoryDir);
410896
411026
  const id2 = buildReflectionWorktreeId(options.now);
410897
- const worktreeBaseDir = join69(dirname29(parentMemoryDir), "memory-worktrees");
410898
- const worktreeDir = join69(worktreeBaseDir, `reflection-${id2}`);
411027
+ const worktreeBaseDir = join70(dirname29(parentMemoryDir), "memory-worktrees");
411028
+ const worktreeDir = join70(worktreeBaseDir, `reflection-${id2}`);
410899
411029
  const branchName = `letta/reflection/${id2}`;
410900
411030
  await mkdir14(worktreeBaseDir, { recursive: true });
410901
411031
  const { stdout: baseHeadOut } = await runGit4(parentMemoryDir, [
@@ -411494,7 +411624,7 @@ var init_reflection_retry = __esm(() => {
411494
411624
  });
411495
411625
 
411496
411626
  // src/telemetry/reflection-threshold-feedback.ts
411497
- import { randomUUID as randomUUID30 } from "node:crypto";
411627
+ import { randomUUID as randomUUID31 } from "node:crypto";
411498
411628
  async function resolveFeedbackApiKey() {
411499
411629
  const settings3 = await settingsManager.getSettingsWithSecureTokens();
411500
411630
  return process.env.LETTA_API_KEY || settings3.env?.LETTA_API_KEY;
@@ -411506,7 +411636,7 @@ function getFeedbackDeviceId() {
411506
411636
  return deviceId;
411507
411637
  }
411508
411638
  } catch {}
411509
- return randomUUID30();
411639
+ return randomUUID31();
411510
411640
  }
411511
411641
  function getAlertDeviceType() {
411512
411642
  switch (process.platform) {
@@ -413885,6 +414015,10 @@ async function drainTurnStreamWithEmission(stream12, buffers, socket, runtime, p
413885
414015
  runtime.turnLifecycle.setRunId(turnLease, maybeRunId);
413886
414016
  turnCorrelation.observeRun(maybeRunId);
413887
414017
  if (!runIdSent) {
414018
+ recordListenerWork(runtime, {
414019
+ runId: maybeRunId,
414020
+ actingUserId: getStreamRequestContext(stream12)?.actingUserId
414021
+ });
413888
414022
  runIdSent = true;
413889
414023
  msgRunIds.push(maybeRunId);
413890
414024
  emitLoopStatusUpdate(socket, runtime, {
@@ -413932,10 +414066,12 @@ var init_turn_stream = __esm(async () => {
413932
414066
  init_debug();
413933
414067
  init_cloud_retry_message();
413934
414068
  init_constants3();
414069
+ init_interrupted_turn_record();
413935
414070
  init_interrupts();
413936
414071
  init_protocol_outbound();
413937
414072
  init_recoverable_notices();
413938
414073
  await __promiseAll([
414074
+ init_message(),
413939
414075
  init_stream(),
413940
414076
  init_recovery()
413941
414077
  ]);
@@ -414245,7 +414381,7 @@ async function handleIncomingMessageInner(msg, socket, runtime, onStatusChange,
414245
414381
  ...turnInput.messages,
414246
414382
  {
414247
414383
  type: "message",
414248
- role: "system",
414384
+ role: "user",
414249
414385
  content: "<system-reminder>The previous response was empty. Please provide a response with either text content or a tool call.</system-reminder>"
414250
414386
  }
414251
414387
  ]);
@@ -415569,7 +415705,7 @@ var init_grep_in_files = __esm(() => {
415569
415705
 
415570
415706
  // src/websocket/listener/file-commands.ts
415571
415707
  import { readdir as readdir10, readFile as readFile21 } from "node:fs/promises";
415572
- import { homedir as homedir43 } from "node:os";
415708
+ import { homedir as homedir44 } from "node:os";
415573
415709
  import path46 from "node:path";
415574
415710
  function trackListenerError3(errorType, error4, context3) {
415575
415711
  trackBoundaryError({
@@ -415589,7 +415725,7 @@ function isWithinOrEqual(parent, child) {
415589
415725
  return relative13 === "" || !relative13.startsWith("..") && !path46.isAbsolute(relative13);
415590
415726
  }
415591
415727
  function getHomeDirectory() {
415592
- return normalizeAbsPath(process.env.HOME || homedir43());
415728
+ return normalizeAbsPath(process.env.HOME || homedir44());
415593
415729
  }
415594
415730
  function isHomeDirectory(absPath) {
415595
415731
  return normalizeAbsPath(absPath) === getHomeDirectory();
@@ -416516,7 +416652,7 @@ __export(exports_custom, {
416516
416652
  });
416517
416653
  import { existsSync as existsSync55 } from "node:fs";
416518
416654
  import { readdir as readdir11, readFile as readFile22 } from "node:fs/promises";
416519
- import { basename as basename24, dirname as dirname30, join as join70 } from "node:path";
416655
+ import { basename as basename24, dirname as dirname30, join as join71 } from "node:path";
416520
416656
  async function getCustomCommands() {
416521
416657
  if (cachedCommands !== null) {
416522
416658
  return cachedCommands;
@@ -416527,7 +416663,7 @@ async function getCustomCommands() {
416527
416663
  function refreshCustomCommands() {
416528
416664
  cachedCommands = null;
416529
416665
  }
416530
- async function discoverCustomCommands(projectPath = join70(process.cwd(), COMMANDS_DIR)) {
416666
+ async function discoverCustomCommands(projectPath = join71(process.cwd(), COMMANDS_DIR)) {
416531
416667
  const commandsById = new Map;
416532
416668
  const userCommands = await discoverFromDirectory(GLOBAL_COMMANDS_DIR, "user");
416533
416669
  for (const cmd of userCommands) {
@@ -416559,7 +416695,7 @@ async function findCommandFiles(currentPath, rootPath, commands, source) {
416559
416695
  try {
416560
416696
  const entries = await readdir11(currentPath, { withFileTypes: true });
416561
416697
  for (const entry of entries) {
416562
- const fullPath = join70(currentPath, entry.name);
416698
+ const fullPath = join71(currentPath, entry.name);
416563
416699
  if (entry.isDirectory()) {
416564
416700
  await findCommandFiles(fullPath, rootPath, commands, source);
416565
416701
  } else if (entry.isFile() && entry.name.endsWith(".md")) {
@@ -416644,7 +416780,7 @@ async function findCustomCommand(commandName) {
416644
416780
  }
416645
416781
  var COMMANDS_DIR = ".commands", GLOBAL_COMMANDS_DIR, cachedCommands = null;
416646
416782
  var init_custom = __esm(() => {
416647
- GLOBAL_COMMANDS_DIR = join70(process.env.HOME || process.env.USERPROFILE || "~", ".letta/commands");
416783
+ GLOBAL_COMMANDS_DIR = join71(process.env.HOME || process.env.USERPROFILE || "~", ".letta/commands");
416648
416784
  });
416649
416785
 
416650
416786
  // src/cli/helpers/doctor-command.ts
@@ -419477,6 +419613,172 @@ var init_process_services = __esm(async () => {
419477
419613
  ]);
419478
419614
  });
419479
419615
 
419616
+ // src/websocket/listener/recover-recorded-turn.ts
419617
+ import { randomUUID as randomUUID32 } from "node:crypto";
419618
+ function scheduleRecordedTurnRecovery(listener, recover = recoverRecordedTurns) {
419619
+ setImmediate(() => {
419620
+ if (listener !== getActiveRuntime() || listener.intentionallyClosed)
419621
+ return;
419622
+ recover(listener).catch((error4) => {
419623
+ debugWarn("recovery", "Recorded restart recovery failed", error4);
419624
+ });
419625
+ });
419626
+ }
419627
+ async function recoverRecordedTurns(listener, deps = {}) {
419628
+ if (!listener.connectionId?.startsWith("conn-") || listener.intentionallyClosed || recovering.has(listener))
419629
+ return;
419630
+ recovering.add(listener);
419631
+ const timer = retryTimers.get(listener);
419632
+ if (timer)
419633
+ clearTimeout(timer);
419634
+ retryTimers.delete(listener);
419635
+ const store3 = deps.store ?? createInterruptedTurnStore();
419636
+ const canRecover = deps.canRecover ?? canRecoverConversation;
419637
+ let deferred2 = false;
419638
+ try {
419639
+ for (const record3 of store3.list()) {
419640
+ const runtime = getOrCreateScopedRuntime(listener, record3.agentId, record3.conversationId);
419641
+ const unchanged = () => runtime.turnLifecycle.kind === "idle" && !listener.intentionallyClosed && store3.read(record3.agentId, record3.conversationId)?.revision === record3.revision;
419642
+ if (runtime.turnLifecycle.kind !== "idle")
419643
+ continue;
419644
+ if (!await canRecover(runtime)) {
419645
+ deferred2 = true;
419646
+ continue;
419647
+ }
419648
+ try {
419649
+ if (record3.teleportId) {
419650
+ const teleport = await (deps.teleportStatus ?? getTeleportStatus)(record3.agentId, record3.conversationId, record3.teleportId);
419651
+ if (!unchanged())
419652
+ continue;
419653
+ if (teleport.status === "completed") {
419654
+ store3.remove(record3.agentId, record3.conversationId);
419655
+ } else if (teleport.status === "failed") {
419656
+ store3.write({ ...record3, teleportId: undefined });
419657
+ deferred2 = true;
419658
+ } else {
419659
+ deferred2 = true;
419660
+ }
419661
+ continue;
419662
+ }
419663
+ const backend3 = deps.backend ?? getBackend();
419664
+ const agent = await backend3.retrieveAgent(record3.agentId);
419665
+ const pending = (await (deps.resume ?? getResumeDataFromBackend)(agent, record3.conversationId, { includeMessageHistory: false })).pendingApprovals;
419666
+ if (!unchanged())
419667
+ continue;
419668
+ let recordedRunId = record3.runId;
419669
+ if (record3.results.length && (!pending.length || pending.some((approval) => !record3.toolCallIds.includes(approval.toolCallId)))) {
419670
+ const stream12 = await backend3.streamConversationMessages(record3.conversationId, {
419671
+ otid: record3.requestOtid,
419672
+ starting_after: 0,
419673
+ ...record3.conversationId === "default" ? { agent_id: record3.agentId } : {}
419674
+ }, { signal: AbortSignal.timeout(5000), maxRetries: 0 });
419675
+ try {
419676
+ for await (const chunk2 of stream12) {
419677
+ if ("run_id" in chunk2 && typeof chunk2.run_id === "string") {
419678
+ recordedRunId = chunk2.run_id;
419679
+ break;
419680
+ }
419681
+ }
419682
+ } finally {
419683
+ stream12.controller.abort();
419684
+ }
419685
+ }
419686
+ if (!pending.length) {
419687
+ const run = recordedRunId ? await backend3.retrieveRun(recordedRunId) : null;
419688
+ if (!unchanged())
419689
+ continue;
419690
+ if (run?.status === "running" || run?.status === "created") {
419691
+ deferred2 = true;
419692
+ continue;
419693
+ }
419694
+ store3.remove(record3.agentId, record3.conversationId);
419695
+ continue;
419696
+ }
419697
+ const owned = [];
419698
+ for (const approval of pending) {
419699
+ if (record3.toolCallIds.includes(approval.toolCallId)) {
419700
+ owned.push(approval);
419701
+ continue;
419702
+ }
419703
+ if (!approval.messageId || !recordedRunId)
419704
+ continue;
419705
+ const messages = await backend3.retrieveMessage(approval.messageId);
419706
+ if (messages.some((message) => ("run_id" in message) && message.run_id === recordedRunId))
419707
+ owned.push(approval);
419708
+ }
419709
+ if (!unchanged())
419710
+ continue;
419711
+ if (!owned.length) {
419712
+ store3.remove(record3.agentId, record3.conversationId);
419713
+ continue;
419714
+ }
419715
+ if (owned.length !== pending.length)
419716
+ continue;
419717
+ if (owned.some((approval) => isInteractiveApprovalTool(approval.toolName)))
419718
+ continue;
419719
+ if (!await canRecover(runtime))
419720
+ continue;
419721
+ if (!unchanged())
419722
+ continue;
419723
+ const approvals = recordedToolResults(record3, owned.map((approval) => approval.toolCallId));
419724
+ const continuation = owned.every((approval) => record3.toolCallIds.includes(approval.toolCallId)) ? record3 : {
419725
+ ...record3,
419726
+ toolCallIds: owned.map((approval) => approval.toolCallId),
419727
+ results: approvals,
419728
+ requestOtid: randomUUID32()
419729
+ };
419730
+ store3.write(continuation);
419731
+ runtime.pendingInterruptedResults = null;
419732
+ runtime.pendingInterruptedContext = null;
419733
+ runtime.pendingInterruptedToolCallIds = null;
419734
+ (deps.setCwd ?? setConversationWorkingDirectory)(listener, record3.agentId, record3.conversationId, record3.workingDirectory);
419735
+ (deps.processTurn ?? handleIncomingMessage)({
419736
+ type: "message",
419737
+ agentId: record3.agentId,
419738
+ conversationId: record3.conversationId,
419739
+ actingUserId: record3.actingUserId,
419740
+ messages: [
419741
+ { type: "approval", approvals, otid: continuation.requestOtid }
419742
+ ]
419743
+ }, getOrCreateProcessTransport(listener), runtime).catch((error4) => {
419744
+ debugWarn("recovery", "Recorded continuation failed; retaining local work", error4);
419745
+ });
419746
+ } catch (error4) {
419747
+ deferred2 = true;
419748
+ debugWarn("recovery", "Recorded turn recovery failed; retaining local work", error4);
419749
+ }
419750
+ }
419751
+ } finally {
419752
+ recovering.delete(listener);
419753
+ if (deferred2 && !listener.intentionallyClosed) {
419754
+ const timer2 = setTimeout(() => {
419755
+ recoverRecordedTurns(listener, deps);
419756
+ }, 5000);
419757
+ timer2.unref();
419758
+ retryTimers.set(listener, timer2);
419759
+ }
419760
+ }
419761
+ }
419762
+ var recovering, retryTimers;
419763
+ var init_recover_recorded_turn = __esm(async () => {
419764
+ init_check_approval();
419765
+ init_backend2();
419766
+ init_environments2();
419767
+ init_interactive_policy();
419768
+ init_debug();
419769
+ init_connection();
419770
+ init_cwd();
419771
+ init_interrupted_turn_record();
419772
+ init_recovery_ownership();
419773
+ init_runtime();
419774
+ await __promiseAll([
419775
+ init_conversation_runtime(),
419776
+ init_turn()
419777
+ ]);
419778
+ recovering = new WeakSet;
419779
+ retryTimers = new WeakMap;
419780
+ });
419781
+
419480
419782
  // src/websocket/listener/recovery-sync.ts
419481
419783
  function isBackendNotFoundError2(error4) {
419482
419784
  return error4 instanceof APIError && (error4.status === 404 || error4.status === 422) || error4 instanceof Error && error4.name === "LocalBackendNotFoundError";
@@ -419846,6 +420148,7 @@ async function startConnectedListenerRuntime(runtime, transport, opts, processQu
419846
420148
  }
419847
420149
  if (options.startProcessServices === false)
419848
420150
  return;
420151
+ scheduleRecordedTurnRecovery(runtime, options.recoverRecordedWork);
419849
420152
  const processTransport = getOrCreateProcessTransport(runtime);
419850
420153
  for (const conversationRuntime of runtime.conversationRuntimes.values()) {
419851
420154
  if (conversationRuntime.queueRuntime?.isEmpty === false) {
@@ -420304,6 +420607,7 @@ var init_lifecycle = __esm(async () => {
420304
420607
  init_mod_adapter2(),
420305
420608
  init_process_services(),
420306
420609
  init_queue(),
420610
+ init_recover_recorded_turn(),
420307
420611
  init_sync_replay(),
420308
420612
  init_warmup()
420309
420613
  ]);
@@ -420742,7 +421046,7 @@ var init_listen_client = __esm(async () => {
420742
421046
  });
420743
421047
 
420744
421048
  // src/websocket/app-server-auth.ts
420745
- import { createHash as createHash9, createHmac, timingSafeEqual } from "node:crypto";
421049
+ import { createHash as createHash10, createHmac, timingSafeEqual } from "node:crypto";
420746
421050
  import { readFile as readFile23 } from "node:fs/promises";
420747
421051
  import { isIP as isIP2 } from "node:net";
420748
421052
  import { isAbsolute as isAbsolute29 } from "node:path";
@@ -421025,7 +421329,7 @@ function sha256DigestArg(flagName, value) {
421025
421329
  return Buffer.from(trimmed, "hex");
421026
421330
  }
421027
421331
  function sha256Digest(value) {
421028
- return createHash9("sha256").update(value).digest();
421332
+ return createHash10("sha256").update(value).digest();
421029
421333
  }
421030
421334
  function unauthorized(message) {
421031
421335
  return { statusCode: 401, message };
@@ -421516,7 +421820,7 @@ function createToolLifecycleTracker(onEvent) {
421516
421820
  }
421517
421821
 
421518
421822
  // src/websocket/app-server-openai-turn.ts
421519
- import { randomUUID as randomUUID31 } from "node:crypto";
421823
+ import { randomUUID as randomUUID33 } from "node:crypto";
421520
421824
  function runBridgeTurn(params) {
421521
421825
  return runTurnImpl(params);
421522
421826
  }
@@ -421535,7 +421839,7 @@ async function ensureListenerRuntime(onLog) {
421535
421839
  if (active && !active.intentionallyClosed)
421536
421840
  return active;
421537
421841
  bridgeRuntimeStart ??= startLocalChannelListener({
421538
- connectionId: `openai-api-${randomUUID31()}`,
421842
+ connectionId: `openai-api-${randomUUID33()}`,
421539
421843
  deviceId: settingsManager.getOrCreateDeviceId(),
421540
421844
  connectionName: "openai-api",
421541
421845
  onConnected: () => {},
@@ -421744,11 +422048,11 @@ var init_app_server_openai_turn = __esm(async () => {
421744
422048
  });
421745
422049
 
421746
422050
  // src/websocket/app-server-openai-responses.ts
421747
- import { randomUUID as randomUUID32 } from "node:crypto";
422051
+ import { randomUUID as randomUUID34 } from "node:crypto";
421748
422052
  function createStoredResponseId(state) {
421749
422053
  const cursor = Buffer.from(JSON.stringify({
421750
422054
  version: 1,
421751
- nonce: randomUUID32(),
422055
+ nonce: randomUUID34(),
421752
422056
  agent_id: state.agentId,
421753
422057
  conversation_id: state.conversationId
421754
422058
  })).toString("base64url");
@@ -421793,7 +422097,7 @@ function toBridgeMessages(messages, stateful) {
421793
422097
  return { messages: [], correlationOtid: null };
421794
422098
  }
421795
422099
  if (stateful) {
421796
- const otid = randomUUID32();
422100
+ const otid = randomUUID34();
421797
422101
  return {
421798
422102
  messages: [{ role: "user", content: lastUserContent, otid }],
421799
422103
  correlationOtid: otid
@@ -421815,7 +422119,7 @@ function toBridgeMessages(messages, stateful) {
421815
422119
  bridgeMessages.push({
421816
422120
  role: message.role,
421817
422121
  content,
421818
- otid: randomUUID32()
422122
+ otid: randomUUID34()
421819
422123
  });
421820
422124
  }
421821
422125
  return {
@@ -421947,7 +422251,7 @@ class ResponseOutputBuilder {
421947
422251
  this.finishText();
421948
422252
  const result2 = {
421949
422253
  type: "function_call_output",
421950
- id: `fco_${randomUUID32()}`,
422254
+ id: `fco_${randomUUID34()}`,
421951
422255
  call_id: event.tool_call_id,
421952
422256
  output: [{ type: "input_text", text: event.output }],
421953
422257
  status: event.success ? "completed" : "incomplete"
@@ -422032,7 +422336,7 @@ class ResponseOutputBuilder {
422032
422336
  return this.message;
422033
422337
  const item = {
422034
422338
  type: "message",
422035
- id: `msg_${randomUUID32()}`,
422339
+ id: `msg_${randomUUID34()}`,
422036
422340
  status: "in_progress",
422037
422341
  role: "assistant",
422038
422342
  content: [{ type: "output_text", text: "", annotations: [] }]
@@ -422059,7 +422363,7 @@ class ResponseOutputBuilder {
422059
422363
  return this.reasoning;
422060
422364
  const item = {
422061
422365
  type: "reasoning",
422062
- id: `rs_${randomUUID32()}`,
422366
+ id: `rs_${randomUUID34()}`,
422063
422367
  status: "in_progress",
422064
422368
  summary: [{ type: "summary_text", text: "" }]
422065
422369
  };
@@ -422090,7 +422394,7 @@ class ResponseOutputBuilder {
422090
422394
  }
422091
422395
  const item = {
422092
422396
  type: "function_call",
422093
- id: `fc_${randomUUID32()}`,
422397
+ id: `fc_${randomUUID34()}`,
422094
422398
  call_id: callId,
422095
422399
  name,
422096
422400
  arguments: "",
@@ -422195,7 +422499,7 @@ async function handleResponses(request, response, options) {
422195
422499
  sendOpenAiError(response, 500, "failed to create a conversation for this response", "server_error");
422196
422500
  return;
422197
422501
  }
422198
- const responseId = body3.store === true ? createStoredResponseId({ agentId: agent.id, conversationId }) : `resp_${randomUUID32()}`;
422502
+ const responseId = body3.store === true ? createStoredResponseId({ agentId: agent.id, conversationId }) : `resp_${randomUUID34()}`;
422199
422503
  const createdAt = Math.floor(Date.now() / 1000);
422200
422504
  let sequenceNumber = 0;
422201
422505
  let clientClosed = false;
@@ -422285,7 +422589,7 @@ var init_app_server_openai_responses = __esm(async () => {
422285
422589
  });
422286
422590
 
422287
422591
  // src/websocket/app-server-openai.ts
422288
- import { randomUUID as randomUUID33 } from "node:crypto";
422592
+ import { randomUUID as randomUUID35 } from "node:crypto";
422289
422593
  function isOpenAiCompatPath(pathname) {
422290
422594
  return pathname === MODELS_PATH || pathname === CHAT_COMPLETIONS_PATH || pathname === RESPONSES_PATH;
422291
422595
  }
@@ -422354,7 +422658,7 @@ async function handleChatCompletions(request, response, options) {
422354
422658
  turnMessages.push({
422355
422659
  role: "user",
422356
422660
  content: userContent,
422357
- otid: randomUUID33()
422661
+ otid: randomUUID35()
422358
422662
  });
422359
422663
  } else {
422360
422664
  for (const message of body3.messages) {
@@ -422371,7 +422675,7 @@ async function handleChatCompletions(request, response, options) {
422371
422675
  }
422372
422676
  if (content.length === 0)
422373
422677
  continue;
422374
- turnMessages.push({ role: message.role, content, otid: randomUUID33() });
422678
+ turnMessages.push({ role: message.role, content, otid: randomUUID35() });
422375
422679
  }
422376
422680
  }
422377
422681
  correlationOtid = turnMessages.at(-1)?.otid ?? null;
@@ -422380,7 +422684,7 @@ async function handleChatCompletions(request, response, options) {
422380
422684
  return;
422381
422685
  }
422382
422686
  }
422383
- const completionId = `chatcmpl-${randomUUID33()}`;
422687
+ const completionId = `chatcmpl-${randomUUID35()}`;
422384
422688
  const created = Math.floor(Date.now() / 1000);
422385
422689
  const streaming3 = body3.stream === true;
422386
422690
  let clientClosed = false;
@@ -423683,20 +423987,20 @@ var init_listen = __esm(async () => {
423683
423987
  });
423684
423988
 
423685
423989
  // src/backend/local/transcript-migration.ts
423686
- import { randomUUID as randomUUID34 } from "node:crypto";
423990
+ import { randomUUID as randomUUID36 } from "node:crypto";
423687
423991
  import {
423688
423992
  copyFileSync as copyFileSync3,
423689
423993
  existsSync as existsSync56,
423690
- mkdirSync as mkdirSync38,
423691
- readdirSync as readdirSync20,
423692
- readFileSync as readFileSync37,
423693
- writeFileSync as writeFileSync28
423994
+ mkdirSync as mkdirSync39,
423995
+ readdirSync as readdirSync21,
423996
+ readFileSync as readFileSync38,
423997
+ writeFileSync as writeFileSync29
423694
423998
  } from "node:fs";
423695
- import { join as join71 } from "node:path";
423999
+ import { join as join72 } from "node:path";
423696
424000
  function readJsonl(path48) {
423697
424001
  if (!existsSync56(path48))
423698
424002
  return [];
423699
- return readFileSync37(path48, "utf8").split(`
424003
+ return readFileSync38(path48, "utf8").split(`
423700
424004
  `).filter((line) => line.trim().length > 0).map((line) => JSON.parse(line));
423701
424005
  }
423702
424006
  function isLegacyUiMessage(value) {
@@ -423706,7 +424010,7 @@ function isPiLocalMessage(value) {
423706
424010
  return isRecord(value) && typeof value.id === "string" && (value.role === "user" || value.role === "assistant" || value.role === "toolResult") && Object.hasOwn(value, "content");
423707
424011
  }
423708
424012
  function writeJsonl(path48, items3) {
423709
- writeFileSync28(path48, `${items3.map((item) => JSON.stringify(item)).join(`
424013
+ writeFileSync29(path48, `${items3.map((item) => JSON.stringify(item)).join(`
423710
424014
  `)}
423711
424015
  `);
423712
424016
  }
@@ -423723,7 +424027,7 @@ function writeSessionEntryJsonl(path48, messages, input) {
423723
424027
  ...messages.map((message) => {
423724
424028
  const entry = {
423725
424029
  type: "message",
423726
- id: randomUUID34().slice(0, 8),
424030
+ id: randomUUID36().slice(0, 8),
423727
424031
  parentId,
423728
424032
  timestamp: message.metadata?.created_at ?? new Date(message.timestamp).toISOString(),
423729
424033
  message
@@ -423975,7 +424279,7 @@ function convertMessages4(messages, mode, nextId2) {
423975
424279
  }
423976
424280
  function migrateLocalBackendTranscripts(input) {
423977
424281
  const storageDir = input.storageDir;
423978
- const conversationsDir = join71(storageDir, "conversations");
424282
+ const conversationsDir = join72(storageDir, "conversations");
423979
424283
  const result2 = {
423980
424284
  storageDir,
423981
424285
  converted: [],
@@ -423984,14 +424288,14 @@ function migrateLocalBackendTranscripts(input) {
423984
424288
  };
423985
424289
  if (!existsSync56(conversationsDir))
423986
424290
  return result2;
423987
- for (const name of readdirSync20(conversationsDir)) {
423988
- const conversationDir = join71(conversationsDir, name);
423989
- const messagesPath = join71(conversationDir, "messages.jsonl");
423990
- const manifestPath = join71(conversationDir, "manifest.json");
424291
+ for (const name of readdirSync21(conversationsDir)) {
424292
+ const conversationDir = join72(conversationsDir, name);
424293
+ const messagesPath = join72(conversationDir, "messages.jsonl");
424294
+ const manifestPath = join72(conversationDir, "manifest.json");
423991
424295
  const hasManifest = existsSync56(manifestPath);
423992
424296
  const existingManifest = hasManifest ? (() => {
423993
424297
  try {
423994
- return JSON.parse(readFileSync37(manifestPath, "utf8"));
424298
+ return JSON.parse(readFileSync38(manifestPath, "utf8"));
423995
424299
  } catch {
423996
424300
  return;
423997
424301
  }
@@ -424006,8 +424310,8 @@ function migrateLocalBackendTranscripts(input) {
424006
424310
  if (legacyMessages.length === 0) {
424007
424311
  result2.skipped.push({ conversationDir, reason: "empty" });
424008
424312
  if (!input.dryRun) {
424009
- mkdirSync38(conversationDir, { recursive: true });
424010
- writeFileSync28(manifestPath, `${JSON.stringify(manifest({}), null, 2)}
424313
+ mkdirSync39(conversationDir, { recursive: true });
424314
+ writeFileSync29(manifestPath, `${JSON.stringify(manifest({}), null, 2)}
424011
424315
  `);
424012
424316
  }
424013
424317
  continue;
@@ -424030,11 +424334,11 @@ function migrateLocalBackendTranscripts(input) {
424030
424334
  const backupPath = `${messagesPath}.pre-pi-backup-${timestampSuffix()}`;
424031
424335
  if (!input.dryRun) {
424032
424336
  copyFileSync3(messagesPath, backupPath);
424033
- const conversationPath = join71(conversationDir, "conversation.json");
424337
+ const conversationPath = join72(conversationDir, "conversation.json");
424034
424338
  let conversation;
424035
424339
  if (existsSync56(conversationPath)) {
424036
424340
  try {
424037
- conversation = JSON.parse(readFileSync37(conversationPath, "utf8"));
424341
+ conversation = JSON.parse(readFileSync38(conversationPath, "utf8"));
424038
424342
  } catch {
424039
424343
  conversation = undefined;
424040
424344
  }
@@ -424060,12 +424364,12 @@ function migrateLocalBackendTranscripts(input) {
424060
424364
  }
424061
424365
  }
424062
424366
  conversation.in_context_message_ids = remapped;
424063
- writeFileSync28(conversationPath, `${JSON.stringify(conversation, null, 2)}
424367
+ writeFileSync29(conversationPath, `${JSON.stringify(conversation, null, 2)}
424064
424368
  `);
424065
424369
  }
424066
424370
  } catch {}
424067
424371
  }
424068
- writeFileSync28(manifestPath, `${JSON.stringify(manifest({
424372
+ writeFileSync29(manifestPath, `${JSON.stringify(manifest({
424069
424373
  backupPath,
424070
424374
  migratedFrom: repairVersioned ? hasLegacyUiRows ? "versioned-pi-transcript-with-legacy-ui-message-rows" : "versioned-pi-ai-message-jsonl" : undefined
424071
424375
  }), null, 2)}
@@ -440989,12 +441293,12 @@ var init_mcp_client = __esm(() => {
440989
441293
  init_streamableHttp();
440990
441294
  DEFAULT_CLIENT_INFO = {
440991
441295
  name: "letta-code",
440992
- version: "0.32.9"
441296
+ version: "0.32.10"
440993
441297
  };
440994
441298
  });
440995
441299
 
440996
441300
  // src/mcp-oauth.ts
440997
- import { createHash as createHash10, randomBytes as randomBytes2 } from "node:crypto";
441301
+ import { createHash as createHash11, randomBytes as randomBytes2 } from "node:crypto";
440998
441302
  import { createServer as createServer3 } from "node:http";
440999
441303
  async function clearMcpOAuthCredentials(agentId, serverName, serverUrl) {
441000
441304
  return deleteSecretValue(oauthSecretName(agentId, serverName, serverUrl));
@@ -441235,7 +441539,7 @@ async function openSystemBrowser(url2) {
441235
441539
  } catch {}
441236
441540
  }
441237
441541
  function oauthSecretName(agentId, serverName, serverUrl) {
441238
- const digest = createHash10("sha256").update(`${agentId}\x00${serverName}\x00${serverUrl}`).digest("hex").slice(0, 32);
441542
+ const digest = createHash11("sha256").update(`${agentId}\x00${serverName}\x00${serverUrl}`).digest("hex").slice(0, 32);
441239
441543
  return `mcp-oauth-${digest}`;
441240
441544
  }
441241
441545
  async function loadState(secretName) {
@@ -442223,9 +442527,9 @@ var init_memory_tokens = __esm(() => {
442223
442527
  });
442224
442528
 
442225
442529
  // src/cli/subcommands/memory.ts
442226
- import { cpSync, existsSync as existsSync57, mkdirSync as mkdirSync39, rmSync as rmSync13, statSync as statSync19 } from "node:fs";
442530
+ import { cpSync, existsSync as existsSync57, mkdirSync as mkdirSync40, rmSync as rmSync14, statSync as statSync19 } from "node:fs";
442227
442531
  import { readdir as readdir12 } from "node:fs/promises";
442228
- import { dirname as dirname31, join as join72 } from "node:path";
442532
+ import { dirname as dirname31, join as join73 } from "node:path";
442229
442533
  import { parseArgs as parseArgs11 } from "node:util";
442230
442534
  function printUsage8() {
442231
442535
  console.log(`
@@ -442295,7 +442599,7 @@ async function listBackups(agentId) {
442295
442599
  continue;
442296
442600
  if (!entry.name.startsWith("memory-backup-"))
442297
442601
  continue;
442298
- const path48 = join72(agentRoot, entry.name);
442602
+ const path48 = join73(agentRoot, entry.name);
442299
442603
  let createdAt = null;
442300
442604
  try {
442301
442605
  const stat16 = statSync19(path48);
@@ -442312,7 +442616,7 @@ function resolveBackupPath(agentId, from) {
442312
442616
  if (from.startsWith("/") || /^[A-Za-z]:[/\\]/.test(from)) {
442313
442617
  return from;
442314
442618
  }
442315
- return join72(getAgentRoot(agentId), from);
442619
+ return join73(getAgentRoot(agentId), from);
442316
442620
  }
442317
442621
  async function runMemorySubcommand(argv) {
442318
442622
  let parsed;
@@ -442395,7 +442699,7 @@ async function runMemorySubcommand(argv) {
442395
442699
  }
442396
442700
  const agentRoot = getAgentRoot(agentId);
442397
442701
  const backupName = `memory-backup-${formatBackupTimestamp()}`;
442398
- const backupPath = join72(agentRoot, backupName);
442702
+ const backupPath = join73(agentRoot, backupName);
442399
442703
  if (existsSync57(backupPath)) {
442400
442704
  console.error(`Backup already exists at ${backupPath}`);
442401
442705
  return 1;
@@ -442430,7 +442734,7 @@ async function runMemorySubcommand(argv) {
442430
442734
  return 1;
442431
442735
  }
442432
442736
  const root2 = getMemoryRoot(agentId);
442433
- rmSync13(root2, { recursive: true, force: true });
442737
+ rmSync14(root2, { recursive: true, force: true });
442434
442738
  cpSync(backupPath, root2, { recursive: true });
442435
442739
  console.log(JSON.stringify({ restoredFrom: backupPath }, null, 2));
442436
442740
  return 0;
@@ -442459,7 +442763,7 @@ async function runMemorySubcommand(argv) {
442459
442763
  return 1;
442460
442764
  }
442461
442765
  } else {
442462
- mkdirSync39(out, { recursive: true });
442766
+ mkdirSync40(out, { recursive: true });
442463
442767
  }
442464
442768
  cpSync(root2, out, { recursive: true });
442465
442769
  console.log(JSON.stringify({ exportedFrom: root2, exportedTo: out, agentId }, null, 2));
@@ -442494,13 +442798,13 @@ var init_memory7 = __esm(() => {
442494
442798
  });
442495
442799
 
442496
442800
  // src/backend/local/transcript-search.ts
442497
- import { existsSync as existsSync58, readdirSync as readdirSync21, readFileSync as readFileSync38, statSync as statSync20 } from "node:fs";
442498
- import { join as join73 } from "node:path";
442801
+ import { existsSync as existsSync58, readdirSync as readdirSync22, readFileSync as readFileSync39, statSync as statSync20 } from "node:fs";
442802
+ import { join as join74 } from "node:path";
442499
442803
  function readJsonFile3(path48) {
442500
442804
  if (!existsSync58(path48))
442501
442805
  return;
442502
442806
  try {
442503
- return JSON.parse(readFileSync38(path48, "utf8"));
442807
+ return JSON.parse(readFileSync39(path48, "utf8"));
442504
442808
  } catch {
442505
442809
  return;
442506
442810
  }
@@ -442509,7 +442813,7 @@ function readJsonlFile2(path48) {
442509
442813
  if (!existsSync58(path48))
442510
442814
  return [];
442511
442815
  try {
442512
- return readFileSync38(path48, "utf8").split(`
442816
+ return readFileSync39(path48, "utf8").split(`
442513
442817
  `).filter((line) => line.trim().length > 0).map((line) => JSON.parse(line));
442514
442818
  } catch {
442515
442819
  return [];
@@ -442716,11 +443020,11 @@ function collectConversationMessages(input) {
442716
443020
  return [];
442717
443021
  if (input.conversationId && conversation.id !== input.conversationId)
442718
443022
  return [];
442719
- const messagesPath = join73(conversationDir, "messages.jsonl");
443023
+ const messagesPath = join74(conversationDir, "messages.jsonl");
442720
443024
  const rows = readJsonlFile2(messagesPath);
442721
443025
  if (rows.length === 0)
442722
443026
  return [];
442723
- const manifest2 = readJsonFile3(join73(conversationDir, "manifest.json"));
443027
+ const manifest2 = readJsonFile3(join74(conversationDir, "manifest.json"));
442724
443028
  const format5 = transcriptFormat(manifest2, rows);
442725
443029
  if (!format5)
442726
443030
  return [];
@@ -442741,11 +443045,11 @@ function collectConversationMessages(input) {
442741
443045
  });
442742
443046
  }
442743
443047
  function conversationDirectories(storageDir) {
442744
- const conversationsDir = join73(storageDir, "conversations");
443048
+ const conversationsDir = join74(storageDir, "conversations");
442745
443049
  if (!existsSync58(conversationsDir))
442746
443050
  return [];
442747
443051
  try {
442748
- return readdirSync21(conversationsDir).map((entry) => join73(conversationsDir, entry)).filter((entryPath) => statSync20(entryPath).isDirectory());
443052
+ return readdirSync22(conversationsDir).map((entry) => join74(conversationsDir, entry)).filter((entryPath) => statSync20(entryPath).isDirectory());
442749
443053
  } catch {
442750
443054
  return [];
442751
443055
  }
@@ -442769,7 +443073,7 @@ function searchLocalTranscriptMessages(storageDir, body3) {
442769
443073
  const endDate = typeof body3.end_date === "string" ? body3.end_date : undefined;
442770
443074
  const includeHidden = body3.include_hidden === true;
442771
443075
  const records = conversationDirectories(storageDir).flatMap((conversationDir) => {
442772
- const conversation = conversationSearchRecord(readJsonFile3(join73(conversationDir, "conversation.json")));
443076
+ const conversation = conversationSearchRecord(readJsonFile3(join74(conversationDir, "conversation.json")));
442773
443077
  if (!conversation)
442774
443078
  return [];
442775
443079
  if (conversation.hidden && !includeHidden)
@@ -443575,13 +443879,13 @@ import {
443575
443879
  copyFileSync as copyFileSync4,
443576
443880
  existsSync as existsSync59,
443577
443881
  lstatSync as lstatSync3,
443578
- mkdirSync as mkdirSync40,
443882
+ mkdirSync as mkdirSync41,
443579
443883
  mkdtempSync as mkdtempSync4,
443580
- readdirSync as readdirSync22,
443581
- readFileSync as readFileSync39,
443582
- renameSync as renameSync7,
443583
- rmSync as rmSync14,
443584
- writeFileSync as writeFileSync29
443884
+ readdirSync as readdirSync23,
443885
+ readFileSync as readFileSync40,
443886
+ renameSync as renameSync8,
443887
+ rmSync as rmSync15,
443888
+ writeFileSync as writeFileSync30
443585
443889
  } from "node:fs";
443586
443890
  import { tmpdir as tmpdir10 } from "node:os";
443587
443891
  import path48 from "node:path";
@@ -443597,7 +443901,7 @@ function isPathInsideOrEqual2(childPath, parentPath) {
443597
443901
  function readPackageJson(packageJsonPath) {
443598
443902
  let parsed;
443599
443903
  try {
443600
- parsed = JSON.parse(readFileSync39(packageJsonPath, "utf8"));
443904
+ parsed = JSON.parse(readFileSync40(packageJsonPath, "utf8"));
443601
443905
  } catch (error5) {
443602
443906
  throw new Error(`Could not read package.json: ${error5 instanceof Error ? error5.message : String(error5)}`);
443603
443907
  }
@@ -443717,8 +444021,8 @@ function validatePackageSource(packageDirectory) {
443717
444021
  };
443718
444022
  }
443719
444023
  function copyPackageDirectory(sourceRoot, targetRoot) {
443720
- mkdirSync40(targetRoot, { recursive: true });
443721
- for (const entry of readdirSync22(sourceRoot, { withFileTypes: true })) {
444024
+ mkdirSync41(targetRoot, { recursive: true });
444025
+ for (const entry of readdirSync23(sourceRoot, { withFileTypes: true })) {
443722
444026
  if (SKIPPED_PACKAGE_COPY_NAMES.has(entry.name))
443723
444027
  continue;
443724
444028
  const sourcePath = path48.join(sourceRoot, entry.name);
@@ -443732,7 +444036,7 @@ function copyPackageDirectory(sourceRoot, targetRoot) {
443732
444036
  continue;
443733
444037
  }
443734
444038
  if (stats.isFile()) {
443735
- mkdirSync40(path48.dirname(targetPath), { recursive: true });
444039
+ mkdirSync41(path48.dirname(targetPath), { recursive: true });
443736
444040
  copyFileSync4(sourcePath, targetPath);
443737
444041
  continue;
443738
444042
  }
@@ -443750,7 +444054,7 @@ function shouldSkipDependencyPath(relativeParts, installedPackageName) {
443750
444054
  function copyDependencyDirectoryFiltered(params) {
443751
444055
  let copied = false;
443752
444056
  const relativeParts = params.relativeParts ?? [];
443753
- for (const entry of readdirSync22(params.sourceRoot, { withFileTypes: true })) {
444057
+ for (const entry of readdirSync23(params.sourceRoot, { withFileTypes: true })) {
443754
444058
  const nextRelativeParts = [...relativeParts, entry.name];
443755
444059
  if (shouldSkipDependencyPath(nextRelativeParts, params.installedPackageName)) {
443756
444060
  continue;
@@ -443772,7 +444076,7 @@ function copyDependencyDirectoryFiltered(params) {
443772
444076
  continue;
443773
444077
  }
443774
444078
  if (stats.isFile()) {
443775
- mkdirSync40(path48.dirname(targetPath), { recursive: true });
444079
+ mkdirSync41(path48.dirname(targetPath), { recursive: true });
443776
444080
  copyFileSync4(sourcePath, targetPath);
443777
444081
  copied = true;
443778
444082
  continue;
@@ -443801,26 +444105,26 @@ function copyPackageInternalNodeModules(params) {
443801
444105
  }
443802
444106
  function restoreRegistry(registryPath, previousContents) {
443803
444107
  if (previousContents === null) {
443804
- rmSync14(registryPath, { force: true });
444108
+ rmSync15(registryPath, { force: true });
443805
444109
  return;
443806
444110
  }
443807
- mkdirSync40(path48.dirname(registryPath), { recursive: true });
443808
- writeFileSync29(registryPath, previousContents);
444111
+ mkdirSync41(path48.dirname(registryPath), { recursive: true });
444112
+ writeFileSync30(registryPath, previousContents);
443809
444113
  }
443810
444114
  function removeIfExists(targetPath) {
443811
444115
  if (!targetPath)
443812
444116
  return;
443813
- rmSync14(targetPath, { force: true, recursive: true });
444117
+ rmSync15(targetPath, { force: true, recursive: true });
443814
444118
  }
443815
444119
  function restoreDestination(params) {
443816
- rmSync14(params.destinationRoot, { force: true, recursive: true });
444120
+ rmSync15(params.destinationRoot, { force: true, recursive: true });
443817
444121
  if (params.backupRoot && existsSync59(params.backupRoot)) {
443818
- renameSync7(params.backupRoot, params.destinationRoot);
444122
+ renameSync8(params.backupRoot, params.destinationRoot);
443819
444123
  }
443820
444124
  }
443821
444125
  function restoreDestinationIfNeeded(params) {
443822
444126
  if (!params.backupRoot || !existsSync59(params.backupRoot)) {
443823
- rmSync14(params.destinationRoot, { force: true, recursive: true });
444127
+ rmSync15(params.destinationRoot, { force: true, recursive: true });
443824
444128
  return;
443825
444129
  }
443826
444130
  restoreDestination(params);
@@ -443828,7 +444132,7 @@ function restoreDestinationIfNeeded(params) {
443828
444132
  function makeSiblingTempDirectory(destinationRoot, label) {
443829
444133
  const parent = path48.dirname(destinationRoot);
443830
444134
  const baseName = path48.basename(destinationRoot).replace(/[^a-zA-Z0-9._-]/g, "-");
443831
- mkdirSync40(parent, { recursive: true });
444135
+ mkdirSync41(parent, { recursive: true });
443832
444136
  return mkdtempSync4(path48.join(parent, `.${baseName}.${label}-`));
443833
444137
  }
443834
444138
  function installPreparedManagedModPackage(params) {
@@ -443862,11 +444166,11 @@ function installPreparedManagedModPackage(params) {
443862
444166
  }
443863
444167
  if (existsSync59(destinationRoot)) {
443864
444168
  backupRoot = makeSiblingTempDirectory(destinationRoot, "backup");
443865
- rmSync14(backupRoot, { force: true, recursive: true });
443866
- renameSync7(destinationRoot, backupRoot);
444169
+ rmSync15(backupRoot, { force: true, recursive: true });
444170
+ renameSync8(destinationRoot, backupRoot);
443867
444171
  destinationNeedsRollback = true;
443868
444172
  }
443869
- renameSync7(stagingRoot, destinationRoot);
444173
+ renameSync8(stagingRoot, destinationRoot);
443870
444174
  destinationNeedsRollback = true;
443871
444175
  stagingRoot = null;
443872
444176
  try {
@@ -443926,7 +444230,7 @@ function getNpmInstallArgs(installSpec) {
443926
444230
  ];
443927
444231
  }
443928
444232
  function writeNpmInstallManifest(tempRoot) {
443929
- writeFileSync29(path48.join(tempRoot, "package.json"), `${JSON.stringify({
444233
+ writeFileSync30(path48.join(tempRoot, "package.json"), `${JSON.stringify({
443930
444234
  private: true,
443931
444235
  name: "letta-managed-mod-install"
443932
444236
  }, null, 2)}
@@ -444165,7 +444469,7 @@ function inferCompatibilityModEntries(packageDirectory) {
444165
444469
  throw new Error(`Package mods directory must not be a symlink: mods`);
444166
444470
  }
444167
444471
  if (stats.isDirectory()) {
444168
- const entries = readdirSync22(modsDirectory, { withFileTypes: true }).filter((entry) => entry.isFile() && isModFileExtension(path48.extname(entry.name))).map((entry) => `mods/${entry.name}`).sort();
444472
+ const entries = readdirSync23(modsDirectory, { withFileTypes: true }).filter((entry) => entry.isFile() && isModFileExtension(path48.extname(entry.name))).map((entry) => `mods/${entry.name}`).sort();
444169
444473
  if (entries.length > 0)
444170
444474
  return entries;
444171
444475
  }
@@ -444200,7 +444504,7 @@ function getPackageVersionForGitPackage(params) {
444200
444504
  }
444201
444505
  function writeCompatibilityPackageManifest(params) {
444202
444506
  const packageJsonPath = path48.join(params.packageDirectory, "package.json");
444203
- writeFileSync29(packageJsonPath, `${JSON.stringify({
444507
+ writeFileSync30(packageJsonPath, `${JSON.stringify({
444204
444508
  ...params.packageJson ?? {},
444205
444509
  name: params.packageName,
444206
444510
  version: params.version,
@@ -444313,7 +444617,7 @@ async function installNpmManagedModPackage(params) {
444313
444617
  packageDirectory
444314
444618
  });
444315
444619
  } finally {
444316
- rmSync14(tempRoot, { force: true, recursive: true });
444620
+ rmSync15(tempRoot, { force: true, recursive: true });
444317
444621
  }
444318
444622
  }
444319
444623
  async function installGitManagedModPackage(params) {
@@ -444345,7 +444649,7 @@ async function installGitManagedModPackage(params) {
444345
444649
  packageInfo
444346
444650
  });
444347
444651
  } finally {
444348
- rmSync14(tempRoot, { force: true, recursive: true });
444652
+ rmSync15(tempRoot, { force: true, recursive: true });
444349
444653
  }
444350
444654
  }
444351
444655
  async function updateNpmManagedModPackage(params) {
@@ -444376,7 +444680,7 @@ async function updateNpmManagedModPackage(params) {
444376
444680
  previousVersion: existing.version
444377
444681
  };
444378
444682
  } finally {
444379
- rmSync14(tempRoot, { force: true, recursive: true });
444683
+ rmSync15(tempRoot, { force: true, recursive: true });
444380
444684
  }
444381
444685
  }
444382
444686
  async function updateGitManagedModPackage(params) {
@@ -444418,7 +444722,7 @@ async function updateGitManagedModPackage(params) {
444418
444722
  previousVersion: existing.version
444419
444723
  };
444420
444724
  } finally {
444421
- rmSync14(tempRoot, { force: true, recursive: true });
444725
+ rmSync15(tempRoot, { force: true, recursive: true });
444422
444726
  }
444423
444727
  }
444424
444728
  var SKIPPED_PACKAGE_COPY_NAMES, spawnNpmInstallProcessOverride = null, spawnGitInstallProcess, platformOverride2 = null;
@@ -444436,9 +444740,9 @@ import {
444436
444740
  copyFileSync as copyFileSync5,
444437
444741
  existsSync as existsSync60,
444438
444742
  lstatSync as lstatSync4,
444439
- mkdirSync as mkdirSync41,
444440
- rmSync as rmSync15,
444441
- writeFileSync as writeFileSync30
444743
+ mkdirSync as mkdirSync42,
444744
+ rmSync as rmSync16,
444745
+ writeFileSync as writeFileSync31
444442
444746
  } from "node:fs";
444443
444747
  import path49 from "node:path";
444444
444748
  function assertValidPackageName(packageName) {
@@ -444539,14 +444843,14 @@ function scaffoldLocalModPackage(options) {
444539
444843
  const modGuidePath = path49.join(outputDirectory, "MOD.md");
444540
444844
  const installCommand = `letta install ${outputDirectory}`;
444541
444845
  try {
444542
- mkdirSync41(targetModsDirectory, { recursive: true });
444846
+ mkdirSync42(targetModsDirectory, { recursive: true });
444543
444847
  copyFileSync5(sourceFile, targetModPath);
444544
- writeFileSync30(packageJsonPath, `${JSON.stringify(createPackageJson(packageName, manifestEntry), null, 2)}
444848
+ writeFileSync31(packageJsonPath, `${JSON.stringify(createPackageJson(packageName, manifestEntry), null, 2)}
444545
444849
  `);
444546
- writeFileSync30(readmePath, createReadme(packageName));
444547
- writeFileSync30(modGuidePath, createModGuide(packageName, manifestEntry));
444850
+ writeFileSync31(readmePath, createReadme(packageName));
444851
+ writeFileSync31(modGuidePath, createModGuide(packageName, manifestEntry));
444548
444852
  } catch (error5) {
444549
- rmSync15(outputDirectory, { force: true, recursive: true });
444853
+ rmSync16(outputDirectory, { force: true, recursive: true });
444550
444854
  throw error5;
444551
444855
  }
444552
444856
  return {
@@ -444569,7 +444873,7 @@ var init_package_scaffolder = __esm(() => {
444569
444873
  });
444570
444874
 
444571
444875
  // src/cli/subcommands/mods.ts
444572
- import { dirname as dirname32, join as join74 } from "node:path";
444876
+ import { dirname as dirname32, join as join75 } from "node:path";
444573
444877
  import { parseArgs as parseArgs14 } from "node:util";
444574
444878
  function printUsage11() {
444575
444879
  console.log(`
@@ -444608,7 +444912,7 @@ function getExplicitAgentId(values4) {
444608
444912
  return typeof explicitAgent === "string" && explicitAgent.trim() ? explicitAgent.trim() : null;
444609
444913
  }
444610
444914
  function getAgentModsDirectory(agentId) {
444611
- return join74(getScopedMemoryFilesystemRoot(agentId), "mods");
444915
+ return join75(getScopedMemoryFilesystemRoot(agentId), "mods");
444612
444916
  }
444613
444917
  function directFilesForSource(source) {
444614
444918
  return source.files.filter((file) => dirname32(file) === source.root);
@@ -445979,7 +446283,7 @@ var init_setup7 = __esm(async () => {
445979
446283
 
445980
446284
  // src/cli/subcommands/shared-memory.ts
445981
446285
  import { existsSync as existsSync61 } from "node:fs";
445982
- import { join as join75 } from "node:path";
446286
+ import { join as join76 } from "node:path";
445983
446287
  import { parseArgs as parseArgs18 } from "node:util";
445984
446288
  function printUsage15() {
445985
446289
  console.log(`
@@ -446171,7 +446475,7 @@ async function runSharedMemorySubcommand(argv, deps = {}) {
446171
446475
  invalidateClientSkills(agentId);
446172
446476
  const recompileError = await recompileAndReportFailure(recompileAgent, agentId);
446173
446477
  const mountDir = getRepositoryMountDir(agentId, repository.name);
446174
- const mounted = existsSync61(join75(mountDir, ".git"));
446478
+ const mounted = existsSync61(join76(mountDir, ".git"));
446175
446479
  console.log(JSON.stringify({
446176
446480
  attached: true,
446177
446481
  repository: { id: repository.id, name: repository.name },
@@ -447702,14 +448006,14 @@ import {
447702
448006
  cpSync as cpSync2,
447703
448007
  existsSync as existsSync62,
447704
448008
  mkdtempSync as mkdtempSync5,
447705
- readFileSync as readFileSync40,
447706
- rmSync as rmSync16,
448009
+ readFileSync as readFileSync41,
448010
+ rmSync as rmSync17,
447707
448011
  statSync as statSync21,
447708
- writeFileSync as writeFileSync31
448012
+ writeFileSync as writeFileSync32
447709
448013
  } from "node:fs";
447710
448014
  import { mkdir as mkdir15, readdir as readdir13 } from "node:fs/promises";
447711
448015
  import { tmpdir as tmpdir11 } from "node:os";
447712
- import { basename as basename26, dirname as dirname33, join as join76, normalize as normalize5, resolve as resolve39, sep as sep8 } from "node:path";
448016
+ import { basename as basename26, dirname as dirname33, join as join77, normalize as normalize5, resolve as resolve39, sep as sep8 } from "node:path";
447713
448017
  import { parseArgs as parseArgs19, TextDecoder as TextDecoder2, TextEncoder as TextEncoder2 } from "node:util";
447714
448018
  function printUsage16() {
447715
448019
  console.log(`
@@ -448001,14 +448305,14 @@ async function resolveBranchAndSubdir(location) {
448001
448305
  }
448002
448306
  async function cloneSkillSource(location) {
448003
448307
  const resolvedLocation = await resolveBranchAndSubdir(location);
448004
- const tmpDir = mkdtempSync5(join76(tmpdir11(), "letta-skill-install-"));
448308
+ const tmpDir = mkdtempSync5(join77(tmpdir11(), "letta-skill-install-"));
448005
448309
  const args = ["clone", "--depth", "1"];
448006
448310
  if (resolvedLocation.branch) {
448007
448311
  args.push("--branch", resolvedLocation.branch);
448008
448312
  }
448009
448313
  args.push(resolvedLocation.repoUrl, tmpDir);
448010
448314
  await execFile17("git", args, { timeout: 120000 });
448011
- const sourceDir = resolvedLocation.subdir ? join76(tmpDir, resolvedLocation.subdir) : tmpDir;
448315
+ const sourceDir = resolvedLocation.subdir ? join77(tmpDir, resolvedLocation.subdir) : tmpDir;
448012
448316
  return { tmpDir, sourceDir };
448013
448317
  }
448014
448318
  function assertDirectSkillFileSize(receivedBytes, maxBytes) {
@@ -448063,14 +448367,14 @@ async function downloadDirectSkillFileSource(location, options = {}) {
448063
448367
  throw new Error(`Direct skill file download failed for ${location.url}: ${response.status}`);
448064
448368
  }
448065
448369
  const skillText = await readResponseTextWithLimit(response, MAX_DIRECT_SKILL_FILE_BYTES);
448066
- const tmpDir = mkdtempSync5(join76(tmpdir11(), "letta-direct-skill-"));
448370
+ const tmpDir = mkdtempSync5(join77(tmpdir11(), "letta-direct-skill-"));
448067
448371
  try {
448068
- const sourceDir = join76(tmpDir, "skill");
448372
+ const sourceDir = join77(tmpDir, "skill");
448069
448373
  await mkdir15(sourceDir, { recursive: true });
448070
- writeFileSync31(join76(sourceDir, "SKILL.md"), skillText, "utf8");
448374
+ writeFileSync32(join77(sourceDir, "SKILL.md"), skillText, "utf8");
448071
448375
  return { tmpDir, sourceDir };
448072
448376
  } catch (error5) {
448073
- rmSync16(tmpDir, { recursive: true, force: true });
448377
+ rmSync17(tmpDir, { recursive: true, force: true });
448074
448378
  throw error5;
448075
448379
  }
448076
448380
  }
@@ -448108,9 +448412,9 @@ function assertSafeZipMember(name) {
448108
448412
  }
448109
448413
  async function downloadClawHubSkillSource(location) {
448110
448414
  const version2 = await resolveClawHubVersion(location);
448111
- const tmpDir = mkdtempSync5(join76(tmpdir11(), "letta-clawhub-skill-"));
448112
- const zipPath = join76(tmpDir, "skill.zip");
448113
- const sourceDir = join76(tmpDir, "skill");
448415
+ const tmpDir = mkdtempSync5(join77(tmpdir11(), "letta-clawhub-skill-"));
448416
+ const zipPath = join77(tmpDir, "skill.zip");
448417
+ const sourceDir = join77(tmpDir, "skill");
448114
448418
  await mkdir15(sourceDir, { recursive: true });
448115
448419
  const url2 = new URL(`${CLAWHUB_API_BASE_URL}/download`);
448116
448420
  url2.searchParams.set("slug", location.slug);
@@ -448119,7 +448423,7 @@ async function downloadClawHubSkillSource(location) {
448119
448423
  if (!response.ok) {
448120
448424
  throw new Error(`ClawHub download failed for ${location.slug}@${version2}: ${response.status}`);
448121
448425
  }
448122
- writeFileSync31(zipPath, Buffer.from(await response.arrayBuffer()));
448426
+ writeFileSync32(zipPath, Buffer.from(await response.arrayBuffer()));
448123
448427
  const { stdout } = await execFile17("unzip", ["-Z1", zipPath], {
448124
448428
  timeout: 30000
448125
448429
  });
@@ -448149,7 +448453,7 @@ function sanitizeSkillName(name) {
448149
448453
  return trimmed;
448150
448454
  }
448151
448455
  function getSkillName(sourceDir) {
448152
- const skillMd = readFileSync40(join76(sourceDir, "SKILL.md"), "utf8");
448456
+ const skillMd = readFileSync41(join77(sourceDir, "SKILL.md"), "utf8");
448153
448457
  const { frontmatter } = parseFrontmatter(skillMd);
448154
448458
  const frontmatterName = frontmatter.name;
448155
448459
  const name = typeof frontmatterName === "string" && frontmatterName.trim() ? frontmatterName : basename26(sourceDir);
@@ -448158,7 +448462,7 @@ function getSkillName(sourceDir) {
448158
448462
  async function installSkillDirectory(params) {
448159
448463
  const sourceDir = resolve39(params.sourceDir);
448160
448464
  const memoryDir = resolve39(params.memoryDir);
448161
- const skillMdPath = join76(sourceDir, "SKILL.md");
448465
+ const skillMdPath = join77(sourceDir, "SKILL.md");
448162
448466
  if (!existsSync62(skillMdPath)) {
448163
448467
  throw new Error("No SKILL.md found in the skill directory.");
448164
448468
  }
@@ -448166,14 +448470,14 @@ async function installSkillDirectory(params) {
448166
448470
  throw new Error(`Skill source is not a directory: ${sourceDir}`);
448167
448471
  }
448168
448472
  const name = getSkillName(sourceDir);
448169
- const skillsDir = join76(memoryDir, "skills");
448170
- const targetPath = join76(skillsDir, name);
448473
+ const skillsDir = join77(memoryDir, "skills");
448474
+ const targetPath = join77(skillsDir, name);
448171
448475
  assertInside(skillsDir, targetPath);
448172
448476
  if (existsSync62(targetPath)) {
448173
448477
  if (!params.force) {
448174
448478
  throw new Error(`Skill "${name}" already exists at ${targetPath}. Re-run with --force to replace it.`);
448175
448479
  }
448176
- rmSync16(targetPath, { recursive: true, force: true });
448480
+ rmSync17(targetPath, { recursive: true, force: true });
448177
448481
  }
448178
448482
  await mkdir15(skillsDir, { recursive: true });
448179
448483
  cpSync2(sourceDir, targetPath, {
@@ -448184,7 +448488,7 @@ async function installSkillDirectory(params) {
448184
448488
  }
448185
448489
  async function listSkillDirectories(params) {
448186
448490
  const memoryDir = resolve39(params.memoryDir);
448187
- const skillsDir = join76(memoryDir, "skills");
448491
+ const skillsDir = join77(memoryDir, "skills");
448188
448492
  if (!existsSync62(skillsDir))
448189
448493
  return [];
448190
448494
  const entries = await readdir13(skillsDir, { withFileTypes: true });
@@ -448192,14 +448496,14 @@ async function listSkillDirectories(params) {
448192
448496
  for (const entry of entries) {
448193
448497
  if (!entry.isDirectory())
448194
448498
  continue;
448195
- const skillDir = join76(skillsDir, entry.name);
448196
- const skillMdPath = join76(skillDir, "SKILL.md");
448499
+ const skillDir = join77(skillsDir, entry.name);
448500
+ const skillMdPath = join77(skillDir, "SKILL.md");
448197
448501
  if (!existsSync62(skillMdPath))
448198
448502
  continue;
448199
448503
  let name = entry.name;
448200
448504
  let description;
448201
448505
  try {
448202
- const skillMd = readFileSync40(skillMdPath, "utf8");
448506
+ const skillMd = readFileSync41(skillMdPath, "utf8");
448203
448507
  const { frontmatter } = parseFrontmatter(skillMd);
448204
448508
  if (typeof frontmatter.name === "string" && frontmatter.name.trim()) {
448205
448509
  name = frontmatter.name.trim();
@@ -448214,9 +448518,9 @@ async function listSkillDirectories(params) {
448214
448518
  }
448215
448519
  async function deleteSkillDirectory(params) {
448216
448520
  const memoryDir = resolve39(params.memoryDir);
448217
- const skillsDir = join76(memoryDir, "skills");
448521
+ const skillsDir = join77(memoryDir, "skills");
448218
448522
  const name = sanitizeSkillName(params.name);
448219
- const targetPath = join76(skillsDir, name);
448523
+ const targetPath = join77(skillsDir, name);
448220
448524
  assertInside(skillsDir, targetPath);
448221
448525
  if (!existsSync62(targetPath)) {
448222
448526
  throw new Error(`Skill "${name}" is not installed at ${targetPath}.`);
@@ -448224,7 +448528,7 @@ async function deleteSkillDirectory(params) {
448224
448528
  if (!statSync21(targetPath).isDirectory()) {
448225
448529
  throw new Error(`Skill path is not a directory: ${targetPath}`);
448226
448530
  }
448227
- rmSync16(targetPath, { recursive: true, force: true });
448531
+ rmSync17(targetPath, { recursive: true, force: true });
448228
448532
  return { name, path: normalize5(targetPath) };
448229
448533
  }
448230
448534
  async function loadSkillMemorySyncFn() {
@@ -448288,7 +448592,7 @@ async function installSkill(specifier, agentId, force) {
448288
448592
  };
448289
448593
  } finally {
448290
448594
  if (tmpDir)
448291
- rmSync16(tmpDir, { recursive: true, force: true });
448595
+ rmSync17(tmpDir, { recursive: true, force: true });
448292
448596
  }
448293
448597
  }
448294
448598
  async function getAgentMemoryDir(agentId) {
@@ -448802,7 +449106,7 @@ var init_teleport2 = __esm(() => {
448802
449106
 
448803
449107
  // src/cli/subcommands/trajectories/readers.ts
448804
449108
  import { readdir as readdir14, readFile as readFile26, stat as stat17 } from "node:fs/promises";
448805
- import { join as join77 } from "node:path";
449109
+ import { join as join78 } from "node:path";
448806
449110
  async function loadSessionTranscript(item) {
448807
449111
  const stats = await stat17(item.path);
448808
449112
  if (stats.isDirectory()) {
@@ -448814,13 +449118,13 @@ async function loadSessionTranscript(item) {
448814
449118
  return readFile26(item.path, "utf-8");
448815
449119
  }
448816
449120
  async function assembleEventDirectory(sessionDir) {
448817
- const eventsSubdir = join77(sessionDir, "events");
449121
+ const eventsSubdir = join78(sessionDir, "events");
448818
449122
  const eventsDir = (await stat17(eventsSubdir).catch(() => null))?.isDirectory() ? eventsSubdir : sessionDir;
448819
449123
  const names2 = (await readdir14(eventsDir, { withFileTypes: true })).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => entry.name).sort((a2, b3) => Number.parseInt(a2, 10) - Number.parseInt(b3, 10) || a2.localeCompare(b3));
448820
449124
  if (names2.length === 0) {
448821
449125
  throw new Error(`No event files found in ${eventsDir}`);
448822
449126
  }
448823
- const events = await Promise.all(names2.map(async (name) => JSON.parse(await readFile26(join77(eventsDir, name), "utf-8"))));
449127
+ const events = await Promise.all(names2.map(async (name) => JSON.parse(await readFile26(join78(eventsDir, name), "utf-8"))));
448824
449128
  return JSON.stringify(events);
448825
449129
  }
448826
449130
  async function openReadOnlyDatabase(path50) {
@@ -448889,7 +449193,7 @@ var init_sources = __esm(() => {
448889
449193
  });
448890
449194
 
448891
449195
  // src/cli/subcommands/trajectories/export.ts
448892
- import { createHash as createHash11 } from "node:crypto";
449196
+ import { createHash as createHash12 } from "node:crypto";
448893
449197
  import {
448894
449198
  mkdir as mkdir16,
448895
449199
  readdir as readdir15,
@@ -448898,14 +449202,14 @@ import {
448898
449202
  stat as stat18,
448899
449203
  writeFile as writeFile17
448900
449204
  } from "node:fs/promises";
448901
- import { basename as basename27, join as join78 } from "node:path";
449205
+ import { basename as basename27, join as join79 } from "node:path";
448902
449206
  function fileTimestamp(startedAt) {
448903
449207
  if (!startedAt)
448904
449208
  return "unknown-date";
448905
449209
  return startedAt.slice(0, 19).replace(/:/g, "-");
448906
449210
  }
448907
449211
  function sessionHash(source, nativeId) {
448908
- return createHash11("sha256").update(`${source}:${nativeId}`).digest("hex").slice(0, 10);
449212
+ return createHash12("sha256").update(`${source}:${nativeId}`).digest("hex").slice(0, 10);
448909
449213
  }
448910
449214
  async function listAllTrajectories(source, root2) {
448911
449215
  const items3 = [];
@@ -448968,7 +449272,7 @@ async function prepareOutDir(outDir) {
448968
449272
  throw new Error(`--out ${outDir} is not empty and has no ${MANIFEST_NAME}; refusing to overwrite a directory this tool did not create`);
448969
449273
  }
448970
449274
  for (const entry of entries) {
448971
- await rm9(join78(outDir, entry), { recursive: true, force: true });
449275
+ await rm9(join79(outDir, entry), { recursive: true, force: true });
448972
449276
  }
448973
449277
  } catch (error5) {
448974
449278
  if (error5.code !== "ENOENT")
@@ -449011,14 +449315,14 @@ async function runTrajectoryExport(options) {
449011
449315
  }
449012
449316
  const sessionId = sessionHash(source, id2);
449013
449317
  const base2 = `${fileTimestamp(stats.startedAt)}_${sessionId}`;
449014
- let file = join78(source, `${base2}.json`);
449318
+ let file = join79(source, `${base2}.json`);
449015
449319
  for (let suffix = 2;usedFiles.has(file); suffix += 1) {
449016
- file = join78(source, `${base2}-${suffix}.json`);
449320
+ file = join79(source, `${base2}-${suffix}.json`);
449017
449321
  }
449018
449322
  usedFiles.add(file);
449019
449323
  const body3 = JSON.stringify(records);
449020
- await mkdir16(join78(options.outDir, source), { recursive: true });
449021
- await writeFile17(join78(options.outDir, file), body3, "utf-8");
449324
+ await mkdir16(join79(options.outDir, source), { recursive: true });
449325
+ await writeFile17(join79(options.outDir, file), body3, "utf-8");
449022
449326
  counts.exported += 1;
449023
449327
  manifest2.sessions.push({
449024
449328
  source,
@@ -449072,7 +449376,7 @@ async function runTrajectoryExport(options) {
449072
449376
  await exportCheckpoint(checkpoint, `${basename27(checkpoint.path)}-${checkpoint.threadId}`);
449073
449377
  }
449074
449378
  manifest2.sessions.sort((a2, b3) => (a2.startedAt ?? "").localeCompare(b3.startedAt ?? ""));
449075
- await writeFile17(join78(options.outDir, MANIFEST_NAME), JSON.stringify(manifest2, null, 2), "utf-8");
449379
+ await writeFile17(join79(options.outDir, MANIFEST_NAME), JSON.stringify(manifest2, null, 2), "utf-8");
449076
449380
  return manifest2;
449077
449381
  }
449078
449382
  var MANIFEST_NAME = "manifest.json", FIRST_PROMPT_MAX_CHARS = 200, LIST_PAGE_LIMIT = 1000;
@@ -449084,13 +449388,13 @@ var init_export = __esm(() => {
449084
449388
 
449085
449389
  // src/cli/subcommands/trajectories/review.ts
449086
449390
  import { readFile as readFile28 } from "node:fs/promises";
449087
- import { isAbsolute as isAbsolute30, join as join79 } from "node:path";
449391
+ import { isAbsolute as isAbsolute30, join as join80 } from "node:path";
449088
449392
  async function readManifest(dir) {
449089
449393
  let raw2;
449090
449394
  try {
449091
- raw2 = await readFile28(join79(dir, "manifest.json"), "utf-8");
449395
+ raw2 = await readFile28(join80(dir, "manifest.json"), "utf-8");
449092
449396
  } catch {
449093
- throw new Error(`No manifest at ${join79(dir, "manifest.json")}. Run: letta trajectories export --out ${dir}`);
449397
+ throw new Error(`No manifest at ${join80(dir, "manifest.json")}. Run: letta trajectories export --out ${dir}`);
449094
449398
  }
449095
449399
  return JSON.parse(raw2);
449096
449400
  }
@@ -449099,7 +449403,7 @@ function filterSessions(sessions, filter4) {
449099
449403
  }
449100
449404
  async function resolveSessionFile(dir, target2) {
449101
449405
  if (target2.endsWith(".json")) {
449102
- const direct = isAbsolute30(target2) ? target2 : join79(dir, target2);
449406
+ const direct = isAbsolute30(target2) ? target2 : join80(dir, target2);
449103
449407
  try {
449104
449408
  await readFile28(direct, "utf-8");
449105
449409
  return direct;
@@ -449110,7 +449414,7 @@ async function resolveSessionFile(dir, target2) {
449110
449414
  if (!entry) {
449111
449415
  throw new Error(`No session "${target2}" in ${dir} (pass a file path, a manifest-relative file, or a sessionId)`);
449112
449416
  }
449113
- return join79(dir, entry.file);
449417
+ return join80(dir, entry.file);
449114
449418
  }
449115
449419
  function stamp(timestamp) {
449116
449420
  return (timestamp ?? "").slice(0, 19);
@@ -449153,7 +449457,7 @@ async function searchSessions(dir, keyword, options = {}) {
449153
449457
  for (const session2 of filterSessions(manifest2.sessions, options)) {
449154
449458
  let records;
449155
449459
  try {
449156
- records = JSON.parse(await readFile28(join79(dir, session2.file), "utf-8"));
449460
+ records = JSON.parse(await readFile28(join80(dir, session2.file), "utf-8"));
449157
449461
  } catch {
449158
449462
  continue;
449159
449463
  }
@@ -452827,7 +453131,7 @@ var init_message_channel_gateway_tool = __esm(() => {
452827
453131
  });
452828
453132
 
452829
453133
  // src/channels/custom/scaffolding.ts
452830
- import { existsSync as existsSync63, mkdirSync as mkdirSync42, rmSync as rmSync17, writeFileSync as writeFileSync32 } from "node:fs";
453134
+ import { existsSync as existsSync63, mkdirSync as mkdirSync43, rmSync as rmSync18, writeFileSync as writeFileSync33 } from "node:fs";
452831
453135
  function removeUserPlugin(channelId) {
452832
453136
  if (FIRST_PARTY_SET.has(channelId)) {
452833
453137
  return;
@@ -452840,7 +453144,7 @@ function removeUserPlugin(channelId) {
452840
453144
  return;
452841
453145
  }
452842
453146
  try {
452843
- rmSync17(channelDir, { recursive: true, force: true });
453147
+ rmSync18(channelDir, { recursive: true, force: true });
452844
453148
  } catch (err) {
452845
453149
  console.error(`[channels] Failed to remove plugin folder ${channelDir}:`, err);
452846
453150
  }
@@ -453881,7 +454185,7 @@ async function handleChannelsSlashCommand(runtime, args) {
453881
454185
  }
453882
454186
 
453883
454187
  // src/channels/gateway-local.ts
453884
- import { createHash as createHash12 } from "node:crypto";
454188
+ import { createHash as createHash13 } from "node:crypto";
453885
454189
  import WebSocket10 from "ws";
453886
454190
  async function executeChannelServiceCommand(command) {
453887
454191
  if (!isDetachedChannelsCommand(command)) {
@@ -453925,7 +454229,7 @@ function gatewayClientMessageId(delivery) {
453925
454229
  messageId: source.messageId ?? null
453926
454230
  })).sort((a2, b3) => JSON.stringify(a2).localeCompare(JSON.stringify(b3)));
453927
454231
  const hasPlatformMessageId = (delivery.turnSources ?? []).some((source) => Boolean(source.messageId));
453928
- const digest = createHash12("sha256").update(JSON.stringify({
454232
+ const digest = createHash13("sha256").update(JSON.stringify({
453929
454233
  agentId: delivery.route.agentId,
453930
454234
  conversationId: delivery.route.conversationId,
453931
454235
  sources: sourceIdentity,
@@ -454826,9 +455130,9 @@ var exports_bootstrap_tools = {};
454826
455130
  __export(exports_bootstrap_tools, {
454827
455131
  bootstrapBaseToolsIfNeeded: () => bootstrapBaseToolsIfNeeded
454828
455132
  });
454829
- import { existsSync as existsSync64, mkdirSync as mkdirSync43, writeFileSync as writeFileSync33 } from "node:fs";
454830
- import { homedir as homedir44 } from "node:os";
454831
- import { join as join80 } from "node:path";
455133
+ import { existsSync as existsSync64, mkdirSync as mkdirSync44, writeFileSync as writeFileSync34 } from "node:fs";
455134
+ import { homedir as homedir45 } from "node:os";
455135
+ import { join as join81 } from "node:path";
454832
455136
  async function bootstrapBaseToolsIfNeeded(options = {}) {
454833
455137
  if (existsSync64(MARKER_PATH2))
454834
455138
  return;
@@ -454836,8 +455140,8 @@ async function bootstrapBaseToolsIfNeeded(options = {}) {
454836
455140
  try {
454837
455141
  const success = await addBaseToolsToServer(options);
454838
455142
  if (success) {
454839
- mkdirSync43(join80(homedir44(), ".letta"), { recursive: true });
454840
- writeFileSync33(MARKER_PATH2, new Date().toISOString(), "utf-8");
455143
+ mkdirSync44(join81(homedir45(), ".letta"), { recursive: true });
455144
+ writeFileSync34(MARKER_PATH2, new Date().toISOString(), "utf-8");
454841
455145
  }
454842
455146
  } catch (err) {
454843
455147
  debugWarn("bootstrap", `Failed to bootstrap base tools: ${err instanceof Error ? err.message : String(err)}`);
@@ -454847,7 +455151,7 @@ var MARKER_PATH2;
454847
455151
  var init_bootstrap_tools = __esm(() => {
454848
455152
  init_debug();
454849
455153
  init_create5();
454850
- MARKER_PATH2 = join80(homedir44(), ".letta", ".bootstrapped");
455154
+ MARKER_PATH2 = join81(homedir45(), ".letta", ".bootstrapped");
454851
455155
  });
454852
455156
 
454853
455157
  // src/utils/headless-stdout-guard.ts
@@ -454888,7 +455192,7 @@ function resolveListMessagesRoute(listReq, sessionConvId, sessionAgentId) {
454888
455192
  }
454889
455193
 
454890
455194
  // src/agent/bootstrap-handler.ts
454891
- import { randomUUID as randomUUID35 } from "node:crypto";
455195
+ import { randomUUID as randomUUID37 } from "node:crypto";
454892
455196
  async function handleBootstrapSessionState(params) {
454893
455197
  const {
454894
455198
  bootstrapReq,
@@ -454937,7 +455241,7 @@ async function handleBootstrapSessionState(params) {
454937
455241
  response: payload
454938
455242
  },
454939
455243
  session_id: sessionContext.sessionId,
454940
- uuid: randomUUID35()
455244
+ uuid: randomUUID37()
454941
455245
  };
454942
455246
  } catch (err) {
454943
455247
  return {
@@ -454948,14 +455252,14 @@ async function handleBootstrapSessionState(params) {
454948
455252
  error: err instanceof Error ? err.message : "bootstrap_session_state failed"
454949
455253
  },
454950
455254
  session_id: sessionContext.sessionId,
454951
- uuid: randomUUID35()
455255
+ uuid: randomUUID37()
454952
455256
  };
454953
455257
  }
454954
455258
  }
454955
455259
  var init_bootstrap_handler = () => {};
454956
455260
 
454957
455261
  // src/agent/list-messages-handler.ts
454958
- import { randomUUID as randomUUID36 } from "node:crypto";
455262
+ import { randomUUID as randomUUID38 } from "node:crypto";
454959
455263
  async function handleListMessages(params) {
454960
455264
  const {
454961
455265
  listReq,
@@ -454995,7 +455299,7 @@ async function handleListMessages(params) {
454995
455299
  response: payload
454996
455300
  },
454997
455301
  session_id: sessionId,
454998
- uuid: randomUUID36()
455302
+ uuid: randomUUID38()
454999
455303
  };
455000
455304
  } catch (err) {
455001
455305
  return {
@@ -455006,7 +455310,7 @@ async function handleListMessages(params) {
455006
455310
  error: err instanceof Error ? err.message : "list_messages failed"
455007
455311
  },
455008
455312
  session_id: sessionId,
455009
- uuid: randomUUID36()
455313
+ uuid: randomUUID38()
455010
455314
  };
455011
455315
  }
455012
455316
  }
@@ -455309,7 +455613,7 @@ var init_headless_environment_response = __esm(() => {
455309
455613
  });
455310
455614
 
455311
455615
  // src/headless-cloud-send.ts
455312
- import { randomUUID as randomUUID37 } from "node:crypto";
455616
+ import { randomUUID as randomUUID39 } from "node:crypto";
455313
455617
  function shouldEnqueueCloudSend(values4, cloud, isAgentLaunch) {
455314
455618
  if (!cloud || isAgentLaunch || values4["new-agent"] || values4.ephemeral)
455315
455619
  return false;
@@ -455358,7 +455662,7 @@ async function tryCloudHeadlessSend(values4, prompt, backend3, isAgentLaunch, de
455358
455662
  const format5 = values4["output-format"] ?? "text";
455359
455663
  const noWait = Boolean(values4["no-wait"]);
455360
455664
  const started = Date.now();
455361
- const clientMessageId = randomUUID37();
455665
+ const clientMessageId = randomUUID39();
455362
455666
  const controller = new AbortController;
455363
455667
  const submissionTimeout = setTimeout(() => controller.abort(new Error("Cloud submission timed out; inspect the conversation before resending.")), 30000);
455364
455668
  const timeout = setTimeout(() => controller.abort(new Error("Stopped waiting; remote execution was not cancelled.")), deps.timeoutMs ?? resolveEnvironmentMaxWaitMs());
@@ -455438,7 +455742,7 @@ async function tryCloudHeadlessSend(values4, prompt, backend3, isAgentLaunch, de
455438
455742
  mcp_servers: [],
455439
455743
  permission_mode: "",
455440
455744
  slash_commands: [],
455441
- uuid: randomUUID37()
455745
+ uuid: randomUUID39()
455442
455746
  };
455443
455747
  await writeObject(init);
455444
455748
  }
@@ -455481,7 +455785,7 @@ async function tryCloudHeadlessSend(values4, prompt, backend3, isAgentLaunch, de
455481
455785
  duration_api_ms: 0,
455482
455786
  num_turns: 1,
455483
455787
  usage: null,
455484
- uuid: randomUUID37(),
455788
+ uuid: randomUUID39(),
455485
455789
  ...recovery
455486
455790
  });
455487
455791
  return 0;
@@ -455500,7 +455804,7 @@ async function tryCloudHeadlessSend(values4, prompt, backend3, isAgentLaunch, de
455500
455804
  run_ids: error5 instanceof EnqueuedWaitError ? error5.runIds : [],
455501
455805
  usage: null,
455502
455806
  stop_reason: "error",
455503
- uuid: randomUUID37(),
455807
+ uuid: randomUUID39(),
455504
455808
  status: receipt ? "wait_failed" : submissionAttempted && !(error5 instanceof ApiRequestError && error5.status >= 400 && error5.status < 500) ? "acceptance_unknown" : "submission_failed",
455505
455809
  agent_id: agentId ?? null,
455506
455810
  conversation_id: conversationId ?? "",
@@ -455654,7 +455958,7 @@ var init_headless_ephemeral_startup = __esm(async () => {
455654
455958
  });
455655
455959
 
455656
455960
  // src/headless-listener-launch.ts
455657
- import { randomUUID as randomUUID38 } from "node:crypto";
455961
+ import { randomUUID as randomUUID40 } from "node:crypto";
455658
455962
  import { setTimeout as delay2 } from "node:timers/promises";
455659
455963
  import WebSocket11 from "ws";
455660
455964
  function listenerControlUrl(baseUrl, connectionId, scope) {
@@ -455701,7 +456005,7 @@ async function cancelListenerInput(params) {
455701
456005
  }
455702
456006
  async function launchListenerConversation(params, deps = {}) {
455703
456007
  const client = deps.client ?? await createListenerClient(params.connectionId, params.scope);
455704
- const clientMessageId = randomUUID38();
456008
+ const clientMessageId = randomUUID40();
455705
456009
  const runIds = new Set;
455706
456010
  let loop;
455707
456011
  let cancelled = false;
@@ -455886,7 +456190,7 @@ function resolveHeadlessMemfsPolicy(options) {
455886
456190
  }
455887
456191
 
455888
456192
  // src/headless-mod-adapter.ts
455889
- import { join as join81 } from "node:path";
456193
+ import { join as join82 } from "node:path";
455890
456194
  function isHeadlessMemfsEnabled(agentId) {
455891
456195
  try {
455892
456196
  return settingsManager.isMemfsEnabled(agentId);
@@ -455957,7 +456261,7 @@ function createHeadlessModContext(options) {
455957
456261
  };
455958
456262
  }
455959
456263
  function createHeadlessModAdapter(options) {
455960
- const agentModsDirectory = isHeadlessMemfsEnabled(options.agent.id) ? join81(getScopedMemoryFilesystemRoot(options.agent.id), "mods") : undefined;
456264
+ const agentModsDirectory = isHeadlessMemfsEnabled(options.agent.id) ? join82(getScopedMemoryFilesystemRoot(options.agent.id), "mods") : undefined;
455961
456265
  return createModAdapter({
455962
456266
  ...agentModsDirectory ? { agentModsDirectory } : {},
455963
456267
  ...options.cacheDirectory ? { cacheDirectory: options.cacheDirectory } : {},
@@ -456344,7 +456648,7 @@ __export(exports_headless, {
456344
456648
  decideInterruptAction: () => decideInterruptAction,
456345
456649
  __headlessTestUtils: () => __headlessTestUtils
456346
456650
  });
456347
- import { randomUUID as randomUUID39 } from "node:crypto";
456651
+ import { randomUUID as randomUUID41 } from "node:crypto";
456348
456652
  function trackHeadlessBoundaryError(errorType, error5, context3) {
456349
456653
  trackBoundaryError({
456350
456654
  errorType,
@@ -456366,7 +456670,7 @@ async function reportStartupErrorAndExit(errorType, error5, context3, outputForm
456366
456670
  message,
456367
456671
  stop_reason: "error",
456368
456672
  session_id: "startup",
456369
- uuid: `startup-error-${randomUUID39()}`
456673
+ uuid: `startup-error-${randomUUID41()}`
456370
456674
  };
456371
456675
  await writeWireMessageAsync(errorMsg);
456372
456676
  } else {
@@ -456465,7 +456769,7 @@ async function emitHeadlessTurnStartCancellationOutput(options) {
456465
456769
  message: options.reason,
456466
456770
  stop_reason: "cancelled",
456467
456771
  session_id: options.sessionId,
456468
- uuid: `error-turn-start-cancel-${randomUUID39()}`
456772
+ uuid: `error-turn-start-cancel-${randomUUID41()}`
456469
456773
  };
456470
456774
  await writeWireMessageAsync(errorMsg);
456471
456775
  const resultMsg = {
@@ -456480,7 +456784,7 @@ async function emitHeadlessTurnStartCancellationOutput(options) {
456480
456784
  conversation_id: options.conversationId,
456481
456785
  run_ids: [],
456482
456786
  usage: null,
456483
- uuid: `result-turn-start-cancel-${randomUUID39()}`,
456787
+ uuid: `result-turn-start-cancel-${randomUUID41()}`,
456484
456788
  stop_reason: "cancelled"
456485
456789
  };
456486
456790
  await writeWireMessageAsync(resultMsg);
@@ -456509,7 +456813,7 @@ function writeBidirectionalTurnStartCancellation(options) {
456509
456813
  message: options.reason,
456510
456814
  stop_reason: "cancelled",
456511
456815
  session_id: options.sessionId,
456512
- uuid: `error-turn-start-cancel-${randomUUID39()}`
456816
+ uuid: `error-turn-start-cancel-${randomUUID41()}`
456513
456817
  };
456514
456818
  writeWireMessage(errorMsg);
456515
456819
  const resultMsg = {
@@ -456524,7 +456828,7 @@ function writeBidirectionalTurnStartCancellation(options) {
456524
456828
  conversation_id: options.conversationId,
456525
456829
  run_ids: [],
456526
456830
  usage: null,
456527
- uuid: `result-turn-start-cancel-${randomUUID39()}`,
456831
+ uuid: `result-turn-start-cancel-${randomUUID41()}`,
456528
456832
  stop_reason: "cancelled"
456529
456833
  };
456530
456834
  writeWireMessage(resultMsg);
@@ -457332,7 +457636,7 @@ Current session AGENT_ID=${process.env.AGENT_ID}; --backend local switches to a
457332
457636
  const approvalInput = {
457333
457637
  type: "approval",
457334
457638
  approvals: denialResults,
457335
- otid: randomUUID39()
457639
+ otid: randomUUID41()
457336
457640
  };
457337
457641
  const approvalMessages = [approvalInput];
457338
457642
  {
@@ -457345,7 +457649,7 @@ Current session AGENT_ID=${process.env.AGENT_ID}; --backend local switches to a
457345
457649
  type: "text",
457346
457650
  text: sc.content
457347
457651
  })),
457348
- otid: randomUUID39()
457652
+ otid: randomUUID41()
457349
457653
  });
457350
457654
  }
457351
457655
  }
@@ -457378,7 +457682,7 @@ Current session AGENT_ID=${process.env.AGENT_ID}; --backend local switches to a
457378
457682
  message: `Failed to resolve pending approvals on resume: ${approvalError instanceof Error ? approvalError.message : String(approvalError)}`,
457379
457683
  stop_reason: "error",
457380
457684
  session_id: sessionId,
457381
- uuid: `error-pre-loop-approval-${randomUUID39()}`
457685
+ uuid: `error-pre-loop-approval-${randomUUID41()}`
457382
457686
  };
457383
457687
  writeWireMessage(errorMsg);
457384
457688
  } else {
@@ -457461,7 +457765,7 @@ ${SYSTEM_REMINDER_CLOSE}
457461
457765
  content: contentParts,
457462
457766
  backend: backend3,
457463
457767
  onMessage: outputFormat === "stream-json" ? (message) => {
457464
- const uuid5 = Reflect.get(message, "otid") ?? Reflect.get(message, "id") ?? randomUUID39();
457768
+ const uuid5 = Reflect.get(message, "otid") ?? Reflect.get(message, "id") ?? randomUUID41();
457465
457769
  writeWireMessage(includePartialMessages ? {
457466
457770
  type: "stream_event",
457467
457771
  event: message,
@@ -457534,7 +457838,7 @@ ${SYSTEM_REMINDER_CLOSE}
457534
457838
  {
457535
457839
  role: "user",
457536
457840
  content: contentParts,
457537
- otid: randomUUID39()
457841
+ otid: randomUUID41()
457538
457842
  }
457539
457843
  ];
457540
457844
  const recoveredApprovalResults = queuedRecoveredApprovalResults ?? [];
@@ -457543,7 +457847,7 @@ ${SYSTEM_REMINDER_CLOSE}
457543
457847
  {
457544
457848
  type: "approval",
457545
457849
  approvals: recoveredApprovalResults,
457546
- otid: randomUUID39()
457850
+ otid: randomUUID41()
457547
457851
  },
457548
457852
  ...currentInput
457549
457853
  ];
@@ -457590,7 +457894,7 @@ ${SYSTEM_REMINDER_CLOSE}
457590
457894
  message: `Maximum turns limit reached (${buffers.usage.stepCount}/${maxTurns} steps)`,
457591
457895
  stop_reason: "max_steps",
457592
457896
  session_id: sessionId,
457593
- uuid: `error-max-turns-${randomUUID39()}`
457897
+ uuid: `error-max-turns-${randomUUID41()}`
457594
457898
  };
457595
457899
  await writeWireMessageAsync(errorMsg);
457596
457900
  } else {
@@ -457608,7 +457912,7 @@ ${SYSTEM_REMINDER_CLOSE}
457608
457912
  message: "Interrupted by SIGINT",
457609
457913
  stop_reason: "cancelled",
457610
457914
  session_id: sessionId,
457611
- uuid: `error-interrupted-${randomUUID39()}`
457915
+ uuid: `error-interrupted-${randomUUID41()}`
457612
457916
  };
457613
457917
  await writeWireMessageAsync(errorMsg);
457614
457918
  } else {
@@ -457637,7 +457941,7 @@ ${SYSTEM_REMINDER_CLOSE}
457637
457941
  type: "text",
457638
457942
  text: sc.content
457639
457943
  })),
457640
- otid: randomUUID39()
457944
+ otid: randomUUID41()
457641
457945
  }
457642
457946
  ];
457643
457947
  }
@@ -457682,7 +457986,7 @@ ${SYSTEM_REMINDER_CLOSE}
457682
457986
  recovery_type: "approval_pending",
457683
457987
  message: "Detected pending approval conflict on send; resolving before retry",
457684
457988
  session_id: sessionId,
457685
- uuid: `recovery-pre-stream-${randomUUID39()}`
457989
+ uuid: `recovery-pre-stream-${randomUUID41()}`
457686
457990
  };
457687
457991
  writeWireMessage(recoveryMsg);
457688
457992
  } else {
@@ -457715,7 +458019,7 @@ ${SYSTEM_REMINDER_CLOSE}
457715
458019
  max_attempts: CONVERSATION_BUSY_MAX_RETRIES,
457716
458020
  delay_ms: retryDelayMs,
457717
458021
  session_id: sessionId,
457718
- uuid: `retry-conversation-busy-${randomUUID39()}`
458022
+ uuid: `retry-conversation-busy-${randomUUID41()}`
457719
458023
  };
457720
458024
  writeWireMessage(retryMsg);
457721
458025
  } else {
@@ -457743,7 +458047,7 @@ ${SYSTEM_REMINDER_CLOSE}
457743
458047
  max_attempts: LLM_API_ERROR_MAX_RETRIES2,
457744
458048
  delay_ms: delayMs,
457745
458049
  session_id: sessionId,
457746
- uuid: `retry-pre-stream-${randomUUID39()}`
458050
+ uuid: `retry-pre-stream-${randomUUID41()}`
457747
458051
  };
457748
458052
  writeWireMessage(retryMsg);
457749
458053
  } else {
@@ -457769,7 +458073,7 @@ ${SYSTEM_REMINDER_CLOSE}
457769
458073
  stop_reason: "error",
457770
458074
  run_id: errorInfo.run_id,
457771
458075
  session_id: sessionId,
457772
- uuid: randomUUID39(),
458076
+ uuid: randomUUID41(),
457773
458077
  ...errorInfo.error_type && errorInfo.run_id && {
457774
458078
  api_error: {
457775
458079
  message_type: "error_message",
@@ -457791,7 +458095,7 @@ ${SYSTEM_REMINDER_CLOSE}
457791
458095
  message: "Detected pending approval conflict; auto-denying stale approval and retrying",
457792
458096
  run_id: recoveryRunId ?? undefined,
457793
458097
  session_id: sessionId,
457794
- uuid: `recovery-${recoveryRunId || randomUUID39()}`
458098
+ uuid: `recovery-${recoveryRunId || randomUUID41()}`
457795
458099
  };
457796
458100
  writeWireMessage(recoveryMsg);
457797
458101
  approvalPendingRecovery = true;
@@ -457809,7 +458113,7 @@ ${SYSTEM_REMINDER_CLOSE}
457809
458113
  type: "stream_event",
457810
458114
  event: chunk2,
457811
458115
  session_id: sessionId,
457812
- uuid: uuid5 || randomUUID39()
458116
+ uuid: uuid5 || randomUUID41()
457813
458117
  };
457814
458118
  writeWireMessage(streamEvent);
457815
458119
  } else {
@@ -457817,7 +458121,7 @@ ${SYSTEM_REMINDER_CLOSE}
457817
458121
  type: "message",
457818
458122
  ...chunk2,
457819
458123
  session_id: sessionId,
457820
- uuid: uuid5 || randomUUID39()
458124
+ uuid: uuid5 || randomUUID41()
457821
458125
  };
457822
458126
  writeWireMessage(msg);
457823
458127
  }
@@ -457862,7 +458166,7 @@ ${SYSTEM_REMINDER_CLOSE}
457862
458166
  {
457863
458167
  role: "user",
457864
458168
  content: continueMessage,
457865
- otid: randomUUID39()
458169
+ otid: randomUUID41()
457866
458170
  }
457867
458171
  ];
457868
458172
  const continueTurnStartEmission = await emitHeadlessTurnStart({
@@ -457934,7 +458238,7 @@ ${SYSTEM_REMINDER_CLOSE}
457934
458238
  const approvalInputWithOtid = {
457935
458239
  type: "approval",
457936
458240
  approvals: executedResults,
457937
- otid: randomUUID39()
458241
+ otid: randomUUID41()
457938
458242
  };
457939
458243
  currentInput = [approvalInputWithOtid];
457940
458244
  continue;
@@ -457970,7 +458274,7 @@ ${SYSTEM_REMINDER_CLOSE}
457970
458274
  delay_ms: 0,
457971
458275
  run_id: lastRunId ?? undefined,
457972
458276
  session_id: sessionId,
457973
- uuid: `retry-${lastRunId || randomUUID39()}`
458277
+ uuid: `retry-${lastRunId || randomUUID41()}`
457974
458278
  };
457975
458279
  writeWireMessage(retryMsg);
457976
458280
  } else {
@@ -457998,7 +458302,7 @@ ${SYSTEM_REMINDER_CLOSE}
457998
458302
  delay_ms: delayMs,
457999
458303
  run_id: lastRunId ?? undefined,
458000
458304
  session_id: sessionId,
458001
- uuid: `retry-${lastRunId || randomUUID39()}`
458305
+ uuid: `retry-${lastRunId || randomUUID41()}`
458002
458306
  };
458003
458307
  writeWireMessage(retryMsg);
458004
458308
  } else {
@@ -458019,7 +458323,7 @@ ${SYSTEM_REMINDER_CLOSE}
458019
458323
  message: "Tool call ID mismatch; fetching actual pending approvals and resyncing",
458020
458324
  run_id: lastRunId ?? undefined,
458021
458325
  session_id: sessionId,
458022
- uuid: `recovery-${lastRunId || randomUUID39()}`
458326
+ uuid: `recovery-${lastRunId || randomUUID41()}`
458023
458327
  };
458024
458328
  writeWireMessage(recoveryMsg);
458025
458329
  } else {
@@ -458036,7 +458340,7 @@ ${SYSTEM_REMINDER_CLOSE}
458036
458340
  stop_reason: stopReason,
458037
458341
  run_id: lastRunId ?? undefined,
458038
458342
  session_id: sessionId,
458039
- uuid: `error-${lastRunId || randomUUID39()}`
458343
+ uuid: `error-${lastRunId || randomUUID41()}`
458040
458344
  };
458041
458345
  await writeWireMessageAsync(errorMsg);
458042
458346
  } else {
@@ -458076,9 +458380,9 @@ ${SYSTEM_REMINDER_CLOSE}
458076
458380
  emptyResponseRetries = attempt2;
458077
458381
  if (attempt2 >= EMPTY_RESPONSE_MAX_RETRIES2) {
458078
458382
  const nudgeMessage = {
458079
- role: "system",
458383
+ role: "user",
458080
458384
  content: `<system-reminder>The previous response was empty. Please provide a response with either text content or a tool call.</system-reminder>`,
458081
- otid: randomUUID39()
458385
+ otid: randomUUID41()
458082
458386
  };
458083
458387
  currentInput = [...currentInput, nudgeMessage];
458084
458388
  }
@@ -458091,7 +458395,7 @@ ${SYSTEM_REMINDER_CLOSE}
458091
458395
  delay_ms: delayMs,
458092
458396
  run_id: lastRunId ?? undefined,
458093
458397
  session_id: sessionId,
458094
- uuid: `retry-empty-${lastRunId || randomUUID39()}`
458398
+ uuid: `retry-empty-${lastRunId || randomUUID41()}`
458095
458399
  };
458096
458400
  writeWireMessage(retryMsg);
458097
458401
  } else {
@@ -458118,7 +458422,7 @@ ${SYSTEM_REMINDER_CLOSE}
458118
458422
  delay_ms: delayMs,
458119
458423
  run_id: lastRunId ?? undefined,
458120
458424
  session_id: sessionId,
458121
- uuid: `retry-${lastRunId || randomUUID39()}`
458425
+ uuid: `retry-${lastRunId || randomUUID41()}`
458122
458426
  };
458123
458427
  writeWireMessage(retryMsg);
458124
458428
  } else {
@@ -458148,7 +458452,7 @@ ${SYSTEM_REMINDER_CLOSE}
458148
458452
  delay_ms: delayMs,
458149
458453
  run_id: lastRunId ?? undefined,
458150
458454
  session_id: sessionId,
458151
- uuid: `retry-${lastRunId || randomUUID39()}`
458455
+ uuid: `retry-${lastRunId || randomUUID41()}`
458152
458456
  };
458153
458457
  writeWireMessage(retryMsg);
458154
458458
  } else {
@@ -458197,7 +458501,7 @@ ${SYSTEM_REMINDER_CLOSE}
458197
458501
  stop_reason: stopReason,
458198
458502
  run_id: lastRunId ?? undefined,
458199
458503
  session_id: sessionId,
458200
- uuid: `error-${lastRunId || randomUUID39()}`
458504
+ uuid: `error-${lastRunId || randomUUID41()}`
458201
458505
  };
458202
458506
  await writeWireMessageAsync(errorMsg);
458203
458507
  } else {
@@ -458216,7 +458520,7 @@ ${SYSTEM_REMINDER_CLOSE}
458216
458520
  stop_reason: "error",
458217
458521
  run_id: lastKnownRunId ?? undefined,
458218
458522
  session_id: sessionId,
458219
- uuid: `error-${lastKnownRunId || randomUUID39()}`
458523
+ uuid: `error-${lastKnownRunId || randomUUID41()}`
458220
458524
  };
458221
458525
  await writeWireMessageAsync(errorMsg);
458222
458526
  } else {
@@ -458413,7 +458717,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
458413
458717
  const approvalInput = {
458414
458718
  type: "approval",
458415
458719
  approvals: denialResults,
458416
- otid: randomUUID39()
458720
+ otid: randomUUID41()
458417
458721
  };
458418
458722
  const approvalMessages = [approvalInput];
458419
458723
  {
@@ -458426,7 +458730,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
458426
458730
  type: "text",
458427
458731
  text: sc.content
458428
458732
  })),
458429
- otid: randomUUID39()
458733
+ otid: randomUUID41()
458430
458734
  });
458431
458735
  }
458432
458736
  }
@@ -458484,7 +458788,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
458484
458788
  reason,
458485
458789
  cleared_count: clearedCount,
458486
458790
  session_id: sessionId,
458487
- uuid: `q-clr-${randomUUID39()}`
458791
+ uuid: `q-clr-${randomUUID41()}`
458488
458792
  })
458489
458793
  }
458490
458794
  });
@@ -458514,7 +458818,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
458514
458818
  reason: "runtime_busy",
458515
458819
  queue_len: Math.max(1, queueLen),
458516
458820
  session_id: sessionId,
458517
- uuid: `q-blk-${randomUUID39()}`
458821
+ uuid: `q-blk-${randomUUID41()}`
458518
458822
  });
458519
458823
  }
458520
458824
  function enqueueForTracking(input) {
@@ -458586,7 +458890,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
458586
458890
  request_id: interruptRequestId
458587
458891
  },
458588
458892
  session_id: sessionId,
458589
- uuid: randomUUID39()
458893
+ uuid: randomUUID41()
458590
458894
  };
458591
458895
  writeWireMessage(interruptResponse);
458592
458896
  return;
@@ -458689,7 +458993,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
458689
458993
  const approvalInput = {
458690
458994
  type: "approval",
458691
458995
  approvals: denialResults,
458692
- otid: randomUUID39()
458996
+ otid: randomUUID41()
458693
458997
  };
458694
458998
  const approvalStream = await sendScopedApprovalMessages({
458695
458999
  agentId: agent.id,
@@ -458728,7 +459032,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
458728
459032
  message: "Invalid JSON input",
458729
459033
  stop_reason: "error",
458730
459034
  session_id: sessionId,
458731
- uuid: randomUUID39()
459035
+ uuid: randomUUID41()
458732
459036
  };
458733
459037
  writeWireMessage(errorMsg2);
458734
459038
  continue;
@@ -458754,7 +459058,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
458754
459058
  }
458755
459059
  },
458756
459060
  session_id: sessionId,
458757
- uuid: randomUUID39()
459061
+ uuid: randomUUID41()
458758
459062
  };
458759
459063
  writeWireMessage(initResponse);
458760
459064
  } else if (subtype === "interrupt") {
@@ -458771,7 +459075,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
458771
459075
  request_id: requestId ?? ""
458772
459076
  },
458773
459077
  session_id: sessionId,
458774
- uuid: randomUUID39()
459078
+ uuid: randomUUID41()
458775
459079
  };
458776
459080
  writeWireMessage(interruptResponse);
458777
459081
  } else if (subtype === "register_external_tools") {
@@ -458819,7 +459123,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
458819
459123
  response: { registered: tools.length }
458820
459124
  },
458821
459125
  session_id: sessionId,
458822
- uuid: randomUUID39()
459126
+ uuid: randomUUID41()
458823
459127
  };
458824
459128
  writeWireMessage(registerResponse);
458825
459129
  } else if (subtype === "bootstrap_session_state") {
@@ -458875,7 +459179,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
458875
459179
  response: recovery
458876
459180
  },
458877
459181
  session_id: sessionId,
458878
- uuid: randomUUID39()
459182
+ uuid: randomUUID41()
458879
459183
  };
458880
459184
  writeWireMessage(recoveryResponse);
458881
459185
  } catch (error5) {
@@ -458887,7 +459191,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
458887
459191
  error: error5 instanceof Error ? error5.message : String(error5)
458888
459192
  },
458889
459193
  session_id: sessionId,
458890
- uuid: randomUUID39()
459194
+ uuid: randomUUID41()
458891
459195
  };
458892
459196
  writeWireMessage(recoveryError);
458893
459197
  }
@@ -458900,7 +459204,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
458900
459204
  error: `Unknown control request subtype: ${subtype}`
458901
459205
  },
458902
459206
  session_id: sessionId,
458903
- uuid: randomUUID39()
459207
+ uuid: randomUUID41()
458904
459208
  };
458905
459209
  writeWireMessage(errorResponse);
458906
459210
  }
@@ -458956,7 +459260,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
458956
459260
  try {
458957
459261
  const buffers = createBuffers(agent.id);
458958
459262
  const startTime = performance.now();
458959
- const userOtid = randomUUID39();
459263
+ const userOtid = randomUUID41();
458960
459264
  const userTranscriptText = extractTelemetryInputText(userContent);
458961
459265
  if (userTranscriptText.length > 0) {
458962
459266
  const userLineId = `user-${userOtid}`;
@@ -459021,7 +459325,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
459021
459325
  currentInput.unshift({
459022
459326
  role: "user",
459023
459327
  content: INTERRUPT_RECOVERY_ALERT,
459024
- otid: randomUUID39()
459328
+ otid: randomUUID41()
459025
459329
  });
459026
459330
  try {
459027
459331
  await resolveAllPendingApprovals();
@@ -459083,7 +459387,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
459083
459387
  recovery_type: "approval_pending",
459084
459388
  message: "Detected pending approval conflict on send; resolving before retry",
459085
459389
  session_id: sessionId,
459086
- uuid: `recovery-bidir-${randomUUID39()}`
459390
+ uuid: `recovery-bidir-${randomUUID41()}`
459087
459391
  };
459088
459392
  writeWireMessage(recoveryMsg);
459089
459393
  await resolveAllPendingApprovals();
@@ -459106,7 +459410,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
459106
459410
  max_attempts: LLM_API_ERROR_MAX_RETRIES2,
459107
459411
  delay_ms: delayMs,
459108
459412
  session_id: sessionId,
459109
- uuid: `retry-bidir-${randomUUID39()}`
459413
+ uuid: `retry-bidir-${randomUUID41()}`
459110
459414
  };
459111
459415
  writeWireMessage(retryMsg);
459112
459416
  await new Promise((resolve40) => setTimeout(resolve40, delayMs));
@@ -459128,7 +459432,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
459128
459432
  stop_reason: "error",
459129
459433
  run_id: errorInfo.run_id,
459130
459434
  session_id: sessionId,
459131
- uuid: randomUUID39(),
459435
+ uuid: randomUUID41(),
459132
459436
  ...errorInfo.error_type && errorInfo.run_id && {
459133
459437
  api_error: {
459134
459438
  message_type: "error_message",
@@ -459156,7 +459460,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
459156
459460
  type: "stream_event",
459157
459461
  event: chunk2,
459158
459462
  session_id: sessionId,
459159
- uuid: uuid5 || randomUUID39()
459463
+ uuid: uuid5 || randomUUID41()
459160
459464
  };
459161
459465
  writeWireMessage(streamEvent);
459162
459466
  } else {
@@ -459164,7 +459468,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
459164
459468
  type: "message",
459165
459469
  ...chunk2,
459166
459470
  session_id: sessionId,
459167
- uuid: uuid5 || randomUUID39()
459471
+ uuid: uuid5 || randomUUID41()
459168
459472
  };
459169
459473
  writeWireMessage(msg);
459170
459474
  }
@@ -459236,7 +459540,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
459236
459540
  const approvalInputWithOtid = {
459237
459541
  type: "approval",
459238
459542
  approvals: executedResults,
459239
- otid: randomUUID39()
459543
+ otid: randomUUID41()
459240
459544
  };
459241
459545
  currentInput = [approvalInputWithOtid];
459242
459546
  continue;
@@ -459299,7 +459603,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
459299
459603
  message: errorDetails,
459300
459604
  stop_reason: "error",
459301
459605
  session_id: sessionId,
459302
- uuid: randomUUID39()
459606
+ uuid: randomUUID41()
459303
459607
  };
459304
459608
  writeWireMessage(errorMsg2);
459305
459609
  const errorResultMsg = {
@@ -459342,7 +459646,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
459342
459646
  message: `Unknown message type: ${message.type}`,
459343
459647
  stop_reason: "error",
459344
459648
  session_id: sessionId,
459345
- uuid: randomUUID39()
459649
+ uuid: randomUUID41()
459346
459650
  };
459347
459651
  writeWireMessage(errorMsg);
459348
459652
  }
@@ -459830,7 +460134,7 @@ function estimateTokens(text2) {
459830
460134
  var BYTES_PER_TOKEN = 4;
459831
460135
 
459832
460136
  // src/cli/helpers/window-title-config.ts
459833
- import { homedir as homedir46 } from "node:os";
460137
+ import { homedir as homedir47 } from "node:os";
459834
460138
  import { basename as basename28, resolve as resolve40 } from "node:path";
459835
460139
  function isWindowTitleField(value) {
459836
460140
  return WINDOW_TITLE_FIELDS.includes(value);
@@ -460000,7 +460304,7 @@ function formatDirectoryDisplay(directory) {
460000
460304
  if (!directory)
460001
460305
  return null;
460002
460306
  const resolved = resolve40(directory);
460003
- const home = homedir46();
460307
+ const home = homedir47();
460004
460308
  if (resolved === home)
460005
460309
  return "~";
460006
460310
  if (resolved.startsWith(`${home}/`)) {
@@ -460724,8 +461028,8 @@ var init_queued_message_parts = __esm(() => {
460724
461028
  import { execFile as execFileCb5 } from "node:child_process";
460725
461029
  import { existsSync as existsSync66 } from "node:fs";
460726
461030
  import { appendFile as appendFile2, chmod, mkdir as mkdir17, writeFile as writeFile18 } from "node:fs/promises";
460727
- import { homedir as homedir47 } from "node:os";
460728
- import { join as join83 } from "node:path";
461031
+ import { homedir as homedir48 } from "node:os";
461032
+ import { join as join84 } from "node:path";
460729
461033
  import { promisify as promisify16 } from "node:util";
460730
461034
  function buildGitEnv(token2, askpassPath) {
460731
461035
  return {
@@ -460761,7 +461065,7 @@ async function runGit6(cwd2, args, env5) {
460761
461065
  }
460762
461066
  }
460763
461067
  async function writeGitAskpass(repoRoot) {
460764
- const askpassPath = join83(repoRoot, "hf-askpass.sh");
461068
+ const askpassPath = join84(repoRoot, "hf-askpass.sh");
460765
461069
  await writeFile18(askpassPath, [
460766
461070
  "#!/bin/sh",
460767
461071
  'case "$1" in',
@@ -460776,7 +461080,7 @@ async function writeGitAskpass(repoRoot) {
460776
461080
  }
460777
461081
  async function prepareHfRepo(env5) {
460778
461082
  await mkdir17(HF_CACHE_ROOT, { recursive: true });
460779
- if (!existsSync66(join83(HF_REPO_DIR, ".git"))) {
461083
+ if (!existsSync66(join84(HF_REPO_DIR, ".git"))) {
460780
461084
  await runGit6(HF_CACHE_ROOT, ["clone", "--depth", "1", HF_REPO_URL, HF_REPO_DIR], env5);
460781
461085
  return HF_REPO_DIR;
460782
461086
  }
@@ -460811,8 +461115,8 @@ async function maybeUploadReflectionArenaChoiceToHf(row) {
460811
461115
  const env5 = buildGitEnv(token2, askpassPath);
460812
461116
  try {
460813
461117
  const repoDir = await prepareHfRepo(env5);
460814
- await mkdir17(join83(repoDir, "data"), { recursive: true });
460815
- await appendFile2(join83(repoDir, HF_DATASET_PATH), `${JSON.stringify(row)}
461118
+ await mkdir17(join84(repoDir, "data"), { recursive: true });
461119
+ await appendFile2(join84(repoDir, HF_DATASET_PATH), `${JSON.stringify(row)}
460816
461120
  `, {
460817
461121
  encoding: "utf-8"
460818
461122
  });
@@ -460840,16 +461144,16 @@ var init_reflection_arena_hf_upload = __esm(() => {
460840
461144
  init_version();
460841
461145
  execFile18 = promisify16(execFileCb5);
460842
461146
  HF_REPO_URL = `https://huggingface.co/datasets/${HF_REPO_ID}`;
460843
- HF_CACHE_ROOT = join83(homedir47(), ".letta", "reflection-arena", "hf-upload");
460844
- HF_REPO_DIR = join83(HF_CACHE_ROOT, "repo");
461147
+ HF_CACHE_ROOT = join84(homedir48(), ".letta", "reflection-arena", "hf-upload");
461148
+ HF_REPO_DIR = join84(HF_CACHE_ROOT, "repo");
460845
461149
  });
460846
461150
 
460847
461151
  // src/cli/helpers/reflection-arena.ts
460848
461152
  import { execFile as execFileCb6 } from "node:child_process";
460849
- import { randomInt as randomInt2, randomUUID as randomUUID40 } from "node:crypto";
461153
+ import { randomInt as randomInt2, randomUUID as randomUUID42 } from "node:crypto";
460850
461154
  import { appendFile as appendFile3, mkdir as mkdir18, readFile as readFile30, writeFile as writeFile19 } from "node:fs/promises";
460851
- import { homedir as homedir48 } from "node:os";
460852
- import { join as join84 } from "node:path";
461155
+ import { homedir as homedir49 } from "node:os";
461156
+ import { join as join85 } from "node:path";
460853
461157
  import { promisify as promisify17 } from "node:util";
460854
461158
  function sampleReflectionArenaComparisonModel(excludedModels = []) {
460855
461159
  const excluded = new Set(excludedModels);
@@ -460898,16 +461202,16 @@ function candidateIsConfirmedNoOp(candidate) {
460898
461202
  return candidate.result?.success === true && candidate.result.memoryNoChanges === true && candidate.result.memoryHead === candidate.worktree.baseHead;
460899
461203
  }
460900
461204
  function getReflectionArenaRoot() {
460901
- return join84(homedir48(), ".letta", "reflection-arena");
461205
+ return join85(homedir49(), ".letta", "reflection-arena");
460902
461206
  }
460903
461207
  function getReflectionArenaRunsDir() {
460904
- return join84(getReflectionArenaRoot(), "runs");
461208
+ return join85(getReflectionArenaRoot(), "runs");
460905
461209
  }
460906
461210
  function getReflectionArenaChoiceLogPath() {
460907
- return join84(getReflectionArenaRoot(), "choices.jsonl");
461211
+ return join85(getReflectionArenaRoot(), "choices.jsonl");
460908
461212
  }
460909
461213
  function getReflectionArenaRunPath(runId) {
460910
- return join84(getReflectionArenaRunsDir(), `${runId}.json`);
461214
+ return join85(getReflectionArenaRunsDir(), `${runId}.json`);
460911
461215
  }
460912
461216
  async function saveReflectionArenaRun(run) {
460913
461217
  await mkdir18(getReflectionArenaRunsDir(), { recursive: true });
@@ -461208,7 +461512,7 @@ async function startReflectionArenaRun(options) {
461208
461512
  }
461209
461513
  let releaseReservation = true;
461210
461514
  try {
461211
- const runId = randomUUID40().slice(0, 8);
461515
+ const runId = randomUUID42().slice(0, 8);
461212
461516
  const labels = shuffledLabels();
461213
461517
  const prepared = await Promise.all([
461214
461518
  prepareReflectionMemoryWorktreeLaunch({
@@ -462064,12 +462368,12 @@ __export(exports_terminal_keybinding_installer, {
462064
462368
  import {
462065
462369
  copyFileSync as copyFileSync6,
462066
462370
  existsSync as existsSync67,
462067
- mkdirSync as mkdirSync45,
462068
- readFileSync as readFileSync42,
462069
- writeFileSync as writeFileSync35
462371
+ mkdirSync as mkdirSync46,
462372
+ readFileSync as readFileSync43,
462373
+ writeFileSync as writeFileSync36
462070
462374
  } from "node:fs";
462071
- import { homedir as homedir49, platform as platform10 } from "node:os";
462072
- import { dirname as dirname34, join as join85 } from "node:path";
462375
+ import { homedir as homedir50, platform as platform10 } from "node:os";
462376
+ import { dirname as dirname34, join as join86 } from "node:path";
462073
462377
  function detectTerminalType() {
462074
462378
  if (process.env.CURSOR_TRACE_ID || process.env.CURSOR_CHANNEL) {
462075
462379
  return "cursor";
@@ -462101,16 +462405,16 @@ function getKeybindingsPath(terminal) {
462101
462405
  }[terminal];
462102
462406
  const os9 = platform10();
462103
462407
  if (os9 === "darwin") {
462104
- return join85(homedir49(), "Library", "Application Support", appName, "User", "keybindings.json");
462408
+ return join86(homedir50(), "Library", "Application Support", appName, "User", "keybindings.json");
462105
462409
  }
462106
462410
  if (os9 === "win32") {
462107
462411
  const appData = process.env.APPDATA;
462108
462412
  if (!appData)
462109
462413
  return null;
462110
- return join85(appData, appName, "User", "keybindings.json");
462414
+ return join86(appData, appName, "User", "keybindings.json");
462111
462415
  }
462112
462416
  if (os9 === "linux") {
462113
- return join85(homedir49(), ".config", appName, "User", "keybindings.json");
462417
+ return join86(homedir50(), ".config", appName, "User", "keybindings.json");
462114
462418
  }
462115
462419
  return null;
462116
462420
  }
@@ -462135,7 +462439,7 @@ function keybindingExists(keybindingsPath) {
462135
462439
  if (!existsSync67(keybindingsPath))
462136
462440
  return false;
462137
462441
  try {
462138
- const content = readFileSync42(keybindingsPath, { encoding: "utf-8" });
462442
+ const content = readFileSync43(keybindingsPath, { encoding: "utf-8" });
462139
462443
  const keybindings = parseKeybindings(content);
462140
462444
  if (!keybindings)
462141
462445
  return false;
@@ -462162,13 +462466,13 @@ function installKeybinding(keybindingsPath) {
462162
462466
  }
462163
462467
  const parentDir = dirname34(keybindingsPath);
462164
462468
  if (!existsSync67(parentDir)) {
462165
- mkdirSync45(parentDir, { recursive: true });
462469
+ mkdirSync46(parentDir, { recursive: true });
462166
462470
  }
462167
462471
  let keybindings = [];
462168
462472
  let backupPath = null;
462169
462473
  if (existsSync67(keybindingsPath)) {
462170
462474
  backupPath = createBackup(keybindingsPath);
462171
- const content = readFileSync42(keybindingsPath, { encoding: "utf-8" });
462475
+ const content = readFileSync43(keybindingsPath, { encoding: "utf-8" });
462172
462476
  const parsed = parseKeybindings(content);
462173
462477
  if (parsed === null) {
462174
462478
  return {
@@ -462181,7 +462485,7 @@ function installKeybinding(keybindingsPath) {
462181
462485
  keybindings.push(SHIFT_ENTER_KEYBINDING);
462182
462486
  const newContent = `${JSON.stringify(keybindings, null, 2)}
462183
462487
  `;
462184
- writeFileSync35(keybindingsPath, newContent, { encoding: "utf-8" });
462488
+ writeFileSync36(keybindingsPath, newContent, { encoding: "utf-8" });
462185
462489
  return {
462186
462490
  success: true,
462187
462491
  backupPath: backupPath ?? undefined
@@ -462199,7 +462503,7 @@ function removeKeybinding(keybindingsPath) {
462199
462503
  if (!existsSync67(keybindingsPath)) {
462200
462504
  return { success: true };
462201
462505
  }
462202
- const content = readFileSync42(keybindingsPath, { encoding: "utf-8" });
462506
+ const content = readFileSync43(keybindingsPath, { encoding: "utf-8" });
462203
462507
  const keybindings = parseKeybindings(content);
462204
462508
  if (!keybindings) {
462205
462509
  return {
@@ -462210,7 +462514,7 @@ function removeKeybinding(keybindingsPath) {
462210
462514
  const filtered = keybindings.filter((kb) => !(kb.key?.toLowerCase() === "shift+enter" && kb.command === "workbench.action.terminal.sendSequence" && kb.when?.includes("terminalFocus")));
462211
462515
  const newContent = `${JSON.stringify(filtered, null, 2)}
462212
462516
  `;
462213
- writeFileSync35(keybindingsPath, newContent, { encoding: "utf-8" });
462517
+ writeFileSync36(keybindingsPath, newContent, { encoding: "utf-8" });
462214
462518
  return { success: true };
462215
462519
  } catch (error5) {
462216
462520
  const message = error5 instanceof Error ? error5.message : String(error5);
@@ -462263,14 +462567,14 @@ function getWezTermConfigPath() {
462263
462567
  }
462264
462568
  const xdgConfig = process.env.XDG_CONFIG_HOME;
462265
462569
  if (xdgConfig) {
462266
- const xdgPath = join85(xdgConfig, "wezterm", "wezterm.lua");
462570
+ const xdgPath = join86(xdgConfig, "wezterm", "wezterm.lua");
462267
462571
  if (existsSync67(xdgPath))
462268
462572
  return xdgPath;
462269
462573
  }
462270
- const configPath = join85(homedir49(), ".config", "wezterm", "wezterm.lua");
462574
+ const configPath = join86(homedir50(), ".config", "wezterm", "wezterm.lua");
462271
462575
  if (existsSync67(configPath))
462272
462576
  return configPath;
462273
- return join85(homedir49(), ".wezterm.lua");
462577
+ return join86(homedir50(), ".wezterm.lua");
462274
462578
  }
462275
462579
  function stripLuaCommentsFromLine(line, blockCommentEnd) {
462276
462580
  let code2 = "";
@@ -462376,7 +462680,7 @@ function wezTermDeleteFixExists(configPath) {
462376
462680
  if (!existsSync67(configPath))
462377
462681
  return false;
462378
462682
  try {
462379
- const content = readFileSync42(configPath, { encoding: "utf-8" });
462683
+ const content = readFileSync43(configPath, { encoding: "utf-8" });
462380
462684
  return content.includes("Letta Code: Fix Delete key") || content.includes("key = 'Delete'") && content.includes("SendString") && content.includes("\\x1b[3~");
462381
462685
  } catch {
462382
462686
  return false;
@@ -462393,14 +462697,14 @@ function installWezTermDeleteFix() {
462393
462697
  if (existsSync67(configPath)) {
462394
462698
  backupPath = `${configPath}.letta-backup`;
462395
462699
  copyFileSync6(configPath, backupPath);
462396
- content = readFileSync42(configPath, { encoding: "utf-8" });
462700
+ content = readFileSync43(configPath, { encoding: "utf-8" });
462397
462701
  }
462398
462702
  content = injectWezTermDeleteFix(content);
462399
462703
  const parentDir = dirname34(configPath);
462400
462704
  if (!existsSync67(parentDir)) {
462401
- mkdirSync45(parentDir, { recursive: true });
462705
+ mkdirSync46(parentDir, { recursive: true });
462402
462706
  }
462403
- writeFileSync35(configPath, content, { encoding: "utf-8" });
462707
+ writeFileSync36(configPath, content, { encoding: "utf-8" });
462404
462708
  return {
462405
462709
  success: true,
462406
462710
  backupPath: backupPath ?? undefined
@@ -462448,10 +462752,10 @@ __export(exports_settings2, {
462448
462752
  loadProjectSettings: () => loadProjectSettings,
462449
462753
  getSetting: () => getSetting
462450
462754
  });
462451
- import { homedir as homedir50 } from "node:os";
462452
- import { join as join86 } from "node:path";
462755
+ import { homedir as homedir51 } from "node:os";
462756
+ import { join as join87 } from "node:path";
462453
462757
  function getSettingsPath() {
462454
- return join86(homedir50(), ".letta", "settings.json");
462758
+ return join87(homedir51(), ".letta", "settings.json");
462455
462759
  }
462456
462760
  async function loadSettings() {
462457
462761
  const settingsPath = getSettingsPath();
@@ -462488,7 +462792,7 @@ async function getSetting(key2) {
462488
462792
  return settings3[key2];
462489
462793
  }
462490
462794
  function getProjectSettingsPath() {
462491
- return join86(process.cwd(), ".letta", "settings.local.json");
462795
+ return join87(process.cwd(), ".letta", "settings.local.json");
462492
462796
  }
462493
462797
  async function loadProjectSettings() {
462494
462798
  const settingsPath = getProjectSettingsPath();
@@ -462506,7 +462810,7 @@ async function loadProjectSettings() {
462506
462810
  }
462507
462811
  async function saveProjectSettings(settings3) {
462508
462812
  const settingsPath = getProjectSettingsPath();
462509
- const dirPath = join86(process.cwd(), ".letta");
462813
+ const dirPath = join87(process.cwd(), ".letta");
462510
462814
  try {
462511
462815
  if (!exists(dirPath)) {
462512
462816
  await mkdir(dirPath, { recursive: true });
@@ -468140,10 +468444,10 @@ var init_HelpDialog = __esm(async () => {
468140
468444
  });
468141
468445
 
468142
468446
  // src/hooks/writer.ts
468143
- import { homedir as homedir51 } from "node:os";
468447
+ import { homedir as homedir52 } from "node:os";
468144
468448
  import { resolve as resolve41 } from "node:path";
468145
468449
  function isProjectSettingsPathCollidingWithGlobal2(workingDirectory) {
468146
- const home = process.env.HOME || homedir51();
468450
+ const home = process.env.HOME || homedir52();
468147
468451
  const globalSettingsPath = resolve41(home, ".letta", "settings.json");
468148
468452
  const projectSettingsPath = resolve41(workingDirectory, ".letta", "settings.json");
468149
468453
  return globalSettingsPath === projectSettingsPath;
@@ -473936,14 +474240,14 @@ var init_InputRich = __esm(async () => {
473936
474240
  import { execFileSync as execFileSync7 } from "node:child_process";
473937
474241
  import {
473938
474242
  existsSync as existsSync68,
473939
- mkdirSync as mkdirSync46,
474243
+ mkdirSync as mkdirSync47,
473940
474244
  mkdtempSync as mkdtempSync6,
473941
- readFileSync as readFileSync43,
473942
- rmSync as rmSync18,
473943
- writeFileSync as writeFileSync36
474245
+ readFileSync as readFileSync44,
474246
+ rmSync as rmSync19,
474247
+ writeFileSync as writeFileSync37
473944
474248
  } from "node:fs";
473945
474249
  import { tmpdir as tmpdir12 } from "node:os";
473946
- import { dirname as dirname35, join as join87 } from "node:path";
474250
+ import { dirname as dirname35, join as join88 } from "node:path";
473947
474251
  function runCommand(command, args, cwd2, input) {
473948
474252
  try {
473949
474253
  return execFileSync7(command, args, {
@@ -474164,8 +474468,8 @@ async function createLettaAgent(apiKey, name) {
474164
474468
  return createMinimalAgent(apiKey, name);
474165
474469
  }
474166
474470
  function cloneRepoToTemp(repo) {
474167
- const tempDir = mkdtempSync6(join87(tmpdir12(), "letta-install-github-app-"));
474168
- const repoDir = join87(tempDir, "repo");
474471
+ const tempDir = mkdtempSync6(join88(tmpdir12(), "letta-install-github-app-"));
474472
+ const repoDir = join88(tempDir, "repo");
474169
474473
  runCommand("gh", ["repo", "clone", repo, repoDir, "--", "--depth=1"]);
474170
474474
  return { tempDir, repoDir };
474171
474475
  }
@@ -474176,19 +474480,19 @@ function runGit7(args, cwd2) {
474176
474480
  return runCommand("git", args, cwd2);
474177
474481
  }
474178
474482
  function writeWorkflow(repoDir, workflowPath, content) {
474179
- const absolutePath = join87(repoDir, workflowPath);
474483
+ const absolutePath = join88(repoDir, workflowPath);
474180
474484
  if (!existsSync68(dirname35(absolutePath))) {
474181
- mkdirSync46(dirname35(absolutePath), { recursive: true });
474485
+ mkdirSync47(dirname35(absolutePath), { recursive: true });
474182
474486
  }
474183
474487
  const next = `${content.trimEnd()}
474184
474488
  `;
474185
474489
  if (existsSync68(absolutePath)) {
474186
- const previous = readFileSync43(absolutePath, "utf8");
474490
+ const previous = readFileSync44(absolutePath, "utf8");
474187
474491
  if (previous === next) {
474188
474492
  return false;
474189
474493
  }
474190
474494
  }
474191
- writeFileSync36(absolutePath, next, "utf8");
474495
+ writeFileSync37(absolutePath, next, "utf8");
474192
474496
  return true;
474193
474497
  }
474194
474498
  function getDefaultBaseBranch(repoDir) {
@@ -474309,7 +474613,7 @@ async function installGithubApp(options) {
474309
474613
  agentUrl: resolvedAgentId ? buildAgentReference(resolvedAgentId) : null
474310
474614
  };
474311
474615
  } finally {
474312
- rmSync18(tempDir, { recursive: true, force: true });
474616
+ rmSync19(tempDir, { recursive: true, force: true });
474313
474617
  }
474314
474618
  }
474315
474619
  var DEFAULT_WORKFLOW_PATH = ".github/workflows/letta.yml", ALTERNATE_WORKFLOW_PATH = ".github/workflows/letta-code.yml";
@@ -478072,9 +478376,9 @@ __export(exports_generate_memory_viewer, {
478072
478376
  generateAndOpenMemoryViewer: () => generateAndOpenMemoryViewer
478073
478377
  });
478074
478378
  import { execFile as execFileCb7 } from "node:child_process";
478075
- import { chmodSync as chmodSync7, existsSync as existsSync69, mkdirSync as mkdirSync47, writeFileSync as writeFileSync37 } from "node:fs";
478076
- import { homedir as homedir52 } from "node:os";
478077
- import { join as join88 } from "node:path";
478379
+ import { chmodSync as chmodSync7, existsSync as existsSync69, mkdirSync as mkdirSync48, writeFileSync as writeFileSync38 } from "node:fs";
478380
+ import { homedir as homedir53 } from "node:os";
478381
+ import { join as join89 } from "node:path";
478078
478382
  import { promisify as promisify18 } from "node:util";
478079
478383
  function messagesFromOverview(overview) {
478080
478384
  return overview.messages?.map((message) => ({
@@ -478383,7 +478687,7 @@ ${m4.body}` : m4.subject;
478383
478687
  async function generateAndOpenMemoryViewer(agentId, options) {
478384
478688
  const memoryRoot = getScopedMemoryFilesystemRoot(agentId);
478385
478689
  const repoDir = memoryRoot;
478386
- if (!existsSync69(join88(repoDir, ".git"))) {
478690
+ if (!existsSync69(join89(repoDir, ".git"))) {
478387
478691
  throw new Error("Memory viewer requires memfs. Run /memfs enable first.");
478388
478692
  }
478389
478693
  const data = await collectMemoryData(agentId, repoDir, memoryRoot, options?.conversationId);
@@ -478394,13 +478698,13 @@ async function generateAndOpenMemoryViewer(agentId, options) {
478394
478698
  const jsonPayload = JSON.stringify(data).replace(/</g, "\\u003c");
478395
478699
  const html5 = memory_viewer_template_default.replace("<!--LETTA_DATA_PLACEHOLDER-->", () => jsonPayload);
478396
478700
  if (!existsSync69(VIEWERS_DIR)) {
478397
- mkdirSync47(VIEWERS_DIR, { recursive: true, mode: 448 });
478701
+ mkdirSync48(VIEWERS_DIR, { recursive: true, mode: 448 });
478398
478702
  }
478399
478703
  try {
478400
478704
  chmodSync7(VIEWERS_DIR, 448);
478401
478705
  } catch {}
478402
- const filePath = join88(VIEWERS_DIR, `memory-${encodeURIComponent(agentId)}.html`);
478403
- writeFileSync37(filePath, html5);
478706
+ const filePath = join89(VIEWERS_DIR, `memory-${encodeURIComponent(agentId)}.html`);
478707
+ writeFileSync38(filePath, html5);
478404
478708
  chmodSync7(filePath, 384);
478405
478709
  const skipOpen = Boolean(process.env.TMUX) || Boolean(process.env.SSH_CONNECTION) || Boolean(process.env.SSH_TTY);
478406
478710
  if (!skipOpen) {
@@ -478425,13 +478729,13 @@ var init_generate_memory_viewer = __esm(() => {
478425
478729
  init_local_memory_context();
478426
478730
  init_memory_viewer_template();
478427
478731
  execFile20 = promisify18(execFileCb7);
478428
- VIEWERS_DIR = join88(homedir52(), ".letta", "viewers");
478732
+ VIEWERS_DIR = join89(homedir53(), ".letta", "viewers");
478429
478733
  REFLECTION_PATTERN = /\(reflection\)|🔮|reflection:/i;
478430
478734
  });
478431
478735
 
478432
478736
  // src/cli/components/MemfsTreeViewer.tsx
478433
478737
  import { existsSync as existsSync70 } from "node:fs";
478434
- import { join as join89 } from "node:path";
478738
+ import { join as join90 } from "node:path";
478435
478739
  function renderTreePrefix(node) {
478436
478740
  let prefix = "";
478437
478741
  for (let i4 = 0;i4 < node.depth; i4++) {
@@ -478460,7 +478764,7 @@ function MemfsTreeViewer({
478460
478764
  const statusTimerRef = import_react88.useRef(null);
478461
478765
  const memoryRoot = getScopedMemoryFilesystemRoot(agentId);
478462
478766
  const memoryExists = existsSync70(memoryRoot);
478463
- const hasGitRepo = import_react88.useMemo(() => existsSync70(join89(memoryRoot, ".git")), [memoryRoot]);
478767
+ const hasGitRepo = import_react88.useMemo(() => existsSync70(join90(memoryRoot, ".git")), [memoryRoot]);
478464
478768
  function showStatus(msg, durationMs) {
478465
478769
  if (statusTimerRef.current)
478466
478770
  clearTimeout(statusTimerRef.current);
@@ -480836,11 +481140,11 @@ var init_PersonalitySelector = __esm(async () => {
480836
481140
 
480837
481141
  // src/utils/aws-credentials.ts
480838
481142
  import { readFile as readFile31 } from "node:fs/promises";
480839
- import { homedir as homedir53 } from "node:os";
480840
- import { join as join90 } from "node:path";
481143
+ import { homedir as homedir54 } from "node:os";
481144
+ import { join as join91 } from "node:path";
480841
481145
  async function parseAwsCredentials() {
480842
- const credentialsPath = join90(homedir53(), ".aws", "credentials");
480843
- const configPath = join90(homedir53(), ".aws", "config");
481146
+ const credentialsPath = join91(homedir54(), ".aws", "credentials");
481147
+ const configPath = join91(homedir54(), ".aws", "config");
480844
481148
  const profiles = new Map;
480845
481149
  try {
480846
481150
  const content = await readFile31(credentialsPath, "utf-8");
@@ -482419,8 +482723,8 @@ function SkillsDialog({ onClose, agentId }) {
482419
482723
  try {
482420
482724
  const { discoverSkills: discoverSkills2, SKILLS_DIR: SKILLS_DIR2 } = await Promise.resolve().then(() => (init_skills5(), exports_skills2));
482421
482725
  const { getSkillsDirectory: getSkillsDirectory2, getSkillSources: getSkillSources2 } = await Promise.resolve().then(() => (init_context(), exports_context));
482422
- const { join: join91 } = await import("node:path");
482423
- const skillsDir = getSkillsDirectory2() || join91(process.cwd(), SKILLS_DIR2);
482726
+ const { join: join92 } = await import("node:path");
482727
+ const skillsDir = getSkillsDirectory2() || join92(process.cwd(), SKILLS_DIR2);
482424
482728
  const result2 = await discoverSkills2(skillsDir, agentId, {
482425
482729
  sources: getSkillSources2()
482426
482730
  });
@@ -486631,12 +486935,12 @@ var init_ExitStats = __esm(async () => {
486631
486935
  });
486632
486936
 
486633
486937
  // src/cli/app/ids.ts
486634
- import { randomUUID as randomUUID41 } from "node:crypto";
486938
+ import { randomUUID as randomUUID43 } from "node:crypto";
486635
486939
  function uid(prefix) {
486636
486940
  return `${prefix}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
486637
486941
  }
486638
486942
  function createClientOtid() {
486639
- return randomUUID41();
486943
+ return randomUUID43();
486640
486944
  }
486641
486945
  function appendOptimisticUserLine(buffers, text2, otid) {
486642
486946
  if (!text2) {
@@ -501978,9 +502282,9 @@ __export(exports_generate_diff_viewer, {
501978
502282
  generateAndOpenDiffViewer: () => generateAndOpenDiffViewer
501979
502283
  });
501980
502284
  import { execFile as execFileCb8 } from "node:child_process";
501981
- import { chmodSync as chmodSync8, existsSync as existsSync71, mkdirSync as mkdirSync48, writeFileSync as writeFileSync38 } from "node:fs";
501982
- import { homedir as homedir54 } from "node:os";
501983
- import { isAbsolute as isAbsolute31, join as join91, resolve as resolve42 } from "node:path";
502285
+ import { chmodSync as chmodSync8, existsSync as existsSync71, mkdirSync as mkdirSync49, writeFileSync as writeFileSync39 } from "node:fs";
502286
+ import { homedir as homedir55 } from "node:os";
502287
+ import { isAbsolute as isAbsolute31, join as join92, resolve as resolve42 } from "node:path";
501984
502288
  import { promisify as promisify19 } from "node:util";
501985
502289
  async function runGit8(cwd2, args) {
501986
502290
  try {
@@ -502200,13 +502504,13 @@ async function generateAndOpenDiffViewer(targetPath) {
502200
502504
  const jsonPayload = JSON.stringify(payload).replace(/</g, "\\u003c");
502201
502505
  const html5 = diff_viewer_template_default.replace("<!--LETTA_DIFF_DATA_PLACEHOLDER-->", () => jsonPayload);
502202
502506
  if (!existsSync71(VIEWERS_DIR2)) {
502203
- mkdirSync48(VIEWERS_DIR2, { recursive: true, mode: 448 });
502507
+ mkdirSync49(VIEWERS_DIR2, { recursive: true, mode: 448 });
502204
502508
  }
502205
502509
  try {
502206
502510
  chmodSync8(VIEWERS_DIR2, 448);
502207
502511
  } catch {}
502208
- const filePath = join91(VIEWERS_DIR2, `diff-${encodeURIComponent(worktreePath)}.html`);
502209
- writeFileSync38(filePath, html5);
502512
+ const filePath = join92(VIEWERS_DIR2, `diff-${encodeURIComponent(worktreePath)}.html`);
502513
+ writeFileSync39(filePath, html5);
502210
502514
  chmodSync8(filePath, 384);
502211
502515
  const skipOpen = shouldSkipOpen();
502212
502516
  if (!skipOpen) {
@@ -502276,7 +502580,7 @@ var init_generate_diff_viewer = __esm(() => {
502276
502580
  init_ssr();
502277
502581
  init_diff_viewer_template();
502278
502582
  execFile21 = promisify19(execFileCb8);
502279
- VIEWERS_DIR2 = join91(homedir54(), ".letta", "viewers");
502583
+ VIEWERS_DIR2 = join92(homedir55(), ".letta", "viewers");
502280
502584
  GIT_MAX_BUFFER = 50 * 1024 * 1024;
502281
502585
  });
502282
502586
 
@@ -503525,7 +503829,7 @@ var init_notifications = __esm(() => {
503525
503829
  });
503526
503830
 
503527
503831
  // src/cli/app/use-approval-flow.ts
503528
- import { randomUUID as randomUUID42 } from "node:crypto";
503832
+ import { randomUUID as randomUUID44 } from "node:crypto";
503529
503833
  function useApprovalFlow(ctx) {
503530
503834
  const {
503531
503835
  abortControllerRef,
@@ -504037,7 +504341,7 @@ function useApprovalFlow(ctx) {
504037
504341
  {
504038
504342
  type: "approval",
504039
504343
  approvals: allResults,
504040
- otid: randomUUID42()
504344
+ otid: randomUUID44()
504041
504345
  }
504042
504346
  ]);
504043
504347
  } catch (error5) {
@@ -504240,16 +504544,16 @@ __export(exports_shell_aliases, {
504240
504544
  expandAliases: () => expandAliases,
504241
504545
  clearAliasCache: () => clearAliasCache
504242
504546
  });
504243
- import { existsSync as existsSync72, readFileSync as readFileSync44 } from "node:fs";
504244
- import { homedir as homedir55 } from "node:os";
504245
- import { join as join92 } from "node:path";
504547
+ import { existsSync as existsSync72, readFileSync as readFileSync45 } from "node:fs";
504548
+ import { homedir as homedir56 } from "node:os";
504549
+ import { join as join93 } from "node:path";
504246
504550
  function parseAliasesFromFile(filePath) {
504247
504551
  const aliases = new Map;
504248
504552
  if (!existsSync72(filePath)) {
504249
504553
  return aliases;
504250
504554
  }
504251
504555
  try {
504252
- const content = readFileSync44(filePath, "utf-8");
504556
+ const content = readFileSync45(filePath, "utf-8");
504253
504557
  const lines = content.split(`
504254
504558
  `);
504255
504559
  let inFunction = false;
@@ -504311,10 +504615,10 @@ function loadAliases(forceReload = false) {
504311
504615
  if (aliasCache && !forceReload) {
504312
504616
  return aliasCache;
504313
504617
  }
504314
- const home = homedir55();
504618
+ const home = homedir56();
504315
504619
  const allAliases = new Map;
504316
504620
  for (const file of ALIAS_FILES) {
504317
- const filePath = join92(home, file);
504621
+ const filePath = join93(home, file);
504318
504622
  const fileAliases = parseAliasesFromFile(filePath);
504319
504623
  for (const [name, value] of fileAliases) {
504320
504624
  allAliases.set(name, value);
@@ -505465,7 +505769,7 @@ var init_system_reminders = __esm(() => {
505465
505769
  });
505466
505770
 
505467
505771
  // src/cli/app/use-conversation-loop.ts
505468
- import { randomUUID as randomUUID43 } from "node:crypto";
505772
+ import { randomUUID as randomUUID45 } from "node:crypto";
505469
505773
  function sleep11(ms) {
505470
505774
  return new Promise((resolve43) => setTimeout(resolve43, ms));
505471
505775
  }
@@ -505774,16 +506078,16 @@ function useConversationLoop(ctx) {
505774
506078
  currentInput = [
505775
506079
  ...lastSentInputRef.current.map((m4) => ({
505776
506080
  ...m4,
505777
- otid: randomUUID43()
506081
+ otid: randomUUID45()
505778
506082
  })),
505779
506083
  ...currentInput.map((m4) => m4.type === "message" && m4.role === "user" ? {
505780
506084
  ...m4,
505781
- otid: randomUUID43(),
506085
+ otid: randomUUID45(),
505782
506086
  content: [
505783
506087
  { type: "text", text: INTERRUPT_RECOVERY_ALERT },
505784
506088
  ...typeof m4.content === "string" ? [{ type: "text", text: m4.content }] : Array.isArray(m4.content) ? m4.content : []
505785
506089
  ]
505786
- } : { ...m4, otid: randomUUID43() })
506090
+ } : { ...m4, otid: randomUUID45() })
505787
506091
  ];
505788
506092
  pendingInterruptRecoveryConversationIdRef.current = null;
505789
506093
  lastSentInputRef.current = [
@@ -505822,7 +506126,7 @@ function useConversationLoop(ctx) {
505822
506126
  type: "text",
505823
506127
  text: sc.content
505824
506128
  })),
505825
- otid: randomUUID43()
506129
+ otid: randomUUID45()
505826
506130
  }
505827
506131
  ];
505828
506132
  }
@@ -506182,7 +506486,7 @@ ${feedback}
506182
506486
  });
506183
506487
  buffersRef.current.order.push(statusId);
506184
506488
  refreshDerived();
506185
- const hookMessageOtid = randomUUID43();
506489
+ const hookMessageOtid = randomUUID45();
506186
506490
  setTimeout(() => {
506187
506491
  processConversation([
506188
506492
  {
@@ -506209,7 +506513,7 @@ ${feedback}
506209
506513
  turnEndContinue = undefined;
506210
506514
  }
506211
506515
  if (turnEndContinue) {
506212
- const continueOtid = randomUUID43();
506516
+ const continueOtid = randomUUID45();
506213
506517
  setTimeout(() => {
506214
506518
  processConversation([
506215
506519
  {
@@ -506563,7 +506867,7 @@ ${feedback}
506563
506867
  {
506564
506868
  type: "approval",
506565
506869
  approvals: allResults,
506566
- otid: randomUUID43()
506870
+ otid: randomUUID45()
506567
506871
  }
506568
506872
  ], {
506569
506873
  allowReentry: true,
@@ -506769,9 +507073,9 @@ ${feedback}
506769
507073
  ...currentInput,
506770
507074
  {
506771
507075
  type: "message",
506772
- role: "system",
507076
+ role: "user",
506773
507077
  content: `<system-reminder>The previous response was empty. Please provide a response with either text content or a tool call.</system-reminder>`,
506774
- otid: randomUUID43()
507078
+ otid: randomUUID45()
506775
507079
  }
506776
507080
  ];
506777
507081
  }
@@ -507048,7 +507352,7 @@ var init_use_conversation_loop = __esm(async () => {
507048
507352
  });
507049
507353
 
507050
507354
  // src/cli/app/use-conversation-switching.ts
507051
- import { randomUUID as randomUUID44 } from "node:crypto";
507355
+ import { randomUUID as randomUUID46 } from "node:crypto";
507052
507356
  function useConversationSwitching(ctx) {
507053
507357
  const {
507054
507358
  abortControllerRef,
@@ -507123,7 +507427,7 @@ function useConversationSwitching(ctx) {
507123
507427
  {
507124
507428
  role: "user",
507125
507429
  content: question,
507126
- otid: randomUUID44()
507430
+ otid: randomUUID46()
507127
507431
  }
507128
507432
  ];
507129
507433
  let approvalRecoveryRetries = 0;
@@ -508424,7 +508728,7 @@ var init_memory_citations_env = __esm(() => {
508424
508728
  'letta.events.on("tool_start", handler) receives event.toolName, event.args, event.toolCallId, and event.conversationId.',
508425
508729
  "letta.tools.register({ name, description, parameters, requiresApproval, parallelSafe, run }) registers a tool available to the model.",
508426
508730
  "For eval compatibility, the snapshot tool must be named exactly memory_citation_snapshot.",
508427
- 'For turn_start reminders, append a separate { type: "message", role: "system", content: reminder } object to event.input. Do not concatenate onto an existing message content field because content may be structured parts.',
508731
+ 'For turn_start reminders, append a separate { type: "message", role: "user", content: "<system-reminder>" + reminder + "</system-reminder>" } object to event.input. Do not concatenate onto an existing message content field because content may be structured parts.',
508428
508732
  "For tool run handlers, ctx.conversation.id is the active conversation id; use it to retrieve state keyed by event.conversationId.",
508429
508733
  "Avoid fragile generated regex strings with embedded quote characters; simple string matching/splitting is fine. The candidate must be syntactically valid TypeScript."
508430
508734
  ],
@@ -508471,7 +508775,7 @@ var init_memory_citations_env = __esm(() => {
508471
508775
  assertions: [
508472
508776
  {
508473
508777
  type: "turn_start_injects_message",
508474
- role: "system",
508778
+ role: "user",
508475
508779
  contains: ["[[", "]]", "cite", "memory"],
508476
508780
  notContains: ["unconditionally", "always call"],
508477
508781
  input: [
@@ -508980,7 +509284,7 @@ export function activate(letta) {
508980
509284
  // strings to existing content because content may be structured parts.
508981
509285
  event.input = [
508982
509286
  ...event.input,
508983
- { type: "message", role: "system", content: "mod reminder" },
509287
+ { type: "message", role: "user", content: "<system-reminder>mod reminder</system-reminder>" },
508984
509288
  ];
508985
509289
  return { input: event.input };
508986
509290
  }));
@@ -509136,7 +509440,7 @@ async function evaluateModLearningAssertions(params) {
509136
509440
  };
509137
509441
  const emission = await engine4.emitEvent("turn_start", event, context3);
509138
509442
  const newMessages = event.input.slice(originalInput.length);
509139
- const role = assertion.role ?? "system";
509443
+ const role = assertion.role ?? "user";
509140
509444
  const matchingMessages = newMessages.filter((message) => message.role === role);
509141
509445
  const matchingText = matchingMessages.map((message) => stringifyMessageContent(message.content)).join(`
509142
509446
  `);
@@ -512539,10 +512843,10 @@ var init_conversation_switch_alert = __esm(() => {
512539
512843
  });
512540
512844
 
512541
512845
  // src/cli/app/use-submit-handler.ts
512542
- import { randomUUID as randomUUID45 } from "node:crypto";
512543
- import { existsSync as existsSync73, readFileSync as readFileSync45, renameSync as renameSync8 } from "node:fs";
512846
+ import { randomUUID as randomUUID47 } from "node:crypto";
512847
+ import { existsSync as existsSync73, readFileSync as readFileSync46, renameSync as renameSync9 } from "node:fs";
512544
512848
  import { tmpdir as tmpdir13 } from "node:os";
512545
- import { join as join93 } from "node:path";
512849
+ import { join as join94 } from "node:path";
512546
512850
  async function findCustomCommandByName(commandName) {
512547
512851
  const { findCustomCommand: findCustomCommand2 } = await Promise.resolve().then(() => (init_custom(), exports_custom));
512548
512852
  return findCustomCommand2(commandName);
@@ -512965,7 +513269,7 @@ ${SYSTEM_REMINDER_CLOSE}` : "";
512965
513269
  content: buildTextParts(`${SYSTEM_REMINDER_OPEN}
512966
513270
  ${prompt}
512967
513271
  ${SYSTEM_REMINDER_CLOSE}`),
512968
- otid: randomUUID45()
513272
+ otid: randomUUID47()
512969
513273
  }
512970
513274
  ]);
512971
513275
  } catch (error5) {
@@ -513029,7 +513333,7 @@ ${SYSTEM_REMINDER_CLOSE}`),
513029
513333
  type: "message",
513030
513334
  role: "user",
513031
513335
  content: buildTextParts(buildModCommandPrompt(result3)),
513032
- otid: randomUUID45()
513336
+ otid: randomUUID47()
513033
513337
  }
513034
513338
  ]);
513035
513339
  } else if (result3.type === "output") {
@@ -513074,7 +513378,7 @@ ${SYSTEM_REMINDER_CLOSE}`),
513074
513378
  ${SYSTEM_REMINDER_OPEN}
513075
513379
  ${request2}
513076
513380
  ${SYSTEM_REMINDER_CLOSE}`),
513077
- otid: randomUUID45()
513381
+ otid: randomUUID47()
513078
513382
  }
513079
513383
  ]);
513080
513384
  } catch (error5) {
@@ -513242,12 +513546,12 @@ ${SYSTEM_REMINDER_CLOSE}`),
513242
513546
  try {
513243
513547
  const memoryRoot = getScopedMemoryFilesystemRoot(agentId);
513244
513548
  const personaCandidates = [
513245
- join93(memoryRoot, "system", "persona.md"),
513246
- join93(memoryRoot, "memory", "system", "persona.md")
513549
+ join94(memoryRoot, "system", "persona.md"),
513550
+ join94(memoryRoot, "memory", "system", "persona.md")
513247
513551
  ];
513248
513552
  const personaPath = personaCandidates.find((candidate) => existsSync73(candidate));
513249
513553
  if (personaPath) {
513250
- const personaContent = readFileSync45(personaPath, "utf-8");
513554
+ const personaContent = readFileSync46(personaPath, "utf-8");
513251
513555
  setCurrentPersonalityId(detectPersonalityFromPersonaFile(personaContent));
513252
513556
  } else {
513253
513557
  setCurrentPersonalityId(null);
@@ -513343,7 +513647,7 @@ ${SYSTEM_REMINDER_CLOSE}`),
513343
513647
  ${SYSTEM_REMINDER_OPEN}
513344
513648
  ${request2}
513345
513649
  ${SYSTEM_REMINDER_CLOSE}`),
513346
- otid: randomUUID45()
513650
+ otid: randomUUID47()
513347
513651
  }
513348
513652
  ]);
513349
513653
  } catch (error5) {
@@ -514095,8 +514399,8 @@ Path: ${memoryDir}`, true);
514095
514399
  updateMemorySyncCommand(cmdId, "No local memory filesystem found to reset.", true, msg);
514096
514400
  return { submitted: true };
514097
514401
  }
514098
- const backupDir = join93(tmpdir13(), `letta-memfs-reset-${agentId}-${Date.now()}`);
514099
- renameSync8(memoryDir, backupDir);
514402
+ const backupDir = join94(tmpdir13(), `letta-memfs-reset-${agentId}-${Date.now()}`);
514403
+ renameSync9(memoryDir, backupDir);
514100
514404
  if (getBackend().capabilities.localMemfs) {
514101
514405
  const { initializeLocalMemoryRepo: initializeLocalMemoryRepo2 } = await Promise.resolve().then(() => (init_memory_git(), exports_memory_git));
514102
514406
  await initializeLocalMemoryRepo2({
@@ -514156,7 +514460,7 @@ ${SYSTEM_REMINDER_CLOSE}`;
514156
514460
  type: "message",
514157
514461
  role: "user",
514158
514462
  content: buildTextParts(skillMessage),
514159
- otid: randomUUID45()
514463
+ otid: randomUUID47()
514160
514464
  }
514161
514465
  ]);
514162
514466
  } catch (error5) {
@@ -514194,7 +514498,7 @@ ${SYSTEM_REMINDER_CLOSE}`;
514194
514498
  type: "message",
514195
514499
  role: "user",
514196
514500
  content: rememberParts,
514197
- otid: randomUUID45()
514501
+ otid: randomUUID47()
514198
514502
  }
514199
514503
  ]);
514200
514504
  } catch (error5) {
@@ -514610,7 +514914,7 @@ Resumed reflection arena choice prompt for run ${run2.runId}.`, true);
514610
514914
  type: "message",
514611
514915
  role: "user",
514612
514916
  content: buildTextParts(initMessage),
514613
- otid: randomUUID45()
514917
+ otid: randomUUID47()
514614
514918
  }
514615
514919
  ]);
514616
514920
  } catch (error5) {
@@ -514643,7 +514947,7 @@ Resumed reflection arena choice prompt for run ${run2.runId}.`, true);
514643
514947
  type: "message",
514644
514948
  role: "user",
514645
514949
  content: buildTextParts(doctorMessage),
514646
- otid: randomUUID45()
514950
+ otid: randomUUID47()
514647
514951
  }
514648
514952
  ]);
514649
514953
  } catch (error5) {
@@ -514775,7 +515079,7 @@ Resumed reflection arena choice prompt for run ${run2.runId}.`, true);
514775
515079
  type: "message",
514776
515080
  role: "user",
514777
515081
  content: buildTextParts(wrapSkillPrompt2(matchedSkill.id, skillContent, userRequest)),
514778
- otid: randomUUID45()
515082
+ otid: randomUUID47()
514779
515083
  }
514780
515084
  ]);
514781
515085
  } catch (error5) {
@@ -514926,7 +515230,7 @@ ${SYSTEM_REMINDER_CLOSE}
514926
515230
  initialInput.push({
514927
515231
  type: "approval",
514928
515232
  approvals: eagerRecoveryDenials,
514929
- otid: randomUUID45()
515233
+ otid: randomUUID47()
514930
515234
  });
514931
515235
  }
514932
515236
  const queuedApprovalInput = consumeQueuedApprovalInputForCurrentConversation();
@@ -515049,7 +515353,7 @@ var init_use_submit_handler = __esm(async () => {
515049
515353
  });
515050
515354
 
515051
515355
  // src/cli/app/AppCoordinator.tsx
515052
- import { join as join94 } from "node:path";
515356
+ import { join as join95 } from "node:path";
515053
515357
  function buildStartupCommandHints(options) {
515054
515358
  const {
515055
515359
  isResumingConversation,
@@ -516336,7 +516640,7 @@ function App2({
516336
516640
  agentId: a2.agentId ?? null
516337
516641
  }))
516338
516642
  });
516339
- const agentModsDirectory = modContext.memfs.enabled && modContext.memfs.memoryDir ? join94(modContext.memfs.memoryDir, "mods") : null;
516643
+ const agentModsDirectory = modContext.memfs.enabled && modContext.memfs.memoryDir ? join95(modContext.memfs.memoryDir, "mods") : null;
516340
516644
  const modAdapter = useLocalModAdapter(modContext, {
516341
516645
  agentModsDirectory,
516342
516646
  disabled: modsDisabled,
@@ -518684,12 +518988,12 @@ EXAMPLES
518684
518988
  console.log(usage);
518685
518989
  }
518686
518990
  async function printInfo() {
518687
- const { join: join95 } = await import("node:path");
518991
+ const { join: join96 } = await import("node:path");
518688
518992
  const { getVersion: getVersion2 } = await Promise.resolve().then(() => (init_version(), exports_version));
518689
518993
  const { SKILLS_DIR: SKILLS_DIR2 } = await Promise.resolve().then(() => (init_skills5(), exports_skills2));
518690
518994
  const { exists: exists2 } = await Promise.resolve().then(() => (init_fs(), exports_fs));
518691
518995
  const cwd2 = process.cwd();
518692
- const skillsDir = join95(cwd2, SKILLS_DIR2);
518996
+ const skillsDir = join96(cwd2, SKILLS_DIR2);
518693
518997
  const skillsExist = exists2(skillsDir);
518694
518998
  await settingsManager.loadLocalProjectSettings(cwd2);
518695
518999
  const pinned = settingsManager.getPinnedAgents();
@@ -522360,4 +522664,4 @@ function registerBunOAuthFlows() {
522360
522664
  registerBunOAuthFlows();
522361
522665
  await init_src5().then(() => exports_src2);
522362
522666
 
522363
- //# debugId=73D666396EC039C064756E2164756E21
522667
+ //# debugId=BB160EB36D5AADE464756E2164756E21