@letta-ai/letta-code 0.30.14 → 0.30.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/letta.js CHANGED
@@ -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.15",
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",
@@ -157948,7 +157948,8 @@ function emitDequeuedUserMessage(socket, runtime, incoming, batch) {
157948
157948
  date: new Date().toISOString(),
157949
157949
  message_type: "user_message",
157950
157950
  content,
157951
- otid
157951
+ otid,
157952
+ created_by_id: incoming.actingUserId
157952
157953
  }, {
157953
157954
  agent_id: incoming.agentId,
157954
157955
  conversation_id: incoming.conversationId
@@ -158410,7 +158411,6 @@ var init_enter_worktree_messages = __esm(() => {
158410
158411
  });
158411
158412
 
158412
158413
  // src/tools/impl/worktree-git.ts
158413
- import { spawn as spawn3 } from "node:child_process";
158414
158414
  import path16 from "node:path";
158415
158415
  function formatGitFailure(error54) {
158416
158416
  if (error54 instanceof GitCommandError) {
@@ -158436,46 +158436,41 @@ This looks like a Windows path-length issue. Try:
158436
158436
  - git config --global core.longpaths true
158437
158437
  - move the repo to a shorter path, like C:\\src\\<repo>, and retry.`;
158438
158438
  }
158439
+ function buildNonInteractiveGitEnv(base2 = getShellEnv()) {
158440
+ const env3 = {
158441
+ ...base2,
158442
+ GIT_TERMINAL_PROMPT: "0",
158443
+ GCM_INTERACTIVE: "never",
158444
+ GIT_ASKPASS: "",
158445
+ SSH_ASKPASS: "",
158446
+ SSH_ASKPASS_REQUIRE: "never"
158447
+ };
158448
+ const sshCommand = env3.GIT_SSH_COMMAND?.trim() || "ssh";
158449
+ env3.GIT_SSH_COMMAND = `${sshCommand} -o BatchMode=yes`;
158450
+ return env3;
158451
+ }
158439
158452
  async function runGit2(args, cwd, options3 = {}) {
158440
158453
  const timeoutMs = options3.timeoutMs ?? DEFAULT_GIT_TIMEOUT_MS;
158441
- return await new Promise((resolve11, reject) => {
158442
- const child = spawn3("git", args, {
158454
+ let result;
158455
+ try {
158456
+ result = await spawnWithLauncher(["git", ...args], {
158443
158457
  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));
158458
+ env: buildNonInteractiveGitEnv(),
158459
+ signal: options3.signal,
158460
+ timeoutMs
158460
158461
  });
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);
158462
+ } catch (error54) {
158463
+ const failure2 = error54;
158464
+ throw new GitCommandError(failure2.killed ? `Timed out running git ${args.join(" ")}` : `Failed to run git ${args.join(" ")}: ${failure2.message}`, args, {
158465
+ stdout: failure2.stdout ?? "",
158466
+ stderr: failure2.stderr ?? "",
158467
+ exitCode: typeof failure2.code === "number" ? failure2.code : null
158477
158468
  });
158478
- });
158469
+ }
158470
+ if (result.exitCode !== 0 && !options3.allowFailure) {
158471
+ throw new GitCommandError(`Failed to run git ${args.join(" ")}`, args, result);
158472
+ }
158473
+ return result;
158479
158474
  }
158480
158475
  async function gitStdout(args, cwd) {
158481
158476
  const result = await runGit2(args, cwd);
@@ -158519,6 +158514,7 @@ function isPathWithin(child, parent) {
158519
158514
  var DEFAULT_GIT_TIMEOUT_MS = 120000, GitCommandError;
158520
158515
  var init_worktree_git = __esm(() => {
158521
158516
  init_shell_env();
158517
+ init_shell_runner();
158522
158518
  GitCommandError = class GitCommandError extends Error {
158523
158519
  args;
158524
158520
  result;
@@ -158594,7 +158590,7 @@ async function resolveWorktreeContext(params) {
158594
158590
  const managedDir = path17.join(primaryRoot, ".letta", "worktrees");
158595
158591
  return { currentCwd, repoRoot, primaryRoot, managedDir };
158596
158592
  }
158597
- async function refreshBaseRef(repoRoot, baseRef) {
158593
+ async function refreshBaseRef(repoRoot, baseRef, signal) {
158598
158594
  const slashIndex = baseRef.indexOf("/");
158599
158595
  if (slashIndex <= 0) {
158600
158596
  return;
@@ -158607,9 +158603,7 @@ async function refreshBaseRef(repoRoot, baseRef) {
158607
158603
  if (!hasRemote) {
158608
158604
  return;
158609
158605
  }
158610
- await runGit2(["fetch", remote, `${branch}:refs/remotes/${remote}/${branch}`], repoRoot, {
158611
- timeoutMs: FETCH_GIT_TIMEOUT_MS
158612
- });
158606
+ await runGit2(["fetch", remote, `${branch}:refs/remotes/${remote}/${branch}`], repoRoot, { signal, timeoutMs: FETCH_GIT_TIMEOUT_MS });
158613
158607
  }
158614
158608
  async function chooseUniqueWorktreePath(worktreesDir, slug) {
158615
158609
  for (let index = 0;index < 100; index += 1) {
@@ -159030,7 +159024,7 @@ async function enter_worktree(rawArgs) {
159030
159024
  const branchName = await chooseUniqueBranchName(repoRoot, slug, getStringArg(args, "branch_name"));
159031
159025
  const baseRef = getStringArg(args, "base_ref") ?? await resolveDefaultBaseRef(repoRoot);
159032
159026
  if (args.refresh_base !== false) {
159033
- await refreshBaseRef(repoRoot, baseRef);
159027
+ await refreshBaseRef(repoRoot, baseRef, args.signal);
159034
159028
  }
159035
159029
  if (!await gitRefExists(repoRoot, baseRef)) {
159036
159030
  throw new Error(`Base ref does not exist: ${baseRef}`);
@@ -163099,13 +163093,16 @@ function normalizeMonitorArgs(args) {
163099
163093
  if (normalized.command !== undefined && typeof normalized.command !== "string") {
163100
163094
  throw new Error("Monitor command must be a string");
163101
163095
  }
163102
- const hasCommand = typeof normalized.command === "string";
163103
- const hasWebSocket = normalized.ws !== undefined;
163096
+ const hasCommand = typeof normalized.command === "string" && normalized.command.length > 0;
163097
+ const hasWebSocket = normalized.ws !== undefined && !(typeof normalized.ws === "object" && normalized.ws !== null && normalized.ws.url === "");
163104
163098
  if (Number(hasCommand) + Number(hasWebSocket) !== 1) {
163105
163099
  throw new Error("Monitor requires exactly one of command or ws");
163106
163100
  }
163107
- if (hasCommand && !normalized.command) {
163108
- throw new Error("Monitor requires exactly one of command or ws");
163101
+ if (!hasCommand) {
163102
+ delete normalized.command;
163103
+ }
163104
+ if (!hasWebSocket) {
163105
+ delete normalized.ws;
163109
163106
  }
163110
163107
  if (hasCommand && containsHiddenControlCharacter(normalized.command)) {
163111
163108
  throw new Error("Monitor command contains control characters that would be hidden in the approval dialog");
@@ -163852,7 +163849,7 @@ async function convertHeicToJpegWithSips(buffer) {
163852
163849
  var init_image_resize_sips = () => {};
163853
163850
 
163854
163851
  // src/utils/image-resize.ts
163855
- import { spawn as spawn4 } from "node:child_process";
163852
+ import { spawn as spawn3 } from "node:child_process";
163856
163853
  import { existsSync as existsSync16 } from "node:fs";
163857
163854
  import { fileURLToPath as fileURLToPath4 } from "node:url";
163858
163855
  function resolveImageWorkerPath() {
@@ -163865,7 +163862,7 @@ function resolveImageWorkerPath() {
163865
163862
  function resizeWithSharpWorker(buffer, inputMediaType) {
163866
163863
  return new Promise((resolve18, reject) => {
163867
163864
  const workerPath = resolveImageWorkerPath();
163868
- const child = spawn4(process.execPath, [workerPath, inputMediaType], {
163865
+ const child = spawn3(process.execPath, [workerPath, inputMediaType], {
163869
163866
  shell: false,
163870
163867
  stdio: ["pipe", "pipe", "pipe"],
163871
163868
  windowsHide: true
@@ -164961,7 +164958,7 @@ var require_cross_spawn = __commonJS((exports, module3) => {
164961
164958
  var cp = __require("child_process");
164962
164959
  var parse8 = require_parse3();
164963
164960
  var enoent = require_enoent();
164964
- function spawn5(command, args, options3) {
164961
+ function spawn4(command, args, options3) {
164965
164962
  const parsed = parse8(command, args, options3);
164966
164963
  const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
164967
164964
  enoent.hookChildProcess(spawned, parsed);
@@ -164973,8 +164970,8 @@ var require_cross_spawn = __commonJS((exports, module3) => {
164973
164970
  result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
164974
164971
  return result;
164975
164972
  }
164976
- module3.exports = spawn5;
164977
- module3.exports.spawn = spawn5;
164973
+ module3.exports = spawn4;
164974
+ module3.exports.spawn = spawn4;
164978
164975
  module3.exports.sync = spawnSync3;
164979
164976
  module3.exports._parse = parse8;
164980
164977
  module3.exports._enoent = enoent;
@@ -164982,13 +164979,13 @@ var require_cross_spawn = __commonJS((exports, module3) => {
164982
164979
 
164983
164980
  // src/utils/package-manager-spawn.ts
164984
164981
  import {
164985
- spawn as spawn5
164982
+ spawn as spawn4
164986
164983
  } from "node:child_process";
164987
164984
  function isWindowsCommandShim(command) {
164988
164985
  return /\.(?:cmd|bat)$/i.test(command);
164989
164986
  }
164990
164987
  function getPackageManagerProcessFactory({
164991
- nativeSpawn = spawn5,
164988
+ nativeSpawn = spawn4,
164992
164989
  platform: platform2 = process.platform,
164993
164990
  windowsSpawn = import_cross_spawn.default
164994
164991
  } = {}) {
@@ -165089,9 +165086,9 @@ var init_typescript = __esm(() => {
165089
165086
  throw new Error("LSP auto-download is disabled. Please install typescript-language-server manually: npm install -g typescript-language-server typescript");
165090
165087
  }
165091
165088
  console.log("[LSP] Installing typescript-language-server and typescript...");
165092
- const { spawn: spawn6 } = await import("node:child_process");
165089
+ const { spawn: spawn5 } = await import("node:child_process");
165093
165090
  return new Promise((resolve18, reject) => {
165094
- const proc = spawn6("npm", ["install", "-g", "typescript-language-server", "typescript"], {
165091
+ const proc = spawn5("npm", ["install", "-g", "typescript-language-server", "typescript"], {
165095
165092
  stdio: "inherit"
165096
165093
  });
165097
165094
  proc.on("exit", (code2) => {
@@ -165164,7 +165161,7 @@ class LSPManager {
165164
165161
  return existing.client;
165165
165162
  }
165166
165163
  try {
165167
- const { spawn: spawn6 } = await import("node:child_process");
165164
+ const { spawn: spawn5 } = await import("node:child_process");
165168
165165
  const rootUri = process.cwd();
165169
165166
  if (serverDef.autoInstall) {
165170
165167
  const isAvailable = await serverDef.autoInstall.check();
@@ -165178,7 +165175,7 @@ class LSPManager {
165178
165175
  console.error(`[LSP] ${serverDef.id} has no command configured`);
165179
165176
  return null;
165180
165177
  }
165181
- const proc = spawn6(command, serverDef.command.slice(1), {
165178
+ const proc = spawn5(command, serverDef.command.slice(1), {
165182
165179
  cwd: rootUri,
165183
165180
  env: {
165184
165181
  ...process.env,
@@ -174208,7 +174205,7 @@ var init_subagent_stream = __esm(() => {
174208
174205
  });
174209
174206
 
174210
174207
  // src/agent/subagents/manager.ts
174211
- import { spawn as spawn6 } from "node:child_process";
174208
+ import { spawn as spawn5 } from "node:child_process";
174212
174209
  import { platform as platform2 } from "node:os";
174213
174210
  function isProviderNotSupportedError(errorOutput) {
174214
174211
  return errorOutput.includes("Provider") && errorOutput.includes("is not supported") && errorOutput.includes("supported providers:");
@@ -174425,7 +174422,7 @@ async function executeSubagent(type3, config3, model, userPrompt, subagentId, is
174425
174422
  if (sandbox) {
174426
174423
  debugLog("subagent", `memory subagent child sandboxed via ${sandbox.backend}`);
174427
174424
  }
174428
- const proc2 = spawn6(spawnLauncher.command, spawnLauncher.args, {
174425
+ const proc2 = spawn5(spawnLauncher.command, spawnLauncher.args, {
174429
174426
  cwd: subagentWorkingDirectory,
174430
174427
  env: spawnEnv
174431
174428
  });
@@ -182860,10 +182857,13 @@ async function executeToolInner(name, args, options3) {
182860
182857
  if (internalName === "Skill" && options3?.parentScope) {
182861
182858
  enhancedArgs = { ...enhancedArgs, parentScope: options3.parentScope };
182862
182859
  }
182863
- if (WORKTREE_TOOL_NAMES.has(internalName) && options3?.toolContextId) {
182860
+ if (WORKTREE_TOOL_NAMES.has(internalName)) {
182864
182861
  enhancedArgs = {
182865
182862
  ...enhancedArgs,
182866
- _executionContextId: options3.toolContextId
182863
+ ...options3?.toolContextId && {
182864
+ _executionContextId: options3.toolContextId
182865
+ },
182866
+ ...options3?.signal && { signal: options3.signal }
182867
182867
  };
182868
182868
  }
182869
182869
  const result2 = await tool2.fn(enhancedArgs);
@@ -184285,7 +184285,7 @@ __export(exports_memory_git, {
184285
184285
  ensureLocalMemfsGitConfig: () => ensureLocalMemfsGitConfig,
184286
184286
  commitMemoryWrite: () => commitMemoryWrite,
184287
184287
  cloneMemoryRepo: () => cloneMemoryRepo,
184288
- buildNonInteractiveGitEnv: () => buildNonInteractiveGitEnv,
184288
+ buildNonInteractiveGitEnv: () => buildNonInteractiveGitEnv2,
184289
184289
  buildMemfsGitProxyArgs: () => buildMemfsGitProxyArgs,
184290
184290
  buildGitAuthArgs: () => buildGitAuthArgs,
184291
184291
  assertMemoryRepoCleanForWrite: () => assertMemoryRepoCleanForWrite,
@@ -184551,7 +184551,7 @@ function buildMemfsGitProxyArgs(args, env3 = process.env) {
184551
184551
  function shouldConfigurePersistentMemfsCredentialHelper(env3 = process.env) {
184552
184552
  return getMemfsGitProxyRewriteConfig(env3) === null;
184553
184553
  }
184554
- function buildNonInteractiveGitEnv(env3 = process.env) {
184554
+ function buildNonInteractiveGitEnv2(env3 = process.env) {
184555
184555
  return {
184556
184556
  ...env3,
184557
184557
  GIT_TERMINAL_PROMPT: "0",
@@ -184580,7 +184580,7 @@ async function runGit3(cwd, args, token, options3) {
184580
184580
  try {
184581
184581
  result = await execFile5("git", allArgs, {
184582
184582
  cwd,
184583
- env: buildNonInteractiveGitEnv(),
184583
+ env: buildNonInteractiveGitEnv2(),
184584
184584
  maxBuffer: 10485760,
184585
184585
  timeout: timeoutMs
184586
184586
  });
@@ -185513,6 +185513,202 @@ var init_memory_git = __esm(() => {
185513
185513
  NO_UPSTREAM_PULL_ERROR_RE = /(there is no tracking information for the current branch|no upstream configured|no tracking branch)/i;
185514
185514
  });
185515
185515
 
185516
+ // src/backend/local/local-model-normalization.ts
185517
+ function supportedModelSettingsFromBody(bodyRecord) {
185518
+ const modelSettings = isRecord(bodyRecord.model_settings) ? { ...bodyRecord.model_settings } : {};
185519
+ if (typeof bodyRecord.context_window_limit === "number") {
185520
+ modelSettings.context_window_limit = bodyRecord.context_window_limit;
185521
+ }
185522
+ if (typeof bodyRecord.parallel_tool_calls === "boolean") {
185523
+ modelSettings.parallel_tool_calls = bodyRecord.parallel_tool_calls;
185524
+ }
185525
+ if (typeof bodyRecord.max_tokens === "number" || bodyRecord.max_tokens === null) {
185526
+ modelSettings.max_tokens = bodyRecord.max_tokens;
185527
+ }
185528
+ return modelSettings;
185529
+ }
185530
+ function providerTypeFromModelSettings2(modelSettings) {
185531
+ const providerType = modelSettings?.provider_type;
185532
+ return typeof providerType === "string" && providerType.length > 0 ? providerType : null;
185533
+ }
185534
+ function normalizeLocalModelHandle(model, modelSettings, legacyLlmConfig) {
185535
+ if (isResolvablePiModelHandle(model) || resolveRegisteredPiProviderFromModelHandle(model)) {
185536
+ return model;
185537
+ }
185538
+ const providerType = providerTypeFromModelSettings2(modelSettings);
185539
+ const legacyEndpointType = legacyLlmConfig?.model_endpoint_type;
185540
+ return resolveModelHandleFromLlmConfig({
185541
+ model,
185542
+ model_endpoint_type: providerType ?? (typeof legacyEndpointType === "string" ? legacyEndpointType : null)
185543
+ }) ?? model;
185544
+ }
185545
+ function modelHandleFromLegacyLlmConfig(legacyLlmConfig) {
185546
+ const model = legacyLlmConfig.model;
185547
+ if (typeof model !== "string")
185548
+ return null;
185549
+ const modelEndpointType = legacyLlmConfig.model_endpoint_type;
185550
+ return resolveModelHandleFromLlmConfig({
185551
+ model,
185552
+ model_endpoint_type: typeof modelEndpointType === "string" ? modelEndpointType : null
185553
+ });
185554
+ }
185555
+ function supportedConversationModelSettingsFromBody(bodyRecord) {
185556
+ const rawSettings = bodyRecord.model_settings;
185557
+ const modelSettings = rawSettings === null ? null : isRecord(rawSettings) ? { ...rawSettings } : undefined;
185558
+ if (modelSettings === null)
185559
+ return null;
185560
+ const next = modelSettings ?? {};
185561
+ if (typeof bodyRecord.max_tokens === "number" || bodyRecord.max_tokens === null) {
185562
+ next.max_tokens = bodyRecord.max_tokens;
185563
+ }
185564
+ return Object.keys(next).length > 0 ? next : modelSettings;
185565
+ }
185566
+ function normalizeStoredLocalModelRecord(record5) {
185567
+ if (typeof record5.model !== "string")
185568
+ return record5;
185569
+ const modelSettings = isRecord(record5.model_settings) ? record5.model_settings : {};
185570
+ const normalizedModel = normalizeLocalModelHandle(record5.model, modelSettings);
185571
+ return normalizedModel === record5.model ? record5 : { ...record5, model: normalizedModel };
185572
+ }
185573
+ function localLlmConfigModelPatch(model, modelSettings) {
185574
+ return mapModelHandleToLlmConfigPatch(model, providerTypeFromModelSettings2(modelSettings));
185575
+ }
185576
+ var init_local_model_normalization = __esm(() => {
185577
+ init_model_handles();
185578
+ init_pi_provider_mod_registry();
185579
+ init_pi_provider_registry();
185580
+ });
185581
+
185582
+ // src/backend/local/local-agent-record.ts
185583
+ import { randomUUID as randomUUID7 } from "node:crypto";
185584
+ function isStringArray2(value) {
185585
+ return Array.isArray(value) && value.every((item) => typeof item === "string");
185586
+ }
185587
+ function normalizeAgentHiddenFlag(hidden, tags) {
185588
+ if (typeof hidden === "boolean")
185589
+ return hidden;
185590
+ if ((hidden === undefined || hidden === null) && isSubagentTags(tags)) {
185591
+ return true;
185592
+ }
185593
+ return hidden === null ? null : undefined;
185594
+ }
185595
+ function isSubagentTags(tags) {
185596
+ return tags.includes(LETTA_CODE_SUBAGENT_TAG);
185597
+ }
185598
+ function isHiddenLocalAgentRecord(record5) {
185599
+ const tags = isStringArray2(record5.tags) ? record5.tags : [];
185600
+ return record5.hidden === true || record5.hidden == null && isSubagentTags(tags);
185601
+ }
185602
+ function shouldPersistSubagentHiddenBackfill(raw, record5) {
185603
+ return isRecord(raw) && (raw.hidden === undefined || raw.hidden === null) && record5.hidden === true && isSubagentTags(record5.tags);
185604
+ }
185605
+ function optionalString(value) {
185606
+ return typeof value === "string" ? value : undefined;
185607
+ }
185608
+ function optionalStringOrNull(value) {
185609
+ return typeof value === "string" || value === null ? value : undefined;
185610
+ }
185611
+ function createDefaultAgentRecord(agentId, defaultAgentName, defaultAgentModel) {
185612
+ return {
185613
+ id: agentId,
185614
+ name: defaultAgentName,
185615
+ description: null,
185616
+ system: "",
185617
+ tags: [],
185618
+ model: defaultAgentModel,
185619
+ model_settings: {}
185620
+ };
185621
+ }
185622
+ function createLocalAgentRecord(body, defaultAgentName, defaultAgentModel) {
185623
+ const bodyRecord = body;
185624
+ const tags = isStringArray2(bodyRecord.tags) ? bodyRecord.tags : [];
185625
+ const hidden = normalizeAgentHiddenFlag(bodyRecord.hidden, tags);
185626
+ const modelSettings = supportedModelSettingsFromBody(bodyRecord);
185627
+ const requestedModel = optionalString(bodyRecord.model) ?? defaultAgentModel;
185628
+ return {
185629
+ id: `agent-local-${randomUUID7()}`,
185630
+ name: optionalString(bodyRecord.name) ?? defaultAgentName,
185631
+ description: optionalStringOrNull(bodyRecord.description) ?? null,
185632
+ system: optionalString(bodyRecord.system) ?? "",
185633
+ tags,
185634
+ model: normalizeLocalModelHandle(requestedModel, modelSettings),
185635
+ model_settings: modelSettings,
185636
+ ...hidden !== undefined ? { hidden } : {}
185637
+ };
185638
+ }
185639
+ function shouldUseDefaultLocalModel(model) {
185640
+ return typeof model !== "string" || model.length === 0 || model === "auto" || model.startsWith("letta/");
185641
+ }
185642
+ function optionalRecordOrNull(value) {
185643
+ if (value === null)
185644
+ return null;
185645
+ return isRecord(value) ? { ...value } : undefined;
185646
+ }
185647
+ function normalizeAgentRecord(value, defaultAgentModel) {
185648
+ if (!isRecord(value) || typeof value.id !== "string")
185649
+ return;
185650
+ const modelSettings = isRecord(value.model_settings) ? { ...value.model_settings } : {};
185651
+ const legacyLlmConfig = isRecord(value.llm_config) ? value.llm_config : {};
185652
+ if (modelSettings.context_window_limit === undefined && typeof legacyLlmConfig.context_window === "number") {
185653
+ modelSettings.context_window_limit = legacyLlmConfig.context_window;
185654
+ }
185655
+ if (modelSettings.max_tokens === undefined && (typeof legacyLlmConfig.max_tokens === "number" || legacyLlmConfig.max_tokens === null)) {
185656
+ modelSettings.max_tokens = legacyLlmConfig.max_tokens;
185657
+ }
185658
+ const compactionSettings = optionalRecordOrNull(value.compaction_settings);
185659
+ const tags = isStringArray2(value.tags) ? value.tags : [];
185660
+ const hidden = normalizeAgentHiddenFlag(value.hidden, tags);
185661
+ const storedModel = optionalString(value.model);
185662
+ const legacyModel = modelHandleFromLegacyLlmConfig(legacyLlmConfig);
185663
+ const model = storedModel ? normalizeLocalModelHandle(storedModel, modelSettings, legacyLlmConfig) : legacyModel ?? defaultAgentModel;
185664
+ return {
185665
+ id: value.id,
185666
+ name: optionalString(value.name) ?? "Letta Code",
185667
+ description: optionalStringOrNull(value.description) ?? null,
185668
+ system: optionalString(value.system) ?? "",
185669
+ tags,
185670
+ model,
185671
+ model_settings: modelSettings,
185672
+ ...hidden !== undefined ? { hidden } : {},
185673
+ ...compactionSettings !== undefined ? { compaction_settings: compactionSettings } : {}
185674
+ };
185675
+ }
185676
+ function projectLocalAgentState(record5, messageIds = [], inContextMessageIds = messageIds, lastRunCompletion) {
185677
+ const hidden = normalizeAgentHiddenFlag(record5.hidden, record5.tags);
185678
+ const nestedReasoning = isRecord(record5.model_settings.reasoning) ? record5.model_settings.reasoning : undefined;
185679
+ 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;
185680
+ 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;
185681
+ const llmConfigModelPatch = localLlmConfigModelPatch(record5.model, record5.model_settings);
185682
+ return {
185683
+ id: record5.id,
185684
+ name: record5.name,
185685
+ description: record5.description,
185686
+ system: record5.system,
185687
+ tools: [],
185688
+ tags: record5.tags,
185689
+ model: record5.model,
185690
+ model_settings: record5.model_settings,
185691
+ ...hidden !== undefined ? { hidden } : {},
185692
+ ...record5.compaction_settings !== undefined ? { compaction_settings: record5.compaction_settings } : {},
185693
+ message_ids: messageIds,
185694
+ in_context_message_ids: inContextMessageIds,
185695
+ ...lastRunCompletion ? { last_run_completion: lastRunCompletion } : {},
185696
+ llm_config: {
185697
+ ...llmConfigModelPatch,
185698
+ model_endpoint: "https://example.invalid/v1",
185699
+ context_window: typeof record5.model_settings.context_window_limit === "number" ? record5.model_settings.context_window_limit : 128000,
185700
+ ...reasoningEffort && { reasoning_effort: reasoningEffort },
185701
+ ...enableReasoner !== undefined && { enable_reasoner: enableReasoner },
185702
+ ...(typeof record5.model_settings.max_tokens === "number" || record5.model_settings.max_tokens === null) && {
185703
+ max_tokens: record5.model_settings.max_tokens
185704
+ }
185705
+ }
185706
+ };
185707
+ }
185708
+ var init_local_agent_record = __esm(() => {
185709
+ init_local_model_normalization();
185710
+ });
185711
+
185516
185712
  // src/backend/local/local-message-projection.ts
185517
185713
  function sourceLocalMessageIdFromStoredMessageId(messageId) {
185518
185714
  const variantSeparator = messageId.search(/:(assistant|reasoning|tool):/);
@@ -185897,7 +186093,7 @@ var FORK_PROJECTION_FALLBACK_DATE = "1970-01-01T00:00:00.000Z";
185897
186093
  var init_local_conversation_fork = () => {};
185898
186094
 
185899
186095
  // src/backend/local/local-conversation-list.ts
185900
- function optionalString(value) {
186096
+ function optionalString2(value) {
185901
186097
  return typeof value === "string" ? value : undefined;
185902
186098
  }
185903
186099
  function matchesSummarySearch(conversation, normalizedSearch) {
@@ -185907,9 +186103,9 @@ function matchesSummarySearch(conversation, normalizedSearch) {
185907
186103
  }
185908
186104
  function listLocalConversations(source2, body) {
185909
186105
  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();
186106
+ const agentId = optionalString2(bodyRecord.agent_id);
186107
+ const after = optionalString2(bodyRecord.after);
186108
+ const normalizedSearch = optionalString2(bodyRecord.summary_search)?.trim().toLowerCase();
185913
186109
  const limit3 = typeof bodyRecord.limit === "number" ? bodyRecord.limit : 20;
185914
186110
  let conversations = [...source2].filter((conversation) => conversation.id !== "default" && (bodyRecord.include_hidden === true || !conversation.hidden) && (!agentId || conversation.agent_id === agentId) && matchesSummarySearch(conversation, normalizedSearch));
185915
186111
  conversations.sort((a, b) => {
@@ -185943,72 +186139,6 @@ function emptyLocalUsage() {
185943
186139
  };
185944
186140
  }
185945
186141
 
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
186142
  // src/backend/local/local-stream-chunks.ts
186013
186143
  function attachLocalMessage(target2, message) {
186014
186144
  Object.defineProperty(target2, LOCAL_MESSAGE, {
@@ -186041,7 +186171,7 @@ var init_local_stream_chunks = __esm(() => {
186041
186171
  });
186042
186172
 
186043
186173
  // src/backend/local/local-store.ts
186044
- import { randomUUID as randomUUID7 } from "node:crypto";
186174
+ import { randomUUID as randomUUID8 } from "node:crypto";
186045
186175
  import {
186046
186176
  appendFileSync as appendFileSync5,
186047
186177
  closeSync,
@@ -186056,64 +186186,15 @@ import {
186056
186186
  writeFileSync as writeFileSync11
186057
186187
  } from "node:fs";
186058
186188
  import { join as join31 } from "node:path";
186059
- function isStringArray2(value) {
186189
+ function isStringArray3(value) {
186060
186190
  return Array.isArray(value) && value.every((item) => typeof item === "string");
186061
186191
  }
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) {
186192
+ function optionalString3(value) {
186081
186193
  return typeof value === "string" ? value : undefined;
186082
186194
  }
186083
- function optionalStringOrNull(value) {
186195
+ function optionalStringOrNull2(value) {
186084
186196
  return typeof value === "string" || value === null ? value : undefined;
186085
186197
  }
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
186198
  function currentIsoTimestamp() {
186118
186199
  return new Date().toISOString();
186119
186200
  }
@@ -186129,11 +186210,6 @@ function isSyntheticLocalTimestamp(value) {
186129
186210
  return false;
186130
186211
  return parsed >= Date.UTC(2026, 0, 1, 0, 0, 0, 0) && parsed < Date.UTC(2026, 0, 2, 0, 0, 0, 0);
186131
186212
  }
186132
- function optionalRecordOrNull(value) {
186133
- if (value === null)
186134
- return null;
186135
- return isRecord(value) ? { ...value } : undefined;
186136
- }
186137
186213
  function createLocalConversationRecord(conversationId, agentId, _sequence, body = {}) {
186138
186214
  const bodyRecord = body;
186139
186215
  const now = currentIsoTimestamp();
@@ -186146,7 +186222,7 @@ function createLocalConversationRecord(conversationId, agentId, _sequence, body
186146
186222
  created_at: now,
186147
186223
  updated_at: now,
186148
186224
  last_message_at: null,
186149
- summary: optionalStringOrNull(bodyRecord.summary) ?? null,
186225
+ summary: optionalStringOrNull2(bodyRecord.summary) ?? null,
186150
186226
  in_context_message_ids: [],
186151
186227
  ...typeof bodyRecord.model === "string" || bodyRecord.model === null ? {
186152
186228
  model: bodyRecord.model === null ? null : normalizeLocalModelHandle(bodyRecord.model, modelSettings ?? {})
@@ -186154,7 +186230,7 @@ function createLocalConversationRecord(conversationId, agentId, _sequence, body
186154
186230
  ...modelSettings !== undefined ? { model_settings: modelSettings } : {},
186155
186231
  ...typeof bodyRecord.context_window_limit === "number" ? { context_window_limit: bodyRecord.context_window_limit } : {},
186156
186232
  ...typeof bodyRecord.hidden === "boolean" ? { hidden: bodyRecord.hidden } : {},
186157
- ...isStringArray2(bodyRecord.tags) ? { tags: bodyRecord.tags } : {}
186233
+ ...isStringArray3(bodyRecord.tags) ? { tags: bodyRecord.tags } : {}
186158
186234
  };
186159
186235
  }
186160
186236
  function updateLocalConversationRecord(current, body, updatedAt) {
@@ -186190,72 +186266,11 @@ function updateLocalConversationRecord(current, body, updatedAt) {
186190
186266
  if (typeof bodyRecord.summary === "string" || bodyRecord.summary === null) {
186191
186267
  next.summary = bodyRecord.summary;
186192
186268
  }
186193
- if (isStringArray2(bodyRecord.tags)) {
186269
+ if (isStringArray3(bodyRecord.tags)) {
186194
186270
  next.tags = bodyRecord.tags;
186195
186271
  }
186196
186272
  return next;
186197
186273
  }
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
186274
  function textContent(text) {
186260
186275
  return [{ type: "text", text }];
186261
186276
  }
@@ -186451,7 +186466,7 @@ function localTranscriptSessionEntries(conversation, messages) {
186451
186466
  ...messages.map((message) => {
186452
186467
  const entry = {
186453
186468
  type: "message",
186454
- id: randomUUID7().slice(0, 8),
186469
+ id: randomUUID8().slice(0, 8),
186455
186470
  parentId,
186456
186471
  timestamp: localMessageDate2(message, currentIsoTimestamp()),
186457
186472
  message
@@ -186618,6 +186633,7 @@ class LocalStore {
186618
186633
  storedMessageIdPrefix;
186619
186634
  localMessageIdPrefix;
186620
186635
  agents = new Map;
186636
+ agentRecordMtimeMsById = new Map;
186621
186637
  conversations = new Map;
186622
186638
  localMessagesByConversationKey = new Map;
186623
186639
  loadedConversationKeys = new Set;
@@ -186655,20 +186671,20 @@ class LocalStore {
186655
186671
  }
186656
186672
  }
186657
186673
  retrieveAgent(agentId) {
186658
- if (!this.strictAgentAccess) {
186674
+ const existing = this.refreshAgentRecordFromStorage(agentId);
186675
+ if (!existing && !this.strictAgentAccess)
186659
186676
  return this.ensureAgent(agentId);
186660
- }
186661
- const existing = this.agents.get(agentId);
186662
186677
  if (!existing) {
186663
186678
  throw new LocalBackendNotFoundError("Agent", agentId);
186664
186679
  }
186665
186680
  return this.projectAgent(existing);
186666
186681
  }
186667
186682
  listAgents(body) {
186683
+ this.refreshLoadedAgentRecordsFromStorage();
186668
186684
  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);
186685
+ const queryText = optionalString3(bodyRecord.query_text)?.toLowerCase();
186686
+ const tags = isStringArray3(bodyRecord.tags) ? bodyRecord.tags : [];
186687
+ const after = optionalString3(bodyRecord.after);
186672
186688
  const limit3 = typeof bodyRecord.limit === "number" ? bodyRecord.limit : 20;
186673
186689
  let agents = [...this.agents.values()].filter((agent2) => !isHiddenLocalAgentRecord(agent2)).map((agent2) => this.projectAgent(agent2));
186674
186690
  if (tags.length > 0) {
@@ -186698,6 +186714,7 @@ class LocalStore {
186698
186714
  throw new LocalBackendNotFoundError("Agent", agentId);
186699
186715
  }
186700
186716
  this.agents.delete(agentId);
186717
+ this.agentRecordMtimeMsById.delete(agentId);
186701
186718
  this.loadConversationRecordsFromStorage();
186702
186719
  for (const [key, conversation] of [...this.conversations.entries()]) {
186703
186720
  if (conversation.agent_id === agentId) {
@@ -186724,17 +186741,18 @@ class LocalStore {
186724
186741
  }
186725
186742
  }
186726
186743
  retrieveAgentRecord(agentId) {
186727
- if (!this.strictAgentAccess) {
186744
+ let existing = this.refreshAgentRecordFromStorage(agentId);
186745
+ if (!existing && !this.strictAgentAccess) {
186728
186746
  this.ensureAgent(agentId);
186747
+ existing = this.agents.get(agentId);
186729
186748
  }
186730
- const existing = this.agents.get(agentId);
186731
186749
  if (!existing) {
186732
186750
  throw new LocalBackendNotFoundError("Agent", agentId);
186733
186751
  }
186734
186752
  return existing;
186735
186753
  }
186736
186754
  ensureAgent(agentId) {
186737
- const existing = this.agents.get(agentId);
186755
+ const existing = this.refreshAgentRecordFromStorage(agentId);
186738
186756
  if (existing)
186739
186757
  return this.projectAgent(existing);
186740
186758
  const agent2 = this.createDefaultAgentRecord(agentId);
@@ -186744,7 +186762,7 @@ class LocalStore {
186744
186762
  return this.projectAgent(agent2);
186745
186763
  }
186746
186764
  updateAgent(agentId, body) {
186747
- const currentRecord = this.agents.get(agentId);
186765
+ const currentRecord = this.refreshAgentRecordFromStorage(agentId);
186748
186766
  if (!currentRecord) {
186749
186767
  if (this.strictAgentAccess) {
186750
186768
  throw new LocalBackendNotFoundError("Agent", agentId);
@@ -186774,7 +186792,7 @@ class LocalStore {
186774
186792
  ...typeof bodyRecord.system === "string" && {
186775
186793
  system: bodyRecord.system
186776
186794
  },
186777
- ...isStringArray2(bodyRecord.tags) && { tags: bodyRecord.tags },
186795
+ ...isStringArray3(bodyRecord.tags) && { tags: bodyRecord.tags },
186778
186796
  ...nextModel && { model: nextModel },
186779
186797
  ...typeof bodyRecord.hidden === "boolean" && {
186780
186798
  hidden: bodyRecord.hidden
@@ -186789,7 +186807,7 @@ class LocalStore {
186789
186807
  return this.projectAgent(updated);
186790
186808
  }
186791
186809
  setAgentCompactionSettings(agentId, settings3) {
186792
- const existing = this.agents.get(agentId);
186810
+ const existing = this.refreshAgentRecordFromStorage(agentId);
186793
186811
  if (!existing) {
186794
186812
  throw new LocalBackendNotFoundError("Agent", agentId);
186795
186813
  }
@@ -187136,7 +187154,7 @@ class LocalStore {
187136
187154
  const localMessage = {
187137
187155
  id: this.nextLocalMessageId(),
187138
187156
  role: "user",
187139
- otid: optionalString2(message.otid ?? message.client_message_id),
187157
+ otid: optionalString3(message.otid ?? message.client_message_id),
187140
187158
  metadata: {
187141
187159
  created_at: date6,
187142
187160
  updated_at: date6,
@@ -187929,10 +187947,13 @@ class LocalStore {
187929
187947
  for (const file3 of readdirSync9(agentsDir)) {
187930
187948
  if (!file3.endsWith(".json") || file3.startsWith("._"))
187931
187949
  continue;
187932
- const raw = readJsonFile2(join31(agentsDir, file3));
187950
+ const filePath = join31(agentsDir, file3);
187951
+ const mtimeMs = statSync7(filePath).mtimeMs;
187952
+ const raw = readJsonFile2(filePath);
187933
187953
  const agent2 = normalizeAgentRecord(raw, this.defaultAgentModel);
187934
187954
  if (agent2?.id) {
187935
187955
  this.agents.set(agent2.id, agent2);
187956
+ this.recordAgentRecordMtime(agent2.id, mtimeMs);
187936
187957
  if (shouldPersistSubagentHiddenBackfill(raw, agent2)) {
187937
187958
  this.persistAgent(agent2.id);
187938
187959
  }
@@ -187950,6 +187971,50 @@ class LocalStore {
187950
187971
  mkdirSync16(agentsDir, { recursive: true });
187951
187972
  writeFileSync11(join31(agentsDir, `${encodePathSegment(agentId)}.json`), `${JSON.stringify(agent2, null, 2)}
187952
187973
  `);
187974
+ this.recordAgentRecordMtime(agentId);
187975
+ }
187976
+ agentRecordFileMtimeMs(agentId) {
187977
+ if (!this.storageDir)
187978
+ return;
187979
+ try {
187980
+ return statSync7(join31(this.storageDir, "agents", `${encodePathSegment(agentId)}.json`)).mtimeMs;
187981
+ } catch {
187982
+ return;
187983
+ }
187984
+ }
187985
+ recordAgentRecordMtime(agentId, mtimeMs) {
187986
+ const recordedMtimeMs = mtimeMs ?? this.agentRecordFileMtimeMs(agentId);
187987
+ if (recordedMtimeMs === undefined) {
187988
+ this.agentRecordMtimeMsById.delete(agentId);
187989
+ return;
187990
+ }
187991
+ this.agentRecordMtimeMsById.set(agentId, recordedMtimeMs);
187992
+ }
187993
+ refreshAgentRecordFromStorage(agentId) {
187994
+ const existing = this.agents.get(agentId);
187995
+ if (!this.storageDir || !existing)
187996
+ return existing;
187997
+ const mtimeMs = this.agentRecordFileMtimeMs(agentId);
187998
+ if (mtimeMs === undefined)
187999
+ return existing;
188000
+ if (this.agentRecordMtimeMsById.get(agentId) === mtimeMs)
188001
+ return existing;
188002
+ try {
188003
+ const raw = readJsonFile2(join31(this.storageDir, "agents", `${encodePathSegment(agentId)}.json`));
188004
+ const agent2 = normalizeAgentRecord(raw, this.defaultAgentModel);
188005
+ if (!agent2 || agent2.id !== agentId)
188006
+ return existing;
188007
+ this.agents.set(agentId, agent2);
188008
+ this.recordAgentRecordMtime(agentId, mtimeMs);
188009
+ return agent2;
188010
+ } catch {
188011
+ return existing;
188012
+ }
188013
+ }
188014
+ refreshLoadedAgentRecordsFromStorage() {
188015
+ for (const agentId of this.agents.keys()) {
188016
+ this.refreshAgentRecordFromStorage(agentId);
188017
+ }
187953
188018
  }
187954
188019
  projectAgent(record5) {
187955
188020
  const defaultConversation = this.findConversation("default", record5.id);
@@ -188134,11 +188199,11 @@ class LocalStore {
188134
188199
  nextSessionEntryId(key) {
188135
188200
  const entryIds = this.sessionEntryIds(key);
188136
188201
  for (let attempt = 0;attempt < 100; attempt += 1) {
188137
- const id2 = randomUUID7().slice(0, 8);
188202
+ const id2 = randomUUID8().slice(0, 8);
188138
188203
  if (!entryIds.has(id2))
188139
188204
  return id2;
188140
188205
  }
188141
- return randomUUID7();
188206
+ return randomUUID8();
188142
188207
  }
188143
188208
  persistCompiledSystemPrompt(conversationId, agentId) {
188144
188209
  if (!this.storageDir)
@@ -188237,6 +188302,7 @@ class LocalStore {
188237
188302
  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
188303
  var init_local_store = __esm(() => {
188239
188304
  init_constants2();
188305
+ init_local_agent_record();
188240
188306
  init_local_conversation_fork();
188241
188307
  init_local_model_normalization();
188242
188308
  init_local_stream_chunks();
@@ -189080,7 +189146,7 @@ var init_error_formatter = __esm(() => {
189080
189146
  });
189081
189147
 
189082
189148
  // src/agent/turn-recovery-policy.ts
189083
- import { randomUUID as randomUUID8 } from "node:crypto";
189149
+ import { randomUUID as randomUUID9 } from "node:crypto";
189084
189150
  function isCloudflareEdge52xDetail(detail) {
189085
189151
  if (typeof detail !== "string")
189086
189152
  return false;
@@ -189293,7 +189359,7 @@ function buildFreshDenialApprovals(serverApprovals, denialReason) {
189293
189359
  function refreshInputOtidsForNewRequest(currentInput) {
189294
189360
  return currentInput.map((item) => ({
189295
189361
  ...item,
189296
- otid: randomUUID8()
189362
+ otid: randomUUID9()
189297
189363
  }));
189298
189364
  }
189299
189365
  function rebuildInputWithFreshDenials(currentInput, serverApprovals, denialReason) {
@@ -189302,7 +189368,7 @@ function rebuildInputWithFreshDenials(currentInput, serverApprovals, denialReaso
189302
189368
  const denials = {
189303
189369
  type: "approval",
189304
189370
  approvals: buildFreshDenialApprovals(serverApprovals, denialReason),
189305
- otid: randomUUID8()
189371
+ otid: randomUUID9()
189306
189372
  };
189307
189373
  return [denials, ...stripped];
189308
189374
  }
@@ -192231,7 +192297,7 @@ __export(exports_provider_turn_executor, {
192231
192297
  buildProviderTurnInput: () => buildProviderTurnInput,
192232
192298
  ProviderTurnExecutor: () => ProviderTurnExecutor
192233
192299
  });
192234
- import { randomUUID as randomUUID9 } from "node:crypto";
192300
+ import { randomUUID as randomUUID10 } from "node:crypto";
192235
192301
  function providerStreamPart(part) {
192236
192302
  return { type: "provider-part", part };
192237
192303
  }
@@ -192390,7 +192456,7 @@ function otidForContentSegment(otids, prefix, contentIndex, partial4, messageTyp
192390
192456
  const existing = otids.get(segmentStartIndex);
192391
192457
  if (existing)
192392
192458
  return existing;
192393
- const otid = `${prefix}-${segmentStartIndex}-${randomUUID9()}`;
192459
+ const otid = `${prefix}-${segmentStartIndex}-${randomUUID10()}`;
192394
192460
  otids.set(segmentStartIndex, otid);
192395
192461
  return otid;
192396
192462
  }
@@ -233645,7 +233711,7 @@ function parsePositiveIntFlag(options3) {
233645
233711
  }
233646
233712
 
233647
233713
  // src/cli/helpers/file-autocomplete.ts
233648
- import { spawn as spawn7, spawnSync as spawnSync3 } from "node:child_process";
233714
+ import { spawn as spawn6, spawnSync as spawnSync3 } from "node:child_process";
233649
233715
  import {
233650
233716
  chmodSync as chmodSync5,
233651
233717
  createWriteStream as createWriteStream3,
@@ -233791,7 +233857,7 @@ async function walkDirectoryWithFd(baseDir, fdPath, query2, maxResults, signal)
233791
233857
  resolve29([]);
233792
233858
  return;
233793
233859
  }
233794
- const child = spawn7(fdPath, args, {
233860
+ const child = spawn6(fdPath, args, {
233795
233861
  stdio: ["ignore", "pipe", "pipe"]
233796
233862
  });
233797
233863
  let stdout = "";
@@ -234346,6 +234412,7 @@ var init_favorites = __esm(() => {
234346
234412
  var init_local = __esm(() => {
234347
234413
  init_context_window_overflow();
234348
234414
  init_compaction();
234415
+ init_local_agent_record();
234349
234416
  init_local_backend();
234350
234417
  init_local_model_config();
234351
234418
  init_local_provider_auth_store();
@@ -237345,7 +237412,7 @@ var init_pairing = __esm(() => {
237345
237412
  });
237346
237413
 
237347
237414
  // src/channels/custom/adapter.ts
237348
- import { randomUUID as randomUUID10 } from "node:crypto";
237415
+ import { randomUUID as randomUUID11 } from "node:crypto";
237349
237416
  function readString(account, key2) {
237350
237417
  const value = account.config[key2];
237351
237418
  return typeof value === "string" && value.length > 0 ? value : null;
@@ -237411,7 +237478,7 @@ function createCustomAdapter(account) {
237411
237478
  parsed = null;
237412
237479
  }
237413
237480
  }
237414
- return { messageId: extractMessageId(parsed) ?? randomUUID10() };
237481
+ return { messageId: extractMessageId(parsed) ?? randomUUID11() };
237415
237482
  }
237416
237483
  return {
237417
237484
  id: `custom:${account.accountId}`,
@@ -238720,7 +238787,7 @@ var init_transcription = __esm(() => {
238720
238787
  });
238721
238788
 
238722
238789
  // src/channels/telegram/media.ts
238723
- import { randomUUID as randomUUID11 } from "node:crypto";
238790
+ import { randomUUID as randomUUID12 } from "node:crypto";
238724
238791
  import { mkdir as mkdir8, writeFile as writeFile10 } from "node:fs/promises";
238725
238792
  import { basename as basename13, extname as extname6, join as join40 } from "node:path";
238726
238793
  function normalizeTelegramMimeType(mimeType) {
@@ -239016,7 +239083,7 @@ function inferAttachmentFileName(params) {
239016
239083
  async function saveTelegramAttachment(params) {
239017
239084
  const inboundDir = join40(getChannelDir("telegram"), "inbound", sanitizeTelegramPathSegment(params.accountId));
239018
239085
  await mkdir8(inboundDir, { recursive: true });
239019
- const filePath = join40(inboundDir, `${Date.now()}-${randomUUID11()}-${sanitizeTelegramPathSegment(params.fileName)}`);
239086
+ const filePath = join40(inboundDir, `${Date.now()}-${randomUUID12()}-${sanitizeTelegramPathSegment(params.fileName)}`);
239020
239087
  await writeFile10(filePath, params.buffer);
239021
239088
  return filePath;
239022
239089
  }
@@ -240171,7 +240238,7 @@ var init_typing_controller = __esm(() => {
240171
240238
  });
240172
240239
 
240173
240240
  // src/channels/telegram/adapter.ts
240174
- import { randomUUID as randomUUID12 } from "node:crypto";
240241
+ import { randomUUID as randomUUID13 } from "node:crypto";
240175
240242
  function createTelegramAdapter(config3) {
240176
240243
  let bot = null;
240177
240244
  let botModule = null;
@@ -240437,7 +240504,7 @@ function createTelegramAdapter(config3) {
240437
240504
  }
240438
240505
  function rememberLifecycleErrorReport(source2, errorText, runId) {
240439
240506
  pruneLifecycleErrorReports();
240440
- const token2 = randomUUID12();
240507
+ const token2 = randomUUID13();
240441
240508
  lifecycleErrorReports.set(token2, {
240442
240509
  expiresAt: Date.now() + TELEGRAM_LIFECYCLE_ERROR_REPORT_TTL_MS,
240443
240510
  report: buildChannelLifecycleErrorReport(source2, errorText, { runId }),
@@ -240831,7 +240898,7 @@ var init_message_actions = __esm(() => {
240831
240898
  });
240832
240899
 
240833
240900
  // src/channels/telegram/setup.ts
240834
- import { randomUUID as randomUUID13 } from "node:crypto";
240901
+ import { randomUUID as randomUUID14 } from "node:crypto";
240835
240902
  import { createInterface } from "node:readline/promises";
240836
240903
  async function runTelegramSetup() {
240837
240904
  const rl = createInterface({
@@ -240900,7 +240967,7 @@ Validating token...`);
240900
240967
  const now = new Date().toISOString();
240901
240968
  const account = {
240902
240969
  channel: "telegram",
240903
- accountId: randomUUID13(),
240970
+ accountId: randomUUID14(),
240904
240971
  displayName: validatedUsername ? `@${validatedUsername}` : undefined,
240905
240972
  enabled: true,
240906
240973
  token: token2.trim(),
@@ -242481,7 +242548,7 @@ var init_approval_controller = __esm(() => {
242481
242548
  });
242482
242549
 
242483
242550
  // src/channels/slack/attachment-stream.ts
242484
- import { randomUUID as randomUUID14 } from "node:crypto";
242551
+ import { randomUUID as randomUUID15 } from "node:crypto";
242485
242552
  import { mkdir as mkdir9, open as open2, rename as rename2, rm as rm7 } from "node:fs/promises";
242486
242553
  import { join as join41 } from "node:path";
242487
242554
  function sanitizeFileName(name) {
@@ -242517,7 +242584,7 @@ async function readWithIdleTimeout(reader, idleTimeoutMs, signal) {
242517
242584
  async function saveSlackAttachmentStream(params) {
242518
242585
  const inboundDir = join41(getChannelDir("slack"), "inbound", sanitizeFileName(params.accountId));
242519
242586
  await mkdir9(inboundDir, { recursive: true });
242520
- const filePath = join41(inboundDir, `${Date.now()}-${randomUUID14()}-${sanitizeFileName(params.fileName)}`);
242587
+ const filePath = join41(inboundDir, `${Date.now()}-${randomUUID15()}-${sanitizeFileName(params.fileName)}`);
242521
242588
  const temporaryPath = `${filePath}.partial`;
242522
242589
  const fileHandle = await open2(temporaryPath, "wx");
242523
242590
  const reader = params.body.getReader();
@@ -246158,7 +246225,7 @@ var init_message_actions2 = __esm(() => {
246158
246225
  });
246159
246226
 
246160
246227
  // src/channels/slack/setup.ts
246161
- import { randomUUID as randomUUID15 } from "node:crypto";
246228
+ import { randomUUID as randomUUID16 } from "node:crypto";
246162
246229
  import { createInterface as createInterface2 } from "node:readline/promises";
246163
246230
  function isValidBotToken(token2) {
246164
246231
  return token2.startsWith("xoxb-") && token2.length >= 20;
@@ -246225,7 +246292,7 @@ DM Policy — who can message this app directly?
246225
246292
  } catch {}
246226
246293
  const account = {
246227
246294
  channel: "slack",
246228
- accountId: randomUUID15(),
246295
+ accountId: randomUUID16(),
246229
246296
  displayName,
246230
246297
  enabled: true,
246231
246298
  mode: "socket",
@@ -246387,7 +246454,7 @@ function resolveDiscordChannelMode(channelId, parentChannelId, isThread, allowed
246387
246454
  }
246388
246455
 
246389
246456
  // src/channels/discord/media.ts
246390
- import { randomUUID as randomUUID16 } from "node:crypto";
246457
+ import { randomUUID as randomUUID17 } from "node:crypto";
246391
246458
  import { mkdirSync as mkdirSync22 } from "node:fs";
246392
246459
  import { writeFile as writeFile11 } from "node:fs/promises";
246393
246460
  import { tmpdir as tmpdir8 } from "node:os";
@@ -246422,7 +246489,7 @@ async function resolveDiscordInboundAttachments(params) {
246422
246489
  const kind = resolveAttachmentKind2(attachment.contentType);
246423
246490
  const localFileName = [
246424
246491
  Date.now(),
246425
- randomUUID16(),
246492
+ randomUUID17(),
246426
246493
  sanitizeDiscordPathSegment(params.accountId),
246427
246494
  sanitizeDiscordPathSegment(params.chatId),
246428
246495
  sanitizeDiscordPathSegment(attachment.id),
@@ -247463,7 +247530,7 @@ var init_message_actions3 = __esm(() => {
247463
247530
  });
247464
247531
 
247465
247532
  // src/channels/discord/setup.ts
247466
- import { randomUUID as randomUUID17 } from "node:crypto";
247533
+ import { randomUUID as randomUUID18 } from "node:crypto";
247467
247534
  import { createInterface as createInterface3 } from "node:readline/promises";
247468
247535
  function isValidBotToken2(token2) {
247469
247536
  return token2.length >= 50 && token2.includes(".");
@@ -247575,7 +247642,7 @@ Warning: No agent bound. DM pairing will still work, but open/allowlist DMs and
247575
247642
  const now = new Date().toISOString();
247576
247643
  const account = {
247577
247644
  channel: "discord",
247578
- accountId: randomUUID17(),
247645
+ accountId: randomUUID18(),
247579
247646
  enabled: true,
247580
247647
  token: token2,
247581
247648
  agentId,
@@ -247808,7 +247875,7 @@ var init_attachment_policy = __esm(() => {
247808
247875
  });
247809
247876
 
247810
247877
  // src/channels/whatsapp/media.ts
247811
- import { randomUUID as randomUUID18 } from "node:crypto";
247878
+ import { randomUUID as randomUUID19 } from "node:crypto";
247812
247879
  import { mkdir as mkdir10, writeFile as writeFile12 } from "node:fs/promises";
247813
247880
  import { basename as basename17, extname as extname10, join as join43 } from "node:path";
247814
247881
  function unwrapWhatsAppMessageContent(message) {
@@ -247966,7 +248033,7 @@ async function collectWhatsAppAttachments(params) {
247966
248033
  const rawName = typeof candidate.mediaMessage.fileName === "string" ? candidate.mediaMessage.fileName : undefined;
247967
248034
  const name = rawName || `whatsapp-${params.messageId}.${extensionFromMime(mimeType)}`;
247968
248035
  const attachment = {
247969
- id: randomUUID18(),
248036
+ id: randomUUID19(),
247970
248037
  name,
247971
248038
  mimeType,
247972
248039
  sizeBytes,
@@ -248487,7 +248554,7 @@ var MAX_WHATSAPP_INBOUND_DEBOUNCE_MS = 1e4;
248487
248554
  var init_inbound_debounce2 = () => {};
248488
248555
 
248489
248556
  // src/channels/whatsapp/lid-store.ts
248490
- import { randomUUID as randomUUID19 } from "node:crypto";
248557
+ import { randomUUID as randomUUID20 } from "node:crypto";
248491
248558
  import {
248492
248559
  closeSync as closeSync2,
248493
248560
  mkdirSync as mkdirSync23,
@@ -248584,7 +248651,7 @@ function createLidStore(filePath) {
248584
248651
  const data = serializeStore(map3);
248585
248652
  const dir = dirname23(filePath);
248586
248653
  mkdirSync23(dir, { recursive: true });
248587
- const tmpPath = `${filePath}.${randomUUID19()}.tmp`;
248654
+ const tmpPath = `${filePath}.${randomUUID20()}.tmp`;
248588
248655
  let fd = null;
248589
248656
  try {
248590
248657
  fd = openSync2(tmpPath, "wx", 384);
@@ -250111,7 +250178,7 @@ var init_message_actions4 = __esm(() => {
250111
250178
  });
250112
250179
 
250113
250180
  // src/channels/whatsapp/setup.ts
250114
- import { randomUUID as randomUUID20 } from "node:crypto";
250181
+ import { randomUUID as randomUUID21 } from "node:crypto";
250115
250182
  import { createInterface as createInterface4 } from "node:readline/promises";
250116
250183
  function isDmPolicy(value) {
250117
250184
  return value === "pairing" || value === "allowlist" || value === "open";
@@ -250193,7 +250260,7 @@ Group mode: disabled, mention, or open [disabled]: `);
250193
250260
  const now = new Date().toISOString();
250194
250261
  const account = {
250195
250262
  channel: "whatsapp",
250196
- accountId: randomUUID20(),
250263
+ accountId: randomUUID21(),
250197
250264
  enabled: true,
250198
250265
  dmPolicy: policy,
250199
250266
  allowedUsers,
@@ -250263,7 +250330,7 @@ var init_plugin5 = __esm(() => {
250263
250330
  });
250264
250331
 
250265
250332
  // src/channels/signal/client.ts
250266
- import { randomUUID as randomUUID21 } from "node:crypto";
250333
+ import { randomUUID as randomUUID22 } from "node:crypto";
250267
250334
  import { request as httpRequest } from "node:http";
250268
250335
  import { request as httpsRequest } from "node:https";
250269
250336
  function getRequest(url2) {
@@ -250349,7 +250416,7 @@ class SignalRestClient {
250349
250416
  jsonrpc: "2.0",
250350
250417
  method: "version",
250351
250418
  params: {},
250352
- id: randomUUID21()
250419
+ id: randomUUID22()
250353
250420
  }).catch((versionError) => {
250354
250421
  throw new Error(`Signal daemon health check failed: ${formatSignalClientError(checkError)}; version fallback failed: ${formatSignalClientError(versionError)}`);
250355
250422
  });
@@ -250368,7 +250435,7 @@ class SignalRestClient {
250368
250435
  jsonrpc: "2.0",
250369
250436
  method,
250370
250437
  params: this.withAccount(params),
250371
- id: randomUUID21()
250438
+ id: randomUUID22()
250372
250439
  };
250373
250440
  const response = await this.request("POST", "/api/v1/rpc", body3);
250374
250441
  if (response === null) {
@@ -250609,7 +250676,7 @@ var init_client6 = __esm(() => {
250609
250676
  });
250610
250677
 
250611
250678
  // src/channels/signal/media.ts
250612
- import { randomUUID as randomUUID22 } from "node:crypto";
250679
+ import { randomUUID as randomUUID23 } from "node:crypto";
250613
250680
  import {
250614
250681
  copyFileSync as copyFileSync2,
250615
250682
  mkdirSync as mkdirSync25,
@@ -250893,7 +250960,7 @@ function copySignalAttachment(params) {
250893
250960
  const kind = inferSignalAttachmentKind({ mimeType, fileName });
250894
250961
  const inboundDir = join46(getChannelDir("signal"), "inbound", sanitizeSignalPathSegment(params.accountId));
250895
250962
  mkdirSync25(inboundDir, { recursive: true });
250896
- const localPath = join46(inboundDir, `${Date.now()}-${randomUUID22()}-${sanitizeSignalPathSegment(fileName)}`);
250963
+ const localPath = join46(inboundDir, `${Date.now()}-${randomUUID23()}-${sanitizeSignalPathSegment(fileName)}`);
250897
250964
  copyFileSync2(params.sourcePath, localPath);
250898
250965
  const attachment = {
250899
250966
  id: params.attachment.id ?? undefined,
@@ -251591,7 +251658,7 @@ var init_runtime6 = __esm(() => {
251591
251658
  });
251592
251659
 
251593
251660
  // src/channels/signal/setup-runtime.ts
251594
- import { execFileSync as execFileSync5, spawn as spawn8 } from "node:child_process";
251661
+ import { execFileSync as execFileSync5, spawn as spawn7 } from "node:child_process";
251595
251662
  import { existsSync as existsSync35 } from "node:fs";
251596
251663
  function getSignalDockerRunCommand() {
251597
251664
  return [
@@ -251653,7 +251720,7 @@ function runNativeSignalCli(args) {
251653
251720
  }
251654
251721
  function runNativeSignalCliInteractive(args, onOutput) {
251655
251722
  return new Promise((resolve30) => {
251656
- const child = spawn8("signal-cli", args, {
251723
+ const child = spawn7("signal-cli", args, {
251657
251724
  stdio: ["ignore", "pipe", "pipe"]
251658
251725
  });
251659
251726
  let output = "";
@@ -255117,7 +255184,7 @@ function isString2(value) {
255117
255184
  function isNullableString2(value) {
255118
255185
  return value === null || typeof value === "string";
255119
255186
  }
255120
- function isStringArray3(value) {
255187
+ function isStringArray4(value) {
255121
255188
  return Array.isArray(value) && value.every((entry) => typeof entry === "string");
255122
255189
  }
255123
255190
  function isDiscordChannelMode(value) {
@@ -255131,7 +255198,7 @@ function isModeMap2(value) {
255131
255198
  return Object.values(record5).every(isDiscordChannelMode);
255132
255199
  }
255133
255200
  function isAllowedChannels(value) {
255134
- return isStringArray3(value) || isModeMap2(value);
255201
+ return isStringArray4(value) || isModeMap2(value);
255135
255202
  }
255136
255203
  function isDefaultPermissionMode(value) {
255137
255204
  return value === "standard" || value === "acceptEdits" || value === "unrestricted" || value === "default" || value === "bypassPermissions" || value === "fullAccess";
@@ -255232,7 +255299,7 @@ function isNullableString3(value) {
255232
255299
  function isBoolean2(value) {
255233
255300
  return typeof value === "boolean";
255234
255301
  }
255235
- function isStringArray4(value) {
255302
+ function isStringArray5(value) {
255236
255303
  return Array.isArray(value) && value.every((entry) => typeof entry === "string");
255237
255304
  }
255238
255305
  function isStringRecord(value) {
@@ -255274,7 +255341,7 @@ var init_account_config3 = __esm(() => {
255274
255341
  return false;
255275
255342
  }
255276
255343
  }
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));
255344
+ 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
255345
  },
255279
255346
  toAccountPatch(config3) {
255280
255347
  return {
@@ -255284,8 +255351,8 @@ var init_account_config3 = __esm(() => {
255284
255351
  agentId: isNullableString3(config3.agent_id) ? config3.agent_id : undefined,
255285
255352
  selfChatMode: isBoolean2(config3.self_chat_mode) ? config3.self_chat_mode : undefined,
255286
255353
  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,
255354
+ allowedGroups: isStringArray5(config3.allowed_groups) ? [...config3.allowed_groups] : undefined,
255355
+ mentionPatterns: isStringArray5(config3.mention_patterns) ? [...config3.mention_patterns] : undefined,
255289
255356
  recipientAliases: isStringRecord(config3.recipient_aliases) ? { ...config3.recipient_aliases } : undefined,
255290
255357
  transcribeVoice: isBoolean2(config3.transcribe_voice) ? config3.transcribe_voice : undefined,
255291
255358
  downloadMedia: isBoolean2(config3.download_media) ? config3.download_media : undefined,
@@ -255340,7 +255407,7 @@ function isNullableString4(value) {
255340
255407
  function isBoolean3(value) {
255341
255408
  return value === true || value === false;
255342
255409
  }
255343
- function isStringArray5(value) {
255410
+ function isStringArray6(value) {
255344
255411
  return Array.isArray(value) && value.every(isString3);
255345
255412
  }
255346
255413
  function isDefaultPermissionMode2(value) {
@@ -255369,7 +255436,7 @@ var init_account_config4 = __esm(() => {
255369
255436
  return false;
255370
255437
  }
255371
255438
  }
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);
255439
+ 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
255440
  },
255374
255441
  toAccountPatch(config3) {
255375
255442
  return {
@@ -255380,7 +255447,7 @@ var init_account_config4 = __esm(() => {
255380
255447
  defaultPermissionMode: isDefaultPermissionMode2(config3.default_permission_mode) ? migratePermissionMode(config3.default_permission_mode) : undefined,
255381
255448
  transcribeVoice: isBoolean3(config3.transcribe_voice) ? config3.transcribe_voice : undefined,
255382
255449
  listenMode: isBoolean3(config3.listen_mode) ? config3.listen_mode : undefined,
255383
- mentionOnlyChannels: isStringArray5(config3.mention_only_channels) ? [...config3.mention_only_channels] : undefined,
255450
+ mentionOnlyChannels: isStringArray6(config3.mention_only_channels) ? [...config3.mention_only_channels] : undefined,
255384
255451
  allowBots: config3.allow_bots !== undefined && isValidSlackAllowBotsConfigValue(config3.allow_bots) ? normalizeSlackAllowBotsMode(config3.allow_bots) : undefined
255385
255452
  };
255386
255453
  },
@@ -255496,7 +255563,7 @@ function isNullableString5(value) {
255496
255563
  function isBoolean5(value) {
255497
255564
  return typeof value === "boolean";
255498
255565
  }
255499
- function isStringArray6(value) {
255566
+ function isStringArray7(value) {
255500
255567
  return Array.isArray(value) && value.every((entry) => typeof entry === "string");
255501
255568
  }
255502
255569
  function isGroupMode3(value) {
@@ -255542,22 +255609,22 @@ var init_account_config6 = __esm(() => {
255542
255609
  return false;
255543
255610
  }
255544
255611
  }
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));
255612
+ 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
255613
  },
255547
255614
  toAccountPatch(config3) {
255548
255615
  return {
255549
255616
  agentId: isNullableString5(config3.agent_id) ? config3.agent_id : undefined,
255550
255617
  selfChatMode: isBoolean5(config3.self_chat_mode) ? config3.self_chat_mode : undefined,
255551
255618
  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,
255619
+ allowedGroups: isStringArray7(config3.allowed_groups) ? [...config3.allowed_groups] : undefined,
255620
+ mentionPatterns: isStringArray7(config3.mention_patterns) ? [...config3.mention_patterns] : undefined,
255554
255621
  transcribeVoice: isBoolean5(config3.transcribe_voice) ? config3.transcribe_voice : undefined,
255555
255622
  downloadMedia: isBoolean5(config3.download_media) ? config3.download_media : undefined,
255556
255623
  mediaMaxBytes: isPositiveNumber2(config3.media_max_bytes) ? config3.media_max_bytes : undefined,
255557
255624
  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,
255625
+ attachmentMimeTypes: isStringArray7(config3.attachment_mime_types) ? [...config3.attachment_mime_types] : undefined,
255626
+ attachmentAllowedRecipients: isStringArray7(config3.attachment_allowed_recipients) ? [...config3.attachment_allowed_recipients] : undefined,
255627
+ attachmentAllowedPaths: isStringArray7(config3.attachment_allowed_paths) ? [...config3.attachment_allowed_paths] : undefined,
255561
255628
  attachmentPathRecursive: isBoolean5(config3.attachment_path_recursive) ? config3.attachment_path_recursive : undefined,
255562
255629
  inboundDebounceMs: isValidInboundDebounceMs(config3.inbound_debounce_ms) ? Math.trunc(Math.min(config3.inbound_debounce_ms, 1e4)) : undefined,
255563
255630
  waitingBehavior: isWaitingBehavior(config3.waiting_behavior) ? config3.waiting_behavior : undefined,
@@ -256427,10 +256494,10 @@ var init_service_snapshots = __esm(() => {
256427
256494
  });
256428
256495
 
256429
256496
  // src/channels/service-accounts.ts
256430
- import { randomUUID as randomUUID23 } from "node:crypto";
256497
+ import { randomUUID as randomUUID24 } from "node:crypto";
256431
256498
  function createChannelAccountLive(channelId, patch2, options3) {
256432
256499
  assertSupportedChannelId(channelId);
256433
- const accountId = options3?.accountId?.trim() || randomUUID23();
256500
+ const accountId = options3?.accountId?.trim() || randomUUID24();
256434
256501
  const existing = getChannelAccount(channelId, accountId);
256435
256502
  if (existing) {
256436
256503
  throw new Error(`Channel account "${accountId}" already exists for ${channelId}.`);
@@ -256440,7 +256507,7 @@ function createChannelAccountLive(channelId, patch2, options3) {
256440
256507
  }
256441
256508
  async function createChannelAccountLiveWithSecrets(channelId, patch2, options3) {
256442
256509
  assertSupportedChannelId(channelId);
256443
- const accountId = options3?.accountId?.trim() || randomUUID23();
256510
+ const accountId = options3?.accountId?.trim() || randomUUID24();
256444
256511
  const existing = await getChannelAccountWithSecrets(channelId, accountId);
256445
256512
  if (existing) {
256446
256513
  throw new Error(`Channel account "${accountId}" already exists for ${channelId}.`);
@@ -258891,7 +258958,11 @@ Provider '${providerName}' saved.`);
258891
258958
  if (provider.target !== "local") {
258892
258959
  await io.ensureSettingsReady();
258893
258960
  }
258894
- await io.checkProviderApiKey(provider.byokProvider.providerType, apiKey);
258961
+ if (hasConnectionOptions(connectionOptions)) {
258962
+ await io.checkProviderApiKey(provider.byokProvider.providerType, apiKey, undefined, undefined, undefined, { connection: connectionOptions });
258963
+ } else {
258964
+ await io.checkProviderApiKey(provider.byokProvider.providerType, apiKey);
258965
+ }
258895
258966
  io.stdout("Saving provider...");
258896
258967
  if (hasConnectionOptions(connectionOptions)) {
258897
258968
  await io.createOrUpdateProvider(provider.byokProvider.providerType, provider.byokProvider.providerName, apiKey, undefined, undefined, undefined, connectionOptions);
@@ -269623,9 +269694,9 @@ function validateTranscript(value, options3) {
269623
269694
  if (typeof record5.source !== "string" || !record5.source) {
269624
269695
  fail2(`Record ${index}: meta.source must be a non-empty string.`);
269625
269696
  }
269626
- optionalString3(record5, "cwd", index);
269627
- optionalString3(record5, "git_branch", index);
269628
- optionalString3(record5, "model", index);
269697
+ optionalString4(record5, "cwd", index);
269698
+ optionalString4(record5, "git_branch", index);
269699
+ optionalString4(record5, "model", index);
269629
269700
  continue;
269630
269701
  }
269631
269702
  validateTimestamp(record5.timestamp, index);
@@ -269726,7 +269797,7 @@ function exactKeys(value, allowed, recordIndex, label = "record") {
269726
269797
  if (extra)
269727
269798
  fail2(`Record ${recordIndex}: unexpected ${label} field ${JSON.stringify(extra)}.`);
269728
269799
  }
269729
- function optionalString3(value, key2, recordIndex) {
269800
+ function optionalString4(value, key2, recordIndex) {
269730
269801
  if (key2 in value && typeof value[key2] !== "string") {
269731
269802
  fail2(`Record ${recordIndex}: ${key2} must be a string when present.`);
269732
269803
  }
@@ -270330,7 +270401,7 @@ var init_core5 = __esm(() => {
270330
270401
  });
270331
270402
 
270332
270403
  // node_modules/@letta-ai/trajectory/dist/adapters/deepagents/index.js
270333
- import { spawn as spawn9 } from "node:child_process";
270404
+ import { spawn as spawn8 } from "node:child_process";
270334
270405
  import { accessSync as accessSync2, constants as constants5 } from "node:fs";
270335
270406
  import { homedir as homedir27 } from "node:os";
270336
270407
  import { join as join48 } from "node:path";
@@ -270361,7 +270432,7 @@ async function loadDeepAgentsCheckpoint(checkpoint2) {
270361
270432
  const python = checkpoint2.pythonExecutable ?? process.env.PYTHON ?? "python3";
270362
270433
  const helper = resolveHelperPath();
270363
270434
  return await new Promise((resolve31, reject) => {
270364
- const child = spawn9(python, [helper], {
270435
+ const child = spawn8(python, [helper], {
270365
270436
  stdio: ["pipe", "pipe", "pipe"],
270366
270437
  windowsHide: true
270367
270438
  });
@@ -272736,7 +272807,7 @@ var init_dream_targets = __esm(() => {
272736
272807
 
272737
272808
  // src/agent/memory-worktree.ts
272738
272809
  import { execFile as execFileCb4 } from "node:child_process";
272739
- import { randomUUID as randomUUID24 } from "node:crypto";
272810
+ import { randomUUID as randomUUID25 } from "node:crypto";
272740
272811
  import { existsSync as existsSync42 } from "node:fs";
272741
272812
  import { mkdir as mkdir13 } from "node:fs/promises";
272742
272813
  import { dirname as dirname26, isAbsolute as isAbsolute25, join as join60, resolve as resolve31 } from "node:path";
@@ -272780,7 +272851,7 @@ function normalizeGitPath(path32, cwd2) {
272780
272851
  }
272781
272852
  function buildReflectionWorktreeId(now = new Date) {
272782
272853
  const timestamp = now.toISOString().replace(/[^0-9]/g, "").slice(0, 14);
272783
- return `${timestamp}-${randomUUID24().slice(0, 8)}`;
272854
+ return `${timestamp}-${randomUUID25().slice(0, 8)}`;
272784
272855
  }
272785
272856
  function summarizeReflectionCommitSubject(subject) {
272786
272857
  const summary = subject.trim().replace(/^[a-z]+(?:\([^)]+\))?!?:\s*/i, "").trim();
@@ -273162,7 +273233,7 @@ ${instructions}
273162
273233
  }
273163
273234
 
273164
273235
  // src/telemetry/reflection-threshold-feedback.ts
273165
- import { randomUUID as randomUUID25 } from "node:crypto";
273236
+ import { randomUUID as randomUUID26 } from "node:crypto";
273166
273237
  async function resolveFeedbackApiKey() {
273167
273238
  const settings3 = await settingsManager.getSettingsWithSecureTokens();
273168
273239
  return process.env.LETTA_API_KEY || settings3.env?.LETTA_API_KEY;
@@ -273174,7 +273245,7 @@ function getFeedbackDeviceId() {
273174
273245
  return deviceId;
273175
273246
  }
273176
273247
  } catch {}
273177
- return randomUUID25();
273248
+ return randomUUID26();
273178
273249
  }
273179
273250
  function getAlertDeviceType() {
273180
273251
  switch (process.platform) {
@@ -276402,7 +276473,7 @@ var init_auth = __esm(() => {
276402
276473
  });
276403
276474
 
276404
276475
  // src/websocket/listener/manual-instance-lock.ts
276405
- import { createHash as createHash7, randomUUID as randomUUID26 } from "node:crypto";
276476
+ import { createHash as createHash7, randomUUID as randomUUID27 } from "node:crypto";
276406
276477
  import { link as link3, mkdir as mkdir14, readFile as readFile20, rm as rm9, unlink as unlink5, writeFile as writeFile15 } from "node:fs/promises";
276407
276478
  import { homedir as homedir36 } from "node:os";
276408
276479
  import path32 from "node:path";
@@ -276453,7 +276524,7 @@ function parseLockRecord(raw2, expectedScopeHash) {
276453
276524
  }
276454
276525
  }
276455
276526
  async function publishInitializedFile(targetPath, contents) {
276456
- const candidatePath = path32.join(path32.dirname(targetPath), `.manual-listener-lock-${randomUUID26()}.candidate`);
276527
+ const candidatePath = path32.join(path32.dirname(targetPath), `.manual-listener-lock-${randomUUID27()}.candidate`);
276457
276528
  let publicationError;
276458
276529
  try {
276459
276530
  await writeFile15(candidatePath, contents, { flag: "wx" });
@@ -276530,7 +276601,7 @@ async function acquireManualListenerLock(scope, overrides = {}) {
276530
276601
  const deps = {
276531
276602
  lockRoot: getDefaultLockRoot(),
276532
276603
  processId: process.pid,
276533
- ownerToken: randomUUID26(),
276604
+ ownerToken: randomUUID27(),
276534
276605
  isProcessAlive: defaultIsProcessAlive2,
276535
276606
  ...overrides
276536
276607
  };
@@ -277045,13 +277116,13 @@ function isExternalToolCallResponseCommand(value) {
277045
277116
  function isExperimentId(value) {
277046
277117
  return typeof value === "string" && EXPERIMENT_IDS.has(value);
277047
277118
  }
277048
- function isStringArray7(value) {
277119
+ function isStringArray8(value) {
277049
277120
  return Array.isArray(value) && value.every((item) => typeof item === "string");
277050
277121
  }
277051
277122
  function isClientToolsetConfig(value) {
277052
277123
  if (!isObjectRecord2(value))
277053
277124
  return false;
277054
- return (value.base === undefined || typeof value.base === "string" && TOOLSET_PREFERENCES.has(value.base)) && (value.include === undefined || isStringArray7(value.include));
277125
+ return (value.base === undefined || typeof value.base === "string" && TOOLSET_PREFERENCES.has(value.base)) && (value.include === undefined || isStringArray8(value.include));
277055
277126
  }
277056
277127
  function isStringRecord2(value) {
277057
277128
  return !!value && typeof value === "object" && !Array.isArray(value) && Object.values(value).every((item) => typeof item === "string");
@@ -277082,7 +277153,7 @@ function isInputCommand(value) {
277082
277153
  }
277083
277154
  const payload = candidate.payload;
277084
277155
  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");
277156
+ 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
277157
  }
277087
277158
  if (payload.kind === "approval_response") {
277088
277159
  return isValidApprovalResponseBody(payload);
@@ -277107,9 +277178,9 @@ function legacyEnvironmentMessageToInputCommand(value) {
277107
277178
  payload: {
277108
277179
  kind: "create_message",
277109
277180
  messages: candidate.messages,
277110
- client_tool_allowlist: isStringArray7(candidate.clientToolAllowlist) ? candidate.clientToolAllowlist : undefined,
277181
+ client_tool_allowlist: isStringArray8(candidate.clientToolAllowlist) ? candidate.clientToolAllowlist : undefined,
277111
277182
  client_toolset: isClientToolsetConfig(candidate.clientToolset) ? candidate.clientToolset : undefined,
277112
- external_tool_scope_ids: isStringArray7(candidate.externalToolScopeIds) ? candidate.externalToolScopeIds : undefined
277183
+ external_tool_scope_ids: isStringArray8(candidate.externalToolScopeIds) ? candidate.externalToolScopeIds : undefined
277113
277184
  }
277114
277185
  };
277115
277186
  }
@@ -277141,7 +277212,7 @@ function getInvalidInputReason(value) {
277141
277212
  reason: "Protocol violation: input.payload.image_failure_mode must be strict or drop"
277142
277213
  };
277143
277214
  }
277144
- if (payload.client_tool_allowlist !== undefined && !isStringArray7(payload.client_tool_allowlist)) {
277215
+ if (payload.client_tool_allowlist !== undefined && !isStringArray8(payload.client_tool_allowlist)) {
277145
277216
  return {
277146
277217
  runtime: candidate.runtime,
277147
277218
  reason: "Protocol violation: input.payload.client_tool_allowlist must be string[]"
@@ -277159,7 +277230,7 @@ function getInvalidInputReason(value) {
277159
277230
  reason: "Protocol violation: input.payload.exclude_interactive_tools must be boolean"
277160
277231
  };
277161
277232
  }
277162
- if (payload.external_tool_scope_ids !== undefined && !isStringArray7(payload.external_tool_scope_ids)) {
277233
+ if (payload.external_tool_scope_ids !== undefined && !isStringArray8(payload.external_tool_scope_ids)) {
277163
277234
  return {
277164
277235
  runtime: candidate.runtime,
277165
277236
  reason: "Protocol violation: input.payload.external_tool_scope_ids must be string[]"
@@ -277240,7 +277311,7 @@ function isRuntimeStartCommand(value) {
277240
277311
  if (!value || typeof value !== "object")
277241
277312
  return false;
277242
277313
  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));
277314
+ 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
277315
  }
277245
277316
  function isTerminalSpawnCommand(value) {
277246
277317
  if (!value || typeof value !== "object")
@@ -277494,7 +277565,7 @@ function isCreateAgentCommand(value) {
277494
277565
  if (!value || typeof value !== "object")
277495
277566
  return false;
277496
277567
  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");
277568
+ 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
277569
  }
277499
277570
  function isAgentListCommand(value) {
277500
277571
  if (!value || typeof value !== "object")
@@ -455424,7 +455495,7 @@ var init_approval_suggestions = __esm(async () => {
455424
455495
  function isRecord12(value) {
455425
455496
  return typeof value === "object" && value !== null && !Array.isArray(value);
455426
455497
  }
455427
- function optionalString4(value) {
455498
+ function optionalString5(value) {
455428
455499
  return typeof value === "string" && value.length > 0 ? value : null;
455429
455500
  }
455430
455501
  function parseCloudRetryMessage(value) {
@@ -455445,11 +455516,11 @@ function parseCloudRetryMessage(value) {
455445
455516
  maxAttempts,
455446
455517
  delayMs,
455447
455518
  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)
455519
+ fromTransport: optionalString5(value.from_transport),
455520
+ toTransport: optionalString5(value.to_transport),
455521
+ errorCode: optionalString5(value.error_code),
455522
+ runId: optionalString5(value.run_id),
455523
+ stepId: optionalString5(value.step_id)
455453
455524
  };
455454
455525
  }
455455
455526
  function normalizeCloudRetryWireMessage(value) {
@@ -463998,7 +464069,7 @@ var init_mod_commands = __esm(async () => {
463998
464069
  });
463999
464070
 
464000
464071
  // src/websocket/listener/commands.ts
464001
- import { spawn as spawn10 } from "node:child_process";
464072
+ import { spawn as spawn9 } from "node:child_process";
464002
464073
  async function handleExecuteCommand(command, socket, conversationRuntime, opts) {
464003
464074
  const scope = {
464004
464075
  agent_id: conversationRuntime.agentId,
@@ -464205,7 +464276,7 @@ function scheduleRemoteRestart(connectionName, log2) {
464205
464276
  setTimeout(async () => {
464206
464277
  await flushRemoteSettingsWrites();
464207
464278
  log2(`spawning replacement listener: ${process.execPath} ${entrypoint} remote --env-name ${connectionName}`);
464208
- const child = spawn10(process.execPath, [entrypoint, "remote", "--env-name", connectionName], {
464279
+ const child = spawn9(process.execPath, [entrypoint, "remote", "--env-name", connectionName], {
464209
464280
  cwd: process.cwd(),
464210
464281
  detached: true,
464211
464282
  env: process.env,
@@ -468706,7 +468777,7 @@ function createToolLifecycleTracker(onEvent) {
468706
468777
  }
468707
468778
 
468708
468779
  // src/websocket/app-server-openai-turn.ts
468709
- import { randomUUID as randomUUID27 } from "node:crypto";
468780
+ import { randomUUID as randomUUID28 } from "node:crypto";
468710
468781
  function runBridgeTurn(params) {
468711
468782
  return runTurnImpl(params);
468712
468783
  }
@@ -468725,7 +468796,7 @@ async function ensureListenerRuntime(onLog) {
468725
468796
  if (active && !active.intentionallyClosed)
468726
468797
  return active;
468727
468798
  bridgeRuntimeStart ??= startLocalChannelListener({
468728
- connectionId: `openai-api-${randomUUID27()}`,
468799
+ connectionId: `openai-api-${randomUUID28()}`,
468729
468800
  deviceId: settingsManager.getOrCreateDeviceId(),
468730
468801
  connectionName: "openai-api",
468731
468802
  onConnected: () => {},
@@ -468934,11 +469005,11 @@ var init_app_server_openai_turn = __esm(async () => {
468934
469005
  });
468935
469006
 
468936
469007
  // src/websocket/app-server-openai-responses.ts
468937
- import { randomUUID as randomUUID28 } from "node:crypto";
469008
+ import { randomUUID as randomUUID29 } from "node:crypto";
468938
469009
  function createStoredResponseId(state) {
468939
469010
  const cursor = Buffer.from(JSON.stringify({
468940
469011
  version: 1,
468941
- nonce: randomUUID28(),
469012
+ nonce: randomUUID29(),
468942
469013
  agent_id: state.agentId,
468943
469014
  conversation_id: state.conversationId
468944
469015
  })).toString("base64url");
@@ -468983,7 +469054,7 @@ function toBridgeMessages(messages, stateful) {
468983
469054
  return { messages: [], correlationOtid: null };
468984
469055
  }
468985
469056
  if (stateful) {
468986
- const otid = randomUUID28();
469057
+ const otid = randomUUID29();
468987
469058
  return {
468988
469059
  messages: [{ role: "user", content: lastUserContent, otid }],
468989
469060
  correlationOtid: otid
@@ -469005,7 +469076,7 @@ function toBridgeMessages(messages, stateful) {
469005
469076
  bridgeMessages.push({
469006
469077
  role: message.role,
469007
469078
  content,
469008
- otid: randomUUID28()
469079
+ otid: randomUUID29()
469009
469080
  });
469010
469081
  }
469011
469082
  return {
@@ -469137,7 +469208,7 @@ class ResponseOutputBuilder {
469137
469208
  this.finishText();
469138
469209
  const result = {
469139
469210
  type: "function_call_output",
469140
- id: `fco_${randomUUID28()}`,
469211
+ id: `fco_${randomUUID29()}`,
469141
469212
  call_id: event2.tool_call_id,
469142
469213
  output: [{ type: "input_text", text: event2.output }],
469143
469214
  status: event2.success ? "completed" : "incomplete"
@@ -469222,7 +469293,7 @@ class ResponseOutputBuilder {
469222
469293
  return this.message;
469223
469294
  const item = {
469224
469295
  type: "message",
469225
- id: `msg_${randomUUID28()}`,
469296
+ id: `msg_${randomUUID29()}`,
469226
469297
  status: "in_progress",
469227
469298
  role: "assistant",
469228
469299
  content: [{ type: "output_text", text: "", annotations: [] }]
@@ -469249,7 +469320,7 @@ class ResponseOutputBuilder {
469249
469320
  return this.reasoning;
469250
469321
  const item = {
469251
469322
  type: "reasoning",
469252
- id: `rs_${randomUUID28()}`,
469323
+ id: `rs_${randomUUID29()}`,
469253
469324
  status: "in_progress",
469254
469325
  summary: [{ type: "summary_text", text: "" }]
469255
469326
  };
@@ -469280,7 +469351,7 @@ class ResponseOutputBuilder {
469280
469351
  }
469281
469352
  const item = {
469282
469353
  type: "function_call",
469283
- id: `fc_${randomUUID28()}`,
469354
+ id: `fc_${randomUUID29()}`,
469284
469355
  call_id: callId,
469285
469356
  name,
469286
469357
  arguments: "",
@@ -469385,7 +469456,7 @@ async function handleResponses(request, response, options3) {
469385
469456
  sendOpenAiError(response, 500, "failed to create a conversation for this response", "server_error");
469386
469457
  return;
469387
469458
  }
469388
- const responseId = body3.store === true ? createStoredResponseId({ agentId: agent2.id, conversationId }) : `resp_${randomUUID28()}`;
469459
+ const responseId = body3.store === true ? createStoredResponseId({ agentId: agent2.id, conversationId }) : `resp_${randomUUID29()}`;
469389
469460
  const createdAt = Math.floor(Date.now() / 1000);
469390
469461
  let sequenceNumber = 0;
469391
469462
  let clientClosed = false;
@@ -469475,7 +469546,7 @@ var init_app_server_openai_responses = __esm(async () => {
469475
469546
  });
469476
469547
 
469477
469548
  // src/websocket/app-server-openai.ts
469478
- import { randomUUID as randomUUID29 } from "node:crypto";
469549
+ import { randomUUID as randomUUID30 } from "node:crypto";
469479
469550
  function isOpenAiCompatPath(pathname) {
469480
469551
  return pathname === MODELS_PATH || pathname === CHAT_COMPLETIONS_PATH || pathname === RESPONSES_PATH;
469481
469552
  }
@@ -469544,7 +469615,7 @@ async function handleChatCompletions(request, response, options3) {
469544
469615
  turnMessages.push({
469545
469616
  role: "user",
469546
469617
  content: userContent,
469547
- otid: randomUUID29()
469618
+ otid: randomUUID30()
469548
469619
  });
469549
469620
  } else {
469550
469621
  for (const message of body3.messages) {
@@ -469561,7 +469632,7 @@ async function handleChatCompletions(request, response, options3) {
469561
469632
  }
469562
469633
  if (content.length === 0)
469563
469634
  continue;
469564
- turnMessages.push({ role: message.role, content, otid: randomUUID29() });
469635
+ turnMessages.push({ role: message.role, content, otid: randomUUID30() });
469565
469636
  }
469566
469637
  }
469567
469638
  correlationOtid = turnMessages.at(-1)?.otid ?? null;
@@ -469570,7 +469641,7 @@ async function handleChatCompletions(request, response, options3) {
469570
469641
  return;
469571
469642
  }
469572
469643
  }
469573
- const completionId = `chatcmpl-${randomUUID29()}`;
469644
+ const completionId = `chatcmpl-${randomUUID30()}`;
469574
469645
  const created = Math.floor(Date.now() / 1000);
469575
469646
  const streaming3 = body3.stream === true;
469576
469647
  let clientClosed = false;
@@ -470037,7 +470108,7 @@ __export(exports_gateway_supervisor, {
470037
470108
  startChannelGatewaySupervisor: () => startChannelGatewaySupervisor,
470038
470109
  CHANNEL_GATEWAY_READY_SIGNAL: () => CHANNEL_GATEWAY_READY_SIGNAL
470039
470110
  });
470040
- import { spawn as spawn11 } from "node:child_process";
470111
+ import { spawn as spawn10 } from "node:child_process";
470041
470112
  function resolveLauncher(cwd2) {
470042
470113
  const invocation = resolveLettaInvocation(process.env, process.argv, process.execPath, cwd2);
470043
470114
  if (invocation)
@@ -470082,7 +470153,7 @@ async function startChannelGatewaySupervisor(options3) {
470082
470153
  const launch = () => {
470083
470154
  if (stopping)
470084
470155
  return;
470085
- child = (options3.spawnProcess ?? spawn11)(launcher.command, childArgs, {
470156
+ child = (options3.spawnProcess ?? spawn10)(launcher.command, childArgs, {
470086
470157
  cwd: cwd2,
470087
470158
  env: options3.env ?? process.env,
470088
470159
  stdio: ["pipe", "pipe", "pipe"],
@@ -470852,7 +470923,7 @@ var init_listen = __esm(async () => {
470852
470923
  });
470853
470924
 
470854
470925
  // src/backend/local/transcript-migration.ts
470855
- import { randomUUID as randomUUID30 } from "node:crypto";
470926
+ import { randomUUID as randomUUID31 } from "node:crypto";
470856
470927
  import {
470857
470928
  copyFileSync as copyFileSync3,
470858
470929
  existsSync as existsSync52,
@@ -470892,7 +470963,7 @@ function writeSessionEntryJsonl(path44, messages, input) {
470892
470963
  ...messages.map((message) => {
470893
470964
  const entry = {
470894
470965
  type: "message",
470895
- id: randomUUID30().slice(0, 8),
470966
+ id: randomUUID31().slice(0, 8),
470896
470967
  parentId,
470897
470968
  timestamp: message.metadata?.created_at ?? new Date(message.timestamp).toISOString(),
470898
470969
  message
@@ -472377,7 +472448,7 @@ var init_messages10 = __esm(() => {
472377
472448
  });
472378
472449
 
472379
472450
  // src/mods/package-installer.ts
472380
- import { spawn as spawn12 } from "node:child_process";
472451
+ import { spawn as spawn11 } from "node:child_process";
472381
472452
  import {
472382
472453
  copyFileSync as copyFileSync4,
472383
472454
  existsSync as existsSync55,
@@ -473235,7 +473306,7 @@ var init_package_installer = __esm(() => {
473235
473306
  init_package_registry();
473236
473307
  init_package_manager_spawn();
473237
473308
  SKIPPED_PACKAGE_COPY_NAMES = new Set([".git", "node_modules"]);
473238
- spawnGitInstallProcess = spawn12;
473309
+ spawnGitInstallProcess = spawn11;
473239
473310
  });
473240
473311
 
473241
473312
  // src/mods/package-scaffolder.ts
@@ -482638,7 +482709,7 @@ function resolveListMessagesRoute(listReq, sessionConvId, sessionAgentId) {
482638
482709
  }
482639
482710
 
482640
482711
  // src/agent/bootstrap-handler.ts
482641
- import { randomUUID as randomUUID31 } from "node:crypto";
482712
+ import { randomUUID as randomUUID32 } from "node:crypto";
482642
482713
  async function handleBootstrapSessionState(params) {
482643
482714
  const {
482644
482715
  bootstrapReq,
@@ -482687,7 +482758,7 @@ async function handleBootstrapSessionState(params) {
482687
482758
  response: payload
482688
482759
  },
482689
482760
  session_id: sessionContext.sessionId,
482690
- uuid: randomUUID31()
482761
+ uuid: randomUUID32()
482691
482762
  };
482692
482763
  } catch (err) {
482693
482764
  return {
@@ -482698,14 +482769,14 @@ async function handleBootstrapSessionState(params) {
482698
482769
  error: err instanceof Error ? err.message : "bootstrap_session_state failed"
482699
482770
  },
482700
482771
  session_id: sessionContext.sessionId,
482701
- uuid: randomUUID31()
482772
+ uuid: randomUUID32()
482702
482773
  };
482703
482774
  }
482704
482775
  }
482705
482776
  var init_bootstrap_handler = () => {};
482706
482777
 
482707
482778
  // src/agent/list-messages-handler.ts
482708
- import { randomUUID as randomUUID32 } from "node:crypto";
482779
+ import { randomUUID as randomUUID33 } from "node:crypto";
482709
482780
  async function handleListMessages(params) {
482710
482781
  const {
482711
482782
  listReq,
@@ -482745,7 +482816,7 @@ async function handleListMessages(params) {
482745
482816
  response: payload
482746
482817
  },
482747
482818
  session_id: sessionId,
482748
- uuid: randomUUID32()
482819
+ uuid: randomUUID33()
482749
482820
  };
482750
482821
  } catch (err) {
482751
482822
  return {
@@ -482756,7 +482827,7 @@ async function handleListMessages(params) {
482756
482827
  error: err instanceof Error ? err.message : "list_messages failed"
482757
482828
  },
482758
482829
  session_id: sessionId,
482759
- uuid: randomUUID32()
482830
+ uuid: randomUUID33()
482760
482831
  };
482761
482832
  }
482762
482833
  }
@@ -494380,7 +494451,7 @@ var init_mcp_client = __esm(() => {
494380
494451
  init_streamableHttp();
494381
494452
  DEFAULT_CLIENT_INFO = {
494382
494453
  name: "letta-code",
494383
- version: "0.30.14"
494454
+ version: "0.30.15"
494384
494455
  };
494385
494456
  });
494386
494457
 
@@ -495419,7 +495490,7 @@ __export(exports_headless, {
495419
495490
  decideInterruptAction: () => decideInterruptAction,
495420
495491
  __headlessTestUtils: () => __headlessTestUtils
495421
495492
  });
495422
- import { randomUUID as randomUUID33 } from "node:crypto";
495493
+ import { randomUUID as randomUUID34 } from "node:crypto";
495423
495494
  function trackHeadlessBoundaryError(errorType, error54, context3) {
495424
495495
  trackBoundaryError({
495425
495496
  errorType,
@@ -495441,7 +495512,7 @@ async function reportStartupErrorAndExit(errorType, error54, context3, outputFor
495441
495512
  message,
495442
495513
  stop_reason: "error",
495443
495514
  session_id: "startup",
495444
- uuid: `startup-error-${randomUUID33()}`
495515
+ uuid: `startup-error-${randomUUID34()}`
495445
495516
  };
495446
495517
  await writeWireMessageAsync(errorMsg);
495447
495518
  } else {
@@ -495565,7 +495636,7 @@ async function emitHeadlessTurnStartCancellationOutput(options3) {
495565
495636
  message: options3.reason,
495566
495637
  stop_reason: "cancelled",
495567
495638
  session_id: options3.sessionId,
495568
- uuid: `error-turn-start-cancel-${randomUUID33()}`
495639
+ uuid: `error-turn-start-cancel-${randomUUID34()}`
495569
495640
  };
495570
495641
  await writeWireMessageAsync(errorMsg);
495571
495642
  const resultMsg = {
@@ -495580,7 +495651,7 @@ async function emitHeadlessTurnStartCancellationOutput(options3) {
495580
495651
  conversation_id: options3.conversationId,
495581
495652
  run_ids: [],
495582
495653
  usage: null,
495583
- uuid: `result-turn-start-cancel-${randomUUID33()}`,
495654
+ uuid: `result-turn-start-cancel-${randomUUID34()}`,
495584
495655
  stop_reason: "cancelled"
495585
495656
  };
495586
495657
  await writeWireMessageAsync(resultMsg);
@@ -495609,7 +495680,7 @@ function writeBidirectionalTurnStartCancellation(options3) {
495609
495680
  message: options3.reason,
495610
495681
  stop_reason: "cancelled",
495611
495682
  session_id: options3.sessionId,
495612
- uuid: `error-turn-start-cancel-${randomUUID33()}`
495683
+ uuid: `error-turn-start-cancel-${randomUUID34()}`
495613
495684
  };
495614
495685
  writeWireMessage(errorMsg);
495615
495686
  const resultMsg = {
@@ -495624,7 +495695,7 @@ function writeBidirectionalTurnStartCancellation(options3) {
495624
495695
  conversation_id: options3.conversationId,
495625
495696
  run_ids: [],
495626
495697
  usage: null,
495627
- uuid: `result-turn-start-cancel-${randomUUID33()}`,
495698
+ uuid: `result-turn-start-cancel-${randomUUID34()}`,
495628
495699
  stop_reason: "cancelled"
495629
495700
  };
495630
495701
  writeWireMessage(resultMsg);
@@ -496574,7 +496645,7 @@ Current session AGENT_ID=${process.env.AGENT_ID}; --backend local switches to a
496574
496645
  const approvalInput = {
496575
496646
  type: "approval",
496576
496647
  approvals: denialResults,
496577
- otid: randomUUID33()
496648
+ otid: randomUUID34()
496578
496649
  };
496579
496650
  const approvalMessages = [approvalInput];
496580
496651
  {
@@ -496587,7 +496658,7 @@ Current session AGENT_ID=${process.env.AGENT_ID}; --backend local switches to a
496587
496658
  type: "text",
496588
496659
  text: sc.content
496589
496660
  })),
496590
- otid: randomUUID33()
496661
+ otid: randomUUID34()
496591
496662
  });
496592
496663
  }
496593
496664
  }
@@ -496620,7 +496691,7 @@ Current session AGENT_ID=${process.env.AGENT_ID}; --backend local switches to a
496620
496691
  message: `Failed to resolve pending approvals on resume: ${approvalError instanceof Error ? approvalError.message : String(approvalError)}`,
496621
496692
  stop_reason: "error",
496622
496693
  session_id: sessionId,
496623
- uuid: `error-pre-loop-approval-${randomUUID33()}`
496694
+ uuid: `error-pre-loop-approval-${randomUUID34()}`
496624
496695
  };
496625
496696
  writeWireMessage(errorMsg);
496626
496697
  } else {
@@ -496768,8 +496839,8 @@ ${loadedContents.join(`
496768
496839
  {
496769
496840
  role: "user",
496770
496841
  content: contentParts,
496771
- client_message_id: randomUUID33(),
496772
- otid: randomUUID33()
496842
+ client_message_id: randomUUID34(),
496843
+ otid: randomUUID34()
496773
496844
  }
496774
496845
  ]
496775
496846
  });
@@ -496826,7 +496897,7 @@ ${loadedContents.join(`
496826
496897
  {
496827
496898
  role: "user",
496828
496899
  content: contentParts,
496829
- otid: randomUUID33()
496900
+ otid: randomUUID34()
496830
496901
  }
496831
496902
  ];
496832
496903
  const recoveredApprovalResults = queuedRecoveredApprovalResults ?? [];
@@ -496835,7 +496906,7 @@ ${loadedContents.join(`
496835
496906
  {
496836
496907
  type: "approval",
496837
496908
  approvals: recoveredApprovalResults,
496838
- otid: randomUUID33()
496909
+ otid: randomUUID34()
496839
496910
  },
496840
496911
  ...currentInput
496841
496912
  ];
@@ -496882,7 +496953,7 @@ ${loadedContents.join(`
496882
496953
  message: `Maximum turns limit reached (${buffers.usage.stepCount}/${maxTurns} steps)`,
496883
496954
  stop_reason: "max_steps",
496884
496955
  session_id: sessionId,
496885
- uuid: `error-max-turns-${randomUUID33()}`
496956
+ uuid: `error-max-turns-${randomUUID34()}`
496886
496957
  };
496887
496958
  await writeWireMessageAsync(errorMsg);
496888
496959
  } else {
@@ -496899,7 +496970,7 @@ ${loadedContents.join(`
496899
496970
  message: "Interrupted by SIGINT",
496900
496971
  stop_reason: "cancelled",
496901
496972
  session_id: sessionId,
496902
- uuid: `error-interrupted-${randomUUID33()}`
496973
+ uuid: `error-interrupted-${randomUUID34()}`
496903
496974
  };
496904
496975
  await writeWireMessageAsync(errorMsg);
496905
496976
  } else {
@@ -496928,7 +496999,7 @@ ${loadedContents.join(`
496928
496999
  type: "text",
496929
497000
  text: sc.content
496930
497001
  })),
496931
- otid: randomUUID33()
497002
+ otid: randomUUID34()
496932
497003
  }
496933
497004
  ];
496934
497005
  }
@@ -496974,7 +497045,7 @@ ${loadedContents.join(`
496974
497045
  recovery_type: "approval_pending",
496975
497046
  message: "Detected pending approval conflict on send; resolving before retry",
496976
497047
  session_id: sessionId,
496977
- uuid: `recovery-pre-stream-${randomUUID33()}`
497048
+ uuid: `recovery-pre-stream-${randomUUID34()}`
496978
497049
  };
496979
497050
  writeWireMessage(recoveryMsg);
496980
497051
  } else {
@@ -497007,7 +497078,7 @@ ${loadedContents.join(`
497007
497078
  max_attempts: CONVERSATION_BUSY_MAX_RETRIES,
497008
497079
  delay_ms: retryDelayMs,
497009
497080
  session_id: sessionId,
497010
- uuid: `retry-conversation-busy-${randomUUID33()}`
497081
+ uuid: `retry-conversation-busy-${randomUUID34()}`
497011
497082
  };
497012
497083
  writeWireMessage(retryMsg);
497013
497084
  } else {
@@ -497031,7 +497102,7 @@ ${loadedContents.join(`
497031
497102
  type: "status",
497032
497103
  message: "Anthropic API error; falling back to Bedrock...",
497033
497104
  session_id: sessionId,
497034
- uuid: `fallback-${randomUUID33()}`
497105
+ uuid: `fallback-${randomUUID34()}`
497035
497106
  }));
497036
497107
  } else {
497037
497108
  console.error("Anthropic API error; falling back to Bedrock...");
@@ -497055,7 +497126,7 @@ ${loadedContents.join(`
497055
497126
  max_attempts: LLM_API_ERROR_MAX_RETRIES2,
497056
497127
  delay_ms: delayMs,
497057
497128
  session_id: sessionId,
497058
- uuid: `retry-pre-stream-${randomUUID33()}`
497129
+ uuid: `retry-pre-stream-${randomUUID34()}`
497059
497130
  };
497060
497131
  writeWireMessage(retryMsg);
497061
497132
  } else {
@@ -497081,7 +497152,7 @@ ${loadedContents.join(`
497081
497152
  stop_reason: "error",
497082
497153
  run_id: errorInfo.run_id,
497083
497154
  session_id: sessionId,
497084
- uuid: randomUUID33(),
497155
+ uuid: randomUUID34(),
497085
497156
  ...errorInfo.error_type && errorInfo.run_id && {
497086
497157
  api_error: {
497087
497158
  message_type: "error_message",
@@ -497103,7 +497174,7 @@ ${loadedContents.join(`
497103
497174
  message: "Detected pending approval conflict; auto-denying stale approval and retrying",
497104
497175
  run_id: recoveryRunId ?? undefined,
497105
497176
  session_id: sessionId,
497106
- uuid: `recovery-${recoveryRunId || randomUUID33()}`
497177
+ uuid: `recovery-${recoveryRunId || randomUUID34()}`
497107
497178
  };
497108
497179
  writeWireMessage(recoveryMsg);
497109
497180
  approvalPendingRecovery = true;
@@ -497121,7 +497192,7 @@ ${loadedContents.join(`
497121
497192
  type: "stream_event",
497122
497193
  event: chunk,
497123
497194
  session_id: sessionId,
497124
- uuid: uuid5 || randomUUID33()
497195
+ uuid: uuid5 || randomUUID34()
497125
497196
  };
497126
497197
  writeWireMessage(streamEvent);
497127
497198
  } else {
@@ -497129,7 +497200,7 @@ ${loadedContents.join(`
497129
497200
  type: "message",
497130
497201
  ...chunk,
497131
497202
  session_id: sessionId,
497132
- uuid: uuid5 || randomUUID33()
497203
+ uuid: uuid5 || randomUUID34()
497133
497204
  };
497134
497205
  writeWireMessage(msg);
497135
497206
  }
@@ -497172,7 +497243,7 @@ ${loadedContents.join(`
497172
497243
  {
497173
497244
  role: "user",
497174
497245
  content: continueMessage,
497175
- otid: randomUUID33()
497246
+ otid: randomUUID34()
497176
497247
  }
497177
497248
  ];
497178
497249
  const continueTurnStartEmission = await emitHeadlessTurnStart({
@@ -497244,7 +497315,7 @@ ${loadedContents.join(`
497244
497315
  const approvalInputWithOtid = {
497245
497316
  type: "approval",
497246
497317
  approvals: executedResults,
497247
- otid: randomUUID33()
497318
+ otid: randomUUID34()
497248
497319
  };
497249
497320
  currentInput = [approvalInputWithOtid];
497250
497321
  continue;
@@ -497274,7 +497345,7 @@ ${loadedContents.join(`
497274
497345
  type: "status",
497275
497346
  message: "Anthropic API error; falling back to Bedrock...",
497276
497347
  session_id: sessionId,
497277
- uuid: `fallback-${randomUUID33()}`
497348
+ uuid: `fallback-${randomUUID34()}`
497278
497349
  }));
497279
497350
  } else {
497280
497351
  console.error("Anthropic API error; falling back to Bedrock...");
@@ -497297,7 +497368,7 @@ ${loadedContents.join(`
497297
497368
  delay_ms: delayMs,
497298
497369
  run_id: lastRunId ?? undefined,
497299
497370
  session_id: sessionId,
497300
- uuid: `retry-${lastRunId || randomUUID33()}`
497371
+ uuid: `retry-${lastRunId || randomUUID34()}`
497301
497372
  };
497302
497373
  writeWireMessage(retryMsg);
497303
497374
  } else {
@@ -497318,7 +497389,7 @@ ${loadedContents.join(`
497318
497389
  message: "Tool call ID mismatch; fetching actual pending approvals and resyncing",
497319
497390
  run_id: lastRunId ?? undefined,
497320
497391
  session_id: sessionId,
497321
- uuid: `recovery-${lastRunId || randomUUID33()}`
497392
+ uuid: `recovery-${lastRunId || randomUUID34()}`
497322
497393
  };
497323
497394
  writeWireMessage(recoveryMsg);
497324
497395
  } else {
@@ -497335,7 +497406,7 @@ ${loadedContents.join(`
497335
497406
  stop_reason: stopReason,
497336
497407
  run_id: lastRunId ?? undefined,
497337
497408
  session_id: sessionId,
497338
- uuid: `error-${lastRunId || randomUUID33()}`
497409
+ uuid: `error-${lastRunId || randomUUID34()}`
497339
497410
  };
497340
497411
  await writeWireMessageAsync(errorMsg);
497341
497412
  } else {
@@ -497377,7 +497448,7 @@ ${loadedContents.join(`
497377
497448
  const nudgeMessage = {
497378
497449
  role: "system",
497379
497450
  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()
497451
+ otid: randomUUID34()
497381
497452
  };
497382
497453
  currentInput = [...currentInput, nudgeMessage];
497383
497454
  }
@@ -497390,7 +497461,7 @@ ${loadedContents.join(`
497390
497461
  delay_ms: delayMs,
497391
497462
  run_id: lastRunId ?? undefined,
497392
497463
  session_id: sessionId,
497393
- uuid: `retry-empty-${lastRunId || randomUUID33()}`
497464
+ uuid: `retry-empty-${lastRunId || randomUUID34()}`
497394
497465
  };
497395
497466
  writeWireMessage(retryMsg);
497396
497467
  } else {
@@ -497417,7 +497488,7 @@ ${loadedContents.join(`
497417
497488
  delay_ms: delayMs,
497418
497489
  run_id: lastRunId ?? undefined,
497419
497490
  session_id: sessionId,
497420
- uuid: `retry-${lastRunId || randomUUID33()}`
497491
+ uuid: `retry-${lastRunId || randomUUID34()}`
497421
497492
  };
497422
497493
  writeWireMessage(retryMsg);
497423
497494
  } else {
@@ -497447,7 +497518,7 @@ ${loadedContents.join(`
497447
497518
  delay_ms: delayMs,
497448
497519
  run_id: lastRunId ?? undefined,
497449
497520
  session_id: sessionId,
497450
- uuid: `retry-${lastRunId || randomUUID33()}`
497521
+ uuid: `retry-${lastRunId || randomUUID34()}`
497451
497522
  };
497452
497523
  writeWireMessage(retryMsg);
497453
497524
  } else {
@@ -497496,7 +497567,7 @@ ${loadedContents.join(`
497496
497567
  stop_reason: stopReason,
497497
497568
  run_id: lastRunId ?? undefined,
497498
497569
  session_id: sessionId,
497499
- uuid: `error-${lastRunId || randomUUID33()}`
497570
+ uuid: `error-${lastRunId || randomUUID34()}`
497500
497571
  };
497501
497572
  await writeWireMessageAsync(errorMsg);
497502
497573
  } else {
@@ -497515,7 +497586,7 @@ ${loadedContents.join(`
497515
497586
  stop_reason: "error",
497516
497587
  run_id: lastKnownRunId ?? undefined,
497517
497588
  session_id: sessionId,
497518
- uuid: `error-${lastKnownRunId || randomUUID33()}`
497589
+ uuid: `error-${lastKnownRunId || randomUUID34()}`
497519
497590
  };
497520
497591
  await writeWireMessageAsync(errorMsg);
497521
497592
  } else {
@@ -497712,7 +497783,7 @@ async function runBidirectionalMode(agent2, conversationId, _outputFormat, inclu
497712
497783
  const approvalInput = {
497713
497784
  type: "approval",
497714
497785
  approvals: denialResults,
497715
- otid: randomUUID33()
497786
+ otid: randomUUID34()
497716
497787
  };
497717
497788
  const approvalMessages = [approvalInput];
497718
497789
  {
@@ -497725,7 +497796,7 @@ async function runBidirectionalMode(agent2, conversationId, _outputFormat, inclu
497725
497796
  type: "text",
497726
497797
  text: sc.content
497727
497798
  })),
497728
- otid: randomUUID33()
497799
+ otid: randomUUID34()
497729
497800
  });
497730
497801
  }
497731
497802
  }
@@ -497783,7 +497854,7 @@ async function runBidirectionalMode(agent2, conversationId, _outputFormat, inclu
497783
497854
  reason,
497784
497855
  cleared_count: clearedCount,
497785
497856
  session_id: sessionId,
497786
- uuid: `q-clr-${randomUUID33()}`
497857
+ uuid: `q-clr-${randomUUID34()}`
497787
497858
  })
497788
497859
  }
497789
497860
  });
@@ -497813,7 +497884,7 @@ async function runBidirectionalMode(agent2, conversationId, _outputFormat, inclu
497813
497884
  reason: "runtime_busy",
497814
497885
  queue_len: Math.max(1, queueLen),
497815
497886
  session_id: sessionId,
497816
- uuid: `q-blk-${randomUUID33()}`
497887
+ uuid: `q-blk-${randomUUID34()}`
497817
497888
  });
497818
497889
  }
497819
497890
  function enqueueForTracking(input) {
@@ -497885,7 +497956,7 @@ async function runBidirectionalMode(agent2, conversationId, _outputFormat, inclu
497885
497956
  request_id: interruptRequestId
497886
497957
  },
497887
497958
  session_id: sessionId,
497888
- uuid: randomUUID33()
497959
+ uuid: randomUUID34()
497889
497960
  };
497890
497961
  writeWireMessage(interruptResponse);
497891
497962
  return;
@@ -498022,7 +498093,7 @@ async function runBidirectionalMode(agent2, conversationId, _outputFormat, inclu
498022
498093
  const approvalInput = {
498023
498094
  type: "approval",
498024
498095
  approvals: denialResults,
498025
- otid: randomUUID33()
498096
+ otid: randomUUID34()
498026
498097
  };
498027
498098
  const approvalStream = await sendScopedApprovalMessages({
498028
498099
  agentId: agent2.id,
@@ -498061,7 +498132,7 @@ async function runBidirectionalMode(agent2, conversationId, _outputFormat, inclu
498061
498132
  message: "Invalid JSON input",
498062
498133
  stop_reason: "error",
498063
498134
  session_id: sessionId,
498064
- uuid: randomUUID33()
498135
+ uuid: randomUUID34()
498065
498136
  };
498066
498137
  writeWireMessage(errorMsg2);
498067
498138
  continue;
@@ -498087,7 +498158,7 @@ async function runBidirectionalMode(agent2, conversationId, _outputFormat, inclu
498087
498158
  }
498088
498159
  },
498089
498160
  session_id: sessionId,
498090
- uuid: randomUUID33()
498161
+ uuid: randomUUID34()
498091
498162
  };
498092
498163
  writeWireMessage(initResponse);
498093
498164
  } else if (subtype === "interrupt") {
@@ -498104,7 +498175,7 @@ async function runBidirectionalMode(agent2, conversationId, _outputFormat, inclu
498104
498175
  request_id: requestId ?? ""
498105
498176
  },
498106
498177
  session_id: sessionId,
498107
- uuid: randomUUID33()
498178
+ uuid: randomUUID34()
498108
498179
  };
498109
498180
  writeWireMessage(interruptResponse);
498110
498181
  } else if (subtype === "register_external_tools") {
@@ -498152,7 +498223,7 @@ async function runBidirectionalMode(agent2, conversationId, _outputFormat, inclu
498152
498223
  response: { registered: tools.length }
498153
498224
  },
498154
498225
  session_id: sessionId,
498155
- uuid: randomUUID33()
498226
+ uuid: randomUUID34()
498156
498227
  };
498157
498228
  writeWireMessage(registerResponse);
498158
498229
  } else if (subtype === "bootstrap_session_state") {
@@ -498208,7 +498279,7 @@ async function runBidirectionalMode(agent2, conversationId, _outputFormat, inclu
498208
498279
  response: recovery
498209
498280
  },
498210
498281
  session_id: sessionId,
498211
- uuid: randomUUID33()
498282
+ uuid: randomUUID34()
498212
498283
  };
498213
498284
  writeWireMessage(recoveryResponse);
498214
498285
  } catch (error54) {
@@ -498220,7 +498291,7 @@ async function runBidirectionalMode(agent2, conversationId, _outputFormat, inclu
498220
498291
  error: error54 instanceof Error ? error54.message : String(error54)
498221
498292
  },
498222
498293
  session_id: sessionId,
498223
- uuid: randomUUID33()
498294
+ uuid: randomUUID34()
498224
498295
  };
498225
498296
  writeWireMessage(recoveryError);
498226
498297
  }
@@ -498233,7 +498304,7 @@ async function runBidirectionalMode(agent2, conversationId, _outputFormat, inclu
498233
498304
  error: `Unknown control request subtype: ${subtype}`
498234
498305
  },
498235
498306
  session_id: sessionId,
498236
- uuid: randomUUID33()
498307
+ uuid: randomUUID34()
498237
498308
  };
498238
498309
  writeWireMessage(errorResponse);
498239
498310
  }
@@ -498288,7 +498359,7 @@ async function runBidirectionalMode(agent2, conversationId, _outputFormat, inclu
498288
498359
  try {
498289
498360
  const buffers = createBuffers(agent2.id);
498290
498361
  const startTime = performance.now();
498291
- const userOtid = randomUUID33();
498362
+ const userOtid = randomUUID34();
498292
498363
  const userTranscriptText = extractTelemetryInputText(userContent);
498293
498364
  if (userTranscriptText.length > 0) {
498294
498365
  const userLineId = `user-${userOtid}`;
@@ -498409,7 +498480,7 @@ async function runBidirectionalMode(agent2, conversationId, _outputFormat, inclu
498409
498480
  recovery_type: "approval_pending",
498410
498481
  message: "Detected pending approval conflict on send; resolving before retry",
498411
498482
  session_id: sessionId,
498412
- uuid: `recovery-bidir-${randomUUID33()}`
498483
+ uuid: `recovery-bidir-${randomUUID34()}`
498413
498484
  };
498414
498485
  writeWireMessage(recoveryMsg);
498415
498486
  await resolveAllPendingApprovals();
@@ -498432,7 +498503,7 @@ async function runBidirectionalMode(agent2, conversationId, _outputFormat, inclu
498432
498503
  max_attempts: LLM_API_ERROR_MAX_RETRIES2,
498433
498504
  delay_ms: delayMs,
498434
498505
  session_id: sessionId,
498435
- uuid: `retry-bidir-${randomUUID33()}`
498506
+ uuid: `retry-bidir-${randomUUID34()}`
498436
498507
  };
498437
498508
  writeWireMessage(retryMsg);
498438
498509
  await new Promise((resolve36) => setTimeout(resolve36, delayMs));
@@ -498454,7 +498525,7 @@ async function runBidirectionalMode(agent2, conversationId, _outputFormat, inclu
498454
498525
  stop_reason: "error",
498455
498526
  run_id: errorInfo.run_id,
498456
498527
  session_id: sessionId,
498457
- uuid: randomUUID33(),
498528
+ uuid: randomUUID34(),
498458
498529
  ...errorInfo.error_type && errorInfo.run_id && {
498459
498530
  api_error: {
498460
498531
  message_type: "error_message",
@@ -498482,7 +498553,7 @@ async function runBidirectionalMode(agent2, conversationId, _outputFormat, inclu
498482
498553
  type: "stream_event",
498483
498554
  event: chunk,
498484
498555
  session_id: sessionId,
498485
- uuid: uuid5 || randomUUID33()
498556
+ uuid: uuid5 || randomUUID34()
498486
498557
  };
498487
498558
  writeWireMessage(streamEvent);
498488
498559
  } else {
@@ -498490,7 +498561,7 @@ async function runBidirectionalMode(agent2, conversationId, _outputFormat, inclu
498490
498561
  type: "message",
498491
498562
  ...chunk,
498492
498563
  session_id: sessionId,
498493
- uuid: uuid5 || randomUUID33()
498564
+ uuid: uuid5 || randomUUID34()
498494
498565
  };
498495
498566
  writeWireMessage(msg);
498496
498567
  }
@@ -498556,7 +498627,7 @@ async function runBidirectionalMode(agent2, conversationId, _outputFormat, inclu
498556
498627
  const approvalInputWithOtid = {
498557
498628
  type: "approval",
498558
498629
  approvals: executedResults,
498559
- otid: randomUUID33()
498630
+ otid: randomUUID34()
498560
498631
  };
498561
498632
  currentInput = [approvalInputWithOtid];
498562
498633
  continue;
@@ -498619,7 +498690,7 @@ async function runBidirectionalMode(agent2, conversationId, _outputFormat, inclu
498619
498690
  message: errorDetails,
498620
498691
  stop_reason: "error",
498621
498692
  session_id: sessionId,
498622
- uuid: randomUUID33()
498693
+ uuid: randomUUID34()
498623
498694
  };
498624
498695
  writeWireMessage(errorMsg2);
498625
498696
  const errorResultMsg = {
@@ -498662,7 +498733,7 @@ async function runBidirectionalMode(agent2, conversationId, _outputFormat, inclu
498662
498733
  message: `Unknown message type: ${message.type}`,
498663
498734
  stop_reason: "error",
498664
498735
  session_id: sessionId,
498665
- uuid: randomUUID33()
498736
+ uuid: randomUUID34()
498666
498737
  };
498667
498738
  writeWireMessage(errorMsg);
498668
498739
  }
@@ -500151,7 +500222,7 @@ var init_reflection_arena_hf_upload = __esm(() => {
500151
500222
 
500152
500223
  // src/cli/helpers/reflection-arena.ts
500153
500224
  import { execFile as execFileCb6 } from "node:child_process";
500154
- import { randomInt as randomInt2, randomUUID as randomUUID34 } from "node:crypto";
500225
+ import { randomInt as randomInt2, randomUUID as randomUUID35 } from "node:crypto";
500155
500226
  import { appendFile as appendFile3, mkdir as mkdir19, readFile as readFile30, writeFile as writeFile21 } from "node:fs/promises";
500156
500227
  import { homedir as homedir46 } from "node:os";
500157
500228
  import { join as join82 } from "node:path";
@@ -500525,7 +500596,7 @@ async function startReflectionArenaRun(options3) {
500525
500596
  }
500526
500597
  let releaseReservation = true;
500527
500598
  try {
500528
- const runId = randomUUID34().slice(0, 8);
500599
+ const runId = randomUUID35().slice(0, 8);
500529
500600
  const labels = shuffledLabels();
500530
500601
  const prepared = await Promise.all([
500531
500602
  prepareReflectionMemoryWorktreeLaunch({
@@ -525720,12 +525791,12 @@ var init_ExitStats = __esm(async () => {
525720
525791
  });
525721
525792
 
525722
525793
  // src/cli/app/ids.ts
525723
- import { randomUUID as randomUUID35 } from "node:crypto";
525794
+ import { randomUUID as randomUUID36 } from "node:crypto";
525724
525795
  function uid(prefix) {
525725
525796
  return `${prefix}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
525726
525797
  }
525727
525798
  function createClientOtid() {
525728
- return randomUUID35();
525799
+ return randomUUID36();
525729
525800
  }
525730
525801
  function appendOptimisticUserLine(buffers, text2, otid) {
525731
525802
  if (!text2) {
@@ -542749,7 +542820,7 @@ var init_notifications = __esm(() => {
542749
542820
  });
542750
542821
 
542751
542822
  // src/cli/app/use-approval-flow.ts
542752
- import { randomUUID as randomUUID36 } from "node:crypto";
542823
+ import { randomUUID as randomUUID37 } from "node:crypto";
542753
542824
  function useApprovalFlow(ctx) {
542754
542825
  const {
542755
542826
  abortControllerRef,
@@ -543261,7 +543332,7 @@ function useApprovalFlow(ctx) {
543261
543332
  {
543262
543333
  type: "approval",
543263
543334
  approvals: allResults,
543264
- otid: randomUUID36()
543335
+ otid: randomUUID37()
543265
543336
  }
543266
543337
  ]);
543267
543338
  } catch (error54) {
@@ -544660,7 +544731,7 @@ var init_system_reminders = __esm(() => {
544660
544731
  });
544661
544732
 
544662
544733
  // src/cli/app/use-conversation-loop.ts
544663
- import { randomUUID as randomUUID37 } from "node:crypto";
544734
+ import { randomUUID as randomUUID38 } from "node:crypto";
544664
544735
  function sleep10(ms) {
544665
544736
  return new Promise((resolve39) => setTimeout(resolve39, ms));
544666
544737
  }
@@ -544964,16 +545035,16 @@ function useConversationLoop(ctx) {
544964
545035
  currentInput = [
544965
545036
  ...lastSentInputRef.current.map((m4) => ({
544966
545037
  ...m4,
544967
- otid: randomUUID37()
545038
+ otid: randomUUID38()
544968
545039
  })),
544969
545040
  ...currentInput.map((m4) => m4.type === "message" && m4.role === "user" ? {
544970
545041
  ...m4,
544971
- otid: randomUUID37(),
545042
+ otid: randomUUID38(),
544972
545043
  content: [
544973
545044
  { type: "text", text: INTERRUPT_RECOVERY_ALERT },
544974
545045
  ...typeof m4.content === "string" ? [{ type: "text", text: m4.content }] : Array.isArray(m4.content) ? m4.content : []
544975
545046
  ]
544976
- } : { ...m4, otid: randomUUID37() })
545047
+ } : { ...m4, otid: randomUUID38() })
544977
545048
  ];
544978
545049
  pendingInterruptRecoveryConversationIdRef.current = null;
544979
545050
  lastSentInputRef.current = [
@@ -545012,7 +545083,7 @@ function useConversationLoop(ctx) {
545012
545083
  type: "text",
545013
545084
  text: sc.content
545014
545085
  })),
545015
- otid: randomUUID37()
545086
+ otid: randomUUID38()
545016
545087
  }
545017
545088
  ];
545018
545089
  }
@@ -545392,7 +545463,7 @@ ${feedback}
545392
545463
  });
545393
545464
  buffersRef.current.order.push(statusId);
545394
545465
  refreshDerived();
545395
- const hookMessageOtid = randomUUID37();
545466
+ const hookMessageOtid = randomUUID38();
545396
545467
  setTimeout(() => {
545397
545468
  processConversation([
545398
545469
  {
@@ -545419,7 +545490,7 @@ ${feedback}
545419
545490
  turnEndContinue = undefined;
545420
545491
  }
545421
545492
  if (turnEndContinue) {
545422
- const continueOtid = randomUUID37();
545493
+ const continueOtid = randomUUID38();
545423
545494
  setTimeout(() => {
545424
545495
  processConversation([
545425
545496
  {
@@ -545773,7 +545844,7 @@ ${feedback}
545773
545844
  {
545774
545845
  type: "approval",
545775
545846
  approvals: allResults,
545776
- otid: randomUUID37()
545847
+ otid: randomUUID38()
545777
545848
  }
545778
545849
  ], {
545779
545850
  allowReentry: true,
@@ -545957,7 +546028,7 @@ ${feedback}
545957
546028
  type: "message",
545958
546029
  role: "system",
545959
546030
  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()
546031
+ otid: randomUUID38()
545961
546032
  }
545962
546033
  ];
545963
546034
  }
@@ -546251,7 +546322,7 @@ var init_use_conversation_loop = __esm(async () => {
546251
546322
  });
546252
546323
 
546253
546324
  // src/cli/app/use-conversation-switching.ts
546254
- import { randomUUID as randomUUID38 } from "node:crypto";
546325
+ import { randomUUID as randomUUID39 } from "node:crypto";
546255
546326
  function useConversationSwitching(ctx) {
546256
546327
  const {
546257
546328
  abortControllerRef,
@@ -546326,7 +546397,7 @@ function useConversationSwitching(ctx) {
546326
546397
  {
546327
546398
  role: "user",
546328
546399
  content: question,
546329
- otid: randomUUID38()
546400
+ otid: randomUUID39()
546330
546401
  }
546331
546402
  ];
546332
546403
  let approvalRecoveryRetries = 0;
@@ -547766,7 +547837,7 @@ The deployment target for this project is CITATION-DOGFOOD-OK.
547766
547837
  });
547767
547838
 
547768
547839
  // src/mods/learning-harness.ts
547769
- import { spawn as spawn14 } from "node:child_process";
547840
+ import { spawn as spawn13 } from "node:child_process";
547770
547841
  import { access as access3, copyFile as copyFile2, mkdir as mkdir20, readFile as readFile32, writeFile as writeFile22 } from "node:fs/promises";
547771
547842
  import path47 from "node:path";
547772
547843
  function slugify2(value) {
@@ -548706,7 +548777,7 @@ async function writeHistoryArtifacts(params) {
548706
548777
  async function defaultCommandRunner(command, args, options3) {
548707
548778
  const startedAt = Date.now();
548708
548779
  return new Promise((resolve39) => {
548709
- const child = spawn14(command, args, {
548780
+ const child = spawn13(command, args, {
548710
548781
  cwd: options3.cwd,
548711
548782
  env: options3.env,
548712
548783
  stdio: ["ignore", "pipe", "pipe"]
@@ -551842,7 +551913,7 @@ var init_conversation_switch_alert = __esm(() => {
551842
551913
  });
551843
551914
 
551844
551915
  // src/cli/app/use-submit-handler.ts
551845
- import { randomUUID as randomUUID39 } from "node:crypto";
551916
+ import { randomUUID as randomUUID40 } from "node:crypto";
551846
551917
  import { existsSync as existsSync70, readFileSync as readFileSync44, renameSync as renameSync8, writeFileSync as writeFileSync38 } from "node:fs";
551847
551918
  import { tmpdir as tmpdir12 } from "node:os";
551848
551919
  import { join as join91 } from "node:path";
@@ -552263,7 +552334,7 @@ ${SYSTEM_REMINDER_CLOSE}` : "";
552263
552334
  content: buildTextParts(`${SYSTEM_REMINDER_OPEN}
552264
552335
  ${prompt}
552265
552336
  ${SYSTEM_REMINDER_CLOSE}`),
552266
- otid: randomUUID39()
552337
+ otid: randomUUID40()
552267
552338
  }
552268
552339
  ]);
552269
552340
  } catch (error54) {
@@ -552327,7 +552398,7 @@ ${SYSTEM_REMINDER_CLOSE}`),
552327
552398
  type: "message",
552328
552399
  role: "user",
552329
552400
  content: buildTextParts(buildModCommandPrompt(result2)),
552330
- otid: randomUUID39()
552401
+ otid: randomUUID40()
552331
552402
  }
552332
552403
  ]);
552333
552404
  } else if (result2.type === "output") {
@@ -552372,7 +552443,7 @@ ${SYSTEM_REMINDER_CLOSE}`),
552372
552443
  ${SYSTEM_REMINDER_OPEN}
552373
552444
  ${request}
552374
552445
  ${SYSTEM_REMINDER_CLOSE}`),
552375
- otid: randomUUID39()
552446
+ otid: randomUUID40()
552376
552447
  }
552377
552448
  ]);
552378
552449
  } catch (error54) {
@@ -552641,7 +552712,7 @@ ${SYSTEM_REMINDER_CLOSE}`),
552641
552712
  ${SYSTEM_REMINDER_OPEN}
552642
552713
  ${request}
552643
552714
  ${SYSTEM_REMINDER_CLOSE}`),
552644
- otid: randomUUID39()
552715
+ otid: randomUUID40()
552645
552716
  }
552646
552717
  ]);
552647
552718
  } catch (error54) {
@@ -553485,7 +553556,7 @@ ${SYSTEM_REMINDER_CLOSE}`;
553485
553556
  type: "message",
553486
553557
  role: "user",
553487
553558
  content: buildTextParts(skillMessage),
553488
- otid: randomUUID39()
553559
+ otid: randomUUID40()
553489
553560
  }
553490
553561
  ]);
553491
553562
  } catch (error54) {
@@ -553523,7 +553594,7 @@ ${SYSTEM_REMINDER_CLOSE}`;
553523
553594
  type: "message",
553524
553595
  role: "user",
553525
553596
  content: rememberParts,
553526
- otid: randomUUID39()
553597
+ otid: randomUUID40()
553527
553598
  }
553528
553599
  ]);
553529
553600
  } catch (error54) {
@@ -553939,7 +554010,7 @@ Resumed reflection arena choice prompt for run ${run2.runId}.`, true);
553939
554010
  type: "message",
553940
554011
  role: "user",
553941
554012
  content: buildTextParts(initMessage),
553942
- otid: randomUUID39()
554013
+ otid: randomUUID40()
553943
554014
  }
553944
554015
  ]);
553945
554016
  } catch (error54) {
@@ -554106,7 +554177,7 @@ Resumed reflection arena choice prompt for run ${run2.runId}.`, true);
554106
554177
  type: "message",
554107
554178
  role: "user",
554108
554179
  content: buildTextParts(wrapSkillPrompt2(matchedSkill.id, skillContent, userRequest)),
554109
- otid: randomUUID39()
554180
+ otid: randomUUID40()
554110
554181
  }
554111
554182
  ]);
554112
554183
  } catch (error54) {
@@ -554257,7 +554328,7 @@ ${SYSTEM_REMINDER_CLOSE}
554257
554328
  initialInput.push({
554258
554329
  type: "approval",
554259
554330
  approvals: eagerRecoveryDenials,
554260
- otid: randomUUID39()
554331
+ otid: randomUUID40()
554261
554332
  });
554262
554333
  }
554263
554334
  const queuedApprovalInput = consumeQueuedApprovalInputForCurrentConversation();
@@ -561664,4 +561735,4 @@ function registerBunOAuthFlows() {
561664
561735
  registerBunOAuthFlows();
561665
561736
  await init_src5().then(() => exports_src2);
561666
561737
 
561667
- //# debugId=59AB0103DFD2BC9664756E2164756E21
561738
+ //# debugId=2F7E57BB5188C34664756E2164756E21