@letta-ai/letta-code 0.30.14 → 0.30.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/dist/mcp-client.js +2 -2
  2. package/dist/mcp-client.js.map +1 -1
  3. package/dist/types/agent/message.d.ts +2 -0
  4. package/dist/types/agent/message.d.ts.map +1 -1
  5. package/dist/types/backend/local/local-agent-record.d.ts +14 -0
  6. package/dist/types/backend/local/local-agent-record.d.ts.map +1 -0
  7. package/dist/types/backend/local/local-store.d.ts +5 -5
  8. package/dist/types/backend/local/local-store.d.ts.map +1 -1
  9. package/dist/types/mods/mod-engine.d.ts.map +1 -1
  10. package/dist/types/mods/turn-start-input.d.ts +5 -0
  11. package/dist/types/mods/turn-start-input.d.ts.map +1 -0
  12. package/dist/types/tools/impl/enter-worktree.d.ts.map +1 -1
  13. package/dist/types/tools/impl/monitor.d.ts.map +1 -1
  14. package/dist/types/tools/impl/worktree-git.d.ts +2 -0
  15. package/dist/types/tools/impl/worktree-git.d.ts.map +1 -1
  16. package/dist/types/types/runtime-scope.d.ts +2 -0
  17. package/dist/types/types/runtime-scope.d.ts.map +1 -1
  18. package/dist/types/websocket/listener/protocol-outbound.d.ts +1 -2
  19. package/dist/types/websocket/listener/protocol-outbound.d.ts.map +1 -1
  20. package/dist/types/websocket/listener/runtime.d.ts.map +1 -1
  21. package/dist/types/websocket/listener/scope.d.ts +1 -0
  22. package/dist/types/websocket/listener/scope.d.ts.map +1 -1
  23. package/dist/types/websocket/listener/turn-lifecycle.d.ts +3 -0
  24. package/dist/types/websocket/listener/turn-lifecycle.d.ts.map +1 -1
  25. package/dist/types/websocket/listener/types.d.ts +4 -0
  26. package/dist/types/websocket/listener/types.d.ts.map +1 -1
  27. package/letta.js +838 -679
  28. package/package.json +1 -1
  29. package/scripts/isolated-unit-tests.json +22 -0
  30. package/scripts/source-file-size-baseline.json +3 -3
package/letta.js CHANGED
@@ -5488,7 +5488,7 @@ var package_default;
5488
5488
  var init_package = __esm(() => {
5489
5489
  package_default = {
5490
5490
  name: "@letta-ai/letta-code",
5491
- version: "0.30.14",
5491
+ version: "0.30.16",
5492
5492
  description: "Letta Code is a CLI tool for interacting with stateful Letta agents from the terminal.",
5493
5493
  type: "module",
5494
5494
  packageManager: "bun@1.3.0",
@@ -152619,7 +152619,8 @@ function resolveRuntimeScope(runtime, params) {
152619
152619
  const resolvedConversationId = resolveScopedConversationId(runtime, params);
152620
152620
  return {
152621
152621
  agent_id: resolvedAgentId,
152622
- conversation_id: resolvedConversationId
152622
+ conversation_id: resolvedConversationId,
152623
+ ...params?.super_run_id ? { super_run_id: params.super_run_id } : {}
152623
152624
  };
152624
152625
  }
152625
152626
 
@@ -152754,6 +152755,7 @@ class TurnLifecycle {
152754
152755
  #createId;
152755
152756
  #state = IDLE_STATE;
152756
152757
  #lastStopReason = null;
152758
+ #superRunOwner = null;
152757
152759
  constructor(createId = () => crypto.randomUUID()) {
152758
152760
  this.#createId = createId;
152759
152761
  }
@@ -152775,6 +152777,9 @@ class TurnLifecycle {
152775
152777
  get activeRunId() {
152776
152778
  return this.#state.kind === "active" ? this.#state.runId : null;
152777
152779
  }
152780
+ get superRunId() {
152781
+ return this.#superRunOwner?.superRunId ?? null;
152782
+ }
152778
152783
  get executingToolCallIds() {
152779
152784
  return this.#state.kind === "active" || this.#state.kind === "cancelling" ? this.#state.executingToolCallIds : [];
152780
152785
  }
@@ -152824,6 +152829,10 @@ class TurnLifecycle {
152824
152829
  id: this.#createId(),
152825
152830
  signal: abortController.signal
152826
152831
  });
152832
+ this.#superRunOwner = {
152833
+ leaseId: lease.id,
152834
+ superRunId: options3.superRunId ?? null
152835
+ };
152827
152836
  this.#state = {
152828
152837
  kind: "active",
152829
152838
  origin: options3.origin,
@@ -152850,6 +152859,13 @@ class TurnLifecycle {
152850
152859
  this.#state = { ...this.#state, loopStatus: status };
152851
152860
  return true;
152852
152861
  }
152862
+ releaseSuperRunId(lease) {
152863
+ if (this.#superRunOwner?.leaseId !== lease.id) {
152864
+ return false;
152865
+ }
152866
+ this.#superRunOwner = null;
152867
+ return true;
152868
+ }
152853
152869
  setRunId(lease, runId) {
152854
152870
  if (this.#state.kind !== "active" || !this.isCurrent(lease)) {
152855
152871
  return false;
@@ -152881,6 +152897,7 @@ class TurnLifecycle {
152881
152897
  if (this.#state.kind !== "idle") {
152882
152898
  return false;
152883
152899
  }
152900
+ this.#superRunOwner = null;
152884
152901
  this.#state = {
152885
152902
  kind: "command",
152886
152903
  loopStatus: "EXECUTING_COMMAND"
@@ -152971,6 +152988,7 @@ class TurnLifecycle {
152971
152988
  }
152972
152989
  reset(stopReason = "cancelled") {
152973
152990
  const state = this.#state;
152991
+ this.#superRunOwner = null;
152974
152992
  if (state.kind === "active" || state.kind === "cancelling") {
152975
152993
  if (!state.abortController.signal.aborted) {
152976
152994
  state.abortController.abort();
@@ -153141,6 +153159,9 @@ function createConversationRuntime(listener, agentId, conversationId) {
153141
153159
  key: runtimeKey,
153142
153160
  agentId: normalizedAgentId,
153143
153161
  conversationId: normalizedConversationId,
153162
+ get superRunId() {
153163
+ return turnLifecycle.superRunId;
153164
+ },
153144
153165
  skillSources: listener.skillSourcesByConversation.get(runtimeKey)?.slice(),
153145
153166
  activeConnectionId: null,
153146
153167
  turnLifecycle,
@@ -157592,7 +157613,8 @@ function getScopeForRuntime(runtime, scope) {
157592
157613
  if (runtime && "listener" in runtime) {
157593
157614
  return {
157594
157615
  agent_id: scope?.agent_id ?? runtime.agentId,
157595
- conversation_id: scope?.conversation_id ?? runtime.conversationId
157616
+ conversation_id: scope?.conversation_id ?? runtime.conversationId,
157617
+ super_run_id: scope?.super_run_id ?? runtime.superRunId ?? undefined
157596
157618
  };
157597
157619
  }
157598
157620
  return scope ?? {};
@@ -157757,7 +157779,7 @@ function emitProtocolV2Message(socket, runtime, message, scope, routing) {
157757
157779
  typeLabel: message.type,
157758
157780
  frameClass,
157759
157781
  ...frameClass === "status" ? {
157760
- coalesceKey: `${message.type}:${runtimeScope.agent_id ?? ""}:${runtimeScope.conversation_id ?? ""}`
157782
+ coalesceKey: `${message.type}:${runtimeScope.agent_id ?? ""}:${runtimeScope.conversation_id ?? ""}:${runtimeScope.super_run_id ?? ""}`
157761
157783
  } : {},
157762
157784
  build: () => {
157763
157785
  const eventSeq = nextListenerConnectionEventSeq(connection, listener);
@@ -157948,7 +157970,8 @@ function emitDequeuedUserMessage(socket, runtime, incoming, batch) {
157948
157970
  date: new Date().toISOString(),
157949
157971
  message_type: "user_message",
157950
157972
  content,
157951
- otid
157973
+ otid,
157974
+ created_by_id: incoming.actingUserId
157952
157975
  }, {
157953
157976
  agent_id: incoming.agentId,
157954
157977
  conversation_id: incoming.conversationId
@@ -158410,7 +158433,6 @@ var init_enter_worktree_messages = __esm(() => {
158410
158433
  });
158411
158434
 
158412
158435
  // src/tools/impl/worktree-git.ts
158413
- import { spawn as spawn3 } from "node:child_process";
158414
158436
  import path16 from "node:path";
158415
158437
  function formatGitFailure(error54) {
158416
158438
  if (error54 instanceof GitCommandError) {
@@ -158436,46 +158458,41 @@ This looks like a Windows path-length issue. Try:
158436
158458
  - git config --global core.longpaths true
158437
158459
  - move the repo to a shorter path, like C:\\src\\<repo>, and retry.`;
158438
158460
  }
158461
+ function buildNonInteractiveGitEnv(base2 = getShellEnv()) {
158462
+ const env3 = {
158463
+ ...base2,
158464
+ GIT_TERMINAL_PROMPT: "0",
158465
+ GCM_INTERACTIVE: "never",
158466
+ GIT_ASKPASS: "",
158467
+ SSH_ASKPASS: "",
158468
+ SSH_ASKPASS_REQUIRE: "never"
158469
+ };
158470
+ const sshCommand = env3.GIT_SSH_COMMAND?.trim() || "ssh";
158471
+ env3.GIT_SSH_COMMAND = `${sshCommand} -o BatchMode=yes`;
158472
+ return env3;
158473
+ }
158439
158474
  async function runGit2(args, cwd, options3 = {}) {
158440
158475
  const timeoutMs = options3.timeoutMs ?? DEFAULT_GIT_TIMEOUT_MS;
158441
- return await new Promise((resolve11, reject) => {
158442
- const child = spawn3("git", args, {
158476
+ let result;
158477
+ try {
158478
+ result = await spawnWithLauncher(["git", ...args], {
158443
158479
  cwd,
158444
- env: getShellEnv(),
158445
- shell: false,
158446
- stdio: ["ignore", "pipe", "pipe"]
158447
- });
158448
- const stdoutChunks = [];
158449
- const stderrChunks = [];
158450
- let timedOut = false;
158451
- const timeout = setTimeout(() => {
158452
- timedOut = true;
158453
- child.kill("SIGTERM");
158454
- }, timeoutMs);
158455
- child.stdout?.on("data", (chunk) => stdoutChunks.push(chunk));
158456
- child.stderr?.on("data", (chunk) => stderrChunks.push(chunk));
158457
- child.on("error", (error54) => {
158458
- clearTimeout(timeout);
158459
- reject(new GitCommandError(`Failed to run git ${args.join(" ")}: ${error54.message}`, args));
158480
+ env: buildNonInteractiveGitEnv(),
158481
+ signal: options3.signal,
158482
+ timeoutMs
158460
158483
  });
158461
- child.on("close", (exitCode) => {
158462
- clearTimeout(timeout);
158463
- const result = {
158464
- stdout: Buffer.concat(stdoutChunks).toString("utf8"),
158465
- stderr: Buffer.concat(stderrChunks).toString("utf8"),
158466
- exitCode
158467
- };
158468
- if (timedOut) {
158469
- reject(new GitCommandError(`Timed out running git ${args.join(" ")}`, args, result));
158470
- return;
158471
- }
158472
- if (exitCode !== 0 && !options3.allowFailure) {
158473
- reject(new GitCommandError(`Failed to run git ${args.join(" ")}`, args, result));
158474
- return;
158475
- }
158476
- resolve11(result);
158484
+ } catch (error54) {
158485
+ const failure2 = error54;
158486
+ throw new GitCommandError(failure2.killed ? `Timed out running git ${args.join(" ")}` : `Failed to run git ${args.join(" ")}: ${failure2.message}`, args, {
158487
+ stdout: failure2.stdout ?? "",
158488
+ stderr: failure2.stderr ?? "",
158489
+ exitCode: typeof failure2.code === "number" ? failure2.code : null
158477
158490
  });
158478
- });
158491
+ }
158492
+ if (result.exitCode !== 0 && !options3.allowFailure) {
158493
+ throw new GitCommandError(`Failed to run git ${args.join(" ")}`, args, result);
158494
+ }
158495
+ return result;
158479
158496
  }
158480
158497
  async function gitStdout(args, cwd) {
158481
158498
  const result = await runGit2(args, cwd);
@@ -158488,11 +158505,13 @@ async function gitRefExists(cwd, ref6) {
158488
158505
  return result.exitCode === 0;
158489
158506
  }
158490
158507
  async function resolveRepoRoot(cwd) {
158491
- return await gitStdout(["rev-parse", "--show-toplevel"], cwd);
158508
+ const repoRoot = await gitStdout(["rev-parse", "--show-toplevel"], cwd);
158509
+ return path16.resolve(repoRoot);
158492
158510
  }
158493
158511
  async function resolvePrimaryWorktreeRoot(repoRoot) {
158494
158512
  const commonDir = await gitStdout(["rev-parse", "--path-format=absolute", "--git-common-dir"], repoRoot);
158495
- return path16.basename(commonDir) === ".git" ? path16.dirname(commonDir) : repoRoot;
158513
+ const primaryRoot = path16.basename(commonDir) === ".git" ? path16.dirname(commonDir) : repoRoot;
158514
+ return path16.resolve(primaryRoot);
158496
158515
  }
158497
158516
  async function resolveDefaultBaseRef(repoRoot) {
158498
158517
  const remoteHead = await runGit2(["symbolic-ref", "--quiet", "--short", "refs/remotes/origin/HEAD"], repoRoot, { allowFailure: true });
@@ -158519,6 +158538,7 @@ function isPathWithin(child, parent) {
158519
158538
  var DEFAULT_GIT_TIMEOUT_MS = 120000, GitCommandError;
158520
158539
  var init_worktree_git = __esm(() => {
158521
158540
  init_shell_env();
158541
+ init_shell_runner();
158522
158542
  GitCommandError = class GitCommandError extends Error {
158523
158543
  args;
158524
158544
  result;
@@ -158594,7 +158614,7 @@ async function resolveWorktreeContext(params) {
158594
158614
  const managedDir = path17.join(primaryRoot, ".letta", "worktrees");
158595
158615
  return { currentCwd, repoRoot, primaryRoot, managedDir };
158596
158616
  }
158597
- async function refreshBaseRef(repoRoot, baseRef) {
158617
+ async function refreshBaseRef(repoRoot, baseRef, signal) {
158598
158618
  const slashIndex = baseRef.indexOf("/");
158599
158619
  if (slashIndex <= 0) {
158600
158620
  return;
@@ -158607,9 +158627,7 @@ async function refreshBaseRef(repoRoot, baseRef) {
158607
158627
  if (!hasRemote) {
158608
158628
  return;
158609
158629
  }
158610
- await runGit2(["fetch", remote, `${branch}:refs/remotes/${remote}/${branch}`], repoRoot, {
158611
- timeoutMs: FETCH_GIT_TIMEOUT_MS
158612
- });
158630
+ await runGit2(["fetch", remote, `${branch}:refs/remotes/${remote}/${branch}`], repoRoot, { signal, timeoutMs: FETCH_GIT_TIMEOUT_MS });
158613
158631
  }
158614
158632
  async function chooseUniqueWorktreePath(worktreesDir, slug) {
158615
158633
  for (let index = 0;index < 100; index += 1) {
@@ -159030,7 +159048,7 @@ async function enter_worktree(rawArgs) {
159030
159048
  const branchName = await chooseUniqueBranchName(repoRoot, slug, getStringArg(args, "branch_name"));
159031
159049
  const baseRef = getStringArg(args, "base_ref") ?? await resolveDefaultBaseRef(repoRoot);
159032
159050
  if (args.refresh_base !== false) {
159033
- await refreshBaseRef(repoRoot, baseRef);
159051
+ await refreshBaseRef(repoRoot, baseRef, args.signal);
159034
159052
  }
159035
159053
  if (!await gitRefExists(repoRoot, baseRef)) {
159036
159054
  throw new Error(`Base ref does not exist: ${baseRef}`);
@@ -162991,7 +163009,7 @@ var init_monitor_event_stream = __esm(() => {
162991
163009
  });
162992
163010
 
162993
163011
  // src/tools/impl/monitor.ts
162994
- import { appendFileSync as appendFileSync4 } from "node:fs";
163012
+ import { appendFileSync as appendFileSync4, readFileSync as readFileSync9, writeFileSync as writeFileSync8 } from "node:fs";
162995
163013
  import { WebSocket as WebSocket4 } from "ws";
162996
163014
  function buildMonitorResult(taskId, timeoutMs, persistent) {
162997
163015
  const lifetime = persistent ? "persistent — runs until TaskStop or session end" : `timeout ${timeoutMs}ms`;
@@ -163039,11 +163057,10 @@ class MonitorOutputWriter {
163039
163057
  const marker = Buffer.from(`
163040
163058
  [output truncated at ${MONITOR_OUTPUT_FILE_BYTES} bytes]
163041
163059
  `, "utf8");
163042
- const contentBudget = Math.max(0, remaining - marker.length);
163043
- const content = validUtf8Prefix(chunk, contentBudget);
163044
- const markerBudget = remaining - content.length;
163045
- appendFileSync4(this.path, Buffer.concat([content, marker.subarray(0, markerBudget)]));
163046
- this.bytesWritten = MONITOR_OUTPUT_FILE_BYTES;
163060
+ const content = validUtf8Prefix(Buffer.concat([readFileSync9(this.path), chunk]), MONITOR_OUTPUT_FILE_BYTES - marker.length);
163061
+ const truncatedOutput = Buffer.concat([content, marker]);
163062
+ writeFileSync8(this.path, truncatedOutput);
163063
+ this.bytesWritten = truncatedOutput.length;
163047
163064
  this.truncated = true;
163048
163065
  }
163049
163066
  }
@@ -163099,13 +163116,16 @@ function normalizeMonitorArgs(args) {
163099
163116
  if (normalized.command !== undefined && typeof normalized.command !== "string") {
163100
163117
  throw new Error("Monitor command must be a string");
163101
163118
  }
163102
- const hasCommand = typeof normalized.command === "string";
163103
- const hasWebSocket = normalized.ws !== undefined;
163119
+ const hasCommand = typeof normalized.command === "string" && normalized.command.length > 0;
163120
+ const hasWebSocket = normalized.ws !== undefined && !(typeof normalized.ws === "object" && normalized.ws !== null && normalized.ws.url === "");
163104
163121
  if (Number(hasCommand) + Number(hasWebSocket) !== 1) {
163105
163122
  throw new Error("Monitor requires exactly one of command or ws");
163106
163123
  }
163107
- if (hasCommand && !normalized.command) {
163108
- throw new Error("Monitor requires exactly one of command or ws");
163124
+ if (!hasCommand) {
163125
+ delete normalized.command;
163126
+ }
163127
+ if (!hasWebSocket) {
163128
+ delete normalized.ws;
163109
163129
  }
163110
163130
  if (hasCommand && containsHiddenControlCharacter(normalized.command)) {
163111
163131
  throw new Error("Monitor command contains control characters that would be hidden in the approval dialog");
@@ -163669,12 +163689,12 @@ __export(exports_image_resize_magick, {
163669
163689
  resizeImageIfNeeded: () => resizeImageIfNeeded
163670
163690
  });
163671
163691
  import { execSync } from "node:child_process";
163672
- import { readFileSync as readFileSync9, unlinkSync as unlinkSync4, writeFileSync as writeFileSync8 } from "node:fs";
163692
+ import { readFileSync as readFileSync10, unlinkSync as unlinkSync4, writeFileSync as writeFileSync9 } from "node:fs";
163673
163693
  import { tmpdir as tmpdir4 } from "node:os";
163674
163694
  import { join as join21 } from "node:path";
163675
163695
  async function getImageDimensions(buffer) {
163676
163696
  const tempInput = join21(tmpdir4(), `image-${Date.now()}-${Math.random().toString(36).slice(2)}.tmp`);
163677
- writeFileSync8(tempInput, buffer);
163697
+ writeFileSync9(tempInput, buffer);
163678
163698
  try {
163679
163699
  const output = execSync(`magick identify -format "%w %h %m" "${tempInput}"`, {
163680
163700
  encoding: "utf-8"
@@ -163705,7 +163725,7 @@ async function compressToFitByteLimit(buffer, currentWidth, currentHeight) {
163705
163725
  return null;
163706
163726
  }
163707
163727
  const tempInput = join21(tmpdir4(), `compress-input-${Date.now()}-${Math.random().toString(36).slice(2)}.tmp`);
163708
- writeFileSync8(tempInput, buffer);
163728
+ writeFileSync9(tempInput, buffer);
163709
163729
  try {
163710
163730
  const qualities = [85, 70, 55, 40];
163711
163731
  for (const quality of qualities) {
@@ -163714,7 +163734,7 @@ async function compressToFitByteLimit(buffer, currentWidth, currentHeight) {
163714
163734
  execSync(`magick "${tempInput}" -quality ${quality} "${tempOutput}"`, {
163715
163735
  stdio: "ignore"
163716
163736
  });
163717
- const compressed = readFileSync9(tempOutput);
163737
+ const compressed = readFileSync10(tempOutput);
163718
163738
  if (compressed.length <= MAX_IMAGE_BYTES) {
163719
163739
  return buildVerifiedResizeResult(compressed, "image/jpeg", true, "compressed image output");
163720
163740
  }
@@ -163733,7 +163753,7 @@ async function compressToFitByteLimit(buffer, currentWidth, currentHeight) {
163733
163753
  execSync(`magick "${tempInput}" -resize ${scaledWidth}x${scaledHeight} -quality 70 "${tempOutput}"`, {
163734
163754
  stdio: "ignore"
163735
163755
  });
163736
- const reduced = readFileSync9(tempOutput);
163756
+ const reduced = readFileSync10(tempOutput);
163737
163757
  if (reduced.length <= MAX_IMAGE_BYTES) {
163738
163758
  return buildVerifiedResizeResult(reduced, "image/jpeg", true, "dimension-reduced image output");
163739
163759
  }
@@ -163760,7 +163780,7 @@ async function resizeImageIfNeeded(buffer, inputMediaType) {
163760
163780
  return buildVerifiedResizeResult(buffer, inputMediaType, false, "passthrough image output");
163761
163781
  }
163762
163782
  const tempInput = join21(tmpdir4(), `resize-input-${Date.now()}-${Math.random().toString(36).slice(2)}.tmp`);
163763
- writeFileSync8(tempInput, buffer);
163783
+ writeFileSync9(tempInput, buffer);
163764
163784
  try {
163765
163785
  if (needsResize) {
163766
163786
  const tempOutput2 = join21(tmpdir4(), `resize-output-${Date.now()}-${Math.random().toString(36).slice(2)}`);
@@ -163770,14 +163790,14 @@ async function resizeImageIfNeeded(buffer, inputMediaType) {
163770
163790
  execSync(`magick "${tempInput}" -resize ${MAX_IMAGE_WIDTH}x${MAX_IMAGE_HEIGHT}> -quality 85 "${tempOutput2}.jpg"`, {
163771
163791
  stdio: "ignore"
163772
163792
  });
163773
- outputBuffer2 = readFileSync9(`${tempOutput2}.jpg`);
163793
+ outputBuffer2 = readFileSync10(`${tempOutput2}.jpg`);
163774
163794
  outputMediaType = "image/jpeg";
163775
163795
  unlinkSync4(`${tempOutput2}.jpg`);
163776
163796
  } else {
163777
163797
  execSync(`magick "${tempInput}" -resize ${MAX_IMAGE_WIDTH}x${MAX_IMAGE_HEIGHT}> "${tempOutput2}.png"`, {
163778
163798
  stdio: "ignore"
163779
163799
  });
163780
- outputBuffer2 = readFileSync9(`${tempOutput2}.png`);
163800
+ outputBuffer2 = readFileSync10(`${tempOutput2}.png`);
163781
163801
  outputMediaType = "image/png";
163782
163802
  unlinkSync4(`${tempOutput2}.png`);
163783
163803
  }
@@ -163792,7 +163812,7 @@ async function resizeImageIfNeeded(buffer, inputMediaType) {
163792
163812
  execSync(`magick "${tempInput}" "${tempOutput}"`, {
163793
163813
  stdio: "ignore"
163794
163814
  });
163795
- const outputBuffer = readFileSync9(tempOutput);
163815
+ const outputBuffer = readFileSync10(tempOutput);
163796
163816
  unlinkSync4(tempOutput);
163797
163817
  const compressed = await compressToFitByteLimit(outputBuffer, width, height);
163798
163818
  if (compressed) {
@@ -163852,7 +163872,7 @@ async function convertHeicToJpegWithSips(buffer) {
163852
163872
  var init_image_resize_sips = () => {};
163853
163873
 
163854
163874
  // src/utils/image-resize.ts
163855
- import { spawn as spawn4 } from "node:child_process";
163875
+ import { spawn as spawn3 } from "node:child_process";
163856
163876
  import { existsSync as existsSync16 } from "node:fs";
163857
163877
  import { fileURLToPath as fileURLToPath4 } from "node:url";
163858
163878
  function resolveImageWorkerPath() {
@@ -163865,7 +163885,7 @@ function resolveImageWorkerPath() {
163865
163885
  function resizeWithSharpWorker(buffer, inputMediaType) {
163866
163886
  return new Promise((resolve18, reject) => {
163867
163887
  const workerPath = resolveImageWorkerPath();
163868
- const child = spawn4(process.execPath, [workerPath, inputMediaType], {
163888
+ const child = spawn3(process.execPath, [workerPath, inputMediaType], {
163869
163889
  shell: false,
163870
163890
  stdio: ["pipe", "pipe", "pipe"],
163871
163891
  windowsHide: true
@@ -164961,7 +164981,7 @@ var require_cross_spawn = __commonJS((exports, module3) => {
164961
164981
  var cp = __require("child_process");
164962
164982
  var parse8 = require_parse3();
164963
164983
  var enoent = require_enoent();
164964
- function spawn5(command, args, options3) {
164984
+ function spawn4(command, args, options3) {
164965
164985
  const parsed = parse8(command, args, options3);
164966
164986
  const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
164967
164987
  enoent.hookChildProcess(spawned, parsed);
@@ -164973,8 +164993,8 @@ var require_cross_spawn = __commonJS((exports, module3) => {
164973
164993
  result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
164974
164994
  return result;
164975
164995
  }
164976
- module3.exports = spawn5;
164977
- module3.exports.spawn = spawn5;
164996
+ module3.exports = spawn4;
164997
+ module3.exports.spawn = spawn4;
164978
164998
  module3.exports.sync = spawnSync3;
164979
164999
  module3.exports._parse = parse8;
164980
165000
  module3.exports._enoent = enoent;
@@ -164982,13 +165002,13 @@ var require_cross_spawn = __commonJS((exports, module3) => {
164982
165002
 
164983
165003
  // src/utils/package-manager-spawn.ts
164984
165004
  import {
164985
- spawn as spawn5
165005
+ spawn as spawn4
164986
165006
  } from "node:child_process";
164987
165007
  function isWindowsCommandShim(command) {
164988
165008
  return /\.(?:cmd|bat)$/i.test(command);
164989
165009
  }
164990
165010
  function getPackageManagerProcessFactory({
164991
- nativeSpawn = spawn5,
165011
+ nativeSpawn = spawn4,
164992
165012
  platform: platform2 = process.platform,
164993
165013
  windowsSpawn = import_cross_spawn.default
164994
165014
  } = {}) {
@@ -165089,9 +165109,9 @@ var init_typescript = __esm(() => {
165089
165109
  throw new Error("LSP auto-download is disabled. Please install typescript-language-server manually: npm install -g typescript-language-server typescript");
165090
165110
  }
165091
165111
  console.log("[LSP] Installing typescript-language-server and typescript...");
165092
- const { spawn: spawn6 } = await import("node:child_process");
165112
+ const { spawn: spawn5 } = await import("node:child_process");
165093
165113
  return new Promise((resolve18, reject) => {
165094
- const proc = spawn6("npm", ["install", "-g", "typescript-language-server", "typescript"], {
165114
+ const proc = spawn5("npm", ["install", "-g", "typescript-language-server", "typescript"], {
165095
165115
  stdio: "inherit"
165096
165116
  });
165097
165117
  proc.on("exit", (code2) => {
@@ -165164,7 +165184,7 @@ class LSPManager {
165164
165184
  return existing.client;
165165
165185
  }
165166
165186
  try {
165167
- const { spawn: spawn6 } = await import("node:child_process");
165187
+ const { spawn: spawn5 } = await import("node:child_process");
165168
165188
  const rootUri = process.cwd();
165169
165189
  if (serverDef.autoInstall) {
165170
165190
  const isAvailable = await serverDef.autoInstall.check();
@@ -165178,7 +165198,7 @@ class LSPManager {
165178
165198
  console.error(`[LSP] ${serverDef.id} has no command configured`);
165179
165199
  return null;
165180
165200
  }
165181
- const proc = spawn6(command, serverDef.command.slice(1), {
165201
+ const proc = spawn5(command, serverDef.command.slice(1), {
165182
165202
  cwd: rootUri,
165183
165203
  env: {
165184
165204
  ...process.env,
@@ -174208,7 +174228,7 @@ var init_subagent_stream = __esm(() => {
174208
174228
  });
174209
174229
 
174210
174230
  // src/agent/subagents/manager.ts
174211
- import { spawn as spawn6 } from "node:child_process";
174231
+ import { spawn as spawn5 } from "node:child_process";
174212
174232
  import { platform as platform2 } from "node:os";
174213
174233
  function isProviderNotSupportedError(errorOutput) {
174214
174234
  return errorOutput.includes("Provider") && errorOutput.includes("is not supported") && errorOutput.includes("supported providers:");
@@ -174425,7 +174445,7 @@ async function executeSubagent(type3, config3, model, userPrompt, subagentId, is
174425
174445
  if (sandbox) {
174426
174446
  debugLog("subagent", `memory subagent child sandboxed via ${sandbox.backend}`);
174427
174447
  }
174428
- const proc2 = spawn6(spawnLauncher.command, spawnLauncher.args, {
174448
+ const proc2 = spawn5(spawnLauncher.command, spawnLauncher.args, {
174429
174449
  cwd: subagentWorkingDirectory,
174430
174450
  env: spawnEnv
174431
174451
  });
@@ -179798,7 +179818,7 @@ __export(exports_loader, {
179798
179818
  getUserSettingsPaths: () => getUserSettingsPaths
179799
179819
  });
179800
179820
  import { createHash as createHash3 } from "node:crypto";
179801
- import { readFileSync as readFileSync10, statSync as statSync5, watch as watch2 } from "node:fs";
179821
+ import { readFileSync as readFileSync11, statSync as statSync5, watch as watch2 } from "node:fs";
179802
179822
  import { homedir as homedir17 } from "node:os";
179803
179823
  import { dirname as dirname17, join as join26, resolve as resolve23 } from "node:path";
179804
179824
  function getUserSettingsPaths(options3 = {}) {
@@ -179828,7 +179848,7 @@ function getFileSignature(path30) {
179828
179848
  exists: true,
179829
179849
  mtimeMs: stat10.mtimeMs,
179830
179850
  size: stat10.size,
179831
- hash: createHash3("sha256").update(readFileSync10(path30)).digest("hex")
179851
+ hash: createHash3("sha256").update(readFileSync11(path30)).digest("hex")
179832
179852
  };
179833
179853
  } catch {
179834
179854
  return { exists: false };
@@ -181455,6 +181475,9 @@ async function sendMessageStreamWithBackend(backend, conversationId, messages, o
181455
181475
  if (opts.actingUserId) {
181456
181476
  extraHeaders["X-Letta-Acting-User-Id"] = opts.actingUserId;
181457
181477
  }
181478
+ if (opts.superRunId) {
181479
+ extraHeaders["X-Letta-Super-Run-Id"] = opts.superRunId;
181480
+ }
181458
181481
  const messageSummary = normalizedMessages.map((item) => {
181459
181482
  if (item.type === "approval") {
181460
181483
  return `approval:${item.approvals?.length ?? 0}`;
@@ -182860,10 +182883,13 @@ async function executeToolInner(name, args, options3) {
182860
182883
  if (internalName === "Skill" && options3?.parentScope) {
182861
182884
  enhancedArgs = { ...enhancedArgs, parentScope: options3.parentScope };
182862
182885
  }
182863
- if (WORKTREE_TOOL_NAMES.has(internalName) && options3?.toolContextId) {
182886
+ if (WORKTREE_TOOL_NAMES.has(internalName)) {
182864
182887
  enhancedArgs = {
182865
182888
  ...enhancedArgs,
182866
- _executionContextId: options3.toolContextId
182889
+ ...options3?.toolContextId && {
182890
+ _executionContextId: options3.toolContextId
182891
+ },
182892
+ ...options3?.signal && { signal: options3.signal }
182867
182893
  };
182868
182894
  }
182869
182895
  const result2 = await tool2.fn(enhancedArgs);
@@ -184056,7 +184082,7 @@ var init_memory_git_config_lock = __esm(() => {
184056
184082
  });
184057
184083
 
184058
184084
  // src/agent/memory-git-hooks.ts
184059
- import { chmodSync as chmodSync4, existsSync as existsSync21, mkdirSync as mkdirSync14, writeFileSync as writeFileSync9 } from "node:fs";
184085
+ import { chmodSync as chmodSync4, existsSync as existsSync21, mkdirSync as mkdirSync14, writeFileSync as writeFileSync10 } from "node:fs";
184060
184086
  import { join as join29 } from "node:path";
184061
184087
  function installPreCommitHook(dir) {
184062
184088
  const hooksDir = join29(dir, ".git", "hooks");
@@ -184064,7 +184090,7 @@ function installPreCommitHook(dir) {
184064
184090
  if (!existsSync21(hooksDir)) {
184065
184091
  mkdirSync14(hooksDir, { recursive: true });
184066
184092
  }
184067
- writeFileSync9(hookPath, PRE_COMMIT_HOOK_SCRIPT, "utf-8");
184093
+ writeFileSync10(hookPath, PRE_COMMIT_HOOK_SCRIPT, "utf-8");
184068
184094
  chmodSync4(hookPath, 493);
184069
184095
  debugLog("memfs-git", "Installed pre-commit hook");
184070
184096
  }
@@ -184074,7 +184100,7 @@ function installPostCommitHook(dir) {
184074
184100
  if (!existsSync21(hooksDir)) {
184075
184101
  mkdirSync14(hooksDir, { recursive: true });
184076
184102
  }
184077
- writeFileSync9(hookPath, POST_COMMIT_HOOK_SCRIPT, "utf-8");
184103
+ writeFileSync10(hookPath, POST_COMMIT_HOOK_SCRIPT, "utf-8");
184078
184104
  chmodSync4(hookPath, 493);
184079
184105
  debugLog("memfs-git", "Installed post-commit memory-repository hook");
184080
184106
  }
@@ -184285,7 +184311,7 @@ __export(exports_memory_git, {
184285
184311
  ensureLocalMemfsGitConfig: () => ensureLocalMemfsGitConfig,
184286
184312
  commitMemoryWrite: () => commitMemoryWrite,
184287
184313
  cloneMemoryRepo: () => cloneMemoryRepo,
184288
- buildNonInteractiveGitEnv: () => buildNonInteractiveGitEnv,
184314
+ buildNonInteractiveGitEnv: () => buildNonInteractiveGitEnv2,
184289
184315
  buildMemfsGitProxyArgs: () => buildMemfsGitProxyArgs,
184290
184316
  buildGitAuthArgs: () => buildGitAuthArgs,
184291
184317
  assertMemoryRepoCleanForWrite: () => assertMemoryRepoCleanForWrite,
@@ -184295,10 +184321,10 @@ import { execFile as execFileCb2 } from "node:child_process";
184295
184321
  import {
184296
184322
  existsSync as existsSync22,
184297
184323
  mkdirSync as mkdirSync15,
184298
- readFileSync as readFileSync11,
184324
+ readFileSync as readFileSync12,
184299
184325
  renameSync as renameSync3,
184300
184326
  rmSync as rmSync4,
184301
- writeFileSync as writeFileSync10
184327
+ writeFileSync as writeFileSync11
184302
184328
  } from "node:fs";
184303
184329
  import { homedir as homedir20, platform as platform3 } from "node:os";
184304
184330
  import { dirname as dirname19, isAbsolute as isAbsolute20, join as join30 } from "node:path";
@@ -184551,7 +184577,7 @@ function buildMemfsGitProxyArgs(args, env3 = process.env) {
184551
184577
  function shouldConfigurePersistentMemfsCredentialHelper(env3 = process.env) {
184552
184578
  return getMemfsGitProxyRewriteConfig(env3) === null;
184553
184579
  }
184554
- function buildNonInteractiveGitEnv(env3 = process.env) {
184580
+ function buildNonInteractiveGitEnv2(env3 = process.env) {
184555
184581
  return {
184556
184582
  ...env3,
184557
184583
  GIT_TERMINAL_PROMPT: "0",
@@ -184580,7 +184606,7 @@ async function runGit3(cwd, args, token, options3) {
184580
184606
  try {
184581
184607
  result = await execFile5("git", allArgs, {
184582
184608
  cwd,
184583
- env: buildNonInteractiveGitEnv(),
184609
+ env: buildNonInteractiveGitEnv2(),
184584
184610
  maxBuffer: 10485760,
184585
184611
  timeout: timeoutMs
184586
184612
  });
@@ -184651,7 +184677,7 @@ async function configureLocalCredentialHelper(dir, token) {
184651
184677
  echo username=letta
184652
184678
  echo password=${token}
184653
184679
  `;
184654
- writeFileSync10(helperScriptPath, batchScript, "utf-8");
184680
+ writeFileSync11(helperScriptPath, batchScript, "utf-8");
184655
184681
  helper = formatGitCredentialHelperPath(helperScriptPath);
184656
184682
  debugLog("memfs-git", `Wrote Windows credential helper script`);
184657
184683
  } else {
@@ -184832,7 +184858,7 @@ function readMemoryRepositoryPushLog(agentId, tailLines = 20) {
184832
184858
  return "";
184833
184859
  }
184834
184860
  try {
184835
- const content = readFileSync11(logPath, "utf-8");
184861
+ const content = readFileSync12(logPath, "utf-8");
184836
184862
  const lines = content.split(`
184837
184863
  `);
184838
184864
  return lines.slice(-tailLines).join(`
@@ -185002,7 +185028,7 @@ function describeMarkdownEncodingIssue(memoryDir, relativePath) {
185002
185028
  if (!existsSync22(filePath)) {
185003
185029
  return null;
185004
185030
  }
185005
- const bytes = readFileSync11(filePath);
185031
+ const bytes = readFileSync12(filePath);
185006
185032
  const utf16Bom = getUtf16Bom(bytes);
185007
185033
  if (utf16Bom) {
185008
185034
  return `${relativePath} has ${utf16Bom} BOM`;
@@ -185080,7 +185106,7 @@ async function initializeLocalMemoryRepo(params) {
185080
185106
  }
185081
185107
  const fullPath = join30(params.memoryDir, relativePath);
185082
185108
  mkdirSync15(dirname19(fullPath), { recursive: true });
185083
- writeFileSync10(fullPath, file3.content, "utf8");
185109
+ writeFileSync11(fullPath, file3.content, "utf8");
185084
185110
  pathspecs.push(relativePath);
185085
185111
  }
185086
185112
  if (pathspecs.length > 0) {
@@ -185513,6 +185539,202 @@ var init_memory_git = __esm(() => {
185513
185539
  NO_UPSTREAM_PULL_ERROR_RE = /(there is no tracking information for the current branch|no upstream configured|no tracking branch)/i;
185514
185540
  });
185515
185541
 
185542
+ // src/backend/local/local-model-normalization.ts
185543
+ function supportedModelSettingsFromBody(bodyRecord) {
185544
+ const modelSettings = isRecord(bodyRecord.model_settings) ? { ...bodyRecord.model_settings } : {};
185545
+ if (typeof bodyRecord.context_window_limit === "number") {
185546
+ modelSettings.context_window_limit = bodyRecord.context_window_limit;
185547
+ }
185548
+ if (typeof bodyRecord.parallel_tool_calls === "boolean") {
185549
+ modelSettings.parallel_tool_calls = bodyRecord.parallel_tool_calls;
185550
+ }
185551
+ if (typeof bodyRecord.max_tokens === "number" || bodyRecord.max_tokens === null) {
185552
+ modelSettings.max_tokens = bodyRecord.max_tokens;
185553
+ }
185554
+ return modelSettings;
185555
+ }
185556
+ function providerTypeFromModelSettings2(modelSettings) {
185557
+ const providerType = modelSettings?.provider_type;
185558
+ return typeof providerType === "string" && providerType.length > 0 ? providerType : null;
185559
+ }
185560
+ function normalizeLocalModelHandle(model, modelSettings, legacyLlmConfig) {
185561
+ if (isResolvablePiModelHandle(model) || resolveRegisteredPiProviderFromModelHandle(model)) {
185562
+ return model;
185563
+ }
185564
+ const providerType = providerTypeFromModelSettings2(modelSettings);
185565
+ const legacyEndpointType = legacyLlmConfig?.model_endpoint_type;
185566
+ return resolveModelHandleFromLlmConfig({
185567
+ model,
185568
+ model_endpoint_type: providerType ?? (typeof legacyEndpointType === "string" ? legacyEndpointType : null)
185569
+ }) ?? model;
185570
+ }
185571
+ function modelHandleFromLegacyLlmConfig(legacyLlmConfig) {
185572
+ const model = legacyLlmConfig.model;
185573
+ if (typeof model !== "string")
185574
+ return null;
185575
+ const modelEndpointType = legacyLlmConfig.model_endpoint_type;
185576
+ return resolveModelHandleFromLlmConfig({
185577
+ model,
185578
+ model_endpoint_type: typeof modelEndpointType === "string" ? modelEndpointType : null
185579
+ });
185580
+ }
185581
+ function supportedConversationModelSettingsFromBody(bodyRecord) {
185582
+ const rawSettings = bodyRecord.model_settings;
185583
+ const modelSettings = rawSettings === null ? null : isRecord(rawSettings) ? { ...rawSettings } : undefined;
185584
+ if (modelSettings === null)
185585
+ return null;
185586
+ const next = modelSettings ?? {};
185587
+ if (typeof bodyRecord.max_tokens === "number" || bodyRecord.max_tokens === null) {
185588
+ next.max_tokens = bodyRecord.max_tokens;
185589
+ }
185590
+ return Object.keys(next).length > 0 ? next : modelSettings;
185591
+ }
185592
+ function normalizeStoredLocalModelRecord(record5) {
185593
+ if (typeof record5.model !== "string")
185594
+ return record5;
185595
+ const modelSettings = isRecord(record5.model_settings) ? record5.model_settings : {};
185596
+ const normalizedModel = normalizeLocalModelHandle(record5.model, modelSettings);
185597
+ return normalizedModel === record5.model ? record5 : { ...record5, model: normalizedModel };
185598
+ }
185599
+ function localLlmConfigModelPatch(model, modelSettings) {
185600
+ return mapModelHandleToLlmConfigPatch(model, providerTypeFromModelSettings2(modelSettings));
185601
+ }
185602
+ var init_local_model_normalization = __esm(() => {
185603
+ init_model_handles();
185604
+ init_pi_provider_mod_registry();
185605
+ init_pi_provider_registry();
185606
+ });
185607
+
185608
+ // src/backend/local/local-agent-record.ts
185609
+ import { randomUUID as randomUUID7 } from "node:crypto";
185610
+ function isStringArray2(value) {
185611
+ return Array.isArray(value) && value.every((item) => typeof item === "string");
185612
+ }
185613
+ function normalizeAgentHiddenFlag(hidden, tags) {
185614
+ if (typeof hidden === "boolean")
185615
+ return hidden;
185616
+ if ((hidden === undefined || hidden === null) && isSubagentTags(tags)) {
185617
+ return true;
185618
+ }
185619
+ return hidden === null ? null : undefined;
185620
+ }
185621
+ function isSubagentTags(tags) {
185622
+ return tags.includes(LETTA_CODE_SUBAGENT_TAG);
185623
+ }
185624
+ function isHiddenLocalAgentRecord(record5) {
185625
+ const tags = isStringArray2(record5.tags) ? record5.tags : [];
185626
+ return record5.hidden === true || record5.hidden == null && isSubagentTags(tags);
185627
+ }
185628
+ function shouldPersistSubagentHiddenBackfill(raw, record5) {
185629
+ return isRecord(raw) && (raw.hidden === undefined || raw.hidden === null) && record5.hidden === true && isSubagentTags(record5.tags);
185630
+ }
185631
+ function optionalString(value) {
185632
+ return typeof value === "string" ? value : undefined;
185633
+ }
185634
+ function optionalStringOrNull(value) {
185635
+ return typeof value === "string" || value === null ? value : undefined;
185636
+ }
185637
+ function createDefaultAgentRecord(agentId, defaultAgentName, defaultAgentModel) {
185638
+ return {
185639
+ id: agentId,
185640
+ name: defaultAgentName,
185641
+ description: null,
185642
+ system: "",
185643
+ tags: [],
185644
+ model: defaultAgentModel,
185645
+ model_settings: {}
185646
+ };
185647
+ }
185648
+ function createLocalAgentRecord(body, defaultAgentName, defaultAgentModel) {
185649
+ const bodyRecord = body;
185650
+ const tags = isStringArray2(bodyRecord.tags) ? bodyRecord.tags : [];
185651
+ const hidden = normalizeAgentHiddenFlag(bodyRecord.hidden, tags);
185652
+ const modelSettings = supportedModelSettingsFromBody(bodyRecord);
185653
+ const requestedModel = optionalString(bodyRecord.model) ?? defaultAgentModel;
185654
+ return {
185655
+ id: `agent-local-${randomUUID7()}`,
185656
+ name: optionalString(bodyRecord.name) ?? defaultAgentName,
185657
+ description: optionalStringOrNull(bodyRecord.description) ?? null,
185658
+ system: optionalString(bodyRecord.system) ?? "",
185659
+ tags,
185660
+ model: normalizeLocalModelHandle(requestedModel, modelSettings),
185661
+ model_settings: modelSettings,
185662
+ ...hidden !== undefined ? { hidden } : {}
185663
+ };
185664
+ }
185665
+ function shouldUseDefaultLocalModel(model) {
185666
+ return typeof model !== "string" || model.length === 0 || model === "auto" || model.startsWith("letta/");
185667
+ }
185668
+ function optionalRecordOrNull(value) {
185669
+ if (value === null)
185670
+ return null;
185671
+ return isRecord(value) ? { ...value } : undefined;
185672
+ }
185673
+ function normalizeAgentRecord(value, defaultAgentModel) {
185674
+ if (!isRecord(value) || typeof value.id !== "string")
185675
+ return;
185676
+ const modelSettings = isRecord(value.model_settings) ? { ...value.model_settings } : {};
185677
+ const legacyLlmConfig = isRecord(value.llm_config) ? value.llm_config : {};
185678
+ if (modelSettings.context_window_limit === undefined && typeof legacyLlmConfig.context_window === "number") {
185679
+ modelSettings.context_window_limit = legacyLlmConfig.context_window;
185680
+ }
185681
+ if (modelSettings.max_tokens === undefined && (typeof legacyLlmConfig.max_tokens === "number" || legacyLlmConfig.max_tokens === null)) {
185682
+ modelSettings.max_tokens = legacyLlmConfig.max_tokens;
185683
+ }
185684
+ const compactionSettings = optionalRecordOrNull(value.compaction_settings);
185685
+ const tags = isStringArray2(value.tags) ? value.tags : [];
185686
+ const hidden = normalizeAgentHiddenFlag(value.hidden, tags);
185687
+ const storedModel = optionalString(value.model);
185688
+ const legacyModel = modelHandleFromLegacyLlmConfig(legacyLlmConfig);
185689
+ const model = storedModel ? normalizeLocalModelHandle(storedModel, modelSettings, legacyLlmConfig) : legacyModel ?? defaultAgentModel;
185690
+ return {
185691
+ id: value.id,
185692
+ name: optionalString(value.name) ?? "Letta Code",
185693
+ description: optionalStringOrNull(value.description) ?? null,
185694
+ system: optionalString(value.system) ?? "",
185695
+ tags,
185696
+ model,
185697
+ model_settings: modelSettings,
185698
+ ...hidden !== undefined ? { hidden } : {},
185699
+ ...compactionSettings !== undefined ? { compaction_settings: compactionSettings } : {}
185700
+ };
185701
+ }
185702
+ function projectLocalAgentState(record5, messageIds = [], inContextMessageIds = messageIds, lastRunCompletion) {
185703
+ const hidden = normalizeAgentHiddenFlag(record5.hidden, record5.tags);
185704
+ const nestedReasoning = isRecord(record5.model_settings.reasoning) ? record5.model_settings.reasoning : undefined;
185705
+ const reasoningEffort = typeof nestedReasoning?.reasoning_effort === "string" ? nestedReasoning.reasoning_effort : typeof record5.model_settings.effort === "string" ? record5.model_settings.effort : typeof record5.model_settings.reasoning_effort === "string" ? record5.model_settings.reasoning_effort : undefined;
185706
+ const enableReasoner = isRecord(record5.model_settings.thinking) && record5.model_settings.thinking.type === "disabled" ? false : typeof record5.model_settings.enable_reasoner === "boolean" ? record5.model_settings.enable_reasoner : undefined;
185707
+ const llmConfigModelPatch = localLlmConfigModelPatch(record5.model, record5.model_settings);
185708
+ return {
185709
+ id: record5.id,
185710
+ name: record5.name,
185711
+ description: record5.description,
185712
+ system: record5.system,
185713
+ tools: [],
185714
+ tags: record5.tags,
185715
+ model: record5.model,
185716
+ model_settings: record5.model_settings,
185717
+ ...hidden !== undefined ? { hidden } : {},
185718
+ ...record5.compaction_settings !== undefined ? { compaction_settings: record5.compaction_settings } : {},
185719
+ message_ids: messageIds,
185720
+ in_context_message_ids: inContextMessageIds,
185721
+ ...lastRunCompletion ? { last_run_completion: lastRunCompletion } : {},
185722
+ llm_config: {
185723
+ ...llmConfigModelPatch,
185724
+ model_endpoint: "https://example.invalid/v1",
185725
+ context_window: typeof record5.model_settings.context_window_limit === "number" ? record5.model_settings.context_window_limit : 128000,
185726
+ ...reasoningEffort && { reasoning_effort: reasoningEffort },
185727
+ ...enableReasoner !== undefined && { enable_reasoner: enableReasoner },
185728
+ ...(typeof record5.model_settings.max_tokens === "number" || record5.model_settings.max_tokens === null) && {
185729
+ max_tokens: record5.model_settings.max_tokens
185730
+ }
185731
+ }
185732
+ };
185733
+ }
185734
+ var init_local_agent_record = __esm(() => {
185735
+ init_local_model_normalization();
185736
+ });
185737
+
185516
185738
  // src/backend/local/local-message-projection.ts
185517
185739
  function sourceLocalMessageIdFromStoredMessageId(messageId) {
185518
185740
  const variantSeparator = messageId.search(/:(assistant|reasoning|tool):/);
@@ -185897,7 +186119,7 @@ var FORK_PROJECTION_FALLBACK_DATE = "1970-01-01T00:00:00.000Z";
185897
186119
  var init_local_conversation_fork = () => {};
185898
186120
 
185899
186121
  // src/backend/local/local-conversation-list.ts
185900
- function optionalString(value) {
186122
+ function optionalString2(value) {
185901
186123
  return typeof value === "string" ? value : undefined;
185902
186124
  }
185903
186125
  function matchesSummarySearch(conversation, normalizedSearch) {
@@ -185907,9 +186129,9 @@ function matchesSummarySearch(conversation, normalizedSearch) {
185907
186129
  }
185908
186130
  function listLocalConversations(source2, body) {
185909
186131
  const bodyRecord = body ?? {};
185910
- const agentId = optionalString(bodyRecord.agent_id);
185911
- const after = optionalString(bodyRecord.after);
185912
- const normalizedSearch = optionalString(bodyRecord.summary_search)?.trim().toLowerCase();
186132
+ const agentId = optionalString2(bodyRecord.agent_id);
186133
+ const after = optionalString2(bodyRecord.after);
186134
+ const normalizedSearch = optionalString2(bodyRecord.summary_search)?.trim().toLowerCase();
185913
186135
  const limit3 = typeof bodyRecord.limit === "number" ? bodyRecord.limit : 20;
185914
186136
  let conversations = [...source2].filter((conversation) => conversation.id !== "default" && (bodyRecord.include_hidden === true || !conversation.hidden) && (!agentId || conversation.agent_id === agentId) && matchesSummarySearch(conversation, normalizedSearch));
185915
186137
  conversations.sort((a, b) => {
@@ -185943,72 +186165,6 @@ function emptyLocalUsage() {
185943
186165
  };
185944
186166
  }
185945
186167
 
185946
- // src/backend/local/local-model-normalization.ts
185947
- function supportedModelSettingsFromBody(bodyRecord) {
185948
- const modelSettings = isRecord(bodyRecord.model_settings) ? { ...bodyRecord.model_settings } : {};
185949
- if (typeof bodyRecord.context_window_limit === "number") {
185950
- modelSettings.context_window_limit = bodyRecord.context_window_limit;
185951
- }
185952
- if (typeof bodyRecord.parallel_tool_calls === "boolean") {
185953
- modelSettings.parallel_tool_calls = bodyRecord.parallel_tool_calls;
185954
- }
185955
- if (typeof bodyRecord.max_tokens === "number" || bodyRecord.max_tokens === null) {
185956
- modelSettings.max_tokens = bodyRecord.max_tokens;
185957
- }
185958
- return modelSettings;
185959
- }
185960
- function providerTypeFromModelSettings2(modelSettings) {
185961
- const providerType = modelSettings?.provider_type;
185962
- return typeof providerType === "string" && providerType.length > 0 ? providerType : null;
185963
- }
185964
- function normalizeLocalModelHandle(model, modelSettings, legacyLlmConfig) {
185965
- if (isResolvablePiModelHandle(model) || resolveRegisteredPiProviderFromModelHandle(model)) {
185966
- return model;
185967
- }
185968
- const providerType = providerTypeFromModelSettings2(modelSettings);
185969
- const legacyEndpointType = legacyLlmConfig?.model_endpoint_type;
185970
- return resolveModelHandleFromLlmConfig({
185971
- model,
185972
- model_endpoint_type: providerType ?? (typeof legacyEndpointType === "string" ? legacyEndpointType : null)
185973
- }) ?? model;
185974
- }
185975
- function modelHandleFromLegacyLlmConfig(legacyLlmConfig) {
185976
- const model = legacyLlmConfig.model;
185977
- if (typeof model !== "string")
185978
- return null;
185979
- const modelEndpointType = legacyLlmConfig.model_endpoint_type;
185980
- return resolveModelHandleFromLlmConfig({
185981
- model,
185982
- model_endpoint_type: typeof modelEndpointType === "string" ? modelEndpointType : null
185983
- });
185984
- }
185985
- function supportedConversationModelSettingsFromBody(bodyRecord) {
185986
- const rawSettings = bodyRecord.model_settings;
185987
- const modelSettings = rawSettings === null ? null : isRecord(rawSettings) ? { ...rawSettings } : undefined;
185988
- if (modelSettings === null)
185989
- return null;
185990
- const next = modelSettings ?? {};
185991
- if (typeof bodyRecord.max_tokens === "number" || bodyRecord.max_tokens === null) {
185992
- next.max_tokens = bodyRecord.max_tokens;
185993
- }
185994
- return Object.keys(next).length > 0 ? next : modelSettings;
185995
- }
185996
- function normalizeStoredLocalModelRecord(record5) {
185997
- if (typeof record5.model !== "string")
185998
- return record5;
185999
- const modelSettings = isRecord(record5.model_settings) ? record5.model_settings : {};
186000
- const normalizedModel = normalizeLocalModelHandle(record5.model, modelSettings);
186001
- return normalizedModel === record5.model ? record5 : { ...record5, model: normalizedModel };
186002
- }
186003
- function localLlmConfigModelPatch(model, modelSettings) {
186004
- return mapModelHandleToLlmConfigPatch(model, providerTypeFromModelSettings2(modelSettings));
186005
- }
186006
- var init_local_model_normalization = __esm(() => {
186007
- init_model_handles();
186008
- init_pi_provider_mod_registry();
186009
- init_pi_provider_registry();
186010
- });
186011
-
186012
186168
  // src/backend/local/local-stream-chunks.ts
186013
186169
  function attachLocalMessage(target2, message) {
186014
186170
  Object.defineProperty(target2, LOCAL_MESSAGE, {
@@ -186041,7 +186197,7 @@ var init_local_stream_chunks = __esm(() => {
186041
186197
  });
186042
186198
 
186043
186199
  // src/backend/local/local-store.ts
186044
- import { randomUUID as randomUUID7 } from "node:crypto";
186200
+ import { randomUUID as randomUUID8 } from "node:crypto";
186045
186201
  import {
186046
186202
  appendFileSync as appendFileSync5,
186047
186203
  closeSync,
@@ -186049,71 +186205,22 @@ import {
186049
186205
  mkdirSync as mkdirSync16,
186050
186206
  openSync,
186051
186207
  readdirSync as readdirSync9,
186052
- readFileSync as readFileSync12,
186208
+ readFileSync as readFileSync13,
186053
186209
  readSync,
186054
186210
  rmSync as rmSync5,
186055
186211
  statSync as statSync7,
186056
- writeFileSync as writeFileSync11
186212
+ writeFileSync as writeFileSync12
186057
186213
  } from "node:fs";
186058
186214
  import { join as join31 } from "node:path";
186059
- function isStringArray2(value) {
186215
+ function isStringArray3(value) {
186060
186216
  return Array.isArray(value) && value.every((item) => typeof item === "string");
186061
186217
  }
186062
- function normalizeAgentHiddenFlag(hidden, tags) {
186063
- if (typeof hidden === "boolean")
186064
- return hidden;
186065
- if ((hidden === undefined || hidden === null) && isSubagentTags(tags)) {
186066
- return true;
186067
- }
186068
- return hidden === null ? null : undefined;
186069
- }
186070
- function isSubagentTags(tags) {
186071
- return tags.includes(LETTA_CODE_SUBAGENT_TAG);
186072
- }
186073
- function isHiddenLocalAgentRecord(record5) {
186074
- const tags = isStringArray2(record5.tags) ? record5.tags : [];
186075
- return record5.hidden === true || record5.hidden == null && isSubagentTags(tags);
186076
- }
186077
- function shouldPersistSubagentHiddenBackfill(raw, record5) {
186078
- return isRecord(raw) && (raw.hidden === undefined || raw.hidden === null) && record5.hidden === true && isSubagentTags(record5.tags);
186079
- }
186080
- function optionalString2(value) {
186218
+ function optionalString3(value) {
186081
186219
  return typeof value === "string" ? value : undefined;
186082
186220
  }
186083
- function optionalStringOrNull(value) {
186221
+ function optionalStringOrNull2(value) {
186084
186222
  return typeof value === "string" || value === null ? value : undefined;
186085
186223
  }
186086
- function createDefaultAgentRecord(agentId, defaultAgentName, defaultAgentModel) {
186087
- return {
186088
- id: agentId,
186089
- name: defaultAgentName,
186090
- description: null,
186091
- system: "",
186092
- tags: [],
186093
- model: defaultAgentModel,
186094
- model_settings: {}
186095
- };
186096
- }
186097
- function createLocalAgentRecord(body, defaultAgentName, defaultAgentModel) {
186098
- const bodyRecord = body;
186099
- const tags = isStringArray2(bodyRecord.tags) ? bodyRecord.tags : [];
186100
- const hidden = normalizeAgentHiddenFlag(bodyRecord.hidden, tags);
186101
- const modelSettings = supportedModelSettingsFromBody(bodyRecord);
186102
- const requestedModel = optionalString2(bodyRecord.model) ?? defaultAgentModel;
186103
- return {
186104
- id: `agent-local-${randomUUID7()}`,
186105
- name: optionalString2(bodyRecord.name) ?? defaultAgentName,
186106
- description: optionalStringOrNull(bodyRecord.description) ?? null,
186107
- system: optionalString2(bodyRecord.system) ?? "",
186108
- tags,
186109
- model: normalizeLocalModelHandle(requestedModel, modelSettings),
186110
- model_settings: modelSettings,
186111
- ...hidden !== undefined ? { hidden } : {}
186112
- };
186113
- }
186114
- function shouldUseDefaultLocalModel(model) {
186115
- return typeof model !== "string" || model.length === 0 || model === "auto" || model.startsWith("letta/");
186116
- }
186117
186224
  function currentIsoTimestamp() {
186118
186225
  return new Date().toISOString();
186119
186226
  }
@@ -186129,11 +186236,6 @@ function isSyntheticLocalTimestamp(value) {
186129
186236
  return false;
186130
186237
  return parsed >= Date.UTC(2026, 0, 1, 0, 0, 0, 0) && parsed < Date.UTC(2026, 0, 2, 0, 0, 0, 0);
186131
186238
  }
186132
- function optionalRecordOrNull(value) {
186133
- if (value === null)
186134
- return null;
186135
- return isRecord(value) ? { ...value } : undefined;
186136
- }
186137
186239
  function createLocalConversationRecord(conversationId, agentId, _sequence, body = {}) {
186138
186240
  const bodyRecord = body;
186139
186241
  const now = currentIsoTimestamp();
@@ -186146,7 +186248,7 @@ function createLocalConversationRecord(conversationId, agentId, _sequence, body
186146
186248
  created_at: now,
186147
186249
  updated_at: now,
186148
186250
  last_message_at: null,
186149
- summary: optionalStringOrNull(bodyRecord.summary) ?? null,
186251
+ summary: optionalStringOrNull2(bodyRecord.summary) ?? null,
186150
186252
  in_context_message_ids: [],
186151
186253
  ...typeof bodyRecord.model === "string" || bodyRecord.model === null ? {
186152
186254
  model: bodyRecord.model === null ? null : normalizeLocalModelHandle(bodyRecord.model, modelSettings ?? {})
@@ -186154,7 +186256,7 @@ function createLocalConversationRecord(conversationId, agentId, _sequence, body
186154
186256
  ...modelSettings !== undefined ? { model_settings: modelSettings } : {},
186155
186257
  ...typeof bodyRecord.context_window_limit === "number" ? { context_window_limit: bodyRecord.context_window_limit } : {},
186156
186258
  ...typeof bodyRecord.hidden === "boolean" ? { hidden: bodyRecord.hidden } : {},
186157
- ...isStringArray2(bodyRecord.tags) ? { tags: bodyRecord.tags } : {}
186259
+ ...isStringArray3(bodyRecord.tags) ? { tags: bodyRecord.tags } : {}
186158
186260
  };
186159
186261
  }
186160
186262
  function updateLocalConversationRecord(current, body, updatedAt) {
@@ -186190,72 +186292,11 @@ function updateLocalConversationRecord(current, body, updatedAt) {
186190
186292
  if (typeof bodyRecord.summary === "string" || bodyRecord.summary === null) {
186191
186293
  next.summary = bodyRecord.summary;
186192
186294
  }
186193
- if (isStringArray2(bodyRecord.tags)) {
186295
+ if (isStringArray3(bodyRecord.tags)) {
186194
186296
  next.tags = bodyRecord.tags;
186195
186297
  }
186196
186298
  return next;
186197
186299
  }
186198
- function normalizeAgentRecord(value, defaultAgentModel) {
186199
- if (!isRecord(value) || typeof value.id !== "string")
186200
- return;
186201
- const modelSettings = isRecord(value.model_settings) ? { ...value.model_settings } : {};
186202
- const legacyLlmConfig = isRecord(value.llm_config) ? value.llm_config : {};
186203
- if (modelSettings.context_window_limit === undefined && typeof legacyLlmConfig.context_window === "number") {
186204
- modelSettings.context_window_limit = legacyLlmConfig.context_window;
186205
- }
186206
- if (modelSettings.max_tokens === undefined && (typeof legacyLlmConfig.max_tokens === "number" || legacyLlmConfig.max_tokens === null)) {
186207
- modelSettings.max_tokens = legacyLlmConfig.max_tokens;
186208
- }
186209
- const compactionSettings = optionalRecordOrNull(value.compaction_settings);
186210
- const tags = isStringArray2(value.tags) ? value.tags : [];
186211
- const hidden = normalizeAgentHiddenFlag(value.hidden, tags);
186212
- const storedModel = optionalString2(value.model);
186213
- const legacyModel = modelHandleFromLegacyLlmConfig(legacyLlmConfig);
186214
- const model = storedModel ? normalizeLocalModelHandle(storedModel, modelSettings, legacyLlmConfig) : legacyModel ?? defaultAgentModel;
186215
- return {
186216
- id: value.id,
186217
- name: optionalString2(value.name) ?? "Letta Code",
186218
- description: optionalStringOrNull(value.description) ?? null,
186219
- system: optionalString2(value.system) ?? "",
186220
- tags,
186221
- model,
186222
- model_settings: modelSettings,
186223
- ...hidden !== undefined ? { hidden } : {},
186224
- ...compactionSettings !== undefined ? { compaction_settings: compactionSettings } : {}
186225
- };
186226
- }
186227
- function projectLocalAgentState(record5, messageIds = [], inContextMessageIds = messageIds, lastRunCompletion) {
186228
- const hidden = normalizeAgentHiddenFlag(record5.hidden, record5.tags);
186229
- const nestedReasoning = isRecord(record5.model_settings.reasoning) ? record5.model_settings.reasoning : undefined;
186230
- const reasoningEffort = typeof nestedReasoning?.reasoning_effort === "string" ? nestedReasoning.reasoning_effort : typeof record5.model_settings.effort === "string" ? record5.model_settings.effort : typeof record5.model_settings.reasoning_effort === "string" ? record5.model_settings.reasoning_effort : undefined;
186231
- const enableReasoner = isRecord(record5.model_settings.thinking) && record5.model_settings.thinking.type === "disabled" ? false : typeof record5.model_settings.enable_reasoner === "boolean" ? record5.model_settings.enable_reasoner : undefined;
186232
- const llmConfigModelPatch = localLlmConfigModelPatch(record5.model, record5.model_settings);
186233
- return {
186234
- id: record5.id,
186235
- name: record5.name,
186236
- description: record5.description,
186237
- system: record5.system,
186238
- tools: [],
186239
- tags: record5.tags,
186240
- model: record5.model,
186241
- model_settings: record5.model_settings,
186242
- ...hidden !== undefined ? { hidden } : {},
186243
- ...record5.compaction_settings !== undefined ? { compaction_settings: record5.compaction_settings } : {},
186244
- message_ids: messageIds,
186245
- in_context_message_ids: inContextMessageIds,
186246
- ...lastRunCompletion ? { last_run_completion: lastRunCompletion } : {},
186247
- llm_config: {
186248
- ...llmConfigModelPatch,
186249
- model_endpoint: "https://example.invalid/v1",
186250
- context_window: typeof record5.model_settings.context_window_limit === "number" ? record5.model_settings.context_window_limit : 128000,
186251
- ...reasoningEffort && { reasoning_effort: reasoningEffort },
186252
- ...enableReasoner !== undefined && { enable_reasoner: enableReasoner },
186253
- ...(typeof record5.model_settings.max_tokens === "number" || record5.model_settings.max_tokens === null) && {
186254
- max_tokens: record5.model_settings.max_tokens
186255
- }
186256
- }
186257
- };
186258
- }
186259
186300
  function textContent(text) {
186260
186301
  return [{ type: "text", text }];
186261
186302
  }
@@ -186348,12 +186389,12 @@ function jsonl(items3) {
186348
186389
  function readJsonFile2(path30) {
186349
186390
  if (!existsSync23(path30))
186350
186391
  return;
186351
- return JSON.parse(readFileSync12(path30, "utf8"));
186392
+ return JSON.parse(readFileSync13(path30, "utf8"));
186352
186393
  }
186353
186394
  function readJsonlFile(path30) {
186354
186395
  if (!existsSync23(path30))
186355
186396
  return [];
186356
- return readFileSync12(path30, "utf8").split(`
186397
+ return readFileSync13(path30, "utf8").split(`
186357
186398
  `).filter((line) => line.trim().length > 0).map((line) => JSON.parse(line));
186358
186399
  }
186359
186400
  function readJsonlFileSuffix(path30, maxBytes) {
@@ -186451,7 +186492,7 @@ function localTranscriptSessionEntries(conversation, messages) {
186451
186492
  ...messages.map((message) => {
186452
186493
  const entry = {
186453
186494
  type: "message",
186454
- id: randomUUID7().slice(0, 8),
186495
+ id: randomUUID8().slice(0, 8),
186455
186496
  parentId,
186456
186497
  timestamp: localMessageDate2(message, currentIsoTimestamp()),
186457
186498
  message
@@ -186531,7 +186572,7 @@ function validateLocalTranscriptManifest(conversationDir, storageDir) {
186531
186572
  return manifest;
186532
186573
  }
186533
186574
  function writeLocalTranscriptManifest(conversationDir, manifest = createLocalTranscriptManifest()) {
186534
- writeFileSync11(transcriptManifestPath(conversationDir), `${JSON.stringify(manifest, null, 2)}
186575
+ writeFileSync12(transcriptManifestPath(conversationDir), `${JSON.stringify(manifest, null, 2)}
186535
186576
  `);
186536
186577
  }
186537
186578
  function numericSuffix(value, prefix) {
@@ -186618,6 +186659,7 @@ class LocalStore {
186618
186659
  storedMessageIdPrefix;
186619
186660
  localMessageIdPrefix;
186620
186661
  agents = new Map;
186662
+ agentRecordMtimeMsById = new Map;
186621
186663
  conversations = new Map;
186622
186664
  localMessagesByConversationKey = new Map;
186623
186665
  loadedConversationKeys = new Set;
@@ -186655,20 +186697,20 @@ class LocalStore {
186655
186697
  }
186656
186698
  }
186657
186699
  retrieveAgent(agentId) {
186658
- if (!this.strictAgentAccess) {
186700
+ const existing = this.refreshAgentRecordFromStorage(agentId);
186701
+ if (!existing && !this.strictAgentAccess)
186659
186702
  return this.ensureAgent(agentId);
186660
- }
186661
- const existing = this.agents.get(agentId);
186662
186703
  if (!existing) {
186663
186704
  throw new LocalBackendNotFoundError("Agent", agentId);
186664
186705
  }
186665
186706
  return this.projectAgent(existing);
186666
186707
  }
186667
186708
  listAgents(body) {
186709
+ this.refreshLoadedAgentRecordsFromStorage();
186668
186710
  const bodyRecord = body ?? {};
186669
- const queryText = optionalString2(bodyRecord.query_text)?.toLowerCase();
186670
- const tags = isStringArray2(bodyRecord.tags) ? bodyRecord.tags : [];
186671
- const after = optionalString2(bodyRecord.after);
186711
+ const queryText = optionalString3(bodyRecord.query_text)?.toLowerCase();
186712
+ const tags = isStringArray3(bodyRecord.tags) ? bodyRecord.tags : [];
186713
+ const after = optionalString3(bodyRecord.after);
186672
186714
  const limit3 = typeof bodyRecord.limit === "number" ? bodyRecord.limit : 20;
186673
186715
  let agents = [...this.agents.values()].filter((agent2) => !isHiddenLocalAgentRecord(agent2)).map((agent2) => this.projectAgent(agent2));
186674
186716
  if (tags.length > 0) {
@@ -186698,6 +186740,7 @@ class LocalStore {
186698
186740
  throw new LocalBackendNotFoundError("Agent", agentId);
186699
186741
  }
186700
186742
  this.agents.delete(agentId);
186743
+ this.agentRecordMtimeMsById.delete(agentId);
186701
186744
  this.loadConversationRecordsFromStorage();
186702
186745
  for (const [key, conversation] of [...this.conversations.entries()]) {
186703
186746
  if (conversation.agent_id === agentId) {
@@ -186724,17 +186767,18 @@ class LocalStore {
186724
186767
  }
186725
186768
  }
186726
186769
  retrieveAgentRecord(agentId) {
186727
- if (!this.strictAgentAccess) {
186770
+ let existing = this.refreshAgentRecordFromStorage(agentId);
186771
+ if (!existing && !this.strictAgentAccess) {
186728
186772
  this.ensureAgent(agentId);
186773
+ existing = this.agents.get(agentId);
186729
186774
  }
186730
- const existing = this.agents.get(agentId);
186731
186775
  if (!existing) {
186732
186776
  throw new LocalBackendNotFoundError("Agent", agentId);
186733
186777
  }
186734
186778
  return existing;
186735
186779
  }
186736
186780
  ensureAgent(agentId) {
186737
- const existing = this.agents.get(agentId);
186781
+ const existing = this.refreshAgentRecordFromStorage(agentId);
186738
186782
  if (existing)
186739
186783
  return this.projectAgent(existing);
186740
186784
  const agent2 = this.createDefaultAgentRecord(agentId);
@@ -186744,7 +186788,7 @@ class LocalStore {
186744
186788
  return this.projectAgent(agent2);
186745
186789
  }
186746
186790
  updateAgent(agentId, body) {
186747
- const currentRecord = this.agents.get(agentId);
186791
+ const currentRecord = this.refreshAgentRecordFromStorage(agentId);
186748
186792
  if (!currentRecord) {
186749
186793
  if (this.strictAgentAccess) {
186750
186794
  throw new LocalBackendNotFoundError("Agent", agentId);
@@ -186774,7 +186818,7 @@ class LocalStore {
186774
186818
  ...typeof bodyRecord.system === "string" && {
186775
186819
  system: bodyRecord.system
186776
186820
  },
186777
- ...isStringArray2(bodyRecord.tags) && { tags: bodyRecord.tags },
186821
+ ...isStringArray3(bodyRecord.tags) && { tags: bodyRecord.tags },
186778
186822
  ...nextModel && { model: nextModel },
186779
186823
  ...typeof bodyRecord.hidden === "boolean" && {
186780
186824
  hidden: bodyRecord.hidden
@@ -186789,7 +186833,7 @@ class LocalStore {
186789
186833
  return this.projectAgent(updated);
186790
186834
  }
186791
186835
  setAgentCompactionSettings(agentId, settings3) {
186792
- const existing = this.agents.get(agentId);
186836
+ const existing = this.refreshAgentRecordFromStorage(agentId);
186793
186837
  if (!existing) {
186794
186838
  throw new LocalBackendNotFoundError("Agent", agentId);
186795
186839
  }
@@ -187136,7 +187180,7 @@ class LocalStore {
187136
187180
  const localMessage = {
187137
187181
  id: this.nextLocalMessageId(),
187138
187182
  role: "user",
187139
- otid: optionalString2(message.otid ?? message.client_message_id),
187183
+ otid: optionalString3(message.otid ?? message.client_message_id),
187140
187184
  metadata: {
187141
187185
  created_at: date6,
187142
187186
  updated_at: date6,
@@ -187929,10 +187973,13 @@ class LocalStore {
187929
187973
  for (const file3 of readdirSync9(agentsDir)) {
187930
187974
  if (!file3.endsWith(".json") || file3.startsWith("._"))
187931
187975
  continue;
187932
- const raw = readJsonFile2(join31(agentsDir, file3));
187976
+ const filePath = join31(agentsDir, file3);
187977
+ const mtimeMs = statSync7(filePath).mtimeMs;
187978
+ const raw = readJsonFile2(filePath);
187933
187979
  const agent2 = normalizeAgentRecord(raw, this.defaultAgentModel);
187934
187980
  if (agent2?.id) {
187935
187981
  this.agents.set(agent2.id, agent2);
187982
+ this.recordAgentRecordMtime(agent2.id, mtimeMs);
187936
187983
  if (shouldPersistSubagentHiddenBackfill(raw, agent2)) {
187937
187984
  this.persistAgent(agent2.id);
187938
187985
  }
@@ -187948,8 +187995,52 @@ class LocalStore {
187948
187995
  return;
187949
187996
  const agentsDir = join31(this.storageDir, "agents");
187950
187997
  mkdirSync16(agentsDir, { recursive: true });
187951
- writeFileSync11(join31(agentsDir, `${encodePathSegment(agentId)}.json`), `${JSON.stringify(agent2, null, 2)}
187998
+ writeFileSync12(join31(agentsDir, `${encodePathSegment(agentId)}.json`), `${JSON.stringify(agent2, null, 2)}
187952
187999
  `);
188000
+ this.recordAgentRecordMtime(agentId);
188001
+ }
188002
+ agentRecordFileMtimeMs(agentId) {
188003
+ if (!this.storageDir)
188004
+ return;
188005
+ try {
188006
+ return statSync7(join31(this.storageDir, "agents", `${encodePathSegment(agentId)}.json`)).mtimeMs;
188007
+ } catch {
188008
+ return;
188009
+ }
188010
+ }
188011
+ recordAgentRecordMtime(agentId, mtimeMs) {
188012
+ const recordedMtimeMs = mtimeMs ?? this.agentRecordFileMtimeMs(agentId);
188013
+ if (recordedMtimeMs === undefined) {
188014
+ this.agentRecordMtimeMsById.delete(agentId);
188015
+ return;
188016
+ }
188017
+ this.agentRecordMtimeMsById.set(agentId, recordedMtimeMs);
188018
+ }
188019
+ refreshAgentRecordFromStorage(agentId) {
188020
+ const existing = this.agents.get(agentId);
188021
+ if (!this.storageDir || !existing)
188022
+ return existing;
188023
+ const mtimeMs = this.agentRecordFileMtimeMs(agentId);
188024
+ if (mtimeMs === undefined)
188025
+ return existing;
188026
+ if (this.agentRecordMtimeMsById.get(agentId) === mtimeMs)
188027
+ return existing;
188028
+ try {
188029
+ const raw = readJsonFile2(join31(this.storageDir, "agents", `${encodePathSegment(agentId)}.json`));
188030
+ const agent2 = normalizeAgentRecord(raw, this.defaultAgentModel);
188031
+ if (!agent2 || agent2.id !== agentId)
188032
+ return existing;
188033
+ this.agents.set(agentId, agent2);
188034
+ this.recordAgentRecordMtime(agentId, mtimeMs);
188035
+ return agent2;
188036
+ } catch {
188037
+ return existing;
188038
+ }
188039
+ }
188040
+ refreshLoadedAgentRecordsFromStorage() {
188041
+ for (const agentId of this.agents.keys()) {
188042
+ this.refreshAgentRecordFromStorage(agentId);
188043
+ }
187953
188044
  }
187954
188045
  projectAgent(record5) {
187955
188046
  const defaultConversation = this.findConversation("default", record5.id);
@@ -187967,7 +188058,7 @@ class LocalStore {
187967
188058
  return;
187968
188059
  const conversationDir = join31(this.storageDir, "conversations", encodePathSegment(key));
187969
188060
  mkdirSync16(conversationDir, { recursive: true });
187970
- writeFileSync11(join31(conversationDir, "conversation.json"), `${JSON.stringify(conversation, null, 2)}
188061
+ writeFileSync12(join31(conversationDir, "conversation.json"), `${JSON.stringify(conversation, null, 2)}
187971
188062
  `);
187972
188063
  this.recordConversationRecordMtime(key, conversationDir);
187973
188064
  const messagesPath = transcriptMessagesPath(conversationDir);
@@ -188038,7 +188129,7 @@ class LocalStore {
188038
188129
  if (messages.length === 0)
188039
188130
  return;
188040
188131
  const entries = localTranscriptSessionEntries(conversation, messages);
188041
- writeFileSync11(messagesPath, jsonl(entries));
188132
+ writeFileSync12(messagesPath, jsonl(entries));
188042
188133
  this.resetPersistedSessionStateFromEntries(key, entries);
188043
188134
  }
188044
188135
  appendConversationSessionMessageEntry(key, conversation, messagesPath, message) {
@@ -188090,7 +188181,7 @@ class LocalStore {
188090
188181
  ensureConversationTranscriptHeader(conversation, messagesPath) {
188091
188182
  if (existsSync23(messagesPath) && statSync7(messagesPath).size > 0)
188092
188183
  return;
188093
- writeFileSync11(messagesPath, `${JSON.stringify(createLocalTranscriptSessionHeader(conversation))}
188184
+ writeFileSync12(messagesPath, `${JSON.stringify(createLocalTranscriptSessionHeader(conversation))}
188094
188185
  `);
188095
188186
  }
188096
188187
  resetPersistedSessionState(key, messageFormat, transcript) {
@@ -188134,11 +188225,11 @@ class LocalStore {
188134
188225
  nextSessionEntryId(key) {
188135
188226
  const entryIds = this.sessionEntryIds(key);
188136
188227
  for (let attempt = 0;attempt < 100; attempt += 1) {
188137
- const id2 = randomUUID7().slice(0, 8);
188228
+ const id2 = randomUUID8().slice(0, 8);
188138
188229
  if (!entryIds.has(id2))
188139
188230
  return id2;
188140
188231
  }
188141
- return randomUUID7();
188232
+ return randomUUID8();
188142
188233
  }
188143
188234
  persistCompiledSystemPrompt(conversationId, agentId) {
188144
188235
  if (!this.storageDir)
@@ -188149,7 +188240,7 @@ class LocalStore {
188149
188240
  return;
188150
188241
  const conversationDir = join31(this.storageDir, "conversations", encodePathSegment(key));
188151
188242
  mkdirSync16(conversationDir, { recursive: true });
188152
- writeFileSync11(join31(conversationDir, "system-prompt.json"), `${JSON.stringify(prompt, null, 2)}
188243
+ writeFileSync12(join31(conversationDir, "system-prompt.json"), `${JSON.stringify(prompt, null, 2)}
188153
188244
  `);
188154
188245
  }
188155
188246
  ensureConversation(conversationId, agentId) {
@@ -188237,6 +188328,7 @@ class LocalStore {
188237
188328
  var DEFAULT_LOCAL_AGENT_NAME = "Letta Code", DEFAULT_LOCAL_MODEL = "local/default", LEGACY_LOCAL_CONTEXT_WINDOW_LIMIT = 128000, DEFAULT_LOCAL_CONVERSATION_ID_PREFIX = "local-conv-", DEFAULT_LOCAL_STORED_MESSAGE_ID_PREFIX = "letta-msg-", DEFAULT_LOCAL_UI_MESSAGE_ID_PREFIX = "ui-msg-", LocalBackendNotFoundError, LOCAL_TRANSCRIPT_LEGACY_SCHEMA_VERSION = 1, LOCAL_TRANSCRIPT_SCHEMA_VERSION = 2, LOCAL_TRANSCRIPT_LEGACY_MESSAGE_FORMAT = "pi-ai-message-jsonl", LOCAL_TRANSCRIPT_MESSAGE_FORMAT = "pi-session-entry-jsonl", LOCAL_TRANSCRIPT_PROVIDER_STACK = "pi-ai", LocalTranscriptMigrationRequiredError, LocalTranscriptRepairRequiredError;
188238
188329
  var init_local_store = __esm(() => {
188239
188330
  init_constants2();
188331
+ init_local_agent_record();
188240
188332
  init_local_conversation_fork();
188241
188333
  init_local_model_normalization();
188242
188334
  init_local_stream_chunks();
@@ -189080,7 +189172,7 @@ var init_error_formatter = __esm(() => {
189080
189172
  });
189081
189173
 
189082
189174
  // src/agent/turn-recovery-policy.ts
189083
- import { randomUUID as randomUUID8 } from "node:crypto";
189175
+ import { randomUUID as randomUUID9 } from "node:crypto";
189084
189176
  function isCloudflareEdge52xDetail(detail) {
189085
189177
  if (typeof detail !== "string")
189086
189178
  return false;
@@ -189293,7 +189385,7 @@ function buildFreshDenialApprovals(serverApprovals, denialReason) {
189293
189385
  function refreshInputOtidsForNewRequest(currentInput) {
189294
189386
  return currentInput.map((item) => ({
189295
189387
  ...item,
189296
- otid: randomUUID8()
189388
+ otid: randomUUID9()
189297
189389
  }));
189298
189390
  }
189299
189391
  function rebuildInputWithFreshDenials(currentInput, serverApprovals, denialReason) {
@@ -189302,7 +189394,7 @@ function rebuildInputWithFreshDenials(currentInput, serverApprovals, denialReaso
189302
189394
  const denials = {
189303
189395
  type: "approval",
189304
189396
  approvals: buildFreshDenialApprovals(serverApprovals, denialReason),
189305
- otid: randomUUID8()
189397
+ otid: randomUUID9()
189306
189398
  };
189307
189399
  return [denials, ...stripped];
189308
189400
  }
@@ -192231,7 +192323,7 @@ __export(exports_provider_turn_executor, {
192231
192323
  buildProviderTurnInput: () => buildProviderTurnInput,
192232
192324
  ProviderTurnExecutor: () => ProviderTurnExecutor
192233
192325
  });
192234
- import { randomUUID as randomUUID9 } from "node:crypto";
192326
+ import { randomUUID as randomUUID10 } from "node:crypto";
192235
192327
  function providerStreamPart(part) {
192236
192328
  return { type: "provider-part", part };
192237
192329
  }
@@ -192390,7 +192482,7 @@ function otidForContentSegment(otids, prefix, contentIndex, partial4, messageTyp
192390
192482
  const existing = otids.get(segmentStartIndex);
192391
192483
  if (existing)
192392
192484
  return existing;
192393
- const otid = `${prefix}-${segmentStartIndex}-${randomUUID9()}`;
192485
+ const otid = `${prefix}-${segmentStartIndex}-${randomUUID10()}`;
192394
192486
  otids.set(segmentStartIndex, otid);
192395
192487
  return otid;
192396
192488
  }
@@ -194960,7 +195052,7 @@ __export(exports_personality, {
194960
195052
  applyPersonalityToMemory: () => applyPersonalityToMemory
194961
195053
  });
194962
195054
  import { execFile as execFileCb3 } from "node:child_process";
194963
- import { existsSync as existsSync25, mkdirSync as mkdirSync17, readFileSync as readFileSync13, writeFileSync as writeFileSync12 } from "node:fs";
195055
+ import { existsSync as existsSync25, mkdirSync as mkdirSync17, readFileSync as readFileSync14, writeFileSync as writeFileSync13 } from "node:fs";
194964
195056
  import { dirname as dirname21, join as join32 } from "node:path";
194965
195057
  import { promisify as promisify6 } from "node:util";
194966
195058
  function ensureTrailingNewline2(content) {
@@ -195094,7 +195186,7 @@ async function getMemoryCommitAuthor(agentId) {
195094
195186
  function applyPersonalityFiles(filesToUpdate) {
195095
195187
  const changedPaths = [];
195096
195188
  for (const file3 of filesToUpdate) {
195097
- const existingContent = existsSync25(file3.absolutePath) ? readFileSync13(file3.absolutePath, "utf-8") : null;
195189
+ const existingContent = existsSync25(file3.absolutePath) ? readFileSync14(file3.absolutePath, "utf-8") : null;
195098
195190
  const nextContent = existingContent ? replaceBodyPreservingFrontmatter(existingContent, file3.content, {
195099
195191
  description: file3.description
195100
195192
  }) : buildDefaultMemoryFile(file3.templatePromptAssetName, file3.content, file3.description);
@@ -195102,7 +195194,7 @@ function applyPersonalityFiles(filesToUpdate) {
195102
195194
  continue;
195103
195195
  }
195104
195196
  mkdirSync17(dirname21(file3.absolutePath), { recursive: true });
195105
- writeFileSync12(file3.absolutePath, nextContent, "utf-8");
195197
+ writeFileSync13(file3.absolutePath, nextContent, "utf-8");
195106
195198
  changedPaths.push(file3.relativePath);
195107
195199
  }
195108
195200
  return changedPaths;
@@ -232273,7 +232365,7 @@ var init_paste_registry = __esm(() => {
232273
232365
 
232274
232366
  // src/cli/helpers/clipboard.ts
232275
232367
  import { execFileSync as execFileSync3 } from "node:child_process";
232276
- import { existsSync as existsSync27, readFileSync as readFileSync15, statSync as statSync8, unlinkSync as unlinkSync5 } from "node:fs";
232368
+ import { existsSync as existsSync27, readFileSync as readFileSync16, statSync as statSync8, unlinkSync as unlinkSync5 } from "node:fs";
232277
232369
  import { tmpdir as tmpdir6 } from "node:os";
232278
232370
  import { basename as basename9, extname as extname4, isAbsolute as isAbsolute21, join as join33, resolve as resolve28 } from "node:path";
232279
232371
  function countLines(text2) {
@@ -232332,14 +232424,14 @@ function translatePasteForImages(paste) {
232332
232424
  try {
232333
232425
  const stat10 = statSync8(filePath);
232334
232426
  if (stat10.isFile())
232335
- buf = readFileSync15(filePath);
232427
+ buf = readFileSync16(filePath);
232336
232428
  } catch {}
232337
232429
  let clipboardMediaType = null;
232338
232430
  if (!buf && process.platform === "darwin" && /TemporaryItems\/.*screencaptureui/i.test(filePath)) {
232339
232431
  const clipResult = getClipboardImageToTempFile();
232340
232432
  if (clipResult) {
232341
232433
  try {
232342
- buf = readFileSync15(clipResult.tempPath);
232434
+ buf = readFileSync16(clipResult.tempPath);
232343
232435
  clipboardMediaType = UTI_TO_MEDIA_TYPE[clipResult.uti] || null;
232344
232436
  try {
232345
232437
  unlinkSync5(clipResult.tempPath);
@@ -232408,7 +232500,7 @@ async function tryImportClipboardImageMac() {
232408
232500
  return null;
232409
232501
  const { tempPath, uti } = clipboardResult;
232410
232502
  try {
232411
- const buffer = readFileSync15(tempPath);
232503
+ const buffer = readFileSync16(tempPath);
232412
232504
  try {
232413
232505
  unlinkSync5(tempPath);
232414
232506
  } catch {}
@@ -233645,7 +233737,7 @@ function parsePositiveIntFlag(options3) {
233645
233737
  }
233646
233738
 
233647
233739
  // src/cli/helpers/file-autocomplete.ts
233648
- import { spawn as spawn7, spawnSync as spawnSync3 } from "node:child_process";
233740
+ import { spawn as spawn6, spawnSync as spawnSync3 } from "node:child_process";
233649
233741
  import {
233650
233742
  chmodSync as chmodSync5,
233651
233743
  createWriteStream as createWriteStream3,
@@ -233791,7 +233883,7 @@ async function walkDirectoryWithFd(baseDir, fdPath, query2, maxResults, signal)
233791
233883
  resolve29([]);
233792
233884
  return;
233793
233885
  }
233794
- const child = spawn7(fdPath, args, {
233886
+ const child = spawn6(fdPath, args, {
233795
233887
  stdio: ["ignore", "pipe", "pipe"]
233796
233888
  });
233797
233889
  let stdout = "";
@@ -234346,6 +234438,7 @@ var init_favorites = __esm(() => {
234346
234438
  var init_local = __esm(() => {
234347
234439
  init_context_window_overflow();
234348
234440
  init_compaction();
234441
+ init_local_agent_record();
234349
234442
  init_local_backend();
234350
234443
  init_local_model_config();
234351
234444
  init_local_provider_auth_store();
@@ -234354,7 +234447,7 @@ var init_local = __esm(() => {
234354
234447
  });
234355
234448
 
234356
234449
  // src/cli/helpers/local-agent-listing.ts
234357
- import { existsSync as existsSync29, readdirSync as readdirSync11, readFileSync as readFileSync16, statSync as statSync10 } from "node:fs";
234450
+ import { existsSync as existsSync29, readdirSync as readdirSync11, readFileSync as readFileSync17, statSync as statSync10 } from "node:fs";
234358
234451
  import { join as join35 } from "node:path";
234359
234452
  function listLocalAgentsFromDisk() {
234360
234453
  const storageDir = getLocalBackendStorageDir();
@@ -234366,7 +234459,7 @@ function listLocalAgentsFromDisk() {
234366
234459
  for (const file3 of files) {
234367
234460
  try {
234368
234461
  const filePath = join35(agentsDir, file3);
234369
- const raw2 = readFileSync16(filePath, "utf8");
234462
+ const raw2 = readFileSync17(filePath, "utf8");
234370
234463
  const record5 = JSON.parse(raw2);
234371
234464
  if (isHiddenLocalAgentRecord(record5))
234372
234465
  continue;
@@ -236224,7 +236317,7 @@ function shouldAcceptSlackInboundBotMessage(params) {
236224
236317
  }
236225
236318
 
236226
236319
  // src/channels/config.ts
236227
- import { existsSync as existsSync30, readFileSync as readFileSync17 } from "node:fs";
236320
+ import { existsSync as existsSync30, readFileSync as readFileSync18 } from "node:fs";
236228
236321
  import { homedir as homedir24 } from "node:os";
236229
236322
  import { join as join36 } from "node:path";
236230
236323
  function parseWhatsAppWaitingBehavior(value) {
@@ -236328,7 +236421,7 @@ function readChannelConfig(channelId) {
236328
236421
  if (!existsSync30(configPath))
236329
236422
  return null;
236330
236423
  try {
236331
- const text2 = readFileSync17(configPath, "utf-8");
236424
+ const text2 = readFileSync18(configPath, "utf-8");
236332
236425
  const parsed = parseSimpleYaml(text2);
236333
236426
  const codec3 = getChannelConfigCodec(channelId);
236334
236427
  if (!codec3)
@@ -236609,7 +236702,7 @@ __export(exports_accounts, {
236609
236702
  __testOverrideLoadChannelAccounts: () => __testOverrideLoadChannelAccounts,
236610
236703
  LEGACY_CHANNEL_ACCOUNT_ID: () => LEGACY_CHANNEL_ACCOUNT_ID
236611
236704
  });
236612
- import { existsSync as existsSync31, mkdirSync as mkdirSync19, readFileSync as readFileSync18, writeFileSync as writeFileSync13 } from "node:fs";
236705
+ import { existsSync as existsSync31, mkdirSync as mkdirSync19, readFileSync as readFileSync19, writeFileSync as writeFileSync14 } from "node:fs";
236613
236706
  function isSecretPlaceholder(value) {
236614
236707
  return value === SECRET_PRESENT_PLACEHOLDER;
236615
236708
  }
@@ -236964,7 +237057,7 @@ function loadChannelAccounts(channelId) {
236964
237057
  const path30 = getChannelAccountsPath(channelId);
236965
237058
  if (existsSync31(path30)) {
236966
237059
  try {
236967
- const text2 = readFileSync18(path30, "utf-8");
237060
+ const text2 = readFileSync19(path30, "utf-8");
236968
237061
  const parsed = JSON.parse(text2);
236969
237062
  stores.set(channelId, {
236970
237063
  accounts: (parsed.accounts ?? []).map((account) => {
@@ -237017,7 +237110,7 @@ function saveChannelAccounts(channelId) {
237017
237110
  }
237018
237111
  const dir = getChannelDir(channelId);
237019
237112
  mkdirSync19(dir, { recursive: true });
237020
- writeFileSync13(getChannelAccountsPath(channelId), `${JSON.stringify({ accounts: writeAccounts }, null, 2)}
237113
+ writeFileSync14(getChannelAccountsPath(channelId), `${JSON.stringify({ accounts: writeAccounts }, null, 2)}
237021
237114
  `, "utf-8");
237022
237115
  }
237023
237116
  async function flushPendingChannelSecretWrites() {
@@ -237174,7 +237267,7 @@ __export(exports_pairing, {
237174
237267
  __testOverrideLoadPairingStore: () => __testOverrideLoadPairingStore
237175
237268
  });
237176
237269
  import { randomInt } from "node:crypto";
237177
- import { existsSync as existsSync32, mkdirSync as mkdirSync20, readFileSync as readFileSync19, writeFileSync as writeFileSync14 } from "node:fs";
237270
+ import { existsSync as existsSync32, mkdirSync as mkdirSync20, readFileSync as readFileSync20, writeFileSync as writeFileSync15 } from "node:fs";
237178
237271
  function normalizeAccountId(accountId) {
237179
237272
  return accountId ?? LEGACY_CHANNEL_ACCOUNT_ID;
237180
237273
  }
@@ -237202,7 +237295,7 @@ function loadPairingStore(channelId) {
237202
237295
  if (!existsSync32(path30))
237203
237296
  return;
237204
237297
  try {
237205
- const text2 = readFileSync19(path30, "utf-8");
237298
+ const text2 = readFileSync20(path30, "utf-8");
237206
237299
  const parsed = JSON.parse(text2);
237207
237300
  stores2.set(channelId, {
237208
237301
  pending: parsed.pending ?? [],
@@ -237221,7 +237314,7 @@ function savePairingStore(channelId) {
237221
237314
  }
237222
237315
  const dir = getChannelDir(channelId);
237223
237316
  mkdirSync20(dir, { recursive: true });
237224
- writeFileSync14(getChannelPairingPath(channelId), `${JSON.stringify(store2, null, 2)}
237317
+ writeFileSync15(getChannelPairingPath(channelId), `${JSON.stringify(store2, null, 2)}
237225
237318
  `, "utf-8");
237226
237319
  }
237227
237320
  function generateCode(length = 6) {
@@ -237345,7 +237438,7 @@ var init_pairing = __esm(() => {
237345
237438
  });
237346
237439
 
237347
237440
  // src/channels/custom/adapter.ts
237348
- import { randomUUID as randomUUID10 } from "node:crypto";
237441
+ import { randomUUID as randomUUID11 } from "node:crypto";
237349
237442
  function readString(account, key2) {
237350
237443
  const value = account.config[key2];
237351
237444
  return typeof value === "string" && value.length > 0 ? value : null;
@@ -237411,7 +237504,7 @@ function createCustomAdapter(account) {
237411
237504
  parsed = null;
237412
237505
  }
237413
237506
  }
237414
- return { messageId: extractMessageId(parsed) ?? randomUUID10() };
237507
+ return { messageId: extractMessageId(parsed) ?? randomUUID11() };
237415
237508
  }
237416
237509
  return {
237417
237510
  id: `custom:${account.accountId}`,
@@ -238597,7 +238690,7 @@ __export(exports_transcription, {
238597
238690
  isTranscriptionConfigured: () => isTranscriptionConfigured
238598
238691
  });
238599
238692
  import { execFileSync as execFileSync4 } from "node:child_process";
238600
- import { mkdtempSync as mkdtempSync2, readFileSync as readFileSync20, rmSync as rmSync7 } from "node:fs";
238693
+ import { mkdtempSync as mkdtempSync2, readFileSync as readFileSync21, rmSync as rmSync7 } from "node:fs";
238601
238694
  import { tmpdir as tmpdir7 } from "node:os";
238602
238695
  import { basename as basename12, extname as extname5, join as join39 } from "node:path";
238603
238696
  function audioMimeTypeForPath(localPath) {
@@ -238664,7 +238757,7 @@ async function transcribeAudioFile(localPath) {
238664
238757
  try {
238665
238758
  const prepared = prepareOpenAiTranscriptionFile(localPath);
238666
238759
  try {
238667
- const buffer = readFileSync20(prepared.localPath);
238760
+ const buffer = readFileSync21(prepared.localPath);
238668
238761
  const filename = basename12(prepared.localPath);
238669
238762
  const formData = new FormData;
238670
238763
  const blob = new Blob([buffer], {
@@ -238720,7 +238813,7 @@ var init_transcription = __esm(() => {
238720
238813
  });
238721
238814
 
238722
238815
  // src/channels/telegram/media.ts
238723
- import { randomUUID as randomUUID11 } from "node:crypto";
238816
+ import { randomUUID as randomUUID12 } from "node:crypto";
238724
238817
  import { mkdir as mkdir8, writeFile as writeFile10 } from "node:fs/promises";
238725
238818
  import { basename as basename13, extname as extname6, join as join40 } from "node:path";
238726
238819
  function normalizeTelegramMimeType(mimeType) {
@@ -239016,7 +239109,7 @@ function inferAttachmentFileName(params) {
239016
239109
  async function saveTelegramAttachment(params) {
239017
239110
  const inboundDir = join40(getChannelDir("telegram"), "inbound", sanitizeTelegramPathSegment(params.accountId));
239018
239111
  await mkdir8(inboundDir, { recursive: true });
239019
- const filePath = join40(inboundDir, `${Date.now()}-${randomUUID11()}-${sanitizeTelegramPathSegment(params.fileName)}`);
239112
+ const filePath = join40(inboundDir, `${Date.now()}-${randomUUID12()}-${sanitizeTelegramPathSegment(params.fileName)}`);
239020
239113
  await writeFile10(filePath, params.buffer);
239021
239114
  return filePath;
239022
239115
  }
@@ -240171,7 +240264,7 @@ var init_typing_controller = __esm(() => {
240171
240264
  });
240172
240265
 
240173
240266
  // src/channels/telegram/adapter.ts
240174
- import { randomUUID as randomUUID12 } from "node:crypto";
240267
+ import { randomUUID as randomUUID13 } from "node:crypto";
240175
240268
  function createTelegramAdapter(config3) {
240176
240269
  let bot = null;
240177
240270
  let botModule = null;
@@ -240437,7 +240530,7 @@ function createTelegramAdapter(config3) {
240437
240530
  }
240438
240531
  function rememberLifecycleErrorReport(source2, errorText, runId) {
240439
240532
  pruneLifecycleErrorReports();
240440
- const token2 = randomUUID12();
240533
+ const token2 = randomUUID13();
240441
240534
  lifecycleErrorReports.set(token2, {
240442
240535
  expiresAt: Date.now() + TELEGRAM_LIFECYCLE_ERROR_REPORT_TTL_MS,
240443
240536
  report: buildChannelLifecycleErrorReport(source2, errorText, { runId }),
@@ -240831,7 +240924,7 @@ var init_message_actions = __esm(() => {
240831
240924
  });
240832
240925
 
240833
240926
  // src/channels/telegram/setup.ts
240834
- import { randomUUID as randomUUID13 } from "node:crypto";
240927
+ import { randomUUID as randomUUID14 } from "node:crypto";
240835
240928
  import { createInterface } from "node:readline/promises";
240836
240929
  async function runTelegramSetup() {
240837
240930
  const rl = createInterface({
@@ -240900,7 +240993,7 @@ Validating token...`);
240900
240993
  const now = new Date().toISOString();
240901
240994
  const account = {
240902
240995
  channel: "telegram",
240903
- accountId: randomUUID13(),
240996
+ accountId: randomUUID14(),
240904
240997
  displayName: validatedUsername ? `@${validatedUsername}` : undefined,
240905
240998
  enabled: true,
240906
240999
  token: token2.trim(),
@@ -242481,7 +242574,7 @@ var init_approval_controller = __esm(() => {
242481
242574
  });
242482
242575
 
242483
242576
  // src/channels/slack/attachment-stream.ts
242484
- import { randomUUID as randomUUID14 } from "node:crypto";
242577
+ import { randomUUID as randomUUID15 } from "node:crypto";
242485
242578
  import { mkdir as mkdir9, open as open2, rename as rename2, rm as rm7 } from "node:fs/promises";
242486
242579
  import { join as join41 } from "node:path";
242487
242580
  function sanitizeFileName(name) {
@@ -242517,7 +242610,7 @@ async function readWithIdleTimeout(reader, idleTimeoutMs, signal) {
242517
242610
  async function saveSlackAttachmentStream(params) {
242518
242611
  const inboundDir = join41(getChannelDir("slack"), "inbound", sanitizeFileName(params.accountId));
242519
242612
  await mkdir9(inboundDir, { recursive: true });
242520
- const filePath = join41(inboundDir, `${Date.now()}-${randomUUID14()}-${sanitizeFileName(params.fileName)}`);
242613
+ const filePath = join41(inboundDir, `${Date.now()}-${randomUUID15()}-${sanitizeFileName(params.fileName)}`);
242521
242614
  const temporaryPath = `${filePath}.partial`;
242522
242615
  const fileHandle = await open2(temporaryPath, "wx");
242523
242616
  const reader = params.body.getReader();
@@ -245768,7 +245861,7 @@ function createSlackMessageActionAdapter(options3 = {}) {
245768
245861
  }
245769
245862
 
245770
245863
  // src/channels/targets.ts
245771
- import { existsSync as existsSync34, mkdirSync as mkdirSync21, readFileSync as readFileSync21, writeFileSync as writeFileSync15 } from "node:fs";
245864
+ import { existsSync as existsSync34, mkdirSync as mkdirSync21, readFileSync as readFileSync22, writeFileSync as writeFileSync16 } from "node:fs";
245772
245865
  function getStore3(channelId) {
245773
245866
  let store2 = stores3.get(channelId);
245774
245867
  if (!store2) {
@@ -245787,7 +245880,7 @@ function loadTargetStore(channelId) {
245787
245880
  return;
245788
245881
  }
245789
245882
  try {
245790
- const text2 = readFileSync21(path30, "utf-8");
245883
+ const text2 = readFileSync22(path30, "utf-8");
245791
245884
  const parsed = JSON.parse(text2);
245792
245885
  stores3.set(channelId, {
245793
245886
  targets: parsed.targets ?? []
@@ -245801,7 +245894,7 @@ function saveTargetStore(channelId) {
245801
245894
  }
245802
245895
  const dir = getChannelDir(channelId);
245803
245896
  mkdirSync21(dir, { recursive: true });
245804
- writeFileSync15(getChannelTargetsPath(channelId), `${JSON.stringify(getStore3(channelId), null, 2)}
245897
+ writeFileSync16(getChannelTargetsPath(channelId), `${JSON.stringify(getStore3(channelId), null, 2)}
245805
245898
  `, "utf-8");
245806
245899
  }
245807
245900
  function listChannelTargets(channelId, accountId) {
@@ -246158,7 +246251,7 @@ var init_message_actions2 = __esm(() => {
246158
246251
  });
246159
246252
 
246160
246253
  // src/channels/slack/setup.ts
246161
- import { randomUUID as randomUUID15 } from "node:crypto";
246254
+ import { randomUUID as randomUUID16 } from "node:crypto";
246162
246255
  import { createInterface as createInterface2 } from "node:readline/promises";
246163
246256
  function isValidBotToken(token2) {
246164
246257
  return token2.startsWith("xoxb-") && token2.length >= 20;
@@ -246225,7 +246318,7 @@ DM Policy — who can message this app directly?
246225
246318
  } catch {}
246226
246319
  const account = {
246227
246320
  channel: "slack",
246228
- accountId: randomUUID15(),
246321
+ accountId: randomUUID16(),
246229
246322
  displayName,
246230
246323
  enabled: true,
246231
246324
  mode: "socket",
@@ -246387,7 +246480,7 @@ function resolveDiscordChannelMode(channelId, parentChannelId, isThread, allowed
246387
246480
  }
246388
246481
 
246389
246482
  // src/channels/discord/media.ts
246390
- import { randomUUID as randomUUID16 } from "node:crypto";
246483
+ import { randomUUID as randomUUID17 } from "node:crypto";
246391
246484
  import { mkdirSync as mkdirSync22 } from "node:fs";
246392
246485
  import { writeFile as writeFile11 } from "node:fs/promises";
246393
246486
  import { tmpdir as tmpdir8 } from "node:os";
@@ -246422,7 +246515,7 @@ async function resolveDiscordInboundAttachments(params) {
246422
246515
  const kind = resolveAttachmentKind2(attachment.contentType);
246423
246516
  const localFileName = [
246424
246517
  Date.now(),
246425
- randomUUID16(),
246518
+ randomUUID17(),
246426
246519
  sanitizeDiscordPathSegment(params.accountId),
246427
246520
  sanitizeDiscordPathSegment(params.chatId),
246428
246521
  sanitizeDiscordPathSegment(attachment.id),
@@ -247463,7 +247556,7 @@ var init_message_actions3 = __esm(() => {
247463
247556
  });
247464
247557
 
247465
247558
  // src/channels/discord/setup.ts
247466
- import { randomUUID as randomUUID17 } from "node:crypto";
247559
+ import { randomUUID as randomUUID18 } from "node:crypto";
247467
247560
  import { createInterface as createInterface3 } from "node:readline/promises";
247468
247561
  function isValidBotToken2(token2) {
247469
247562
  return token2.length >= 50 && token2.includes(".");
@@ -247575,7 +247668,7 @@ Warning: No agent bound. DM pairing will still work, but open/allowlist DMs and
247575
247668
  const now = new Date().toISOString();
247576
247669
  const account = {
247577
247670
  channel: "discord",
247578
- accountId: randomUUID17(),
247671
+ accountId: randomUUID18(),
247579
247672
  enabled: true,
247580
247673
  token: token2,
247581
247674
  agentId,
@@ -247808,7 +247901,7 @@ var init_attachment_policy = __esm(() => {
247808
247901
  });
247809
247902
 
247810
247903
  // src/channels/whatsapp/media.ts
247811
- import { randomUUID as randomUUID18 } from "node:crypto";
247904
+ import { randomUUID as randomUUID19 } from "node:crypto";
247812
247905
  import { mkdir as mkdir10, writeFile as writeFile12 } from "node:fs/promises";
247813
247906
  import { basename as basename17, extname as extname10, join as join43 } from "node:path";
247814
247907
  function unwrapWhatsAppMessageContent(message) {
@@ -247966,7 +248059,7 @@ async function collectWhatsAppAttachments(params) {
247966
248059
  const rawName = typeof candidate.mediaMessage.fileName === "string" ? candidate.mediaMessage.fileName : undefined;
247967
248060
  const name = rawName || `whatsapp-${params.messageId}.${extensionFromMime(mimeType)}`;
247968
248061
  const attachment = {
247969
- id: randomUUID18(),
248062
+ id: randomUUID19(),
247970
248063
  name,
247971
248064
  mimeType,
247972
248065
  sizeBytes,
@@ -248487,21 +248580,21 @@ var MAX_WHATSAPP_INBOUND_DEBOUNCE_MS = 1e4;
248487
248580
  var init_inbound_debounce2 = () => {};
248488
248581
 
248489
248582
  // src/channels/whatsapp/lid-store.ts
248490
- import { randomUUID as randomUUID19 } from "node:crypto";
248583
+ import { randomUUID as randomUUID20 } from "node:crypto";
248491
248584
  import {
248492
248585
  closeSync as closeSync2,
248493
248586
  mkdirSync as mkdirSync23,
248494
248587
  openSync as openSync2,
248495
- readFileSync as readFileSync22,
248588
+ readFileSync as readFileSync23,
248496
248589
  renameSync as renameSync5,
248497
248590
  unlinkSync as unlinkSync6,
248498
- writeFileSync as writeFileSync16
248591
+ writeFileSync as writeFileSync17
248499
248592
  } from "node:fs";
248500
248593
  import { dirname as dirname23, isAbsolute as isAbsolute23 } from "node:path";
248501
248594
  function parseStoreFile(filePath) {
248502
248595
  let rawText;
248503
248596
  try {
248504
- rawText = readFileSync22(filePath, "utf8");
248597
+ rawText = readFileSync23(filePath, "utf8");
248505
248598
  } catch {
248506
248599
  return new Map;
248507
248600
  }
@@ -248584,11 +248677,11 @@ function createLidStore(filePath) {
248584
248677
  const data = serializeStore(map3);
248585
248678
  const dir = dirname23(filePath);
248586
248679
  mkdirSync23(dir, { recursive: true });
248587
- const tmpPath = `${filePath}.${randomUUID19()}.tmp`;
248680
+ const tmpPath = `${filePath}.${randomUUID20()}.tmp`;
248588
248681
  let fd = null;
248589
248682
  try {
248590
248683
  fd = openSync2(tmpPath, "wx", 384);
248591
- writeFileSync16(fd, data, "utf8");
248684
+ writeFileSync17(fd, data, "utf8");
248592
248685
  closeSync2(fd);
248593
248686
  fd = null;
248594
248687
  renameSync5(tmpPath, filePath);
@@ -248915,7 +249008,7 @@ var init_state = __esm(() => {
248915
249008
  });
248916
249009
 
248917
249010
  // src/channels/whatsapp/session.ts
248918
- import { mkdirSync as mkdirSync24, readFileSync as readFileSync23, rmSync as rmSync8, writeFileSync as writeFileSync17 } from "node:fs";
249011
+ import { mkdirSync as mkdirSync24, readFileSync as readFileSync24, rmSync as rmSync8, writeFileSync as writeFileSync18 } from "node:fs";
248919
249012
  import { homedir as homedir25 } from "node:os";
248920
249013
  import { join as join44 } from "node:path";
248921
249014
  function shouldDropLine(line) {
@@ -248989,7 +249082,7 @@ function defaultIsProcessAlive(pid) {
248989
249082
  }
248990
249083
  function readLeaseOwner(lockDir) {
248991
249084
  try {
248992
- const owner = JSON.parse(readFileSync23(join44(lockDir, "owner.json"), "utf8"));
249085
+ const owner = JSON.parse(readFileSync24(join44(lockDir, "owner.json"), "utf8"));
248993
249086
  return {
248994
249087
  pid: typeof owner.pid === "number" ? owner.pid : undefined,
248995
249088
  command: typeof owner.command === "string" ? owner.command : undefined
@@ -249009,7 +249102,7 @@ function acquireWhatsAppSessionLease(accountId, options3 = {}) {
249009
249102
  for (let attempt = 0;attempt < 2; attempt += 1) {
249010
249103
  try {
249011
249104
  mkdirSync24(lockDir);
249012
- writeFileSync17(join44(lockDir, "owner.json"), `${JSON.stringify({
249105
+ writeFileSync18(join44(lockDir, "owner.json"), `${JSON.stringify({
249013
249106
  accountId,
249014
249107
  pid,
249015
249108
  command: process.argv.join(" "),
@@ -250111,7 +250204,7 @@ var init_message_actions4 = __esm(() => {
250111
250204
  });
250112
250205
 
250113
250206
  // src/channels/whatsapp/setup.ts
250114
- import { randomUUID as randomUUID20 } from "node:crypto";
250207
+ import { randomUUID as randomUUID21 } from "node:crypto";
250115
250208
  import { createInterface as createInterface4 } from "node:readline/promises";
250116
250209
  function isDmPolicy(value) {
250117
250210
  return value === "pairing" || value === "allowlist" || value === "open";
@@ -250193,7 +250286,7 @@ Group mode: disabled, mention, or open [disabled]: `);
250193
250286
  const now = new Date().toISOString();
250194
250287
  const account = {
250195
250288
  channel: "whatsapp",
250196
- accountId: randomUUID20(),
250289
+ accountId: randomUUID21(),
250197
250290
  enabled: true,
250198
250291
  dmPolicy: policy,
250199
250292
  allowedUsers,
@@ -250263,7 +250356,7 @@ var init_plugin5 = __esm(() => {
250263
250356
  });
250264
250357
 
250265
250358
  // src/channels/signal/client.ts
250266
- import { randomUUID as randomUUID21 } from "node:crypto";
250359
+ import { randomUUID as randomUUID22 } from "node:crypto";
250267
250360
  import { request as httpRequest } from "node:http";
250268
250361
  import { request as httpsRequest } from "node:https";
250269
250362
  function getRequest(url2) {
@@ -250349,7 +250442,7 @@ class SignalRestClient {
250349
250442
  jsonrpc: "2.0",
250350
250443
  method: "version",
250351
250444
  params: {},
250352
- id: randomUUID21()
250445
+ id: randomUUID22()
250353
250446
  }).catch((versionError) => {
250354
250447
  throw new Error(`Signal daemon health check failed: ${formatSignalClientError(checkError)}; version fallback failed: ${formatSignalClientError(versionError)}`);
250355
250448
  });
@@ -250368,7 +250461,7 @@ class SignalRestClient {
250368
250461
  jsonrpc: "2.0",
250369
250462
  method,
250370
250463
  params: this.withAccount(params),
250371
- id: randomUUID21()
250464
+ id: randomUUID22()
250372
250465
  };
250373
250466
  const response = await this.request("POST", "/api/v1/rpc", body3);
250374
250467
  if (response === null) {
@@ -250609,12 +250702,12 @@ var init_client6 = __esm(() => {
250609
250702
  });
250610
250703
 
250611
250704
  // src/channels/signal/media.ts
250612
- import { randomUUID as randomUUID22 } from "node:crypto";
250705
+ import { randomUUID as randomUUID23 } from "node:crypto";
250613
250706
  import {
250614
250707
  copyFileSync as copyFileSync2,
250615
250708
  mkdirSync as mkdirSync25,
250616
250709
  readdirSync as readdirSync12,
250617
- readFileSync as readFileSync24,
250710
+ readFileSync as readFileSync25,
250618
250711
  realpathSync as realpathSync6,
250619
250712
  statSync as statSync12
250620
250713
  } from "node:fs";
@@ -250893,7 +250986,7 @@ function copySignalAttachment(params) {
250893
250986
  const kind = inferSignalAttachmentKind({ mimeType, fileName });
250894
250987
  const inboundDir = join46(getChannelDir("signal"), "inbound", sanitizeSignalPathSegment(params.accountId));
250895
250988
  mkdirSync25(inboundDir, { recursive: true });
250896
- const localPath = join46(inboundDir, `${Date.now()}-${randomUUID22()}-${sanitizeSignalPathSegment(fileName)}`);
250989
+ const localPath = join46(inboundDir, `${Date.now()}-${randomUUID23()}-${sanitizeSignalPathSegment(fileName)}`);
250897
250990
  copyFileSync2(params.sourcePath, localPath);
250898
250991
  const attachment = {
250899
250992
  id: params.attachment.id ?? undefined,
@@ -250904,7 +250997,7 @@ function copySignalAttachment(params) {
250904
250997
  localPath
250905
250998
  };
250906
250999
  if (kind === "image" && sizeBytes <= MAX_SIGNAL_INLINE_IMAGE_BYTES) {
250907
- attachment.imageDataBase64 = readFileSync24(localPath).toString("base64");
251000
+ attachment.imageDataBase64 = readFileSync25(localPath).toString("base64");
250908
251001
  }
250909
251002
  return attachment;
250910
251003
  }
@@ -251591,7 +251684,7 @@ var init_runtime6 = __esm(() => {
251591
251684
  });
251592
251685
 
251593
251686
  // src/channels/signal/setup-runtime.ts
251594
- import { execFileSync as execFileSync5, spawn as spawn8 } from "node:child_process";
251687
+ import { execFileSync as execFileSync5, spawn as spawn7 } from "node:child_process";
251595
251688
  import { existsSync as existsSync35 } from "node:fs";
251596
251689
  function getSignalDockerRunCommand() {
251597
251690
  return [
@@ -251653,7 +251746,7 @@ function runNativeSignalCli(args) {
251653
251746
  }
251654
251747
  function runNativeSignalCliInteractive(args, onOutput) {
251655
251748
  return new Promise((resolve30) => {
251656
- const child = spawn8("signal-cli", args, {
251749
+ const child = spawn7("signal-cli", args, {
251657
251750
  stdio: ["ignore", "pipe", "pipe"]
251658
251751
  });
251659
251752
  let output = "";
@@ -252400,7 +252493,7 @@ __export(exports_plugin_registry, {
252400
252493
  getChannelDisplayName: () => getChannelDisplayName,
252401
252494
  __testClearUserChannelPluginCache: () => __testClearUserChannelPluginCache
252402
252495
  });
252403
- import { existsSync as existsSync36, readdirSync as readdirSync13, readFileSync as readFileSync25 } from "node:fs";
252496
+ import { existsSync as existsSync36, readdirSync as readdirSync13, readFileSync as readFileSync26 } from "node:fs";
252404
252497
  import { resolve as resolve30, sep as sep6 } from "node:path";
252405
252498
  import { pathToFileURL as pathToFileURL2 } from "node:url";
252406
252499
  function isValidChannelId(value) {
@@ -252415,7 +252508,7 @@ function readChannelManifest(channelDir) {
252415
252508
  return null;
252416
252509
  }
252417
252510
  try {
252418
- const parsed = JSON.parse(readFileSync25(manifestPath, "utf-8"));
252511
+ const parsed = JSON.parse(readFileSync26(manifestPath, "utf-8"));
252419
252512
  if (!isRecord(parsed)) {
252420
252513
  return null;
252421
252514
  }
@@ -252676,7 +252769,7 @@ __export(exports_routing, {
252676
252769
  __testOverrideSaveRoutes: () => __testOverrideSaveRoutes,
252677
252770
  __testOverrideLoadRoutes: () => __testOverrideLoadRoutes
252678
252771
  });
252679
- import { existsSync as existsSync37, mkdirSync as mkdirSync26, readFileSync as readFileSync26, writeFileSync as writeFileSync18 } from "node:fs";
252772
+ import { existsSync as existsSync37, mkdirSync as mkdirSync26, readFileSync as readFileSync27, writeFileSync as writeFileSync19 } from "node:fs";
252680
252773
  function normalizeAccountId3(accountId) {
252681
252774
  return accountId ?? LEGACY_CHANNEL_ACCOUNT_ID;
252682
252775
  }
@@ -252730,7 +252823,7 @@ function loadRoutes(channelId) {
252730
252823
  if (!existsSync37(path30))
252731
252824
  return;
252732
252825
  try {
252733
- const text2 = readFileSync26(path30, "utf-8");
252826
+ const text2 = readFileSync27(path30, "utf-8");
252734
252827
  const parsed = JSON.parse(text2);
252735
252828
  const routes = parsed.routes ?? [];
252736
252829
  for (const route of routes) {
@@ -252767,7 +252860,7 @@ function saveRoutes(channelId) {
252767
252860
  mkdirSync26(dir, { recursive: true });
252768
252861
  const routes = getRoutesForChannel(channelId);
252769
252862
  const data = { routes };
252770
- writeFileSync18(getChannelRoutingPath(channelId), `${JSON.stringify(data, null, 2)}
252863
+ writeFileSync19(getChannelRoutingPath(channelId), `${JSON.stringify(data, null, 2)}
252771
252864
  `, "utf-8");
252772
252865
  }
252773
252866
  function getRoute(channel, chatId, accountId, threadId) {
@@ -253190,7 +253283,7 @@ var init_registry_commands = __esm(() => {
253190
253283
  });
253191
253284
 
253192
253285
  // src/channels/pending-control-requests.ts
253193
- import { existsSync as existsSync38, mkdirSync as mkdirSync27, readFileSync as readFileSync27, writeFileSync as writeFileSync19 } from "node:fs";
253286
+ import { existsSync as existsSync38, mkdirSync as mkdirSync27, readFileSync as readFileSync28, writeFileSync as writeFileSync20 } from "node:fs";
253194
253287
  import { dirname as dirname24 } from "node:path";
253195
253288
  function cloneEvent(event2) {
253196
253289
  return structuredClone(event2);
@@ -253223,7 +253316,7 @@ function ensureStoreLoaded() {
253223
253316
  return;
253224
253317
  }
253225
253318
  try {
253226
- const text2 = readFileSync27(storePath, "utf-8");
253319
+ const text2 = readFileSync28(storePath, "utf-8");
253227
253320
  const parsed = JSON.parse(text2);
253228
253321
  store2 = {
253229
253322
  requests: Array.isArray(parsed.requests) ? parsed.requests.filter(isChannelControlRequestEvent).map(cloneEvent) : []
@@ -253241,7 +253334,7 @@ function saveStore() {
253241
253334
  }
253242
253335
  const storePath = getPendingChannelControlRequestsPath();
253243
253336
  mkdirSync27(dirname24(storePath), { recursive: true });
253244
- writeFileSync19(storePath, `${JSON.stringify(snapshot, null, 2)}
253337
+ writeFileSync20(storePath, `${JSON.stringify(snapshot, null, 2)}
253245
253338
  `, "utf-8");
253246
253339
  }
253247
253340
  function listPendingControlRequests() {
@@ -255117,7 +255210,7 @@ function isString2(value) {
255117
255210
  function isNullableString2(value) {
255118
255211
  return value === null || typeof value === "string";
255119
255212
  }
255120
- function isStringArray3(value) {
255213
+ function isStringArray4(value) {
255121
255214
  return Array.isArray(value) && value.every((entry) => typeof entry === "string");
255122
255215
  }
255123
255216
  function isDiscordChannelMode(value) {
@@ -255131,7 +255224,7 @@ function isModeMap2(value) {
255131
255224
  return Object.values(record5).every(isDiscordChannelMode);
255132
255225
  }
255133
255226
  function isAllowedChannels(value) {
255134
- return isStringArray3(value) || isModeMap2(value);
255227
+ return isStringArray4(value) || isModeMap2(value);
255135
255228
  }
255136
255229
  function isDefaultPermissionMode(value) {
255137
255230
  return value === "standard" || value === "acceptEdits" || value === "unrestricted" || value === "default" || value === "bypassPermissions" || value === "fullAccess";
@@ -255232,7 +255325,7 @@ function isNullableString3(value) {
255232
255325
  function isBoolean2(value) {
255233
255326
  return typeof value === "boolean";
255234
255327
  }
255235
- function isStringArray4(value) {
255328
+ function isStringArray5(value) {
255236
255329
  return Array.isArray(value) && value.every((entry) => typeof entry === "string");
255237
255330
  }
255238
255331
  function isStringRecord(value) {
@@ -255274,7 +255367,7 @@ var init_account_config3 = __esm(() => {
255274
255367
  return false;
255275
255368
  }
255276
255369
  }
255277
- return (config3.base_url === undefined || isNullableString3(config3.base_url)) && (config3.account === undefined || isNullableString3(config3.account)) && (config3.account_uuid === undefined || isNullableString3(config3.account_uuid)) && (config3.agent_id === undefined || isNullableString3(config3.agent_id)) && (config3.self_chat_mode === undefined || isBoolean2(config3.self_chat_mode)) && (config3.group_mode === undefined || isGroupMode2(config3.group_mode)) && (config3.allowed_groups === undefined || isStringArray4(config3.allowed_groups)) && (config3.mention_patterns === undefined || isStringArray4(config3.mention_patterns)) && (config3.recipient_aliases === undefined || isStringRecord(config3.recipient_aliases)) && (config3.transcribe_voice === undefined || isBoolean2(config3.transcribe_voice)) && (config3.download_media === undefined || isBoolean2(config3.download_media)) && (config3.media_max_bytes === undefined || isPositiveNumber(config3.media_max_bytes));
255370
+ return (config3.base_url === undefined || isNullableString3(config3.base_url)) && (config3.account === undefined || isNullableString3(config3.account)) && (config3.account_uuid === undefined || isNullableString3(config3.account_uuid)) && (config3.agent_id === undefined || isNullableString3(config3.agent_id)) && (config3.self_chat_mode === undefined || isBoolean2(config3.self_chat_mode)) && (config3.group_mode === undefined || isGroupMode2(config3.group_mode)) && (config3.allowed_groups === undefined || isStringArray5(config3.allowed_groups)) && (config3.mention_patterns === undefined || isStringArray5(config3.mention_patterns)) && (config3.recipient_aliases === undefined || isStringRecord(config3.recipient_aliases)) && (config3.transcribe_voice === undefined || isBoolean2(config3.transcribe_voice)) && (config3.download_media === undefined || isBoolean2(config3.download_media)) && (config3.media_max_bytes === undefined || isPositiveNumber(config3.media_max_bytes));
255278
255371
  },
255279
255372
  toAccountPatch(config3) {
255280
255373
  return {
@@ -255284,8 +255377,8 @@ var init_account_config3 = __esm(() => {
255284
255377
  agentId: isNullableString3(config3.agent_id) ? config3.agent_id : undefined,
255285
255378
  selfChatMode: isBoolean2(config3.self_chat_mode) ? config3.self_chat_mode : undefined,
255286
255379
  groupMode: isGroupMode2(config3.group_mode) ? config3.group_mode : undefined,
255287
- allowedGroups: isStringArray4(config3.allowed_groups) ? [...config3.allowed_groups] : undefined,
255288
- mentionPatterns: isStringArray4(config3.mention_patterns) ? [...config3.mention_patterns] : undefined,
255380
+ allowedGroups: isStringArray5(config3.allowed_groups) ? [...config3.allowed_groups] : undefined,
255381
+ mentionPatterns: isStringArray5(config3.mention_patterns) ? [...config3.mention_patterns] : undefined,
255289
255382
  recipientAliases: isStringRecord(config3.recipient_aliases) ? { ...config3.recipient_aliases } : undefined,
255290
255383
  transcribeVoice: isBoolean2(config3.transcribe_voice) ? config3.transcribe_voice : undefined,
255291
255384
  downloadMedia: isBoolean2(config3.download_media) ? config3.download_media : undefined,
@@ -255340,7 +255433,7 @@ function isNullableString4(value) {
255340
255433
  function isBoolean3(value) {
255341
255434
  return value === true || value === false;
255342
255435
  }
255343
- function isStringArray5(value) {
255436
+ function isStringArray6(value) {
255344
255437
  return Array.isArray(value) && value.every(isString3);
255345
255438
  }
255346
255439
  function isDefaultPermissionMode2(value) {
@@ -255369,7 +255462,7 @@ var init_account_config4 = __esm(() => {
255369
255462
  return false;
255370
255463
  }
255371
255464
  }
255372
- return (config3.bot_token === undefined || isString3(config3.bot_token)) && (config3.app_token === undefined || isString3(config3.app_token)) && (config3.mode === undefined || config3.mode === "socket") && (config3.agent_id === undefined || isNullableString4(config3.agent_id)) && (config3.default_permission_mode === undefined || isDefaultPermissionMode2(config3.default_permission_mode)) && (config3.transcribe_voice === undefined || isBoolean3(config3.transcribe_voice)) && (config3.show_completed_reaction === undefined || isBoolean3(config3.show_completed_reaction)) && (config3.listen_mode === undefined || isBoolean3(config3.listen_mode)) && (config3.mention_only_channels === undefined || isStringArray5(config3.mention_only_channels)) && isValidSlackAllowBotsConfigValue(config3.allow_bots);
255465
+ return (config3.bot_token === undefined || isString3(config3.bot_token)) && (config3.app_token === undefined || isString3(config3.app_token)) && (config3.mode === undefined || config3.mode === "socket") && (config3.agent_id === undefined || isNullableString4(config3.agent_id)) && (config3.default_permission_mode === undefined || isDefaultPermissionMode2(config3.default_permission_mode)) && (config3.transcribe_voice === undefined || isBoolean3(config3.transcribe_voice)) && (config3.show_completed_reaction === undefined || isBoolean3(config3.show_completed_reaction)) && (config3.listen_mode === undefined || isBoolean3(config3.listen_mode)) && (config3.mention_only_channels === undefined || isStringArray6(config3.mention_only_channels)) && isValidSlackAllowBotsConfigValue(config3.allow_bots);
255373
255466
  },
255374
255467
  toAccountPatch(config3) {
255375
255468
  return {
@@ -255380,7 +255473,7 @@ var init_account_config4 = __esm(() => {
255380
255473
  defaultPermissionMode: isDefaultPermissionMode2(config3.default_permission_mode) ? migratePermissionMode(config3.default_permission_mode) : undefined,
255381
255474
  transcribeVoice: isBoolean3(config3.transcribe_voice) ? config3.transcribe_voice : undefined,
255382
255475
  listenMode: isBoolean3(config3.listen_mode) ? config3.listen_mode : undefined,
255383
- mentionOnlyChannels: isStringArray5(config3.mention_only_channels) ? [...config3.mention_only_channels] : undefined,
255476
+ mentionOnlyChannels: isStringArray6(config3.mention_only_channels) ? [...config3.mention_only_channels] : undefined,
255384
255477
  allowBots: config3.allow_bots !== undefined && isValidSlackAllowBotsConfigValue(config3.allow_bots) ? normalizeSlackAllowBotsMode(config3.allow_bots) : undefined
255385
255478
  };
255386
255479
  },
@@ -255496,7 +255589,7 @@ function isNullableString5(value) {
255496
255589
  function isBoolean5(value) {
255497
255590
  return typeof value === "boolean";
255498
255591
  }
255499
- function isStringArray6(value) {
255592
+ function isStringArray7(value) {
255500
255593
  return Array.isArray(value) && value.every((entry) => typeof entry === "string");
255501
255594
  }
255502
255595
  function isGroupMode3(value) {
@@ -255542,22 +255635,22 @@ var init_account_config6 = __esm(() => {
255542
255635
  return false;
255543
255636
  }
255544
255637
  }
255545
- return (config3.agent_id === undefined || isNullableString5(config3.agent_id)) && (config3.self_chat_mode === undefined || isBoolean5(config3.self_chat_mode)) && (config3.group_mode === undefined || isGroupMode3(config3.group_mode)) && (config3.allowed_groups === undefined || isStringArray6(config3.allowed_groups)) && (config3.mention_patterns === undefined || isStringArray6(config3.mention_patterns)) && (config3.transcribe_voice === undefined || isBoolean5(config3.transcribe_voice)) && (config3.download_media === undefined || isBoolean5(config3.download_media)) && (config3.media_max_bytes === undefined || isPositiveNumber2(config3.media_max_bytes)) && (config3.attachment_filter === undefined || isBoolean5(config3.attachment_filter)) && (config3.attachment_mime_types === undefined || isStringArray6(config3.attachment_mime_types)) && (config3.attachment_allowed_recipients === undefined || isStringArray6(config3.attachment_allowed_recipients)) && (config3.attachment_allowed_paths === undefined || isStringArray6(config3.attachment_allowed_paths)) && (config3.attachment_path_recursive === undefined || isBoolean5(config3.attachment_path_recursive)) && (config3.inbound_debounce_ms === undefined || isValidInboundDebounceMs(config3.inbound_debounce_ms)) && (config3.waiting_behavior === undefined || isWaitingBehavior(config3.waiting_behavior)) && (config3.message_prefix === undefined || isString5(config3.message_prefix));
255638
+ return (config3.agent_id === undefined || isNullableString5(config3.agent_id)) && (config3.self_chat_mode === undefined || isBoolean5(config3.self_chat_mode)) && (config3.group_mode === undefined || isGroupMode3(config3.group_mode)) && (config3.allowed_groups === undefined || isStringArray7(config3.allowed_groups)) && (config3.mention_patterns === undefined || isStringArray7(config3.mention_patterns)) && (config3.transcribe_voice === undefined || isBoolean5(config3.transcribe_voice)) && (config3.download_media === undefined || isBoolean5(config3.download_media)) && (config3.media_max_bytes === undefined || isPositiveNumber2(config3.media_max_bytes)) && (config3.attachment_filter === undefined || isBoolean5(config3.attachment_filter)) && (config3.attachment_mime_types === undefined || isStringArray7(config3.attachment_mime_types)) && (config3.attachment_allowed_recipients === undefined || isStringArray7(config3.attachment_allowed_recipients)) && (config3.attachment_allowed_paths === undefined || isStringArray7(config3.attachment_allowed_paths)) && (config3.attachment_path_recursive === undefined || isBoolean5(config3.attachment_path_recursive)) && (config3.inbound_debounce_ms === undefined || isValidInboundDebounceMs(config3.inbound_debounce_ms)) && (config3.waiting_behavior === undefined || isWaitingBehavior(config3.waiting_behavior)) && (config3.message_prefix === undefined || isString5(config3.message_prefix));
255546
255639
  },
255547
255640
  toAccountPatch(config3) {
255548
255641
  return {
255549
255642
  agentId: isNullableString5(config3.agent_id) ? config3.agent_id : undefined,
255550
255643
  selfChatMode: isBoolean5(config3.self_chat_mode) ? config3.self_chat_mode : undefined,
255551
255644
  groupMode: isGroupMode3(config3.group_mode) ? config3.group_mode : undefined,
255552
- allowedGroups: isStringArray6(config3.allowed_groups) ? [...config3.allowed_groups] : undefined,
255553
- mentionPatterns: isStringArray6(config3.mention_patterns) ? [...config3.mention_patterns] : undefined,
255645
+ allowedGroups: isStringArray7(config3.allowed_groups) ? [...config3.allowed_groups] : undefined,
255646
+ mentionPatterns: isStringArray7(config3.mention_patterns) ? [...config3.mention_patterns] : undefined,
255554
255647
  transcribeVoice: isBoolean5(config3.transcribe_voice) ? config3.transcribe_voice : undefined,
255555
255648
  downloadMedia: isBoolean5(config3.download_media) ? config3.download_media : undefined,
255556
255649
  mediaMaxBytes: isPositiveNumber2(config3.media_max_bytes) ? config3.media_max_bytes : undefined,
255557
255650
  attachmentFilter: isBoolean5(config3.attachment_filter) ? config3.attachment_filter : undefined,
255558
- attachmentMimeTypes: isStringArray6(config3.attachment_mime_types) ? [...config3.attachment_mime_types] : undefined,
255559
- attachmentAllowedRecipients: isStringArray6(config3.attachment_allowed_recipients) ? [...config3.attachment_allowed_recipients] : undefined,
255560
- attachmentAllowedPaths: isStringArray6(config3.attachment_allowed_paths) ? [...config3.attachment_allowed_paths] : undefined,
255651
+ attachmentMimeTypes: isStringArray7(config3.attachment_mime_types) ? [...config3.attachment_mime_types] : undefined,
255652
+ attachmentAllowedRecipients: isStringArray7(config3.attachment_allowed_recipients) ? [...config3.attachment_allowed_recipients] : undefined,
255653
+ attachmentAllowedPaths: isStringArray7(config3.attachment_allowed_paths) ? [...config3.attachment_allowed_paths] : undefined,
255561
255654
  attachmentPathRecursive: isBoolean5(config3.attachment_path_recursive) ? config3.attachment_path_recursive : undefined,
255562
255655
  inboundDebounceMs: isValidInboundDebounceMs(config3.inbound_debounce_ms) ? Math.trunc(Math.min(config3.inbound_debounce_ms, 1e4)) : undefined,
255563
255656
  waitingBehavior: isWaitingBehavior(config3.waiting_behavior) ? config3.waiting_behavior : undefined,
@@ -256427,10 +256520,10 @@ var init_service_snapshots = __esm(() => {
256427
256520
  });
256428
256521
 
256429
256522
  // src/channels/service-accounts.ts
256430
- import { randomUUID as randomUUID23 } from "node:crypto";
256523
+ import { randomUUID as randomUUID24 } from "node:crypto";
256431
256524
  function createChannelAccountLive(channelId, patch2, options3) {
256432
256525
  assertSupportedChannelId(channelId);
256433
- const accountId = options3?.accountId?.trim() || randomUUID23();
256526
+ const accountId = options3?.accountId?.trim() || randomUUID24();
256434
256527
  const existing = getChannelAccount(channelId, accountId);
256435
256528
  if (existing) {
256436
256529
  throw new Error(`Channel account "${accountId}" already exists for ${channelId}.`);
@@ -256440,7 +256533,7 @@ function createChannelAccountLive(channelId, patch2, options3) {
256440
256533
  }
256441
256534
  async function createChannelAccountLiveWithSecrets(channelId, patch2, options3) {
256442
256535
  assertSupportedChannelId(channelId);
256443
- const accountId = options3?.accountId?.trim() || randomUUID23();
256536
+ const accountId = options3?.accountId?.trim() || randomUUID24();
256444
256537
  const existing = await getChannelAccountWithSecrets(channelId, accountId);
256445
256538
  if (existing) {
256446
256539
  throw new Error(`Channel account "${accountId}" already exists for ${channelId}.`);
@@ -258891,7 +258984,11 @@ Provider '${providerName}' saved.`);
258891
258984
  if (provider.target !== "local") {
258892
258985
  await io.ensureSettingsReady();
258893
258986
  }
258894
- await io.checkProviderApiKey(provider.byokProvider.providerType, apiKey);
258987
+ if (hasConnectionOptions(connectionOptions)) {
258988
+ await io.checkProviderApiKey(provider.byokProvider.providerType, apiKey, undefined, undefined, undefined, { connection: connectionOptions });
258989
+ } else {
258990
+ await io.checkProviderApiKey(provider.byokProvider.providerType, apiKey);
258991
+ }
258895
258992
  io.stdout("Saving provider...");
258896
258993
  if (hasConnectionOptions(connectionOptions)) {
258897
258994
  await io.createOrUpdateProvider(provider.byokProvider.providerType, provider.byokProvider.providerName, apiKey, undefined, undefined, undefined, connectionOptions);
@@ -265363,8 +265460,8 @@ var require_CronFileParser = __commonJS((exports) => {
265363
265460
  return CronFileParser.#parseContent(data);
265364
265461
  }
265365
265462
  static parseFileSync(filePath) {
265366
- const { readFileSync: readFileSync28 } = __require("fs");
265367
- const data = readFileSync28(filePath, "utf8");
265463
+ const { readFileSync: readFileSync29 } = __require("fs");
265464
+ const data = readFileSync29(filePath, "utf8");
265368
265465
  return CronFileParser.#parseContent(data);
265369
265466
  }
265370
265467
  static #parseContent(data) {
@@ -265706,11 +265803,11 @@ import { randomBytes } from "node:crypto";
265706
265803
  import {
265707
265804
  existsSync as existsSync39,
265708
265805
  mkdirSync as mkdirSync28,
265709
- readFileSync as readFileSync28,
265806
+ readFileSync as readFileSync29,
265710
265807
  renameSync as renameSync6,
265711
265808
  rmSync as rmSync9,
265712
265809
  statSync as statSync13,
265713
- writeFileSync as writeFileSync20
265810
+ writeFileSync as writeFileSync21
265714
265811
  } from "node:fs";
265715
265812
  import { join as join47 } from "node:path";
265716
265813
  function getLettaDir() {
@@ -265755,7 +265852,7 @@ function readCronFile() {
265755
265852
  if (!existsSync39(path31))
265756
265853
  return emptyFile();
265757
265854
  try {
265758
- const raw2 = readFileSync28(path31, "utf-8");
265855
+ const raw2 = readFileSync29(path31, "utf-8");
265759
265856
  const data = JSON.parse(raw2);
265760
265857
  if (data.version !== 1)
265761
265858
  return emptyFile();
@@ -265771,12 +265868,12 @@ function writeCronFile(data) {
265771
265868
  mkdirSync28(dir, { recursive: true });
265772
265869
  }
265773
265870
  const tmp = `${path31}.tmp`;
265774
- writeFileSync20(tmp, JSON.stringify(data, null, 2), { flush: true });
265871
+ writeFileSync21(tmp, JSON.stringify(data, null, 2), { flush: true });
265775
265872
  renameSync6(tmp, path31);
265776
265873
  }
265777
265874
  function readLinuxProcessIdentity(pid) {
265778
265875
  try {
265779
- const stat10 = readFileSync28(`/proc/${pid}/stat`, "utf8");
265876
+ const stat10 = readFileSync29(`/proc/${pid}/stat`, "utf8");
265780
265877
  const endCommand = stat10.lastIndexOf(")");
265781
265878
  if (endCommand === -1) {
265782
265879
  return null;
@@ -265788,7 +265885,7 @@ function readLinuxProcessIdentity(pid) {
265788
265885
  }
265789
265886
  let bootId = null;
265790
265887
  try {
265791
- bootId = readFileSync28("/proc/sys/kernel/random/boot_id", "utf8").trim() || null;
265888
+ bootId = readFileSync29("/proc/sys/kernel/random/boot_id", "utf8").trim() || null;
265792
265889
  } catch {}
265793
265890
  return { startTicks, bootId };
265794
265891
  } catch {
@@ -265829,14 +265926,14 @@ function isProcessAlive(pid, owner) {
265829
265926
  }
265830
265927
  function readLockOwner(lockDir) {
265831
265928
  try {
265832
- const raw2 = readFileSync28(join47(lockDir, LOCK_TOKEN_FILE), "utf-8");
265929
+ const raw2 = readFileSync29(join47(lockDir, LOCK_TOKEN_FILE), "utf-8");
265833
265930
  return JSON.parse(raw2);
265834
265931
  } catch {
265835
265932
  return null;
265836
265933
  }
265837
265934
  }
265838
265935
  function writeLockOwner(lockDir, owner) {
265839
- writeFileSync20(join47(lockDir, LOCK_TOKEN_FILE), JSON.stringify(owner));
265936
+ writeFileSync21(join47(lockDir, LOCK_TOKEN_FILE), JSON.stringify(owner));
265840
265937
  }
265841
265938
  function isLockStale(lockDir) {
265842
265939
  const owner = readLockOwner(lockDir);
@@ -266126,9 +266223,9 @@ import {
266126
266223
  chmodSync as chmodSync6,
266127
266224
  existsSync as existsSync40,
266128
266225
  mkdirSync as mkdirSync29,
266129
- readFileSync as readFileSync29,
266226
+ readFileSync as readFileSync30,
266130
266227
  statSync as statSync14,
266131
- writeFileSync as writeFileSync21
266228
+ writeFileSync as writeFileSync22
266132
266229
  } from "node:fs";
266133
266230
  import path31 from "node:path";
266134
266231
  function assertSafeCronRunLogJobId(jobId) {
@@ -266174,11 +266271,11 @@ function pruneIfNeeded(filePath, opts) {
266174
266271
  if (size <= opts.maxBytes) {
266175
266272
  return;
266176
266273
  }
266177
- const raw2 = readFileSync29(filePath, "utf-8");
266274
+ const raw2 = readFileSync30(filePath, "utf-8");
266178
266275
  const lines = raw2.split(`
266179
266276
  `).map((line) => line.trim()).filter(Boolean);
266180
266277
  const kept = lines.slice(Math.max(0, lines.length - opts.keepLines));
266181
- writeFileSync21(filePath, `${kept.join(`
266278
+ writeFileSync22(filePath, `${kept.join(`
266182
266279
  `)}
266183
266280
  `, { mode: 384 });
266184
266281
  setSecureFileMode(filePath);
@@ -266254,7 +266351,7 @@ function readCronRunLogEntries(filePath, opts) {
266254
266351
  const limit3 = Math.max(1, Math.min(5000, Math.floor(opts?.limit ?? 200)));
266255
266352
  let raw2 = "";
266256
266353
  try {
266257
- raw2 = readFileSync29(path31.resolve(filePath), "utf-8");
266354
+ raw2 = readFileSync30(path31.resolve(filePath), "utf-8");
266258
266355
  } catch {
266259
266356
  return [];
266260
266357
  }
@@ -266682,7 +266779,7 @@ function shouldProcessInboundMessageDirectly(runtime, parsed) {
266682
266779
  });
266683
266780
  return getListenerBlockedReason(runtime.turnLifecycle.snapshot(), activeScope ? getPendingControlRequestCount(runtime.listener, activeScope) : 0) === null;
266684
266781
  }
266685
- function consumeQueuedTurn(runtime) {
266782
+ function consumeQueuedTurn(runtime, options3) {
266686
266783
  const queuedItems = runtime.queueRuntime.peek();
266687
266784
  const firstQueuedItem = queuedItems[0];
266688
266785
  if (!firstQueuedItem || !isCoalescable(firstQueuedItem.kind)) {
@@ -266732,6 +266829,18 @@ function consumeQueuedTurn(runtime) {
266732
266829
  if (!hasMessage && !hasTaskNotification && !hasCronPrompt && !hasModContinue || queueLen === 0) {
266733
266830
  return null;
266734
266831
  }
266832
+ if (options3?.matchActiveSuperRun) {
266833
+ const activeSuperRunId = runtime.superRunId;
266834
+ const crossesSuperRun = queuedItems.slice(0, queueLen).some((item) => {
266835
+ if (item.kind !== "message")
266836
+ return false;
266837
+ const queuedSuperRunId = runtime.queuedMessagesByItemId.get(item.id)?.superRunId ?? null;
266838
+ return queuedSuperRunId !== activeSuperRunId;
266839
+ });
266840
+ if (crossesSuperRun) {
266841
+ return null;
266842
+ }
266843
+ }
266735
266844
  const dequeuedBatch = runtime.queueRuntime.consumeItems(queueLen);
266736
266845
  if (!dequeuedBatch) {
266737
266846
  return null;
@@ -269623,9 +269732,9 @@ function validateTranscript(value, options3) {
269623
269732
  if (typeof record5.source !== "string" || !record5.source) {
269624
269733
  fail2(`Record ${index}: meta.source must be a non-empty string.`);
269625
269734
  }
269626
- optionalString3(record5, "cwd", index);
269627
- optionalString3(record5, "git_branch", index);
269628
- optionalString3(record5, "model", index);
269735
+ optionalString4(record5, "cwd", index);
269736
+ optionalString4(record5, "git_branch", index);
269737
+ optionalString4(record5, "model", index);
269629
269738
  continue;
269630
269739
  }
269631
269740
  validateTimestamp(record5.timestamp, index);
@@ -269726,7 +269835,7 @@ function exactKeys(value, allowed, recordIndex, label = "record") {
269726
269835
  if (extra)
269727
269836
  fail2(`Record ${recordIndex}: unexpected ${label} field ${JSON.stringify(extra)}.`);
269728
269837
  }
269729
- function optionalString3(value, key2, recordIndex) {
269838
+ function optionalString4(value, key2, recordIndex) {
269730
269839
  if (key2 in value && typeof value[key2] !== "string") {
269731
269840
  fail2(`Record ${recordIndex}: ${key2} must be a string when present.`);
269732
269841
  }
@@ -270330,7 +270439,7 @@ var init_core5 = __esm(() => {
270330
270439
  });
270331
270440
 
270332
270441
  // node_modules/@letta-ai/trajectory/dist/adapters/deepagents/index.js
270333
- import { spawn as spawn9 } from "node:child_process";
270442
+ import { spawn as spawn8 } from "node:child_process";
270334
270443
  import { accessSync as accessSync2, constants as constants5 } from "node:fs";
270335
270444
  import { homedir as homedir27 } from "node:os";
270336
270445
  import { join as join48 } from "node:path";
@@ -270361,7 +270470,7 @@ async function loadDeepAgentsCheckpoint(checkpoint2) {
270361
270470
  const python = checkpoint2.pythonExecutable ?? process.env.PYTHON ?? "python3";
270362
270471
  const helper = resolveHelperPath();
270363
270472
  return await new Promise((resolve31, reject) => {
270364
- const child = spawn9(python, [helper], {
270473
+ const child = spawn8(python, [helper], {
270365
270474
  stdio: ["pipe", "pipe", "pipe"],
270366
270475
  windowsHide: true
270367
270476
  });
@@ -272736,7 +272845,7 @@ var init_dream_targets = __esm(() => {
272736
272845
 
272737
272846
  // src/agent/memory-worktree.ts
272738
272847
  import { execFile as execFileCb4 } from "node:child_process";
272739
- import { randomUUID as randomUUID24 } from "node:crypto";
272848
+ import { randomUUID as randomUUID25 } from "node:crypto";
272740
272849
  import { existsSync as existsSync42 } from "node:fs";
272741
272850
  import { mkdir as mkdir13 } from "node:fs/promises";
272742
272851
  import { dirname as dirname26, isAbsolute as isAbsolute25, join as join60, resolve as resolve31 } from "node:path";
@@ -272780,7 +272889,7 @@ function normalizeGitPath(path32, cwd2) {
272780
272889
  }
272781
272890
  function buildReflectionWorktreeId(now = new Date) {
272782
272891
  const timestamp = now.toISOString().replace(/[^0-9]/g, "").slice(0, 14);
272783
- return `${timestamp}-${randomUUID24().slice(0, 8)}`;
272892
+ return `${timestamp}-${randomUUID25().slice(0, 8)}`;
272784
272893
  }
272785
272894
  function summarizeReflectionCommitSubject(subject) {
272786
272895
  const summary = subject.trim().replace(/^[a-z]+(?:\([^)]+\))?!?:\s*/i, "").trim();
@@ -273162,7 +273271,7 @@ ${instructions}
273162
273271
  }
273163
273272
 
273164
273273
  // src/telemetry/reflection-threshold-feedback.ts
273165
- import { randomUUID as randomUUID25 } from "node:crypto";
273274
+ import { randomUUID as randomUUID26 } from "node:crypto";
273166
273275
  async function resolveFeedbackApiKey() {
273167
273276
  const settings3 = await settingsManager.getSettingsWithSecureTokens();
273168
273277
  return process.env.LETTA_API_KEY || settings3.env?.LETTA_API_KEY;
@@ -273174,7 +273283,7 @@ function getFeedbackDeviceId() {
273174
273283
  return deviceId;
273175
273284
  }
273176
273285
  } catch {}
273177
- return randomUUID25();
273286
+ return randomUUID26();
273178
273287
  }
273179
273288
  function getAlertDeviceType() {
273180
273289
  switch (process.platform) {
@@ -276402,7 +276511,7 @@ var init_auth = __esm(() => {
276402
276511
  });
276403
276512
 
276404
276513
  // src/websocket/listener/manual-instance-lock.ts
276405
- import { createHash as createHash7, randomUUID as randomUUID26 } from "node:crypto";
276514
+ import { createHash as createHash7, randomUUID as randomUUID27 } from "node:crypto";
276406
276515
  import { link as link3, mkdir as mkdir14, readFile as readFile20, rm as rm9, unlink as unlink5, writeFile as writeFile15 } from "node:fs/promises";
276407
276516
  import { homedir as homedir36 } from "node:os";
276408
276517
  import path32 from "node:path";
@@ -276453,7 +276562,7 @@ function parseLockRecord(raw2, expectedScopeHash) {
276453
276562
  }
276454
276563
  }
276455
276564
  async function publishInitializedFile(targetPath, contents) {
276456
- const candidatePath = path32.join(path32.dirname(targetPath), `.manual-listener-lock-${randomUUID26()}.candidate`);
276565
+ const candidatePath = path32.join(path32.dirname(targetPath), `.manual-listener-lock-${randomUUID27()}.candidate`);
276457
276566
  let publicationError;
276458
276567
  try {
276459
276568
  await writeFile15(candidatePath, contents, { flag: "wx" });
@@ -276530,7 +276639,7 @@ async function acquireManualListenerLock(scope, overrides = {}) {
276530
276639
  const deps = {
276531
276640
  lockRoot: getDefaultLockRoot(),
276532
276641
  processId: process.pid,
276533
- ownerToken: randomUUID26(),
276642
+ ownerToken: randomUUID27(),
276534
276643
  isProcessAlive: defaultIsProcessAlive2,
276535
276644
  ...overrides
276536
276645
  };
@@ -276771,11 +276880,11 @@ function resolvePendingApprovalResolver(runtime, response, connectionId) {
276771
276880
  setCommandLoopStatus(runtime, "WAITING_ON_INPUT");
276772
276881
  }
276773
276882
  pending.resolve(response);
276774
- emitLoopStatusIfOpen(runtime.listener, {
276883
+ emitLoopStatusIfOpen(runtime, {
276775
276884
  agent_id: runtime.agentId,
276776
276885
  conversation_id: runtime.conversationId
276777
276886
  });
276778
- emitDeviceStatusIfOpen(runtime.listener, {
276887
+ emitDeviceStatusIfOpen(runtime, {
276779
276888
  agent_id: runtime.agentId,
276780
276889
  conversation_id: runtime.conversationId
276781
276890
  });
@@ -276790,11 +276899,11 @@ function rejectPendingApprovalResolvers(runtime, reason) {
276790
276899
  if (!runtime.isProcessing && !runtime.cancelRequested) {
276791
276900
  setCommandLoopStatus(runtime, "WAITING_ON_INPUT");
276792
276901
  }
276793
- emitLoopStatusIfOpen(runtime.listener, {
276902
+ emitLoopStatusIfOpen(runtime, {
276794
276903
  agent_id: runtime.agentId,
276795
276904
  conversation_id: runtime.conversationId
276796
276905
  });
276797
- emitDeviceStatusIfOpen(runtime.listener, {
276906
+ emitDeviceStatusIfOpen(runtime, {
276798
276907
  agent_id: runtime.agentId,
276799
276908
  conversation_id: runtime.conversationId
276800
276909
  });
@@ -276899,11 +277008,11 @@ function requestApprovalOverWS(runtime, socket, turnLease, requestId, controlReq
276899
277008
  runtime.turnLifecycle.recordStopReason(turnLease, "requires_approval");
276900
277009
  setTurnLoopStatus(runtime, turnLease, "WAITING_ON_APPROVAL");
276901
277010
  emitProtocolV2Message(socket, runtime, controlRequest, scope, TO_SUBSCRIBERS);
276902
- emitLoopStatusIfOpen(runtime.listener, {
277011
+ emitLoopStatusIfOpen(runtime, {
276903
277012
  agent_id: runtime.agentId,
276904
277013
  conversation_id: runtime.conversationId
276905
277014
  });
276906
- emitDeviceStatusIfOpen(runtime.listener, {
277015
+ emitDeviceStatusIfOpen(runtime, {
276907
277016
  agent_id: runtime.agentId,
276908
277017
  conversation_id: runtime.conversationId
276909
277018
  });
@@ -277045,13 +277154,13 @@ function isExternalToolCallResponseCommand(value) {
277045
277154
  function isExperimentId(value) {
277046
277155
  return typeof value === "string" && EXPERIMENT_IDS.has(value);
277047
277156
  }
277048
- function isStringArray7(value) {
277157
+ function isStringArray8(value) {
277049
277158
  return Array.isArray(value) && value.every((item) => typeof item === "string");
277050
277159
  }
277051
277160
  function isClientToolsetConfig(value) {
277052
277161
  if (!isObjectRecord2(value))
277053
277162
  return false;
277054
- return (value.base === undefined || typeof value.base === "string" && TOOLSET_PREFERENCES.has(value.base)) && (value.include === undefined || isStringArray7(value.include));
277163
+ return (value.base === undefined || typeof value.base === "string" && TOOLSET_PREFERENCES.has(value.base)) && (value.include === undefined || isStringArray8(value.include));
277055
277164
  }
277056
277165
  function isStringRecord2(value) {
277057
277166
  return !!value && typeof value === "object" && !Array.isArray(value) && Object.values(value).every((item) => typeof item === "string");
@@ -277082,7 +277191,7 @@ function isInputCommand(value) {
277082
277191
  }
277083
277192
  const payload = candidate.payload;
277084
277193
  if (payload.kind === "create_message") {
277085
- return Array.isArray(payload.messages) && (payload.image_failure_mode === undefined || payload.image_failure_mode === "strict" || payload.image_failure_mode === "drop") && (payload.client_tool_allowlist === undefined || isStringArray7(payload.client_tool_allowlist)) && (payload.client_toolset === undefined || isClientToolsetConfig(payload.client_toolset)) && (payload.external_tool_scope_ids === undefined || isStringArray7(payload.external_tool_scope_ids)) && (payload.exclude_interactive_tools === undefined || typeof payload.exclude_interactive_tools === "boolean");
277194
+ return Array.isArray(payload.messages) && (payload.image_failure_mode === undefined || payload.image_failure_mode === "strict" || payload.image_failure_mode === "drop") && (payload.client_tool_allowlist === undefined || isStringArray8(payload.client_tool_allowlist)) && (payload.client_toolset === undefined || isClientToolsetConfig(payload.client_toolset)) && (payload.external_tool_scope_ids === undefined || isStringArray8(payload.external_tool_scope_ids)) && (payload.exclude_interactive_tools === undefined || typeof payload.exclude_interactive_tools === "boolean");
277086
277195
  }
277087
277196
  if (payload.kind === "approval_response") {
277088
277197
  return isValidApprovalResponseBody(payload);
@@ -277107,9 +277216,9 @@ function legacyEnvironmentMessageToInputCommand(value) {
277107
277216
  payload: {
277108
277217
  kind: "create_message",
277109
277218
  messages: candidate.messages,
277110
- client_tool_allowlist: isStringArray7(candidate.clientToolAllowlist) ? candidate.clientToolAllowlist : undefined,
277219
+ client_tool_allowlist: isStringArray8(candidate.clientToolAllowlist) ? candidate.clientToolAllowlist : undefined,
277111
277220
  client_toolset: isClientToolsetConfig(candidate.clientToolset) ? candidate.clientToolset : undefined,
277112
- external_tool_scope_ids: isStringArray7(candidate.externalToolScopeIds) ? candidate.externalToolScopeIds : undefined
277221
+ external_tool_scope_ids: isStringArray8(candidate.externalToolScopeIds) ? candidate.externalToolScopeIds : undefined
277113
277222
  }
277114
277223
  };
277115
277224
  }
@@ -277141,7 +277250,7 @@ function getInvalidInputReason(value) {
277141
277250
  reason: "Protocol violation: input.payload.image_failure_mode must be strict or drop"
277142
277251
  };
277143
277252
  }
277144
- if (payload.client_tool_allowlist !== undefined && !isStringArray7(payload.client_tool_allowlist)) {
277253
+ if (payload.client_tool_allowlist !== undefined && !isStringArray8(payload.client_tool_allowlist)) {
277145
277254
  return {
277146
277255
  runtime: candidate.runtime,
277147
277256
  reason: "Protocol violation: input.payload.client_tool_allowlist must be string[]"
@@ -277159,7 +277268,7 @@ function getInvalidInputReason(value) {
277159
277268
  reason: "Protocol violation: input.payload.exclude_interactive_tools must be boolean"
277160
277269
  };
277161
277270
  }
277162
- if (payload.external_tool_scope_ids !== undefined && !isStringArray7(payload.external_tool_scope_ids)) {
277271
+ if (payload.external_tool_scope_ids !== undefined && !isStringArray8(payload.external_tool_scope_ids)) {
277163
277272
  return {
277164
277273
  runtime: candidate.runtime,
277165
277274
  reason: "Protocol violation: input.payload.external_tool_scope_ids must be string[]"
@@ -277240,7 +277349,7 @@ function isRuntimeStartCommand(value) {
277240
277349
  if (!value || typeof value !== "object")
277241
277350
  return false;
277242
277351
  const c = value;
277243
- return c.type === "runtime_start" && typeof c.request_id === "string" && (c.agent_id === undefined || typeof c.agent_id === "string") && (c.create_agent === undefined || isRuntimeStartCreateAgentOptions(c.create_agent)) && (c.conversation_id === undefined || typeof c.conversation_id === "string") && (c.create_conversation === undefined || isRuntimeStartCreateConversationOptions(c.create_conversation)) && (c.conversation_source_tags === undefined || isStringArray7(c.conversation_source_tags)) && (c.cwd === undefined || c.cwd === null || typeof c.cwd === "string") && (c.mode === undefined || isDevicePermissionMode(c.mode)) && (c.skill_sources === undefined || isSkillSourceArray(c.skill_sources)) && (c.preserve_skill_sources === undefined || typeof c.preserve_skill_sources === "boolean") && (c.client_info === undefined || isRuntimeStartClientInfo(c.client_info)) && (c.recover_approvals === undefined || typeof c.recover_approvals === "boolean") && (c.force_device_status === undefined || typeof c.force_device_status === "boolean") && (c.wait_for_replay === undefined || typeof c.wait_for_replay === "boolean") && (c.external_tools === undefined || Array.isArray(c.external_tools) && c.external_tools.every(isRuntimeStartExternalToolsGroup));
277352
+ return c.type === "runtime_start" && typeof c.request_id === "string" && (c.agent_id === undefined || typeof c.agent_id === "string") && (c.create_agent === undefined || isRuntimeStartCreateAgentOptions(c.create_agent)) && (c.conversation_id === undefined || typeof c.conversation_id === "string") && (c.create_conversation === undefined || isRuntimeStartCreateConversationOptions(c.create_conversation)) && (c.conversation_source_tags === undefined || isStringArray8(c.conversation_source_tags)) && (c.cwd === undefined || c.cwd === null || typeof c.cwd === "string") && (c.mode === undefined || isDevicePermissionMode(c.mode)) && (c.skill_sources === undefined || isSkillSourceArray(c.skill_sources)) && (c.preserve_skill_sources === undefined || typeof c.preserve_skill_sources === "boolean") && (c.client_info === undefined || isRuntimeStartClientInfo(c.client_info)) && (c.recover_approvals === undefined || typeof c.recover_approvals === "boolean") && (c.force_device_status === undefined || typeof c.force_device_status === "boolean") && (c.wait_for_replay === undefined || typeof c.wait_for_replay === "boolean") && (c.external_tools === undefined || Array.isArray(c.external_tools) && c.external_tools.every(isRuntimeStartExternalToolsGroup));
277244
277353
  }
277245
277354
  function isTerminalSpawnCommand(value) {
277246
277355
  if (!value || typeof value !== "object")
@@ -277494,7 +277603,7 @@ function isCreateAgentCommand(value) {
277494
277603
  if (!value || typeof value !== "object")
277495
277604
  return false;
277496
277605
  const c = value;
277497
- return c.type === "create_agent" && typeof c.request_id === "string" && (c.personality === "memo" || c.personality === "blank" || c.personality === "tutorial" || c.personality === "linus" || c.personality === "kawaii") && (c.model === undefined || typeof c.model === "string") && (c.tags === undefined || isStringArray7(c.tags)) && (c.pin_global === undefined || typeof c.pin_global === "boolean");
277606
+ return c.type === "create_agent" && typeof c.request_id === "string" && (c.personality === "memo" || c.personality === "blank" || c.personality === "tutorial" || c.personality === "linus" || c.personality === "kawaii") && (c.model === undefined || typeof c.model === "string") && (c.tags === undefined || isStringArray8(c.tags)) && (c.pin_global === undefined || typeof c.pin_global === "boolean");
277498
277607
  }
277499
277608
  function isAgentListCommand(value) {
277500
277609
  if (!value || typeof value !== "object")
@@ -278461,7 +278570,7 @@ __export(exports_memory_scanner, {
278461
278570
  readFileContent: () => readFileContent,
278462
278571
  getFileNodes: () => getFileNodes
278463
278572
  });
278464
- import { readdirSync as readdirSync16, readFileSync as readFileSync30, statSync as statSync16 } from "node:fs";
278573
+ import { readdirSync as readdirSync16, readFileSync as readFileSync31, statSync as statSync16 } from "node:fs";
278465
278574
  import { join as join62, relative as relative9 } from "node:path";
278466
278575
  function scanMemoryFilesystem(memoryRoot) {
278467
278576
  const nodes = [];
@@ -278526,7 +278635,7 @@ function getFileNodes(nodes) {
278526
278635
  }
278527
278636
  function readFileContent(fullPath) {
278528
278637
  try {
278529
- return readFileSync30(fullPath, "utf-8");
278638
+ return readFileSync31(fullPath, "utf-8");
278530
278639
  } catch {
278531
278640
  return "(unable to read file)";
278532
278641
  }
@@ -279268,7 +279377,7 @@ __export(exports_remote_model_catalog, {
279268
279377
  __testResetRemoteModelCatalog: () => __testResetRemoteModelCatalog
279269
279378
  });
279270
279379
  import { createHash as createHash8 } from "node:crypto";
279271
- import { existsSync as existsSync44, mkdirSync as mkdirSync31, readFileSync as readFileSync31, writeFileSync as writeFileSync22 } from "node:fs";
279380
+ import { existsSync as existsSync44, mkdirSync as mkdirSync31, readFileSync as readFileSync32, writeFileSync as writeFileSync23 } from "node:fs";
279272
279381
  import { homedir as homedir37 } from "node:os";
279273
279382
  import { dirname as dirname27, join as join63 } from "node:path";
279274
279383
  function cloneCatalogModels(entries) {
@@ -279360,7 +279469,7 @@ function persistCatalogCache(entries, source2) {
279360
279469
  try {
279361
279470
  const path33 = catalogCachePath();
279362
279471
  mkdirSync31(dirname27(path33), { recursive: true });
279363
- writeFileSync22(path33, JSON.stringify({
279472
+ writeFileSync23(path33, JSON.stringify({
279364
279473
  schemaVersion: CACHE_SCHEMA_VERSION,
279365
279474
  source: source2,
279366
279475
  bundledCatalogFingerprint,
@@ -279379,7 +279488,7 @@ function loadPersistedModelCatalog(source2) {
279379
279488
  if (!existsSync44(path33)) {
279380
279489
  return false;
279381
279490
  }
279382
- const parsed = JSON.parse(readFileSync31(path33, "utf-8"));
279491
+ const parsed = JSON.parse(readFileSync32(path33, "utf-8"));
279383
279492
  if (parsed.schemaVersion !== CACHE_SCHEMA_VERSION || parsed.source !== normalizeCatalogSource(source2) || parsed.bundledCatalogFingerprint !== bundledCatalogFingerprint || !Array.isArray(parsed.models)) {
279384
279493
  return false;
279385
279494
  }
@@ -279801,7 +279910,7 @@ var LETTA_MODS_DIR_ENV = "LETTA_MODS_DIR", LEGACY_LETTA_EXTENSIONS_DIR_ENV = "LE
279801
279910
  var init_paths2 = () => {};
279802
279911
 
279803
279912
  // src/mods/mod-diagnostics-file.ts
279804
- import { mkdirSync as mkdirSync32, writeFileSync as writeFileSync23 } from "node:fs";
279913
+ import { mkdirSync as mkdirSync32, writeFileSync as writeFileSync24 } from "node:fs";
279805
279914
  import { homedir as homedir39 } from "node:os";
279806
279915
  import path34 from "node:path";
279807
279916
  function getDefaultModDiagnosticsRoot(homeDirectory = homedir39()) {
@@ -279820,7 +279929,7 @@ function writeModDiagnosticsLatestFile(diagnostics2, options3 = {}) {
279820
279929
  const file3 = createModDiagnosticsFile(diagnostics2, options3.generatedAt);
279821
279930
  const filePath = getModDiagnosticsLatestFilePath(options3.rootDirectory);
279822
279931
  mkdirSync32(path34.dirname(filePath), { recursive: true });
279823
- writeFileSync23(filePath, `${JSON.stringify(file3, null, 2)}
279932
+ writeFileSync24(filePath, `${JSON.stringify(file3, null, 2)}
279824
279933
  `, "utf-8");
279825
279934
  return file3;
279826
279935
  }
@@ -448565,7 +448674,7 @@ var init_file_extensions = __esm(() => {
448565
448674
  });
448566
448675
 
448567
448676
  // src/mods/package-manifest.ts
448568
- import { readFileSync as readFileSync32 } from "node:fs";
448677
+ import { readFileSync as readFileSync33 } from "node:fs";
448569
448678
  import path35 from "node:path";
448570
448679
  function isRecord9(value) {
448571
448680
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -448775,7 +448884,7 @@ function parseLettaPackageManifest(packageJson) {
448775
448884
  }
448776
448885
  function readLettaPackageManifest(packageJsonPath) {
448777
448886
  try {
448778
- const packageJson = JSON.parse(readFileSync32(packageJsonPath, "utf8"));
448887
+ const packageJson = JSON.parse(readFileSync33(packageJsonPath, "utf8"));
448779
448888
  return parseLettaPackageManifest(packageJson);
448780
448889
  } catch (error54) {
448781
448890
  return {
@@ -448807,9 +448916,9 @@ var init_package_manifest = __esm(() => {
448807
448916
  import {
448808
448917
  existsSync as existsSync46,
448809
448918
  mkdirSync as mkdirSync33,
448810
- readFileSync as readFileSync33,
448919
+ readFileSync as readFileSync34,
448811
448920
  rmSync as rmSync10,
448812
- writeFileSync as writeFileSync24
448921
+ writeFileSync as writeFileSync25
448813
448922
  } from "node:fs";
448814
448923
  import path36 from "node:path";
448815
448924
  function isRecord10(value) {
@@ -448863,7 +448972,7 @@ function parseJsonFile(filePath) {
448863
448972
  try {
448864
448973
  return {
448865
448974
  ok: true,
448866
- value: JSON.parse(readFileSync33(filePath, "utf8"))
448975
+ value: JSON.parse(readFileSync34(filePath, "utf8"))
448867
448976
  };
448868
448977
  } catch (error54) {
448869
448978
  return {
@@ -449304,12 +449413,12 @@ function findPackageIndex(modsRoot, packagesValue, specifier) {
449304
449413
  }
449305
449414
  function writePackageRegistry(registryPath, registry2) {
449306
449415
  mkdirSync33(path36.dirname(registryPath), { recursive: true });
449307
- writeFileSync24(registryPath, `${JSON.stringify(registry2, null, 2)}
449416
+ writeFileSync25(registryPath, `${JSON.stringify(registry2, null, 2)}
449308
449417
  `);
449309
449418
  }
449310
449419
  function validateManagedModPackageRegistryForMutation(modsRoot) {
449311
449420
  const registryPath = getRegistryPath(modsRoot);
449312
- const contents = existsSync46(registryPath) ? readFileSync33(registryPath, "utf8") : null;
449421
+ const contents = existsSync46(registryPath) ? readFileSync34(registryPath, "utf8") : null;
449313
449422
  const registry2 = readMutablePackageRegistry(modsRoot, {
449314
449423
  createIfMissing: true
449315
449424
  });
@@ -449562,6 +449671,41 @@ function getTurnStartCancel(event2) {
449562
449671
  }
449563
449672
  var MAX_TURN_START_CANCEL_REASON_LENGTH = 2000;
449564
449673
 
449674
+ // src/mods/turn-start-input.ts
449675
+ function isTurnStartInput(value) {
449676
+ return Array.isArray(value) && value.every((item) => typeof item === "object" && item !== null);
449677
+ }
449678
+ function cloneTurnStartInput(input) {
449679
+ return input.map((item) => structuredClone(item));
449680
+ }
449681
+ function isApprovalInput(item) {
449682
+ return item.type === "approval";
449683
+ }
449684
+ function preserveApprovalFirstOrdering(wasApprovalContinuation, transformedInput) {
449685
+ if (!wasApprovalContinuation)
449686
+ return transformedInput;
449687
+ let sawNonApproval = false;
449688
+ let needsReorder = false;
449689
+ for (const item of transformedInput) {
449690
+ if (isApprovalInput(item)) {
449691
+ if (sawNonApproval) {
449692
+ needsReorder = true;
449693
+ break;
449694
+ }
449695
+ } else {
449696
+ sawNonApproval = true;
449697
+ }
449698
+ }
449699
+ if (!needsReorder)
449700
+ return transformedInput;
449701
+ const approvals = [];
449702
+ const remaining = [];
449703
+ for (const item of transformedInput) {
449704
+ (isApprovalInput(item) ? approvals : remaining).push(item);
449705
+ }
449706
+ return [...approvals, ...remaining];
449707
+ }
449708
+
449565
449709
  // src/mods/ui-helpers.ts
449566
449710
  function createNoopModPanelHandle() {
449567
449711
  return { close() {}, update() {} };
@@ -449573,10 +449717,10 @@ import {
449573
449717
  existsSync as existsSync48,
449574
449718
  mkdirSync as mkdirSync35,
449575
449719
  readdirSync as readdirSync18,
449576
- readFileSync as readFileSync34,
449720
+ readFileSync as readFileSync35,
449577
449721
  statSync as statSync17,
449578
449722
  unlinkSync as unlinkSync9,
449579
- writeFileSync as writeFileSync25
449723
+ writeFileSync as writeFileSync26
449580
449724
  } from "node:fs";
449581
449725
  import { createRequire as createRequire5 } from "node:module";
449582
449726
  import path39 from "node:path";
@@ -449749,7 +449893,7 @@ function prepareModForImport(modPath, source2) {
449749
449893
  }
449750
449894
  function createImportableModPath(modPath, cacheDirectory, source2) {
449751
449895
  const importCacheDirectory = getManagedPackageImportCacheDirectory(modPath, source2) ?? cacheDirectory;
449752
- const sourceText = readFileSync34(modPath, "utf8");
449896
+ const sourceText = readFileSync35(modPath, "utf8");
449753
449897
  const hash4 = createHash9("sha256").update(sourceText).digest("hex").slice(0, 16);
449754
449898
  const fileExtension = path39.extname(modPath);
449755
449899
  const importableSource = prepareModForImport(modPath, sourceText);
@@ -449761,7 +449905,7 @@ function createImportableModPath(modPath, cacheDirectory, source2) {
449761
449905
  const baseName = path39.basename(modPath, fileExtension).replace(/[^a-zA-Z0-9_-]/g, "-");
449762
449906
  const importPath = path39.join(importCacheDirectory, `.letta-mod-${baseName}-${hash4}.mjs`);
449763
449907
  if (!existsSync48(importPath)) {
449764
- writeFileSync25(importPath, importableSource, "utf8");
449908
+ writeFileSync26(importPath, importableSource, "utf8");
449765
449909
  }
449766
449910
  try {
449767
449911
  for (const entry of readdirSync18(importCacheDirectory)) {
@@ -449830,12 +449974,6 @@ function isTurnStartResultWithCancel(name, result) {
449830
449974
  const cancel = result.cancel;
449831
449975
  return typeof cancel === "object" && cancel !== null && normalizeTurnStartCancelReason(cancel.reason) !== null;
449832
449976
  }
449833
- function isTurnStartInput(value) {
449834
- return Array.isArray(value) && value.every((item) => typeof item === "object" && item !== null);
449835
- }
449836
- function cloneTurnStartInput(input) {
449837
- return input.map((item) => structuredClone(item));
449838
- }
449839
449977
  function isToolStartResultWithArgs(name, result) {
449840
449978
  return name === "tool_start" && typeof result === "object" && result !== null && isToolStartArgs2(result.args);
449841
449979
  }
@@ -450410,7 +450548,7 @@ async function loadLocalMods(options3) {
450410
450548
  }
450411
450549
  try {
450412
450550
  const mtimeMs = statSync17(modPath).mtimeMs;
450413
- const sourceText = readFileSync34(modPath, "utf8");
450551
+ const sourceText = readFileSync35(modPath, "utf8");
450414
450552
  recordDeprecatedContextApiSourceDiagnostics(sourceText, (diagnostic) => {
450415
450553
  recordModDiagnostic(registry2, {
450416
450554
  ...diagnostic,
@@ -450458,6 +450596,7 @@ async function emitLocalModEvent(registry2, name, event2, context3, backend3, on
450458
450596
  const diagnostics2 = [];
450459
450597
  const results = [];
450460
450598
  let turnStartCancel;
450599
+ const turnStartHadApproval = name === "turn_start" && event2.input.some((item) => item.type === "approval");
450461
450600
  for (const registration of registrations) {
450462
450601
  const signal = registration.owner ? registry2.ownerAbortControllers[registration.owner.id]?.signal : undefined;
450463
450602
  if (signal?.aborted)
@@ -450532,6 +450671,7 @@ async function emitLocalModEvent(registry2, name, event2, context3, backend3, on
450532
450671
  }
450533
450672
  if (name === "turn_start") {
450534
450673
  const turnStartEventWithCancel = event2;
450674
+ turnStartEventWithCancel.input = preserveApprovalFirstOrdering(turnStartHadApproval, turnStartEventWithCancel.input);
450535
450675
  if (turnStartCancel) {
450536
450676
  turnStartEventWithCancel.cancel = { ...turnStartCancel };
450537
450677
  } else {
@@ -454388,7 +454528,7 @@ import {
454388
454528
  mkdirSync as mkdirSync37,
454389
454529
  readdirSync as readdirSync19,
454390
454530
  unlinkSync as unlinkSync10,
454391
- writeFileSync as writeFileSync26
454531
+ writeFileSync as writeFileSync27
454392
454532
  } from "node:fs";
454393
454533
  import { homedir as homedir40 } from "node:os";
454394
454534
  import { join as join65 } from "node:path";
@@ -454500,7 +454640,7 @@ class ChunkLog {
454500
454640
  try {
454501
454641
  const content = this.buffer.map((entry) => JSON.stringify(entry)).join(`
454502
454642
  `);
454503
- writeFileSync26(this.logPath, `${content}
454643
+ writeFileSync27(this.logPath, `${content}
454504
454644
  `, "utf8");
454505
454645
  } catch (e2) {
454506
454646
  debugWarn("chunkLog", `Failed to write ${this.logPath}: ${e2 instanceof Error ? e2.message : String(e2)}`);
@@ -455424,7 +455564,7 @@ var init_approval_suggestions = __esm(async () => {
455424
455564
  function isRecord12(value) {
455425
455565
  return typeof value === "object" && value !== null && !Array.isArray(value);
455426
455566
  }
455427
- function optionalString4(value) {
455567
+ function optionalString5(value) {
455428
455568
  return typeof value === "string" && value.length > 0 ? value : null;
455429
455569
  }
455430
455570
  function parseCloudRetryMessage(value) {
@@ -455445,11 +455585,11 @@ function parseCloudRetryMessage(value) {
455445
455585
  maxAttempts,
455446
455586
  delayMs,
455447
455587
  provider: value.provider,
455448
- fromTransport: optionalString4(value.from_transport),
455449
- toTransport: optionalString4(value.to_transport),
455450
- errorCode: optionalString4(value.error_code),
455451
- runId: optionalString4(value.run_id),
455452
- stepId: optionalString4(value.step_id)
455588
+ fromTransport: optionalString5(value.from_transport),
455589
+ toTransport: optionalString5(value.to_transport),
455590
+ errorCode: optionalString5(value.error_code),
455591
+ runId: optionalString5(value.run_id),
455592
+ stepId: optionalString5(value.step_id)
455453
455593
  };
455454
455594
  }
455455
455595
  function normalizeCloudRetryWireMessage(value) {
@@ -455866,7 +456006,8 @@ async function resolveRecoveredApprovalResponse(runtime, socket, response, proce
455866
456006
  const workingDirectory = getConversationWorkingDirectory(runtime.listener, recovered.agentId, recovered.conversationId);
455867
456007
  const scope = {
455868
456008
  agent_id: recovered.agentId,
455869
- conversation_id: recovered.conversationId
456009
+ conversation_id: recovered.conversationId,
456010
+ ...opts?.superRunId ? { super_run_id: opts.superRunId } : {}
455870
456011
  };
455871
456012
  const respondedEntry = recovered.approvalsByRequestId.get(requestId);
455872
456013
  let autoDecisionsToAppend = [];
@@ -455919,7 +456060,8 @@ async function resolveRecoveredApprovalResponse(runtime, socket, response, proce
455919
456060
  const recoveryLease = pendingRequestIdsAfterResponse.length === 0 ? runtime.turnLifecycle.begin({
455920
456061
  origin: "approval_recovery",
455921
456062
  workingDirectory,
455922
- initialStatus: "EXECUTING_CLIENT_SIDE_TOOL"
456063
+ initialStatus: "EXECUTING_CLIENT_SIDE_TOOL",
456064
+ superRunId: opts?.superRunId
455923
456065
  }) : null;
455924
456066
  let continuationFinalized = false;
455925
456067
  try {
@@ -456073,7 +456215,9 @@ async function resolveRecoveredApprovalResponse(runtime, socket, response, proce
456073
456215
  }
456074
456216
  ]);
456075
456217
  let continuationBatchId = `batch-recovered-${crypto.randomUUID()}`;
456076
- const consumedQueuedTurn = consumeQueuedTurn(runtime);
456218
+ const consumedQueuedTurn = consumeQueuedTurn(runtime, {
456219
+ matchActiveSuperRun: true
456220
+ });
456077
456221
  if (consumedQueuedTurn) {
456078
456222
  const { dequeuedBatch, queuedTurn } = consumedQueuedTurn;
456079
456223
  continuationBatchId = dequeuedBatch.batchId;
@@ -456087,6 +456231,7 @@ async function resolveRecoveredApprovalResponse(runtime, socket, response, proce
456087
456231
  type: "message",
456088
456232
  agentId: recovered.agentId,
456089
456233
  conversationId: recovered.conversationId,
456234
+ ...opts?.superRunId ? { superRunId: opts.superRunId } : {},
456090
456235
  messages: continuationInput.messages
456091
456236
  }, socket, runtime, opts?.onStatusChange, opts?.connectionId, continuationBatchId, recoveryLease);
456092
456237
  if (runtime.turnLifecycle.isCurrent(recoveryLease)) {
@@ -456112,17 +456257,21 @@ async function resolveRecoveredApprovalResponse(runtime, socket, response, proce
456112
456257
  recovered.responsesByRequestId.clear();
456113
456258
  }
456114
456259
  const stopReason = recoveryLease.signal.aborted ? "cancelled" : "error";
456115
- finishListenerTurn(runtime, recoveryLease, {
456116
- stopReason,
456117
- socket,
456118
- agentId: recovered.agentId,
456119
- conversationId: recovered.conversationId,
456120
- turnId: `batch-recovered-${requestId}`,
456121
- error: stopReason === "error" ? getTranscriptLoopErrorMessage({
456122
- error: error54,
456123
- message: error54 instanceof Error ? error54.message : String(error54)
456124
- }) : undefined
456125
- });
456260
+ try {
456261
+ finishListenerTurn(runtime, recoveryLease, {
456262
+ stopReason,
456263
+ socket,
456264
+ agentId: recovered.agentId,
456265
+ conversationId: recovered.conversationId,
456266
+ turnId: `batch-recovered-${requestId}`,
456267
+ error: stopReason === "error" ? getTranscriptLoopErrorMessage({
456268
+ error: error54,
456269
+ message: error54 instanceof Error ? error54.message : String(error54)
456270
+ }) : undefined
456271
+ });
456272
+ } finally {
456273
+ runtime.turnLifecycle.releaseSuperRunId(recoveryLease);
456274
+ }
456126
456275
  throw error54;
456127
456276
  }
456128
456277
  }
@@ -456469,7 +456618,9 @@ async function resolveStaleApprovals(runtime, socket, turnLease, deps = {}) {
456469
456618
  otid: crypto.randomUUID()
456470
456619
  }
456471
456620
  ]);
456472
- const consumedQueuedTurn = consumeQueuedTurn(runtime);
456621
+ const consumedQueuedTurn = consumeQueuedTurn(runtime, {
456622
+ matchActiveSuperRun: true
456623
+ });
456473
456624
  if (consumedQueuedTurn) {
456474
456625
  const { dequeuedBatch, queuedTurn } = consumedQueuedTurn;
456475
456626
  continuationInput = appendQueuedTurnToInput(continuationInput, queuedTurn);
@@ -459242,7 +459393,9 @@ async function handleApprovalStop(params) {
459242
459393
  }
459243
459394
  ]);
459244
459395
  let continuationBatchId = dequeuedBatchId;
459245
- const consumedQueuedTurn = consumeQueuedTurn(runtime);
459396
+ const consumedQueuedTurn = consumeQueuedTurn(runtime, {
459397
+ matchActiveSuperRun: true
459398
+ });
459246
459399
  if (consumedQueuedTurn) {
459247
459400
  const { dequeuedBatch, queuedTurn } = consumedQueuedTurn;
459248
459401
  continuationBatchId = dequeuedBatch.batchId;
@@ -460857,7 +461010,8 @@ async function handleIncomingMessageInner(msg, socket, runtime, onStatusChange,
460857
461010
  let lastNeedsUserInputToolCallIds = [];
460858
461011
  const turnLease = existingTurnLease ?? runtime.turnLifecycle.begin({
460859
461012
  origin: "message",
460860
- workingDirectory: turnWorkingDirectory
461013
+ workingDirectory: turnWorkingDirectory,
461014
+ superRunId: msg.superRunId
460861
461015
  });
460862
461016
  if (connectionId) {
460863
461017
  runtime.activeConnectionId = connectionId;
@@ -460976,6 +461130,7 @@ async function handleIncomingMessageInner(msg, socket, runtime, onStatusChange,
460976
461130
  } : {},
460977
461131
  ...providerFallback.overrideModel ? { overrideModel: providerFallback.overrideModel } : {},
460978
461132
  ...msg.actingUserId ? { actingUserId: msg.actingUserId } : {},
461133
+ ...msg.superRunId ? { superRunId: msg.superRunId } : {},
460979
461134
  ...pendingNormalizationInterruptedToolCallIds.length > 0 ? {
460980
461135
  approvalNormalization: {
460981
461136
  interruptedToolCallIds: pendingNormalizationInterruptedToolCallIds
@@ -461501,6 +461656,7 @@ async function handleIncomingMessageInner(msg, socket, runtime, onStatusChange,
461501
461656
  }
461502
461657
  } finally {
461503
461658
  releaseListenerTurnContext({ runtime, agentId, conversationId });
461659
+ runtime.turnLifecycle.releaseSuperRunId(turnLease);
461504
461660
  }
461505
461661
  evictConversationRuntimeIfIdle(runtime);
461506
461662
  }
@@ -461627,7 +461783,8 @@ async function handleApprovalResponseInput(listener, params, deps = {
461627
461783
  }
461628
461784
  if (await deps.resolveRecoveredApprovalResponse(targetRuntime, params.socket, params.response, handleIncomingMessage, {
461629
461785
  onStatusChange: params.opts.onStatusChange,
461630
- connectionId: params.opts.connectionId
461786
+ connectionId: params.opts.connectionId,
461787
+ ...params.runtime.super_run_id ? { superRunId: params.runtime.super_run_id } : {}
461631
461788
  })) {
461632
461789
  deps.scheduleQueuePump(targetRuntime, params.socket, params.opts, params.processQueuedTurn);
461633
461790
  return true;
@@ -463998,7 +464155,7 @@ var init_mod_commands = __esm(async () => {
463998
464155
  });
463999
464156
 
464000
464157
  // src/websocket/listener/commands.ts
464001
- import { spawn as spawn10 } from "node:child_process";
464158
+ import { spawn as spawn9 } from "node:child_process";
464002
464159
  async function handleExecuteCommand(command, socket, conversationRuntime, opts) {
464003
464160
  const scope = {
464004
464161
  agent_id: conversationRuntime.agentId,
@@ -464205,7 +464362,7 @@ function scheduleRemoteRestart(connectionName, log2) {
464205
464362
  setTimeout(async () => {
464206
464363
  await flushRemoteSettingsWrites();
464207
464364
  log2(`spawning replacement listener: ${process.execPath} ${entrypoint} remote --env-name ${connectionName}`);
464208
- const child = spawn10(process.execPath, [entrypoint, "remote", "--env-name", connectionName], {
464365
+ const child = spawn9(process.execPath, [entrypoint, "remote", "--env-name", connectionName], {
464209
464366
  cwd: process.cwd(),
464210
464367
  detached: true,
464211
464368
  env: process.env,
@@ -466150,6 +466307,8 @@ function createListenerMessageHandler(params) {
466150
466307
  connectionId,
466151
466308
  agentId: parsed.runtime.agent_id,
466152
466309
  conversationId: parsed.runtime.conversation_id,
466310
+ superRunId: parsed.runtime.super_run_id,
466311
+ noCoalesce: parsed.runtime.super_run_id !== undefined,
466153
466312
  clientToolAllowlist: inputPayload.client_tool_allowlist,
466154
466313
  clientToolset: inputPayload.client_toolset,
466155
466314
  externalToolScopeIds: inputPayload.external_tool_scope_ids,
@@ -468706,7 +468865,7 @@ function createToolLifecycleTracker(onEvent) {
468706
468865
  }
468707
468866
 
468708
468867
  // src/websocket/app-server-openai-turn.ts
468709
- import { randomUUID as randomUUID27 } from "node:crypto";
468868
+ import { randomUUID as randomUUID28 } from "node:crypto";
468710
468869
  function runBridgeTurn(params) {
468711
468870
  return runTurnImpl(params);
468712
468871
  }
@@ -468725,7 +468884,7 @@ async function ensureListenerRuntime(onLog) {
468725
468884
  if (active && !active.intentionallyClosed)
468726
468885
  return active;
468727
468886
  bridgeRuntimeStart ??= startLocalChannelListener({
468728
- connectionId: `openai-api-${randomUUID27()}`,
468887
+ connectionId: `openai-api-${randomUUID28()}`,
468729
468888
  deviceId: settingsManager.getOrCreateDeviceId(),
468730
468889
  connectionName: "openai-api",
468731
468890
  onConnected: () => {},
@@ -468934,11 +469093,11 @@ var init_app_server_openai_turn = __esm(async () => {
468934
469093
  });
468935
469094
 
468936
469095
  // src/websocket/app-server-openai-responses.ts
468937
- import { randomUUID as randomUUID28 } from "node:crypto";
469096
+ import { randomUUID as randomUUID29 } from "node:crypto";
468938
469097
  function createStoredResponseId(state) {
468939
469098
  const cursor = Buffer.from(JSON.stringify({
468940
469099
  version: 1,
468941
- nonce: randomUUID28(),
469100
+ nonce: randomUUID29(),
468942
469101
  agent_id: state.agentId,
468943
469102
  conversation_id: state.conversationId
468944
469103
  })).toString("base64url");
@@ -468983,7 +469142,7 @@ function toBridgeMessages(messages, stateful) {
468983
469142
  return { messages: [], correlationOtid: null };
468984
469143
  }
468985
469144
  if (stateful) {
468986
- const otid = randomUUID28();
469145
+ const otid = randomUUID29();
468987
469146
  return {
468988
469147
  messages: [{ role: "user", content: lastUserContent, otid }],
468989
469148
  correlationOtid: otid
@@ -469005,7 +469164,7 @@ function toBridgeMessages(messages, stateful) {
469005
469164
  bridgeMessages.push({
469006
469165
  role: message.role,
469007
469166
  content,
469008
- otid: randomUUID28()
469167
+ otid: randomUUID29()
469009
469168
  });
469010
469169
  }
469011
469170
  return {
@@ -469137,7 +469296,7 @@ class ResponseOutputBuilder {
469137
469296
  this.finishText();
469138
469297
  const result = {
469139
469298
  type: "function_call_output",
469140
- id: `fco_${randomUUID28()}`,
469299
+ id: `fco_${randomUUID29()}`,
469141
469300
  call_id: event2.tool_call_id,
469142
469301
  output: [{ type: "input_text", text: event2.output }],
469143
469302
  status: event2.success ? "completed" : "incomplete"
@@ -469222,7 +469381,7 @@ class ResponseOutputBuilder {
469222
469381
  return this.message;
469223
469382
  const item = {
469224
469383
  type: "message",
469225
- id: `msg_${randomUUID28()}`,
469384
+ id: `msg_${randomUUID29()}`,
469226
469385
  status: "in_progress",
469227
469386
  role: "assistant",
469228
469387
  content: [{ type: "output_text", text: "", annotations: [] }]
@@ -469249,7 +469408,7 @@ class ResponseOutputBuilder {
469249
469408
  return this.reasoning;
469250
469409
  const item = {
469251
469410
  type: "reasoning",
469252
- id: `rs_${randomUUID28()}`,
469411
+ id: `rs_${randomUUID29()}`,
469253
469412
  status: "in_progress",
469254
469413
  summary: [{ type: "summary_text", text: "" }]
469255
469414
  };
@@ -469280,7 +469439,7 @@ class ResponseOutputBuilder {
469280
469439
  }
469281
469440
  const item = {
469282
469441
  type: "function_call",
469283
- id: `fc_${randomUUID28()}`,
469442
+ id: `fc_${randomUUID29()}`,
469284
469443
  call_id: callId,
469285
469444
  name,
469286
469445
  arguments: "",
@@ -469385,7 +469544,7 @@ async function handleResponses(request, response, options3) {
469385
469544
  sendOpenAiError(response, 500, "failed to create a conversation for this response", "server_error");
469386
469545
  return;
469387
469546
  }
469388
- const responseId = body3.store === true ? createStoredResponseId({ agentId: agent2.id, conversationId }) : `resp_${randomUUID28()}`;
469547
+ const responseId = body3.store === true ? createStoredResponseId({ agentId: agent2.id, conversationId }) : `resp_${randomUUID29()}`;
469389
469548
  const createdAt = Math.floor(Date.now() / 1000);
469390
469549
  let sequenceNumber = 0;
469391
469550
  let clientClosed = false;
@@ -469475,7 +469634,7 @@ var init_app_server_openai_responses = __esm(async () => {
469475
469634
  });
469476
469635
 
469477
469636
  // src/websocket/app-server-openai.ts
469478
- import { randomUUID as randomUUID29 } from "node:crypto";
469637
+ import { randomUUID as randomUUID30 } from "node:crypto";
469479
469638
  function isOpenAiCompatPath(pathname) {
469480
469639
  return pathname === MODELS_PATH || pathname === CHAT_COMPLETIONS_PATH || pathname === RESPONSES_PATH;
469481
469640
  }
@@ -469544,7 +469703,7 @@ async function handleChatCompletions(request, response, options3) {
469544
469703
  turnMessages.push({
469545
469704
  role: "user",
469546
469705
  content: userContent,
469547
- otid: randomUUID29()
469706
+ otid: randomUUID30()
469548
469707
  });
469549
469708
  } else {
469550
469709
  for (const message of body3.messages) {
@@ -469561,7 +469720,7 @@ async function handleChatCompletions(request, response, options3) {
469561
469720
  }
469562
469721
  if (content.length === 0)
469563
469722
  continue;
469564
- turnMessages.push({ role: message.role, content, otid: randomUUID29() });
469723
+ turnMessages.push({ role: message.role, content, otid: randomUUID30() });
469565
469724
  }
469566
469725
  }
469567
469726
  correlationOtid = turnMessages.at(-1)?.otid ?? null;
@@ -469570,7 +469729,7 @@ async function handleChatCompletions(request, response, options3) {
469570
469729
  return;
469571
469730
  }
469572
469731
  }
469573
- const completionId = `chatcmpl-${randomUUID29()}`;
469732
+ const completionId = `chatcmpl-${randomUUID30()}`;
469574
469733
  const created = Math.floor(Date.now() / 1000);
469575
469734
  const streaming3 = body3.stream === true;
469576
469735
  let clientClosed = false;
@@ -470037,7 +470196,7 @@ __export(exports_gateway_supervisor, {
470037
470196
  startChannelGatewaySupervisor: () => startChannelGatewaySupervisor,
470038
470197
  CHANNEL_GATEWAY_READY_SIGNAL: () => CHANNEL_GATEWAY_READY_SIGNAL
470039
470198
  });
470040
- import { spawn as spawn11 } from "node:child_process";
470199
+ import { spawn as spawn10 } from "node:child_process";
470041
470200
  function resolveLauncher(cwd2) {
470042
470201
  const invocation = resolveLettaInvocation(process.env, process.argv, process.execPath, cwd2);
470043
470202
  if (invocation)
@@ -470082,7 +470241,7 @@ async function startChannelGatewaySupervisor(options3) {
470082
470241
  const launch = () => {
470083
470242
  if (stopping)
470084
470243
  return;
470085
- child = (options3.spawnProcess ?? spawn11)(launcher.command, childArgs, {
470244
+ child = (options3.spawnProcess ?? spawn10)(launcher.command, childArgs, {
470086
470245
  cwd: cwd2,
470087
470246
  env: options3.env ?? process.env,
470088
470247
  stdio: ["pipe", "pipe", "pipe"],
@@ -470852,20 +471011,20 @@ var init_listen = __esm(async () => {
470852
471011
  });
470853
471012
 
470854
471013
  // src/backend/local/transcript-migration.ts
470855
- import { randomUUID as randomUUID30 } from "node:crypto";
471014
+ import { randomUUID as randomUUID31 } from "node:crypto";
470856
471015
  import {
470857
471016
  copyFileSync as copyFileSync3,
470858
471017
  existsSync as existsSync52,
470859
471018
  mkdirSync as mkdirSync38,
470860
471019
  readdirSync as readdirSync20,
470861
- readFileSync as readFileSync35,
470862
- writeFileSync as writeFileSync27
471020
+ readFileSync as readFileSync36,
471021
+ writeFileSync as writeFileSync28
470863
471022
  } from "node:fs";
470864
471023
  import { join as join68 } from "node:path";
470865
471024
  function readJsonl(path44) {
470866
471025
  if (!existsSync52(path44))
470867
471026
  return [];
470868
- return readFileSync35(path44, "utf8").split(`
471027
+ return readFileSync36(path44, "utf8").split(`
470869
471028
  `).filter((line) => line.trim().length > 0).map((line) => JSON.parse(line));
470870
471029
  }
470871
471030
  function isLegacyUiMessage(value) {
@@ -470875,7 +471034,7 @@ function isPiLocalMessage(value) {
470875
471034
  return isRecord(value) && typeof value.id === "string" && (value.role === "user" || value.role === "assistant" || value.role === "toolResult") && Object.hasOwn(value, "content");
470876
471035
  }
470877
471036
  function writeJsonl(path44, items3) {
470878
- writeFileSync27(path44, `${items3.map((item) => JSON.stringify(item)).join(`
471037
+ writeFileSync28(path44, `${items3.map((item) => JSON.stringify(item)).join(`
470879
471038
  `)}
470880
471039
  `);
470881
471040
  }
@@ -470892,7 +471051,7 @@ function writeSessionEntryJsonl(path44, messages, input) {
470892
471051
  ...messages.map((message) => {
470893
471052
  const entry = {
470894
471053
  type: "message",
470895
- id: randomUUID30().slice(0, 8),
471054
+ id: randomUUID31().slice(0, 8),
470896
471055
  parentId,
470897
471056
  timestamp: message.metadata?.created_at ?? new Date(message.timestamp).toISOString(),
470898
471057
  message
@@ -471160,7 +471319,7 @@ function migrateLocalBackendTranscripts(input) {
471160
471319
  const hasManifest = existsSync52(manifestPath);
471161
471320
  const existingManifest = hasManifest ? (() => {
471162
471321
  try {
471163
- return JSON.parse(readFileSync35(manifestPath, "utf8"));
471322
+ return JSON.parse(readFileSync36(manifestPath, "utf8"));
471164
471323
  } catch {
471165
471324
  return;
471166
471325
  }
@@ -471176,7 +471335,7 @@ function migrateLocalBackendTranscripts(input) {
471176
471335
  result.skipped.push({ conversationDir, reason: "empty" });
471177
471336
  if (!input.dryRun) {
471178
471337
  mkdirSync38(conversationDir, { recursive: true });
471179
- writeFileSync27(manifestPath, `${JSON.stringify(manifest({}), null, 2)}
471338
+ writeFileSync28(manifestPath, `${JSON.stringify(manifest({}), null, 2)}
471180
471339
  `);
471181
471340
  }
471182
471341
  continue;
@@ -471203,7 +471362,7 @@ function migrateLocalBackendTranscripts(input) {
471203
471362
  let conversation;
471204
471363
  if (existsSync52(conversationPath)) {
471205
471364
  try {
471206
- conversation = JSON.parse(readFileSync35(conversationPath, "utf8"));
471365
+ conversation = JSON.parse(readFileSync36(conversationPath, "utf8"));
471207
471366
  } catch {
471208
471367
  conversation = undefined;
471209
471368
  }
@@ -471229,12 +471388,12 @@ function migrateLocalBackendTranscripts(input) {
471229
471388
  }
471230
471389
  }
471231
471390
  conversation.in_context_message_ids = remapped;
471232
- writeFileSync27(conversationPath, `${JSON.stringify(conversation, null, 2)}
471391
+ writeFileSync28(conversationPath, `${JSON.stringify(conversation, null, 2)}
471233
471392
  `);
471234
471393
  }
471235
471394
  } catch {}
471236
471395
  }
471237
- writeFileSync27(manifestPath, `${JSON.stringify(manifest({
471396
+ writeFileSync28(manifestPath, `${JSON.stringify(manifest({
471238
471397
  backupPath,
471239
471398
  migratedFrom: repairVersioned ? hasLegacyUiRows ? "versioned-pi-transcript-with-legacy-ui-message-rows" : "versioned-pi-ai-message-jsonl" : undefined
471240
471399
  }), null, 2)}
@@ -471665,13 +471824,13 @@ var init_memory7 = __esm(() => {
471665
471824
  });
471666
471825
 
471667
471826
  // src/backend/local/transcript-search.ts
471668
- import { existsSync as existsSync54, readdirSync as readdirSync21, readFileSync as readFileSync36, statSync as statSync19 } from "node:fs";
471827
+ import { existsSync as existsSync54, readdirSync as readdirSync21, readFileSync as readFileSync37, statSync as statSync19 } from "node:fs";
471669
471828
  import { join as join70 } from "node:path";
471670
471829
  function readJsonFile3(path44) {
471671
471830
  if (!existsSync54(path44))
471672
471831
  return;
471673
471832
  try {
471674
- return JSON.parse(readFileSync36(path44, "utf8"));
471833
+ return JSON.parse(readFileSync37(path44, "utf8"));
471675
471834
  } catch {
471676
471835
  return;
471677
471836
  }
@@ -471680,7 +471839,7 @@ function readJsonlFile2(path44) {
471680
471839
  if (!existsSync54(path44))
471681
471840
  return [];
471682
471841
  try {
471683
- return readFileSync36(path44, "utf8").split(`
471842
+ return readFileSync37(path44, "utf8").split(`
471684
471843
  `).filter((line) => line.trim().length > 0).map((line) => JSON.parse(line));
471685
471844
  } catch {
471686
471845
  return [];
@@ -472377,7 +472536,7 @@ var init_messages10 = __esm(() => {
472377
472536
  });
472378
472537
 
472379
472538
  // src/mods/package-installer.ts
472380
- import { spawn as spawn12 } from "node:child_process";
472539
+ import { spawn as spawn11 } from "node:child_process";
472381
472540
  import {
472382
472541
  copyFileSync as copyFileSync4,
472383
472542
  existsSync as existsSync55,
@@ -472385,10 +472544,10 @@ import {
472385
472544
  mkdirSync as mkdirSync40,
472386
472545
  mkdtempSync as mkdtempSync3,
472387
472546
  readdirSync as readdirSync22,
472388
- readFileSync as readFileSync37,
472547
+ readFileSync as readFileSync38,
472389
472548
  renameSync as renameSync7,
472390
472549
  rmSync as rmSync12,
472391
- writeFileSync as writeFileSync28
472550
+ writeFileSync as writeFileSync29
472392
472551
  } from "node:fs";
472393
472552
  import { tmpdir as tmpdir9 } from "node:os";
472394
472553
  import path44 from "node:path";
@@ -472404,7 +472563,7 @@ function isPathInsideOrEqual2(childPath, parentPath) {
472404
472563
  function readPackageJson(packageJsonPath) {
472405
472564
  let parsed;
472406
472565
  try {
472407
- parsed = JSON.parse(readFileSync37(packageJsonPath, "utf8"));
472566
+ parsed = JSON.parse(readFileSync38(packageJsonPath, "utf8"));
472408
472567
  } catch (error54) {
472409
472568
  throw new Error(`Could not read package.json: ${error54 instanceof Error ? error54.message : String(error54)}`);
472410
472569
  }
@@ -472612,7 +472771,7 @@ function restoreRegistry(registryPath, previousContents) {
472612
472771
  return;
472613
472772
  }
472614
472773
  mkdirSync40(path44.dirname(registryPath), { recursive: true });
472615
- writeFileSync28(registryPath, previousContents);
472774
+ writeFileSync29(registryPath, previousContents);
472616
472775
  }
472617
472776
  function removeIfExists(targetPath) {
472618
472777
  if (!targetPath)
@@ -472733,7 +472892,7 @@ function getNpmInstallArgs(installSpec) {
472733
472892
  ];
472734
472893
  }
472735
472894
  function writeNpmInstallManifest(tempRoot) {
472736
- writeFileSync28(path44.join(tempRoot, "package.json"), `${JSON.stringify({
472895
+ writeFileSync29(path44.join(tempRoot, "package.json"), `${JSON.stringify({
472737
472896
  private: true,
472738
472897
  name: "letta-managed-mod-install"
472739
472898
  }, null, 2)}
@@ -473007,7 +473166,7 @@ function getPackageVersionForGitPackage(params) {
473007
473166
  }
473008
473167
  function writeCompatibilityPackageManifest(params) {
473009
473168
  const packageJsonPath = path44.join(params.packageDirectory, "package.json");
473010
- writeFileSync28(packageJsonPath, `${JSON.stringify({
473169
+ writeFileSync29(packageJsonPath, `${JSON.stringify({
473011
473170
  ...params.packageJson ?? {},
473012
473171
  name: params.packageName,
473013
473172
  version: params.version,
@@ -473235,7 +473394,7 @@ var init_package_installer = __esm(() => {
473235
473394
  init_package_registry();
473236
473395
  init_package_manager_spawn();
473237
473396
  SKIPPED_PACKAGE_COPY_NAMES = new Set([".git", "node_modules"]);
473238
- spawnGitInstallProcess = spawn12;
473397
+ spawnGitInstallProcess = spawn11;
473239
473398
  });
473240
473399
 
473241
473400
  // src/mods/package-scaffolder.ts
@@ -473245,7 +473404,7 @@ import {
473245
473404
  lstatSync as lstatSync4,
473246
473405
  mkdirSync as mkdirSync41,
473247
473406
  rmSync as rmSync13,
473248
- writeFileSync as writeFileSync29
473407
+ writeFileSync as writeFileSync30
473249
473408
  } from "node:fs";
473250
473409
  import path45 from "node:path";
473251
473410
  function assertValidPackageName(packageName) {
@@ -473348,10 +473507,10 @@ function scaffoldLocalModPackage(options3) {
473348
473507
  try {
473349
473508
  mkdirSync41(targetModsDirectory, { recursive: true });
473350
473509
  copyFileSync5(sourceFile, targetModPath);
473351
- writeFileSync29(packageJsonPath, `${JSON.stringify(createPackageJson(packageName, manifestEntry), null, 2)}
473510
+ writeFileSync30(packageJsonPath, `${JSON.stringify(createPackageJson(packageName, manifestEntry), null, 2)}
473352
473511
  `);
473353
- writeFileSync29(readmePath, createReadme(packageName));
473354
- writeFileSync29(modGuidePath, createModGuide(packageName, manifestEntry));
473512
+ writeFileSync30(readmePath, createReadme(packageName));
473513
+ writeFileSync30(modGuidePath, createModGuide(packageName, manifestEntry));
473355
473514
  } catch (error54) {
473356
473515
  rmSync13(outputDirectory, { force: true, recursive: true });
473357
473516
  throw error54;
@@ -476086,10 +476245,10 @@ import {
476086
476245
  cpSync as cpSync2,
476087
476246
  existsSync as existsSync58,
476088
476247
  mkdtempSync as mkdtempSync4,
476089
- readFileSync as readFileSync38,
476248
+ readFileSync as readFileSync39,
476090
476249
  rmSync as rmSync14,
476091
476250
  statSync as statSync20,
476092
- writeFileSync as writeFileSync30
476251
+ writeFileSync as writeFileSync31
476093
476252
  } from "node:fs";
476094
476253
  import { mkdir as mkdir15, readdir as readdir14 } from "node:fs/promises";
476095
476254
  import { tmpdir as tmpdir10 } from "node:os";
@@ -476451,7 +476610,7 @@ async function downloadDirectSkillFileSource(location, options3 = {}) {
476451
476610
  try {
476452
476611
  const sourceDir = join73(tmpDir, "skill");
476453
476612
  await mkdir15(sourceDir, { recursive: true });
476454
- writeFileSync30(join73(sourceDir, "SKILL.md"), skillText, "utf8");
476613
+ writeFileSync31(join73(sourceDir, "SKILL.md"), skillText, "utf8");
476455
476614
  return { tmpDir, sourceDir };
476456
476615
  } catch (error54) {
476457
476616
  rmSync14(tmpDir, { recursive: true, force: true });
@@ -476503,7 +476662,7 @@ async function downloadClawHubSkillSource(location) {
476503
476662
  if (!response.ok) {
476504
476663
  throw new Error(`ClawHub download failed for ${location.slug}@${version2}: ${response.status}`);
476505
476664
  }
476506
- writeFileSync30(zipPath, Buffer.from(await response.arrayBuffer()));
476665
+ writeFileSync31(zipPath, Buffer.from(await response.arrayBuffer()));
476507
476666
  const { stdout } = await execFile16("unzip", ["-Z1", zipPath], {
476508
476667
  timeout: 30000
476509
476668
  });
@@ -476533,7 +476692,7 @@ function sanitizeSkillName(name) {
476533
476692
  return trimmed;
476534
476693
  }
476535
476694
  function getSkillName(sourceDir) {
476536
- const skillMd = readFileSync38(join73(sourceDir, "SKILL.md"), "utf8");
476695
+ const skillMd = readFileSync39(join73(sourceDir, "SKILL.md"), "utf8");
476537
476696
  const { frontmatter } = parseFrontmatter(skillMd);
476538
476697
  const frontmatterName = frontmatter.name;
476539
476698
  const name = typeof frontmatterName === "string" && frontmatterName.trim() ? frontmatterName : basename28(sourceDir);
@@ -476583,7 +476742,7 @@ async function listSkillDirectories(params) {
476583
476742
  let name = entry.name;
476584
476743
  let description;
476585
476744
  try {
476586
- const skillMd = readFileSync38(skillMdPath, "utf8");
476745
+ const skillMd = readFileSync39(skillMdPath, "utf8");
476587
476746
  const { frontmatter } = parseFrontmatter(skillMd);
476588
476747
  if (typeof frontmatter.name === "string" && frontmatter.name.trim()) {
476589
476748
  name = frontmatter.name.trim();
@@ -480625,7 +480784,7 @@ var init_message_channel_gateway_tool = __esm(() => {
480625
480784
  });
480626
480785
 
480627
480786
  // src/channels/custom/scaffolding.ts
480628
- import { existsSync as existsSync59, mkdirSync as mkdirSync42, rmSync as rmSync15, writeFileSync as writeFileSync31 } from "node:fs";
480787
+ import { existsSync as existsSync59, mkdirSync as mkdirSync42, rmSync as rmSync15, writeFileSync as writeFileSync32 } from "node:fs";
480629
480788
  function removeUserPlugin(channelId) {
480630
480789
  if (FIRST_PARTY_SET.has(channelId)) {
480631
480790
  return;
@@ -482576,7 +482735,7 @@ var exports_bootstrap_tools = {};
482576
482735
  __export(exports_bootstrap_tools, {
482577
482736
  bootstrapBaseToolsIfNeeded: () => bootstrapBaseToolsIfNeeded
482578
482737
  });
482579
- import { existsSync as existsSync60, mkdirSync as mkdirSync43, writeFileSync as writeFileSync32 } from "node:fs";
482738
+ import { existsSync as existsSync60, mkdirSync as mkdirSync43, writeFileSync as writeFileSync33 } from "node:fs";
482580
482739
  import { homedir as homedir42 } from "node:os";
482581
482740
  import { join as join77 } from "node:path";
482582
482741
  async function bootstrapBaseToolsIfNeeded() {
@@ -482587,7 +482746,7 @@ async function bootstrapBaseToolsIfNeeded() {
482587
482746
  const success2 = await addBaseToolsToServer();
482588
482747
  if (success2) {
482589
482748
  mkdirSync43(join77(homedir42(), ".letta"), { recursive: true });
482590
- writeFileSync32(MARKER_PATH, new Date().toISOString(), "utf-8");
482749
+ writeFileSync33(MARKER_PATH, new Date().toISOString(), "utf-8");
482591
482750
  }
482592
482751
  } catch (err) {
482593
482752
  debugWarn("bootstrap", `Failed to bootstrap base tools: ${err instanceof Error ? err.message : String(err)}`);
@@ -482638,7 +482797,7 @@ function resolveListMessagesRoute(listReq, sessionConvId, sessionAgentId) {
482638
482797
  }
482639
482798
 
482640
482799
  // src/agent/bootstrap-handler.ts
482641
- import { randomUUID as randomUUID31 } from "node:crypto";
482800
+ import { randomUUID as randomUUID32 } from "node:crypto";
482642
482801
  async function handleBootstrapSessionState(params) {
482643
482802
  const {
482644
482803
  bootstrapReq,
@@ -482687,7 +482846,7 @@ async function handleBootstrapSessionState(params) {
482687
482846
  response: payload
482688
482847
  },
482689
482848
  session_id: sessionContext.sessionId,
482690
- uuid: randomUUID31()
482849
+ uuid: randomUUID32()
482691
482850
  };
482692
482851
  } catch (err) {
482693
482852
  return {
@@ -482698,14 +482857,14 @@ async function handleBootstrapSessionState(params) {
482698
482857
  error: err instanceof Error ? err.message : "bootstrap_session_state failed"
482699
482858
  },
482700
482859
  session_id: sessionContext.sessionId,
482701
- uuid: randomUUID31()
482860
+ uuid: randomUUID32()
482702
482861
  };
482703
482862
  }
482704
482863
  }
482705
482864
  var init_bootstrap_handler = () => {};
482706
482865
 
482707
482866
  // src/agent/list-messages-handler.ts
482708
- import { randomUUID as randomUUID32 } from "node:crypto";
482867
+ import { randomUUID as randomUUID33 } from "node:crypto";
482709
482868
  async function handleListMessages(params) {
482710
482869
  const {
482711
482870
  listReq,
@@ -482745,7 +482904,7 @@ async function handleListMessages(params) {
482745
482904
  response: payload
482746
482905
  },
482747
482906
  session_id: sessionId,
482748
- uuid: randomUUID32()
482907
+ uuid: randomUUID33()
482749
482908
  };
482750
482909
  } catch (err) {
482751
482910
  return {
@@ -482756,7 +482915,7 @@ async function handleListMessages(params) {
482756
482915
  error: err instanceof Error ? err.message : "list_messages failed"
482757
482916
  },
482758
482917
  session_id: sessionId,
482759
- uuid: randomUUID32()
482918
+ uuid: randomUUID33()
482760
482919
  };
482761
482920
  }
482762
482921
  }
@@ -494380,7 +494539,7 @@ var init_mcp_client = __esm(() => {
494380
494539
  init_streamableHttp();
494381
494540
  DEFAULT_CLIENT_INFO = {
494382
494541
  name: "letta-code",
494383
- version: "0.30.14"
494542
+ version: "0.30.16"
494384
494543
  };
494385
494544
  });
494386
494545
 
@@ -494802,7 +494961,7 @@ var init_mcp_runtime = __esm(async () => {
494802
494961
  });
494803
494962
 
494804
494963
  // src/skills/builtin/creating-skills/scripts/validate-skill.ts
494805
- import { existsSync as existsSync61, readFileSync as readFileSync39 } from "node:fs";
494964
+ import { existsSync as existsSync61, readFileSync as readFileSync40 } from "node:fs";
494806
494965
  import { basename as basename30, join as join79, resolve as resolve34 } from "node:path";
494807
494966
  import { fileURLToPath as fileURLToPath11 } from "node:url";
494808
494967
  function parseQuotedScalar(value) {
@@ -494904,7 +495063,7 @@ function validateSkill(skillPath) {
494904
495063
  if (!existsSync61(skillMdPath)) {
494905
495064
  return { valid: false, message: "SKILL.md not found" };
494906
495065
  }
494907
- const content = readFileSync39(skillMdPath, "utf-8");
495066
+ const content = readFileSync40(skillMdPath, "utf-8");
494908
495067
  if (!content.startsWith("---")) {
494909
495068
  return { valid: false, message: "No YAML frontmatter found" };
494910
495069
  }
@@ -495419,7 +495578,7 @@ __export(exports_headless, {
495419
495578
  decideInterruptAction: () => decideInterruptAction,
495420
495579
  __headlessTestUtils: () => __headlessTestUtils
495421
495580
  });
495422
- import { randomUUID as randomUUID33 } from "node:crypto";
495581
+ import { randomUUID as randomUUID34 } from "node:crypto";
495423
495582
  function trackHeadlessBoundaryError(errorType, error54, context3) {
495424
495583
  trackBoundaryError({
495425
495584
  errorType,
@@ -495441,7 +495600,7 @@ async function reportStartupErrorAndExit(errorType, error54, context3, outputFor
495441
495600
  message,
495442
495601
  stop_reason: "error",
495443
495602
  session_id: "startup",
495444
- uuid: `startup-error-${randomUUID33()}`
495603
+ uuid: `startup-error-${randomUUID34()}`
495445
495604
  };
495446
495605
  await writeWireMessageAsync(errorMsg);
495447
495606
  } else {
@@ -495565,7 +495724,7 @@ async function emitHeadlessTurnStartCancellationOutput(options3) {
495565
495724
  message: options3.reason,
495566
495725
  stop_reason: "cancelled",
495567
495726
  session_id: options3.sessionId,
495568
- uuid: `error-turn-start-cancel-${randomUUID33()}`
495727
+ uuid: `error-turn-start-cancel-${randomUUID34()}`
495569
495728
  };
495570
495729
  await writeWireMessageAsync(errorMsg);
495571
495730
  const resultMsg = {
@@ -495580,7 +495739,7 @@ async function emitHeadlessTurnStartCancellationOutput(options3) {
495580
495739
  conversation_id: options3.conversationId,
495581
495740
  run_ids: [],
495582
495741
  usage: null,
495583
- uuid: `result-turn-start-cancel-${randomUUID33()}`,
495742
+ uuid: `result-turn-start-cancel-${randomUUID34()}`,
495584
495743
  stop_reason: "cancelled"
495585
495744
  };
495586
495745
  await writeWireMessageAsync(resultMsg);
@@ -495609,7 +495768,7 @@ function writeBidirectionalTurnStartCancellation(options3) {
495609
495768
  message: options3.reason,
495610
495769
  stop_reason: "cancelled",
495611
495770
  session_id: options3.sessionId,
495612
- uuid: `error-turn-start-cancel-${randomUUID33()}`
495771
+ uuid: `error-turn-start-cancel-${randomUUID34()}`
495613
495772
  };
495614
495773
  writeWireMessage(errorMsg);
495615
495774
  const resultMsg = {
@@ -495624,7 +495783,7 @@ function writeBidirectionalTurnStartCancellation(options3) {
495624
495783
  conversation_id: options3.conversationId,
495625
495784
  run_ids: [],
495626
495785
  usage: null,
495627
- uuid: `result-turn-start-cancel-${randomUUID33()}`,
495786
+ uuid: `result-turn-start-cancel-${randomUUID34()}`,
495628
495787
  stop_reason: "cancelled"
495629
495788
  };
495630
495789
  writeWireMessage(resultMsg);
@@ -496574,7 +496733,7 @@ Current session AGENT_ID=${process.env.AGENT_ID}; --backend local switches to a
496574
496733
  const approvalInput = {
496575
496734
  type: "approval",
496576
496735
  approvals: denialResults,
496577
- otid: randomUUID33()
496736
+ otid: randomUUID34()
496578
496737
  };
496579
496738
  const approvalMessages = [approvalInput];
496580
496739
  {
@@ -496587,7 +496746,7 @@ Current session AGENT_ID=${process.env.AGENT_ID}; --backend local switches to a
496587
496746
  type: "text",
496588
496747
  text: sc.content
496589
496748
  })),
496590
- otid: randomUUID33()
496749
+ otid: randomUUID34()
496591
496750
  });
496592
496751
  }
496593
496752
  }
@@ -496620,7 +496779,7 @@ Current session AGENT_ID=${process.env.AGENT_ID}; --backend local switches to a
496620
496779
  message: `Failed to resolve pending approvals on resume: ${approvalError instanceof Error ? approvalError.message : String(approvalError)}`,
496621
496780
  stop_reason: "error",
496622
496781
  session_id: sessionId,
496623
- uuid: `error-pre-loop-approval-${randomUUID33()}`
496782
+ uuid: `error-pre-loop-approval-${randomUUID34()}`
496624
496783
  };
496625
496784
  writeWireMessage(errorMsg);
496626
496785
  } else {
@@ -496768,8 +496927,8 @@ ${loadedContents.join(`
496768
496927
  {
496769
496928
  role: "user",
496770
496929
  content: contentParts,
496771
- client_message_id: randomUUID33(),
496772
- otid: randomUUID33()
496930
+ client_message_id: randomUUID34(),
496931
+ otid: randomUUID34()
496773
496932
  }
496774
496933
  ]
496775
496934
  });
@@ -496826,7 +496985,7 @@ ${loadedContents.join(`
496826
496985
  {
496827
496986
  role: "user",
496828
496987
  content: contentParts,
496829
- otid: randomUUID33()
496988
+ otid: randomUUID34()
496830
496989
  }
496831
496990
  ];
496832
496991
  const recoveredApprovalResults = queuedRecoveredApprovalResults ?? [];
@@ -496835,7 +496994,7 @@ ${loadedContents.join(`
496835
496994
  {
496836
496995
  type: "approval",
496837
496996
  approvals: recoveredApprovalResults,
496838
- otid: randomUUID33()
496997
+ otid: randomUUID34()
496839
496998
  },
496840
496999
  ...currentInput
496841
497000
  ];
@@ -496882,7 +497041,7 @@ ${loadedContents.join(`
496882
497041
  message: `Maximum turns limit reached (${buffers.usage.stepCount}/${maxTurns} steps)`,
496883
497042
  stop_reason: "max_steps",
496884
497043
  session_id: sessionId,
496885
- uuid: `error-max-turns-${randomUUID33()}`
497044
+ uuid: `error-max-turns-${randomUUID34()}`
496886
497045
  };
496887
497046
  await writeWireMessageAsync(errorMsg);
496888
497047
  } else {
@@ -496899,7 +497058,7 @@ ${loadedContents.join(`
496899
497058
  message: "Interrupted by SIGINT",
496900
497059
  stop_reason: "cancelled",
496901
497060
  session_id: sessionId,
496902
- uuid: `error-interrupted-${randomUUID33()}`
497061
+ uuid: `error-interrupted-${randomUUID34()}`
496903
497062
  };
496904
497063
  await writeWireMessageAsync(errorMsg);
496905
497064
  } else {
@@ -496928,7 +497087,7 @@ ${loadedContents.join(`
496928
497087
  type: "text",
496929
497088
  text: sc.content
496930
497089
  })),
496931
- otid: randomUUID33()
497090
+ otid: randomUUID34()
496932
497091
  }
496933
497092
  ];
496934
497093
  }
@@ -496974,7 +497133,7 @@ ${loadedContents.join(`
496974
497133
  recovery_type: "approval_pending",
496975
497134
  message: "Detected pending approval conflict on send; resolving before retry",
496976
497135
  session_id: sessionId,
496977
- uuid: `recovery-pre-stream-${randomUUID33()}`
497136
+ uuid: `recovery-pre-stream-${randomUUID34()}`
496978
497137
  };
496979
497138
  writeWireMessage(recoveryMsg);
496980
497139
  } else {
@@ -497007,7 +497166,7 @@ ${loadedContents.join(`
497007
497166
  max_attempts: CONVERSATION_BUSY_MAX_RETRIES,
497008
497167
  delay_ms: retryDelayMs,
497009
497168
  session_id: sessionId,
497010
- uuid: `retry-conversation-busy-${randomUUID33()}`
497169
+ uuid: `retry-conversation-busy-${randomUUID34()}`
497011
497170
  };
497012
497171
  writeWireMessage(retryMsg);
497013
497172
  } else {
@@ -497031,7 +497190,7 @@ ${loadedContents.join(`
497031
497190
  type: "status",
497032
497191
  message: "Anthropic API error; falling back to Bedrock...",
497033
497192
  session_id: sessionId,
497034
- uuid: `fallback-${randomUUID33()}`
497193
+ uuid: `fallback-${randomUUID34()}`
497035
497194
  }));
497036
497195
  } else {
497037
497196
  console.error("Anthropic API error; falling back to Bedrock...");
@@ -497055,7 +497214,7 @@ ${loadedContents.join(`
497055
497214
  max_attempts: LLM_API_ERROR_MAX_RETRIES2,
497056
497215
  delay_ms: delayMs,
497057
497216
  session_id: sessionId,
497058
- uuid: `retry-pre-stream-${randomUUID33()}`
497217
+ uuid: `retry-pre-stream-${randomUUID34()}`
497059
497218
  };
497060
497219
  writeWireMessage(retryMsg);
497061
497220
  } else {
@@ -497081,7 +497240,7 @@ ${loadedContents.join(`
497081
497240
  stop_reason: "error",
497082
497241
  run_id: errorInfo.run_id,
497083
497242
  session_id: sessionId,
497084
- uuid: randomUUID33(),
497243
+ uuid: randomUUID34(),
497085
497244
  ...errorInfo.error_type && errorInfo.run_id && {
497086
497245
  api_error: {
497087
497246
  message_type: "error_message",
@@ -497103,7 +497262,7 @@ ${loadedContents.join(`
497103
497262
  message: "Detected pending approval conflict; auto-denying stale approval and retrying",
497104
497263
  run_id: recoveryRunId ?? undefined,
497105
497264
  session_id: sessionId,
497106
- uuid: `recovery-${recoveryRunId || randomUUID33()}`
497265
+ uuid: `recovery-${recoveryRunId || randomUUID34()}`
497107
497266
  };
497108
497267
  writeWireMessage(recoveryMsg);
497109
497268
  approvalPendingRecovery = true;
@@ -497121,7 +497280,7 @@ ${loadedContents.join(`
497121
497280
  type: "stream_event",
497122
497281
  event: chunk,
497123
497282
  session_id: sessionId,
497124
- uuid: uuid5 || randomUUID33()
497283
+ uuid: uuid5 || randomUUID34()
497125
497284
  };
497126
497285
  writeWireMessage(streamEvent);
497127
497286
  } else {
@@ -497129,7 +497288,7 @@ ${loadedContents.join(`
497129
497288
  type: "message",
497130
497289
  ...chunk,
497131
497290
  session_id: sessionId,
497132
- uuid: uuid5 || randomUUID33()
497291
+ uuid: uuid5 || randomUUID34()
497133
497292
  };
497134
497293
  writeWireMessage(msg);
497135
497294
  }
@@ -497172,7 +497331,7 @@ ${loadedContents.join(`
497172
497331
  {
497173
497332
  role: "user",
497174
497333
  content: continueMessage,
497175
- otid: randomUUID33()
497334
+ otid: randomUUID34()
497176
497335
  }
497177
497336
  ];
497178
497337
  const continueTurnStartEmission = await emitHeadlessTurnStart({
@@ -497244,7 +497403,7 @@ ${loadedContents.join(`
497244
497403
  const approvalInputWithOtid = {
497245
497404
  type: "approval",
497246
497405
  approvals: executedResults,
497247
- otid: randomUUID33()
497406
+ otid: randomUUID34()
497248
497407
  };
497249
497408
  currentInput = [approvalInputWithOtid];
497250
497409
  continue;
@@ -497274,7 +497433,7 @@ ${loadedContents.join(`
497274
497433
  type: "status",
497275
497434
  message: "Anthropic API error; falling back to Bedrock...",
497276
497435
  session_id: sessionId,
497277
- uuid: `fallback-${randomUUID33()}`
497436
+ uuid: `fallback-${randomUUID34()}`
497278
497437
  }));
497279
497438
  } else {
497280
497439
  console.error("Anthropic API error; falling back to Bedrock...");
@@ -497297,7 +497456,7 @@ ${loadedContents.join(`
497297
497456
  delay_ms: delayMs,
497298
497457
  run_id: lastRunId ?? undefined,
497299
497458
  session_id: sessionId,
497300
- uuid: `retry-${lastRunId || randomUUID33()}`
497459
+ uuid: `retry-${lastRunId || randomUUID34()}`
497301
497460
  };
497302
497461
  writeWireMessage(retryMsg);
497303
497462
  } else {
@@ -497318,7 +497477,7 @@ ${loadedContents.join(`
497318
497477
  message: "Tool call ID mismatch; fetching actual pending approvals and resyncing",
497319
497478
  run_id: lastRunId ?? undefined,
497320
497479
  session_id: sessionId,
497321
- uuid: `recovery-${lastRunId || randomUUID33()}`
497480
+ uuid: `recovery-${lastRunId || randomUUID34()}`
497322
497481
  };
497323
497482
  writeWireMessage(recoveryMsg);
497324
497483
  } else {
@@ -497335,7 +497494,7 @@ ${loadedContents.join(`
497335
497494
  stop_reason: stopReason,
497336
497495
  run_id: lastRunId ?? undefined,
497337
497496
  session_id: sessionId,
497338
- uuid: `error-${lastRunId || randomUUID33()}`
497497
+ uuid: `error-${lastRunId || randomUUID34()}`
497339
497498
  };
497340
497499
  await writeWireMessageAsync(errorMsg);
497341
497500
  } else {
@@ -497377,7 +497536,7 @@ ${loadedContents.join(`
497377
497536
  const nudgeMessage = {
497378
497537
  role: "system",
497379
497538
  content: `<system-reminder>The previous response was empty. Please provide a response with either text content or a tool call.</system-reminder>`,
497380
- otid: randomUUID33()
497539
+ otid: randomUUID34()
497381
497540
  };
497382
497541
  currentInput = [...currentInput, nudgeMessage];
497383
497542
  }
@@ -497390,7 +497549,7 @@ ${loadedContents.join(`
497390
497549
  delay_ms: delayMs,
497391
497550
  run_id: lastRunId ?? undefined,
497392
497551
  session_id: sessionId,
497393
- uuid: `retry-empty-${lastRunId || randomUUID33()}`
497552
+ uuid: `retry-empty-${lastRunId || randomUUID34()}`
497394
497553
  };
497395
497554
  writeWireMessage(retryMsg);
497396
497555
  } else {
@@ -497417,7 +497576,7 @@ ${loadedContents.join(`
497417
497576
  delay_ms: delayMs,
497418
497577
  run_id: lastRunId ?? undefined,
497419
497578
  session_id: sessionId,
497420
- uuid: `retry-${lastRunId || randomUUID33()}`
497579
+ uuid: `retry-${lastRunId || randomUUID34()}`
497421
497580
  };
497422
497581
  writeWireMessage(retryMsg);
497423
497582
  } else {
@@ -497447,7 +497606,7 @@ ${loadedContents.join(`
497447
497606
  delay_ms: delayMs,
497448
497607
  run_id: lastRunId ?? undefined,
497449
497608
  session_id: sessionId,
497450
- uuid: `retry-${lastRunId || randomUUID33()}`
497609
+ uuid: `retry-${lastRunId || randomUUID34()}`
497451
497610
  };
497452
497611
  writeWireMessage(retryMsg);
497453
497612
  } else {
@@ -497496,7 +497655,7 @@ ${loadedContents.join(`
497496
497655
  stop_reason: stopReason,
497497
497656
  run_id: lastRunId ?? undefined,
497498
497657
  session_id: sessionId,
497499
- uuid: `error-${lastRunId || randomUUID33()}`
497658
+ uuid: `error-${lastRunId || randomUUID34()}`
497500
497659
  };
497501
497660
  await writeWireMessageAsync(errorMsg);
497502
497661
  } else {
@@ -497515,7 +497674,7 @@ ${loadedContents.join(`
497515
497674
  stop_reason: "error",
497516
497675
  run_id: lastKnownRunId ?? undefined,
497517
497676
  session_id: sessionId,
497518
- uuid: `error-${lastKnownRunId || randomUUID33()}`
497677
+ uuid: `error-${lastKnownRunId || randomUUID34()}`
497519
497678
  };
497520
497679
  await writeWireMessageAsync(errorMsg);
497521
497680
  } else {
@@ -497712,7 +497871,7 @@ async function runBidirectionalMode(agent2, conversationId, _outputFormat, inclu
497712
497871
  const approvalInput = {
497713
497872
  type: "approval",
497714
497873
  approvals: denialResults,
497715
- otid: randomUUID33()
497874
+ otid: randomUUID34()
497716
497875
  };
497717
497876
  const approvalMessages = [approvalInput];
497718
497877
  {
@@ -497725,7 +497884,7 @@ async function runBidirectionalMode(agent2, conversationId, _outputFormat, inclu
497725
497884
  type: "text",
497726
497885
  text: sc.content
497727
497886
  })),
497728
- otid: randomUUID33()
497887
+ otid: randomUUID34()
497729
497888
  });
497730
497889
  }
497731
497890
  }
@@ -497783,7 +497942,7 @@ async function runBidirectionalMode(agent2, conversationId, _outputFormat, inclu
497783
497942
  reason,
497784
497943
  cleared_count: clearedCount,
497785
497944
  session_id: sessionId,
497786
- uuid: `q-clr-${randomUUID33()}`
497945
+ uuid: `q-clr-${randomUUID34()}`
497787
497946
  })
497788
497947
  }
497789
497948
  });
@@ -497813,7 +497972,7 @@ async function runBidirectionalMode(agent2, conversationId, _outputFormat, inclu
497813
497972
  reason: "runtime_busy",
497814
497973
  queue_len: Math.max(1, queueLen),
497815
497974
  session_id: sessionId,
497816
- uuid: `q-blk-${randomUUID33()}`
497975
+ uuid: `q-blk-${randomUUID34()}`
497817
497976
  });
497818
497977
  }
497819
497978
  function enqueueForTracking(input) {
@@ -497885,7 +498044,7 @@ async function runBidirectionalMode(agent2, conversationId, _outputFormat, inclu
497885
498044
  request_id: interruptRequestId
497886
498045
  },
497887
498046
  session_id: sessionId,
497888
- uuid: randomUUID33()
498047
+ uuid: randomUUID34()
497889
498048
  };
497890
498049
  writeWireMessage(interruptResponse);
497891
498050
  return;
@@ -498022,7 +498181,7 @@ async function runBidirectionalMode(agent2, conversationId, _outputFormat, inclu
498022
498181
  const approvalInput = {
498023
498182
  type: "approval",
498024
498183
  approvals: denialResults,
498025
- otid: randomUUID33()
498184
+ otid: randomUUID34()
498026
498185
  };
498027
498186
  const approvalStream = await sendScopedApprovalMessages({
498028
498187
  agentId: agent2.id,
@@ -498061,7 +498220,7 @@ async function runBidirectionalMode(agent2, conversationId, _outputFormat, inclu
498061
498220
  message: "Invalid JSON input",
498062
498221
  stop_reason: "error",
498063
498222
  session_id: sessionId,
498064
- uuid: randomUUID33()
498223
+ uuid: randomUUID34()
498065
498224
  };
498066
498225
  writeWireMessage(errorMsg2);
498067
498226
  continue;
@@ -498087,7 +498246,7 @@ async function runBidirectionalMode(agent2, conversationId, _outputFormat, inclu
498087
498246
  }
498088
498247
  },
498089
498248
  session_id: sessionId,
498090
- uuid: randomUUID33()
498249
+ uuid: randomUUID34()
498091
498250
  };
498092
498251
  writeWireMessage(initResponse);
498093
498252
  } else if (subtype === "interrupt") {
@@ -498104,7 +498263,7 @@ async function runBidirectionalMode(agent2, conversationId, _outputFormat, inclu
498104
498263
  request_id: requestId ?? ""
498105
498264
  },
498106
498265
  session_id: sessionId,
498107
- uuid: randomUUID33()
498266
+ uuid: randomUUID34()
498108
498267
  };
498109
498268
  writeWireMessage(interruptResponse);
498110
498269
  } else if (subtype === "register_external_tools") {
@@ -498152,7 +498311,7 @@ async function runBidirectionalMode(agent2, conversationId, _outputFormat, inclu
498152
498311
  response: { registered: tools.length }
498153
498312
  },
498154
498313
  session_id: sessionId,
498155
- uuid: randomUUID33()
498314
+ uuid: randomUUID34()
498156
498315
  };
498157
498316
  writeWireMessage(registerResponse);
498158
498317
  } else if (subtype === "bootstrap_session_state") {
@@ -498208,7 +498367,7 @@ async function runBidirectionalMode(agent2, conversationId, _outputFormat, inclu
498208
498367
  response: recovery
498209
498368
  },
498210
498369
  session_id: sessionId,
498211
- uuid: randomUUID33()
498370
+ uuid: randomUUID34()
498212
498371
  };
498213
498372
  writeWireMessage(recoveryResponse);
498214
498373
  } catch (error54) {
@@ -498220,7 +498379,7 @@ async function runBidirectionalMode(agent2, conversationId, _outputFormat, inclu
498220
498379
  error: error54 instanceof Error ? error54.message : String(error54)
498221
498380
  },
498222
498381
  session_id: sessionId,
498223
- uuid: randomUUID33()
498382
+ uuid: randomUUID34()
498224
498383
  };
498225
498384
  writeWireMessage(recoveryError);
498226
498385
  }
@@ -498233,7 +498392,7 @@ async function runBidirectionalMode(agent2, conversationId, _outputFormat, inclu
498233
498392
  error: `Unknown control request subtype: ${subtype}`
498234
498393
  },
498235
498394
  session_id: sessionId,
498236
- uuid: randomUUID33()
498395
+ uuid: randomUUID34()
498237
498396
  };
498238
498397
  writeWireMessage(errorResponse);
498239
498398
  }
@@ -498288,7 +498447,7 @@ async function runBidirectionalMode(agent2, conversationId, _outputFormat, inclu
498288
498447
  try {
498289
498448
  const buffers = createBuffers(agent2.id);
498290
498449
  const startTime = performance.now();
498291
- const userOtid = randomUUID33();
498450
+ const userOtid = randomUUID34();
498292
498451
  const userTranscriptText = extractTelemetryInputText(userContent);
498293
498452
  if (userTranscriptText.length > 0) {
498294
498453
  const userLineId = `user-${userOtid}`;
@@ -498409,7 +498568,7 @@ async function runBidirectionalMode(agent2, conversationId, _outputFormat, inclu
498409
498568
  recovery_type: "approval_pending",
498410
498569
  message: "Detected pending approval conflict on send; resolving before retry",
498411
498570
  session_id: sessionId,
498412
- uuid: `recovery-bidir-${randomUUID33()}`
498571
+ uuid: `recovery-bidir-${randomUUID34()}`
498413
498572
  };
498414
498573
  writeWireMessage(recoveryMsg);
498415
498574
  await resolveAllPendingApprovals();
@@ -498432,7 +498591,7 @@ async function runBidirectionalMode(agent2, conversationId, _outputFormat, inclu
498432
498591
  max_attempts: LLM_API_ERROR_MAX_RETRIES2,
498433
498592
  delay_ms: delayMs,
498434
498593
  session_id: sessionId,
498435
- uuid: `retry-bidir-${randomUUID33()}`
498594
+ uuid: `retry-bidir-${randomUUID34()}`
498436
498595
  };
498437
498596
  writeWireMessage(retryMsg);
498438
498597
  await new Promise((resolve36) => setTimeout(resolve36, delayMs));
@@ -498454,7 +498613,7 @@ async function runBidirectionalMode(agent2, conversationId, _outputFormat, inclu
498454
498613
  stop_reason: "error",
498455
498614
  run_id: errorInfo.run_id,
498456
498615
  session_id: sessionId,
498457
- uuid: randomUUID33(),
498616
+ uuid: randomUUID34(),
498458
498617
  ...errorInfo.error_type && errorInfo.run_id && {
498459
498618
  api_error: {
498460
498619
  message_type: "error_message",
@@ -498482,7 +498641,7 @@ async function runBidirectionalMode(agent2, conversationId, _outputFormat, inclu
498482
498641
  type: "stream_event",
498483
498642
  event: chunk,
498484
498643
  session_id: sessionId,
498485
- uuid: uuid5 || randomUUID33()
498644
+ uuid: uuid5 || randomUUID34()
498486
498645
  };
498487
498646
  writeWireMessage(streamEvent);
498488
498647
  } else {
@@ -498490,7 +498649,7 @@ async function runBidirectionalMode(agent2, conversationId, _outputFormat, inclu
498490
498649
  type: "message",
498491
498650
  ...chunk,
498492
498651
  session_id: sessionId,
498493
- uuid: uuid5 || randomUUID33()
498652
+ uuid: uuid5 || randomUUID34()
498494
498653
  };
498495
498654
  writeWireMessage(msg);
498496
498655
  }
@@ -498556,7 +498715,7 @@ async function runBidirectionalMode(agent2, conversationId, _outputFormat, inclu
498556
498715
  const approvalInputWithOtid = {
498557
498716
  type: "approval",
498558
498717
  approvals: executedResults,
498559
- otid: randomUUID33()
498718
+ otid: randomUUID34()
498560
498719
  };
498561
498720
  currentInput = [approvalInputWithOtid];
498562
498721
  continue;
@@ -498619,7 +498778,7 @@ async function runBidirectionalMode(agent2, conversationId, _outputFormat, inclu
498619
498778
  message: errorDetails,
498620
498779
  stop_reason: "error",
498621
498780
  session_id: sessionId,
498622
- uuid: randomUUID33()
498781
+ uuid: randomUUID34()
498623
498782
  };
498624
498783
  writeWireMessage(errorMsg2);
498625
498784
  const errorResultMsg = {
@@ -498662,7 +498821,7 @@ async function runBidirectionalMode(agent2, conversationId, _outputFormat, inclu
498662
498821
  message: `Unknown message type: ${message.type}`,
498663
498822
  stop_reason: "error",
498664
498823
  session_id: sessionId,
498665
- uuid: randomUUID33()
498824
+ uuid: randomUUID34()
498666
498825
  };
498667
498826
  writeWireMessage(errorMsg);
498668
498827
  }
@@ -500151,7 +500310,7 @@ var init_reflection_arena_hf_upload = __esm(() => {
500151
500310
 
500152
500311
  // src/cli/helpers/reflection-arena.ts
500153
500312
  import { execFile as execFileCb6 } from "node:child_process";
500154
- import { randomInt as randomInt2, randomUUID as randomUUID34 } from "node:crypto";
500313
+ import { randomInt as randomInt2, randomUUID as randomUUID35 } from "node:crypto";
500155
500314
  import { appendFile as appendFile3, mkdir as mkdir19, readFile as readFile30, writeFile as writeFile21 } from "node:fs/promises";
500156
500315
  import { homedir as homedir46 } from "node:os";
500157
500316
  import { join as join82 } from "node:path";
@@ -500525,7 +500684,7 @@ async function startReflectionArenaRun(options3) {
500525
500684
  }
500526
500685
  let releaseReservation = true;
500527
500686
  try {
500528
- const runId = randomUUID34().slice(0, 8);
500687
+ const runId = randomUUID35().slice(0, 8);
500529
500688
  const labels = shuffledLabels();
500530
500689
  const prepared = await Promise.all([
500531
500690
  prepareReflectionMemoryWorktreeLaunch({
@@ -501326,8 +501485,8 @@ import {
501326
501485
  copyFileSync as copyFileSync6,
501327
501486
  existsSync as existsSync64,
501328
501487
  mkdirSync as mkdirSync45,
501329
- readFileSync as readFileSync41,
501330
- writeFileSync as writeFileSync34
501488
+ readFileSync as readFileSync42,
501489
+ writeFileSync as writeFileSync35
501331
501490
  } from "node:fs";
501332
501491
  import { homedir as homedir47, platform as platform10 } from "node:os";
501333
501492
  import { dirname as dirname35, join as join83 } from "node:path";
@@ -501396,7 +501555,7 @@ function keybindingExists(keybindingsPath) {
501396
501555
  if (!existsSync64(keybindingsPath))
501397
501556
  return false;
501398
501557
  try {
501399
- const content = readFileSync41(keybindingsPath, { encoding: "utf-8" });
501558
+ const content = readFileSync42(keybindingsPath, { encoding: "utf-8" });
501400
501559
  const keybindings = parseKeybindings(content);
501401
501560
  if (!keybindings)
501402
501561
  return false;
@@ -501429,7 +501588,7 @@ function installKeybinding(keybindingsPath) {
501429
501588
  let backupPath = null;
501430
501589
  if (existsSync64(keybindingsPath)) {
501431
501590
  backupPath = createBackup(keybindingsPath);
501432
- const content = readFileSync41(keybindingsPath, { encoding: "utf-8" });
501591
+ const content = readFileSync42(keybindingsPath, { encoding: "utf-8" });
501433
501592
  const parsed = parseKeybindings(content);
501434
501593
  if (parsed === null) {
501435
501594
  return {
@@ -501442,7 +501601,7 @@ function installKeybinding(keybindingsPath) {
501442
501601
  keybindings.push(SHIFT_ENTER_KEYBINDING);
501443
501602
  const newContent = `${JSON.stringify(keybindings, null, 2)}
501444
501603
  `;
501445
- writeFileSync34(keybindingsPath, newContent, { encoding: "utf-8" });
501604
+ writeFileSync35(keybindingsPath, newContent, { encoding: "utf-8" });
501446
501605
  return {
501447
501606
  success: true,
501448
501607
  backupPath: backupPath ?? undefined
@@ -501460,7 +501619,7 @@ function removeKeybinding(keybindingsPath) {
501460
501619
  if (!existsSync64(keybindingsPath)) {
501461
501620
  return { success: true };
501462
501621
  }
501463
- const content = readFileSync41(keybindingsPath, { encoding: "utf-8" });
501622
+ const content = readFileSync42(keybindingsPath, { encoding: "utf-8" });
501464
501623
  const keybindings = parseKeybindings(content);
501465
501624
  if (!keybindings) {
501466
501625
  return {
@@ -501471,7 +501630,7 @@ function removeKeybinding(keybindingsPath) {
501471
501630
  const filtered = keybindings.filter((kb) => !(kb.key?.toLowerCase() === "shift+enter" && kb.command === "workbench.action.terminal.sendSequence" && kb.when?.includes("terminalFocus")));
501472
501631
  const newContent = `${JSON.stringify(filtered, null, 2)}
501473
501632
  `;
501474
- writeFileSync34(keybindingsPath, newContent, { encoding: "utf-8" });
501633
+ writeFileSync35(keybindingsPath, newContent, { encoding: "utf-8" });
501475
501634
  return { success: true };
501476
501635
  } catch (error54) {
501477
501636
  const message = error54 instanceof Error ? error54.message : String(error54);
@@ -501637,7 +501796,7 @@ function wezTermDeleteFixExists(configPath) {
501637
501796
  if (!existsSync64(configPath))
501638
501797
  return false;
501639
501798
  try {
501640
- const content = readFileSync41(configPath, { encoding: "utf-8" });
501799
+ const content = readFileSync42(configPath, { encoding: "utf-8" });
501641
501800
  return content.includes("Letta Code: Fix Delete key") || content.includes("key = 'Delete'") && content.includes("SendString") && content.includes("\\x1b[3~");
501642
501801
  } catch {
501643
501802
  return false;
@@ -501654,14 +501813,14 @@ function installWezTermDeleteFix() {
501654
501813
  if (existsSync64(configPath)) {
501655
501814
  backupPath = `${configPath}.letta-backup`;
501656
501815
  copyFileSync6(configPath, backupPath);
501657
- content = readFileSync41(configPath, { encoding: "utf-8" });
501816
+ content = readFileSync42(configPath, { encoding: "utf-8" });
501658
501817
  }
501659
501818
  content = injectWezTermDeleteFix(content);
501660
501819
  const parentDir = dirname35(configPath);
501661
501820
  if (!existsSync64(parentDir)) {
501662
501821
  mkdirSync45(parentDir, { recursive: true });
501663
501822
  }
501664
- writeFileSync34(configPath, content, { encoding: "utf-8" });
501823
+ writeFileSync35(configPath, content, { encoding: "utf-8" });
501665
501824
  return {
501666
501825
  success: true,
501667
501826
  backupPath: backupPath ?? undefined
@@ -513165,9 +513324,9 @@ import {
513165
513324
  existsSync as existsSync65,
513166
513325
  mkdirSync as mkdirSync46,
513167
513326
  mkdtempSync as mkdtempSync5,
513168
- readFileSync as readFileSync42,
513327
+ readFileSync as readFileSync43,
513169
513328
  rmSync as rmSync16,
513170
- writeFileSync as writeFileSync35
513329
+ writeFileSync as writeFileSync36
513171
513330
  } from "node:fs";
513172
513331
  import { tmpdir as tmpdir11 } from "node:os";
513173
513332
  import { dirname as dirname36, join as join85 } from "node:path";
@@ -513410,12 +513569,12 @@ function writeWorkflow(repoDir, workflowPath, content) {
513410
513569
  const next = `${content.trimEnd()}
513411
513570
  `;
513412
513571
  if (existsSync65(absolutePath)) {
513413
- const previous = readFileSync42(absolutePath, "utf8");
513572
+ const previous = readFileSync43(absolutePath, "utf8");
513414
513573
  if (previous === next) {
513415
513574
  return false;
513416
513575
  }
513417
513576
  }
513418
- writeFileSync35(absolutePath, next, "utf8");
513577
+ writeFileSync36(absolutePath, next, "utf8");
513419
513578
  return true;
513420
513579
  }
513421
513580
  function getDefaultBaseBranch(repoDir) {
@@ -517299,7 +517458,7 @@ __export(exports_generate_memory_viewer, {
517299
517458
  generateAndOpenMemoryViewer: () => generateAndOpenMemoryViewer
517300
517459
  });
517301
517460
  import { execFile as execFileCb7 } from "node:child_process";
517302
- import { chmodSync as chmodSync7, existsSync as existsSync66, mkdirSync as mkdirSync47, writeFileSync as writeFileSync36 } from "node:fs";
517461
+ import { chmodSync as chmodSync7, existsSync as existsSync66, mkdirSync as mkdirSync47, writeFileSync as writeFileSync37 } from "node:fs";
517303
517462
  import { homedir as homedir50 } from "node:os";
517304
517463
  import { join as join86 } from "node:path";
517305
517464
  import { promisify as promisify17 } from "node:util";
@@ -517627,7 +517786,7 @@ async function generateAndOpenMemoryViewer(agentId, options3) {
517627
517786
  chmodSync7(VIEWERS_DIR, 448);
517628
517787
  } catch {}
517629
517788
  const filePath = join86(VIEWERS_DIR, `memory-${encodeURIComponent(agentId)}.html`);
517630
- writeFileSync36(filePath, html5);
517789
+ writeFileSync37(filePath, html5);
517631
517790
  chmodSync7(filePath, 384);
517632
517791
  const skipOpen = Boolean(process.env.TMUX) || Boolean(process.env.SSH_CONNECTION) || Boolean(process.env.SSH_TTY);
517633
517792
  if (!skipOpen) {
@@ -525720,12 +525879,12 @@ var init_ExitStats = __esm(async () => {
525720
525879
  });
525721
525880
 
525722
525881
  // src/cli/app/ids.ts
525723
- import { randomUUID as randomUUID35 } from "node:crypto";
525882
+ import { randomUUID as randomUUID36 } from "node:crypto";
525724
525883
  function uid(prefix) {
525725
525884
  return `${prefix}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
525726
525885
  }
525727
525886
  function createClientOtid() {
525728
- return randomUUID35();
525887
+ return randomUUID36();
525729
525888
  }
525730
525889
  function appendOptimisticUserLine(buffers, text2, otid) {
525731
525890
  if (!text2) {
@@ -541178,7 +541337,7 @@ __export(exports_generate_diff_viewer, {
541178
541337
  generateAndOpenDiffViewer: () => generateAndOpenDiffViewer
541179
541338
  });
541180
541339
  import { execFile as execFileCb8 } from "node:child_process";
541181
- import { chmodSync as chmodSync8, existsSync as existsSync68, mkdirSync as mkdirSync48, writeFileSync as writeFileSync37 } from "node:fs";
541340
+ import { chmodSync as chmodSync8, existsSync as existsSync68, mkdirSync as mkdirSync48, writeFileSync as writeFileSync38 } from "node:fs";
541182
541341
  import { homedir as homedir52 } from "node:os";
541183
541342
  import { isAbsolute as isAbsolute29, join as join89, resolve as resolve38 } from "node:path";
541184
541343
  import { promisify as promisify18 } from "node:util";
@@ -541406,7 +541565,7 @@ async function generateAndOpenDiffViewer(targetPath) {
541406
541565
  chmodSync8(VIEWERS_DIR2, 448);
541407
541566
  } catch {}
541408
541567
  const filePath = join89(VIEWERS_DIR2, `diff-${encodeURIComponent(worktreePath)}.html`);
541409
- writeFileSync37(filePath, html5);
541568
+ writeFileSync38(filePath, html5);
541410
541569
  chmodSync8(filePath, 384);
541411
541570
  const skipOpen = shouldSkipOpen();
541412
541571
  if (!skipOpen) {
@@ -542749,7 +542908,7 @@ var init_notifications = __esm(() => {
542749
542908
  });
542750
542909
 
542751
542910
  // src/cli/app/use-approval-flow.ts
542752
- import { randomUUID as randomUUID36 } from "node:crypto";
542911
+ import { randomUUID as randomUUID37 } from "node:crypto";
542753
542912
  function useApprovalFlow(ctx) {
542754
542913
  const {
542755
542914
  abortControllerRef,
@@ -543261,7 +543420,7 @@ function useApprovalFlow(ctx) {
543261
543420
  {
543262
543421
  type: "approval",
543263
543422
  approvals: allResults,
543264
- otid: randomUUID36()
543423
+ otid: randomUUID37()
543265
543424
  }
543266
543425
  ]);
543267
543426
  } catch (error54) {
@@ -543464,7 +543623,7 @@ __export(exports_shell_aliases, {
543464
543623
  expandAliases: () => expandAliases,
543465
543624
  clearAliasCache: () => clearAliasCache
543466
543625
  });
543467
- import { existsSync as existsSync69, readFileSync as readFileSync43 } from "node:fs";
543626
+ import { existsSync as existsSync69, readFileSync as readFileSync44 } from "node:fs";
543468
543627
  import { homedir as homedir53 } from "node:os";
543469
543628
  import { join as join90 } from "node:path";
543470
543629
  function parseAliasesFromFile(filePath) {
@@ -543473,7 +543632,7 @@ function parseAliasesFromFile(filePath) {
543473
543632
  return aliases;
543474
543633
  }
543475
543634
  try {
543476
- const content = readFileSync43(filePath, "utf-8");
543635
+ const content = readFileSync44(filePath, "utf-8");
543477
543636
  const lines = content.split(`
543478
543637
  `);
543479
543638
  let inFunction = false;
@@ -544660,7 +544819,7 @@ var init_system_reminders = __esm(() => {
544660
544819
  });
544661
544820
 
544662
544821
  // src/cli/app/use-conversation-loop.ts
544663
- import { randomUUID as randomUUID37 } from "node:crypto";
544822
+ import { randomUUID as randomUUID38 } from "node:crypto";
544664
544823
  function sleep10(ms) {
544665
544824
  return new Promise((resolve39) => setTimeout(resolve39, ms));
544666
544825
  }
@@ -544964,16 +545123,16 @@ function useConversationLoop(ctx) {
544964
545123
  currentInput = [
544965
545124
  ...lastSentInputRef.current.map((m4) => ({
544966
545125
  ...m4,
544967
- otid: randomUUID37()
545126
+ otid: randomUUID38()
544968
545127
  })),
544969
545128
  ...currentInput.map((m4) => m4.type === "message" && m4.role === "user" ? {
544970
545129
  ...m4,
544971
- otid: randomUUID37(),
545130
+ otid: randomUUID38(),
544972
545131
  content: [
544973
545132
  { type: "text", text: INTERRUPT_RECOVERY_ALERT },
544974
545133
  ...typeof m4.content === "string" ? [{ type: "text", text: m4.content }] : Array.isArray(m4.content) ? m4.content : []
544975
545134
  ]
544976
- } : { ...m4, otid: randomUUID37() })
545135
+ } : { ...m4, otid: randomUUID38() })
544977
545136
  ];
544978
545137
  pendingInterruptRecoveryConversationIdRef.current = null;
544979
545138
  lastSentInputRef.current = [
@@ -545012,7 +545171,7 @@ function useConversationLoop(ctx) {
545012
545171
  type: "text",
545013
545172
  text: sc.content
545014
545173
  })),
545015
- otid: randomUUID37()
545174
+ otid: randomUUID38()
545016
545175
  }
545017
545176
  ];
545018
545177
  }
@@ -545392,7 +545551,7 @@ ${feedback}
545392
545551
  });
545393
545552
  buffersRef.current.order.push(statusId);
545394
545553
  refreshDerived();
545395
- const hookMessageOtid = randomUUID37();
545554
+ const hookMessageOtid = randomUUID38();
545396
545555
  setTimeout(() => {
545397
545556
  processConversation([
545398
545557
  {
@@ -545419,7 +545578,7 @@ ${feedback}
545419
545578
  turnEndContinue = undefined;
545420
545579
  }
545421
545580
  if (turnEndContinue) {
545422
- const continueOtid = randomUUID37();
545581
+ const continueOtid = randomUUID38();
545423
545582
  setTimeout(() => {
545424
545583
  processConversation([
545425
545584
  {
@@ -545773,7 +545932,7 @@ ${feedback}
545773
545932
  {
545774
545933
  type: "approval",
545775
545934
  approvals: allResults,
545776
- otid: randomUUID37()
545935
+ otid: randomUUID38()
545777
545936
  }
545778
545937
  ], {
545779
545938
  allowReentry: true,
@@ -545957,7 +546116,7 @@ ${feedback}
545957
546116
  type: "message",
545958
546117
  role: "system",
545959
546118
  content: `<system-reminder>The previous response was empty. Please provide a response with either text content or a tool call.</system-reminder>`,
545960
- otid: randomUUID37()
546119
+ otid: randomUUID38()
545961
546120
  }
545962
546121
  ];
545963
546122
  }
@@ -546251,7 +546410,7 @@ var init_use_conversation_loop = __esm(async () => {
546251
546410
  });
546252
546411
 
546253
546412
  // src/cli/app/use-conversation-switching.ts
546254
- import { randomUUID as randomUUID38 } from "node:crypto";
546413
+ import { randomUUID as randomUUID39 } from "node:crypto";
546255
546414
  function useConversationSwitching(ctx) {
546256
546415
  const {
546257
546416
  abortControllerRef,
@@ -546326,7 +546485,7 @@ function useConversationSwitching(ctx) {
546326
546485
  {
546327
546486
  role: "user",
546328
546487
  content: question,
546329
- otid: randomUUID38()
546488
+ otid: randomUUID39()
546330
546489
  }
546331
546490
  ];
546332
546491
  let approvalRecoveryRetries = 0;
@@ -547766,7 +547925,7 @@ The deployment target for this project is CITATION-DOGFOOD-OK.
547766
547925
  });
547767
547926
 
547768
547927
  // src/mods/learning-harness.ts
547769
- import { spawn as spawn14 } from "node:child_process";
547928
+ import { spawn as spawn13 } from "node:child_process";
547770
547929
  import { access as access3, copyFile as copyFile2, mkdir as mkdir20, readFile as readFile32, writeFile as writeFile22 } from "node:fs/promises";
547771
547930
  import path47 from "node:path";
547772
547931
  function slugify2(value) {
@@ -548706,7 +548865,7 @@ async function writeHistoryArtifacts(params) {
548706
548865
  async function defaultCommandRunner(command, args, options3) {
548707
548866
  const startedAt = Date.now();
548708
548867
  return new Promise((resolve39) => {
548709
- const child = spawn14(command, args, {
548868
+ const child = spawn13(command, args, {
548710
548869
  cwd: options3.cwd,
548711
548870
  env: options3.env,
548712
548871
  stdio: ["ignore", "pipe", "pipe"]
@@ -551842,8 +552001,8 @@ var init_conversation_switch_alert = __esm(() => {
551842
552001
  });
551843
552002
 
551844
552003
  // src/cli/app/use-submit-handler.ts
551845
- import { randomUUID as randomUUID39 } from "node:crypto";
551846
- import { existsSync as existsSync70, readFileSync as readFileSync44, renameSync as renameSync8, writeFileSync as writeFileSync38 } from "node:fs";
552004
+ import { randomUUID as randomUUID40 } from "node:crypto";
552005
+ import { existsSync as existsSync70, readFileSync as readFileSync45, renameSync as renameSync8, writeFileSync as writeFileSync39 } from "node:fs";
551847
552006
  import { tmpdir as tmpdir12 } from "node:os";
551848
552007
  import { join as join91 } from "node:path";
551849
552008
  async function findCustomCommandByName(commandName) {
@@ -552263,7 +552422,7 @@ ${SYSTEM_REMINDER_CLOSE}` : "";
552263
552422
  content: buildTextParts(`${SYSTEM_REMINDER_OPEN}
552264
552423
  ${prompt}
552265
552424
  ${SYSTEM_REMINDER_CLOSE}`),
552266
- otid: randomUUID39()
552425
+ otid: randomUUID40()
552267
552426
  }
552268
552427
  ]);
552269
552428
  } catch (error54) {
@@ -552327,7 +552486,7 @@ ${SYSTEM_REMINDER_CLOSE}`),
552327
552486
  type: "message",
552328
552487
  role: "user",
552329
552488
  content: buildTextParts(buildModCommandPrompt(result2)),
552330
- otid: randomUUID39()
552489
+ otid: randomUUID40()
552331
552490
  }
552332
552491
  ]);
552333
552492
  } else if (result2.type === "output") {
@@ -552372,7 +552531,7 @@ ${SYSTEM_REMINDER_CLOSE}`),
552372
552531
  ${SYSTEM_REMINDER_OPEN}
552373
552532
  ${request}
552374
552533
  ${SYSTEM_REMINDER_CLOSE}`),
552375
- otid: randomUUID39()
552534
+ otid: randomUUID40()
552376
552535
  }
552377
552536
  ]);
552378
552537
  } catch (error54) {
@@ -552545,7 +552704,7 @@ ${SYSTEM_REMINDER_CLOSE}`),
552545
552704
  ];
552546
552705
  const personaPath = personaCandidates.find((candidate) => existsSync70(candidate));
552547
552706
  if (personaPath) {
552548
- const personaContent = readFileSync44(personaPath, "utf-8");
552707
+ const personaContent = readFileSync45(personaPath, "utf-8");
552549
552708
  setCurrentPersonalityId(detectPersonalityFromPersonaFile(personaContent));
552550
552709
  } else {
552551
552710
  setCurrentPersonalityId(null);
@@ -552641,7 +552800,7 @@ ${SYSTEM_REMINDER_CLOSE}`),
552641
552800
  ${SYSTEM_REMINDER_OPEN}
552642
552801
  ${request}
552643
552802
  ${SYSTEM_REMINDER_CLOSE}`),
552644
- otid: randomUUID39()
552803
+ otid: randomUUID40()
552645
552804
  }
552646
552805
  ]);
552647
552806
  } catch (error54) {
@@ -553313,7 +553472,7 @@ Tip: Use /clear instead to clear the current message buffer.`;
553313
553472
  fileContent.skills = skills;
553314
553473
  }
553315
553474
  const fileName = exportParams.conversation_id ? `${exportParams.conversation_id}.af` : `${agentId}.af`;
553316
- writeFileSync38(fileName, JSON.stringify(fileContent, null, 2));
553475
+ writeFileSync39(fileName, JSON.stringify(fileContent, null, 2));
553317
553476
  let summary = `AgentFile exported to ${fileName}`;
553318
553477
  if (skills.length > 0) {
553319
553478
  summary += `
@@ -553485,7 +553644,7 @@ ${SYSTEM_REMINDER_CLOSE}`;
553485
553644
  type: "message",
553486
553645
  role: "user",
553487
553646
  content: buildTextParts(skillMessage),
553488
- otid: randomUUID39()
553647
+ otid: randomUUID40()
553489
553648
  }
553490
553649
  ]);
553491
553650
  } catch (error54) {
@@ -553523,7 +553682,7 @@ ${SYSTEM_REMINDER_CLOSE}`;
553523
553682
  type: "message",
553524
553683
  role: "user",
553525
553684
  content: rememberParts,
553526
- otid: randomUUID39()
553685
+ otid: randomUUID40()
553527
553686
  }
553528
553687
  ]);
553529
553688
  } catch (error54) {
@@ -553939,7 +554098,7 @@ Resumed reflection arena choice prompt for run ${run2.runId}.`, true);
553939
554098
  type: "message",
553940
554099
  role: "user",
553941
554100
  content: buildTextParts(initMessage),
553942
- otid: randomUUID39()
554101
+ otid: randomUUID40()
553943
554102
  }
553944
554103
  ]);
553945
554104
  } catch (error54) {
@@ -554106,7 +554265,7 @@ Resumed reflection arena choice prompt for run ${run2.runId}.`, true);
554106
554265
  type: "message",
554107
554266
  role: "user",
554108
554267
  content: buildTextParts(wrapSkillPrompt2(matchedSkill.id, skillContent, userRequest)),
554109
- otid: randomUUID39()
554268
+ otid: randomUUID40()
554110
554269
  }
554111
554270
  ]);
554112
554271
  } catch (error54) {
@@ -554257,7 +554416,7 @@ ${SYSTEM_REMINDER_CLOSE}
554257
554416
  initialInput.push({
554258
554417
  type: "approval",
554259
554418
  approvals: eagerRecoveryDenials,
554260
- otid: randomUUID39()
554419
+ otid: randomUUID40()
554261
554420
  });
554262
554421
  }
554263
554422
  const queuedApprovalInput = consumeQueuedApprovalInputForCurrentConversation();
@@ -561664,4 +561823,4 @@ function registerBunOAuthFlows() {
561664
561823
  registerBunOAuthFlows();
561665
561824
  await init_src5().then(() => exports_src2);
561666
561825
 
561667
- //# debugId=59AB0103DFD2BC9664756E2164756E21
561826
+ //# debugId=036B0E52721A750064756E2164756E21