@letta-ai/letta-code 0.31.1 → 0.31.3

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
@@ -5509,7 +5509,7 @@ var package_default;
5509
5509
  var init_package = __esm(() => {
5510
5510
  package_default = {
5511
5511
  name: "@letta-ai/letta-code",
5512
- version: "0.31.1",
5512
+ version: "0.31.3",
5513
5513
  description: "Letta Code is a CLI tool for interacting with stateful Letta agents from the terminal.",
5514
5514
  type: "module",
5515
5515
  packageManager: "bun@1.3.10",
@@ -84634,21 +84634,24 @@ function stripPowerShellUtf8OutputPrefix(command) {
84634
84634
  const leadingWhitespace = command.slice(0, command.length - trimmed.length);
84635
84635
  return `${leadingWhitespace}${trimmed.slice(POWERSHELL_UTF8_OUTPUT_PREFIX.length)}`;
84636
84636
  }
84637
- function buildPowerShellCommand(command, envAliases = []) {
84637
+ function buildPowerShellCommand(command, envAliases = [], preserveExitCode = false) {
84638
84638
  const powerShellCommand = stripPowerShellUtf8OutputPrefix(normalizePowerShellCommand(command));
84639
84639
  const aliases = [
84640
84640
  ...new Set([...POWERSHELL_ENV_ALIASES, ...envAliases])
84641
84641
  ].filter(isValidEnvAlias);
84642
84642
  const aliasPrelude = aliases.map((name) => `$${name} = $env:${name}`).join("; ");
84643
- return prefixPowerShellCommandWithUtf8Output(`${aliasPrelude}; ${powerShellCommand}`);
84643
+ const encodedCommand = Buffer.from(powerShellCommand, "utf16le").toString("base64");
84644
+ const exitCodePrefix = preserveExitCode ? "$global:LASTEXITCODE = $null; " + `$__lettaHookText = [System.Text.Encoding]::Unicode.GetString([System.Convert]::FromBase64String('${encodedCommand}')); ` + "$__lettaTokens = $null; $__lettaParseErrors = $null; " + "$__lettaHookAst = [System.Management.Automation.Language.Parser]::ParseInput($__lettaHookText, [ref]$__lettaTokens, [ref]$__lettaParseErrors); " + "$__lettaStatements = $__lettaHookAst.EndBlock.Statements; " + "$__lettaFinalStatement = if ($__lettaStatements.Count -gt 0) { $__lettaStatements[$__lettaStatements.Count - 1] } else { $null }; " + "$__lettaFinalPipelineElement = if ($__lettaFinalStatement -is [System.Management.Automation.Language.PipelineAst]) { $__lettaFinalStatement.PipelineElements[$__lettaFinalStatement.PipelineElements.Count - 1] } else { $null }; " + "$__lettaFinalCommandName = if ($__lettaFinalPipelineElement -is [System.Management.Automation.Language.CommandAst]) { $__lettaFinalPipelineElement.GetCommandName() } else { $null }; " : "";
84645
+ const exitCodeSuffix = preserveExitCode ? POWERSHELL_EXIT_CODE_SUFFIX : "";
84646
+ return prefixPowerShellCommandWithUtf8Output(`${aliasPrelude}; ${exitCodePrefix}${powerShellCommand}${exitCodeSuffix}`);
84644
84647
  }
84645
- function windowsLaunchers(command, envAliases = []) {
84648
+ function windowsLaunchers(command, envAliases = [], preserveExitCode = false) {
84646
84649
  const trimmed = command.trim();
84647
84650
  if (!trimmed)
84648
84651
  return [];
84649
84652
  const launchers = [];
84650
84653
  const seen = new Set;
84651
- const powerShellCommand = buildPowerShellCommand(trimmed, envAliases);
84654
+ const powerShellCommand = buildPowerShellCommand(trimmed, envAliases, preserveExitCode);
84652
84655
  pushUnique(launchers, seen, [
84653
84656
  "pwsh",
84654
84657
  "-NoProfile",
@@ -84786,11 +84789,13 @@ function unixLaunchers(command, login) {
84786
84789
  function buildShellLaunchers(command, options) {
84787
84790
  const login = options?.login ?? false;
84788
84791
  const commandToRun = withStrictShellPrelude(command, options?.env);
84789
- return process.platform === "win32" ? windowsLaunchers(commandToRun, options?.powershellEnvAliases) : unixLaunchers(commandToRun, login);
84792
+ return process.platform === "win32" ? windowsLaunchers(commandToRun, options?.powershellEnvAliases, options?.preservePowerShellExitCode) : unixLaunchers(commandToRun, login);
84790
84793
  }
84791
84794
  var SEP = "\x00", STRICT_SHELL_ENV_VAR = "LETTA_BASH_STRICT", STRICT_SHELL_PRELUDE = "set -euo pipefail", POWERSHELL_UTF8_OUTPUT_PREFIX = `try { [Console]::OutputEncoding=[System.Text.Encoding]::UTF8 } catch {}
84792
- `, POWERSHELL_ENV_ALIASES, WINDOWS_PWSH_FALLBACK_PATH = "C:\\Program Files\\PowerShell\\7\\pwsh.exe", WINDOWS_POWERSHELL_FALLBACK_PATH = "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe";
84795
+ `, POWERSHELL_EXIT_CODE_SUFFIX, POWERSHELL_ENV_ALIASES, WINDOWS_PWSH_FALLBACK_PATH = "C:\\Program Files\\PowerShell\\7\\pwsh.exe", WINDOWS_POWERSHELL_FALLBACK_PATH = "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe";
84793
84796
  var init_shell_launchers = __esm(() => {
84797
+ POWERSHELL_EXIT_CODE_SUFFIX = `
84798
+ $__lettaCommandSucceeded = $?; ` + "if ($__lettaCommandSucceeded) { exit 0 }; " + "$__lettaFinalCommand = $null; " + "if ($null -ne $__lettaFinalCommandName) { try { $__lettaFinalCommand = $ExecutionContext.InvokeCommand.GetCommand($__lettaFinalCommandName, [System.Management.Automation.CommandTypes]::All) } catch {} }; " + "while ($__lettaFinalCommand -is [System.Management.Automation.AliasInfo]) { $__lettaFinalCommand = $__lettaFinalCommand.ResolvedCommand }; " + "if (($__lettaFinalCommand.CommandType -eq [System.Management.Automation.CommandTypes]::Application) -and ($null -ne $LASTEXITCODE) -and ($LASTEXITCODE -ne 0)) { exit $LASTEXITCODE }; " + "exit 1";
84794
84799
  POWERSHELL_ENV_ALIASES = [
84795
84800
  "MEMORY_DIR",
84796
84801
  "LETTA_MEMORY_DIR",
@@ -85050,7 +85055,9 @@ async function executeCommandHook(hook, input, workingDirectory = process.cwd())
85050
85055
  const startTime = Date.now();
85051
85056
  const timeout = hook.timeout ?? DEFAULT_TIMEOUT_MS;
85052
85057
  const inputJson = JSON.stringify(input);
85053
- const launchers = buildShellLaunchers(hook.command);
85058
+ const launchers = buildShellLaunchers(hook.command, {
85059
+ preservePowerShellExitCode: true
85060
+ });
85054
85061
  if (launchers.length === 0) {
85055
85062
  return {
85056
85063
  exitCode: 1 /* ERROR */,
@@ -111849,7 +111856,8 @@ var init_skills3 = __esm(() => {
111849
111856
  init_skill_sources();
111850
111857
  LOCAL_AGENT_EXCLUDED_BUNDLED_SKILLS = new Set([
111851
111858
  "image-generation",
111852
- "managing-shared-memory"
111859
+ "managing-shared-memory",
111860
+ "using-cloud-mcp"
111853
111861
  ]);
111854
111862
  PROJECT_SKILLS_DIR = join23(".agents", "skills");
111855
111863
  GLOBAL_SKILLS_DIR = join23(process.env.HOME || process.env.USERPROFILE || "~", ".letta/skills");
@@ -197183,6 +197191,330 @@ var init_channels = __esm(() => {
197183
197191
  };
197184
197192
  });
197185
197193
 
197194
+ // src/backend/api/mcp-servers.ts
197195
+ function getString(record3, key2) {
197196
+ const value = record3[key2];
197197
+ return typeof value === "string" ? value : null;
197198
+ }
197199
+ function parseAgentConnectedMcpServer(value) {
197200
+ if (!isRecord(value)) {
197201
+ return null;
197202
+ }
197203
+ const id2 = getString(value, "id");
197204
+ const serverName = getString(value, "server_name");
197205
+ const serverType = getString(value, "mcp_server_type");
197206
+ if (!id2 || !serverName || !serverType) {
197207
+ return null;
197208
+ }
197209
+ const target2 = getString(value, "server_url") ?? [
197210
+ getString(value, "command"),
197211
+ ...Array.isArray(value.args) ? value.args : []
197212
+ ].filter((item) => typeof item === "string").join(" ");
197213
+ return { id: id2, serverName, serverType, target: target2 };
197214
+ }
197215
+ function parseAgentConnectedMcpTool(value) {
197216
+ if (!isRecord(value)) {
197217
+ return null;
197218
+ }
197219
+ const id2 = getString(value, "id");
197220
+ const name = getString(value, "name");
197221
+ if (!id2 || !name) {
197222
+ return null;
197223
+ }
197224
+ const description = getString(value, "description");
197225
+ return { id: id2, name, description };
197226
+ }
197227
+ function parseAgentMcpToolRunResult(value) {
197228
+ if (!isRecord(value)) {
197229
+ throw new Error("MCP tool run returned an invalid response");
197230
+ }
197231
+ const status = getString(value, "status") ?? "unknown";
197232
+ return {
197233
+ status,
197234
+ funcReturn: value.func_return,
197235
+ stdout: value.stdout,
197236
+ stderr: value.stderr
197237
+ };
197238
+ }
197239
+ function withTimeout(promise, timeoutMs, label) {
197240
+ let timer;
197241
+ const timeout = new Promise((_4, reject2) => {
197242
+ timer = setTimeout(() => reject2(new Error(`${label} timed out after ${timeoutMs}ms`)), timeoutMs);
197243
+ });
197244
+ return Promise.race([promise, timeout]).finally(() => {
197245
+ if (timer !== undefined)
197246
+ clearTimeout(timer);
197247
+ });
197248
+ }
197249
+ function listServerMcpServers(client, timeoutMs = 1e4) {
197250
+ return withTimeout(client.mcpServers.list(), timeoutMs, "Listing server-side MCP servers");
197251
+ }
197252
+ async function listAgentConnectedMcpServers(client, agentId, timeoutMs = 1e4) {
197253
+ const result2 = await withTimeout(client.get(`/v1/agents/${encodeURIComponent(agentId)}/mcp-servers`), timeoutMs, "Listing agent-connected MCP servers");
197254
+ if (!Array.isArray(result2)) {
197255
+ return [];
197256
+ }
197257
+ return result2.map(parseAgentConnectedMcpServer).filter((server2) => server2 !== null);
197258
+ }
197259
+ async function listAgentConnectedMcpTools(client, agentId, mcpServerId, timeoutMs = 1e4) {
197260
+ const result2 = await withTimeout(client.get(`/v1/agents/${encodeURIComponent(agentId)}/mcp-servers/${encodeURIComponent(mcpServerId)}/tools`), timeoutMs, "Listing agent-connected MCP server tools");
197261
+ if (!Array.isArray(result2)) {
197262
+ return [];
197263
+ }
197264
+ return result2.map(parseAgentConnectedMcpTool).filter((tool) => tool !== null);
197265
+ }
197266
+ async function runAgentConnectedMcpTool(params) {
197267
+ const result2 = await withTimeout(params.client.post(`/v1/agents/${encodeURIComponent(params.agentId)}/mcp-servers/${encodeURIComponent(params.mcpServerId)}/tools/${encodeURIComponent(params.toolId)}/run`, { args: params.args }), params.timeoutMs ?? 60000, "Running agent-connected MCP tool");
197268
+ return parseAgentMcpToolRunResult(result2);
197269
+ }
197270
+ async function listLiveServerMcpTools(client, serverName, timeoutMs = 15000) {
197271
+ const result2 = await withTimeout(client.get(`/v1/tools/mcp/servers/${encodeURIComponent(serverName)}/tools`), timeoutMs, `Listing tools for MCP server "${serverName}"`);
197272
+ if (!Array.isArray(result2))
197273
+ return [];
197274
+ return result2.filter((tool) => typeof tool === "object" && tool !== null && typeof tool.name === "string");
197275
+ }
197276
+ async function loadServerMcpEntries(client, timeoutMs = 15000) {
197277
+ const servers = await listServerMcpServers(client, timeoutMs);
197278
+ return Promise.all(servers.map(async (server2) => {
197279
+ try {
197280
+ const tools = await listLiveServerMcpTools(client, server2.server_name, timeoutMs);
197281
+ return { server: server2, tools };
197282
+ } catch (cause) {
197283
+ return {
197284
+ server: server2,
197285
+ tools: [],
197286
+ toolsError: cause instanceof Error ? cause.message : String(cause)
197287
+ };
197288
+ }
197289
+ }));
197290
+ }
197291
+ function parseMcpMetadata(tool) {
197292
+ const metadata = tool.metadata_;
197293
+ const mcp = metadata?.mcp;
197294
+ if (typeof mcp !== "object" || mcp === null)
197295
+ return null;
197296
+ const { server_id, server_name } = mcp;
197297
+ return {
197298
+ ...typeof server_id === "string" && { serverId: server_id },
197299
+ ...typeof server_name === "string" && { serverName: server_name }
197300
+ };
197301
+ }
197302
+ async function listAgentMcpAttachments(client, agentId) {
197303
+ const attachments = [];
197304
+ for await (const tool of client.agents.tools.list(agentId, { limit: 100 })) {
197305
+ if (tool.tool_type !== "external_mcp" || !tool.id || !tool.name)
197306
+ continue;
197307
+ attachments.push({
197308
+ toolId: tool.id,
197309
+ toolName: tool.name,
197310
+ ...parseMcpMetadata(tool)
197311
+ });
197312
+ }
197313
+ return attachments;
197314
+ }
197315
+ function attachmentsForEntry(entry, attachments) {
197316
+ return attachments.filter((attachment) => attachment.serverId && entry.server.id ? attachment.serverId === entry.server.id : attachment.serverName === entry.server.server_name);
197317
+ }
197318
+ function attachedToolNamesForEntry(entry, attachments) {
197319
+ return new Set(attachmentsForEntry(entry, attachments).map((attachment) => attachment.toolName));
197320
+ }
197321
+ async function registerServerMcpTool(client, serverName, toolName) {
197322
+ const result2 = await client.post(`/v1/tools/mcp/servers/${encodeURIComponent(serverName)}/${encodeURIComponent(toolName)}`);
197323
+ if (typeof result2?.id !== "string") {
197324
+ throw new Error(`Registering MCP tool "${toolName}" on server "${serverName}" returned no tool id`);
197325
+ }
197326
+ return { id: result2.id };
197327
+ }
197328
+ async function attachServerMcpTools(client, agentId, serverName, toolNames) {
197329
+ await Promise.all(toolNames.map(async (toolName) => {
197330
+ const { id: id2 } = await registerServerMcpTool(client, serverName, toolName);
197331
+ await client.agents.tools.attach(id2, { agent_id: agentId });
197332
+ }));
197333
+ }
197334
+ async function detachServerMcpTools(client, agentId, toolIds) {
197335
+ await Promise.all(toolIds.map((toolId) => client.agents.tools.detach(toolId, { agent_id: agentId })));
197336
+ }
197337
+ function refreshServerMcpServer(client, mcpServerId, agentId) {
197338
+ return client.mcpServers.refresh(mcpServerId, { agent_id: agentId });
197339
+ }
197340
+ function planServerMcpToggle(entry, attachments) {
197341
+ const attached = attachmentsForEntry(entry, attachments);
197342
+ if (attached.length > 0) {
197343
+ return {
197344
+ action: "detach",
197345
+ toolIds: attached.map((attachment) => attachment.toolId)
197346
+ };
197347
+ }
197348
+ return { action: "attach", toolNames: entry.tools.map((tool) => tool.name) };
197349
+ }
197350
+ function describeServerMcpTarget(server2) {
197351
+ if ("server_url" in server2 && server2.server_url) {
197352
+ return server2.server_url;
197353
+ }
197354
+ if ("command" in server2 && server2.command) {
197355
+ return [server2.command, ...server2.args ?? []].join(" ");
197356
+ }
197357
+ return "";
197358
+ }
197359
+ var init_mcp_servers2 = () => {};
197360
+
197361
+ // src/cli/subcommands/cloud-mcp.ts
197362
+ import { parseArgs as parseArgs4 } from "node:util";
197363
+ function printUsage4(stdout = console.log) {
197364
+ stdout(`
197365
+ Usage:
197366
+ letta cloud-mcp list [--agent <id>]
197367
+ letta cloud-mcp tools <mcp-server-id> [--agent <id>]
197368
+ letta cloud-mcp run <mcp-server-id> <tool-id> [--args '<json>'] [--agent <id>]
197369
+
197370
+ Actions:
197371
+ list List MCP servers connected to the agent
197372
+ tools List registered tools for one connected MCP server
197373
+ run Run one registered MCP tool through the agent-scoped server route
197374
+
197375
+ Aliases:
197376
+ list-servers, list_servers Alias for list
197377
+ list-tools, list_tools Alias for tools
197378
+ call, run-tool, run_tool Alias for run
197379
+
197380
+ Options:
197381
+ --agent <id> Agent ID. Defaults to LETTA_AGENT_ID or AGENT_ID
197382
+ --agent-id <id> Alias for --agent
197383
+ --args '<json>' JSON object passed as MCP tool arguments for run
197384
+ -h, --help Show this help
197385
+
197386
+ Notes:
197387
+ - Output is JSON only.
197388
+ - Requires a signed-in Letta Cloud agent with server-side MCP support.
197389
+ - Uses CLI auth; override with LETTA_API_KEY/LETTA_BASE_URL if needed.
197390
+ `.trim());
197391
+ }
197392
+ function parseCloudMcpArgs(argv) {
197393
+ return parseArgs4({
197394
+ args: argv,
197395
+ options: {
197396
+ help: { type: "boolean", short: "h" },
197397
+ agent: { type: "string" },
197398
+ "agent-id": { type: "string" },
197399
+ args: { type: "string" }
197400
+ },
197401
+ strict: true,
197402
+ allowPositionals: true
197403
+ });
197404
+ }
197405
+ function stringValue3(value) {
197406
+ return typeof value === "string" ? value : undefined;
197407
+ }
197408
+ function resolveCloudMcpAgentId(agent, agentId, env4 = process.env) {
197409
+ return (agent || agentId || env4.LETTA_AGENT_ID || env4.AGENT_ID || "").trim();
197410
+ }
197411
+ function parseToolArgs(value) {
197412
+ const raw2 = stringValue3(value);
197413
+ if (!raw2) {
197414
+ return {};
197415
+ }
197416
+ let parsed;
197417
+ try {
197418
+ parsed = JSON.parse(raw2);
197419
+ } catch (error4) {
197420
+ const message = error4 instanceof Error ? error4.message : String(error4);
197421
+ throw new Error(`Invalid --args JSON: ${message}`);
197422
+ }
197423
+ if (!isRecord(parsed)) {
197424
+ throw new Error("Invalid --args JSON: expected a JSON object");
197425
+ }
197426
+ return parsed;
197427
+ }
197428
+ function printJson(stdout, result2) {
197429
+ stdout(JSON.stringify(result2, null, 2));
197430
+ }
197431
+ async function defaultGetClient() {
197432
+ const client = await getClient();
197433
+ return client;
197434
+ }
197435
+ async function runCloudMcpSubcommand(argv, deps = {}) {
197436
+ const stdout = deps.stdout ?? console.log;
197437
+ const stderr = deps.stderr ?? console.error;
197438
+ let parsed;
197439
+ try {
197440
+ parsed = parseCloudMcpArgs(argv);
197441
+ } catch (error4) {
197442
+ const message = error4 instanceof Error ? error4.message : String(error4);
197443
+ stderr(`Error: ${message}`);
197444
+ printUsage4(stdout);
197445
+ return 1;
197446
+ }
197447
+ const [action3, mcpServerId, toolId] = parsed.positionals;
197448
+ if (parsed.values.help || !action3 || action3 === "help") {
197449
+ printUsage4(stdout);
197450
+ return 0;
197451
+ }
197452
+ const isAvailable = deps.isServerSideMcpAvailable ?? (() => getBackend().capabilities.serverSideToolManagement);
197453
+ if (!isAvailable()) {
197454
+ stderr("Server-side MCP requires a signed-in Letta Cloud agent; the local backend does not support it.");
197455
+ return 1;
197456
+ }
197457
+ const agentId = resolveCloudMcpAgentId(stringValue3(parsed.values.agent), stringValue3(parsed.values["agent-id"]));
197458
+ if (!agentId) {
197459
+ stderr("Agent id required: pass --agent <id> or set LETTA_AGENT_ID/AGENT_ID.");
197460
+ return 1;
197461
+ }
197462
+ await (deps.initializeSettings ?? (() => settingsManager.initialize()))();
197463
+ const client = await (deps.getClient ?? defaultGetClient)();
197464
+ try {
197465
+ if (action3 === "list" || action3 === "list-servers" || action3 === "list_servers") {
197466
+ printJson(stdout, {
197467
+ agent_id: agentId,
197468
+ servers: await listAgentConnectedMcpServers(client, agentId)
197469
+ });
197470
+ return 0;
197471
+ }
197472
+ if (action3 === "tools" || action3 === "list-tools" || action3 === "list_tools") {
197473
+ if (!mcpServerId) {
197474
+ stderr("Usage: letta cloud-mcp tools <mcp-server-id> [--agent <id>]");
197475
+ return 1;
197476
+ }
197477
+ printJson(stdout, {
197478
+ agent_id: agentId,
197479
+ mcp_server_id: mcpServerId,
197480
+ tools: await listAgentConnectedMcpTools(client, agentId, mcpServerId)
197481
+ });
197482
+ return 0;
197483
+ }
197484
+ if (action3 === "run" || action3 === "call" || action3 === "run-tool" || action3 === "run_tool") {
197485
+ if (!mcpServerId || !toolId) {
197486
+ stderr("Usage: letta cloud-mcp run <mcp-server-id> <tool-id> [--args '<json>'] [--agent <id>]");
197487
+ return 1;
197488
+ }
197489
+ printJson(stdout, {
197490
+ agent_id: agentId,
197491
+ mcp_server_id: mcpServerId,
197492
+ tool_id: toolId,
197493
+ result: await runAgentConnectedMcpTool({
197494
+ client,
197495
+ agentId,
197496
+ mcpServerId,
197497
+ toolId,
197498
+ args: parseToolArgs(parsed.values.args)
197499
+ })
197500
+ });
197501
+ return 0;
197502
+ }
197503
+ stderr(`Unknown cloud-mcp action: ${action3}`);
197504
+ printUsage4(stdout);
197505
+ return 1;
197506
+ } catch (error4) {
197507
+ stderr(error4 instanceof Error ? error4.message : String(error4));
197508
+ return 1;
197509
+ }
197510
+ }
197511
+ var init_cloud_mcp = __esm(() => {
197512
+ init_backend2();
197513
+ init_client2();
197514
+ init_mcp_servers2();
197515
+ init_settings_manager();
197516
+ });
197517
+
197186
197518
  // src/auth/openai-oauth.ts
197187
197519
  import http3 from "node:http";
197188
197520
  function renderOAuthPage(options) {
@@ -198306,7 +198638,7 @@ var init_connect_normalize = __esm(() => {
198306
198638
  // src/cli/subcommands/connect.ts
198307
198639
  import { createInterface as createInterface6 } from "node:readline/promises";
198308
198640
  import { Writable } from "node:stream";
198309
- import { parseArgs as parseArgs4 } from "node:util";
198641
+ import { parseArgs as parseArgs5 } from "node:util";
198310
198642
  function readStringOption(value) {
198311
198643
  if (typeof value === "string") {
198312
198644
  return value;
@@ -198398,7 +198730,7 @@ async function runConnectSubcommand(argv, deps = {}) {
198398
198730
  const io = { ...DEFAULT_DEPS2, ...deps };
198399
198731
  let parsed;
198400
198732
  try {
198401
- parsed = parseArgs4({
198733
+ parsed = parseArgs5({
198402
198734
  args: argv,
198403
198735
  options: CONNECT_OPTIONS,
198404
198736
  strict: true,
@@ -207608,8 +207940,8 @@ var init_cron_task_ref = __esm(async () => {
207608
207940
  });
207609
207941
 
207610
207942
  // src/cli/subcommands/cron.ts
207611
- import { parseArgs as parseArgs5 } from "node:util";
207612
- function printUsage4() {
207943
+ import { parseArgs as parseArgs6 } from "node:util";
207944
+ function printUsage5() {
207613
207945
  console.log(`
207614
207946
  Usage:
207615
207947
  letta cron add --prompt <text> --every <interval> [options]
@@ -207663,7 +207995,7 @@ Output is JSON.
207663
207995
  `.trim());
207664
207996
  }
207665
207997
  function parseCronArgs(argv) {
207666
- return parseArgs5({
207998
+ return parseArgs6({
207667
207999
  args: argv,
207668
208000
  options: CRON_OPTIONS,
207669
208001
  strict: true,
@@ -208219,12 +208551,12 @@ async function runCronSubcommand(argv) {
208219
208551
  parsed = parseCronArgs(argv);
208220
208552
  } catch (err) {
208221
208553
  console.error(`Error: ${err instanceof Error ? err.message : String(err)}`);
208222
- printUsage4();
208554
+ printUsage5();
208223
208555
  return 1;
208224
208556
  }
208225
208557
  const [action3] = parsed.positionals;
208226
208558
  if (parsed.values.help || !action3 || action3 === "help") {
208227
- printUsage4();
208559
+ printUsage5();
208228
208560
  return 0;
208229
208561
  }
208230
208562
  switch (action3) {
@@ -208241,7 +208573,7 @@ async function runCronSubcommand(argv) {
208241
208573
  return handleDelete(parsed.values, parsed.positionals);
208242
208574
  default:
208243
208575
  console.error(`Unknown action: ${action3}`);
208244
- printUsage4();
208576
+ printUsage5();
208245
208577
  return 1;
208246
208578
  }
208247
208579
  }
@@ -213820,8 +214152,8 @@ var init_reflection_launcher = __esm(() => {
213820
214152
  });
213821
214153
 
213822
214154
  // src/cli/subcommands/dream.ts
213823
- import { parseArgs as parseArgs6 } from "node:util";
213824
- function printUsage5() {
214155
+ import { parseArgs as parseArgs7 } from "node:util";
214156
+ function printUsage6() {
213825
214157
  console.log(`
213826
214158
  Usage:
213827
214159
  letta dream [options]
@@ -213858,7 +214190,7 @@ Notes:
213858
214190
  `.trim());
213859
214191
  }
213860
214192
  function parseDreamArgs(argv) {
213861
- return parseArgs6({
214193
+ return parseArgs7({
213862
214194
  args: argv,
213863
214195
  options: DREAM_OPTIONS,
213864
214196
  strict: true,
@@ -213875,17 +214207,17 @@ async function runDreamSubcommand(argv) {
213875
214207
  } catch (error4) {
213876
214208
  const message = error4 instanceof Error ? error4.message : String(error4);
213877
214209
  console.error(`Error: ${message}`);
213878
- printUsage5();
214210
+ printUsage6();
213879
214211
  return 1;
213880
214212
  }
213881
214213
  const [action3] = parsed.positionals;
213882
214214
  if (parsed.values.help || action3 === "help") {
213883
- printUsage5();
214215
+ printUsage6();
213884
214216
  return 0;
213885
214217
  }
213886
214218
  if (action3) {
213887
214219
  console.error(`Unknown argument: ${action3}`);
213888
- printUsage5();
214220
+ printUsage6();
213889
214221
  return 1;
213890
214222
  }
213891
214223
  const asJson = Boolean(parsed.values.json);
@@ -214111,8 +214443,8 @@ var init_dream = __esm(() => {
214111
214443
  });
214112
214444
 
214113
214445
  // src/cli/subcommands/environments.ts
214114
- import { parseArgs as parseArgs7 } from "node:util";
214115
- function printUsage6() {
214446
+ import { parseArgs as parseArgs8 } from "node:util";
214447
+ function printUsage7() {
214116
214448
  console.log(`
214117
214449
  Usage:
214118
214450
  letta environments list [options]
@@ -214180,7 +214512,7 @@ function scoreCurrentEnvironment(environment2, options) {
214180
214512
  return score;
214181
214513
  }
214182
214514
  function parseEnvironmentsArgs(argv) {
214183
- return parseArgs7({
214515
+ return parseArgs8({
214184
214516
  args: argv,
214185
214517
  options: ENVIRONMENTS_OPTIONS,
214186
214518
  strict: true,
@@ -214194,17 +214526,17 @@ async function runEnvironmentsSubcommand(argv, deps = {}) {
214194
214526
  } catch (error4) {
214195
214527
  const message = error4 instanceof Error ? error4.message : String(error4);
214196
214528
  console.error(`Error: ${message}`);
214197
- printUsage6();
214529
+ printUsage7();
214198
214530
  return 1;
214199
214531
  }
214200
214532
  const [action3] = parsed.positionals;
214201
214533
  if (parsed.values.help || !action3 || action3 === "help") {
214202
- printUsage6();
214534
+ printUsage7();
214203
214535
  return 0;
214204
214536
  }
214205
214537
  if (action3 !== "list" && action3 !== "current") {
214206
214538
  console.error(`Unknown action: ${action3}`);
214207
- printUsage6();
214539
+ printUsage7();
214208
214540
  return 1;
214209
214541
  }
214210
214542
  await (deps.initializeSettings ?? (() => settingsManager.initialize()))();
@@ -241956,9 +242288,9 @@ ${lanes.join(`
241956
242288
  function isJsonEqual(a2, b3) {
241957
242289
  return a2 === b3 || typeof a2 === "object" && a2 !== null && typeof b3 === "object" && b3 !== null && equalOwnProperties(a2, b3, isJsonEqual);
241958
242290
  }
241959
- function parsePseudoBigInt(stringValue3) {
242291
+ function parsePseudoBigInt(stringValue4) {
241960
242292
  let log2Base;
241961
- switch (stringValue3.charCodeAt(1)) {
242293
+ switch (stringValue4.charCodeAt(1)) {
241962
242294
  case 98:
241963
242295
  case 66:
241964
242296
  log2Base = 1;
@@ -241972,19 +242304,19 @@ ${lanes.join(`
241972
242304
  log2Base = 4;
241973
242305
  break;
241974
242306
  default:
241975
- const nIndex = stringValue3.length - 1;
242307
+ const nIndex = stringValue4.length - 1;
241976
242308
  let nonZeroStart = 0;
241977
- while (stringValue3.charCodeAt(nonZeroStart) === 48) {
242309
+ while (stringValue4.charCodeAt(nonZeroStart) === 48) {
241978
242310
  nonZeroStart++;
241979
242311
  }
241980
- return stringValue3.slice(nonZeroStart, nIndex) || "0";
242312
+ return stringValue4.slice(nonZeroStart, nIndex) || "0";
241981
242313
  }
241982
- const startIndex = 2, endIndex = stringValue3.length - 1;
242314
+ const startIndex = 2, endIndex = stringValue4.length - 1;
241983
242315
  const bitsNeeded = (endIndex - startIndex) * log2Base;
241984
242316
  const segments = new Uint16Array((bitsNeeded >>> 4) + (bitsNeeded & 15 ? 1 : 0));
241985
242317
  for (let i4 = endIndex - 1, bitOffset = 0;i4 >= startIndex; i4--, bitOffset += log2Base) {
241986
242318
  const segment = bitOffset >>> 4;
241987
- const digitChar = stringValue3.charCodeAt(i4);
242319
+ const digitChar = stringValue4.charCodeAt(i4);
241988
242320
  const digit = digitChar <= 57 ? digitChar - 48 : 10 + digitChar - (digitChar <= 70 ? 65 : 97);
241989
242321
  const shiftedDigit = digit << (bitOffset & 15);
241990
242322
  segments[segment] |= shiftedDigit;
@@ -395047,7 +395379,7 @@ function toRunsArray(listResponse) {
395047
395379
  }
395048
395380
  return [];
395049
395381
  }
395050
- function withTimeout(promise, timeoutMs, timeoutMessage) {
395382
+ function withTimeout2(promise, timeoutMs, timeoutMessage) {
395051
395383
  return new Promise((resolve35, reject2) => {
395052
395384
  const timer = setTimeout(() => reject2(new Error(timeoutMessage)), timeoutMs);
395053
395385
  promise.then((value) => {
@@ -395061,7 +395393,7 @@ function withTimeout(promise, timeoutMs, timeoutMessage) {
395061
395393
  }
395062
395394
  async function discoverFallbackRunIdWithTimeout(ctx) {
395063
395395
  const client = await getClient();
395064
- return withTimeout(discoverFallbackRunIdForResume(client, ctx), FALLBACK_RUN_DISCOVERY_TIMEOUT_MS, `Fallback run discovery timed out after ${FALLBACK_RUN_DISCOVERY_TIMEOUT_MS}ms`);
395396
+ return withTimeout2(discoverFallbackRunIdForResume(client, ctx), FALLBACK_RUN_DISCOVERY_TIMEOUT_MS, `Fallback run discovery timed out after ${FALLBACK_RUN_DISCOVERY_TIMEOUT_MS}ms`);
395065
395397
  }
395066
395398
  async function discoverFallbackRunIdForResume(client, ctx) {
395067
395399
  const statuses = ["running"];
@@ -395789,7 +396121,7 @@ function formatMissingRequiredArgsReason(toolName, parsedArgs, missingRequiredAr
395789
396121
  }
395790
396122
  return base2;
395791
396123
  }
395792
- function parseToolArgs(rawArgs) {
396124
+ function parseToolArgs2(rawArgs) {
395793
396125
  const raw2 = rawArgs ?? "";
395794
396126
  const trimmed = raw2.trim();
395795
396127
  if (!trimmed) {
@@ -395834,7 +396166,7 @@ async function classifyApprovals(approvals, opts = {}) {
395834
396166
  });
395835
396167
  continue;
395836
396168
  }
395837
- const argsParse = parseToolArgs(approval.toolArgs);
396169
+ const argsParse = parseToolArgs2(approval.toolArgs);
395838
396170
  const parsedArgs = argsParse.parsedArgs;
395839
396171
  if (argsParse.parseFailed) {
395840
396172
  debugWarn("approval-classification", `Tool call ${approval.toolCallId} (${toolName}) had unparseable arguments ` + `(${argsParse.rawLength} chars); treating as empty`);
@@ -405796,7 +406128,7 @@ function getNumber(record3, keys3) {
405796
406128
  }
405797
406129
  return null;
405798
406130
  }
405799
- function getString(record3, keys3) {
406131
+ function getString2(record3, keys3) {
405800
406132
  const value = getValue(record3, keys3);
405801
406133
  if (typeof value === "string" && value.trim())
405802
406134
  return value.trim();
@@ -405882,7 +406214,7 @@ function normalizeCredits(raw2, rateLimit) {
405882
406214
  const resetCredits = getRecord(raw2, ["rate_limit_reset_credits", "rateLimitResetCredits"]) ?? getRecord(rateLimit, ["rate_limit_reset_credits", "rateLimitResetCredits"]);
405883
406215
  if (!credits && !resetCredits)
405884
406216
  return null;
405885
- const balance = getString(credits, ["balance", "credit_balance", "amount"]);
406217
+ const balance = getString2(credits, ["balance", "credit_balance", "amount"]);
405886
406218
  const availableCount = getNumber(credits, ["available_count", "availableCount", "count"]) ?? getNumber(resetCredits, ["available_count", "availableCount", "count"]);
405887
406219
  const hasCredits = getBoolean(credits, ["has_credits", "hasCredits"]);
405888
406220
  const unlimited = getBoolean(credits, ["unlimited", "is_unlimited"]);
@@ -405901,8 +406233,8 @@ function normalizeIndividualLimit(raw2, nowMs) {
405901
406233
  const record3 = getRecord(raw2, ["individual_limit", "individualLimit"]) ?? getRecord(spendControl, ["individual_limit", "individualLimit"]);
405902
406234
  if (!record3)
405903
406235
  return null;
405904
- const limit3 = getString(record3, ["limit"]);
405905
- const used = getString(record3, ["used"]);
406236
+ const limit3 = getString2(record3, ["limit"]);
406237
+ const used = getString2(record3, ["used"]);
405906
406238
  const remainingPercent = getNumber(record3, [
405907
406239
  "remaining_percent",
405908
406240
  "remainingPercent"
@@ -405931,10 +406263,10 @@ function normalizeCloudUsageWindow(value, fallbackLabel, nowMs) {
405931
406263
  const record3 = asRecord8(value);
405932
406264
  if (!record3)
405933
406265
  return null;
405934
- return normalizeUsageWindow(record3, getString(record3, ["label", "name"]) ?? fallbackLabel, nowMs);
406266
+ return normalizeUsageWindow(record3, getString2(record3, ["label", "name"]) ?? fallbackLabel, nowMs);
405935
406267
  }
405936
406268
  function normalizeAdditionalRateLimit(details, index, nowMs) {
405937
- const label = getString(details, [
406269
+ const label = getString2(details, [
405938
406270
  "limit_name",
405939
406271
  "limitName",
405940
406272
  "metered_feature",
@@ -405960,7 +406292,7 @@ function getRateLimitReachedType(raw2) {
405960
406292
  if (typeof value === "string" && value.trim())
405961
406293
  return value.trim();
405962
406294
  const record3 = asRecord8(value);
405963
- return getString(record3, ["type", "kind"]);
406295
+ return getString2(record3, ["type", "kind"]);
405964
406296
  }
405965
406297
  function formatPercent(value) {
405966
406298
  const rounded = Math.round(value);
@@ -406075,7 +406407,7 @@ function normalizeWhamUsageResponse(input) {
406075
406407
  const snapshotWithoutSummary = {
406076
406408
  providerName: input.providerName,
406077
406409
  fetchedAt,
406078
- planType: getString(raw2, ["plan_type", "planType"]),
406410
+ planType: getString2(raw2, ["plan_type", "planType"]),
406079
406411
  limitReached: getBoolean(rateLimit, ["limit_reached", "limitReached"]) ?? getBoolean(spendControl, ["reached"]),
406080
406412
  rateLimitReachedType: getRateLimitReachedType(raw2),
406081
406413
  primary,
@@ -406094,18 +406426,18 @@ function normalizeCloudChatGPTUsageResponse(input) {
406094
406426
  if (!raw2)
406095
406427
  return null;
406096
406428
  const nowMs = input.nowMs ?? Date.now();
406097
- const fetchedAt = getString(raw2, ["fetchedAt", "fetched_at"]) ?? new Date(nowMs).toISOString();
406429
+ const fetchedAt = getString2(raw2, ["fetchedAt", "fetched_at"]) ?? new Date(nowMs).toISOString();
406098
406430
  const additional = getRecordArray(raw2, [
406099
406431
  "additional",
406100
406432
  "additional_rate_limits",
406101
406433
  "additionalRateLimits"
406102
406434
  ]).map((window2, index) => normalizeCloudUsageWindow(window2, `limit ${index + 1}`, nowMs)).filter((window2) => !!window2);
406103
406435
  const snapshotWithoutSummary = {
406104
- providerName: getString(raw2, ["providerName", "provider_name"]) ?? input.providerName,
406436
+ providerName: getString2(raw2, ["providerName", "provider_name"]) ?? input.providerName,
406105
406437
  fetchedAt,
406106
- planType: getString(raw2, ["planType", "plan_type"]),
406438
+ planType: getString2(raw2, ["planType", "plan_type"]),
406107
406439
  limitReached: getBoolean(raw2, ["limitReached", "limit_reached"]),
406108
- rateLimitReachedType: getString(raw2, [
406440
+ rateLimitReachedType: getString2(raw2, [
406109
406441
  "rateLimitReachedType",
406110
406442
  "rate_limit_reached_type"
406111
406443
  ]),
@@ -406117,7 +406449,7 @@ function normalizeCloudChatGPTUsageResponse(input) {
406117
406449
  };
406118
406450
  return {
406119
406451
  ...snapshotWithoutSummary,
406120
- summary: getString(raw2, ["summary"]) ?? formatChatGPTUsageSnapshot(snapshotWithoutSummary, new Date(nowMs))
406452
+ summary: getString2(raw2, ["summary"]) ?? formatChatGPTUsageSnapshot(snapshotWithoutSummary, new Date(nowMs))
406121
406453
  };
406122
406454
  }
406123
406455
  function retryAfterMs(response) {
@@ -406142,7 +406474,7 @@ async function readJsonRecord(response) {
406142
406474
  }
406143
406475
  }
406144
406476
  function responseMessage(raw2, fallback) {
406145
- return getString(raw2 ?? undefined, ["message", "error", "detail"]) ?? fallback;
406477
+ return getString2(raw2 ?? undefined, ["message", "error", "detail"]) ?? fallback;
406146
406478
  }
406147
406479
  function chatGPTUsageError(code2, message, retryAfter) {
406148
406480
  return {
@@ -409901,7 +410233,7 @@ var init_app_server_openai_common = __esm(() => {
409901
410233
  function asRecord9(value) {
409902
410234
  return value !== null && typeof value === "object" ? value : null;
409903
410235
  }
409904
- function stringValue3(value) {
410236
+ function stringValue4(value) {
409905
410237
  return typeof value === "string" ? value : undefined;
409906
410238
  }
409907
410239
  function extractToolCallFragments(record3) {
@@ -409915,12 +410247,12 @@ function extractToolCallFragments(record3) {
409915
410247
  if (!toolCall) {
409916
410248
  continue;
409917
410249
  }
409918
- const toolCallId = stringValue3(toolCall.tool_call_id);
410250
+ const toolCallId = stringValue4(toolCall.tool_call_id);
409919
410251
  if (!toolCallId) {
409920
410252
  continue;
409921
410253
  }
409922
- const name = stringValue3(toolCall.name) ?? null;
409923
- const argumentsDelta = stringValue3(toolCall.arguments) ?? null;
410254
+ const name = stringValue4(toolCall.name) ?? null;
410255
+ const argumentsDelta = stringValue4(toolCall.arguments) ?? null;
409924
410256
  fragments.push({ toolCallId, name, argumentsDelta });
409925
410257
  }
409926
410258
  return fragments;
@@ -409960,7 +410292,7 @@ function extractToolReturns(record3) {
409960
410292
  if (!rec) {
409961
410293
  continue;
409962
410294
  }
409963
- const toolCallId = stringValue3(rec.tool_call_id);
410295
+ const toolCallId = stringValue4(rec.tool_call_id);
409964
410296
  const status = asToolReturnStatus2(rec.status);
409965
410297
  if (!toolCallId || !status) {
409966
410298
  continue;
@@ -409975,7 +410307,7 @@ function extractToolReturns(record3) {
409975
410307
  return results;
409976
410308
  }
409977
410309
  }
409978
- const topLevelToolCallId = stringValue3(record3.tool_call_id);
410310
+ const topLevelToolCallId = stringValue4(record3.tool_call_id);
409979
410311
  const topLevelStatus = asToolReturnStatus2(record3.status);
409980
410312
  if (!topLevelToolCallId || !topLevelStatus) {
409981
410313
  return [];
@@ -410063,13 +410395,13 @@ function createToolLifecycleTracker(onEvent) {
410063
410395
  return;
410064
410396
  }
410065
410397
  const record3 = delta2;
410066
- const messageType = stringValue3(record3.message_type);
410067
- const toolCallId = stringValue3(record3.tool_call_id);
410398
+ const messageType = stringValue4(record3.message_type);
410399
+ const toolCallId = stringValue4(record3.tool_call_id);
410068
410400
  if (messageType === "client_tool_start" && toolCallId) {
410069
410401
  const state = getOrCreate(toolCallId);
410070
410402
  state.clientManaged = true;
410071
410403
  if (!state.name)
410072
- state.name = stringValue3(record3.tool_name) ?? null;
410404
+ state.name = stringValue4(record3.tool_name) ?? null;
410073
410405
  return;
410074
410406
  }
410075
410407
  if (messageType === "client_tool_end" && toolCallId) {
@@ -411656,7 +411988,7 @@ var init_gateway_supervisor = __esm(() => {
411656
411988
 
411657
411989
  // src/cli/subcommands/listen.tsx
411658
411990
  import { hostname as hostname4 } from "node:os";
411659
- import { parseArgs as parseArgs8 } from "node:util";
411991
+ import { parseArgs as parseArgs9 } from "node:util";
411660
411992
  import { MessageChannel as MessageChannel2 } from "node:worker_threads";
411661
411993
  function PromptEnvName(props) {
411662
411994
  const [value, setValue] = import_react33.useState("");
@@ -411769,7 +412101,7 @@ function printListenUsage() {
411769
412101
  async function runListenSubcommand(argv) {
411770
412102
  let values3;
411771
412103
  try {
411772
- ({ values: values3 } = parseArgs8({
412104
+ ({ values: values3 } = parseArgs9({
411773
412105
  args: argv,
411774
412106
  options: LISTEN_OPTIONS,
411775
412107
  strict: true,
@@ -412677,15 +413009,15 @@ var init_transcript_migration = __esm(() => {
412677
413009
  });
412678
413010
 
412679
413011
  // src/cli/subcommands/local-backend.ts
412680
- import { parseArgs as parseArgs9 } from "node:util";
413012
+ import { parseArgs as parseArgs10 } from "node:util";
412681
413013
  function parseLocalBackendArgs(argv) {
412682
- return parseArgs9({
413014
+ return parseArgs10({
412683
413015
  args: argv,
412684
413016
  options: LOCAL_BACKEND_OPTIONS,
412685
413017
  strict: true
412686
413018
  });
412687
413019
  }
412688
- function printUsage7() {
413020
+ function printUsage8() {
412689
413021
  console.log(`
412690
413022
  Usage:
412691
413023
  letta local-backend migrate-transcripts [--storage-dir <path>] [--dry-run]
@@ -412698,12 +413030,12 @@ before it is replaced.
412698
413030
  async function runLocalBackendSubcommand(argv) {
412699
413031
  const [command, ...rest4] = argv;
412700
413032
  if (!command || command === "help" || command === "--help" || command === "-h") {
412701
- printUsage7();
413033
+ printUsage8();
412702
413034
  return command ? 0 : 1;
412703
413035
  }
412704
413036
  if (command !== "migrate-transcripts") {
412705
413037
  console.error(`Unknown local-backend command: ${command}`);
412706
- printUsage7();
413038
+ printUsage8();
412707
413039
  return 1;
412708
413040
  }
412709
413041
  let parsed;
@@ -412712,11 +413044,11 @@ async function runLocalBackendSubcommand(argv) {
412712
413044
  } catch (error4) {
412713
413045
  const message = error4 instanceof Error ? error4.message : String(error4);
412714
413046
  console.error(`Error: ${message}`);
412715
- printUsage7();
413047
+ printUsage8();
412716
413048
  return 1;
412717
413049
  }
412718
413050
  if (parsed.values.help) {
412719
- printUsage7();
413051
+ printUsage8();
412720
413052
  return 0;
412721
413053
  }
412722
413054
  const storageDir = parsed.values["storage-dir"] ?? getLocalBackendStorageDir();
@@ -412764,7 +413096,7 @@ function printText(total, files, top, quiet) {
412764
413096
  console.log(` ${formatNumber(row.tokens).padStart(8)} ${row.path}`);
412765
413097
  }
412766
413098
  }
412767
- function printJson(total, files) {
413099
+ function printJson2(total, files) {
412768
413100
  console.log(JSON.stringify({
412769
413101
  total_tokens: total,
412770
413102
  files
@@ -412805,7 +413137,7 @@ async function runMemoryTokensAction(options) {
412805
413137
  }
412806
413138
  const { total, files } = estimate;
412807
413139
  if (format5 === "json") {
412808
- printJson(total, files);
413140
+ printJson2(total, files);
412809
413141
  } else {
412810
413142
  printText(total, files, top, options.quiet);
412811
413143
  }
@@ -412820,8 +413152,8 @@ var init_memory_tokens = __esm(() => {
412820
413152
  import { cpSync, existsSync as existsSync55, mkdirSync as mkdirSync39, rmSync as rmSync12, statSync as statSync19 } from "node:fs";
412821
413153
  import { readdir as readdir13 } from "node:fs/promises";
412822
413154
  import { dirname as dirname32, join as join72 } from "node:path";
412823
- import { parseArgs as parseArgs10 } from "node:util";
412824
- function printUsage8() {
413155
+ import { parseArgs as parseArgs11 } from "node:util";
413156
+ function printUsage9() {
412825
413157
  console.log(`
412826
413158
  Usage:
412827
413159
  letta memory status [--agent <id>]
@@ -412854,7 +413186,7 @@ function getAgentId3(agentFromArgs, agentIdFromArgs) {
412854
413186
  return agentFromArgs || agentIdFromArgs || process.env.LETTA_AGENT_ID || "";
412855
413187
  }
412856
413188
  function parseMemoryArgs(argv) {
412857
- return parseArgs10({
413189
+ return parseArgs11({
412858
413190
  args: argv,
412859
413191
  options: MEMORY_OPTIONS,
412860
413192
  strict: true,
@@ -412915,12 +413247,12 @@ async function runMemorySubcommand(argv) {
412915
413247
  } catch (error4) {
412916
413248
  const message = error4 instanceof Error ? error4.message : String(error4);
412917
413249
  console.error(`Error: ${message}`);
412918
- printUsage8();
413250
+ printUsage9();
412919
413251
  return 1;
412920
413252
  }
412921
413253
  const [action3] = parsed.positionals;
412922
413254
  if (parsed.values.help || !action3 || action3 === "help") {
412923
- printUsage8();
413255
+ printUsage9();
412924
413256
  return 0;
412925
413257
  }
412926
413258
  const agentId = getAgentId3(parsed.values.agent, parsed.values["agent-id"]);
@@ -413063,7 +413395,7 @@ async function runMemorySubcommand(argv) {
413063
413395
  return 1;
413064
413396
  }
413065
413397
  console.error(`Unknown action: ${action3}`);
413066
- printUsage8();
413398
+ printUsage9();
413067
413399
  return 1;
413068
413400
  }
413069
413401
  var MEMORY_OPTIONS;
@@ -413422,8 +413754,8 @@ var init_message_search = __esm(() => {
413422
413754
  // src/cli/subcommands/messages.ts
413423
413755
  import { writeFile as writeFile17 } from "node:fs/promises";
413424
413756
  import { resolve as resolve35 } from "node:path";
413425
- import { parseArgs as parseArgs11 } from "node:util";
413426
- function printUsage9() {
413757
+ import { parseArgs as parseArgs12 } from "node:util";
413758
+ function printUsage10() {
413427
413759
  console.log(`
413428
413760
  Usage:
413429
413761
  letta messages search --query <text> [options]
@@ -413508,7 +413840,7 @@ function pageItems4(page) {
413508
413840
  return [];
413509
413841
  }
413510
413842
  function parseMessagesArgs(argv) {
413511
- return parseArgs11({
413843
+ return parseArgs12({
413512
413844
  args: argv,
413513
413845
  options: MESSAGES_OPTIONS,
413514
413846
  strict: true,
@@ -413522,12 +413854,12 @@ async function runMessagesSubcommand(argv, deps = {}) {
413522
413854
  } catch (error4) {
413523
413855
  const message = error4 instanceof Error ? error4.message : String(error4);
413524
413856
  console.error(`Error: ${message}`);
413525
- printUsage9();
413857
+ printUsage10();
413526
413858
  return 1;
413527
413859
  }
413528
413860
  const [action3] = parsed.positionals;
413529
413861
  if (parsed.values.help || !action3 || action3 === "help") {
413530
- printUsage9();
413862
+ printUsage10();
413531
413863
  return 0;
413532
413864
  }
413533
413865
  try {
@@ -413769,7 +414101,7 @@ async function runMessagesSubcommand(argv, deps = {}) {
413769
414101
  return 1;
413770
414102
  }
413771
414103
  console.error(`Unknown action: ${action3}`);
413772
- printUsage9();
414104
+ printUsage10();
413773
414105
  return 1;
413774
414106
  }
413775
414107
  var MESSAGES_OPTIONS;
@@ -414799,8 +415131,8 @@ var init_package_scaffolder = __esm(() => {
414799
415131
 
414800
415132
  // src/cli/subcommands/mods.ts
414801
415133
  import { dirname as dirname33, join as join74 } from "node:path";
414802
- import { parseArgs as parseArgs12 } from "node:util";
414803
- function printUsage10() {
415134
+ import { parseArgs as parseArgs13 } from "node:util";
415135
+ function printUsage11() {
414804
415136
  console.log(`
414805
415137
  Usage:
414806
415138
  letta mods list [--agent <id>]
@@ -414817,7 +415149,7 @@ Options:
414817
415149
  `.trim());
414818
415150
  }
414819
415151
  function parseModsArgs(argv) {
414820
- return parseArgs12({
415152
+ return parseArgs13({
414821
415153
  args: argv,
414822
415154
  options: MODS_OPTIONS,
414823
415155
  strict: true,
@@ -414825,7 +415157,7 @@ function parseModsArgs(argv) {
414825
415157
  });
414826
415158
  }
414827
415159
  function parseModsPackageArgs(argv) {
414828
- return parseArgs12({
415160
+ return parseArgs13({
414829
415161
  args: argv,
414830
415162
  options: MODS_PACKAGE_OPTIONS,
414831
415163
  strict: true,
@@ -414923,16 +415255,16 @@ async function runList(argv, options = {}) {
414923
415255
  parsed = parseModsArgs(argv);
414924
415256
  } catch (error4) {
414925
415257
  console.error(`Error: ${error4 instanceof Error ? error4.message : String(error4)}`);
414926
- printUsage10();
415258
+ printUsage11();
414927
415259
  return 1;
414928
415260
  }
414929
415261
  if (parsed.values.help) {
414930
- printUsage10();
415262
+ printUsage11();
414931
415263
  return 0;
414932
415264
  }
414933
415265
  if (parsed.positionals.length > 0) {
414934
415266
  console.error(`Unexpected argument: ${parsed.positionals[0]}`);
414935
- printUsage10();
415267
+ printUsage11();
414936
415268
  return 1;
414937
415269
  }
414938
415270
  const agentId = getExplicitAgentId(parsed.values);
@@ -414949,27 +415281,27 @@ async function runPackageMutation(action3, argv, options = {}) {
414949
415281
  parsed = parseModsArgs(argv);
414950
415282
  } catch (error4) {
414951
415283
  console.error(`Error: ${error4 instanceof Error ? error4.message : String(error4)}`);
414952
- printUsage10();
415284
+ printUsage11();
414953
415285
  return 1;
414954
415286
  }
414955
415287
  if (parsed.values.help) {
414956
- printUsage10();
415288
+ printUsage11();
414957
415289
  return 0;
414958
415290
  }
414959
415291
  if (getExplicitAgentId(parsed.values)) {
414960
415292
  console.error(`--agent is only supported for 'letta mods list'.`);
414961
- printUsage10();
415293
+ printUsage11();
414962
415294
  return 1;
414963
415295
  }
414964
415296
  const [specifier, extra] = parsed.positionals;
414965
415297
  if (!specifier) {
414966
415298
  console.error(`Missing package specifier.`);
414967
- printUsage10();
415299
+ printUsage11();
414968
415300
  return 1;
414969
415301
  }
414970
415302
  if (extra) {
414971
415303
  console.error(`Unexpected argument: ${extra}`);
414972
- printUsage10();
415304
+ printUsage11();
414973
415305
  return 1;
414974
415306
  }
414975
415307
  try {
@@ -414995,27 +415327,27 @@ async function runPackageUpdate(argv, options = {}) {
414995
415327
  parsed = parseModsArgs(argv);
414996
415328
  } catch (error4) {
414997
415329
  console.error(`Error: ${error4 instanceof Error ? error4.message : String(error4)}`);
414998
- printUsage10();
415330
+ printUsage11();
414999
415331
  return 1;
415000
415332
  }
415001
415333
  if (parsed.values.help) {
415002
- printUsage10();
415334
+ printUsage11();
415003
415335
  return 0;
415004
415336
  }
415005
415337
  if (getExplicitAgentId(parsed.values)) {
415006
415338
  console.error(`--agent is not supported for 'letta mods update'.`);
415007
- printUsage10();
415339
+ printUsage11();
415008
415340
  return 1;
415009
415341
  }
415010
415342
  const [specifier, extra] = parsed.positionals;
415011
415343
  if (!specifier) {
415012
415344
  console.error(`Missing package specifier.`);
415013
- printUsage10();
415345
+ printUsage11();
415014
415346
  return 1;
415015
415347
  }
415016
415348
  if (extra) {
415017
415349
  console.error(`Unexpected argument: ${extra}`);
415018
- printUsage10();
415350
+ printUsage11();
415019
415351
  return 1;
415020
415352
  }
415021
415353
  try {
@@ -415037,33 +415369,33 @@ async function runPackageScaffold(argv) {
415037
415369
  parsed = parseModsPackageArgs(argv);
415038
415370
  } catch (error4) {
415039
415371
  console.error(`Error: ${error4 instanceof Error ? error4.message : String(error4)}`);
415040
- printUsage10();
415372
+ printUsage11();
415041
415373
  return 1;
415042
415374
  }
415043
415375
  if (parsed.values.help) {
415044
- printUsage10();
415376
+ printUsage11();
415045
415377
  return 0;
415046
415378
  }
415047
415379
  if (getExplicitAgentId(parsed.values)) {
415048
415380
  console.error(`--agent is not supported for 'letta mods package'.`);
415049
- printUsage10();
415381
+ printUsage11();
415050
415382
  return 1;
415051
415383
  }
415052
415384
  const [sourceFile, extra] = parsed.positionals;
415053
415385
  if (!sourceFile) {
415054
415386
  console.error(`Missing mod file.`);
415055
- printUsage10();
415387
+ printUsage11();
415056
415388
  return 1;
415057
415389
  }
415058
415390
  if (extra) {
415059
415391
  console.error(`Unexpected argument: ${extra}`);
415060
- printUsage10();
415392
+ printUsage11();
415061
415393
  return 1;
415062
415394
  }
415063
415395
  const packageName = parsed.values.name;
415064
415396
  if (typeof packageName !== "string" || !packageName.trim()) {
415065
415397
  console.error(`Missing required --name <package-name>.`);
415066
- printUsage10();
415398
+ printUsage11();
415067
415399
  return 1;
415068
415400
  }
415069
415401
  try {
@@ -415085,7 +415417,7 @@ async function runPackageScaffold(argv) {
415085
415417
  async function runModsSubcommand(argv, options = {}) {
415086
415418
  const [action3, ...rest4] = argv;
415087
415419
  if (!action3 || action3 === "help" || action3 === "--help" || action3 === "-h") {
415088
- printUsage10();
415420
+ printUsage11();
415089
415421
  return 0;
415090
415422
  }
415091
415423
  switch (action3) {
@@ -415101,7 +415433,7 @@ async function runModsSubcommand(argv, options = {}) {
415101
415433
  return runPackageMutation(action3, rest4, options);
415102
415434
  default:
415103
415435
  console.error(`Unknown mods action: ${action3}`);
415104
- printUsage10();
415436
+ printUsage11();
415105
415437
  return 1;
415106
415438
  }
415107
415439
  }
@@ -415181,8 +415513,8 @@ var init_sandbox_files = __esm(() => {
415181
415513
  // src/cli/subcommands/sandbox.ts
415182
415514
  import { readFile as readFile25, stat as stat17, writeFile as writeFile18 } from "node:fs/promises";
415183
415515
  import { basename as basename26, resolve as resolve36 } from "node:path";
415184
- import { parseArgs as parseArgs13 } from "node:util";
415185
- function printUsage11() {
415516
+ import { parseArgs as parseArgs14 } from "node:util";
415517
+ function printUsage12() {
415186
415518
  console.log(`
415187
415519
  Usage:
415188
415520
  letta sandbox upload <local-path>
@@ -415196,7 +415528,7 @@ Notes:
415196
415528
  `.trim());
415197
415529
  }
415198
415530
  function parseSandboxArgs(argv) {
415199
- return parseArgs13({
415531
+ return parseArgs14({
415200
415532
  args: argv,
415201
415533
  options: SANDBOX_OPTIONS,
415202
415534
  strict: true,
@@ -415236,17 +415568,17 @@ async function runSandboxSubcommand(argv, deps = {}) {
415236
415568
  parsed = parseSandboxArgs(argv);
415237
415569
  } catch (error4) {
415238
415570
  console.error(`Error: ${error4 instanceof Error ? error4.message : error4}`);
415239
- printUsage11();
415571
+ printUsage12();
415240
415572
  return 1;
415241
415573
  }
415242
415574
  const [action3, path48] = parsed.positionals;
415243
415575
  if (parsed.values.help || !action3 || action3 === "help") {
415244
- printUsage11();
415576
+ printUsage12();
415245
415577
  return 0;
415246
415578
  }
415247
415579
  if (action3 !== "upload" && action3 !== "download" || !path48) {
415248
415580
  console.error("Error: expected upload or download with a file path");
415249
- printUsage11();
415581
+ printUsage12();
415250
415582
  return 1;
415251
415583
  }
415252
415584
  try {
@@ -415290,8 +415622,8 @@ var init_sandbox2 = __esm(() => {
415290
415622
  });
415291
415623
 
415292
415624
  // src/cli/subcommands/secret.ts
415293
- import { parseArgs as parseArgs14 } from "node:util";
415294
- function printUsage12() {
415625
+ import { parseArgs as parseArgs15 } from "node:util";
415626
+ function printUsage13() {
415295
415627
  console.log(`
415296
415628
  Usage:
415297
415629
  letta secret set KEY --env SOURCE_VAR Set KEY from environment variable SOURCE_VAR
@@ -415316,7 +415648,7 @@ Notes:
415316
415648
  `.trim());
415317
415649
  }
415318
415650
  function parseSecretArgs(argv) {
415319
- return parseArgs14({
415651
+ return parseArgs15({
415320
415652
  args: argv,
415321
415653
  options: SECRET_OPTIONS,
415322
415654
  strict: true,
@@ -415351,11 +415683,11 @@ async function runSecretSubcommand(argv, deps = {}) {
415351
415683
  parsed = parseSecretArgs(argv);
415352
415684
  } catch (error4) {
415353
415685
  printError(error4);
415354
- printUsage12();
415686
+ printUsage13();
415355
415687
  return 1;
415356
415688
  }
415357
415689
  if (parsed.values.help || parsed.positionals.length === 0) {
415358
- printUsage12();
415690
+ printUsage13();
415359
415691
  return parsed.values.help ? 0 : 1;
415360
415692
  }
415361
415693
  const [verb, rawKey, rawValue] = parsed.positionals;
@@ -415365,7 +415697,7 @@ async function runSecretSubcommand(argv, deps = {}) {
415365
415697
  }
415366
415698
  switch (verb) {
415367
415699
  case "help": {
415368
- printUsage12();
415700
+ printUsage13();
415369
415701
  return 0;
415370
415702
  }
415371
415703
  case "list": {
@@ -415473,7 +415805,7 @@ async function runSecretSubcommand(argv, deps = {}) {
415473
415805
  }
415474
415806
  default: {
415475
415807
  console.error(`Unknown subcommand '${verb ?? ""}'.`);
415476
- printUsage12();
415808
+ printUsage13();
415477
415809
  return 1;
415478
415810
  }
415479
415811
  }
@@ -415491,7 +415823,7 @@ var init_secret = __esm(() => {
415491
415823
  });
415492
415824
 
415493
415825
  // src/cli/subcommands/app-server.ts
415494
- import { parseArgs as parseArgs15 } from "node:util";
415826
+ import { parseArgs as parseArgs16 } from "node:util";
415495
415827
  function printAppServerHelp() {
415496
415828
  console.log(`Usage: letta server --listen [url]
415497
415829
 
@@ -415539,7 +415871,7 @@ Stopped App Server (${signal}).`);
415539
415871
  async function runAppServerSubcommand(argv) {
415540
415872
  let parsed;
415541
415873
  try {
415542
- parsed = parseArgs15({
415874
+ parsed = parseArgs16({
415543
415875
  args: argv,
415544
415876
  allowPositionals: false,
415545
415877
  options: {
@@ -416124,7 +416456,7 @@ var init_setup6 = __esm(async () => {
416124
416456
  });
416125
416457
 
416126
416458
  // src/cli/subcommands/setup.ts
416127
- function printUsage13() {
416459
+ function printUsage14() {
416128
416460
  console.log(`
416129
416461
  Usage:
416130
416462
  letta setup
@@ -416135,12 +416467,12 @@ Re-run the interactive setup menu to choose local mode or sign in with Letta.
416135
416467
  async function runSetupSubcommand(argv) {
416136
416468
  const [arg, ...rest4] = argv;
416137
416469
  if (arg === "help" || arg === "--help" || arg === "-h") {
416138
- printUsage13();
416470
+ printUsage14();
416139
416471
  return 0;
416140
416472
  }
416141
416473
  if (arg || rest4.length > 0) {
416142
416474
  console.error(`Unexpected arguments: ${[arg, ...rest4].filter(Boolean).join(" ")}`);
416143
- printUsage13();
416475
+ printUsage14();
416144
416476
  return 1;
416145
416477
  }
416146
416478
  await settingsManager.initialize();
@@ -416155,8 +416487,8 @@ var init_setup7 = __esm(async () => {
416155
416487
  // src/cli/subcommands/shared-memory.ts
416156
416488
  import { existsSync as existsSync59 } from "node:fs";
416157
416489
  import { join as join75 } from "node:path";
416158
- import { parseArgs as parseArgs16 } from "node:util";
416159
- function printUsage14() {
416490
+ import { parseArgs as parseArgs17 } from "node:util";
416491
+ function printUsage15() {
416160
416492
  console.log(`
416161
416493
  Usage:
416162
416494
  letta shared-memory list [--agent <id>]
@@ -416191,7 +416523,7 @@ Examples:
416191
416523
  `.trim());
416192
416524
  }
416193
416525
  function parseSharedMemoryArgs(argv) {
416194
- return parseArgs16({
416526
+ return parseArgs17({
416195
416527
  args: argv,
416196
416528
  options: SHARED_MEMORY_OPTIONS,
416197
416529
  strict: true,
@@ -416267,12 +416599,12 @@ async function runSharedMemorySubcommand(argv, deps = {}) {
416267
416599
  parsed = parseSharedMemoryArgs(argv);
416268
416600
  } catch (error4) {
416269
416601
  console.error(error4 instanceof Error ? error4.message : String(error4));
416270
- printUsage14();
416602
+ printUsage15();
416271
416603
  return 1;
416272
416604
  }
416273
416605
  const [action3, reference] = parsed.positionals;
416274
416606
  if (parsed.values.help || !action3 || action3 === "help") {
416275
- printUsage14();
416607
+ printUsage15();
416276
416608
  return 0;
416277
416609
  }
416278
416610
  if (isLocalBackendEnvEnabled()) {
@@ -416377,7 +416709,7 @@ async function runSharedMemorySubcommand(argv, deps = {}) {
416377
416709
  return result2.failed > 0 ? 1 : 0;
416378
416710
  }
416379
416711
  console.error(`Unknown action: ${action3}`);
416380
- printUsage14();
416712
+ printUsage15();
416381
416713
  return 1;
416382
416714
  } catch (error4) {
416383
416715
  console.error(error4 instanceof Error ? error4.message : String(error4));
@@ -417885,8 +418217,8 @@ import {
417885
418217
  import { mkdir as mkdir15, readdir as readdir14 } from "node:fs/promises";
417886
418218
  import { tmpdir as tmpdir11 } from "node:os";
417887
418219
  import { basename as basename27, dirname as dirname34, join as join76, normalize as normalize5, resolve as resolve37, sep as sep8 } from "node:path";
417888
- import { parseArgs as parseArgs17, TextDecoder as TextDecoder2, TextEncoder as TextEncoder2 } from "node:util";
417889
- function printUsage15() {
418220
+ import { parseArgs as parseArgs18, TextDecoder as TextDecoder2, TextEncoder as TextEncoder2 } from "node:util";
418221
+ function printUsage16() {
417890
418222
  console.log(`
417891
418223
  Usage:
417892
418224
  letta install <thing> [--agent <id> | -n <agent name>] [--force]
@@ -417913,7 +418245,7 @@ Options:
417913
418245
  `.trim());
417914
418246
  }
417915
418247
  function parseSkillsArgs(argv) {
417916
- return parseArgs17({
418248
+ return parseArgs18({
417917
418249
  args: argv,
417918
418250
  options: SKILLS_OPTIONS,
417919
418251
  strict: true,
@@ -418561,17 +418893,17 @@ async function runInstall(argv, options = {}) {
418561
418893
  parsed = parseSkillsArgs(argv);
418562
418894
  } catch (error4) {
418563
418895
  console.error(`Error: ${error4 instanceof Error ? error4.message : String(error4)}`);
418564
- printUsage15();
418896
+ printUsage16();
418565
418897
  return 1;
418566
418898
  }
418567
418899
  const [specifier] = parsed.positionals;
418568
418900
  if (parsed.values.help || !specifier || specifier === "help") {
418569
- printUsage15();
418901
+ printUsage16();
418570
418902
  return 0;
418571
418903
  }
418572
418904
  if (parsed.positionals.length > 1) {
418573
418905
  console.error(`Unexpected argument: ${parsed.positionals[1]}`);
418574
- printUsage15();
418906
+ printUsage16();
418575
418907
  return 1;
418576
418908
  }
418577
418909
  if (specifier.startsWith("npm:")) {
@@ -418662,16 +418994,16 @@ async function runList2(argv) {
418662
418994
  parsed = parseSkillsArgs(argv);
418663
418995
  } catch (error4) {
418664
418996
  console.error(`Error: ${error4 instanceof Error ? error4.message : String(error4)}`);
418665
- printUsage15();
418997
+ printUsage16();
418666
418998
  return 1;
418667
418999
  }
418668
419000
  if (parsed.values.help) {
418669
- printUsage15();
419001
+ printUsage16();
418670
419002
  return 0;
418671
419003
  }
418672
419004
  if (parsed.positionals.length > 0) {
418673
419005
  console.error(`Unexpected argument: ${parsed.positionals[0]}`);
418674
- printUsage15();
419006
+ printUsage16();
418675
419007
  return 1;
418676
419008
  }
418677
419009
  try {
@@ -418692,17 +419024,17 @@ async function runDelete(argv) {
418692
419024
  parsed = parseSkillsArgs(argv);
418693
419025
  } catch (error4) {
418694
419026
  console.error(`Error: ${error4 instanceof Error ? error4.message : String(error4)}`);
418695
- printUsage15();
419027
+ printUsage16();
418696
419028
  return 1;
418697
419029
  }
418698
419030
  const [skillName] = parsed.positionals;
418699
419031
  if (parsed.values.help || !skillName || skillName === "help") {
418700
- printUsage15();
419032
+ printUsage16();
418701
419033
  return 0;
418702
419034
  }
418703
419035
  if (parsed.positionals.length > 1) {
418704
419036
  console.error(`Unexpected argument: ${parsed.positionals[1]}`);
418705
- printUsage15();
419037
+ printUsage16();
418706
419038
  return 1;
418707
419039
  }
418708
419040
  const agentId = getExplicitAgentId2(parsed.values);
@@ -418742,11 +419074,11 @@ async function runSkillsSubcommand(argv) {
418742
419074
  case "help":
418743
419075
  case "--help":
418744
419076
  case "-h":
418745
- printUsage15();
419077
+ printUsage16();
418746
419078
  return 0;
418747
419079
  default:
418748
419080
  console.error(`Unknown action: ${action3}`);
418749
- printUsage15();
419081
+ printUsage16();
418750
419082
  return 1;
418751
419083
  }
418752
419084
  }
@@ -418765,8 +419097,8 @@ var init_skills4 = __esm(() => {
418765
419097
  });
418766
419098
 
418767
419099
  // src/cli/subcommands/teleport.ts
418768
- import { parseArgs as parseArgs18 } from "node:util";
418769
- function printUsage16() {
419100
+ import { parseArgs as parseArgs19 } from "node:util";
419101
+ function printUsage17() {
418770
419102
  console.log(`
418771
419103
  Usage:
418772
419104
  letta teleport list
@@ -418789,7 +419121,7 @@ Notes:
418789
419121
  `.trim());
418790
419122
  }
418791
419123
  function parseTeleportArgs(argv) {
418792
- return parseArgs18({
419124
+ return parseArgs19({
418793
419125
  args: argv,
418794
419126
  options: TELEPORT_OPTIONS,
418795
419127
  strict: true,
@@ -418862,12 +419194,12 @@ async function runTeleportSubcommand(argv, deps = {}) {
418862
419194
  parsed = parseTeleportArgs(argv);
418863
419195
  } catch (error4) {
418864
419196
  console.error(`Error: ${error4 instanceof Error ? error4.message : error4}`);
418865
- printUsage16();
419197
+ printUsage17();
418866
419198
  return 1;
418867
419199
  }
418868
419200
  const [action3] = parsed.positionals;
418869
419201
  if (parsed.values.help || !action3 || action3 === "help") {
418870
- printUsage16();
419202
+ printUsage17();
418871
419203
  return 0;
418872
419204
  }
418873
419205
  try {
@@ -419303,8 +419635,8 @@ var init_review = () => {};
419303
419635
 
419304
419636
  // src/cli/subcommands/trajectories.ts
419305
419637
  import { readFile as readFile29 } from "node:fs/promises";
419306
- import { parseArgs as parseArgs19 } from "node:util";
419307
- function printUsage17() {
419638
+ import { parseArgs as parseArgs20 } from "node:util";
419639
+ function printUsage18() {
419308
419640
  console.log(`
419309
419641
  Usage:
419310
419642
  letta trajectories export [options]
@@ -419442,7 +419774,7 @@ ${results.length} session(s) matched "${keyword}"`);
419442
419774
  return 0;
419443
419775
  }
419444
419776
  function parseTrajectoriesArgs(argv) {
419445
- return parseArgs19({
419777
+ return parseArgs20({
419446
419778
  args: argv,
419447
419779
  options: TRAJECTORIES_OPTIONS,
419448
419780
  strict: true,
@@ -419455,12 +419787,12 @@ async function runTrajectoriesSubcommand(argv) {
419455
419787
  parsed = parseTrajectoriesArgs(argv);
419456
419788
  } catch (error4) {
419457
419789
  console.error(`Error: ${error4 instanceof Error ? error4.message : String(error4)}`);
419458
- printUsage17();
419790
+ printUsage18();
419459
419791
  return 1;
419460
419792
  }
419461
419793
  const [action3] = parsed.positionals;
419462
419794
  if (parsed.values.help || action3 === "help" || !action3) {
419463
- printUsage17();
419795
+ printUsage18();
419464
419796
  return parsed.values.help || action3 === "help" ? 0 : 1;
419465
419797
  }
419466
419798
  const asJson = Boolean(parsed.values.json);
@@ -419492,7 +419824,7 @@ async function runTrajectoriesSubcommand(argv) {
419492
419824
  }
419493
419825
  if (action3 !== "export") {
419494
419826
  console.error(`Unknown command: ${action3}`);
419495
- printUsage17();
419827
+ printUsage18();
419496
419828
  return 1;
419497
419829
  }
419498
419830
  const options = {
@@ -421041,9 +421373,9 @@ class ChannelRichDraftStreamerImpl {
421041
421373
  return;
421042
421374
  }
421043
421375
  const record3 = asRecord10(chunk2);
421044
- const messageType = stringValue4(record3?.message_type);
421376
+ const messageType = stringValue5(record3?.message_type);
421045
421377
  if (messageType === "tool_return_message") {
421046
- const toolCallId = stringValue4(record3?.tool_call_id);
421378
+ const toolCallId = stringValue5(record3?.tool_call_id);
421047
421379
  if (toolCallId) {
421048
421380
  this.finishCall(toolCallId);
421049
421381
  }
@@ -421336,14 +421668,14 @@ function extractToolCallFragments2(record3) {
421336
421668
  const fragments = [];
421337
421669
  for (const rawToolCall of rawToolCalls) {
421338
421670
  const toolCall = asRecord10(rawToolCall);
421339
- const toolCallId = stringValue4(toolCall?.tool_call_id);
421671
+ const toolCallId = stringValue5(toolCall?.tool_call_id);
421340
421672
  if (!toolCallId) {
421341
421673
  continue;
421342
421674
  }
421343
421675
  fragments.push({
421344
421676
  toolCallId,
421345
- name: stringValue4(toolCall?.name),
421346
- argumentsDelta: stringValue4(toolCall?.arguments)
421677
+ name: stringValue5(toolCall?.name),
421678
+ argumentsDelta: stringValue5(toolCall?.arguments)
421347
421679
  });
421348
421680
  }
421349
421681
  return fragments;
@@ -421463,7 +421795,7 @@ function buildDraftId(seed) {
421463
421795
  function asRecord10(value) {
421464
421796
  return value && typeof value === "object" ? value : null;
421465
421797
  }
421466
- function stringValue4(value) {
421798
+ function stringValue5(value) {
421467
421799
  return typeof value === "string" ? value : undefined;
421468
421800
  }
421469
421801
  var MESSAGE_CHANNEL_TOOL_NAMES, DEFAULT_DRAFT_DEBOUNCE_MS = 1000, MIN_DRAFT_TEXT_LENGTH = 1;
@@ -424331,14 +424663,14 @@ var exports_channel_gateway = {};
424331
424663
  __export(exports_channel_gateway, {
424332
424664
  runChannelGatewaySubcommand: () => runChannelGatewaySubcommand
424333
424665
  });
424334
- import { parseArgs as parseArgs20 } from "node:util";
424666
+ import { parseArgs as parseArgs21 } from "node:util";
424335
424667
  function isGatewayCommandEnvelope(value) {
424336
424668
  return Boolean(value && typeof value === "object" && "type" in value && value.type === "command" && "requestId" in value && typeof value.requestId === "string" && "command" in value && value.command && typeof value.command === "object");
424337
424669
  }
424338
424670
  async function runChannelGatewaySubcommand(argv) {
424339
424671
  let values3;
424340
424672
  try {
424341
- ({ values: values3 } = parseArgs20({
424673
+ ({ values: values3 } = parseArgs21({
424342
424674
  args: argv,
424343
424675
  strict: true,
424344
424676
  allowPositionals: false,
@@ -424477,6 +424809,7 @@ function subcommandNeedsEarlyBackendMode(command) {
424477
424809
  case "sandbox":
424478
424810
  case "secret":
424479
424811
  case "server":
424812
+ case "cloud-mcp":
424480
424813
  case "shared-memory":
424481
424814
  case "skills":
424482
424815
  case "teleport":
@@ -424519,6 +424852,8 @@ async function runSubcommand(argv) {
424519
424852
  return runTeleportSubcommand(rest4);
424520
424853
  case "server":
424521
424854
  return runServerSubcommand(rest4);
424855
+ case "cloud-mcp":
424856
+ return runCloudMcpSubcommand(rest4);
424522
424857
  case "remote":
424523
424858
  return runListenSubcommand(rest4);
424524
424859
  case "connect":
@@ -424556,6 +424891,7 @@ var init_router = __esm(async () => {
424556
424891
  init_agents6();
424557
424892
  init_backend3();
424558
424893
  init_channels();
424894
+ init_cloud_mcp();
424559
424895
  init_connect();
424560
424896
  init_dream();
424561
424897
  init_environments3();
@@ -442523,7 +442859,7 @@ var init_mcp_client = __esm(() => {
442523
442859
  init_streamableHttp();
442524
442860
  DEFAULT_CLIENT_INFO = {
442525
442861
  name: "letta-code",
442526
- version: "0.31.1"
442862
+ version: "0.31.3"
442527
442863
  };
442528
442864
  });
442529
442865
 
@@ -462400,110 +462736,6 @@ var init_LettaLoginOverlay = __esm(async () => {
462400
462736
  jsx_dev_runtime63 = __toESM(require_jsx_dev_runtime(), 1);
462401
462737
  });
462402
462738
 
462403
- // src/backend/api/mcp-servers.ts
462404
- function withTimeout2(promise2, timeoutMs, label) {
462405
- let timer;
462406
- const timeout = new Promise((_4, reject2) => {
462407
- timer = setTimeout(() => reject2(new Error(`${label} timed out after ${timeoutMs}ms`)), timeoutMs);
462408
- });
462409
- return Promise.race([promise2, timeout]).finally(() => {
462410
- if (timer !== undefined)
462411
- clearTimeout(timer);
462412
- });
462413
- }
462414
- function listServerMcpServers(client, timeoutMs = 1e4) {
462415
- return withTimeout2(client.mcpServers.list(), timeoutMs, "Listing server-side MCP servers");
462416
- }
462417
- async function listLiveServerMcpTools(client, serverName, timeoutMs = 15000) {
462418
- const result2 = await withTimeout2(client.get(`/v1/tools/mcp/servers/${encodeURIComponent(serverName)}/tools`), timeoutMs, `Listing tools for MCP server "${serverName}"`);
462419
- if (!Array.isArray(result2))
462420
- return [];
462421
- return result2.filter((tool) => typeof tool === "object" && tool !== null && typeof tool.name === "string");
462422
- }
462423
- async function loadServerMcpEntries(client, timeoutMs = 15000) {
462424
- const servers = await listServerMcpServers(client, timeoutMs);
462425
- return Promise.all(servers.map(async (server2) => {
462426
- try {
462427
- const tools = await listLiveServerMcpTools(client, server2.server_name, timeoutMs);
462428
- return { server: server2, tools };
462429
- } catch (cause) {
462430
- return {
462431
- server: server2,
462432
- tools: [],
462433
- toolsError: cause instanceof Error ? cause.message : String(cause)
462434
- };
462435
- }
462436
- }));
462437
- }
462438
- function parseMcpMetadata(tool) {
462439
- const metadata = tool.metadata_;
462440
- const mcp = metadata?.mcp;
462441
- if (typeof mcp !== "object" || mcp === null)
462442
- return null;
462443
- const { server_id, server_name } = mcp;
462444
- return {
462445
- ...typeof server_id === "string" && { serverId: server_id },
462446
- ...typeof server_name === "string" && { serverName: server_name }
462447
- };
462448
- }
462449
- async function listAgentMcpAttachments(client, agentId) {
462450
- const attachments = [];
462451
- for await (const tool of client.agents.tools.list(agentId, { limit: 100 })) {
462452
- if (tool.tool_type !== "external_mcp" || !tool.id || !tool.name)
462453
- continue;
462454
- attachments.push({
462455
- toolId: tool.id,
462456
- toolName: tool.name,
462457
- ...parseMcpMetadata(tool)
462458
- });
462459
- }
462460
- return attachments;
462461
- }
462462
- function attachmentsForEntry(entry, attachments) {
462463
- return attachments.filter((attachment) => attachment.serverId && entry.server.id ? attachment.serverId === entry.server.id : attachment.serverName === entry.server.server_name);
462464
- }
462465
- function attachedToolNamesForEntry(entry, attachments) {
462466
- return new Set(attachmentsForEntry(entry, attachments).map((attachment) => attachment.toolName));
462467
- }
462468
- async function registerServerMcpTool(client, serverName, toolName) {
462469
- const result2 = await client.post(`/v1/tools/mcp/servers/${encodeURIComponent(serverName)}/${encodeURIComponent(toolName)}`);
462470
- if (typeof result2?.id !== "string") {
462471
- throw new Error(`Registering MCP tool "${toolName}" on server "${serverName}" returned no tool id`);
462472
- }
462473
- return { id: result2.id };
462474
- }
462475
- async function attachServerMcpTools(client, agentId, serverName, toolNames) {
462476
- await Promise.all(toolNames.map(async (toolName) => {
462477
- const { id: id2 } = await registerServerMcpTool(client, serverName, toolName);
462478
- await client.agents.tools.attach(id2, { agent_id: agentId });
462479
- }));
462480
- }
462481
- async function detachServerMcpTools(client, agentId, toolIds) {
462482
- await Promise.all(toolIds.map((toolId) => client.agents.tools.detach(toolId, { agent_id: agentId })));
462483
- }
462484
- function refreshServerMcpServer(client, mcpServerId, agentId) {
462485
- return client.mcpServers.refresh(mcpServerId, { agent_id: agentId });
462486
- }
462487
- function planServerMcpToggle(entry, attachments) {
462488
- const attached = attachmentsForEntry(entry, attachments);
462489
- if (attached.length > 0) {
462490
- return {
462491
- action: "detach",
462492
- toolIds: attached.map((attachment) => attachment.toolId)
462493
- };
462494
- }
462495
- return { action: "attach", toolNames: entry.tools.map((tool) => tool.name) };
462496
- }
462497
- function describeServerMcpTarget(server2) {
462498
- if ("server_url" in server2 && server2.server_url) {
462499
- return server2.server_url;
462500
- }
462501
- if ("command" in server2 && server2.command) {
462502
- return [server2.command, ...server2.args ?? []].join(" ");
462503
- }
462504
- return "";
462505
- }
462506
-
462507
462739
  // src/cli/components/McpSelector.tsx
462508
462740
  function buildMcpRows(localStates, serverEntries) {
462509
462741
  return [
@@ -462620,6 +462852,7 @@ var import_react87, jsx_dev_runtime64, SOLID_LINE12 = "─", DISPLAY_PAGE_SIZE2
462620
462852
  var init_McpSelector = __esm(async () => {
462621
462853
  init_backend2();
462622
462854
  init_client2();
462855
+ init_mcp_servers2();
462623
462856
  init_truncate_text();
462624
462857
  init_use_terminal_width();
462625
462858
  init_mcp_oauth();
@@ -472249,7 +472482,7 @@ var init_ToolCallMessageRich = __esm(async () => {
472249
472482
  let shellSemanticKind = null;
472250
472483
  let hasShellDescription = false;
472251
472484
  if (!isQuestionTool(rawName)) {
472252
- const parseArgs21 = () => {
472485
+ const parseArgs22 = () => {
472253
472486
  if (!argsText.trim()) {
472254
472487
  return { formatted: null, parseable: true };
472255
472488
  }
@@ -472263,7 +472496,7 @@ var init_ToolCallMessageRich = __esm(async () => {
472263
472496
  return { formatted: null, parseable: false };
472264
472497
  }
472265
472498
  };
472266
- const { formatted, parseable } = parseArgs21();
472499
+ const { formatted, parseable } = parseArgs22();
472267
472500
  const argsComplete = parseable || line.phase === "running" || line.phase === "finished" || !isStreaming;
472268
472501
  if (!argsComplete) {
472269
472502
  args = "(…)";
@@ -474479,7 +474712,7 @@ function updateCommandResult(buffersRef, refreshDerived, cmdId, input, output, s
474479
474712
  buffersRef.current.byId.set(cmdId, line);
474480
474713
  refreshDerived();
474481
474714
  }
474482
- function parseArgs21(msg) {
474715
+ function parseArgs22(msg) {
474483
474716
  return msg.trim().split(/\s+/).filter(Boolean);
474484
474717
  }
474485
474718
  function formatConnectUsage() {
@@ -474861,7 +475094,7 @@ ${formatBedrockUsage2()}`, false);
474861
475094
  }
474862
475095
  }
474863
475096
  async function handleConnect(ctx, msg) {
474864
- const parts = parseArgs21(msg);
475097
+ const parts = parseArgs22(msg);
474865
475098
  const providerToken = parts[1];
474866
475099
  if (!providerToken) {
474867
475100
  addCommandResult(ctx.buffersRef, ctx.refreshDerived, msg, formatConnectUsage(), false);
@@ -505797,9 +506030,7 @@ USAGE
505797
506030
  letta -p "..." One-off prompt in headless mode (no TTY UI)
505798
506031
 
505799
506032
  # maintenance
505800
- letta update Manually check for updates and install if available
505801
- letta upgrade Alias for \`letta update\`
505802
- letta --update/--upgrade Aliases for \`letta update\`
506033
+ letta update Check for updates and install (aliases: upgrade, --update, --upgrade)
505803
506034
  letta memory ... Memory filesystem subcommands
505804
506035
  letta agents ... Agents subcommands (JSON-only)
505805
506036
  letta environments ... List available remote environments (JSON-only)
@@ -505808,6 +506039,7 @@ USAGE
505808
506039
  letta mods ... List and manage local mods
505809
506040
  letta sandbox ... Transfer files to or from the current Cloud sandbox
505810
506041
  letta server ... Run a remote environment, channels, or the App Server
506042
+ letta cloud-mcp ... Use MCP servers connected to an agent
505811
506043
  letta connect ... Connect providers from terminal
505812
506044
  letta backend ... Show or set the default backend
505813
506045
  letta setup Re-run first-run setup
@@ -505839,6 +506071,7 @@ SUBCOMMANDS
505839
506071
  letta mods enable <package-spec>
505840
506072
  letta mods disable <package-spec>
505841
506073
  letta mods remove <package-spec>
506074
+ letta cloud-mcp list|tools|run ... [--agent <id>]
505842
506075
  letta server [--env-name <name> | --listen [url]] [options]
505843
506076
  letta connect <provider> [options]
505844
506077
  letta install <thing> [--agent <id> | -n <name>]
@@ -509659,4 +509892,4 @@ function registerBunOAuthFlows() {
509659
509892
  registerBunOAuthFlows();
509660
509893
  await init_src5().then(() => exports_src2);
509661
509894
 
509662
- //# debugId=1177A2820C3BD72164756E2164756E21
509895
+ //# debugId=B393760B54BCD06F64756E2164756E21