@letta-ai/letta-code 0.34.44 → 0.34.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/letta.js CHANGED
@@ -6077,7 +6077,7 @@ var package_default;
6077
6077
  var init_package = __esm(() => {
6078
6078
  package_default = {
6079
6079
  name: "@letta-ai/letta-code",
6080
- version: "0.34.44",
6080
+ version: "0.34.45",
6081
6081
  lettaStartupLogProtocol: 1,
6082
6082
  lettaConfigDirProtocol: 1,
6083
6083
  description: "Letta Code is a CLI tool for interacting with stateful Letta agents from the terminal.",
@@ -6230,7 +6230,6 @@ var init_package = __esm(() => {
6230
6230
  dependencies: {
6231
6231
  "@cursor/sdk": "1.1.0",
6232
6232
  "@earendil-works/pi-ai": "^0.99.1",
6233
- "@janhapke/sharp-electron": "0.35.3-electron.1",
6234
6233
  "@letta-ai/letta-agent-sdk": "0.8.38",
6235
6234
  "@letta-ai/letta-client": "^1.10.2",
6236
6235
  "@letta-ai/trajectory": "0.2.0",
@@ -6246,7 +6245,7 @@ var init_package = __esm(() => {
6246
6245
  "node-pty": "^1.1.0",
6247
6246
  open: "^10.2.0",
6248
6247
  react: "18.2.0",
6249
- sharp: "^0.34.5",
6248
+ sharp: "^0.35.5",
6250
6249
  shiki: "^4.0.2",
6251
6250
  "strip-ansi": "^7.2.0",
6252
6251
  ws: "^8.19.0"
@@ -6355,7 +6354,7 @@ var init_package = __esm(() => {
6355
6354
  },
6356
6355
  lettaLifecycleProtocol: 1,
6357
6356
  lettaRuntimeGraphProtocol: 1,
6358
- lettaRuntimeGraphSha512: "sha512-x6CZjpXvXckGCycYwdxVs0W3XTf6uzPH1il5cUWVWlNkC2w7naCOb53kNlJ0PC9/t6XHtxAPZhqhWJUlOKG2lg==",
6357
+ lettaRuntimeGraphSha512: "sha512-WIZjjGgnUTIQDdGkiMGGmYxhKDr34pXqcEUPqh9YvmdauZnqYCj0OeYE8ltjcpPNYevvXHP32Edeo+arrylfXA==",
6359
6358
  patchedDependencies: {
6360
6359
  "@earendil-works/pi-ai@0.99.1": "patches/@earendil-works%2Fpi-ai@0.99.1.patch"
6361
6360
  }
@@ -99417,16 +99416,6 @@ var init_context = __esm(() => {
99417
99416
  context2 = getContext();
99418
99417
  });
99419
99418
 
99420
- // src/constants.ts
99421
- var DEFAULT_SUMMARIZATION_MODEL = "letta/auto", DEFAULT_TITLE_SUMMARIZATION_MODEL = "openai/gpt-6-luna", DEFAULT_AGENT_NAME = "Letta Code", INTERRUPTED_BY_USER = "Interrupted by user", TURN_DID_NOT_COMPLETE = "Turn did not complete", SYSTEM_REMINDER_TAG = "system-reminder", SYSTEM_REMINDER_OPEN, SYSTEM_REMINDER_CLOSE, SYSTEM_ALERT_TAG = "system-alert", SYSTEM_ALERT_OPEN, SYSTEM_ALERT_CLOSE, COMPACTION_SUMMARY_HEADER = "(Earlier messages in this conversation have been compacted to free up context, summarized below)", TOKEN_DISPLAY_THRESHOLD = 100, ELAPSED_DISPLAY_THRESHOLD_MS;
99422
- var init_constants2 = __esm(() => {
99423
- SYSTEM_REMINDER_OPEN = `<${SYSTEM_REMINDER_TAG}>`;
99424
- SYSTEM_REMINDER_CLOSE = `</${SYSTEM_REMINDER_TAG}>`;
99425
- SYSTEM_ALERT_OPEN = `<${SYSTEM_ALERT_TAG}>`;
99426
- SYSTEM_ALERT_CLOSE = `</${SYSTEM_ALERT_TAG}>`;
99427
- ELAPSED_DISPLAY_THRESHOLD_MS = 60 * 1000;
99428
- });
99429
-
99430
99419
  // src/agent/memory-constants.ts
99431
99420
  var READ_ONLY_BLOCK_LABELS;
99432
99421
  var init_memory_constants = __esm(() => {
@@ -101785,26 +101774,18 @@ function resolveModel(modelIdentifier) {
101785
101774
  return builtinHandle;
101786
101775
  return modelIdentifier.includes("/") ? modelIdentifier : null;
101787
101776
  }
101777
+ function isLettaHostedModelHandle(handle) {
101778
+ return handle.startsWith("letta/");
101779
+ }
101788
101780
  function getDefaultModel() {
101789
- if (models2.length === 0)
101790
- return "letta/auto";
101791
- const autoModel = models2.find((model) => model.id === "auto");
101792
- if (autoModel)
101793
- return autoModel.handle;
101794
- const defaultModel = models2.find((model) => model.isDefault);
101795
- if (defaultModel)
101796
- return defaultModel.handle;
101797
- const firstModel = models2[0];
101798
- if (!firstModel) {
101799
- throw new Error("Model catalog is unavailable.");
101800
- }
101801
- return firstModel.handle;
101802
- }
101803
- var models2, BUILTIN_MODEL_ALIASES;
101781
+ const candidates2 = models2.filter((model) => !isLettaHostedModelHandle(model.handle));
101782
+ const defaultModel = candidates2.find((model) => model.isDefault) ?? candidates2[0];
101783
+ return defaultModel?.handle ?? UNSELECTED_MODEL_HANDLE;
101784
+ }
101785
+ var models2, BUILTIN_MODEL_ALIASES, UNSELECTED_MODEL_HANDLE = "local/default";
101804
101786
  var init_model_catalog = __esm(() => {
101805
101787
  models2 = [];
101806
101788
  BUILTIN_MODEL_ALIASES = new Map([
101807
- ["auto", "letta/auto"],
101808
101789
  ["auto-chat", "letta/auto-chat"],
101809
101790
  ["auto-fast", "letta/auto-fast"]
101810
101791
  ]);
@@ -102143,7 +102124,7 @@ async function buildCreateAgentRequest(options = {}) {
102143
102124
  initial_message_sequence: [],
102144
102125
  parallel_tool_calls: options.parallelToolCalls ?? true,
102145
102126
  compaction_settings: {
102146
- model: options.compactionModel ?? DEFAULT_SUMMARIZATION_MODEL
102127
+ model: options.compactionModel ?? modelHandle
102147
102128
  },
102148
102129
  ...options.embedding !== undefined ? { embedding: options.embedding } : {},
102149
102130
  ...options.isSubagent ? { hidden: true } : options.hidden !== undefined ? { hidden: options.hidden } : {}
@@ -102151,7 +102132,6 @@ async function buildCreateAgentRequest(options = {}) {
102151
102132
  }
102152
102133
  var LETTA_CODE_AGENT_TYPE = "letta_v1_agent", DEFAULT_CREATED_AGENT_BASE_TOOLS, DEFAULT_ROOT_MEMORY_BLOCK;
102153
102134
  var init_create_agent_request = __esm(() => {
102154
- init_constants2();
102155
102135
  init_memory3();
102156
102136
  init_model_catalog();
102157
102137
  init_personality_presets();
@@ -102773,9 +102753,11 @@ case "$memory_layout_policy" in
102773
102753
  esac
102774
102754
 
102775
102755
  if [ "$use_v2_validation" = "true" ]; then
102776
- for file in $(git diff --cached --name-only --diff-filter=ACMR | grep -E '^skills/[^/]+\\.md$' || true); do
102777
- errors="$errors\\n $file: invalid skill path (skills must be folders). Use skills/<name>/SKILL.md"
102778
- done
102756
+ while IFS= read -r -d '' file; do
102757
+ if [[ "$file" =~ ^skills/[^/]+\\.md$ ]]; then
102758
+ errors="$errors\\n $file: invalid skill path (skills must be folders). Use skills/<name>/SKILL.md"
102759
+ fi
102760
+ done < <(git diff --cached --name-only -z --diff-filter=ACMR)
102779
102761
 
102780
102762
  validate_memory_files "memfs-v2"
102781
102763
 
@@ -102790,15 +102772,20 @@ fi
102790
102772
 
102791
102773
  # Skills must always be directories: skills/<name>/SKILL.md
102792
102774
  # Reject legacy flat skill files (both current and legacy repo layouts).
102793
- for file in $(git diff --cached --name-only --diff-filter=ACMR | grep -E '^(memory/)?skills/[^/]+\\.md$' || true); do
102794
- errors="$errors\\n $file: invalid skill path (skills must be folders). Use skills/<name>/SKILL.md"
102795
- done
102775
+ while IFS= read -r -d '' file; do
102776
+ if [[ "$file" =~ ^(memory/)?skills/[^/]+\\.md$ ]]; then
102777
+ errors="$errors\\n $file: invalid skill path (skills must be folders). Use skills/<name>/SKILL.md"
102778
+ fi
102779
+ done < <(git diff --cached --name-only -z --diff-filter=ACMR)
102796
102780
 
102797
102781
  # Match .md files under system/ or reference/ (with optional memory/ prefix).
102798
102782
  # Skip skill SKILL.md files — they use a different frontmatter format.
102799
- for file in $(git diff --cached --name-only --diff-filter=ACM | grep -E '^(memory/)?(system|reference)/.*\\.md$'); do
102800
- memory_files+=("$file")
102801
- done
102783
+ # NUL-delimited so paths containing spaces or quotes stay intact.
102784
+ while IFS= read -r -d '' file; do
102785
+ if [[ "$file" =~ ^(memory/)?(system|reference)/.*\\.md$ ]]; then
102786
+ memory_files+=("$file")
102787
+ fi
102788
+ done < <(git diff --cached --name-only -z --diff-filter=ACM)
102802
102789
  validate_memory_files "legacy"
102803
102790
 
102804
102791
  if [ -n "$errors" ]; then
@@ -108661,6 +108648,7 @@ __export(exports_secrets_store, {
108661
108648
  deleteSecretOnServer: () => deleteSecretOnServer,
108662
108649
  clearSecretsCache: () => clearSecretsCache,
108663
108650
  applySecretBatch: () => applySecretBatch,
108651
+ __testSetSecretsMaxAgeMs: () => __testSetSecretsMaxAgeMs,
108664
108652
  __testSeedSecretsCache: () => __testSeedSecretsCache,
108665
108653
  __testOverrideSecretsBackend: () => __testOverrideSecretsBackend,
108666
108654
  __testOverrideLocalSecretStorage: () => __testOverrideLocalSecretStorage
@@ -108759,8 +108747,19 @@ function getCache() {
108759
108747
  }
108760
108748
  return global2[SECRETS_CACHE_KEY];
108761
108749
  }
108750
+ function getLoadedAt() {
108751
+ const global2 = globalThis;
108752
+ if (!global2[SECRETS_LOADED_AT_KEY]) {
108753
+ global2[SECRETS_LOADED_AT_KEY] = new Map;
108754
+ }
108755
+ return global2[SECRETS_LOADED_AT_KEY];
108756
+ }
108762
108757
  function setCache(agentId, secrets2) {
108763
108758
  getCache().set(agentId, { ...secrets2 });
108759
+ getLoadedAt().set(agentId, Date.now());
108760
+ }
108761
+ function __testSetSecretsMaxAgeMs(ms) {
108762
+ testSecretsMaxAgeOverride = ms;
108764
108763
  }
108765
108764
  function localSecretIndexName(agentId) {
108766
108765
  return `agent:${agentId}:secrets:index`;
@@ -108895,8 +108894,22 @@ function loadSecrets(agentId) {
108895
108894
  return { ...getCache().get(resolvedAgentId) ?? {} };
108896
108895
  }
108897
108896
  async function ensureSecretsLoaded(agentId) {
108898
- if (!getCache().has(agentId))
108897
+ if (!getCache().has(agentId)) {
108899
108898
  await initSecretsFromServer(agentId);
108899
+ return;
108900
+ }
108901
+ const loadedAt = getLoadedAt().get(agentId) ?? 0;
108902
+ const maxAge = testSecretsMaxAgeOverride ?? DEFAULT_SECRETS_MAX_AGE_MS;
108903
+ if (Date.now() - loadedAt < maxAge)
108904
+ return;
108905
+ let refresh = staleRefreshes.get(agentId);
108906
+ if (!refresh) {
108907
+ refresh = initSecretsFromServer(agentId).catch(() => {
108908
+ return;
108909
+ }).finally(() => staleRefreshes.delete(agentId));
108910
+ staleRefreshes.set(agentId, refresh);
108911
+ }
108912
+ await refresh;
108900
108913
  }
108901
108914
  function listSecretNames(agentId) {
108902
108915
  return Object.keys(loadSecrets(agentId)).sort();
@@ -108980,16 +108993,19 @@ async function deleteSecretOnServer(key, agentIdArg) {
108980
108993
  function clearSecretsCache(agentId) {
108981
108994
  if (agentId === null) {
108982
108995
  getCache().clear();
108996
+ getLoadedAt().clear();
108983
108997
  return;
108984
108998
  }
108985
108999
  const resolvedAgentId = resolveSecretsAgentId(agentId);
108986
109000
  if (resolvedAgentId) {
108987
109001
  getCache().delete(resolvedAgentId);
109002
+ getLoadedAt().delete(resolvedAgentId);
108988
109003
  return;
108989
109004
  }
108990
109005
  getCache().clear();
109006
+ getLoadedAt().clear();
108991
109007
  }
108992
- var testBackendOverride = null, testLocalSecretStorageOverride = null, FILE_BACKED_LOCAL_SECRETS_PATH, SECRETS_CACHE_KEY, LOCAL_SECRET_NAME_PATTERN;
109008
+ var testBackendOverride = null, testLocalSecretStorageOverride = null, FILE_BACKED_LOCAL_SECRETS_PATH, SECRETS_CACHE_KEY, SECRETS_LOADED_AT_KEY, DEFAULT_SECRETS_MAX_AGE_MS = 60000, testSecretsMaxAgeOverride = null, staleRefreshes, LOCAL_SECRET_NAME_PATTERN;
108993
109009
  var init_secrets_store = __esm(() => {
108994
109010
  init_context();
108995
109011
  init_backend2();
@@ -108997,6 +109013,8 @@ var init_secrets_store = __esm(() => {
108997
109013
  init_secrets();
108998
109014
  FILE_BACKED_LOCAL_SECRETS_PATH = join18("secrets", "local-agent-secrets.json");
108999
109015
  SECRETS_CACHE_KEY = Symbol.for("@letta/secretsCache");
109016
+ SECRETS_LOADED_AT_KEY = Symbol.for("@letta/secretsLoadedAt");
109017
+ staleRefreshes = new Map;
109000
109018
  LOCAL_SECRET_NAME_PATTERN = /^[A-Z_][A-Z0-9_]*$/;
109001
109019
  });
109002
109020
 
@@ -109405,6 +109423,16 @@ function localConversationKey(conversationId, agentId) {
109405
109423
  return conversationId === "default" ? `default:${agentId}` : `conversation:${conversationId}`;
109406
109424
  }
109407
109425
 
109426
+ // src/constants.ts
109427
+ var DEFAULT_TITLE_SUMMARIZATION_MODEL = "openai/gpt-6-luna", DEFAULT_AGENT_NAME = "Letta Code", INTERRUPTED_BY_USER = "Interrupted by user", TURN_DID_NOT_COMPLETE = "Turn did not complete", SYSTEM_REMINDER_TAG = "system-reminder", SYSTEM_REMINDER_OPEN, SYSTEM_REMINDER_CLOSE, SYSTEM_ALERT_TAG = "system-alert", SYSTEM_ALERT_OPEN, SYSTEM_ALERT_CLOSE, COMPACTION_SUMMARY_HEADER = "(Earlier messages in this conversation have been compacted to free up context, summarized below)", TOKEN_DISPLAY_THRESHOLD = 100, ELAPSED_DISPLAY_THRESHOLD_MS;
109428
+ var init_constants2 = __esm(() => {
109429
+ SYSTEM_REMINDER_OPEN = `<${SYSTEM_REMINDER_TAG}>`;
109430
+ SYSTEM_REMINDER_CLOSE = `</${SYSTEM_REMINDER_TAG}>`;
109431
+ SYSTEM_ALERT_OPEN = `<${SYSTEM_ALERT_TAG}>`;
109432
+ SYSTEM_ALERT_CLOSE = `</${SYSTEM_ALERT_TAG}>`;
109433
+ ELAPSED_DISPLAY_THRESHOLD_MS = 60 * 1000;
109434
+ });
109435
+
109408
109436
  // src/backend/local/local-model-normalization.ts
109409
109437
  function supportedModelSettingsFromBody(bodyRecord) {
109410
109438
  const modelSettings = isRecord2(bodyRecord.model_settings) ? { ...bodyRecord.model_settings } : {};
@@ -113572,7 +113600,7 @@ Delete ${resourceType} at: ${LETTA_AGENTS_URL}`;
113572
113600
  const lettaHostedQuotaMsg2 = getLettaHostedQuotaMessage(e2, reasons);
113573
113601
  if (lettaHostedQuotaMsg2)
113574
113602
  return lettaHostedQuotaMsg2;
113575
- return `Your account does not have credits for this model. Add your own API keys or upgrade your plan to purchase credits.`;
113603
+ return KEY_OR_CREDITS_REQUIRED_MESSAGE;
113576
113604
  }
113577
113605
  const lettaHostedQuotaMsg = getLettaHostedQuotaMessage(e2, reasons);
113578
113606
  if (lettaHostedQuotaMsg)
@@ -113678,7 +113706,7 @@ function createAgentLink(runId, agentId, conversationId, surface) {
113678
113706
  const agentRef = surface === "terminal" ? buildAgentTerminalLink(agentId, { conversationId }) : agentId;
113679
113707
  return `View agent: ${agentRef} (run: ${runId})`;
113680
113708
  }
113681
- var LETTA_USAGE_URL, LETTA_AGENTS_URL, GENERIC_ERROR_MESSAGE = "The request failed. Please try again.", CLOUDFLARE_EDGE_5XX_MARKER_PATTERN, CLOUDFLARE_EDGE_5XX_TITLE_PATTERN, CLOUDFLARE_EDGE_5XX_FORMATTED_PATTERN, CLOUDFLARE_JSON_5XX_PATTERN, CHATGPT_USAGE_LIMIT_HINT = "Switch models with /model, or connect your own provider keys with /connect.", ENCRYPTED_CONTENT_HINT, DEFAULT_RETRY_MESSAGE = "Unexpected downstream LLM API error, retrying...", ENDPOINT_TYPE_DISPLAY_NAMES;
113709
+ var LETTA_USAGE_URL, KEY_OR_CREDITS_REQUIRED_MESSAGE, LETTA_AGENTS_URL, GENERIC_ERROR_MESSAGE = "The request failed. Please try again.", CLOUDFLARE_EDGE_5XX_MARKER_PATTERN, CLOUDFLARE_EDGE_5XX_TITLE_PATTERN, CLOUDFLARE_EDGE_5XX_FORMATTED_PATTERN, CLOUDFLARE_JSON_5XX_PATTERN, CHATGPT_USAGE_LIMIT_HINT = "Switch models with /model, or connect your own provider keys with /connect.", ENCRYPTED_CONTENT_HINT, DEFAULT_RETRY_MESSAGE = "Unexpected downstream LLM API error, retrying...", ENDPOINT_TYPE_DISPLAY_NAMES;
113682
113710
  var init_error_formatter = __esm(() => {
113683
113711
  init_error();
113684
113712
  init_conversation_busy_error();
@@ -113686,6 +113714,7 @@ var init_error_formatter = __esm(() => {
113686
113714
  init_error_context();
113687
113715
  init_zai_errors();
113688
113716
  LETTA_USAGE_URL = buildChatWebUrl("/preferences/usage");
113717
+ KEY_OR_CREDITS_REQUIRED_MESSAGE = `This model needs your own API key or Letta credits. Run /connect to add a provider key, or buy credits at ${LETTA_USAGE_URL}.`;
113689
113718
  LETTA_AGENTS_URL = buildChatWebUrl("/agents");
113690
113719
  CLOUDFLARE_EDGE_5XX_MARKER_PATTERN = /(^|\s)(502|52[0-6])\s*<!doctype html|error code\s*(502|52[0-6])/i;
113691
113720
  CLOUDFLARE_EDGE_5XX_TITLE_PATTERN = /\|\s*(502|52[0-6])\s*:/i;
@@ -141978,7 +142007,7 @@ var init_devtools = __esm(() => {
141978
142007
 
141979
142008
  // node_modules/ink/build/reconciler.js
141980
142009
  import process3 from "node:process";
141981
- var import_react_reconciler, import_constants7, diff2 = (before2, after2) => {
142010
+ var import_react_reconciler, import_constants6, diff2 = (before2, after2) => {
141982
142011
  if (before2 === after2) {
141983
142012
  return;
141984
142013
  }
@@ -142014,7 +142043,7 @@ var init_reconciler = __esm(async () => {
142014
142043
  init_styles()
142015
142044
  ]);
142016
142045
  import_react_reconciler = __toESM(require_react_reconciler(), 1);
142017
- import_constants7 = __toESM(require_constants(), 1);
142046
+ import_constants6 = __toESM(require_constants(), 1);
142018
142047
  if (process3.env["DEV"] === "true") {
142019
142048
  try {
142020
142049
  await Promise.resolve().then(() => (init_devtools(), exports_devtools));
@@ -142131,7 +142160,7 @@ $ npm install --save-dev react-devtools-core
142131
142160
  scheduleTimeout: setTimeout,
142132
142161
  cancelTimeout: clearTimeout,
142133
142162
  noTimeout: -1,
142134
- getCurrentEventPriority: () => import_constants7.DefaultEventPriority,
142163
+ getCurrentEventPriority: () => import_constants6.DefaultEventPriority,
142135
142164
  beforeActiveInstanceBlur() {},
142136
142165
  afterActiveInstanceBlur() {},
142137
142166
  detachDeletedInstance() {},
@@ -158209,6 +158238,7 @@ function resizeWithSharpWorker(buffer, inputMediaType) {
158209
158238
  return new Promise((resolve11, reject2) => {
158210
158239
  const workerPath = resolveImageWorkerPath();
158211
158240
  const child = spawn3(process.execPath, [workerPath, inputMediaType], {
158241
+ env: { ...process.env, ELECTRON_RUN_AS_NODE: "1" },
158212
158242
  shell: false,
158213
158243
  stdio: ["pipe", "pipe", "pipe"],
158214
158244
  windowsHide: true
@@ -212050,7 +212080,7 @@ var init_mcp_client = __esm(() => {
212050
212080
  init_streamableHttp();
212051
212081
  DEFAULT_CLIENT_INFO = {
212052
212082
  name: "letta-code",
212053
- version: "0.34.44"
212083
+ version: "0.34.45"
212054
212084
  };
212055
212085
  });
212056
212086
 
@@ -248027,7 +248057,7 @@ class CodexAppServerClient {
248027
248057
  await this.request("initialize", {
248028
248058
  clientInfo: {
248029
248059
  name: "letta-code",
248030
- version: "0.34.44"
248060
+ version: "0.34.45"
248031
248061
  },
248032
248062
  capabilities: null
248033
248063
  });
@@ -252691,7 +252721,7 @@ async function fetchParentConversationMessages(params) {
252691
252721
  }
252692
252722
  return messages;
252693
252723
  }
252694
- function contentText3(content) {
252724
+ function contentText2(content) {
252695
252725
  if (typeof content === "string")
252696
252726
  return content;
252697
252727
  if (!Array.isArray(content))
@@ -252717,7 +252747,7 @@ function renderToolCall(call2) {
252717
252747
  }
252718
252748
  function renderToolResult(result3) {
252719
252749
  const raw2 = result3.tool_return ?? result3.func_response;
252720
- const text2 = typeof raw2 === "string" ? raw2 : contentText3(raw2) || (raw2 == null ? "" : JSON.stringify(raw2));
252750
+ const text2 = typeof raw2 === "string" ? raw2 : contentText2(raw2) || (raw2 == null ? "" : JSON.stringify(raw2));
252721
252751
  return {
252722
252752
  type: "tool_result",
252723
252753
  call_id: result3.tool_call_id ?? undefined,
@@ -252753,11 +252783,11 @@ function userEvents(text2, speaker) {
252753
252783
  function renderMessage(message2) {
252754
252784
  switch (message2.message_type) {
252755
252785
  case "user_message": {
252756
- const text2 = contentText3(message2.content).replace(SYSTEM_REMINDER_PATTERN, "").trim();
252786
+ const text2 = contentText2(message2.content).replace(SYSTEM_REMINDER_PATTERN, "").trim();
252757
252787
  return userEvents(text2, message2.name ?? undefined);
252758
252788
  }
252759
252789
  case "assistant_message": {
252760
- const text2 = contentText3(message2.content).trim();
252790
+ const text2 = contentText2(message2.content).trim();
252761
252791
  return text2 ? [
252762
252792
  {
252763
252793
  type: "message",
@@ -457391,7 +457421,7 @@ function buildConversationDescriptionMessages(messages) {
457391
457421
  }
457392
457422
  return descriptionMessages;
457393
457423
  }
457394
- async function generateConversationDescriptionFromSummary(conversationId, messages, model = DEFAULT_SUMMARIZATION_MODEL) {
457424
+ async function generateConversationDescriptionFromSummary(conversationId, messages, model = DEFAULT_TITLE_SUMMARIZATION_MODEL) {
457395
457425
  if (messages.length === 0) {
457396
457426
  return null;
457397
457427
  }
@@ -457432,7 +457462,7 @@ async function regenerateConversationDescription(conversationId) {
457432
457462
  include_return_message_types: ["user_message", "assistant_message"]
457433
457463
  });
457434
457464
  const messages = buildConversationDescriptionMessages(paginatedItems3(page).reverse());
457435
- const description = await generateConversationDescriptionFromSummary(conversationId, messages, DEFAULT_SUMMARIZATION_MODEL);
457465
+ const description = await generateConversationDescriptionFromSummary(conversationId, messages, DEFAULT_TITLE_SUMMARIZATION_MODEL);
457436
457466
  if (!description) {
457437
457467
  return false;
457438
457468
  }
@@ -458020,12 +458050,12 @@ function rowToolCalls(row, index, diagnostics2) {
458020
458050
  }
458021
458051
  return calls;
458022
458052
  }
458023
- function contentText4(content) {
458053
+ function contentText3(content) {
458024
458054
  if (typeof content === "string") {
458025
458055
  if (content.startsWith(CONTENT_JSON_PREFIX)) {
458026
458056
  const encoded = content.slice(CONTENT_JSON_PREFIX.length);
458027
458057
  try {
458028
- return contentText4(JSON.parse(encoded));
458058
+ return contentText3(JSON.parse(encoded));
458029
458059
  } catch {
458030
458060
  return encoded;
458031
458061
  }
@@ -458111,7 +458141,7 @@ var init_hermes = __esm(() => {
458111
458141
  });
458112
458142
  };
458113
458143
  if (row.role === "user") {
458114
- const content = contentText4(row.content);
458144
+ const content = contentText3(row.content);
458115
458145
  if (content) {
458116
458146
  emit({
458117
458147
  type: "message",
@@ -458131,7 +458161,7 @@ var init_hermes = __esm(() => {
458131
458161
  ...timestamp ? { timestamp } : {}
458132
458162
  });
458133
458163
  }
458134
- const content = contentText4(row.content);
458164
+ const content = contentText3(row.content);
458135
458165
  if (content) {
458136
458166
  emit({
458137
458167
  type: "message",
@@ -458154,7 +458184,7 @@ var init_hermes = __esm(() => {
458154
458184
  if (row.role === "tool") {
458155
458185
  emit({
458156
458186
  type: "tool_result",
458157
- content: contentText4(row.content),
458187
+ content: contentText3(row.content),
458158
458188
  ...typeof row.tool_call_id === "string" && row.tool_call_id ? { callId: row.tool_call_id } : {},
458159
458189
  ...timestamp ? { timestamp } : {}
458160
458190
  });
@@ -466958,7 +466988,7 @@ async function handleCompactCommand(socket, conversationRuntime, args) {
466958
466988
  compactParams = {
466959
466989
  compaction_settings: {
466960
466990
  mode: modeArg,
466961
- model: agent.compaction_settings?.model?.trim() || DEFAULT_SUMMARIZATION_MODEL
466991
+ model: agent.compaction_settings?.model?.trim() || agent.model || undefined
466962
466992
  }
466963
466993
  };
466964
466994
  }
@@ -467116,7 +467146,6 @@ var init_commands2 = __esm(async () => {
467116
467146
  init_reflect_command();
467117
467147
  init_reflection_launcher();
467118
467148
  init_command_runtime();
467119
- init_constants2();
467120
467149
  init_hooks();
467121
467150
  init_settings_manager();
467122
467151
  init_error_reporting();
@@ -493621,10 +493650,10 @@ async function reconcileExistingAgentState(client, agent) {
493621
493650
  const appliedTweaks = [];
493622
493651
  const skippedTweaks = [];
493623
493652
  const configuredCompactionModel = typeof agent.compaction_settings?.model === "string" ? agent.compaction_settings.model.trim() : "";
493624
- if (!configuredCompactionModel) {
493653
+ if (!configuredCompactionModel && agent.model) {
493625
493654
  patch2.compaction_settings = {
493626
493655
  ...agent.compaction_settings ?? {},
493627
- model: DEFAULT_SUMMARIZATION_MODEL
493656
+ model: agent.model
493628
493657
  };
493629
493658
  appliedTweaks.push("set_compaction_model");
493630
493659
  }
@@ -493659,7 +493688,6 @@ async function reconcileExistingAgentState(client, agent) {
493659
493688
  }
493660
493689
  var DEFAULT_ATTACHED_BASE_TOOLS;
493661
493690
  var init_reconcile_existing_agent_state = __esm(() => {
493662
- init_constants2();
493663
493691
  DEFAULT_ATTACHED_BASE_TOOLS = [
493664
493692
  "web_search",
493665
493693
  "fetch_webpage"
@@ -494926,14 +494954,14 @@ function sampleReflectionArenaComparisonModel(excludedModels = []) {
494926
494954
  const candidates2 = REFLECTION_ARENA_COMPARISON_MODEL_POOL.filter((entry) => !excluded.has(entry.model));
494927
494955
  const totalWeight = candidates2.reduce((sum2, entry) => sum2 + Math.max(0, entry.weight), 0);
494928
494956
  if (totalWeight <= 0)
494929
- return "letta/auto";
494957
+ return REFLECTION_ARENA_COMPARISON_FALLBACK_MODEL;
494930
494958
  let offset = randomInt2(totalWeight);
494931
494959
  for (const candidate of candidates2) {
494932
494960
  offset -= Math.max(0, candidate.weight);
494933
494961
  if (offset < 0)
494934
494962
  return candidate.model;
494935
494963
  }
494936
- return candidates2[0]?.model ?? "letta/auto";
494964
+ return candidates2[0]?.model ?? REFLECTION_ARENA_COMPARISON_FALLBACK_MODEL;
494937
494965
  }
494938
494966
  async function getGitOutput(cwd2, args) {
494939
494967
  try {
@@ -495493,7 +495521,7 @@ async function finalizeReflectionArenaChoice(options) {
495493
495521
  run: completedRun
495494
495522
  };
495495
495523
  }
495496
- var execFile23, REFLECTION_ARENA_TELEMETRY_TRANSCRIPT_MAX_CHARS = 1e6, REFLECTION_ARENA_MODEL_A_DEFAULT = "letta/auto-memory", REFLECTION_ARENA_COMPARISON_MODEL_POOL, ANSI_BOLD = "\x1B[1m", ANSI_CYAN = "\x1B[36m", ANSI_MAGENTA = "\x1B[35m", ANSI_RESET_BOLD = "\x1B[22m", ANSI_RESET_FOREGROUND = "\x1B[39m", REFLECTION_ARENA_CANDIDATE_COUNT = 2, REFLECTION_ARENA_CHOICE_QUESTION = "Which reflection should be merged?", REFLECTION_ARENA_NOTES_QUESTION = "Optional feedback for this choice?", updateLocks;
495524
+ var execFile23, REFLECTION_ARENA_TELEMETRY_TRANSCRIPT_MAX_CHARS = 1e6, REFLECTION_ARENA_MODEL_A_DEFAULT = "letta/auto-memory", REFLECTION_ARENA_COMPARISON_FALLBACK_MODEL = "lc-anthropic/claude-sonnet-5", REFLECTION_ARENA_COMPARISON_MODEL_POOL, ANSI_BOLD = "\x1B[1m", ANSI_CYAN = "\x1B[36m", ANSI_MAGENTA = "\x1B[35m", ANSI_RESET_BOLD = "\x1B[22m", ANSI_RESET_FOREGROUND = "\x1B[39m", REFLECTION_ARENA_CANDIDATE_COUNT = 2, REFLECTION_ARENA_CHOICE_QUESTION = "Which reflection should be merged?", REFLECTION_ARENA_NOTES_QUESTION = "Optional feedback for this choice?", updateLocks;
495497
495525
  var init_reflection_arena = __esm(() => {
495498
495526
  init_memory_worktree();
495499
495527
  init_app_urls();
@@ -495509,7 +495537,6 @@ var init_reflection_arena = __esm(() => {
495509
495537
  { model: "lc-anthropic/claude-sonnet-5", weight: 1 },
495510
495538
  { model: "lc-anthropic/claude-opus-4-8", weight: 3 },
495511
495539
  { model: "lc-anthropic/claude-fable-5", weight: 1 },
495512
- { model: "letta/auto", weight: 1 },
495513
495540
  { model: "deepseek/deepseek-v4-pro", weight: 1 },
495514
495541
  { model: "minimax-m3", weight: 1 },
495515
495542
  { model: "gpt-5.5-plus-pro-high", weight: 3 }
@@ -524136,7 +524163,7 @@ var init_AppView = __esm(async () => {
524136
524163
  });
524137
524164
 
524138
524165
  // src/cli/app/constants.ts
524139
- var 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", 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, 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;
524166
+ var 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, 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, 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;
524140
524167
  var init_constants4 = __esm(() => {
524141
524168
  PROVIDER_STATUS_PAGES = {
524142
524169
  anthropic: {
@@ -525936,7 +525963,7 @@ ${guidance}`);
525936
525963
  const existingModel = existing?.model?.trim();
525937
525964
  const nextCompactionSettings = {
525938
525965
  ...existing,
525939
- model: existingModel || DEFAULT_SUMMARIZATION_MODEL,
525966
+ model: existingModel || agentState?.model || undefined,
525940
525967
  mode
525941
525968
  };
525942
525969
  await getBackend().updateAgent(agentId, {
@@ -525956,6 +525983,7 @@ ${guidance}`);
525956
525983
  isAgentBusy,
525957
525984
  withCommandLock,
525958
525985
  agentState?.compaction_settings,
525986
+ agentState?.model,
525959
525987
  setActiveOverlay,
525960
525988
  setAgentState,
525961
525989
  setQueuedOverlayAction
@@ -526151,7 +526179,6 @@ var init_use_configuration_handlers = __esm(async () => {
526151
526179
  init_client4();
526152
526180
  init_error_formatter();
526153
526181
  init_memory_reminder();
526154
- init_constants2();
526155
526182
  init_manager();
526156
526183
  init_openai_codex_provider();
526157
526184
  init_settings_manager();
@@ -526376,7 +526403,6 @@ function useConversationLoop(ctx) {
526376
526403
  queuedApprovalResultsRef,
526377
526404
  queueApprovalResults,
526378
526405
  queueSnapshotRef,
526379
- quotaAutoSwapAttemptedRef,
526380
526406
  refreshDerived,
526381
526407
  refreshDerivedThrottled,
526382
526408
  resetTrajectoryBases,
@@ -526404,7 +526430,6 @@ function useConversationLoop(ctx) {
526404
526430
  setRestoredInput,
526405
526431
  setStreaming,
526406
526432
  setConversationSummary,
526407
- setTempModelOverride,
526408
526433
  setThinkingMessage,
526409
526434
  setTrajectoryElapsedBaseMs,
526410
526435
  setTrajectoryTokenBase,
@@ -526579,7 +526604,6 @@ function useConversationLoop(ctx) {
526579
526604
  llmApiErrorRetriesRef.current = 0;
526580
526605
  emptyResponseRetriesRef.current = 0;
526581
526606
  conversationBusyRetriesRef.current = 0;
526582
- quotaAutoSwapAttemptedRef.current = false;
526583
526607
  chatgptPlanSwapsRef.current = 0;
526584
526608
  chatgptExhaustedProvidersRef.current.clear();
526585
526609
  }
@@ -527539,37 +527563,8 @@ ${feedback}
527539
527563
  continue;
527540
527564
  }
527541
527565
  }
527542
- const autoSwapOnQuotaLimitEnabled = settingsManager.getSetting("autoSwapOnQuotaLimit") !== false;
527543
- const supportsHostedAutoQuotaFallback = !getBackend().capabilities.localModelCatalog;
527544
- const isQuotaLimit = isQuotaLimitErrorDetail(detailFromRun ?? fallbackError);
527545
- const alreadyOnTempAuto = tempModelOverrideRef.current === TEMP_QUOTA_OVERRIDE_MODEL;
527546
- const canAttemptQuotaAutoSwap = autoSwapOnQuotaLimitEnabled && supportsHostedAutoQuotaFallback && isQuotaLimit && !alreadyOnTempAuto && !quotaAutoSwapAttemptedRef.current;
527547
- if (canAttemptQuotaAutoSwap) {
527548
- quotaAutoSwapAttemptedRef.current = true;
527549
- setTempModelOverride(TEMP_QUOTA_OVERRIDE_MODEL);
527550
- const statusId = uid("status");
527551
- buffersRef.current.byId.set(statusId, {
527552
- kind: "status",
527553
- id: statusId,
527554
- lines: [
527555
- "Quota limit reached; temporarily switching to Auto and continuing..."
527556
- ]
527557
- });
527558
- buffersRef.current.order.push(statusId);
527559
- refreshDerived();
527560
- currentInput = [
527561
- ...currentInput,
527562
- {
527563
- type: "message",
527564
- role: "user",
527565
- content: "Keep going."
527566
- }
527567
- ];
527568
- buffersRef.current.byId.delete(statusId);
527569
- buffersRef.current.order = buffersRef.current.order.filter((id2) => id2 !== statusId);
527570
- refreshDerived();
527571
- buffersRef.current.interrupted = false;
527572
- continue;
527566
+ if (!getBackend().capabilities.localModelCatalog && isQuotaLimitErrorDetail(detailFromRun ?? fallbackError)) {
527567
+ appendError(KEY_OR_CREDITS_REQUIRED_MESSAGE, true);
527573
527568
  }
527574
527569
  if (isEmptyResponseRetryable(stopReasonToHandle === "llm_api_error" ? "llm_error" : undefined, detailFromRun, emptyResponseRetriesRef.current, EMPTY_RESPONSE_MAX_RETRIES3)) {
527575
527570
  emptyResponseRetriesRef.current += 1;
@@ -530980,7 +530975,7 @@ function readOptionValue(argv, index, optionName) {
530980
530975
  }
530981
530976
  function resolveRequestedModel(requested, currentModelId) {
530982
530977
  if (requested === "current")
530983
- return currentModelId ?? DEFAULT_MODEL;
530978
+ return currentModelId ?? undefined;
530984
530979
  return requested;
530985
530980
  }
530986
530981
  function parseModsCommand(trimmed, currentModelId) {
@@ -531401,7 +531396,11 @@ async function runLearnCommand(learn, ctx, command) {
531401
531396
  const launcher = (ctx.resolveLauncher ?? resolveCurrentLettaLauncher)();
531402
531397
  const headlessEnv = await (ctx.getHeadlessEnv ?? defaultHeadlessEnv)();
531403
531398
  const learningEnv = await resolveEnv(learn, ctx.cwd, readEnvImpl);
531404
- const model = learn.options.model ?? DEFAULT_MODEL;
531399
+ const model = learn.options.model ?? ctx.currentModelId;
531400
+ if (!model) {
531401
+ command.fail("No model selected. Pass --model <handle>, or choose one with /model first.");
531402
+ return;
531403
+ }
531405
531404
  const optimizationIterations = effectiveOptimizationIterations(learn.options);
531406
531405
  let lastProgress = null;
531407
531406
  let pulseFrameIndex = 0;
@@ -531469,7 +531468,7 @@ function handleModsCommand(trimmed, ctx) {
531469
531468
  });
531470
531469
  return { handled: true, done };
531471
531470
  }
531472
- var DEFAULT_TARGET = "memory-citations", DEFAULT_MODEL = "auto", DEFAULT_OPTIMIZATION_ITERATIONS = 5, MOD_OPTIMIZATION_PULSE, MOD_OPTIMIZATION_RUNNING_LABELS, MOD_OPTIMIZATION_SPINNER_INTERVAL_MS, SPARKLINE_BLOCKS, SCORE_BAR_WIDTH = 12, MAX_SCORE_BARS = 5, MAX_STEP_DOTS = 20;
531471
+ var DEFAULT_TARGET = "memory-citations", DEFAULT_OPTIMIZATION_ITERATIONS = 5, MOD_OPTIMIZATION_PULSE, MOD_OPTIMIZATION_RUNNING_LABELS, MOD_OPTIMIZATION_SPINNER_INTERVAL_MS, SPARKLINE_BLOCKS, SCORE_BAR_WIDTH = 12, MAX_SCORE_BARS = 5, MAX_STEP_DOTS = 20;
531473
531472
  var init_mods2 = __esm(async () => {
531474
531473
  init_memory_citations_env();
531475
531474
  init_animations();
@@ -534511,7 +534510,7 @@ Tip: Use /clear instead to clear the current message buffer.`;
534511
534510
  const compactParams = modeArg ? {
534512
534511
  compaction_settings: {
534513
534512
  mode: modeArg,
534514
- model: agentStateRef.current?.compaction_settings?.model?.trim() || DEFAULT_SUMMARIZATION_MODEL
534513
+ model: agentStateRef.current?.compaction_settings?.model?.trim() || agentStateRef.current?.model || undefined
534515
534514
  }
534516
534515
  } : undefined;
534517
534516
  const compactConversationId = conversationIdRef.current;
@@ -536466,7 +536465,6 @@ function App2({
536466
536465
  const abortControllerRef = import_react124.useRef(null);
536467
536466
  const userCancelledRef = import_react124.useRef(false);
536468
536467
  const llmApiErrorRetriesRef = import_react124.useRef(0);
536469
- const quotaAutoSwapAttemptedRef = import_react124.useRef(false);
536470
536468
  const emptyResponseRetriesRef = import_react124.useRef(0);
536471
536469
  const chatgptPlanSwapsRef = import_react124.useRef(0);
536472
536470
  const chatgptExhaustedProvidersRef = import_react124.useRef(new Set);
@@ -537952,7 +537950,6 @@ Memory may be stale. Try running: git -C ${getScopedMemoryFilesystemRoot(agentId
537952
537950
  queuedApprovalResultsRef,
537953
537951
  queueApprovalResults,
537954
537952
  queueSnapshotRef,
537955
- quotaAutoSwapAttemptedRef,
537956
537953
  refreshDerived,
537957
537954
  refreshDerivedThrottled,
537958
537955
  resetTrajectoryBases,
@@ -543241,4 +543238,4 @@ function registerBunOAuthFlows() {
543241
543238
  registerBunOAuthFlows();
543242
543239
  await init_src5().then(() => exports_src2);
543243
543240
 
543244
- //# debugId=1FB31163ED2A450364756E2164756E21
543241
+ //# debugId=C674484D04E610E464756E2164756E21