@letta-ai/letta-code 0.22.3 → 0.22.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/letta.js +631 -543
  2. package/package.json +1 -1
package/letta.js CHANGED
@@ -3269,7 +3269,7 @@ var package_default;
3269
3269
  var init_package = __esm(() => {
3270
3270
  package_default = {
3271
3271
  name: "@letta-ai/letta-code",
3272
- version: "0.22.3",
3272
+ version: "0.22.4",
3273
3273
  description: "Letta Code is a CLI tool for interacting with stateful Letta agents from the terminal.",
3274
3274
  type: "module",
3275
3275
  bin: {
@@ -3388,6 +3388,29 @@ function isDuplicateKeychainItemError(error) {
3388
3388
  const message = getErrorMessage(error);
3389
3389
  return message.includes("already exists in the keychain") || message.includes("code: -25299");
3390
3390
  }
3391
+ async function getSecretValue(name, label) {
3392
+ if (!secretsAvailable && !secretGetOverrideForTests) {
3393
+ return null;
3394
+ }
3395
+ try {
3396
+ const options = {
3397
+ service: SERVICE_NAME,
3398
+ name
3399
+ };
3400
+ const value = secretGetOverrideForTests ? await secretGetOverrideForTests(options) : await secrets.get(options);
3401
+ warnedSecretReadFailures.delete(name);
3402
+ return value;
3403
+ } catch (error) {
3404
+ const message = `Failed to retrieve ${label} from secrets: ${error}`;
3405
+ if (!warnedSecretReadFailures.has(name)) {
3406
+ warnedSecretReadFailures.add(name);
3407
+ console.warn(message);
3408
+ } else {
3409
+ debugWarn("secrets", message);
3410
+ }
3411
+ return null;
3412
+ }
3413
+ }
3391
3414
  async function setSecretValue(name, value) {
3392
3415
  if (!secretsAvailable) {
3393
3416
  throw new Error("Secrets API unavailable");
@@ -3423,17 +3446,7 @@ async function setApiKey(apiKey) {
3423
3446
  await setSecretValue(API_KEY_NAME, apiKey);
3424
3447
  }
3425
3448
  async function getApiKey() {
3426
- if (secretsAvailable) {
3427
- try {
3428
- return await secrets.get({
3429
- service: SERVICE_NAME,
3430
- name: API_KEY_NAME
3431
- });
3432
- } catch (error) {
3433
- console.warn(`Failed to retrieve API key from secrets: ${error}`);
3434
- }
3435
- }
3436
- return null;
3449
+ return getSecretValue(API_KEY_NAME, "API key");
3437
3450
  }
3438
3451
  async function setRefreshToken(refreshToken) {
3439
3452
  if (!secretsAvailable) {
@@ -3442,17 +3455,7 @@ async function setRefreshToken(refreshToken) {
3442
3455
  await setSecretValue(REFRESH_TOKEN_NAME, refreshToken);
3443
3456
  }
3444
3457
  async function getRefreshToken() {
3445
- if (secretsAvailable) {
3446
- try {
3447
- return await secrets.get({
3448
- service: SERVICE_NAME,
3449
- name: REFRESH_TOKEN_NAME
3450
- });
3451
- } catch (error) {
3452
- console.warn(`Failed to retrieve refresh token from secrets: ${error}`);
3453
- }
3454
- }
3455
- return null;
3458
+ return getSecretValue(REFRESH_TOKEN_NAME, "refresh token");
3456
3459
  }
3457
3460
  async function getSecureTokens() {
3458
3461
  const [apiKey, refreshToken] = await Promise.allSettled([
@@ -3509,6 +3512,9 @@ async function isKeychainAvailable() {
3509
3512
  if (process.env.LETTA_SKIP_KEYCHAIN_CHECK === "1") {
3510
3513
  return false;
3511
3514
  }
3515
+ if (process.platform === "linux" && !process.env.DBUS_SESSION_BUS_ADDRESS?.trim()) {
3516
+ return false;
3517
+ }
3512
3518
  if (!secretsAvailable) {
3513
3519
  return false;
3514
3520
  }
@@ -3522,15 +3528,16 @@ async function isKeychainAvailable() {
3522
3528
  return false;
3523
3529
  }
3524
3530
  }
3525
- var secrets, secretsAvailable = false, SERVICE_NAME = "letta-code", API_KEY_NAME = "letta-api-key", REFRESH_TOKEN_NAME = "letta-refresh-token", keychainAvailablePrecompute;
3526
- var init_secrets = __esm(async () => {
3531
+ var secrets, secretsAvailable = false, SERVICE_NAME = "letta-code", API_KEY_NAME = "letta-api-key", REFRESH_TOKEN_NAME = "letta-refresh-token", warnedSecretReadFailures, secretGetOverrideForTests = null;
3532
+ var init_secrets = __esm(() => {
3533
+ init_debug();
3527
3534
  try {
3528
3535
  secrets = globalThis.Bun.secrets;
3529
3536
  secretsAvailable = true;
3530
3537
  } catch {
3531
3538
  secretsAvailable = false;
3532
3539
  }
3533
- keychainAvailablePrecompute = await isKeychainAvailable();
3540
+ warnedSecretReadFailures = new Set;
3534
3541
  });
3535
3542
 
3536
3543
  // src/settings-manager.ts
@@ -4523,13 +4530,11 @@ class SettingsManager {
4523
4530
  }
4524
4531
  }
4525
4532
  var DEFAULT_SETTINGS, DEFAULT_PROJECT_SETTINGS, DEFAULT_LOCAL_PROJECT_SETTINGS, DEFAULT_LETTA_API_URL = "https://api.letta.com", settingsManager;
4526
- var init_settings_manager = __esm(async () => {
4533
+ var init_settings_manager = __esm(() => {
4534
+ init_errorReporting();
4527
4535
  init_debug();
4528
4536
  init_fs();
4529
- await __promiseAll([
4530
- init_errorReporting(),
4531
- init_secrets()
4532
- ]);
4537
+ init_secrets();
4533
4538
  DEFAULT_SETTINGS = {
4534
4539
  lastAgent: null,
4535
4540
  tokenStreaming: false,
@@ -4751,16 +4756,14 @@ If you experience this issue multiple times, move ~/.letta to ~/.letta_backup, a
4751
4756
  });
4752
4757
  }
4753
4758
  var SDK_DIAGNOSTIC_MAX_LEN = 400, SDK_DIAGNOSTIC_MAX_LINES = 4, lastSDKDiagnostic = null, _cachedApiKey, sdkLogger;
4754
- var init_client2 = __esm(async () => {
4759
+ var init_client2 = __esm(() => {
4755
4760
  init_letta_client();
4756
4761
  init_package();
4762
+ init_oauth();
4763
+ init_settings_manager();
4764
+ init_errorReporting();
4757
4765
  init_debug();
4758
4766
  init_timing();
4759
- await __promiseAll([
4760
- init_oauth(),
4761
- init_settings_manager(),
4762
- init_errorReporting()
4763
- ]);
4764
4767
  sdkLogger = {
4765
4768
  error: (...args) => {
4766
4769
  try {
@@ -5105,14 +5108,12 @@ class TelemetryManager {
5105
5108
  }
5106
5109
  }
5107
5110
  var telemetry;
5108
- var init_telemetry = __esm(async () => {
5111
+ var init_telemetry = __esm(() => {
5112
+ init_client2();
5109
5113
  init_http_headers();
5114
+ init_settings_manager();
5110
5115
  init_debug();
5111
5116
  init_version();
5112
- await __promiseAll([
5113
- init_client2(),
5114
- init_settings_manager()
5115
- ]);
5116
5117
  telemetry = new TelemetryManager;
5117
5118
  });
5118
5119
 
@@ -5138,8 +5139,8 @@ function trackBoundaryError(options) {
5138
5139
  recentChunks: options.recentChunks
5139
5140
  });
5140
5141
  }
5141
- var init_errorReporting = __esm(async () => {
5142
- await init_telemetry();
5142
+ var init_errorReporting = __esm(() => {
5143
+ init_telemetry();
5143
5144
  });
5144
5145
 
5145
5146
  // src/auth/oauth.ts
@@ -5354,9 +5355,9 @@ async function validateCredentials(baseUrl, apiKey) {
5354
5355
  }
5355
5356
  }
5356
5357
  var LETTA_CLOUD_API_URL = "https://api.letta.com", OAUTH_CONFIG;
5357
- var init_oauth = __esm(async () => {
5358
+ var init_oauth = __esm(() => {
5358
5359
  init_letta_client();
5359
- await init_errorReporting();
5360
+ init_errorReporting();
5360
5361
  OAUTH_CONFIG = {
5361
5362
  clientId: "ci-let-724dea7e98f4af6f8f370f4b1466200c",
5362
5363
  clientSecret: "",
@@ -10081,12 +10082,10 @@ async function removeOpenAICodexProvider() {
10081
10082
  }
10082
10083
  }
10083
10084
  var OPENAI_CODEX_PROVIDER_NAME = "chatgpt-plus-pro", CHATGPT_OAUTH_PROVIDER_TYPE = "chatgpt_oauth";
10084
- var init_openai_codex_provider = __esm(async () => {
10085
+ var init_openai_codex_provider = __esm(() => {
10085
10086
  init_http_headers();
10086
- await __promiseAll([
10087
- init_oauth(),
10088
- init_settings_manager()
10089
- ]);
10087
+ init_oauth();
10088
+ init_settings_manager();
10090
10089
  });
10091
10090
 
10092
10091
  // src/agent/model.ts
@@ -10299,9 +10298,9 @@ function resolveModelByLlmConfig(llmConfigModel) {
10299
10298
  return null;
10300
10299
  }
10301
10300
  var models, REASONING_EFFORT_ORDER, RESUME_REFRESH_FIELDS;
10302
- var init_model = __esm(async () => {
10301
+ var init_model = __esm(() => {
10303
10302
  init_models2();
10304
- await init_openai_codex_provider();
10303
+ init_openai_codex_provider();
10305
10304
  models = models_default.models;
10306
10305
  REASONING_EFFORT_ORDER = [
10307
10306
  "none",
@@ -10421,9 +10420,9 @@ async function getModelContextWindow(handle) {
10421
10420
  return cache2?.contextWindows.get(handle);
10422
10421
  }
10423
10422
  var CACHE_TTL_MS, cache2 = null, inflight = null;
10424
- var init_available_models = __esm(async () => {
10423
+ var init_available_models = __esm(() => {
10425
10424
  init_debug();
10426
- await init_client2();
10425
+ init_client2();
10427
10426
  CACHE_TTL_MS = 5 * 60 * 1000;
10428
10427
  });
10429
10428
 
@@ -10639,9 +10638,9 @@ async function validateCredentials2(baseUrl, apiKey) {
10639
10638
  }
10640
10639
  }
10641
10640
  var LETTA_CLOUD_API_URL2 = "https://api.letta.com", OAUTH_CONFIG2;
10642
- var init_oauth2 = __esm(async () => {
10641
+ var init_oauth2 = __esm(() => {
10643
10642
  init_letta_client();
10644
- await init_errorReporting();
10643
+ init_errorReporting();
10645
10644
  OAUTH_CONFIG2 = {
10646
10645
  clientId: "ci-let-724dea7e98f4af6f8f370f4b1466200c",
10647
10646
  clientSecret: "",
@@ -37896,9 +37895,9 @@ function resolveModelByLlmConfig2(llmConfigModel) {
37896
37895
  return null;
37897
37896
  }
37898
37897
  var models2, REASONING_EFFORT_ORDER2, RESUME_REFRESH_FIELDS2;
37899
- var init_model2 = __esm(async () => {
37898
+ var init_model2 = __esm(() => {
37900
37899
  init_models2();
37901
- await init_openai_codex_provider();
37900
+ init_openai_codex_provider();
37902
37901
  models2 = models_default.models;
37903
37902
  REASONING_EFFORT_ORDER2 = [
37904
37903
  "none",
@@ -38160,13 +38159,13 @@ function getLoadingMessage(loadingState, continueSession) {
38160
38159
  }
38161
38160
  var import_react25, jsx_dev_runtime6;
38162
38161
  var init_WelcomeScreen = __esm(async () => {
38162
+ init_model2();
38163
+ init_settings_manager();
38163
38164
  init_version();
38164
38165
  init_useTerminalWidth();
38165
38166
  init_colors();
38166
38167
  await __promiseAll([
38167
38168
  init_build2(),
38168
- init_model2(),
38169
- init_settings_manager(),
38170
38169
  init_AnimatedLogo(),
38171
38170
  init_Text2()
38172
38171
  ]);
@@ -38365,7 +38364,7 @@ async function updateAgentSystemPromptRaw2(agentId, systemPromptContent) {
38365
38364
  async function updateAgentSystemPrompt2(agentId, systemPromptId) {
38366
38365
  try {
38367
38366
  const { isKnownPreset: isKnownPreset2, resolveAndBuildSystemPrompt: resolveAndBuildSystemPrompt2 } = await Promise.resolve().then(() => (init_promptAssets(), exports_promptAssets));
38368
- const { settingsManager: settingsManager2 } = await init_settings_manager().then(() => exports_settings_manager);
38367
+ const { settingsManager: settingsManager2 } = await Promise.resolve().then(() => (init_settings_manager(), exports_settings_manager));
38369
38368
  const client = await getClient();
38370
38369
  const memoryMode = settingsManager2.isReady && settingsManager2.isMemfsEnabled(agentId) ? "memfs" : "standard";
38371
38370
  const systemPromptContent = await resolveAndBuildSystemPrompt2(systemPromptId, memoryMode);
@@ -38401,7 +38400,7 @@ async function updateAgentSystemPrompt2(agentId, systemPromptId) {
38401
38400
  }
38402
38401
  async function updateAgentSystemPromptMemfs(agentId, enableMemfs) {
38403
38402
  try {
38404
- const { settingsManager: settingsManager2 } = await init_settings_manager().then(() => exports_settings_manager);
38403
+ const { settingsManager: settingsManager2 } = await Promise.resolve().then(() => (init_settings_manager(), exports_settings_manager));
38405
38404
  const { isKnownPreset: isKnownPreset2, buildSystemPrompt: buildSystemPrompt2, swapMemoryAddon: swapMemoryAddon2 } = await Promise.resolve().then(() => (init_promptAssets(), exports_promptAssets));
38406
38405
  const newMode = enableMemfs ? "memfs" : "standard";
38407
38406
  const storedPreset = settingsManager2.isReady ? settingsManager2.getSystemPromptPreset(agentId) : undefined;
@@ -38428,13 +38427,11 @@ async function updateAgentSystemPromptMemfs(agentId, enableMemfs) {
38428
38427
  };
38429
38428
  }
38430
38429
  }
38431
- var init_modify = __esm(async () => {
38430
+ var init_modify = __esm(() => {
38431
+ init_openai_codex_provider();
38432
38432
  init_debug();
38433
- await __promiseAll([
38434
- init_openai_codex_provider(),
38435
- init_available_models(),
38436
- init_client2()
38437
- ]);
38433
+ init_available_models();
38434
+ init_client2();
38438
38435
  });
38439
38436
 
38440
38437
  // src/agent/create.ts
@@ -38653,18 +38650,16 @@ async function createAgent(nameOrOptions = DEFAULT_AGENT_NAME, model, embeddingM
38653
38650
  };
38654
38651
  return { agent: fullAgent, provenance };
38655
38652
  }
38656
- var init_create = __esm(async () => {
38653
+ var init_create = __esm(() => {
38657
38654
  init_constants();
38655
+ init_settings_manager();
38656
+ init_available_models();
38657
+ init_client2();
38658
38658
  init_http_headers();
38659
38659
  init_memory();
38660
+ init_model2();
38661
+ init_modify();
38660
38662
  init_promptAssets();
38661
- await __promiseAll([
38662
- init_settings_manager(),
38663
- init_available_models(),
38664
- init_client2(),
38665
- init_model2(),
38666
- init_modify()
38667
- ]);
38668
38663
  });
38669
38664
 
38670
38665
  // src/agent/memoryGit.ts
@@ -39146,9 +39141,9 @@ if [ -n "$errors" ]; then
39146
39141
  exit 1
39147
39142
  fi
39148
39143
  `;
39149
- var init_memoryGit = __esm(async () => {
39144
+ var init_memoryGit = __esm(() => {
39150
39145
  init_debug();
39151
- await init_client2();
39146
+ init_client2();
39152
39147
  execFile = promisify(execFileCb);
39153
39148
  RETRYABLE_GIT_HTTP_ERROR_RE = /(?:\bHTTP\s+(?:520|521|522|523|524)\b|The requested URL returned error:\s*(?:520|521|522|523|524))/i;
39154
39149
  RETRYABLE_GIT_NETWORK_ERROR_RE = /(remote end hung up unexpectedly|connection reset by peer|operation timed out|timed out)/i;
@@ -39373,7 +39368,7 @@ async function buildCreateAgentOptionsForPersonality(params) {
39373
39368
  async function enableMemfsForCreatedAgent(params) {
39374
39369
  const { agentId, agentTags } = params;
39375
39370
  try {
39376
- const { getClient: getClient3 } = await init_client2().then(() => exports_client);
39371
+ const { getClient: getClient3 } = await Promise.resolve().then(() => (init_client2(), exports_client));
39377
39372
  const client = await getClient3();
39378
39373
  const tags = agentTags || [];
39379
39374
  if (!tags.includes(GIT_MEMORY_ENABLED_TAG)) {
@@ -39385,7 +39380,7 @@ async function enableMemfsForCreatedAgent(params) {
39385
39380
  } catch {}
39386
39381
  }
39387
39382
  async function createAgentForPersonality(params) {
39388
- const { createAgent: createAgent2 } = await init_create().then(() => exports_create);
39383
+ const { createAgent: createAgent2 } = await Promise.resolve().then(() => (init_create(), exports_create));
39389
39384
  const result = await createAgent2(await buildCreateAgentOptionsForPersonality(params));
39390
39385
  await enableMemfsForCreatedAgent({
39391
39386
  agentId: result.agent.id,
@@ -39530,13 +39525,11 @@ async function applyPersonalityToMemory(params) {
39530
39525
  };
39531
39526
  }
39532
39527
  var execFile2, PRIMARY_PERSONA_RELATIVE_PATH = "system/persona.md", LEGACY_PERSONA_RELATIVE_PATH = "memory/system/persona.md", PRIMARY_HUMAN_RELATIVE_PATH = "system/human.md", LEGACY_HUMAN_RELATIVE_PATH = "memory/system/human.md", PERSONALITY_OPTIONS, DEFAULT_CREATE_AGENT_PERSONALITIES, PERSONALITY_ALIASES, FRONTMATTER_REGEX, EDITABLE_FRONTMATTER_KEYS;
39533
- var init_personality = __esm(async () => {
39528
+ var init_personality = __esm(() => {
39529
+ init_settings_manager();
39534
39530
  init_memory();
39531
+ init_memoryGit();
39535
39532
  init_promptAssets();
39536
- await __promiseAll([
39537
- init_settings_manager(),
39538
- init_memoryGit()
39539
- ]);
39540
39533
  execFile2 = promisify2(execFileCb2);
39541
39534
  PERSONALITY_OPTIONS = [
39542
39535
  {
@@ -40213,8 +40206,22 @@ var init_sessionContext = __esm(() => {
40213
40206
  function escapeXml(text) {
40214
40207
  return text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
40215
40208
  }
40216
- function formatChannelNotification(msg) {
40209
+ function buildChannelReminderText(msg) {
40217
40210
  const localTime = escapeXml(getLocalTime());
40211
+ const escapedChannel = escapeXml(msg.channel);
40212
+ const escapedChatId = escapeXml(msg.chatId);
40213
+ return [
40214
+ SYSTEM_REMINDER_OPEN,
40215
+ `This message originated from an external ${escapedChannel} channel.`,
40216
+ `If you want the ensure the user on ${escapedChannel} will see your reply, you must call the MessageChannel tool to send a message back on the same channel.`,
40217
+ `Use channel="${escapedChannel}" and chat_id="${escapedChatId}" when calling MessageChannel.`,
40218
+ "Only pass reply_to_message_id if you intentionally want the platform's quote/reply UI.",
40219
+ `Current local time on this device: ${localTime}`,
40220
+ SYSTEM_REMINDER_CLOSE
40221
+ ].join(`
40222
+ `);
40223
+ }
40224
+ function buildChannelNotificationXml(msg) {
40218
40225
  const attrs = [
40219
40226
  `source="${escapeXml(msg.channel)}"`,
40220
40227
  `chat_id="${escapeXml(msg.chatId)}"`,
@@ -40228,23 +40235,16 @@ function formatChannelNotification(msg) {
40228
40235
  }
40229
40236
  const attrString = attrs.join(" ");
40230
40237
  const escapedText = escapeXml(msg.text);
40231
- const escapedChannel = escapeXml(msg.channel);
40232
- const escapedChatId = escapeXml(msg.chatId);
40233
- const reminder = [
40234
- SYSTEM_REMINDER_OPEN,
40235
- `This message originated from an external ${escapedChannel} channel.`,
40236
- `If you want the ensure the user on ${escapedChannel} will see your reply, you must call the MessageChannel tool to send a message back on the same channel.`,
40237
- `Use channel="${escapedChannel}" and chat_id="${escapedChatId}" when calling MessageChannel.`,
40238
- "Only pass reply_to_message_id if you intentionally want the platform's quote/reply UI.",
40239
- `Current local time on this device: ${localTime}`,
40240
- SYSTEM_REMINDER_CLOSE
40241
- ].join(`
40242
- `);
40243
- return `${reminder}
40244
- <channel-notification ${attrString}>
40238
+ return `<channel-notification ${attrString}>
40245
40239
  ${escapedText}
40246
40240
  </channel-notification>`;
40247
40241
  }
40242
+ function formatChannelNotification(msg) {
40243
+ return [
40244
+ { type: "text", text: buildChannelReminderText(msg) },
40245
+ { type: "text", text: buildChannelNotificationXml(msg) }
40246
+ ];
40247
+ }
40248
40248
  var init_xml = __esm(() => {
40249
40249
  init_sessionContext();
40250
40250
  init_constants();
@@ -40336,7 +40336,16 @@ function createTelegramAdapter(config) {
40336
40336
  return running;
40337
40337
  },
40338
40338
  async sendMessage(msg) {
40339
- const result = await bot.api.sendMessage(msg.chatId, msg.text, msg.replyToMessageId ? { reply_parameters: { message_id: Number(msg.replyToMessageId) } } : undefined);
40339
+ const opts = {};
40340
+ if (msg.replyToMessageId) {
40341
+ opts.reply_parameters = {
40342
+ message_id: Number(msg.replyToMessageId)
40343
+ };
40344
+ }
40345
+ if (msg.parseMode) {
40346
+ opts.parse_mode = msg.parseMode;
40347
+ }
40348
+ const result = await bot.api.sendMessage(msg.chatId, msg.text, opts);
40340
40349
  return { messageId: String(result.message_id) };
40341
40350
  },
40342
40351
  async sendDirectReply(chatId, text) {
@@ -40514,11 +40523,11 @@ This code expires in 15 minutes.`);
40514
40523
  await adapter.sendDirectReply(msg.chatId, `This chat isn't bound to an agent. Run \`/channels telegram enable --chat-id ${msg.chatId}\` on your Letta Code agent to connect.`);
40515
40524
  return;
40516
40525
  }
40517
- const xmlContent = formatChannelNotification(msg);
40526
+ const content = formatChannelNotification(msg);
40518
40527
  if (this.isReady()) {
40519
- this.messageHandler?.(route, xmlContent);
40528
+ this.messageHandler?.(route, content);
40520
40529
  } else {
40521
- this.buffer.push({ route, xmlContent });
40530
+ this.buffer.push({ route, content });
40522
40531
  }
40523
40532
  }
40524
40533
  flushBuffer() {
@@ -40527,7 +40536,7 @@ This code expires in 15 minutes.`);
40527
40536
  while (this.buffer.length > 0) {
40528
40537
  const item = this.buffer.shift();
40529
40538
  if (item) {
40530
- this.messageHandler(item.route, item.xmlContent);
40539
+ this.messageHandler(item.route, item.content);
40531
40540
  }
40532
40541
  }
40533
40542
  }
@@ -40780,12 +40789,10 @@ function getProviderConfig(id) {
40780
40789
  return BYOK_PROVIDERS.find((p) => p.id === id);
40781
40790
  }
40782
40791
  var BYOK_PROVIDERS, STATIC_BYOK_PROVIDER_PREFIXES, PROVIDER_TYPE_TO_BASE_PROVIDER;
40783
- var init_byok_providers = __esm(async () => {
40792
+ var init_byok_providers = __esm(() => {
40784
40793
  init_http_headers();
40785
- await __promiseAll([
40786
- init_oauth(),
40787
- init_settings_manager()
40788
- ]);
40794
+ init_oauth();
40795
+ init_settings_manager();
40789
40796
  BYOK_PROVIDERS = [
40790
40797
  {
40791
40798
  id: "codex",
@@ -40946,8 +40953,8 @@ function isConnectZaiBaseProvider(provider) {
40946
40953
  return provider.canonical === "zai";
40947
40954
  }
40948
40955
  var ALIAS_TO_CANONICAL, CANONICAL_ORDER;
40949
- var init_connect_normalize = __esm(async () => {
40950
- await init_byok_providers();
40956
+ var init_connect_normalize = __esm(() => {
40957
+ init_byok_providers();
40951
40958
  ALIAS_TO_CANONICAL = {
40952
40959
  chatgpt: "chatgpt",
40953
40960
  codex: "chatgpt",
@@ -41801,12 +41808,10 @@ ${authorizationUrl}`);
41801
41808
  }
41802
41809
  }
41803
41810
  var DEFAULT_DEPS;
41804
- var init_connect_oauth_core = __esm(async () => {
41811
+ var init_connect_oauth_core = __esm(() => {
41805
41812
  init_openai_oauth();
41806
- await __promiseAll([
41807
- init_openai_codex_provider(),
41808
- init_settings_manager()
41809
- ]);
41813
+ init_openai_codex_provider();
41814
+ init_settings_manager();
41810
41815
  DEFAULT_DEPS = {
41811
41816
  startOAuth: (port) => startOpenAIOAuth(port ?? OPENAI_OAUTH_CONFIG.defaultPort),
41812
41817
  startCallbackServer: (expectedState, port) => startLocalOAuthServer(expectedState, port ?? OPENAI_OAUTH_CONFIG.defaultPort),
@@ -45030,9 +45035,9 @@ function parseMemoryPreference(questions, answers, agentId, workingDirectory) {
45030
45035
  return false;
45031
45036
  }
45032
45037
  var MEMORY_INTERVAL_FREQUENT = 5, MEMORY_INTERVAL_OCCASIONAL = 10, DEFAULT_STEP_COUNT = 25, DEFAULT_REFLECTION_SETTINGS;
45033
- var init_memoryReminder = __esm(async () => {
45038
+ var init_memoryReminder = __esm(() => {
45039
+ init_settings_manager();
45034
45040
  init_debug();
45035
- await init_settings_manager();
45036
45041
  DEFAULT_REFLECTION_SETTINGS = {
45037
45042
  trigger: "compaction-event",
45038
45043
  stepCount: DEFAULT_STEP_COUNT
@@ -53025,10 +53030,10 @@ Example responses:
53025
53030
  - To block: {"ok": false, "reason": "This action violates the security policy"}
53026
53031
 
53027
53032
  Respond with JSON only. No markdown code blocks. No explanation outside the JSON.`, PROMPT_HOOK_RESPONSE_SCHEMA;
53028
- var init_prompt_executor = __esm(async () => {
53033
+ var init_prompt_executor = __esm(() => {
53034
+ init_client2();
53029
53035
  init_context();
53030
53036
  init_types();
53031
- await init_client2();
53032
53037
  PROMPT_HOOK_RESPONSE_SCHEMA = {
53033
53038
  properties: {
53034
53039
  ok: {
@@ -53309,9 +53314,9 @@ async function executeHooksParallel(hooks, input, workingDirectory = process.cwd
53309
53314
  };
53310
53315
  }
53311
53316
  var DEFAULT_TIMEOUT_MS = 60000;
53312
- var init_executor = __esm(async () => {
53317
+ var init_executor = __esm(() => {
53318
+ init_prompt_executor();
53313
53319
  init_types();
53314
- await init_prompt_executor();
53315
53320
  });
53316
53321
 
53317
53322
  // src/hooks/loader.ts
@@ -53489,10 +53494,10 @@ async function getHooksForEvent(event, toolName, workingDirectory = process.cwd(
53489
53494
  const config = await loadHooks(workingDirectory);
53490
53495
  return getMatchingHooks(config, event, toolName);
53491
53496
  }
53492
- var init_loader = __esm(async () => {
53497
+ var init_loader = __esm(() => {
53498
+ init_settings_manager();
53493
53499
  init_debug();
53494
53500
  init_types();
53495
- await init_settings_manager();
53496
53501
  });
53497
53502
 
53498
53503
  // src/hooks/index.ts
@@ -53695,13 +53700,11 @@ async function runSessionEndHooks(durationMs, messageCount, toolCallCount, agent
53695
53700
  };
53696
53701
  return executeHooksParallel(hooks, input, workingDirectory);
53697
53702
  }
53698
- var init_hooks = __esm(async () => {
53703
+ var init_hooks = __esm(() => {
53699
53704
  init_session();
53700
- await __promiseAll([
53701
- init_executor(),
53702
- init_loader(),
53703
- init_loader()
53704
- ]);
53705
+ init_executor();
53706
+ init_loader();
53707
+ init_loader();
53705
53708
  init_types();
53706
53709
  });
53707
53710
 
@@ -55475,9 +55478,9 @@ function clearSecretsCache() {
55475
55478
  setCache(null);
55476
55479
  }
55477
55480
  var SECRETS_CACHE_KEY;
55478
- var init_secretsStore = __esm(async () => {
55481
+ var init_secretsStore = __esm(() => {
55482
+ init_client2();
55479
55483
  init_context();
55480
- await init_client2();
55481
55484
  SECRETS_CACHE_KEY = Symbol.for("@letta/secretsCache");
55482
55485
  });
55483
55486
 
@@ -55512,8 +55515,8 @@ function scrubSecretsFromString(input) {
55512
55515
  return result;
55513
55516
  }
55514
55517
  var SECRET_PATTERN;
55515
- var init_secret_substitution = __esm(async () => {
55516
- await init_secretsStore();
55518
+ var init_secret_substitution = __esm(() => {
55519
+ init_secretsStore();
55517
55520
  SECRET_PATTERN = /\$([A-Z_][A-Z0-9_]*)/g;
55518
55521
  });
55519
55522
 
@@ -57645,13 +57648,11 @@ function getShellEnv() {
57645
57648
  return env3;
57646
57649
  }
57647
57650
  var LETTA_BIN_ARGS_ENV = "LETTA_CODE_BIN_ARGS_JSON";
57648
- var init_shellEnv = __esm(async () => {
57651
+ var init_shellEnv = __esm(() => {
57652
+ init_client2();
57649
57653
  init_context();
57650
57654
  init_memoryFilesystem();
57651
- await __promiseAll([
57652
- init_client2(),
57653
- init_settings_manager()
57654
- ]);
57655
+ init_settings_manager();
57655
57656
  });
57656
57657
 
57657
57658
  // src/tools/impl/shellRunner.ts
@@ -58198,12 +58199,12 @@ ${errorMessage}`;
58198
58199
  }
58199
58200
  }
58200
58201
  var cachedWorkingLauncher = null;
58201
- var init_Bash2 = __esm(async () => {
58202
+ var init_Bash2 = __esm(() => {
58202
58203
  init_constants();
58203
58204
  init_process_manager();
58205
+ init_shellEnv();
58204
58206
  init_shellRunner();
58205
58207
  init_truncation();
58206
- await init_shellEnv();
58207
58208
  });
58208
58209
 
58209
58210
  // src/tools/impl/BashOutput.ts
@@ -60041,12 +60042,10 @@ function emitMemoryUpdated(affectedPaths) {
60041
60042
  } catch {}
60042
60043
  }
60043
60044
  var execFile10;
60044
- var init_Memory2 = __esm(async () => {
60045
+ var init_Memory2 = __esm(() => {
60046
+ init_client2();
60045
60047
  init_context();
60046
- await __promiseAll([
60047
- init_client2(),
60048
- init_memoryGit()
60049
- ]);
60048
+ init_memoryGit();
60050
60049
  execFile10 = promisify10(execFileCb3);
60051
60050
  });
60052
60051
 
@@ -60619,16 +60618,143 @@ function buildOldNewChunks(lines) {
60619
60618
  };
60620
60619
  }
60621
60620
  var execFile11;
60622
- var init_MemoryApplyPatch2 = __esm(async () => {
60621
+ var init_MemoryApplyPatch2 = __esm(() => {
60622
+ init_client2();
60623
60623
  init_context();
60624
- await __promiseAll([
60625
- init_client2(),
60626
- init_memoryGit()
60627
- ]);
60624
+ init_memoryGit();
60628
60625
  execFile11 = promisify11(execFileCb4);
60629
60626
  });
60630
60627
 
60631
60628
  // src/tools/impl/MessageChannel.ts
60629
+ function escapeTelegramHtml(text) {
60630
+ return text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
60631
+ }
60632
+ function escapeTelegramHtmlAttribute(text) {
60633
+ return escapeTelegramHtml(text).replace(/"/g, "&quot;").replace(/'/g, "&#39;");
60634
+ }
60635
+ function createTelegramPlaceholder(placeholders, value) {
60636
+ const placeholder = `${TELEGRAM_PLACEHOLDER_PREFIX}${placeholders.length}${TELEGRAM_PLACEHOLDER_SUFFIX}`;
60637
+ placeholders.push(value);
60638
+ return placeholder;
60639
+ }
60640
+ function restoreTelegramPlaceholders(text, placeholders) {
60641
+ return text.replace(TELEGRAM_PLACEHOLDER_PATTERN, (_match, index) => {
60642
+ return placeholders[Number(index)] ?? "";
60643
+ });
60644
+ }
60645
+ function replaceFencedCodeBlocks(text, placeholders) {
60646
+ return text.replace(/```([^\n`]*)\n?([\s\S]*?)```/g, (_match, _lang, code) => {
60647
+ return createTelegramPlaceholder(placeholders, `<pre>${escapeTelegramHtml(String(code).trimEnd())}</pre>`);
60648
+ });
60649
+ }
60650
+ function replaceInlineCode(text, placeholders) {
60651
+ return text.replace(/`([^`\n]+)`/g, (_match, code) => {
60652
+ return createTelegramPlaceholder(placeholders, `<code>${escapeTelegramHtml(String(code))}</code>`);
60653
+ });
60654
+ }
60655
+ function parseMarkdownLink(text, startIndex) {
60656
+ if (text[startIndex] !== "[") {
60657
+ return null;
60658
+ }
60659
+ let labelEnd = startIndex + 1;
60660
+ let bracketDepth = 1;
60661
+ while (labelEnd < text.length) {
60662
+ const char = text[labelEnd];
60663
+ if (char === "\\") {
60664
+ labelEnd += 2;
60665
+ continue;
60666
+ }
60667
+ if (char === "[") {
60668
+ bracketDepth++;
60669
+ } else if (char === "]") {
60670
+ bracketDepth--;
60671
+ if (bracketDepth === 0) {
60672
+ break;
60673
+ }
60674
+ }
60675
+ labelEnd++;
60676
+ }
60677
+ if (bracketDepth !== 0 || text[labelEnd + 1] !== "(") {
60678
+ return null;
60679
+ }
60680
+ let urlEnd = labelEnd + 2;
60681
+ let parenDepth = 1;
60682
+ while (urlEnd < text.length) {
60683
+ const char = text[urlEnd];
60684
+ if (char === "\\") {
60685
+ urlEnd += 2;
60686
+ continue;
60687
+ }
60688
+ if (char === "(") {
60689
+ parenDepth++;
60690
+ } else if (char === ")") {
60691
+ parenDepth--;
60692
+ if (parenDepth === 0) {
60693
+ break;
60694
+ }
60695
+ }
60696
+ urlEnd++;
60697
+ }
60698
+ if (parenDepth !== 0) {
60699
+ return null;
60700
+ }
60701
+ const label = text.slice(startIndex + 1, labelEnd);
60702
+ const url = text.slice(labelEnd + 2, urlEnd).trim();
60703
+ if (!url) {
60704
+ return null;
60705
+ }
60706
+ return {
60707
+ label,
60708
+ url,
60709
+ endIndex: urlEnd + 1
60710
+ };
60711
+ }
60712
+ function replaceMarkdownLinks(text, placeholders, renderLabel) {
60713
+ let result = "";
60714
+ let index = 0;
60715
+ while (index < text.length) {
60716
+ if (text[index] !== "[") {
60717
+ result += text[index];
60718
+ index++;
60719
+ continue;
60720
+ }
60721
+ const link2 = parseMarkdownLink(text, index);
60722
+ if (!link2) {
60723
+ result += text[index];
60724
+ index++;
60725
+ continue;
60726
+ }
60727
+ result += createTelegramPlaceholder(placeholders, `<a href="${escapeTelegramHtmlAttribute(link2.url)}">${renderLabel(link2.label)}</a>`);
60728
+ index = link2.endIndex;
60729
+ }
60730
+ return result;
60731
+ }
60732
+ function applyTelegramInlineFormatting(text) {
60733
+ return text.replace(/\*\*\*([^\s*](?:[\s\S]*?[^\s*])?)\*\*\*/g, "<b><i>$1</i></b>").replace(/___([^\s_](?:[\s\S]*?[^\s_])?)___/g, "<b><i>$1</i></b>").replace(/\*\*([^\s*](?:[\s\S]*?[^\s*])?)\*\*/g, "<b>$1</b>").replace(/__([^\s_](?:[\s\S]*?[^\s_])?)__/g, "<b>$1</b>").replace(/~~([^\s~](?:[\s\S]*?[^\s~])?)~~/g, "<s>$1</s>").replace(/(^|[^\w*])\*([^\s*](?:[\s\S]*?[^\s*])?)\*(?!\w)/g, "$1<i>$2</i>").replace(/(^|[^\w_])_([^\s_](?:[\s\S]*?[^\s_])?)_(?!\w)/g, "$1<i>$2</i>");
60734
+ }
60735
+ function formatTelegramText(text, options) {
60736
+ const placeholders = [];
60737
+ let result = replaceFencedCodeBlocks(text, placeholders);
60738
+ result = replaceInlineCode(result, placeholders);
60739
+ if (options?.enableLinks !== false) {
60740
+ result = replaceMarkdownLinks(result, placeholders, (label) => formatTelegramText(label, { enableLinks: false }));
60741
+ }
60742
+ result = escapeTelegramHtml(result);
60743
+ result = applyTelegramInlineFormatting(result);
60744
+ return restoreTelegramPlaceholders(result, placeholders);
60745
+ }
60746
+ function markdownToTelegramHtml(text) {
60747
+ return formatTelegramText(text);
60748
+ }
60749
+ function formatOutboundChannelMessage(channel, text) {
60750
+ if (channel !== TELEGRAM_CHANNEL_ID) {
60751
+ return { text };
60752
+ }
60753
+ return {
60754
+ text: markdownToTelegramHtml(text),
60755
+ parseMode: "HTML"
60756
+ };
60757
+ }
60632
60758
  async function message_channel(args) {
60633
60759
  const registry = getChannelRegistry();
60634
60760
  if (!registry) {
@@ -60650,11 +60776,13 @@ async function message_channel(args) {
60650
60776
  return `Error: No route for chat_id "${args.chat_id}" on "${args.channel}" for this agent/conversation.`;
60651
60777
  }
60652
60778
  try {
60779
+ const formattedMessage = formatOutboundChannelMessage(args.channel, args.text);
60653
60780
  const result = await adapter.sendMessage({
60654
60781
  channel: args.channel,
60655
60782
  chatId: args.chat_id,
60656
- text: args.text,
60657
- replyToMessageId: args.reply_to_message_id
60783
+ text: formattedMessage.text,
60784
+ replyToMessageId: args.reply_to_message_id,
60785
+ parseMode: formattedMessage.parseMode
60658
60786
  });
60659
60787
  return `Message sent to ${args.channel} (message_id: ${result.messageId})`;
60660
60788
  } catch (err) {
@@ -60662,8 +60790,10 @@ async function message_channel(args) {
60662
60790
  return `Error sending message to ${args.channel}: ${msg}`;
60663
60791
  }
60664
60792
  }
60793
+ var TELEGRAM_CHANNEL_ID = "telegram", TELEGRAM_PLACEHOLDER_PREFIX = "LCTELEGRAMHTMLPLACEHOLDER", TELEGRAM_PLACEHOLDER_SUFFIX = "X", TELEGRAM_PLACEHOLDER_PATTERN;
60665
60794
  var init_MessageChannel2 = __esm(() => {
60666
60795
  init_registry();
60796
+ TELEGRAM_PLACEHOLDER_PATTERN = /LCTELEGRAMHTMLPLACEHOLDER(\d+)X/g;
60667
60797
  });
60668
60798
 
60669
60799
  // src/tools/impl/MultiEdit.ts
@@ -67406,9 +67536,9 @@ function extractShellScript(command, shellIndex) {
67406
67536
  return null;
67407
67537
  }
67408
67538
  var DEFAULT_TIMEOUT = 120000;
67409
- var init_Shell2 = __esm(async () => {
67539
+ var init_Shell2 = __esm(() => {
67540
+ init_shellEnv();
67410
67541
  init_shellRunner();
67411
- await init_shellEnv();
67412
67542
  });
67413
67543
 
67414
67544
  // src/tools/impl/ShellCommand.ts
@@ -67553,12 +67683,12 @@ function stripWrappingQuotes(token) {
67553
67683
  function shellQuote(value) {
67554
67684
  return `'${value.replaceAll("'", `'"'"'`)}'`;
67555
67685
  }
67556
- var init_ShellCommand2 = __esm(async () => {
67686
+ var init_ShellCommand2 = __esm(() => {
67557
67687
  init_context();
67558
67688
  init_readOnlyShell();
67689
+ init_Shell2();
67559
67690
  init_shellRunner();
67560
67691
  init_truncation();
67561
- await init_Shell2();
67562
67692
  });
67563
67693
 
67564
67694
  // src/tools/impl/RunShellCommandGemini.ts
@@ -67573,8 +67703,8 @@ async function run_shell_command(args) {
67573
67703
  const message = result.output.trim() || "(Command completed with no output)";
67574
67704
  return { message };
67575
67705
  }
67576
- var init_RunShellCommandGemini2 = __esm(async () => {
67577
- await init_ShellCommand2();
67706
+ var init_RunShellCommandGemini2 = __esm(() => {
67707
+ init_ShellCommand2();
67578
67708
  });
67579
67709
 
67580
67710
  // src/tools/impl/SearchFileContentGemini.ts
@@ -68674,22 +68804,20 @@ async function spawnSubagent(type, prompt, userModel, subagentId, signal, existi
68674
68804
  return result;
68675
68805
  }
68676
68806
  var BYOK_PROVIDER_TO_BASE;
68677
- var init_manager2 = __esm(async () => {
68807
+ var init_manager2 = __esm(() => {
68678
68808
  init_subagentState();
68679
68809
  init_constants();
68680
68810
  init_cli();
68681
68811
  init_memoryScope();
68682
68812
  init_mode();
68683
68813
  init_session();
68814
+ init_settings_manager();
68815
+ init_shellEnv();
68816
+ init_available_models();
68817
+ init_client2();
68684
68818
  init_context();
68819
+ init_model2();
68685
68820
  init_subagents();
68686
- await __promiseAll([
68687
- init_settings_manager(),
68688
- init_shellEnv(),
68689
- init_available_models(),
68690
- init_client2(),
68691
- init_model2()
68692
- ]);
68693
68821
  BYOK_PROVIDER_TO_BASE = {
68694
68822
  "lc-anthropic": "anthropic",
68695
68823
  "lc-openai": "openai",
@@ -69153,18 +69281,16 @@ Output file: ${outputFile}`;
69153
69281
  }
69154
69282
  }
69155
69283
  var VALID_DEPLOY_TYPES, BACKGROUND_STARTUP_POLL_MS = 50;
69156
- var init_Task2 = __esm(async () => {
69284
+ var init_Task2 = __esm(() => {
69285
+ init_client2();
69157
69286
  init_context();
69158
69287
  init_subagents();
69288
+ init_manager2();
69159
69289
  init_messageQueueBridge();
69160
69290
  init_subagentState();
69291
+ init_hooks();
69161
69292
  init_process_manager();
69162
69293
  init_truncation();
69163
- await __promiseAll([
69164
- init_client2(),
69165
- init_manager2(),
69166
- init_hooks()
69167
- ]);
69168
69294
  VALID_DEPLOY_TYPES = new Set(["explore", "general-purpose"]);
69169
69295
  });
69170
69296
 
@@ -70609,6 +70735,7 @@ var init_toolDefinitions = __esm(async () => {
70609
70735
  init_WriteTodosGemini();
70610
70736
  init_ApplyPatch2();
70611
70737
  init_AskUserQuestion2();
70738
+ init_Bash2();
70612
70739
  init_BashOutput2();
70613
70740
  init_Edit2();
70614
70741
  init_Glob2();
@@ -70619,12 +70746,18 @@ var init_toolDefinitions = __esm(async () => {
70619
70746
  init_ListDirCodex2();
70620
70747
  init_ListDirectoryGemini2();
70621
70748
  init_LS3();
70749
+ init_Memory2();
70750
+ init_MemoryApplyPatch2();
70622
70751
  init_MessageChannel2();
70623
70752
  init_MultiEdit2();
70624
70753
  init_ReadFileCodex2();
70625
70754
  init_ReplaceGemini2();
70755
+ init_RunShellCommandGemini2();
70626
70756
  init_SearchFileContentGemini2();
70757
+ init_Shell2();
70758
+ init_ShellCommand2();
70627
70759
  init_Skill2();
70760
+ init_Task2();
70628
70761
  init_TaskOutput2();
70629
70762
  init_TaskStop2();
70630
70763
  init_TodoWrite2();
@@ -70670,19 +70803,12 @@ var init_toolDefinitions = __esm(async () => {
70670
70803
  init_WriteFileGemini3();
70671
70804
  init_WriteTodosGemini2();
70672
70805
  await __promiseAll([
70673
- init_Bash2(),
70674
70806
  init_EnterPlanMode2(),
70675
70807
  init_ExitPlanMode2(),
70676
- init_Memory2(),
70677
- init_MemoryApplyPatch2(),
70678
70808
  init_Read2(),
70679
70809
  init_ReadFileGemini2(),
70680
70810
  init_ReadLSP2(),
70681
70811
  init_ReadManyFilesGemini2(),
70682
- init_RunShellCommandGemini2(),
70683
- init_Shell2(),
70684
- init_ShellCommand2(),
70685
- init_Task2(),
70686
70812
  init_ViewImage2()
70687
70813
  ]);
70688
70814
  toolDefinitions = {
@@ -72793,15 +72919,15 @@ async function checkPermissionWithHooks(toolName, toolArgs, permissions, working
72793
72919
  return result;
72794
72920
  }
72795
72921
  var WORKING_DIRECTORY_TOOLS_V2, WORKING_DIRECTORY_TOOLS_V1, READ_ONLY_SHELL_TOOLS, FILE_TOOLS_V2, FILE_TOOLS_V1, SAFE_AUTO_APPROVE_SUBAGENT_TYPES;
72796
- var init_checker = __esm(async () => {
72922
+ var init_checker = __esm(() => {
72797
72923
  init_context();
72924
+ init_hooks();
72798
72925
  init_canonical();
72799
72926
  init_cli();
72800
72927
  init_matcher();
72801
72928
  init_mode();
72802
72929
  init_readOnlyShell();
72803
72930
  init_session();
72804
- await init_hooks();
72805
72931
  WORKING_DIRECTORY_TOOLS_V2 = ["Read", "Glob", "Grep", "ListDir"];
72806
72932
  WORKING_DIRECTORY_TOOLS_V1 = [
72807
72933
  "Read",
@@ -73877,7 +74003,7 @@ async function withExecutionWorkingDirectory(workingDirectory, fn) {
73877
74003
  }
73878
74004
  }
73879
74005
  async function checkToolPermission(toolName, toolArgs, workingDirectory = process.cwd(), permissionModeStateArg) {
73880
- const { checkPermissionWithHooks: checkPermissionWithHooks2 } = await init_checker().then(() => exports_checker);
74006
+ const { checkPermissionWithHooks: checkPermissionWithHooks2 } = await Promise.resolve().then(() => (init_checker(), exports_checker));
73881
74007
  const { loadPermissions: loadPermissions2 } = await Promise.resolve().then(() => (init_loader2(), exports_loader));
73882
74008
  const permissions = await loadPermissions2(workingDirectory);
73883
74009
  return checkPermissionWithHooks2(toolName, toolArgs, permissions, workingDirectory, permissionModeStateArg);
@@ -74373,19 +74499,19 @@ function clearToolsWithLock() {
74373
74499
  }
74374
74500
  var TOOL_NAMES, STREAMING_SHELL_TOOLS, TOOL_NAME_MAPPINGS, ANTHROPIC_DEFAULT_TOOLS, OPENAI_DEFAULT_TOOLS, GEMINI_DEFAULT_TOOLS, OPENAI_PASCAL_TOOLS, GEMINI_PASCAL_TOOLS, REGISTRY_KEY, SWITCH_LOCK_KEY, EXECUTION_CONTEXTS_KEY, toolRegistry, toolExecutionContextCounter = 0, EXTERNAL_TOOLS_KEY, EXTERNAL_EXECUTOR_KEY;
74375
74501
  var init_manager3 = __esm(async () => {
74502
+ init_model2();
74376
74503
  init_subagents();
74377
74504
  init_registry();
74378
74505
  init_fileIndex();
74379
74506
  init_constants();
74507
+ init_hooks();
74380
74508
  init_mode();
74509
+ init_openai_codex_provider();
74510
+ init_telemetry();
74381
74511
  init_debug();
74512
+ init_secret_substitution();
74382
74513
  await __promiseAll([
74383
74514
  init_approval_execution(),
74384
- init_model2(),
74385
- init_hooks(),
74386
- init_openai_codex_provider(),
74387
- init_telemetry(),
74388
- init_secret_substitution(),
74389
74515
  init_toolDefinitions()
74390
74516
  ]);
74391
74517
  TOOL_NAMES = Object.keys(TOOL_DEFINITIONS);
@@ -74770,14 +74896,12 @@ async function switchToolsetForModel(modelIdentifier, agentId) {
74770
74896
  }
74771
74897
  var MEMORY_TOOL_NAMES;
74772
74898
  var init_toolset = __esm(async () => {
74899
+ init_client2();
74900
+ init_model2();
74773
74901
  init_registry();
74902
+ init_settings_manager();
74774
74903
  init_filter();
74775
- await __promiseAll([
74776
- init_client2(),
74777
- init_model2(),
74778
- init_settings_manager(),
74779
- init_manager3()
74780
- ]);
74904
+ await init_manager3();
74781
74905
  MEMORY_TOOL_NAMES = new Set([
74782
74906
  "memory",
74783
74907
  "memory_apply_patch",
@@ -74937,23 +75061,23 @@ function renderMemoryFilesystemTree(systemLabels, detachedLabels, options = {})
74937
75061
  `);
74938
75062
  }
74939
75063
  async function applyMemfsFlags(agentId, memfsFlag, noMemfsFlag, options) {
74940
- const { settingsManager: settingsManager2 } = await init_settings_manager().then(() => exports_settings_manager);
75064
+ const { settingsManager: settingsManager2 } = await Promise.resolve().then(() => (init_settings_manager(), exports_settings_manager));
74941
75065
  if (memfsFlag && !await isLettaCloud()) {
74942
75066
  throw new Error("--memfs is only available on Letta Cloud (api.letta.com).");
74943
75067
  }
74944
75068
  const hasExplicitToggle = Boolean(memfsFlag || noMemfsFlag);
74945
75069
  const localMemfsEnabled = settingsManager2.isMemfsEnabled(agentId);
74946
- const { GIT_MEMORY_ENABLED_TAG: GIT_MEMORY_ENABLED_TAG2 } = await init_memoryGit().then(() => exports_memoryGit);
75070
+ const { GIT_MEMORY_ENABLED_TAG: GIT_MEMORY_ENABLED_TAG2 } = await Promise.resolve().then(() => (init_memoryGit(), exports_memoryGit));
74947
75071
  const shouldAutoEnableFromTag = !hasExplicitToggle && !localMemfsEnabled && Boolean(options?.agentTags?.includes(GIT_MEMORY_ENABLED_TAG2));
74948
75072
  const targetEnabled = memfsFlag ? true : noMemfsFlag ? false : shouldAutoEnableFromTag ? true : localMemfsEnabled;
74949
75073
  if (hasExplicitToggle || shouldAutoEnableFromTag) {
74950
75074
  if (!options?.skipPromptUpdate) {
74951
- const { updateAgentSystemPromptMemfs: updateAgentSystemPromptMemfs2 } = await init_modify().then(() => exports_modify);
75075
+ const { updateAgentSystemPromptMemfs: updateAgentSystemPromptMemfs2 } = await Promise.resolve().then(() => (init_modify(), exports_modify));
74952
75076
  const promptUpdate = await updateAgentSystemPromptMemfs2(agentId, targetEnabled);
74953
75077
  if (!promptUpdate.success) {
74954
75078
  throw new Error(promptUpdate.message);
74955
75079
  }
74956
- const { getClient: getClient3 } = await init_client2().then(() => exports_client);
75080
+ const { getClient: getClient3 } = await Promise.resolve().then(() => (init_client2(), exports_client));
74957
75081
  const client = await getClient3();
74958
75082
  await client.agents.recompile(agentId, { update_timestamp: false });
74959
75083
  }
@@ -74963,7 +75087,7 @@ async function applyMemfsFlags(agentId, memfsFlag, noMemfsFlag, options) {
74963
75087
  if (isEnabled && (memfsFlag || shouldAutoEnableFromTag)) {
74964
75088
  const { detachMemoryTools: detachMemoryTools2 } = await init_toolset().then(() => exports_toolset);
74965
75089
  await detachMemoryTools2(agentId);
74966
- const { getClient: getClient3 } = await init_client2().then(() => exports_client);
75090
+ const { getClient: getClient3 } = await Promise.resolve().then(() => (init_client2(), exports_client));
74967
75091
  const client = await getClient3();
74968
75092
  for (const label of ["skills", "loaded_skills"]) {
74969
75093
  try {
@@ -74980,12 +75104,12 @@ async function applyMemfsFlags(agentId, memfsFlag, noMemfsFlag, options) {
74980
75104
  }
74981
75105
  }
74982
75106
  if (noMemfsFlag) {
74983
- const { removeGitMemoryTag: removeGitMemoryTag2 } = await init_memoryGit().then(() => exports_memoryGit);
75107
+ const { removeGitMemoryTag: removeGitMemoryTag2 } = await Promise.resolve().then(() => (init_memoryGit(), exports_memoryGit));
74984
75108
  await removeGitMemoryTag2(agentId);
74985
75109
  }
74986
75110
  let pullSummary;
74987
75111
  if (isEnabled) {
74988
- const { addGitMemoryTag: addGitMemoryTag2, isGitRepo: isGitRepo2, cloneMemoryRepo: cloneMemoryRepo2, pullMemory: pullMemory2 } = await init_memoryGit().then(() => exports_memoryGit);
75112
+ const { addGitMemoryTag: addGitMemoryTag2, isGitRepo: isGitRepo2, cloneMemoryRepo: cloneMemoryRepo2, pullMemory: pullMemory2 } = await Promise.resolve().then(() => (init_memoryGit(), exports_memoryGit));
74989
75113
  await addGitMemoryTag2(agentId, options?.agentTags ? { tags: options.agentTags } : undefined);
74990
75114
  if (!isGitRepo2(agentId)) {
74991
75115
  await cloneMemoryRepo2(agentId);
@@ -74993,7 +75117,7 @@ async function applyMemfsFlags(agentId, memfsFlag, noMemfsFlag, options) {
74993
75117
  const result = await pullMemory2(agentId);
74994
75118
  pullSummary = result.summary;
74995
75119
  }
74996
- const { initSecretsFromServer: initSecretsFromServer2 } = await init_secretsStore().then(() => exports_secretsStore);
75120
+ const { initSecretsFromServer: initSecretsFromServer2 } = await Promise.resolve().then(() => (init_secretsStore(), exports_secretsStore));
74997
75121
  try {
74998
75122
  await initSecretsFromServer2(agentId);
74999
75123
  } catch {}
@@ -75006,7 +75130,7 @@ async function applyMemfsFlags(agentId, memfsFlag, noMemfsFlag, options) {
75006
75130
  };
75007
75131
  }
75008
75132
  async function isLettaCloud() {
75009
- const { getServerUrl: getServerUrl2 } = await init_client2().then(() => exports_client);
75133
+ const { getServerUrl: getServerUrl2 } = await Promise.resolve().then(() => (init_client2(), exports_client));
75010
75134
  const serverUrl = getServerUrl2();
75011
75135
  return serverUrl.includes("api.letta.com") || process.env.LETTA_MEMFS_LOCAL === "1" || process.env.LETTA_API_KEY === "local-desktop";
75012
75136
  }
@@ -75858,9 +75982,9 @@ async function fetchRunErrorDetail(runId) {
75858
75982
  const errorInfo = await fetchRunErrorInfo(runId);
75859
75983
  return errorInfo?.detail ?? errorInfo?.message ?? null;
75860
75984
  }
75861
- var init_approval_recovery = __esm(async () => {
75985
+ var init_approval_recovery = __esm(() => {
75986
+ init_client2();
75862
75987
  init_turn_recovery_policy();
75863
- await init_client2();
75864
75988
  });
75865
75989
 
75866
75990
  // src/agent/check-approval.ts
@@ -76585,12 +76709,10 @@ var init_message = __esm(async () => {
76585
76709
  init_streamAbortRelay();
76586
76710
  init_timing();
76587
76711
  init_approval_result_normalization();
76712
+ init_client2();
76588
76713
  init_clientSkills();
76589
76714
  init_context();
76590
- await __promiseAll([
76591
- init_manager3(),
76592
- init_client2()
76593
- ]);
76715
+ await init_manager3();
76594
76716
  streamRequestStartTimes = new WeakMap;
76595
76717
  streamToolContextIds = new WeakMap;
76596
76718
  streamRequestContexts = new WeakMap;
@@ -77796,12 +77918,10 @@ ${line.argsText}` : "";
77796
77918
  var MAX_TAIL_LINES = 5, MAX_BUFFER_SIZE = 1e5, CANCEL_REASON_TEXT;
77797
77919
  var init_accumulator = __esm(async () => {
77798
77920
  init_constants();
77921
+ init_hooks();
77799
77922
  init_debug();
77800
77923
  init_backfill();
77801
- await __promiseAll([
77802
- init_hooks(),
77803
- init_toolNameMapping()
77804
- ]);
77924
+ await init_toolNameMapping();
77805
77925
  CANCEL_REASON_TEXT = {
77806
77926
  user_interrupt: INTERRUPTED_BY_USER,
77807
77927
  stream_error: "Stream error",
@@ -77851,8 +77971,8 @@ async function handleMemorySubagentCompletion(args, deps) {
77851
77971
  }
77852
77972
  return `${baseMessage} System prompt recompilation failed: ${recompileError}`;
77853
77973
  }
77854
- var init_memorySubagentCompletion = __esm(async () => {
77855
- await init_modify();
77974
+ var init_memorySubagentCompletion = __esm(() => {
77975
+ init_modify();
77856
77976
  });
77857
77977
 
77858
77978
  // src/cli/helpers/reflectionTranscript.ts
@@ -78871,14 +78991,14 @@ async function drainStreamWithResume(stream2, buffers, refresh, abortSignal, onF
78871
78991
  var FALLBACK_RUN_DISCOVERY_TIMEOUT_MS = 5000;
78872
78992
  var init_stream = __esm(async () => {
78873
78993
  init_error();
78994
+ init_client2();
78995
+ init_telemetry();
78874
78996
  init_debug();
78875
78997
  init_streamAbortRelay();
78876
78998
  init_timing();
78877
78999
  init_chunkLog();
78878
79000
  await __promiseAll([
78879
- init_client2(),
78880
79001
  init_message(),
78881
- init_telemetry(),
78882
79002
  init_accumulator()
78883
79003
  ]);
78884
79004
  });
@@ -78938,10 +79058,10 @@ ${SYSTEM_REMINDER_CLOSE}`;
78938
79058
  return "";
78939
79059
  }
78940
79060
  }
78941
- var init_agentInfo = __esm(async () => {
79061
+ var init_agentInfo = __esm(() => {
78942
79062
  init_memoryFilesystem();
78943
79063
  init_constants();
78944
- await init_settings_manager();
79064
+ init_settings_manager();
78945
79065
  });
78946
79066
 
78947
79067
  // src/reminders/catalog.ts
@@ -79056,7 +79176,7 @@ async function buildSecretsInfoReminder(context3) {
79056
79176
  }
79057
79177
  context3.state.hasSentSecretsInfo = true;
79058
79178
  try {
79059
- const { listSecretNames: listSecretNames2 } = await init_secretsStore().then(() => exports_secretsStore);
79179
+ const { listSecretNames: listSecretNames2 } = await Promise.resolve().then(() => (init_secretsStore(), exports_secretsStore));
79060
79180
  const names = listSecretNames2();
79061
79181
  if (names.length === 0) {
79062
79182
  return null;
@@ -79279,17 +79399,15 @@ function prependReminderPartsToContent(content, reminderParts) {
79279
79399
  return content;
79280
79400
  }
79281
79401
  var PERMISSION_MODE_DESCRIPTIONS, MAX_COMMAND_REMINDERS_PER_TURN = 10, MAX_TOOLSET_REMINDERS_PER_TURN = 5, MAX_COMMAND_INPUT_CHARS = 2000, MAX_COMMAND_OUTPUT_CHARS = 4000, MAX_TOOL_LIST_CHARS = 3000, sharedReminderProviders;
79282
- var init_engine = __esm(async () => {
79402
+ var init_engine = __esm(() => {
79403
+ init_agentInfo();
79404
+ init_memoryReminder();
79283
79405
  init_sessionContext();
79284
79406
  init_constants();
79285
79407
  init_mode();
79408
+ init_settings_manager();
79286
79409
  init_debug();
79287
79410
  init_catalog();
79288
- await __promiseAll([
79289
- init_agentInfo(),
79290
- init_memoryReminder(),
79291
- init_settings_manager()
79292
- ]);
79293
79411
  PERMISSION_MODE_DESCRIPTIONS = {
79294
79412
  default: "Normal approval flow.",
79295
79413
  acceptEdits: "File edits auto-approved.",
@@ -82329,6 +82447,7 @@ async function resolveRecoveredApprovalResponse(runtime, socket, response, proce
82329
82447
  var init_recovery = __esm(async () => {
82330
82448
  init_error();
82331
82449
  init_check_approval();
82450
+ init_client2();
82332
82451
  init_turn_recovery_policy();
82333
82452
  init_diffPreview();
82334
82453
  init_interactivePolicy();
@@ -82338,7 +82457,6 @@ var init_recovery = __esm(async () => {
82338
82457
  init_runtime();
82339
82458
  await __promiseAll([
82340
82459
  init_approval_execution(),
82341
- init_client2(),
82342
82460
  init_accumulator(),
82343
82461
  init_stream(),
82344
82462
  init_toolset(),
@@ -82864,7 +82982,9 @@ async function sendApprovalContinuationWithRetry(conversationId, messages, opts,
82864
82982
  }
82865
82983
  var init_send = __esm(async () => {
82866
82984
  init_error();
82985
+ init_approval_recovery();
82867
82986
  init_check_approval();
82987
+ init_client2();
82868
82988
  init_turn_recovery_policy();
82869
82989
  init_errorFormatter();
82870
82990
  init_diffPreview();
@@ -82876,8 +82996,6 @@ var init_send = __esm(async () => {
82876
82996
  init_skill_injection();
82877
82997
  await __promiseAll([
82878
82998
  init_approval_execution(),
82879
- init_approval_recovery(),
82880
- init_client2(),
82881
82999
  init_message(),
82882
83000
  init_toolset(),
82883
83001
  init_approval(),
@@ -83240,10 +83358,10 @@ __export(exports_memfs_sync, {
83240
83358
  ensureMemfsSyncedForAgent: () => ensureMemfsSyncedForAgent
83241
83359
  });
83242
83360
  async function syncMemfsForAgent(agentId) {
83243
- const { getClient: getClient3 } = await init_client2().then(() => exports_client);
83361
+ const { getClient: getClient3 } = await Promise.resolve().then(() => (init_client2(), exports_client));
83244
83362
  const client = await getClient3();
83245
83363
  const agent = await client.agents.retrieve(agentId);
83246
- const { GIT_MEMORY_ENABLED_TAG: GIT_MEMORY_ENABLED_TAG2 } = await init_memoryGit().then(() => exports_memoryGit);
83364
+ const { GIT_MEMORY_ENABLED_TAG: GIT_MEMORY_ENABLED_TAG2 } = await Promise.resolve().then(() => (init_memoryGit(), exports_memoryGit));
83247
83365
  if (!agent.tags?.includes(GIT_MEMORY_ENABLED_TAG2)) {
83248
83366
  debugLog("memfs-sync", `Agent ${agentId} does not have memfs tag, skipping`);
83249
83367
  return;
@@ -83329,7 +83447,7 @@ function buildMaybeLaunchReflectionSubagent(params) {
83329
83447
  cwd: workingDirectory,
83330
83448
  parentMemory
83331
83449
  });
83332
- const { spawnBackgroundSubagentTask: spawnBackgroundSubagentTask2 } = await init_Task2().then(() => exports_Task);
83450
+ const { spawnBackgroundSubagentTask: spawnBackgroundSubagentTask2 } = await Promise.resolve().then(() => (init_Task2(), exports_Task));
83333
83451
  const { subagentId } = spawnBackgroundSubagentTask2({
83334
83452
  subagentType: "reflection",
83335
83453
  prompt: reflectionPrompt,
@@ -83948,13 +84066,21 @@ async function handleIncomingMessage(msg, socket, runtime, onStatusChange, conne
83948
84066
  }
83949
84067
  var AUTO_REFLECTION_DESCRIPTION = "Reflect on recent conversations";
83950
84068
  var init_turn = __esm(async () => {
84069
+ init_approval_recovery();
83951
84070
  init_check_approval();
84071
+ init_client2();
83952
84072
  init_context();
83953
84073
  init_memoryFilesystem();
83954
84074
  init_turn_recovery_policy();
83955
84075
  init_errorFormatter();
84076
+ init_memoryReminder();
84077
+ init_memorySubagentCompletion();
83956
84078
  init_subagentState();
84079
+ init_engine();
83957
84080
  init_planModeReminder();
84081
+ init_settings_manager();
84082
+ init_telemetry();
84083
+ init_errorReporting();
83958
84084
  init_debug();
83959
84085
  init_constants2();
83960
84086
  init_cwd();
@@ -83962,18 +84088,10 @@ var init_turn = __esm(async () => {
83962
84088
  init_runtime();
83963
84089
  init_skill_injection();
83964
84090
  await __promiseAll([
83965
- init_approval_recovery(),
83966
- init_client2(),
83967
84091
  init_message(),
83968
84092
  init_accumulator(),
83969
- init_memoryReminder(),
83970
- init_memorySubagentCompletion(),
83971
84093
  init_reflectionTranscript(),
83972
84094
  init_stream(),
83973
- init_engine(),
83974
- init_settings_manager(),
83975
- init_telemetry(),
83976
- init_errorReporting(),
83977
84095
  init_toolset(),
83978
84096
  init_interrupts(),
83979
84097
  init_protocol_outbound(),
@@ -84226,16 +84344,16 @@ async function handleChannelsCommand(_socket, conversationRuntime, args, _opts)
84226
84344
  }
84227
84345
  var SUPPORTED_REMOTE_COMMANDS;
84228
84346
  var init_commands = __esm(async () => {
84347
+ init_client2();
84229
84348
  init_memory();
84230
84349
  init_memoryFilesystem();
84231
84350
  init_promptAssets();
84232
84351
  init_initCommand();
84233
84352
  init_constants();
84353
+ init_settings_manager();
84354
+ init_errorReporting();
84234
84355
  init_runtime();
84235
84356
  await __promiseAll([
84236
- init_client2(),
84237
- init_settings_manager(),
84238
- init_errorReporting(),
84239
84357
  init_protocol_outbound(),
84240
84358
  init_turn()
84241
84359
  ]);
@@ -84692,19 +84810,17 @@ var GIT_CONTEXT_CACHE_TTL_MS = 15000, MAX_GIT_CONTEXT_CACHE_ENTRIES = 64, gitCon
84692
84810
  var init_protocol_outbound = __esm(async () => {
84693
84811
  init_memoryFilesystem();
84694
84812
  init_gitContext();
84813
+ init_memoryReminder();
84695
84814
  init_subagentState();
84696
84815
  init_mode();
84816
+ init_settings_manager();
84697
84817
  init_process_manager();
84698
84818
  init_debug();
84699
84819
  init_constants2();
84700
84820
  init_cwd();
84701
84821
  init_permissionMode();
84702
84822
  init_runtime();
84703
- await __promiseAll([
84704
- init_memoryReminder(),
84705
- init_settings_manager(),
84706
- init_commands()
84707
- ]);
84823
+ await init_commands();
84708
84824
  gitContextCache = new Map;
84709
84825
  });
84710
84826
 
@@ -84992,10 +85108,10 @@ function scheduleQueuePump(runtime, socket, opts, processQueuedTurn) {
84992
85108
  }
84993
85109
  var init_queue = __esm(async () => {
84994
85110
  init_queueRuntime();
85111
+ init_errorReporting();
84995
85112
  init_runtime();
84996
85113
  await __promiseAll([
84997
85114
  init_imageResize(),
84998
- init_errorReporting(),
84999
85115
  init_protocol_outbound()
85000
85116
  ]);
85001
85117
  });
@@ -86977,7 +87093,7 @@ async function handleCreateAgentCommand(parsed, socket) {
86977
87093
  return;
86978
87094
  }
86979
87095
  }
86980
- const { createAgentForPersonality: createAgentForPersonality2 } = await init_personality().then(() => exports_personality);
87096
+ const { createAgentForPersonality: createAgentForPersonality2 } = await Promise.resolve().then(() => (init_personality(), exports_personality));
86981
87097
  const result = await createAgentForPersonality2({
86982
87098
  personalityId: parsed.personality,
86983
87099
  model: parsed.model
@@ -87087,12 +87203,12 @@ function wireChannelIngress(listener, socket, opts, processQueuedTurn) {
87087
87203
  const registry = getChannelRegistry();
87088
87204
  if (!registry)
87089
87205
  return;
87090
- registry.setMessageHandler((route, xmlContent) => {
87206
+ registry.setMessageHandler((route, messageContent) => {
87091
87207
  const rawRuntime = getOrCreateConversationRuntime(listener, route.agentId, route.conversationId);
87092
87208
  if (!rawRuntime)
87093
87209
  return;
87094
87210
  const conversationRuntime = ensureConversationQueueRuntime(listener, rawRuntime);
87095
- enqueueChannelTurn(conversationRuntime, route, xmlContent);
87211
+ enqueueChannelTurn(conversationRuntime, route, messageContent);
87096
87212
  scheduleQueuePump(conversationRuntime, socket, opts, processQueuedTurn);
87097
87213
  });
87098
87214
  registry.setEventHandler((event) => {
@@ -87103,12 +87219,12 @@ function wireChannelIngress(listener, socket, opts, processQueuedTurn) {
87103
87219
  });
87104
87220
  registry.setReady();
87105
87221
  }
87106
- function enqueueChannelTurn(runtime, route, xmlContent) {
87222
+ function enqueueChannelTurn(runtime, route, messageContent) {
87107
87223
  const clientMessageId = `cm-channel-${crypto.randomUUID()}`;
87108
87224
  const enqueuedItem = runtime.queueRuntime.enqueue({
87109
87225
  kind: "message",
87110
87226
  source: "channel",
87111
- content: xmlContent,
87227
+ content: messageContent,
87112
87228
  clientMessageId,
87113
87229
  agentId: route.agentId,
87114
87230
  conversationId: route.conversationId
@@ -87123,7 +87239,7 @@ function enqueueChannelTurn(runtime, route, xmlContent) {
87123
87239
  messages: [
87124
87240
  {
87125
87241
  role: "user",
87126
- content: xmlContent,
87242
+ content: messageContent,
87127
87243
  client_message_id: clientMessageId
87128
87244
  }
87129
87245
  ]
@@ -88752,15 +88868,24 @@ function createLegacyTestRuntime() {
88752
88868
  }
88753
88869
  var WIKI_LINK_REGEX, __listenClientTestUtils;
88754
88870
  var init_client4 = __esm(async () => {
88871
+ init_available_models();
88872
+ init_client2();
88873
+ init_model2();
88874
+ init_modify();
88755
88875
  init_registry();
88756
88876
  init_fileIndex();
88757
88877
  init_gitContext();
88878
+ init_memoryReminder();
88758
88879
  init_messageQueueBridge();
88759
88880
  init_planName();
88760
88881
  init_subagentState();
88761
88882
  init_constants();
88762
88883
  init_cron();
88884
+ init_byok_providers();
88763
88885
  init_queueRuntime();
88886
+ init_settings_manager();
88887
+ init_telemetry();
88888
+ init_errorReporting();
88764
88889
  init_toolset_labels();
88765
88890
  init_debug();
88766
88891
  init_terminalHandler();
@@ -88769,16 +88894,7 @@ var init_client4 = __esm(async () => {
88769
88894
  init_permissionMode();
88770
88895
  init_runtime();
88771
88896
  await __promiseAll([
88772
- init_available_models(),
88773
- init_client2(),
88774
- init_model2(),
88775
- init_modify(),
88776
- init_memoryReminder(),
88777
88897
  init_scheduler(),
88778
- init_byok_providers(),
88779
- init_settings_manager(),
88780
- init_telemetry(),
88781
- init_errorReporting(),
88782
88898
  init_manager3(),
88783
88899
  init_toolset(),
88784
88900
  init_approval(),
@@ -89391,9 +89507,9 @@ async function bootstrapBaseToolsIfNeeded() {
89391
89507
  }
89392
89508
  }
89393
89509
  var MARKER_PATH;
89394
- var init_bootstrap_tools = __esm(async () => {
89510
+ var init_bootstrap_tools = __esm(() => {
89395
89511
  init_debug();
89396
- await init_create();
89512
+ init_create();
89397
89513
  MARKER_PATH = join33(homedir28(), ".letta", ".bootstrapped");
89398
89514
  });
89399
89515
 
@@ -89912,9 +90028,9 @@ To update manually: ${installCmd}`
89912
90028
  };
89913
90029
  }
89914
90030
  var execFileAsync7, DEBUG, DEFAULT_UPDATE_PACKAGE_NAME = "@letta-ai/letta-code", DEFAULT_UPDATE_REGISTRY_BASE_URL = "https://registry.npmjs.org", UPDATE_PACKAGE_NAME_ENV = "LETTA_UPDATE_PACKAGE_NAME", UPDATE_REGISTRY_BASE_URL_ENV = "LETTA_UPDATE_REGISTRY_BASE_URL", UPDATE_INSTALL_REGISTRY_URL_ENV = "LETTA_UPDATE_INSTALL_REGISTRY_URL", INSTALL_ARG_PREFIX, VALID_PACKAGE_MANAGERS;
89915
- var init_auto_update = __esm(async () => {
90031
+ var init_auto_update = __esm(() => {
90032
+ init_errorReporting();
89916
90033
  init_version();
89917
- await init_errorReporting();
89918
90034
  execFileAsync7 = promisify13(execFile13);
89919
90035
  DEBUG = process.env.LETTA_DEBUG_AUTOUPDATE === "1";
89920
90036
  INSTALL_ARG_PREFIX = {
@@ -89989,11 +90105,9 @@ async function startDockerVersionCheck() {
89989
90105
  } catch {}
89990
90106
  }
89991
90107
  var MINIMUM_DOCKER_VERSION = "0.16.6";
89992
- var init_startup_docker_check = __esm(async () => {
89993
- await __promiseAll([
89994
- init_client2(),
89995
- init_settings_manager()
89996
- ]);
90108
+ var init_startup_docker_check = __esm(() => {
90109
+ init_client2();
90110
+ init_settings_manager();
89997
90111
  });
89998
90112
 
89999
90113
  // src/tools/impl/overflow.ts
@@ -90535,12 +90649,12 @@ function SetupUI({ onComplete }) {
90535
90649
  var import_react31, jsx_dev_runtime10, AUTH_LOGIN_LABEL = "Login to Letta Code", AUTH_LOGO_ANIMATE = false;
90536
90650
  var init_setup_ui = __esm(async () => {
90537
90651
  init_colors();
90652
+ init_settings_manager();
90653
+ init_oauth();
90538
90654
  await __promiseAll([
90539
90655
  init_build2(),
90540
90656
  init_AnimatedLogo(),
90541
- init_Text2(),
90542
- init_settings_manager(),
90543
- init_oauth()
90657
+ init_Text2()
90544
90658
  ]);
90545
90659
  import_react31 = __toESM(require_react(), 1);
90546
90660
  jsx_dev_runtime10 = __toESM(require_jsx_dev_runtime(), 1);
@@ -91226,12 +91340,10 @@ async function importAgentFromRegistry(options) {
91226
91340
  }
91227
91341
  }
91228
91342
  var AGENT_REGISTRY_OWNER = "letta-ai", AGENT_REGISTRY_REPO = "agent-file", AGENT_REGISTRY_BRANCH = "main";
91229
- var init_import = __esm(async () => {
91230
- await __promiseAll([
91231
- init_client2(),
91232
- init_model2(),
91233
- init_modify()
91234
- ]);
91343
+ var init_import = __esm(() => {
91344
+ init_client2();
91345
+ init_model2();
91346
+ init_modify();
91235
91347
  });
91236
91348
 
91237
91349
  // src/agent/defaults.ts
@@ -91324,15 +91436,13 @@ async function ensureDefaultAgents(client, options) {
91324
91436
  }
91325
91437
  }
91326
91438
  var MEMO_TAG = "default:memo", INCOGNITO_TAG = "default:incognito", MEMO_PERSONA, MEMO_HUMAN, MEMO_DESCRIPTION = "The default Letta Code agent with persistent memory", INCOGNITO_DESCRIPTION = "A stateless coding agent without memory (incognito mode)", DEFAULT_AGENT_CONFIGS;
91327
- var init_defaults = __esm(async () => {
91439
+ var init_defaults = __esm(() => {
91440
+ init_settings_manager();
91441
+ init_client2();
91442
+ init_create();
91328
91443
  init_memory();
91444
+ init_model2();
91329
91445
  init_promptAssets();
91330
- await __promiseAll([
91331
- init_settings_manager(),
91332
- init_client2(),
91333
- init_create(),
91334
- init_model2()
91335
- ]);
91336
91446
  MEMO_PERSONA = parseMdxFrontmatter(MEMORY_PROMPTS["persona_memo.mdx"] ?? "").body;
91337
91447
  MEMO_HUMAN = parseMdxFrontmatter(MEMORY_PROMPTS["human_memo.mdx"] ?? "").body;
91338
91448
  DEFAULT_AGENT_CONFIGS = {
@@ -91810,7 +91920,7 @@ In headless mode, use:
91810
91920
  if (!agent && fromAfFile) {
91811
91921
  let result;
91812
91922
  if (isRegistryImport) {
91813
- const { importAgentFromRegistry: importAgentFromRegistry2 } = await init_import().then(() => exports_import);
91923
+ const { importAgentFromRegistry: importAgentFromRegistry2 } = await Promise.resolve().then(() => (init_import(), exports_import));
91814
91924
  result = await importAgentFromRegistry2({
91815
91925
  handle: fromAfFile,
91816
91926
  modelOverride: model,
@@ -91818,7 +91928,7 @@ In headless mode, use:
91818
91928
  stripSkills: false
91819
91929
  });
91820
91930
  } else {
91821
- const { importAgentFromFile: importAgentFromFile2 } = await init_import().then(() => exports_import);
91931
+ const { importAgentFromFile: importAgentFromFile2 } = await Promise.resolve().then(() => (init_import(), exports_import));
91822
91932
  result = await importAgentFromFile2({
91823
91933
  filePath: fromAfFile,
91824
91934
  modelOverride: model,
@@ -91888,7 +91998,7 @@ In headless mode, use:
91888
91998
  }
91889
91999
  }
91890
92000
  if (!agent) {
91891
- const { ensureDefaultAgents: ensureDefaultAgents2 } = await init_defaults().then(() => exports_defaults);
92001
+ const { ensureDefaultAgents: ensureDefaultAgents2 } = await Promise.resolve().then(() => (init_defaults(), exports_defaults));
91892
92002
  const defaultAgent = await ensureDefaultAgents2(client, {
91893
92003
  preferredModel: model
91894
92004
  });
@@ -91928,7 +92038,7 @@ In headless mode, use:
91928
92038
  const startupMemfsFlag = autoEnableMemfsForFreshAgent ? true : memfsFlag;
91929
92039
  let memfsBgPromise;
91930
92040
  const secretsAgentId = agent?.id;
91931
- const secretsInitPromise = secretsAgentId ? init_secretsStore().then(() => exports_secretsStore).then(({ initSecretsFromServer: initSecretsFromServer2 }) => initSecretsFromServer2(secretsAgentId)) : Promise.resolve();
92041
+ const secretsInitPromise = secretsAgentId ? Promise.resolve().then(() => (init_secretsStore(), exports_secretsStore)).then(({ initSecretsFromServer: initSecretsFromServer2 }) => initSecretsFromServer2(secretsAgentId)) : Promise.resolve();
91932
92042
  if (memfsStartupPolicy === "skip") {
91933
92043
  try {
91934
92044
  const { applyMemfsFlags: applyMemfsFlags2 } = await Promise.resolve().then(() => (init_memoryFilesystem(), exports_memoryFilesystem));
@@ -93971,36 +94081,36 @@ async function runBidirectionalMode(agent, conversationId, client, _outputFormat
93971
94081
  var LLM_API_ERROR_MAX_RETRIES2 = 3, EMPTY_RESPONSE_MAX_RETRIES2 = 2, PROVIDER_FALLBACK_MAP, CONVERSATION_BUSY_MAX_RETRIES = 3, __headlessTestUtils;
93972
94082
  var init_headless = __esm(async () => {
93973
94083
  init_error();
94084
+ init_approval_recovery();
93974
94085
  init_bootstrapHandler();
94086
+ init_client2();
93975
94087
  init_clientSkills();
93976
94088
  init_context();
94089
+ init_create();
93977
94090
  init_listMessagesHandler();
93978
94091
  init_memory();
94092
+ init_model2();
94093
+ init_modify();
93979
94094
  init_skillSources();
93980
94095
  init_errorFormatter();
94096
+ init_memoryReminder();
93981
94097
  init_messageQueueBridge();
93982
94098
  init_constants();
93983
94099
  init_diffPreview();
93984
94100
  init_queueRuntime();
94101
+ init_engine();
93985
94102
  init_runtime_context();
94103
+ init_settings_manager();
94104
+ init_telemetry();
94105
+ init_errorReporting();
93986
94106
  init_interactivePolicy();
93987
94107
  init_debug();
93988
94108
  init_timing();
93989
94109
  await __promiseAll([
93990
- init_approval_recovery(),
93991
- init_client2(),
93992
- init_create(),
93993
94110
  init_message(),
93994
- init_model2(),
93995
- init_modify(),
93996
94111
  init_accumulator(),
93997
94112
  init_approvalClassification(),
93998
- init_memoryReminder(),
93999
94113
  init_stream(),
94000
- init_engine(),
94001
- init_settings_manager(),
94002
- init_telemetry(),
94003
- init_errorReporting(),
94004
94114
  init_manager3(),
94005
94115
  init_toolset()
94006
94116
  ]);
@@ -94733,9 +94843,9 @@ Use /mcp and press R to refresh manually.`, true);
94733
94843
  }
94734
94844
  }
94735
94845
  var activeCommandId = null;
94736
- var init_mcp = __esm(async () => {
94846
+ var init_mcp = __esm(() => {
94847
+ init_client2();
94737
94848
  init_errorFormatter();
94738
- await init_client2();
94739
94849
  });
94740
94850
 
94741
94851
  // src/cli/commands/profile.ts
@@ -94890,7 +95000,7 @@ async function handlePin(ctx, msg, argsStr) {
94890
95000
  const globalPinned = settingsManager.getGlobalPinnedAgents();
94891
95001
  if (name && name !== ctx.agentName) {
94892
95002
  try {
94893
- const { getClient: getClient3 } = await init_client2().then(() => exports_client);
95003
+ const { getClient: getClient3 } = await Promise.resolve().then(() => (init_client2(), exports_client));
94894
95004
  const client = await getClient3();
94895
95005
  await client.agents.update(ctx.agentId, { name });
94896
95006
  ctx.updateAgentName(name);
@@ -94938,12 +95048,10 @@ function handleUnpin(ctx, msg, argsStr) {
94938
95048
  }
94939
95049
  }
94940
95050
  var activeCommandId2 = null;
94941
- var init_profile = __esm(async () => {
95051
+ var init_profile = __esm(() => {
95052
+ init_client2();
95053
+ init_settings_manager();
94942
95054
  init_errorFormatter();
94943
- await __promiseAll([
94944
- init_client2(),
94945
- init_settings_manager()
94946
- ]);
94947
95055
  });
94948
95056
 
94949
95057
  // src/cli/commands/runner.ts
@@ -95822,13 +95930,13 @@ function AgentSelector({
95822
95930
  }
95823
95931
  var import_react33, jsx_dev_runtime11, SOLID_LINE2 = "─", TABS, TAB_DESCRIPTIONS, TAB_EMPTY_STATES, DISPLAY_PAGE_SIZE2 = 5, FETCH_PAGE_SIZE2 = 20;
95824
95932
  var init_AgentSelector = __esm(async () => {
95933
+ init_client2();
95934
+ init_model2();
95935
+ init_settings_manager();
95825
95936
  init_useTerminalWidth();
95826
95937
  init_colors();
95827
95938
  await __promiseAll([
95828
95939
  init_build2(),
95829
- init_client2(),
95830
- init_model2(),
95831
- init_settings_manager(),
95832
95940
  init_MarkdownDisplay(),
95833
95941
  init_Text2()
95834
95942
  ]);
@@ -115945,12 +116053,12 @@ function ConversationSelector2({
115945
116053
  }
115946
116054
  var import_react59, jsx_dev_runtime36, SOLID_LINE14 = "─", DISPLAY_PAGE_SIZE3 = 3, FETCH_PAGE_SIZE3 = 20, ENRICH_MESSAGE_LIMIT2 = 20, RESUME_PREVIEW_MESSAGE_TYPES2;
115947
116055
  var init_ConversationSelector = __esm(async () => {
116056
+ init_client2();
115948
116057
  init_constants();
115949
116058
  init_useTerminalWidth();
115950
116059
  init_colors();
115951
116060
  await __promiseAll([
115952
116061
  init_build2(),
115953
- init_client2(),
115954
116062
  init_MarkdownDisplay(),
115955
116063
  init_Text2()
115956
116064
  ]);
@@ -117153,8 +117261,8 @@ Use /secret help for usage.`
117153
117261
  }
117154
117262
  }
117155
117263
  }
117156
- var init_secret = __esm(async () => {
117157
- await init_secretsStore();
117264
+ var init_secret = __esm(() => {
117265
+ init_secretsStore();
117158
117266
  });
117159
117267
 
117160
117268
  // src/cli/utils/terminalKeybindingInstaller.ts
@@ -117508,8 +117616,8 @@ async function executeCommand(input) {
117508
117616
  }
117509
117617
  }
117510
117618
  var commands;
117511
- var init_registry2 = __esm(async () => {
117512
- await init_secret();
117619
+ var init_registry2 = __esm(() => {
117620
+ init_secret();
117513
117621
  commands = {
117514
117622
  "/agents": {
117515
117623
  desc: "Browse agents (pinned, Letta Code, all)",
@@ -118116,8 +118224,8 @@ async function expandBashCommands(content) {
118116
118224
  if (matches.length === 0) {
118117
118225
  return content;
118118
118226
  }
118119
- const { spawnCommand: spawnCommand2 } = await init_Bash2().then(() => exports_Bash);
118120
- const { getShellEnv: getShellEnv2 } = await init_shellEnv().then(() => exports_shellEnv);
118227
+ const { spawnCommand: spawnCommand2 } = await Promise.resolve().then(() => (init_Bash2(), exports_Bash));
118228
+ const { getShellEnv: getShellEnv2 } = await Promise.resolve().then(() => (init_shellEnv(), exports_shellEnv));
118121
118229
  let result = content;
118122
118230
  for (const match3 of matches) {
118123
118231
  const fullMatch = match3[0];
@@ -118418,10 +118526,10 @@ function HelpDialog({ onClose }) {
118418
118526
  var import_react65, jsx_dev_runtime42, PAGE_SIZE = 10, HELP_TABS;
118419
118527
  var init_HelpDialog = __esm(async () => {
118420
118528
  init_version();
118529
+ init_registry2();
118421
118530
  init_colors();
118422
118531
  await __promiseAll([
118423
118532
  init_build2(),
118424
- init_registry2(),
118425
118533
  init_Text2()
118426
118534
  ]);
118427
118535
  import_react65 = __toESM(require_react(), 1);
@@ -118622,10 +118730,10 @@ function setHooksDisabled(disabled) {
118622
118730
  }
118623
118731
  });
118624
118732
  }
118625
- var init_writer = __esm(async () => {
118733
+ var init_writer = __esm(() => {
118734
+ init_settings_manager();
118626
118735
  init_debug();
118627
118736
  init_types();
118628
- await init_settings_manager();
118629
118737
  });
118630
118738
 
118631
118739
  // src/cli/components/HooksManager.tsx
@@ -118664,12 +118772,12 @@ function boxBottom(width) {
118664
118772
  var import_react66, jsx_dev_runtime43, BOX_TOP_LEFT = "╭", BOX_TOP_RIGHT = "╮", BOX_BOTTOM_LEFT = "╰", BOX_BOTTOM_RIGHT = "╯", BOX_HORIZONTAL = "─", BOX_VERTICAL = "│", HOOK_EVENTS, FALLBACK_TOOL_NAMES, SAVE_LOCATIONS, HooksManager;
118665
118773
  var init_HooksManager = __esm(async () => {
118666
118774
  init_types();
118775
+ init_writer();
118776
+ init_settings_manager();
118667
118777
  init_useTerminalWidth();
118668
118778
  init_colors();
118669
118779
  await __promiseAll([
118670
118780
  init_build2(),
118671
- init_writer(),
118672
- init_settings_manager(),
118673
118781
  init_PasteAwareTextInput(),
118674
118782
  init_Text2()
118675
118783
  ]);
@@ -118735,7 +118843,7 @@ var init_HooksManager = __esm(async () => {
118735
118843
  return;
118736
118844
  const fetchAgentTools = async () => {
118737
118845
  try {
118738
- const { getClient: getClient3 } = await init_client2().then(() => exports_client);
118846
+ const { getClient: getClient3 } = await Promise.resolve().then(() => (init_client2(), exports_client));
118739
118847
  const client = await getClient3();
118740
118848
  const toolsPage = await client.agents.tools.list(agentId, {
118741
118849
  limit: 50
@@ -120883,13 +120991,13 @@ var import_react68, jsx_dev_runtime45, AgentInfoBar;
120883
120991
  var init_AgentInfoBar = __esm(async () => {
120884
120992
  init_string_width();
120885
120993
  init_constants();
120994
+ init_settings_manager();
120886
120995
  init_version();
120887
120996
  init_useTerminalWidth();
120888
120997
  init_colors();
120889
120998
  await __promiseAll([
120890
120999
  init_build2(),
120891
121000
  init_dist5(),
120892
- init_settings_manager(),
120893
121001
  init_Text2()
120894
121002
  ]);
120895
121003
  import_react68 = __toESM(require_react(), 1);
@@ -121662,10 +121770,10 @@ function SlashCommandAutocomplete({
121662
121770
  }
121663
121771
  var import_react71, jsx_dev_runtime48, VISIBLE_COMMANDS = 7, CMD_COL_WIDTH = 14, _allCommands;
121664
121772
  var init_SlashCommandAutocomplete = __esm(async () => {
121773
+ init_settings_manager();
121774
+ init_registry2();
121665
121775
  init_useTerminalWidth();
121666
121776
  await __promiseAll([
121667
- init_settings_manager(),
121668
- init_registry2(),
121669
121777
  init_useAutocompleteNavigation(),
121670
121778
  init_Autocomplete(),
121671
121779
  init_Text2()
@@ -122777,9 +122885,12 @@ var import_react75, jsx_dev_runtime52, Spinner2, ESC_CLEAR_WINDOW_MS = 2500, FOO
122777
122885
  var init_InputRich = __esm(async () => {
122778
122886
  init_source();
122779
122887
  init_string_width();
122888
+ init_oauth();
122780
122889
  init_constants();
122781
122890
  init_mode();
122891
+ init_openai_codex_provider();
122782
122892
  init_mode2();
122893
+ init_settings_manager();
122783
122894
  init_subagentState();
122784
122895
  init_thinkingMessages();
122785
122896
  init_colors();
@@ -122787,9 +122898,6 @@ var init_InputRich = __esm(async () => {
122787
122898
  init_build2(),
122788
122899
  init_dist5(),
122789
122900
  init_build4(),
122790
- init_oauth(),
122791
- init_openai_codex_provider(),
122792
- init_settings_manager(),
122793
122901
  init_BlinkingSpinner(),
122794
122902
  init_InputAssist(),
122795
122903
  init_PasteAwareTextInput(),
@@ -123735,6 +123843,7 @@ function ChoiceList({
123735
123843
  var import_react76, jsx_dev_runtime53, TextInput2, SOLID_LINE16 = "─", InstallGithubAppFlow;
123736
123844
  var init_InstallGithubAppFlow = __esm(async () => {
123737
123845
  init_context();
123846
+ init_settings_manager();
123738
123847
  init_install_github_app();
123739
123848
  init_useTerminalWidth();
123740
123849
  init_colors();
@@ -123742,7 +123851,6 @@ var init_InstallGithubAppFlow = __esm(async () => {
123742
123851
  init_build2(),
123743
123852
  init_dist5(),
123744
123853
  init_build3(),
123745
- init_settings_manager(),
123746
123854
  init_PasteAwareTextInput(),
123747
123855
  init_Text2()
123748
123856
  ]);
@@ -124416,12 +124524,10 @@ async function connectMcpServer(config, options = {}) {
124416
124524
  reader.releaseLock();
124417
124525
  }
124418
124526
  }
124419
- var init_mcpOauth = __esm(async () => {
124527
+ var init_mcpOauth = __esm(() => {
124528
+ init_client2();
124420
124529
  init_http_headers();
124421
- await __promiseAll([
124422
- init_client2(),
124423
- init_settings_manager()
124424
- ]);
124530
+ init_settings_manager();
124425
124531
  });
124426
124532
 
124427
124533
  // src/cli/components/McpConnectFlow.tsx
@@ -124453,12 +124559,12 @@ function validateName(name) {
124453
124559
  }
124454
124560
  var import_react77, jsx_dev_runtime54, SOLID_LINE17 = "─", TRANSPORTS, McpConnectFlow;
124455
124561
  var init_McpConnectFlow = __esm(async () => {
124562
+ init_client2();
124563
+ init_mcpOauth();
124456
124564
  init_useTerminalWidth();
124457
124565
  init_colors();
124458
124566
  await __promiseAll([
124459
124567
  init_build2(),
124460
- init_client2(),
124461
- init_mcpOauth(),
124462
124568
  init_PasteAwareTextInput(),
124463
124569
  init_Text2()
124464
124570
  ]);
@@ -125103,11 +125209,11 @@ function truncateText3(text, maxWidth) {
125103
125209
  }
125104
125210
  var import_react78, jsx_dev_runtime55, SOLID_LINE18 = "─", DISPLAY_PAGE_SIZE4 = 5, TOOLS_DISPLAY_PAGE_SIZE = 8, McpSelector;
125105
125211
  var init_McpSelector = __esm(async () => {
125212
+ init_client2();
125106
125213
  init_useTerminalWidth();
125107
125214
  init_colors();
125108
125215
  await __promiseAll([
125109
125216
  init_build2(),
125110
- init_client2(),
125111
125217
  init_Text2()
125112
125218
  ]);
125113
125219
  import_react78 = __toESM(require_react(), 1);
@@ -128078,14 +128184,12 @@ async function generateAndOpenMemoryViewer(agentId, options) {
128078
128184
  return { filePath, opened: !skipOpen };
128079
128185
  }
128080
128186
  var execFile14, VIEWERS_DIR2, MAX_COMMITS = 500, RECENT_DIFF_COUNT = 50, PER_DIFF_CAP = 1e5, TOTAL_PAYLOAD_CAP = 5000000, RECORD_SEP = "\x1E", REFLECTION_PATTERN;
128081
- var init_generate_memory_viewer = __esm(async () => {
128187
+ var init_generate_memory_viewer = __esm(() => {
128188
+ init_client2();
128082
128189
  init_memoryFilesystem();
128190
+ init_memoryGit();
128083
128191
  init_memoryScanner();
128084
128192
  init_memory_viewer_template();
128085
- await __promiseAll([
128086
- init_client2(),
128087
- init_memoryGit()
128088
- ]);
128089
128193
  execFile14 = promisify14(execFileCb5);
128090
128194
  VIEWERS_DIR2 = join44(homedir35(), ".letta", "viewers");
128091
128195
  REFLECTION_PATTERN = /\(reflection\)|🔮|reflection:/i;
@@ -128560,14 +128664,14 @@ function MemfsTreeViewer({
128560
128664
  var import_react79, jsx_dev_runtime56, SOLID_LINE19 = "─", DOTTED_LINE4 = "╌", TREE_VISIBLE_LINES = 15, FULL_VIEW_VISIBLE_LINES = 16;
128561
128665
  var init_MemfsTreeViewer = __esm(async () => {
128562
128666
  init_memoryFilesystem();
128667
+ init_memoryGit();
128563
128668
  init_memoryScanner();
128669
+ init_generate_memory_viewer();
128564
128670
  init_useTerminalWidth();
128565
128671
  init_colors();
128566
128672
  await __promiseAll([
128567
128673
  init_build2(),
128568
128674
  init_dist5(),
128569
- init_memoryGit(),
128570
- init_generate_memory_viewer(),
128571
128675
  init_Text2()
128572
128676
  ]);
128573
128677
  import_react79 = __toESM(require_react(), 1);
@@ -128876,13 +128980,13 @@ function MemoryTabViewer({
128876
128980
  }
128877
128981
  var import_react80, jsx_dev_runtime57, SOLID_LINE20 = "─", VISIBLE_LINES = 12;
128878
128982
  var init_MemoryTabViewer = __esm(async () => {
128983
+ init_client2();
128879
128984
  init_debug();
128880
128985
  init_useTerminalWidth();
128881
128986
  init_colors();
128882
128987
  await __promiseAll([
128883
128988
  init_build2(),
128884
128989
  init_dist5(),
128885
- init_client2(),
128886
128990
  init_MarkdownDisplay(),
128887
128991
  init_Text2()
128888
128992
  ]);
@@ -129523,11 +129627,11 @@ function MessageSearch({
129523
129627
  }
129524
129628
  var import_react81, jsx_dev_runtime58, SOLID_LINE21 = "─", VISIBLE_ITEMS = 5, SEARCH_LIMIT = 100, SEARCH_MODES, SEARCH_RANGES;
129525
129629
  var init_MessageSearch = __esm(async () => {
129630
+ init_client2();
129526
129631
  init_useTerminalWidth();
129527
129632
  init_colors();
129528
129633
  await __promiseAll([
129529
129634
  init_build2(),
129530
- init_client2(),
129531
129635
  init_Text2()
129532
129636
  ]);
129533
129637
  import_react81 = __toESM(require_react(), 1);
@@ -130275,13 +130379,13 @@ function ModelSelector({
130275
130379
  }
130276
130380
  var import_react83, jsx_dev_runtime60, SOLID_LINE23 = "─", VISIBLE_ITEMS2 = 8, API_GATED_MODEL_HANDLES;
130277
130381
  var init_ModelSelector = __esm(async () => {
130382
+ init_available_models();
130383
+ init_model2();
130384
+ init_byok_providers();
130278
130385
  init_useTerminalWidth();
130279
130386
  init_colors();
130280
130387
  await __promiseAll([
130281
130388
  init_build2(),
130282
- init_available_models(),
130283
- init_model2(),
130284
- init_byok_providers(),
130285
130389
  init_Text2()
130286
130390
  ]);
130287
130391
  import_react83 = __toESM(require_react(), 1);
@@ -130796,11 +130900,11 @@ function PersonalitySelector({
130796
130900
  }
130797
130901
  var import_react87, jsx_dev_runtime64, SOLID_LINE25 = "─";
130798
130902
  var init_PersonalitySelector = __esm(async () => {
130903
+ init_personality();
130799
130904
  init_useTerminalWidth();
130800
130905
  init_colors();
130801
130906
  await __promiseAll([
130802
130907
  init_build2(),
130803
- init_personality(),
130804
130908
  init_Text2()
130805
130909
  ]);
130806
130910
  import_react87 = __toESM(require_react(), 1);
@@ -131744,13 +131848,13 @@ function ProviderSelector({
131744
131848
  }
131745
131849
  var import_react88, jsx_dev_runtime65, SOLID_LINE26 = "─";
131746
131850
  var init_ProviderSelector = __esm(async () => {
131851
+ init_byok_providers();
131747
131852
  init_aws_credentials();
131748
131853
  init_debug();
131749
131854
  init_useTerminalWidth();
131750
131855
  init_colors();
131751
131856
  await __promiseAll([
131752
131857
  init_build2(),
131753
- init_byok_providers(),
131754
131858
  init_Text2()
131755
131859
  ]);
131756
131860
  import_react88 = __toESM(require_react(), 1);
@@ -132517,11 +132621,9 @@ function getSubagentModelDisplay(model) {
132517
132621
  isOpenAICodexProvider
132518
132622
  };
132519
132623
  }
132520
- var init_subagentDisplay = __esm(async () => {
132521
- await __promiseAll([
132522
- init_model2(),
132523
- init_openai_codex_provider()
132524
- ]);
132624
+ var init_subagentDisplay = __esm(() => {
132625
+ init_model2();
132626
+ init_openai_codex_provider();
132525
132627
  });
132526
132628
 
132527
132629
  // src/cli/components/SubagentGroupDisplay.tsx
@@ -132545,12 +132647,12 @@ function formatToolArgs(argsStr) {
132545
132647
  var import_react93, jsx_dev_runtime70, AgentRow, GroupHeader, SubagentGroupDisplay;
132546
132648
  var init_SubagentGroupDisplay = __esm(async () => {
132547
132649
  init_AnimationContext();
132650
+ init_subagentDisplay();
132548
132651
  init_subagentState();
132549
132652
  init_useTerminalWidth();
132550
132653
  init_colors();
132551
132654
  await __promiseAll([
132552
132655
  init_build2(),
132553
- init_subagentDisplay(),
132554
132656
  init_BlinkDot(),
132555
132657
  init_Text2()
132556
132658
  ]);
@@ -132918,11 +133020,11 @@ var init_SubagentGroupDisplay = __esm(async () => {
132918
133020
  // src/cli/components/SubagentGroupStatic.tsx
132919
133021
  var import_react94, jsx_dev_runtime71, AgentRow2, SubagentGroupStatic;
132920
133022
  var init_SubagentGroupStatic = __esm(async () => {
133023
+ init_subagentDisplay();
132921
133024
  init_useTerminalWidth();
132922
133025
  init_colors();
132923
133026
  await __promiseAll([
132924
133027
  init_build2(),
132925
- init_subagentDisplay(),
132926
133028
  init_Text2()
132927
133029
  ]);
132928
133030
  import_react94 = __toESM(require_react(), 1);
@@ -135978,10 +136080,10 @@ function buildStartupSystemPromptWarning(agentState) {
135978
136080
  return null;
135979
136081
  }
135980
136082
  var STARTUP_SYSTEM_PROMPT_WARNING_THRESHOLD_TOKENS = 30000, STARTUP_SYSTEM_PROMPT_ESTIMATED_BYTES_PER_TOKEN = 4;
135981
- var init_startupSystemPromptWarning = __esm(async () => {
136083
+ var init_startupSystemPromptWarning = __esm(() => {
135982
136084
  init_memoryFilesystem();
136085
+ init_settings_manager();
135983
136086
  init_debug();
135984
- await init_settings_manager();
135985
136087
  });
135986
136088
 
135987
136089
  // src/cli/helpers/statusLineConfig.ts
@@ -136072,9 +136174,9 @@ function resolvePromptChar(workingDirectory = process.cwd()) {
136072
136174
  }
136073
136175
  }
136074
136176
  var MIN_STATUS_LINE_INTERVAL_MS = 1000, DEFAULT_STATUS_LINE_TIMEOUT_MS = 5000, MAX_STATUS_LINE_TIMEOUT_MS = 30000, DEFAULT_STATUS_LINE_DEBOUNCE_MS = 300, MIN_STATUS_LINE_DEBOUNCE_MS = 50, MAX_STATUS_LINE_DEBOUNCE_MS = 5000, MAX_STATUS_LINE_PADDING = 16;
136075
- var init_statusLineConfig = __esm(async () => {
136177
+ var init_statusLineConfig = __esm(() => {
136178
+ init_settings_manager();
136076
136179
  init_debug();
136077
- await init_settings_manager();
136078
136180
  });
136079
136181
 
136080
136182
  // src/cli/helpers/statusLineSchema.ts
@@ -136686,10 +136788,10 @@ function useConfigurableStatusLine(inputs) {
136686
136788
  return { text, rightText, active, executing, lastError, padding, prompt };
136687
136789
  }
136688
136790
  var import_react101, RS = "\x1E";
136689
- var init_useConfigurableStatusLine = __esm(async () => {
136791
+ var init_useConfigurableStatusLine = __esm(() => {
136792
+ init_statusLineConfig();
136690
136793
  init_statusLinePayload();
136691
136794
  init_statusLineRuntime();
136692
- await init_statusLineConfig();
136693
136795
  import_react101 = __toESM(require_react(), 1);
136694
136796
  });
136695
136797
 
@@ -137263,13 +137365,11 @@ async function handleDisconnect(ctx, msg) {
137263
137365
  await handleDisconnectByokProvider(ctx, msg, provider);
137264
137366
  }
137265
137367
  var activeCommandId3 = null;
137266
- var init_connect = __esm(async () => {
137267
- await __promiseAll([
137268
- init_byok_providers(),
137269
- init_openai_codex_provider(),
137270
- init_connect_normalize(),
137271
- init_connect_oauth_core()
137272
- ]);
137368
+ var init_connect = __esm(() => {
137369
+ init_byok_providers();
137370
+ init_openai_codex_provider();
137371
+ init_connect_normalize();
137372
+ init_connect_oauth_core();
137273
137373
  });
137274
137374
 
137275
137375
  // src/cli/commands/listen.ts
@@ -137470,12 +137570,10 @@ Retry ${attempt} in ${Math.round(delayMs / 1000)}s: ${error.message}`, true, "ru
137470
137570
  }
137471
137571
  }
137472
137572
  var activeCommandId4 = null;
137473
- var init_listen = __esm(async () => {
137573
+ var init_listen = __esm(() => {
137574
+ init_client2();
137575
+ init_settings_manager();
137474
137576
  init_listen_register();
137475
- await __promiseAll([
137476
- init_client2(),
137477
- init_settings_manager()
137478
- ]);
137479
137577
  });
137480
137578
 
137481
137579
  // src/agent/export.ts
@@ -139413,7 +139511,7 @@ function App2({
139413
139511
  let cancelled = false;
139414
139512
  const fetchConfig = async () => {
139415
139513
  try {
139416
- const { getClient: getClient3 } = await init_client2().then(() => exports_client);
139514
+ const { getClient: getClient3 } = await Promise.resolve().then(() => (init_client2(), exports_client));
139417
139515
  const client = await getClient3();
139418
139516
  let agent;
139419
139517
  if (initialAgentState && initialAgentState.id === agentId) {
@@ -139460,7 +139558,7 @@ function App2({
139460
139558
  const lastRunCompletion = agent.last_run_completion;
139461
139559
  setAgentLastRunAt(lastRunCompletion ?? null);
139462
139560
  const agentModelHandle = getPreferredAgentModelHandle2(agent);
139463
- const { getModelInfoForLlmConfig: getModelInfoForLlmConfig3 } = await init_model2().then(() => exports_model2);
139561
+ const { getModelInfoForLlmConfig: getModelInfoForLlmConfig3 } = await Promise.resolve().then(() => (init_model2(), exports_model2));
139464
139562
  const modelInfo = getModelInfoForLlmConfig3(agentModelHandle || "", agent.llm_config);
139465
139563
  if (modelInfo) {
139466
139564
  setCurrentModelId(modelInfo.id);
@@ -139618,7 +139716,7 @@ function App2({
139618
139716
  updateArgs.enable_reasoner = enableReasoner;
139619
139717
  }
139620
139718
  try {
139621
- const { updateConversationLLMConfig: updateConversationLLMConfig2 } = await init_modify().then(() => exports_modify);
139719
+ const { updateConversationLLMConfig: updateConversationLLMConfig2 } = await Promise.resolve().then(() => (init_modify(), exports_modify));
139622
139720
  await updateConversationLLMConfig2(targetConversationId, modelHandle, Object.keys(updateArgs).length > 0 ? updateArgs : undefined, { preserveContextWindow: true });
139623
139721
  } catch (error) {
139624
139722
  debugWarn("conversation-model", `Failed to carry over active model to new conversation: ${error instanceof Error ? error.message : String(error)}`);
@@ -139664,7 +139762,7 @@ function App2({
139664
139762
  const isIntervalTurn = sharedReminderStateRef.current.turnCount > 0 && sharedReminderStateRef.current.turnCount % MEMFS_CONFLICT_CHECK_INTERVAL === 0;
139665
139763
  if (isIntervalTurn && !memfsGitCheckInFlightRef.current) {
139666
139764
  memfsGitCheckInFlightRef.current = true;
139667
- init_memoryGit().then(() => exports_memoryGit).then(({ getMemoryGitStatus: getMemoryGitStatus2 }) => getMemoryGitStatus2(agentId)).then((status) => {
139765
+ Promise.resolve().then(() => (init_memoryGit(), exports_memoryGit)).then(({ getMemoryGitStatus: getMemoryGitStatus2 }) => getMemoryGitStatus2(agentId)).then((status) => {
139668
139766
  pendingGitReminderRef.current = status.dirty || status.aheadOfRemote ? status : null;
139669
139767
  }).catch(() => {}).finally(() => {
139670
139768
  memfsGitCheckInFlightRef.current = false;
@@ -139687,7 +139785,7 @@ function App2({
139687
139785
  memoryFilesystemInitializedRef.current = true;
139688
139786
  (async () => {
139689
139787
  try {
139690
- const { isGitRepo: isGitRepo2, cloneMemoryRepo: cloneMemoryRepo2, pullMemory: pullMemory2 } = await init_memoryGit().then(() => exports_memoryGit);
139788
+ const { isGitRepo: isGitRepo2, cloneMemoryRepo: cloneMemoryRepo2, pullMemory: pullMemory2 } = await Promise.resolve().then(() => (init_memoryGit(), exports_memoryGit));
139691
139789
  if (!isGitRepo2(agentId)) {
139692
139790
  await cloneMemoryRepo2(agentId);
139693
139791
  } else {
@@ -141721,7 +141819,7 @@ ${feedback}
141721
141819
  setConversationId3(targetConversationId);
141722
141820
  resetBootstrapReminderState();
141723
141821
  {
141724
- const { getModelDisplayName: getModelDisplayName3 } = await init_model2().then(() => exports_model2);
141822
+ const { getModelDisplayName: getModelDisplayName3 } = await Promise.resolve().then(() => (init_model2(), exports_model2));
141725
141823
  const modelHandle = agent.model || (agent.llm_config?.model_endpoint_type && agent.llm_config?.model ? `${agent.llm_config.model_endpoint_type}/${agent.llm_config.model}` : null);
141726
141824
  const modelLabel = modelHandle && getModelDisplayName3(modelHandle) || modelHandle || "unknown";
141727
141825
  pendingConversationSwitchRef.current = {
@@ -141847,7 +141945,7 @@ ${feedback}
141847
141945
  agentSwitchContext: {
141848
141946
  name: agent.name || agent.id,
141849
141947
  description: agent.description ?? undefined,
141850
- model: agentModelHandle ? (await init_model2().then(() => exports_model2)).getModelDisplayName(agentModelHandle) || agentModelHandle : "unknown",
141948
+ model: agentModelHandle ? (await Promise.resolve().then(() => (init_model2(), exports_model2))).getModelDisplayName(agentModelHandle) || agentModelHandle : "unknown",
141851
141949
  blockCount: agent.blocks?.length ?? 0
141852
141950
  }
141853
141951
  };
@@ -141903,8 +142001,8 @@ ${feedback}
141903
142001
  const expanded = expandAliases2(command);
141904
142002
  const finalCommand = expanded.functionDef ? `${expanded.functionDef}
141905
142003
  ${expanded.command}` : expanded.command;
141906
- const { spawnCommand: spawnCommand2 } = await init_Bash2().then(() => exports_Bash);
141907
- const { getShellEnv: getShellEnv2 } = await init_shellEnv().then(() => exports_shellEnv);
142004
+ const { spawnCommand: spawnCommand2 } = await Promise.resolve().then(() => (init_Bash2(), exports_Bash));
142005
+ const { getShellEnv: getShellEnv2 } = await Promise.resolve().then(() => (init_shellEnv(), exports_shellEnv));
141908
142006
  const result = await spawnCommand2(finalCommand, {
141909
142007
  cwd: process.cwd(),
141910
142008
  env: getShellEnv2(),
@@ -142287,7 +142385,7 @@ ${SYSTEM_REMINDER_CLOSE}` : "";
142287
142385
  cmd.finish("Memory Palace requires memfs. Run /memfs enable first.", false);
142288
142386
  return { submitted: true };
142289
142387
  }
142290
- const { generateAndOpenMemoryViewer: generateAndOpenMemoryViewer2 } = await init_generate_memory_viewer().then(() => exports_generate_memory_viewer);
142388
+ const { generateAndOpenMemoryViewer: generateAndOpenMemoryViewer2 } = await Promise.resolve().then(() => (init_generate_memory_viewer(), exports_generate_memory_viewer));
142291
142389
  generateAndOpenMemoryViewer2(agentId, {
142292
142390
  agentName: agentName ?? undefined,
142293
142391
  conversationId: conversationId !== "default" ? conversationId : undefined
@@ -142367,7 +142465,7 @@ ${SYSTEM_REMINDER_CLOSE}` : "";
142367
142465
  const {
142368
142466
  handleConnect: handleConnect2,
142369
142467
  setActiveCommandId: setActiveConnectCommandId
142370
- } = await init_connect().then(() => exports_connect);
142468
+ } = await Promise.resolve().then(() => (init_connect(), exports_connect));
142371
142469
  setActiveConnectCommandId(cmd.id);
142372
142470
  try {
142373
142471
  await handleConnect2({
@@ -142393,7 +142491,7 @@ ${SYSTEM_REMINDER_CLOSE}` : "";
142393
142491
  const {
142394
142492
  handleDisconnect: handleDisconnect2,
142395
142493
  setActiveCommandId: setActiveConnectCommandId
142396
- } = await init_connect().then(() => exports_connect);
142494
+ } = await Promise.resolve().then(() => (init_connect(), exports_connect));
142397
142495
  setActiveConnectCommandId(cmd.id);
142398
142496
  try {
142399
142497
  await handleDisconnect2({
@@ -142419,7 +142517,7 @@ ${SYSTEM_REMINDER_CLOSE}` : "";
142419
142517
  }
142420
142518
  }
142421
142519
  const cmd = commandRunner.start(msg, "Starting listener...");
142422
- const { handleListen: handleListen2, setActiveCommandId: setActiveListenCommandId } = await init_listen().then(() => exports_listen);
142520
+ const { handleListen: handleListen2, setActiveCommandId: setActiveListenCommandId } = await Promise.resolve().then(() => (init_listen(), exports_listen));
142423
142521
  setActiveListenCommandId(cmd.id);
142424
142522
  try {
142425
142523
  await handleListen2({
@@ -142678,10 +142776,10 @@ ${SYSTEM_REMINDER_CLOSE}` : "";
142678
142776
  const cmd = commandRunner.start(msg.trim(), "Logging out...");
142679
142777
  setCommandRunning(true);
142680
142778
  try {
142681
- const { settingsManager: settingsManager3 } = await init_settings_manager().then(() => exports_settings_manager);
142779
+ const { settingsManager: settingsManager3 } = await Promise.resolve().then(() => (init_settings_manager(), exports_settings_manager));
142682
142780
  const currentSettings = await settingsManager3.getSettingsWithSecureTokens();
142683
142781
  if (currentSettings.refreshToken) {
142684
- const { revokeToken: revokeToken3 } = await init_oauth().then(() => exports_oauth);
142782
+ const { revokeToken: revokeToken3 } = await Promise.resolve().then(() => (init_oauth(), exports_oauth));
142685
142783
  await revokeToken3(currentSettings.refreshToken);
142686
142784
  }
142687
142785
  await settingsManager3.logout();
@@ -142756,7 +142854,7 @@ Type your task to begin the loop.`, true);
142756
142854
  setCommandRunning(true);
142757
142855
  try {
142758
142856
  setTokenStreamingEnabled(newValue);
142759
- const { settingsManager: settingsManager3 } = await init_settings_manager().then(() => exports_settings_manager);
142857
+ const { settingsManager: settingsManager3 } = await Promise.resolve().then(() => (init_settings_manager(), exports_settings_manager));
142760
142858
  settingsManager3.updateSettings({ tokenStreaming: newValue });
142761
142859
  cmd.finish(`Token streaming ${newValue ? "enabled" : "disabled"}`, true);
142762
142860
  } catch (error) {
@@ -143525,7 +143623,7 @@ Path: ${result2.memoryDir}`, true, msg);
143525
143623
  updateMemorySyncCommand(cmdId, "Pulling latest memory from server...", true, msg, true);
143526
143624
  setCommandRunning(true);
143527
143625
  try {
143528
- const { pullMemory: pullMemory2 } = await init_memoryGit().then(() => exports_memoryGit);
143626
+ const { pullMemory: pullMemory2 } = await Promise.resolve().then(() => (init_memoryGit(), exports_memoryGit));
143529
143627
  const result2 = await pullMemory2(agentId);
143530
143628
  updateMemorySyncCommand(cmdId, result2.summary, true, msg);
143531
143629
  } catch (error) {
@@ -143566,10 +143664,10 @@ Run \`/memfs sync\` to repopulate from API.`, true, msg);
143566
143664
  const { reattachMemoryTool: reattachMemoryTool2 } = await init_toolset().then(() => exports_toolset);
143567
143665
  const modelId = currentModelId || "anthropic/claude-sonnet-4";
143568
143666
  await reattachMemoryTool2(agentId, modelId);
143569
- const { updateAgentSystemPromptMemfs: updateAgentSystemPromptMemfs2 } = await init_modify().then(() => exports_modify);
143667
+ const { updateAgentSystemPromptMemfs: updateAgentSystemPromptMemfs2 } = await Promise.resolve().then(() => (init_modify(), exports_modify));
143570
143668
  await updateAgentSystemPromptMemfs2(agentId, false);
143571
143669
  settingsManager.setMemfsEnabled(agentId, false);
143572
- const { removeGitMemoryTag: removeGitMemoryTag2 } = await init_memoryGit().then(() => exports_memoryGit);
143670
+ const { removeGitMemoryTag: removeGitMemoryTag2 } = await Promise.resolve().then(() => (init_memoryGit(), exports_memoryGit));
143573
143671
  await removeGitMemoryTag2(agentId);
143574
143672
  let backupInfo = "";
143575
143673
  const memoryDir = getMemoryFilesystemRoot(agentId);
@@ -143698,7 +143796,7 @@ ${SYSTEM_REMINDER_CLOSE}`;
143698
143796
  cwd: process.cwd(),
143699
143797
  parentMemory
143700
143798
  });
143701
- const { spawnBackgroundSubagentTask: spawnBackgroundSubagentTask2 } = await init_Task2().then(() => exports_Task);
143799
+ const { spawnBackgroundSubagentTask: spawnBackgroundSubagentTask2 } = await Promise.resolve().then(() => (init_Task2(), exports_Task));
143702
143800
  const { subagentId } = spawnBackgroundSubagentTask2({
143703
143801
  subagentType: "reflection",
143704
143802
  prompt: reflectionPrompt,
@@ -143929,7 +144027,7 @@ ${SYSTEM_REMINDER_CLOSE}`),
143929
144027
  }
143930
144028
  return { submitted: true };
143931
144029
  }
143932
- const { commands: commands2, executeCommand: executeCommand2 } = await init_registry2().then(() => exports_registry2);
144030
+ const { commands: commands2, executeCommand: executeCommand2 } = await Promise.resolve().then(() => (init_registry2(), exports_registry2));
143933
144031
  const registryCommandName = trimmed.split(/\s+/)[0] ?? "";
143934
144032
  const isRegistryCommand = Boolean(commands2[registryCommandName]);
143935
144033
  const registryCmd = isRegistryCommand ? commandRunner.start(msg, `Running ${registryCommandName}...`) : null;
@@ -144038,7 +144136,7 @@ ${SYSTEM_REMINDER_CLOSE}
144038
144136
  cwd: process.cwd(),
144039
144137
  parentMemory
144040
144138
  });
144041
- const { spawnBackgroundSubagentTask: spawnBackgroundSubagentTask2 } = await init_Task2().then(() => exports_Task);
144139
+ const { spawnBackgroundSubagentTask: spawnBackgroundSubagentTask2 } = await Promise.resolve().then(() => (init_Task2(), exports_Task));
144042
144140
  const { subagentId } = spawnBackgroundSubagentTask2({
144043
144141
  subagentType: "reflection",
144044
144142
  prompt: reflectionPrompt,
@@ -145036,7 +145134,7 @@ ${SYSTEM_REMINDER_CLOSE}
145036
145134
  };
145037
145135
  let selectedModel = null;
145038
145136
  try {
145039
- const { getReasoningTierOptionsForHandle: getReasoningTierOptionsForHandle3, models: models3 } = await init_model2().then(() => exports_model2);
145137
+ const { getReasoningTierOptionsForHandle: getReasoningTierOptionsForHandle3, models: models3 } = await Promise.resolve().then(() => (init_model2(), exports_model2));
145040
145138
  const pickPreferredModelForHandle = (handle) => {
145041
145139
  const candidates = models3.filter((m) => m.handle === handle);
145042
145140
  return candidates.find((m) => m.isDefault) ?? candidates.find((m) => m.isFeatured) ?? candidates.find((m) => m.updateArgs?.reasoning_effort === "medium") ?? candidates.find((m) => m.updateArgs?.reasoning_effort === "high") ?? candidates[0] ?? null;
@@ -145053,7 +145151,7 @@ ${SYSTEM_REMINDER_CLOSE}
145053
145151
  }
145054
145152
  }
145055
145153
  if (!selectedModel && modelId.includes("/")) {
145056
- const { getModelContextWindow: getModelContextWindow2 } = await init_available_models().then(() => exports_available_models);
145154
+ const { getModelContextWindow: getModelContextWindow2 } = await Promise.resolve().then(() => (init_available_models(), exports_available_models));
145057
145155
  const apiContextWindow = await getModelContextWindow2(modelId);
145058
145156
  selectedModel = {
145059
145157
  id: modelId,
@@ -145114,11 +145212,11 @@ ${SYSTEM_REMINDER_CLOSE}
145114
145212
  let conversationContextWindowLimit;
145115
145213
  let updatedAgent = null;
145116
145214
  if (isDefaultConversation) {
145117
- const { updateAgentLLMConfig: updateAgentLLMConfig3 } = await init_modify().then(() => exports_modify);
145215
+ const { updateAgentLLMConfig: updateAgentLLMConfig3 } = await Promise.resolve().then(() => (init_modify(), exports_modify));
145118
145216
  updatedAgent = await updateAgentLLMConfig3(agentIdRef.current, modelHandle, model.updateArgs);
145119
145217
  conversationModelSettings = updatedAgent?.model_settings;
145120
145218
  } else {
145121
- const { updateConversationLLMConfig: updateConversationLLMConfig2 } = await init_modify().then(() => exports_modify);
145219
+ const { updateConversationLLMConfig: updateConversationLLMConfig2 } = await Promise.resolve().then(() => (init_modify(), exports_modify));
145122
145220
  const updatedConversation = await updateConversationLLMConfig2(conversationIdRef.current, modelHandle, model.updateArgs, { preserveContextWindow: false });
145123
145221
  conversationModelSettings = updatedConversation.model_settings;
145124
145222
  conversationContextWindowLimit = updatedConversation.context_window_limit;
@@ -145248,7 +145346,7 @@ ${guidance}`);
145248
145346
  output: `Switching system prompt to ${prompt.label}...`,
145249
145347
  phase: "running"
145250
145348
  });
145251
- const { updateAgentSystemPrompt: updateAgentSystemPrompt3 } = await init_modify().then(() => exports_modify);
145349
+ const { updateAgentSystemPrompt: updateAgentSystemPrompt3 } = await Promise.resolve().then(() => (init_modify(), exports_modify));
145252
145350
  const result = await updateAgentSystemPrompt3(agentId, promptId);
145253
145351
  if (result.success) {
145254
145352
  setCurrentSystemPromptId(promptId);
@@ -145756,12 +145854,12 @@ ${guidance}`);
145756
145854
  let conversationContextWindowLimit;
145757
145855
  let updatedAgent = null;
145758
145856
  if (isDefaultConversation) {
145759
- const { updateAgentLLMConfig: updateAgentLLMConfig3 } = await init_modify().then(() => exports_modify);
145857
+ const { updateAgentLLMConfig: updateAgentLLMConfig3 } = await Promise.resolve().then(() => (init_modify(), exports_modify));
145760
145858
  updatedAgent = await updateAgentLLMConfig3(agentIdRef.current, desired.modelHandle, {
145761
145859
  reasoning_effort: desired.effort
145762
145860
  });
145763
145861
  } else {
145764
- const { updateConversationLLMConfig: updateConversationLLMConfig2 } = await init_modify().then(() => exports_modify);
145862
+ const { updateConversationLLMConfig: updateConversationLLMConfig2 } = await Promise.resolve().then(() => (init_modify(), exports_modify));
145765
145863
  const updatedConversation = await updateConversationLLMConfig2(conversationIdRef.current, desired.modelHandle, {
145766
145864
  reasoning_effort: desired.effort
145767
145865
  }, { preserveContextWindow: true });
@@ -145809,7 +145907,7 @@ ${guidance}`);
145809
145907
  reasoningCycleLastConfirmedAgentStateRef.current = null;
145810
145908
  }
145811
145909
  reasoningCyclePatchedAgentStateRef.current = false;
145812
- const { getModelInfo: getModelInfo3 } = await init_model2().then(() => exports_model2);
145910
+ const { getModelInfo: getModelInfo3 } = await Promise.resolve().then(() => (init_model2(), exports_model2));
145813
145911
  const modelHandle = prev.model_endpoint_type && prev.model ? `${prev.model_endpoint_type === "chatgpt_oauth" ? OPENAI_CODEX_PROVIDER_NAME : prev.model_endpoint_type}/${prev.model}` : prev.model;
145814
145912
  const modelInfo = modelHandle ? getModelInfo3(modelHandle) : null;
145815
145913
  setCurrentModelId(modelInfo?.id ?? null);
@@ -145838,7 +145936,7 @@ ${guidance}`);
145838
145936
  return;
145839
145937
  const modelSettingsForEffort = hasConversationModelOverrideRef.current ? undefined : agentStateRef.current?.model_settings;
145840
145938
  const currentEffort = deriveReasoningEffort(modelSettingsForEffort, current) ?? "none";
145841
- const { models: models3 } = await init_model2().then(() => exports_model2);
145939
+ const { models: models3 } = await Promise.resolve().then(() => (init_model2(), exports_model2));
145842
145940
  const tiers = models3.filter((m) => m.handle === modelHandle).map((m) => {
145843
145941
  const effort = m.updateArgs?.reasoning_effort;
145844
145942
  return {
@@ -146778,7 +146876,7 @@ If using apply_patch, use this exact relative patch path: ${applyPatchRelativePa
146778
146876
  const {
146779
146877
  handleConnect: handleConnect2,
146780
146878
  setActiveCommandId: setActiveConnectCommandId
146781
- } = await init_connect().then(() => exports_connect);
146879
+ } = await Promise.resolve().then(() => (init_connect(), exports_connect));
146782
146880
  setActiveConnectCommandId(cmd.id);
146783
146881
  try {
146784
146882
  await handleConnect2({
@@ -147252,23 +147350,37 @@ Open /mcp to attach or detach tools for this server.`, true);
147252
147350
  var import_react104, jsx_dev_runtime81, CLEAR_SCREEN_AND_HOME = "\x1B[2J\x1B[H", MIN_RESIZE_DELTA = 2, RESIZE_SETTLE_MS = 250, MIN_CLEAR_INTERVAL_MS = 750, STABLE_WIDTH_SETTLE_MS = 180, TOOL_CALL_COMMIT_DEFER_MS = 50, ANIMATION_RESUME_HYSTERESIS_ROWS = 2, EAGER_CANCEL = true, LLM_API_ERROR_MAX_RETRIES3 = 3, EMPTY_RESPONSE_MAX_RETRIES3 = 2, TEMP_QUOTA_OVERRIDE_MODEL = "letta/auto", PROVIDER_FALLBACK_MAP2, CONVERSATION_BUSY_MAX_RETRIES2 = 3, INTERRUPT_MESSAGE = "Interrupted – tell the agent what to do differently. Something went wrong? Use /feedback to report issues.", ERROR_FEEDBACK_HINT = "Something went wrong? Use /feedback to report issues.", PROVIDER_STATUS_PAGES, INTERACTIVE_SLASH_COMMANDS, NON_STATE_COMMANDS, APPROVAL_OPTIONS_HEIGHT = 8, APPROVAL_PREVIEW_BUFFER = 4, MIN_WRAP_WIDTH = 10, TEXT_WRAP_GUTTER = 6, DIFF_WRAP_GUTTER = 12, SHELL_PREVIEW_MAX_LINES = 3, AUTO_REFLECTION_DESCRIPTION2 = "Reflect on recent conversations";
147253
147351
  var init_App2 = __esm(async () => {
147254
147352
  init_error();
147353
+ init_approval_recovery();
147354
+ init_available_models();
147255
147355
  init_check_approval();
147356
+ init_client2();
147256
147357
  init_context();
147358
+ init_create();
147359
+ init_defaults();
147257
147360
  init_http_headers();
147258
147361
  init_memory();
147259
147362
  init_memoryFilesystem();
147363
+ init_model2();
147364
+ init_personality();
147260
147365
  init_promptAssets();
147261
147366
  init_reconcileExistingAgentState();
147262
147367
  init_sessionHistory();
147263
147368
  init_constants();
147369
+ init_hooks();
147264
147370
  init_mode();
147371
+ init_openai_codex_provider();
147265
147372
  init_queueRuntime();
147266
147373
  init_mode2();
147374
+ init_engine();
147267
147375
  init_planModeReminder();
147268
147376
  init_settings();
147377
+ init_settings_manager();
147378
+ init_telemetry();
147269
147379
  init_toolset_labels();
147270
147380
  init_debug();
147271
147381
  init_version();
147382
+ init_mcp();
147383
+ init_profile();
147272
147384
  init_colors();
147273
147385
  init_SessionStats();
147274
147386
  init_AnimationContext();
@@ -147279,39 +147391,30 @@ var init_App2 = __esm(async () => {
147279
147391
  init_errorContext();
147280
147392
  init_errorFormatter();
147281
147393
  init_initCommand();
147394
+ init_memoryReminder();
147395
+ init_memorySubagentCompletion();
147282
147396
  init_messageQueueBridge();
147283
147397
  init_pasteRegistry();
147284
147398
  init_planName();
147285
147399
  init_queuedMessageParts();
147286
147400
  init_reasoningTabToggle();
147287
147401
  init_sessionContext();
147402
+ init_startupSystemPromptWarning();
147403
+ init_statusLineConfig();
147288
147404
  init_statusLineHelp();
147289
147405
  init_statusLinePayload();
147290
147406
  init_statusLineRuntime();
147291
147407
  init_subagentState();
147292
147408
  init_thinkingMessages();
147409
+ init_useConfigurableStatusLine();
147293
147410
  init_useSyncedState();
147294
147411
  init_useTerminalWidth();
147295
147412
  await __promiseAll([
147296
147413
  init_build2(),
147297
147414
  init_approval_execution(),
147298
- init_approval_recovery(),
147299
- init_available_models(),
147300
- init_client2(),
147301
- init_create(),
147302
- init_defaults(),
147303
147415
  init_message(),
147304
- init_model2(),
147305
- init_personality(),
147306
- init_hooks(),
147307
- init_openai_codex_provider(),
147308
- init_engine(),
147309
- init_settings_manager(),
147310
- init_telemetry(),
147311
147416
  init_manager3(),
147312
147417
  init_toolset(),
147313
- init_mcp(),
147314
- init_profile(),
147315
147418
  init_AgentSelector(),
147316
147419
  init_ApprovalPreview(),
147317
147420
  init_ApprovalSwitch(),
@@ -147357,16 +147460,11 @@ var init_App2 = __esm(async () => {
147357
147460
  init_accumulator(),
147358
147461
  init_approvalClassification(),
147359
147462
  init_formatArgsDisplay(),
147360
- init_memoryReminder(),
147361
- init_memorySubagentCompletion(),
147362
147463
  init_reflectionTranscript(),
147363
- init_startupSystemPromptWarning(),
147364
- init_statusLineConfig(),
147365
147464
  init_stream(),
147366
147465
  init_subagentAggregation(),
147367
147466
  init_toolNameMapping(),
147368
147467
  init_toolNameMapping(),
147369
- init_useConfigurableStatusLine(),
147370
147468
  init_useSuspend()
147371
147469
  ]);
147372
147470
  import_react104 = __toESM(require_react(), 1);
@@ -147885,9 +147983,9 @@ async function checkReleaseNotes() {
147885
147983
  return notes;
147886
147984
  }
147887
147985
  var releaseNotes;
147888
- var init_release_notes = __esm(async () => {
147986
+ var init_release_notes = __esm(() => {
147987
+ init_settings_manager();
147889
147988
  init_version();
147890
- await init_settings_manager();
147891
147989
  releaseNotes = {
147892
147990
  "0.13.4": `\uD83D\uDD04 **Letta Code 0.13.4: Back to the OG experience**
147893
147991
  → Running **letta** now resumes your "default" conversation (instead of spawning a new one)
@@ -148021,15 +148119,13 @@ async function ensureDefaultAgents2(client, options) {
148021
148119
  }
148022
148120
  }
148023
148121
  var MEMO_TAG2 = "default:memo", INCOGNITO_TAG2 = "default:incognito", MEMO_PERSONA2, MEMO_HUMAN2, MEMO_DESCRIPTION2 = "The default Letta Code agent with persistent memory", INCOGNITO_DESCRIPTION2 = "A stateless coding agent without memory (incognito mode)", DEFAULT_AGENT_CONFIGS2;
148024
- var init_defaults2 = __esm(async () => {
148122
+ var init_defaults2 = __esm(() => {
148123
+ init_settings_manager();
148124
+ init_client2();
148125
+ init_create();
148025
148126
  init_memory();
148127
+ init_model2();
148026
148128
  init_promptAssets();
148027
- await __promiseAll([
148028
- init_settings_manager(),
148029
- init_client2(),
148030
- init_create(),
148031
- init_model2()
148032
- ]);
148033
148129
  MEMO_PERSONA2 = parseMdxFrontmatter(MEMORY_PROMPTS["persona_memo.mdx"] ?? "").body;
148034
148130
  MEMO_HUMAN2 = parseMdxFrontmatter(MEMORY_PROMPTS["human_memo.mdx"] ?? "").body;
148035
148131
  DEFAULT_AGENT_CONFIGS2 = {
@@ -148266,18 +148362,16 @@ async function createAgent2(nameOrOptions = DEFAULT_AGENT_NAME, model, embedding
148266
148362
  };
148267
148363
  return { agent: fullAgent, provenance };
148268
148364
  }
148269
- var init_create3 = __esm(async () => {
148365
+ var init_create3 = __esm(() => {
148270
148366
  init_constants();
148367
+ init_settings_manager();
148368
+ init_available_models();
148369
+ init_client2();
148271
148370
  init_http_headers();
148272
148371
  init_memory();
148372
+ init_model2();
148373
+ init_modify();
148273
148374
  init_promptAssets();
148274
- await __promiseAll([
148275
- init_settings_manager(),
148276
- init_available_models(),
148277
- init_client2(),
148278
- init_model2(),
148279
- init_modify()
148280
- ]);
148281
148375
  });
148282
148376
 
148283
148377
  // src/agent/import.ts
@@ -148430,12 +148524,10 @@ async function importAgentFromRegistry2(options) {
148430
148524
  }
148431
148525
  }
148432
148526
  var AGENT_REGISTRY_OWNER2 = "letta-ai", AGENT_REGISTRY_REPO2 = "agent-file", AGENT_REGISTRY_BRANCH2 = "main";
148433
- var init_import2 = __esm(async () => {
148434
- await __promiseAll([
148435
- init_client2(),
148436
- init_model2(),
148437
- init_modify()
148438
- ]);
148527
+ var init_import2 = __esm(() => {
148528
+ init_client2();
148529
+ init_model2();
148530
+ init_modify();
148439
148531
  });
148440
148532
 
148441
148533
  // src/agent/memoryFilesystem.ts
@@ -148588,23 +148680,23 @@ function renderMemoryFilesystemTree2(systemLabels, detachedLabels, options = {})
148588
148680
  `);
148589
148681
  }
148590
148682
  async function applyMemfsFlags2(agentId, memfsFlag, noMemfsFlag, options) {
148591
- const { settingsManager: settingsManager3 } = await init_settings_manager().then(() => exports_settings_manager);
148683
+ const { settingsManager: settingsManager3 } = await Promise.resolve().then(() => (init_settings_manager(), exports_settings_manager));
148592
148684
  if (memfsFlag && !await isLettaCloud2()) {
148593
148685
  throw new Error("--memfs is only available on Letta Cloud (api.letta.com).");
148594
148686
  }
148595
148687
  const hasExplicitToggle = Boolean(memfsFlag || noMemfsFlag);
148596
148688
  const localMemfsEnabled = settingsManager3.isMemfsEnabled(agentId);
148597
- const { GIT_MEMORY_ENABLED_TAG: GIT_MEMORY_ENABLED_TAG2 } = await init_memoryGit().then(() => exports_memoryGit);
148689
+ const { GIT_MEMORY_ENABLED_TAG: GIT_MEMORY_ENABLED_TAG2 } = await Promise.resolve().then(() => (init_memoryGit(), exports_memoryGit));
148598
148690
  const shouldAutoEnableFromTag = !hasExplicitToggle && !localMemfsEnabled && Boolean(options?.agentTags?.includes(GIT_MEMORY_ENABLED_TAG2));
148599
148691
  const targetEnabled = memfsFlag ? true : noMemfsFlag ? false : shouldAutoEnableFromTag ? true : localMemfsEnabled;
148600
148692
  if (hasExplicitToggle || shouldAutoEnableFromTag) {
148601
148693
  if (!options?.skipPromptUpdate) {
148602
- const { updateAgentSystemPromptMemfs: updateAgentSystemPromptMemfs2 } = await init_modify().then(() => exports_modify);
148694
+ const { updateAgentSystemPromptMemfs: updateAgentSystemPromptMemfs2 } = await Promise.resolve().then(() => (init_modify(), exports_modify));
148603
148695
  const promptUpdate = await updateAgentSystemPromptMemfs2(agentId, targetEnabled);
148604
148696
  if (!promptUpdate.success) {
148605
148697
  throw new Error(promptUpdate.message);
148606
148698
  }
148607
- const { getClient: getClient3 } = await init_client2().then(() => exports_client);
148699
+ const { getClient: getClient3 } = await Promise.resolve().then(() => (init_client2(), exports_client));
148608
148700
  const client = await getClient3();
148609
148701
  await client.agents.recompile(agentId, { update_timestamp: false });
148610
148702
  }
@@ -148614,7 +148706,7 @@ async function applyMemfsFlags2(agentId, memfsFlag, noMemfsFlag, options) {
148614
148706
  if (isEnabled && (memfsFlag || shouldAutoEnableFromTag)) {
148615
148707
  const { detachMemoryTools: detachMemoryTools2 } = await init_toolset().then(() => exports_toolset);
148616
148708
  await detachMemoryTools2(agentId);
148617
- const { getClient: getClient3 } = await init_client2().then(() => exports_client);
148709
+ const { getClient: getClient3 } = await Promise.resolve().then(() => (init_client2(), exports_client));
148618
148710
  const client = await getClient3();
148619
148711
  for (const label of ["skills", "loaded_skills"]) {
148620
148712
  try {
@@ -148631,12 +148723,12 @@ async function applyMemfsFlags2(agentId, memfsFlag, noMemfsFlag, options) {
148631
148723
  }
148632
148724
  }
148633
148725
  if (noMemfsFlag) {
148634
- const { removeGitMemoryTag: removeGitMemoryTag2 } = await init_memoryGit().then(() => exports_memoryGit);
148726
+ const { removeGitMemoryTag: removeGitMemoryTag2 } = await Promise.resolve().then(() => (init_memoryGit(), exports_memoryGit));
148635
148727
  await removeGitMemoryTag2(agentId);
148636
148728
  }
148637
148729
  let pullSummary;
148638
148730
  if (isEnabled) {
148639
- const { addGitMemoryTag: addGitMemoryTag2, isGitRepo: isGitRepo2, cloneMemoryRepo: cloneMemoryRepo2, pullMemory: pullMemory2 } = await init_memoryGit().then(() => exports_memoryGit);
148731
+ const { addGitMemoryTag: addGitMemoryTag2, isGitRepo: isGitRepo2, cloneMemoryRepo: cloneMemoryRepo2, pullMemory: pullMemory2 } = await Promise.resolve().then(() => (init_memoryGit(), exports_memoryGit));
148640
148732
  await addGitMemoryTag2(agentId, options?.agentTags ? { tags: options.agentTags } : undefined);
148641
148733
  if (!isGitRepo2(agentId)) {
148642
148734
  await cloneMemoryRepo2(agentId);
@@ -148644,7 +148736,7 @@ async function applyMemfsFlags2(agentId, memfsFlag, noMemfsFlag, options) {
148644
148736
  const result = await pullMemory2(agentId);
148645
148737
  pullSummary = result.summary;
148646
148738
  }
148647
- const { initSecretsFromServer: initSecretsFromServer2 } = await init_secretsStore().then(() => exports_secretsStore);
148739
+ const { initSecretsFromServer: initSecretsFromServer2 } = await Promise.resolve().then(() => (init_secretsStore(), exports_secretsStore));
148648
148740
  try {
148649
148741
  await initSecretsFromServer2(agentId);
148650
148742
  } catch {}
@@ -148657,7 +148749,7 @@ async function applyMemfsFlags2(agentId, memfsFlag, noMemfsFlag, options) {
148657
148749
  };
148658
148750
  }
148659
148751
  async function isLettaCloud2() {
148660
- const { getServerUrl: getServerUrl2 } = await init_client2().then(() => exports_client);
148752
+ const { getServerUrl: getServerUrl2 } = await Promise.resolve().then(() => (init_client2(), exports_client));
148661
148753
  const serverUrl = getServerUrl2();
148662
148754
  return serverUrl.includes("api.letta.com") || process.env.LETTA_MEMFS_LOCAL === "1" || process.env.LETTA_API_KEY === "local-desktop";
148663
148755
  }
@@ -148741,9 +148833,9 @@ function clearSecretsCache2() {
148741
148833
  setCache2(null);
148742
148834
  }
148743
148835
  var SECRETS_CACHE_KEY2;
148744
- var init_secretsStore2 = __esm(async () => {
148836
+ var init_secretsStore2 = __esm(() => {
148837
+ init_client2();
148745
148838
  init_context();
148746
- await init_client2();
148747
148839
  SECRETS_CACHE_KEY2 = Symbol.for("@letta/secretsCache");
148748
148840
  });
148749
148841
 
@@ -149149,13 +149241,11 @@ async function getResumeData(client, agent, conversationId, options = {}) {
149149
149241
  // src/agent/client.ts
149150
149242
  init_letta_client();
149151
149243
  init_package();
149244
+ init_oauth();
149245
+ init_settings_manager();
149246
+ init_errorReporting();
149152
149247
  init_debug();
149153
149248
  init_timing();
149154
- await __promiseAll([
149155
- init_oauth(),
149156
- init_settings_manager(),
149157
- init_errorReporting()
149158
- ]);
149159
149249
  import { hostname as hostname2 } from "node:os";
149160
149250
  var SDK_DIAGNOSTIC_MAX_LEN2 = 400;
149161
149251
  var SDK_DIAGNOSTIC_MAX_LINES2 = 4;
@@ -149313,15 +149403,13 @@ var MEMORY_BLOCK_LABELS2 = [
149313
149403
  var ISOLATED_BLOCK_LABELS2 = [];
149314
149404
 
149315
149405
  // src/index.ts
149316
- await init_model();
149406
+ init_model();
149317
149407
 
149318
149408
  // src/agent/modify.ts
149409
+ init_openai_codex_provider();
149319
149410
  init_debug();
149320
- await __promiseAll([
149321
- init_openai_codex_provider(),
149322
- init_available_models(),
149323
- init_client2()
149324
- ]);
149411
+ init_available_models();
149412
+ init_client2();
149325
149413
  function buildModelSettings(modelHandle, updateArgs) {
149326
149414
  const isOpenAI = modelHandle.startsWith("openai/") || modelHandle.startsWith(`${OPENAI_CODEX_PROVIDER_NAME}/`);
149327
149415
  const isAnthropic = modelHandle.startsWith("anthropic/") || modelHandle.startsWith("claude-pro-max/") || modelHandle.startsWith("minimax/");
@@ -149478,7 +149566,7 @@ async function updateAgentSystemPromptRaw(agentId, systemPromptContent) {
149478
149566
  async function updateAgentSystemPrompt(agentId, systemPromptId) {
149479
149567
  try {
149480
149568
  const { isKnownPreset: isKnownPreset2, resolveAndBuildSystemPrompt: resolveAndBuildSystemPrompt2 } = await Promise.resolve().then(() => (init_promptAssets(), exports_promptAssets));
149481
- const { settingsManager: settingsManager2 } = await init_settings_manager().then(() => exports_settings_manager);
149569
+ const { settingsManager: settingsManager2 } = await Promise.resolve().then(() => (init_settings_manager(), exports_settings_manager));
149482
149570
  const client = await getClient();
149483
149571
  const memoryMode = settingsManager2.isReady && settingsManager2.isMemfsEnabled(agentId) ? "memfs" : "standard";
149484
149572
  const systemPromptContent = await resolveAndBuildSystemPrompt2(systemPromptId, memoryMode);
@@ -149562,7 +149650,7 @@ function resolveSkillSourcesSelection2(input) {
149562
149650
  }
149563
149651
 
149564
149652
  // src/index.ts
149565
- await init_oauth2();
149653
+ init_oauth2();
149566
149654
 
149567
149655
  // src/cli/args.ts
149568
149656
  import { parseArgs } from "node:util";
@@ -149847,12 +149935,12 @@ function parseCliArgs(args, strict) {
149847
149935
  }
149848
149936
 
149849
149937
  // src/cli/components/ConversationSelector.tsx
149938
+ init_client2();
149850
149939
  init_constants();
149851
149940
  init_useTerminalWidth();
149852
149941
  init_colors();
149853
149942
  await __promiseAll([
149854
149943
  init_build2(),
149855
- init_client2(),
149856
149944
  init_MarkdownDisplay(),
149857
149945
  init_Text2()
149858
149946
  ]);
@@ -151348,11 +151436,11 @@ function ensureFileIndex(fullRebuild = false) {
151348
151436
  }
151349
151437
 
151350
151438
  // src/cli/profile-selection.tsx
151439
+ init_client2();
151440
+ init_settings_manager();
151351
151441
  init_colors();
151352
151442
  await __promiseAll([
151353
151443
  init_build2(),
151354
- init_client2(),
151355
- init_settings_manager(),
151356
151444
  init_Text2(),
151357
151445
  init_WelcomeScreen()
151358
151446
  ]);
@@ -151819,12 +151907,10 @@ function validateRegistryHandleOrThrow(handle) {
151819
151907
  }
151820
151908
 
151821
151909
  // src/cli/subcommands/agents.ts
151822
- await __promiseAll([
151823
- init_client2(),
151824
- init_create(),
151825
- init_personality(),
151826
- init_settings_manager()
151827
- ]);
151910
+ init_client2();
151911
+ init_create();
151912
+ init_personality();
151913
+ init_settings_manager();
151828
151914
  import { parseArgs as parseArgs2 } from "node:util";
151829
151915
  function printUsage() {
151830
151916
  console.log(`
@@ -151914,6 +152000,7 @@ async function runAgentsSubcommand(argv) {
151914
152000
  return 1;
151915
152001
  }
151916
152002
  async function runCreateAction(values) {
152003
+ await settingsManager.initialize();
151917
152004
  const personalityInput = values.personality;
151918
152005
  const personality = personalityInput ? resolvePersonalityId(personalityInput) : undefined;
151919
152006
  if (personalityInput && !personality) {
@@ -151966,6 +152053,7 @@ async function runCreateAction(values) {
151966
152053
  }
151967
152054
  }
151968
152055
  async function runListAction(values) {
152056
+ await settingsManager.initialize();
151969
152057
  const params = {
151970
152058
  limit: parseLimit(values.limit, 20)
151971
152059
  };
@@ -151997,7 +152085,8 @@ async function runListAction(values) {
151997
152085
  }
151998
152086
 
151999
152087
  // src/cli/subcommands/blocks.ts
152000
- await init_client2();
152088
+ init_client2();
152089
+ init_settings_manager();
152001
152090
  import { parseArgs as parseArgs3 } from "node:util";
152002
152091
  function printUsage2() {
152003
152092
  console.log(`
@@ -152170,6 +152259,7 @@ async function runBlocksSubcommand(argv) {
152170
152259
  return 0;
152171
152260
  }
152172
152261
  try {
152262
+ await settingsManager.initialize();
152173
152263
  const client = await getClient();
152174
152264
  if (action === "list") {
152175
152265
  const agentId = parsed.values.agent || parsed.values["agent-id"] || "";
@@ -152462,11 +152552,10 @@ async function runChannelsSubcommand(argv) {
152462
152552
  }
152463
152553
 
152464
152554
  // src/cli/subcommands/connect.ts
152465
- await __promiseAll([
152466
- init_byok_providers(),
152467
- init_connect_normalize(),
152468
- init_connect_oauth_core()
152469
- ]);
152555
+ init_byok_providers();
152556
+ init_settings_manager();
152557
+ init_connect_normalize();
152558
+ init_connect_oauth_core();
152470
152559
  import { createInterface as createInterface2 } from "node:readline/promises";
152471
152560
  import { Writable } from "node:stream";
152472
152561
  import { parseArgs as parseArgs5 } from "node:util";
@@ -152489,6 +152578,7 @@ var DEFAULT_DEPS2 = {
152489
152578
  stdout: (message) => console.log(message),
152490
152579
  stderr: (message) => console.error(message),
152491
152580
  isTTY: () => Boolean(process.stdin.isTTY && process.stdout.isTTY),
152581
+ ensureSettingsReady: () => settingsManager.initialize(),
152492
152582
  promptSecret,
152493
152583
  checkProviderApiKey,
152494
152584
  createOrUpdateProvider,
@@ -152582,6 +152672,7 @@ async function runConnectSubcommand(argv, deps = {}) {
152582
152672
  }
152583
152673
  if (isConnectOAuthProvider(provider)) {
152584
152674
  try {
152675
+ await io.ensureSettingsReady();
152585
152676
  if (await io.isChatGPTOAuthConnected()) {
152586
152677
  io.stdout("Already connected to ChatGPT via OAuth. Disconnect first if you want to re-authenticate.");
152587
152678
  return 0;
@@ -152914,12 +153005,12 @@ async function runCronSubcommand(argv) {
152914
153005
  }
152915
153006
 
152916
153007
  // src/cli/subcommands/listen.tsx
153008
+ init_oauth();
153009
+ init_settings_manager();
153010
+ init_telemetry();
152917
153011
  await __promiseAll([
152918
153012
  init_build2(),
152919
- init_build3(),
152920
- init_oauth(),
152921
- init_settings_manager(),
152922
- init_telemetry()
153013
+ init_build3()
152923
153014
  ]);
152924
153015
  var import_react30 = __toESM(require_react(), 1);
152925
153016
  import { hostname as hostname3 } from "node:os";
@@ -153244,6 +153335,7 @@ async function runListenSubcommand(argv) {
153244
153335
  console.log("then message the bot from Telegram and run /channels telegram pair <code> in the target conversation.");
153245
153336
  return 0;
153246
153337
  }
153338
+ await settingsManager.initialize();
153247
153339
  telemetry.setSurface("websocket");
153248
153340
  telemetry.init();
153249
153341
  const exitWithTelemetry = async (code, exitReason) => {
@@ -153482,7 +153574,7 @@ async function runListenSubcommand(argv) {
153482
153574
  }
153483
153575
 
153484
153576
  // src/cli/subcommands/memfs.ts
153485
- await init_memoryGit();
153577
+ init_memoryGit();
153486
153578
  import { cpSync, existsSync as existsSync24, mkdirSync as mkdirSync18, rmSync as rmSync3, statSync as statSync8 } from "node:fs";
153487
153579
  import { readdir as readdir6 } from "node:fs/promises";
153488
153580
  import { homedir as homedir24 } from "node:os";
@@ -153721,7 +153813,8 @@ async function runMemfsSubcommand(argv) {
153721
153813
  }
153722
153814
 
153723
153815
  // src/cli/subcommands/messages.ts
153724
- await init_client2();
153816
+ init_client2();
153817
+ init_settings_manager();
153725
153818
  import { writeFile as writeFile6 } from "node:fs/promises";
153726
153819
  import { resolve as resolve24 } from "node:path";
153727
153820
  import { parseArgs as parseArgs9 } from "node:util";
@@ -153834,6 +153927,7 @@ async function runMessagesSubcommand(argv) {
153834
153927
  return 0;
153835
153928
  }
153836
153929
  try {
153930
+ await settingsManager.initialize();
153837
153931
  const client = await getClient();
153838
153932
  const renderText = (value) => {
153839
153933
  if (typeof value === "string")
@@ -154484,12 +154578,10 @@ class PermissionModeManager2 {
154484
154578
  var permissionMode2 = new PermissionModeManager2;
154485
154579
 
154486
154580
  // src/settings-manager.ts
154581
+ init_errorReporting();
154487
154582
  init_debug();
154488
154583
  init_fs();
154489
- await __promiseAll([
154490
- init_errorReporting(),
154491
- init_secrets()
154492
- ]);
154584
+ init_secrets();
154493
154585
  import { randomUUID as randomUUID4 } from "node:crypto";
154494
154586
  import { homedir as homedir26 } from "node:os";
154495
154587
  import { join as join30, resolve as resolve25 } from "node:path";
@@ -155500,7 +155592,7 @@ if (!globalThis.__lettaSettingsManager) {
155500
155592
  var settingsManager2 = globalThis.__lettaSettingsManager;
155501
155593
 
155502
155594
  // src/startup-auto-update.ts
155503
- await init_errorReporting();
155595
+ init_errorReporting();
155504
155596
  function startStartupAutoUpdateCheck(checkAndAutoUpdate, logError = console.error) {
155505
155597
  return checkAndAutoUpdate().then((result) => {
155506
155598
  if (result?.enotemptyFailed) {
@@ -155524,13 +155616,11 @@ Auto-update failed due to filesystem issue (ENOTEMPTY).`);
155524
155616
  }
155525
155617
 
155526
155618
  // src/telemetry/index.ts
155619
+ init_client2();
155527
155620
  init_http_headers();
155621
+ init_settings_manager();
155528
155622
  init_debug();
155529
155623
  init_version();
155530
- await __promiseAll([
155531
- init_client2(),
155532
- init_settings_manager()
155533
- ]);
155534
155624
 
155535
155625
  class TelemetryManager2 {
155536
155626
  events = [];
@@ -155829,7 +155919,7 @@ class TelemetryManager2 {
155829
155919
  var telemetry2 = new TelemetryManager2;
155830
155920
 
155831
155921
  // src/telemetry/errorReporting.ts
155832
- await init_telemetry();
155922
+ init_telemetry();
155833
155923
  function formatTelemetryErrorMessage3(error) {
155834
155924
  if (error instanceof Error) {
155835
155925
  return error.message;
@@ -155853,19 +155943,19 @@ function trackBoundaryError2(options) {
155853
155943
  }
155854
155944
 
155855
155945
  // src/tools/manager.ts
155946
+ init_model2();
155856
155947
  init_subagents();
155857
155948
  init_registry();
155858
155949
  init_fileIndex();
155859
155950
  init_constants();
155951
+ init_hooks();
155860
155952
  init_mode();
155953
+ init_openai_codex_provider();
155954
+ init_telemetry();
155861
155955
  init_debug();
155956
+ init_secret_substitution();
155862
155957
  await __promiseAll([
155863
155958
  init_approval_execution(),
155864
- init_model2(),
155865
- init_hooks(),
155866
- init_openai_codex_provider(),
155867
- init_telemetry(),
155868
- init_secret_substitution(),
155869
155959
  init_toolDefinitions()
155870
155960
  ]);
155871
155961
  var TOOL_NAMES2 = Object.keys(TOOL_DEFINITIONS);
@@ -156125,14 +156215,12 @@ ${after}`;
156125
156215
  }
156126
156216
 
156127
156217
  // src/tools/toolset.ts
156218
+ init_client2();
156219
+ init_model2();
156128
156220
  init_registry();
156221
+ init_settings_manager();
156129
156222
  init_filter();
156130
- await __promiseAll([
156131
- init_client2(),
156132
- init_model2(),
156133
- init_settings_manager(),
156134
- init_manager3()
156135
- ]);
156223
+ await init_manager3();
156136
156224
  var MEMORY_TOOL_NAMES2 = new Set([
156137
156225
  "memory",
156138
156226
  "memory_apply_patch",
@@ -156412,19 +156500,19 @@ async function getPinnedAgentNames() {
156412
156500
  }
156413
156501
  async function main() {
156414
156502
  markMilestone2("CLI_START");
156503
+ const subcommandResult = await runSubcommand(process.argv.slice(2));
156504
+ if (subcommandResult !== null) {
156505
+ process.exit(subcommandResult);
156506
+ }
156507
+ await settingsManager2.initialize();
156415
156508
  const { initTerminalTheme: initTerminalTheme2 } = await Promise.resolve().then(() => exports_terminalTheme);
156416
156509
  await initTerminalTheme2();
156417
- await settingsManager2.initialize();
156418
156510
  const settings = await settingsManager2.getSettingsWithSecureTokens();
156419
156511
  markMilestone2("SETTINGS_LOADED");
156420
156512
  if (process.env.LETTA_API_KEY) {
156421
- const { bootstrapBaseToolsIfNeeded: bootstrapBaseToolsIfNeeded2 } = await init_bootstrap_tools().then(() => exports_bootstrap_tools);
156513
+ const { bootstrapBaseToolsIfNeeded: bootstrapBaseToolsIfNeeded2 } = await Promise.resolve().then(() => (init_bootstrap_tools(), exports_bootstrap_tools));
156422
156514
  await bootstrapBaseToolsIfNeeded2();
156423
156515
  }
156424
- const subcommandResult = await runSubcommand(process.argv.slice(2));
156425
- if (subcommandResult !== null) {
156426
- process.exit(subcommandResult);
156427
- }
156428
156516
  if (process.env.LETTA_ENABLE_LSP) {
156429
156517
  try {
156430
156518
  const { lspManager: lspManager3 } = await Promise.resolve().then(() => (init_manager4(), exports_manager2));
@@ -156434,7 +156522,7 @@ async function main() {
156434
156522
  console.error("[LSP] Failed to initialize:", error);
156435
156523
  }
156436
156524
  }
156437
- const { checkAndAutoUpdate: checkAndAutoUpdate2 } = await init_auto_update().then(() => exports_auto_update);
156525
+ const { checkAndAutoUpdate: checkAndAutoUpdate2 } = await Promise.resolve().then(() => (init_auto_update(), exports_auto_update));
156438
156526
  const autoUpdatePromise = startStartupAutoUpdateCheck(checkAndAutoUpdate2);
156439
156527
  const processedArgs = preprocessCliArgs(process.argv);
156440
156528
  let values;
@@ -156475,7 +156563,7 @@ Note: Flags should use double dashes for full names (e.g., --yolo, not -yolo)`);
156475
156563
  process.exit(0);
156476
156564
  }
156477
156565
  if (command === "update") {
156478
- const { manualUpdate: manualUpdate2 } = await init_auto_update().then(() => exports_auto_update);
156566
+ const { manualUpdate: manualUpdate2 } = await Promise.resolve().then(() => (init_auto_update(), exports_auto_update));
156479
156567
  const result = await manualUpdate2();
156480
156568
  console.log(result.message);
156481
156569
  process.exit(result.success ? 0 : 1);
@@ -156547,7 +156635,7 @@ Note: Flags should use double dashes for full names (e.g., --yolo, not -yolo)`);
156547
156635
  telemetry2.setSurface(isHeadless ? "headless" : "tui");
156548
156636
  telemetry2.init();
156549
156637
  if (!isHeadless) {
156550
- const { startDockerVersionCheck: startDockerVersionCheck2 } = await init_startup_docker_check().then(() => exports_startup_docker_check);
156638
+ const { startDockerVersionCheck: startDockerVersionCheck2 } = await Promise.resolve().then(() => (init_startup_docker_check(), exports_startup_docker_check));
156551
156639
  startDockerVersionCheck2().catch(() => {});
156552
156640
  const { cleanupOldOverflowFiles: cleanupOldOverflowFiles2 } = await Promise.resolve().then(() => (init_overflow2(), exports_overflow));
156553
156641
  Promise.resolve().then(() => {
@@ -156731,11 +156819,11 @@ Error: ${message}`);
156731
156819
  await runSetup2();
156732
156820
  return main();
156733
156821
  }
156734
- const { validateCredentials: validateCredentials3 } = await init_oauth2().then(() => exports_oauth2);
156822
+ const { validateCredentials: validateCredentials3 } = await Promise.resolve().then(() => (init_oauth2(), exports_oauth2));
156735
156823
  const isValid = await validateCredentials3(baseURL, apiKey ?? "");
156736
156824
  markMilestone2("CREDENTIALS_VALIDATED");
156737
156825
  if (isValid) {
156738
- const { bootstrapBaseToolsIfNeeded: bootstrapBaseToolsIfNeeded2 } = await init_bootstrap_tools().then(() => exports_bootstrap_tools);
156826
+ const { bootstrapBaseToolsIfNeeded: bootstrapBaseToolsIfNeeded2 } = await Promise.resolve().then(() => (init_bootstrap_tools(), exports_bootstrap_tools));
156739
156827
  await bootstrapBaseToolsIfNeeded2();
156740
156828
  }
156741
156829
  if (!isValid) {
@@ -156933,7 +157021,7 @@ Error: ${message}`);
156933
157021
  }, []);
156934
157022
  useEffect41(() => {
156935
157023
  async function checkNotes() {
156936
- const { checkReleaseNotes: checkReleaseNotes2 } = await init_release_notes().then(() => exports_release_notes);
157024
+ const { checkReleaseNotes: checkReleaseNotes2 } = await Promise.resolve().then(() => (init_release_notes(), exports_release_notes));
156937
157025
  const notes = await checkReleaseNotes2();
156938
157026
  setReleaseNotes(notes);
156939
157027
  }
@@ -156950,7 +157038,7 @@ Error: ${message}`);
156950
157038
  if (isSelfHosted) {
156951
157039
  setSelfHostedBaseUrl(baseURL2);
156952
157040
  try {
156953
- const { getDefaultModel: getDefaultModel3 } = await init_model().then(() => exports_model);
157041
+ const { getDefaultModel: getDefaultModel3 } = await Promise.resolve().then(() => (init_model(), exports_model));
156954
157042
  const defaultModel = getDefaultModel3();
156955
157043
  setSelfHostedDefaultModel(defaultModel);
156956
157044
  const modelsList = await client.models.list();
@@ -157085,7 +157173,7 @@ Error: ${message}`);
157085
157173
  setLoadingState("selecting_global");
157086
157174
  return;
157087
157175
  case "create": {
157088
- const { ensureDefaultAgents: ensureDefaultAgents3 } = await init_defaults2().then(() => exports_defaults2);
157176
+ const { ensureDefaultAgents: ensureDefaultAgents3 } = await Promise.resolve().then(() => (init_defaults2(), exports_defaults2));
157089
157177
  try {
157090
157178
  const defaultAgent = await ensureDefaultAgents3(client, {
157091
157179
  preferredModel: model
@@ -157163,14 +157251,14 @@ Error: ${message}`);
157163
157251
  const modelForTools = getModelForToolLoading(model, toolset);
157164
157252
  await loadTools2(modelForTools);
157165
157253
  setLoadingState("initializing");
157166
- const { createAgent: createAgent3 } = await init_create3().then(() => exports_create2);
157254
+ const { createAgent: createAgent3 } = await Promise.resolve().then(() => (init_create3(), exports_create2));
157167
157255
  let agent = null;
157168
157256
  let autoEnableMemfsForFreshAgent = false;
157169
157257
  if (fromAfFile2) {
157170
157258
  setLoadingState("importing");
157171
157259
  let result;
157172
157260
  if (isRegistryImport2) {
157173
- const { importAgentFromRegistry: importAgentFromRegistry3 } = await init_import2().then(() => exports_import2);
157261
+ const { importAgentFromRegistry: importAgentFromRegistry3 } = await Promise.resolve().then(() => (init_import2(), exports_import2));
157174
157262
  result = await importAgentFromRegistry3({
157175
157263
  handle: fromAfFile2,
157176
157264
  modelOverride: model,
@@ -157178,7 +157266,7 @@ Error: ${message}`);
157178
157266
  stripSkills: false
157179
157267
  });
157180
157268
  } else {
157181
- const { importAgentFromFile: importAgentFromFile3 } = await init_import2().then(() => exports_import2);
157269
+ const { importAgentFromFile: importAgentFromFile3 } = await Promise.resolve().then(() => (init_import2(), exports_import2));
157182
157270
  result = await importAgentFromFile3({
157183
157271
  filePath: fromAfFile2,
157184
157272
  modelOverride: model,
@@ -157219,7 +157307,7 @@ Error: ${message}`);
157219
157307
  }
157220
157308
  let effectiveModel = selectedServerModel || model;
157221
157309
  if (!effectiveModel && !selfHostedBaseUrl) {
157222
- const { getDefaultModelForTier: getDefaultModelForTier3 } = await init_model().then(() => exports_model);
157310
+ const { getDefaultModelForTier: getDefaultModelForTier3 } = await Promise.resolve().then(() => (init_model(), exports_model));
157223
157311
  let billingTier = null;
157224
157312
  try {
157225
157313
  const baseURL2 = process.env.LETTA_BASE_URL || settings.env?.LETTA_BASE_URL || LETTA_CLOUD_API_URL2;
@@ -157280,7 +157368,7 @@ Error: ${message}`);
157280
157368
  agentTags,
157281
157369
  skipPromptUpdate: shouldCreateNew
157282
157370
  }));
157283
- const secretsInitPromise = init_secretsStore2().then(() => exports_secretsStore2).then(({ initSecretsFromServer: initSecretsFromServer3 }) => initSecretsFromServer3(agentId2));
157371
+ const secretsInitPromise = Promise.resolve().then(() => (init_secretsStore2(), exports_secretsStore2)).then(({ initSecretsFromServer: initSecretsFromServer3 }) => initSecretsFromServer3(agentId2));
157284
157372
  const isResumingProject = !shouldCreateNew && !!resumingAgentId;
157285
157373
  const isReusingExistingAgent = !shouldCreateNew && !fromAfFile2 && agent && agent.id;
157286
157374
  const resuming = !!(agentIdArg || isResumingProject || isReusingExistingAgent);
@@ -157565,4 +157653,4 @@ Error during initialization: ${message}`);
157565
157653
  }
157566
157654
  main();
157567
157655
 
157568
- //# debugId=C8198BA5F7A6868064756E2164756E21
157656
+ //# debugId=D8A1D12AB070B18C64756E2164756E21