@letta-ai/letta-code 0.13.7 → 0.13.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/letta.js +570 -229
  2. package/package.json +2 -2
package/letta.js CHANGED
@@ -256,7 +256,7 @@ var init_values = __esm(() => {
256
256
  var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
257
257
 
258
258
  // node_modules/@letta-ai/letta-client/version.mjs
259
- var VERSION = "1.7.2";
259
+ var VERSION = "1.7.5";
260
260
 
261
261
  // node_modules/@letta-ai/letta-client/internal/detect-platform.mjs
262
262
  function getDetectedPlatform() {
@@ -1817,6 +1817,31 @@ var init_passages = __esm(() => {
1817
1817
  };
1818
1818
  });
1819
1819
 
1820
+ // node_modules/@letta-ai/letta-client/resources/agents/schedule.mjs
1821
+ var Schedule;
1822
+ var init_schedule = __esm(() => {
1823
+ init_path();
1824
+ Schedule = class Schedule extends APIResource {
1825
+ create(agentID, body, options) {
1826
+ return this._client.post(path`/v1/agents/${agentID}/schedule`, { body, ...options });
1827
+ }
1828
+ retrieve(scheduledMessageID, params, options) {
1829
+ const { agent_id } = params;
1830
+ return this._client.get(path`/v1/agents/${agent_id}/schedule/${scheduledMessageID}`, options);
1831
+ }
1832
+ list(agentID, query = {}, options) {
1833
+ return this._client.get(path`/v1/agents/${agentID}/schedule`, { query, ...options });
1834
+ }
1835
+ delete(scheduledMessageID, params, options) {
1836
+ const { agent_id, ...body } = params;
1837
+ return this._client.delete(path`/v1/agents/${agent_id}/schedule/${scheduledMessageID}`, {
1838
+ body,
1839
+ ...options
1840
+ });
1841
+ }
1842
+ };
1843
+ });
1844
+
1820
1845
  // node_modules/@letta-ai/letta-client/resources/agents/tools.mjs
1821
1846
  var Tools;
1822
1847
  var init_tools = __esm(() => {
@@ -1935,6 +1960,8 @@ var init_agents = __esm(() => {
1935
1960
  init_messages();
1936
1961
  init_passages();
1937
1962
  init_passages();
1963
+ init_schedule();
1964
+ init_schedule();
1938
1965
  init_tools();
1939
1966
  init_tools();
1940
1967
  init_pagination();
@@ -1945,6 +1972,7 @@ var init_agents = __esm(() => {
1945
1972
  constructor() {
1946
1973
  super(...arguments);
1947
1974
  this.messages = new Messages(this._client);
1975
+ this.schedule = new Schedule(this._client);
1948
1976
  this.blocks = new Blocks(this._client);
1949
1977
  this.tools = new Tools(this._client);
1950
1978
  this.folders = new Folders(this._client);
@@ -1986,6 +2014,7 @@ var init_agents = __esm(() => {
1986
2014
  }
1987
2015
  };
1988
2016
  Agents.Messages = Messages;
2017
+ Agents.Schedule = Schedule;
1989
2018
  Agents.Blocks = Blocks;
1990
2019
  Agents.Tools = Tools;
1991
2020
  Agents.Folders = Folders;
@@ -2011,6 +2040,9 @@ var init_passages2 = __esm(() => {
2011
2040
  headers: buildHeaders([{ Accept: "*/*" }, options?.headers])
2012
2041
  });
2013
2042
  }
2043
+ createMany(archiveID, body, options) {
2044
+ return this._client.post(path`/v1/archives/${archiveID}/passages/batch`, { body, ...options });
2045
+ }
2014
2046
  };
2015
2047
  });
2016
2048
 
@@ -2111,6 +2143,9 @@ var init_messages2 = __esm(() => {
2111
2143
  list(conversationID, query = {}, options) {
2112
2144
  return this._client.getAPIList(path`/v1/conversations/${conversationID}/messages`, ArrayPage, { query, ...options });
2113
2145
  }
2146
+ compact(conversationID, body = {}, options) {
2147
+ return this._client.post(path`/v1/conversations/${conversationID}/compact`, { body, ...options });
2148
+ }
2114
2149
  stream(conversationID, body = {}, options) {
2115
2150
  return this._client.post(path`/v1/conversations/${conversationID}/stream`, {
2116
2151
  body,
@@ -3073,7 +3108,7 @@ var package_default;
3073
3108
  var init_package = __esm(() => {
3074
3109
  package_default = {
3075
3110
  name: "@letta-ai/letta-code",
3076
- version: "0.13.7",
3111
+ version: "0.13.8",
3077
3112
  description: "Letta Code is a CLI tool for interacting with stateful Letta agents from the terminal.",
3078
3113
  type: "module",
3079
3114
  bin: {
@@ -3103,7 +3138,7 @@ var init_package = __esm(() => {
3103
3138
  access: "public"
3104
3139
  },
3105
3140
  dependencies: {
3106
- "@letta-ai/letta-client": "^1.7.2",
3141
+ "@letta-ai/letta-client": "1.7.5",
3107
3142
  glob: "^13.0.0",
3108
3143
  "ink-link": "^5.0.0",
3109
3144
  open: "^10.2.0",
@@ -59815,7 +59850,7 @@ async function sendMessageStream(conversationId, messages, opts = { streamTokens
59815
59850
  } else {
59816
59851
  stream2 = await client.conversations.messages.create(conversationId, {
59817
59852
  messages,
59818
- streaming: true,
59853
+ stream: true,
59819
59854
  stream_tokens: opts.streamTokens ?? true,
59820
59855
  background: opts.background ?? true,
59821
59856
  client_tools: getClientToolsFromRegistry()
@@ -75371,18 +75406,46 @@ var init_AgentInfoBar = __esm(async () => {
75371
75406
  color: "gray",
75372
75407
  children: " (type /pin to pin agent)"
75373
75408
  }, undefined, false, undefined, this),
75374
- /* @__PURE__ */ jsx_dev_runtime35.jsxDEV(Text, {
75409
+ isCloudUser && adeUrl && !isTmux && /* @__PURE__ */ jsx_dev_runtime35.jsxDEV(jsx_dev_runtime35.Fragment, {
75410
+ children: [
75411
+ /* @__PURE__ */ jsx_dev_runtime35.jsxDEV(Text, {
75412
+ dimColor: true,
75413
+ children: " · "
75414
+ }, undefined, false, undefined, this),
75415
+ /* @__PURE__ */ jsx_dev_runtime35.jsxDEV(dist_default4, {
75416
+ url: adeUrl,
75417
+ children: /* @__PURE__ */ jsx_dev_runtime35.jsxDEV(Text, {
75418
+ children: "Open in ADE ↗"
75419
+ }, undefined, false, undefined, this)
75420
+ }, undefined, false, undefined, this)
75421
+ ]
75422
+ }, undefined, true, undefined, this),
75423
+ isCloudUser && adeUrl && isTmux && /* @__PURE__ */ jsx_dev_runtime35.jsxDEV(Text, {
75375
75424
  dimColor: true,
75376
75425
  children: [
75377
- " · ",
75378
- agentId
75426
+ " · Open in ADE: ",
75427
+ adeUrl
75379
75428
  ]
75380
75429
  }, undefined, true, undefined, this),
75381
- conversationId && conversationId !== "default" && /* @__PURE__ */ jsx_dev_runtime35.jsxDEV(Text, {
75430
+ isCloudUser && /* @__PURE__ */ jsx_dev_runtime35.jsxDEV(jsx_dev_runtime35.Fragment, {
75431
+ children: [
75432
+ /* @__PURE__ */ jsx_dev_runtime35.jsxDEV(Text, {
75433
+ dimColor: true,
75434
+ children: " · "
75435
+ }, undefined, false, undefined, this),
75436
+ /* @__PURE__ */ jsx_dev_runtime35.jsxDEV(dist_default4, {
75437
+ url: "https://app.letta.com/settings/organization/usage",
75438
+ children: /* @__PURE__ */ jsx_dev_runtime35.jsxDEV(Text, {
75439
+ children: "View usage ↗"
75440
+ }, undefined, false, undefined, this)
75441
+ }, undefined, false, undefined, this)
75442
+ ]
75443
+ }, undefined, true, undefined, this),
75444
+ !isCloudUser && /* @__PURE__ */ jsx_dev_runtime35.jsxDEV(Text, {
75382
75445
  dimColor: true,
75383
75446
  children: [
75384
75447
  " · ",
75385
- conversationId
75448
+ serverUrl
75386
75449
  ]
75387
75450
  }, undefined, true, undefined, this)
75388
75451
  ]
@@ -75391,34 +75454,18 @@ var init_AgentInfoBar = __esm(async () => {
75391
75454
  children: [
75392
75455
  /* @__PURE__ */ jsx_dev_runtime35.jsxDEV(Text, {
75393
75456
  dimColor: true,
75394
- children: " "
75395
- }, undefined, false, undefined, this),
75396
- isCloudUser && adeUrl && !isTmux && /* @__PURE__ */ jsx_dev_runtime35.jsxDEV(dist_default4, {
75397
- url: adeUrl,
75398
- children: /* @__PURE__ */ jsx_dev_runtime35.jsxDEV(Text, {
75399
- children: "Open in ADE ↗"
75400
- }, undefined, false, undefined, this)
75401
- }, undefined, false, undefined, this),
75402
- isCloudUser && adeUrl && isTmux && /* @__PURE__ */ jsx_dev_runtime35.jsxDEV(Text, {
75403
75457
  children: [
75404
- "Open in ADE: ",
75405
- adeUrl
75458
+ " ",
75459
+ agentId
75406
75460
  ]
75407
75461
  }, undefined, true, undefined, this),
75408
- isCloudUser && /* @__PURE__ */ jsx_dev_runtime35.jsxDEV(Text, {
75409
- dimColor: true,
75410
- children: " · "
75411
- }, undefined, false, undefined, this),
75412
- isCloudUser && /* @__PURE__ */ jsx_dev_runtime35.jsxDEV(dist_default4, {
75413
- url: "https://app.letta.com/settings/organization/usage",
75414
- children: /* @__PURE__ */ jsx_dev_runtime35.jsxDEV(Text, {
75415
- children: "View usage ↗"
75416
- }, undefined, false, undefined, this)
75417
- }, undefined, false, undefined, this),
75418
- !isCloudUser && /* @__PURE__ */ jsx_dev_runtime35.jsxDEV(Text, {
75462
+ conversationId && conversationId !== "default" && /* @__PURE__ */ jsx_dev_runtime35.jsxDEV(Text, {
75419
75463
  dimColor: true,
75420
- children: serverUrl
75421
- }, undefined, false, undefined, this)
75464
+ children: [
75465
+ " · ",
75466
+ conversationId
75467
+ ]
75468
+ }, undefined, true, undefined, this)
75422
75469
  ]
75423
75470
  }, undefined, true, undefined, this)
75424
75471
  ]
@@ -78516,26 +78563,6 @@ var init_MemoryTabViewer = __esm(async () => {
78516
78563
  });
78517
78564
 
78518
78565
  // src/cli/components/MessageSearch.tsx
78519
- function formatRelativeTime5(dateStr) {
78520
- if (!dateStr)
78521
- return "";
78522
- const date = new Date(dateStr);
78523
- const now = new Date;
78524
- const diffMs = now.getTime() - date.getTime();
78525
- const diffMins = Math.floor(diffMs / 60000);
78526
- const diffHours = Math.floor(diffMs / 3600000);
78527
- const diffDays = Math.floor(diffMs / 86400000);
78528
- const diffWeeks = Math.floor(diffDays / 7);
78529
- if (diffMins < 1)
78530
- return "just now";
78531
- if (diffMins < 60)
78532
- return `${diffMins}m ago`;
78533
- if (diffHours < 24)
78534
- return `${diffHours}h ago`;
78535
- if (diffDays < 7)
78536
- return `${diffDays}d ago`;
78537
- return `${diffWeeks}w ago`;
78538
- }
78539
78566
  function formatLocalTime(dateStr) {
78540
78567
  if (!dateStr)
78541
78568
  return "";
@@ -78586,34 +78613,102 @@ function getMessageText(msg) {
78586
78613
  }
78587
78614
  return `[${msg.message_type || "unknown"}]`;
78588
78615
  }
78589
- function MessageSearch({ onClose, initialQuery }) {
78616
+ function MessageSearch({
78617
+ onClose,
78618
+ initialQuery,
78619
+ agentId,
78620
+ conversationId,
78621
+ onOpenConversation
78622
+ }) {
78590
78623
  const terminalWidth = useTerminalWidth();
78591
78624
  const [searchInput, setSearchInput] = import_react70.useState(initialQuery ?? "");
78592
78625
  const [activeQuery, setActiveQuery] = import_react70.useState(initialQuery ?? "");
78593
78626
  const [searchMode, setSearchMode] = import_react70.useState("hybrid");
78627
+ const [searchRange, setSearchRange] = import_react70.useState("all");
78594
78628
  const [results, setResults] = import_react70.useState([]);
78595
78629
  const [loading, setLoading] = import_react70.useState(false);
78596
78630
  const [error, setError] = import_react70.useState(null);
78597
- const [currentPage, setCurrentPage] = import_react70.useState(0);
78598
78631
  const [selectedIndex, setSelectedIndex] = import_react70.useState(0);
78632
+ const [expandedMessage, setExpandedMessage] = import_react70.useState(null);
78599
78633
  const clientRef = import_react70.useRef(null);
78600
- const executeSearch = import_react70.useCallback(async (query, mode) => {
78634
+ const resultsCache = import_react70.useRef(new Map);
78635
+ const getCacheKey = import_react70.useCallback((query, mode, range2) => {
78636
+ const rangeKey = range2 === "agent" ? agentId || "no-agent" : range2 === "conv" ? conversationId || "no-conv" : "all";
78637
+ return `${query.trim()}-${mode}-${rangeKey}`;
78638
+ }, [agentId, conversationId]);
78639
+ const fetchSearchResults = import_react70.useCallback(async (client, query, mode, range2) => {
78640
+ const body = {
78641
+ query: query.trim(),
78642
+ search_mode: mode,
78643
+ limit: SEARCH_LIMIT
78644
+ };
78645
+ if (range2 === "agent" && agentId) {
78646
+ body.agent_id = agentId;
78647
+ } else if (range2 === "conv" && conversationId) {
78648
+ body.conversation_id = conversationId;
78649
+ }
78650
+ const searchResults = await client.post("/v1/messages/search", { body });
78651
+ return searchResults;
78652
+ }, [agentId, conversationId]);
78653
+ const executeSearch = import_react70.useCallback(async (query, mode, range2) => {
78601
78654
  if (!query.trim())
78602
78655
  return;
78656
+ const cacheKey = getCacheKey(query, mode, range2);
78657
+ const cached = resultsCache.current.get(cacheKey);
78658
+ if (cached) {
78659
+ setResults(cached);
78660
+ setSelectedIndex(0);
78661
+ return;
78662
+ }
78603
78663
  setLoading(true);
78604
78664
  setError(null);
78605
78665
  try {
78606
78666
  const client = clientRef.current || await getClient2();
78607
78667
  clientRef.current = client;
78608
- const searchResults = await client.post("/v1/messages/search", {
78609
- body: {
78610
- query: query.trim(),
78611
- search_mode: mode,
78612
- limit: SEARCH_LIMIT
78613
- }
78614
- });
78615
- setResults(searchResults);
78616
- setCurrentPage(0);
78668
+ const getOrFetch = (m, r) => {
78669
+ const key = getCacheKey(query, m, r);
78670
+ return resultsCache.current.get(key) ?? fetchSearchResults(client, query, m, r);
78671
+ };
78672
+ const [
78673
+ hybridAll,
78674
+ vectorAll,
78675
+ ftsAll,
78676
+ hybridAgent,
78677
+ vectorAgent,
78678
+ ftsAgent,
78679
+ hybridConv,
78680
+ vectorConv,
78681
+ ftsConv
78682
+ ] = await Promise.all([
78683
+ getOrFetch("hybrid", "all"),
78684
+ getOrFetch("vector", "all"),
78685
+ getOrFetch("fts", "all"),
78686
+ agentId ? getOrFetch("hybrid", "agent") : Promise.resolve([]),
78687
+ agentId ? getOrFetch("vector", "agent") : Promise.resolve([]),
78688
+ agentId ? getOrFetch("fts", "agent") : Promise.resolve([]),
78689
+ conversationId ? getOrFetch("hybrid", "conv") : Promise.resolve([]),
78690
+ conversationId ? getOrFetch("vector", "conv") : Promise.resolve([]),
78691
+ conversationId ? getOrFetch("fts", "conv") : Promise.resolve([])
78692
+ ]);
78693
+ resultsCache.current.set(getCacheKey(query, "hybrid", "all"), hybridAll);
78694
+ resultsCache.current.set(getCacheKey(query, "vector", "all"), vectorAll);
78695
+ resultsCache.current.set(getCacheKey(query, "fts", "all"), ftsAll);
78696
+ if (agentId) {
78697
+ resultsCache.current.set(getCacheKey(query, "hybrid", "agent"), hybridAgent);
78698
+ resultsCache.current.set(getCacheKey(query, "vector", "agent"), vectorAgent);
78699
+ resultsCache.current.set(getCacheKey(query, "fts", "agent"), ftsAgent);
78700
+ }
78701
+ if (conversationId) {
78702
+ resultsCache.current.set(getCacheKey(query, "hybrid", "conv"), hybridConv);
78703
+ resultsCache.current.set(getCacheKey(query, "vector", "conv"), vectorConv);
78704
+ resultsCache.current.set(getCacheKey(query, "fts", "conv"), ftsConv);
78705
+ }
78706
+ const resultMap = {
78707
+ hybrid: { all: hybridAll, agent: hybridAgent, conv: hybridConv },
78708
+ vector: { all: vectorAll, agent: vectorAgent, conv: vectorConv },
78709
+ fts: { all: ftsAll, agent: ftsAgent, conv: ftsConv }
78710
+ };
78711
+ setResults(resultMap[mode][range2]);
78617
78712
  setSelectedIndex(0);
78618
78713
  } catch (err) {
78619
78714
  setError(err instanceof Error ? err.message : String(err));
@@ -78621,40 +78716,56 @@ function MessageSearch({ onClose, initialQuery }) {
78621
78716
  } finally {
78622
78717
  setLoading(false);
78623
78718
  }
78624
- }, []);
78719
+ }, [fetchSearchResults, getCacheKey, agentId, conversationId]);
78625
78720
  const submitSearch = import_react70.useCallback(() => {
78626
78721
  if (searchInput.trim() && searchInput !== activeQuery) {
78627
78722
  setActiveQuery(searchInput);
78628
- executeSearch(searchInput, searchMode);
78723
+ executeSearch(searchInput, searchMode, searchRange);
78629
78724
  }
78630
- }, [searchInput, activeQuery, searchMode, executeSearch]);
78725
+ }, [searchInput, activeQuery, searchMode, searchRange, executeSearch]);
78631
78726
  const clearSearch = import_react70.useCallback(() => {
78632
78727
  setSearchInput("");
78633
78728
  setActiveQuery("");
78634
78729
  setResults([]);
78635
- setCurrentPage(0);
78636
78730
  setSelectedIndex(0);
78637
78731
  }, []);
78638
- const cycleSearchMode = import_react70.useCallback(() => {
78732
+ const cycleSearchMode = import_react70.useCallback((reverse = false) => {
78639
78733
  setSearchMode((current) => {
78640
78734
  const currentIndex = SEARCH_MODES.indexOf(current);
78641
- const nextIndex = (currentIndex + 1) % SEARCH_MODES.length;
78735
+ const nextIndex = reverse ? (currentIndex - 1 + SEARCH_MODES.length) % SEARCH_MODES.length : (currentIndex + 1) % SEARCH_MODES.length;
78642
78736
  return SEARCH_MODES[nextIndex];
78643
78737
  });
78644
78738
  }, []);
78739
+ const cycleSearchRange = import_react70.useCallback(() => {
78740
+ setSearchRange((current) => {
78741
+ const currentIndex = SEARCH_RANGES.indexOf(current);
78742
+ const nextIndex = (currentIndex + 1) % SEARCH_RANGES.length;
78743
+ return SEARCH_RANGES[nextIndex];
78744
+ });
78745
+ }, []);
78645
78746
  import_react70.useEffect(() => {
78646
78747
  if (activeQuery) {
78647
- executeSearch(activeQuery, searchMode);
78748
+ executeSearch(activeQuery, searchMode, searchRange);
78648
78749
  }
78649
- }, [searchMode, activeQuery, executeSearch]);
78650
- const totalPages = Math.ceil(results.length / DISPLAY_PAGE_SIZE5);
78651
- const startIndex = currentPage * DISPLAY_PAGE_SIZE5;
78652
- const pageResults = results.slice(startIndex, startIndex + DISPLAY_PAGE_SIZE5);
78750
+ }, [searchMode, searchRange, activeQuery, executeSearch]);
78751
+ const startIndex = Math.max(0, Math.min(selectedIndex - 2, results.length - VISIBLE_ITEMS));
78752
+ const visibleResults = results.slice(startIndex, startIndex + VISIBLE_ITEMS);
78653
78753
  use_input_default((input, key) => {
78654
78754
  if (key.ctrl && input === "c") {
78655
78755
  onClose();
78656
78756
  return;
78657
78757
  }
78758
+ if (expandedMessage) {
78759
+ if (key.escape) {
78760
+ setExpandedMessage(null);
78761
+ } else if (key.return && onOpenConversation) {
78762
+ const msgData = expandedMessage;
78763
+ if (msgData.agent_id) {
78764
+ onOpenConversation(msgData.agent_id, msgData.conversation_id);
78765
+ }
78766
+ }
78767
+ return;
78768
+ }
78658
78769
  if (key.escape) {
78659
78770
  if (searchInput || activeQuery) {
78660
78771
  clearSearch();
@@ -78662,94 +78773,209 @@ function MessageSearch({ onClose, initialQuery }) {
78662
78773
  onClose();
78663
78774
  }
78664
78775
  } else if (key.return) {
78665
- submitSearch();
78776
+ if (searchInput.trim() && searchInput !== activeQuery) {
78777
+ submitSearch();
78778
+ } else if (results.length > 0 && results[selectedIndex]) {
78779
+ setExpandedMessage(results[selectedIndex]);
78780
+ }
78666
78781
  } else if (key.backspace || key.delete) {
78667
78782
  setSearchInput((prev) => prev.slice(0, -1));
78668
- } else if (key.tab) {
78783
+ } else if (key.tab && key.shift) {
78669
78784
  cycleSearchMode();
78785
+ } else if (key.tab) {
78786
+ cycleSearchRange();
78670
78787
  } else if (key.upArrow) {
78671
78788
  setSelectedIndex((prev) => Math.max(0, prev - 1));
78672
78789
  } else if (key.downArrow) {
78673
- setSelectedIndex((prev) => Math.min(pageResults.length - 1, prev + 1));
78674
- } else if (input === "j" || input === "J") {
78675
- if (currentPage > 0) {
78676
- setCurrentPage((prev) => prev - 1);
78677
- setSelectedIndex(0);
78678
- }
78679
- } else if (input === "k" || input === "K") {
78680
- if (currentPage < totalPages - 1) {
78681
- setCurrentPage((prev) => prev + 1);
78682
- setSelectedIndex(0);
78683
- }
78790
+ setSelectedIndex((prev) => Math.min(results.length - 1, prev + 1));
78684
78791
  } else if (input && !key.ctrl && !key.meta) {
78685
78792
  setSearchInput((prev) => prev + input);
78686
78793
  }
78687
78794
  });
78795
+ const solidLine = SOLID_LINE16.repeat(Math.max(terminalWidth, 10));
78796
+ const getRangeLabel = (range2) => {
78797
+ switch (range2) {
78798
+ case "all":
78799
+ return "all agents";
78800
+ case "agent":
78801
+ return "this agent";
78802
+ case "conv":
78803
+ return "this conversation";
78804
+ }
78805
+ };
78688
78806
  return /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Box_default, {
78689
78807
  flexDirection: "column",
78690
- gap: 1,
78691
78808
  children: [
78692
- /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Box_default, {
78693
- children: /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Text, {
78694
- bold: true,
78695
- color: colors.selector.title,
78696
- children: "Search messages across all agents"
78697
- }, undefined, false, undefined, this)
78809
+ /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Text, {
78810
+ dimColor: true,
78811
+ children: "> /search"
78812
+ }, undefined, false, undefined, this),
78813
+ /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Text, {
78814
+ dimColor: true,
78815
+ children: solidLine
78698
78816
  }, undefined, false, undefined, this),
78699
78817
  /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Box_default, {
78818
+ height: 1
78819
+ }, undefined, false, undefined, this),
78820
+ expandedMessage && (() => {
78821
+ const msgData = expandedMessage;
78822
+ const fullText = getMessageText(expandedMessage);
78823
+ const msgType = expandedMessage.message_type || "unknown";
78824
+ const isAssistant = msgType === "assistant_message" || msgType === "reasoning_message";
78825
+ const typeLabel = isAssistant ? "Agent message" : "User message";
78826
+ const timestamp = formatLocalTime(msgData.created_at || msgData.date);
78827
+ return /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(jsx_dev_runtime46.Fragment, {
78828
+ children: [
78829
+ /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Box_default, {
78830
+ paddingLeft: 2,
78831
+ children: /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Text, {
78832
+ children: [
78833
+ '"',
78834
+ fullText,
78835
+ '"'
78836
+ ]
78837
+ }, undefined, true, undefined, this)
78838
+ }, undefined, false, undefined, this),
78839
+ /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Box_default, {
78840
+ height: 1
78841
+ }, undefined, false, undefined, this),
78842
+ /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Box_default, {
78843
+ flexDirection: "column",
78844
+ paddingLeft: 2,
78845
+ children: [
78846
+ /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Text, {
78847
+ dimColor: true,
78848
+ children: [
78849
+ typeLabel,
78850
+ ", sent ",
78851
+ timestamp
78852
+ ]
78853
+ }, undefined, true, undefined, this),
78854
+ /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Text, {
78855
+ dimColor: true,
78856
+ children: [
78857
+ "Agent ID: ",
78858
+ msgData.agent_id || "unknown"
78859
+ ]
78860
+ }, undefined, true, undefined, this),
78861
+ msgData.conversation_id && /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Text, {
78862
+ dimColor: true,
78863
+ children: [
78864
+ "Conv ID: ",
78865
+ msgData.conversation_id
78866
+ ]
78867
+ }, undefined, true, undefined, this)
78868
+ ]
78869
+ }, undefined, true, undefined, this),
78870
+ /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Box_default, {
78871
+ height: 1
78872
+ }, undefined, false, undefined, this),
78873
+ /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Box_default, {
78874
+ paddingLeft: 2,
78875
+ children: /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Text, {
78876
+ dimColor: true,
78877
+ children: onOpenConversation ? "Enter to open conversation · Esc cancel" : "Esc cancel"
78878
+ }, undefined, false, undefined, this)
78879
+ }, undefined, false, undefined, this)
78880
+ ]
78881
+ }, undefined, true, undefined, this);
78882
+ })(),
78883
+ !expandedMessage && /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Box_default, {
78700
78884
  flexDirection: "column",
78885
+ gap: 1,
78886
+ marginBottom: 1,
78701
78887
  children: [
78888
+ /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Text, {
78889
+ bold: true,
78890
+ color: colors.selector.title,
78891
+ children: "Search messages across all agents"
78892
+ }, undefined, false, undefined, this),
78702
78893
  /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Box_default, {
78894
+ flexDirection: "column",
78895
+ paddingLeft: 1,
78703
78896
  children: [
78704
- /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Text, {
78705
- dimColor: true,
78706
- children: "Search: "
78707
- }, undefined, false, undefined, this),
78708
- searchInput ? /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(jsx_dev_runtime46.Fragment, {
78897
+ /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Box_default, {
78898
+ flexDirection: "row",
78709
78899
  children: [
78710
78900
  /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Text, {
78711
- children: searchInput
78901
+ dimColor: true,
78902
+ children: " Search: "
78712
78903
  }, undefined, false, undefined, this),
78713
- searchInput !== activeQuery && /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Text, {
78904
+ searchInput ? /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(jsx_dev_runtime46.Fragment, {
78905
+ children: [
78906
+ /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Text, {
78907
+ children: searchInput
78908
+ }, undefined, false, undefined, this),
78909
+ searchInput !== activeQuery && /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Text, {
78910
+ dimColor: true,
78911
+ children: " (press Enter to search)"
78912
+ }, undefined, false, undefined, this)
78913
+ ]
78914
+ }, undefined, true, undefined, this) : /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Text, {
78714
78915
  dimColor: true,
78715
- children: " (press Enter to search)"
78916
+ children: "(type to search)"
78716
78917
  }, undefined, false, undefined, this)
78717
78918
  ]
78718
- }, undefined, true, undefined, this) : /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Text, {
78719
- dimColor: true,
78720
- italic: true,
78721
- children: "(type your query)"
78722
- }, undefined, false, undefined, this)
78723
- ]
78724
- }, undefined, true, undefined, this),
78725
- /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Box_default, {
78726
- children: [
78727
- /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Text, {
78728
- dimColor: true,
78729
- children: "Mode: "
78919
+ }, undefined, true, undefined, this),
78920
+ /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Box_default, {
78921
+ height: 1
78730
78922
  }, undefined, false, undefined, this),
78731
- SEARCH_MODES.map((mode, i) => /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Text, {
78923
+ /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Box_default, {
78924
+ flexDirection: "row",
78732
78925
  children: [
78733
- i > 0 && /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Text, {
78926
+ /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Text, {
78734
78927
  dimColor: true,
78735
- children: " · "
78928
+ children: " Range (tab): "
78736
78929
  }, undefined, false, undefined, this),
78930
+ SEARCH_RANGES.map((range2, i) => {
78931
+ const isActive = range2 === searchRange;
78932
+ return /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Text, {
78933
+ children: [
78934
+ i > 0 && /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Text, {
78935
+ children: " "
78936
+ }, undefined, false, undefined, this),
78937
+ /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Text, {
78938
+ backgroundColor: isActive ? colors.selector.itemHighlighted : undefined,
78939
+ color: isActive ? "black" : undefined,
78940
+ bold: isActive,
78941
+ children: ` ${getRangeLabel(range2)} `
78942
+ }, undefined, false, undefined, this)
78943
+ ]
78944
+ }, range2, true, undefined, this);
78945
+ })
78946
+ ]
78947
+ }, undefined, true, undefined, this),
78948
+ /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Box_default, {
78949
+ flexDirection: "row",
78950
+ children: [
78737
78951
  /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Text, {
78738
- bold: mode === searchMode,
78739
- color: mode === searchMode ? colors.selector.itemHighlighted : undefined,
78740
- children: mode
78741
- }, undefined, false, undefined, this)
78952
+ dimColor: true,
78953
+ children: " Mode (shift-tab): "
78954
+ }, undefined, false, undefined, this),
78955
+ SEARCH_MODES.map((mode, i) => {
78956
+ const isActive = mode === searchMode;
78957
+ return /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Text, {
78958
+ children: [
78959
+ i > 0 && /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Text, {
78960
+ children: " "
78961
+ }, undefined, false, undefined, this),
78962
+ /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Text, {
78963
+ backgroundColor: isActive ? colors.selector.itemHighlighted : undefined,
78964
+ color: isActive ? "black" : undefined,
78965
+ bold: isActive,
78966
+ children: ` ${mode} `
78967
+ }, undefined, false, undefined, this)
78968
+ ]
78969
+ }, mode, true, undefined, this);
78970
+ })
78742
78971
  ]
78743
- }, mode, true, undefined, this)),
78744
- /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Text, {
78745
- dimColor: true,
78746
- children: " (Tab to change)"
78747
- }, undefined, false, undefined, this)
78972
+ }, undefined, true, undefined, this)
78748
78973
  ]
78749
78974
  }, undefined, true, undefined, this)
78750
78975
  ]
78751
78976
  }, undefined, true, undefined, this),
78752
- error && /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Box_default, {
78977
+ !expandedMessage && error && /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Box_default, {
78978
+ paddingLeft: 2,
78753
78979
  children: /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Text, {
78754
78980
  color: "red",
78755
78981
  children: [
@@ -78758,13 +78984,15 @@ function MessageSearch({ onClose, initialQuery }) {
78758
78984
  ]
78759
78985
  }, undefined, true, undefined, this)
78760
78986
  }, undefined, false, undefined, this),
78761
- loading && /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Box_default, {
78987
+ !expandedMessage && loading && /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Box_default, {
78988
+ paddingLeft: 2,
78762
78989
  children: /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Text, {
78763
78990
  dimColor: true,
78764
78991
  children: "Searching..."
78765
78992
  }, undefined, false, undefined, this)
78766
78993
  }, undefined, false, undefined, this),
78767
- !loading && activeQuery && results.length === 0 && /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Box_default, {
78994
+ !expandedMessage && !loading && activeQuery && results.length === 0 && /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Box_default, {
78995
+ paddingLeft: 2,
78768
78996
  children: /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Text, {
78769
78997
  dimColor: true,
78770
78998
  children: [
@@ -78774,22 +79002,24 @@ function MessageSearch({ onClose, initialQuery }) {
78774
79002
  ]
78775
79003
  }, undefined, true, undefined, this)
78776
79004
  }, undefined, false, undefined, this),
78777
- !loading && results.length > 0 && /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Box_default, {
79005
+ !expandedMessage && !loading && results.length > 0 && /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Box_default, {
78778
79006
  flexDirection: "column",
78779
- children: pageResults.map((msg, index) => {
78780
- const isSelected = index === selectedIndex;
79007
+ children: visibleResults.map((msg, visibleIndex) => {
79008
+ const actualIndex = startIndex + visibleIndex;
79009
+ const isSelected = actualIndex === selectedIndex;
78781
79010
  const messageText = getMessageText(msg);
78782
79011
  const msgWithDate = msg;
78783
- const timestamp = msgWithDate.date ? formatRelativeTime5(msgWithDate.date) : "";
78784
- const msgType = (msg.message_type || "unknown").replace("_message", "");
78785
- const agentId = msgWithDate.agent_id || "unknown";
78786
- const conversationId = msgWithDate.conversation_id;
78787
- const createdAt = formatLocalTime(msgWithDate.created_at);
78788
- const metaWidth = timestamp.length + msgType.length + 10;
78789
- const availableWidth = Math.max(20, terminalWidth - metaWidth - 4);
79012
+ const msgType = msg.message_type || "unknown";
79013
+ const agentIdFromMsg = msgWithDate.agent_id || "unknown";
79014
+ const conversationIdFromMsg = msgWithDate.conversation_id;
79015
+ const createdAt = formatLocalTime(msgWithDate.created_at || msgWithDate.date);
79016
+ const isAssistant = msgType === "assistant_message" || msgType === "reasoning_message";
79017
+ const emoji = isAssistant ? "\uD83D\uDC7E" : "\uD83D\uDC64";
79018
+ const availableWidth = Math.max(20, terminalWidth - 8);
78790
79019
  const displayText = truncateText2(messageText.replace(/\n/g, " "), availableWidth);
79020
+ const idToShow = conversationIdFromMsg || agentIdFromMsg;
78791
79021
  const msgId = "message_id" in msg ? String(msg.message_id) : "result";
78792
- const uniqueKey = `${msgId}-${startIndex + index}`;
79022
+ const uniqueKey = `${msgId}-${actualIndex}`;
78793
79023
  return /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Box_default, {
78794
79024
  flexDirection: "column",
78795
79025
  marginBottom: 1,
@@ -78802,10 +79032,15 @@ function MessageSearch({ onClose, initialQuery }) {
78802
79032
  children: isSelected ? ">" : " "
78803
79033
  }, undefined, false, undefined, this),
78804
79034
  /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Text, {
78805
- children: " "
78806
- }, undefined, false, undefined, this),
79035
+ children: [
79036
+ " ",
79037
+ emoji,
79038
+ " "
79039
+ ]
79040
+ }, undefined, true, undefined, this),
78807
79041
  /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Text, {
78808
79042
  bold: isSelected,
79043
+ italic: true,
78809
79044
  color: isSelected ? colors.selector.itemHighlighted : undefined,
78810
79045
  children: displayText
78811
79046
  }, undefined, false, undefined, this)
@@ -78814,95 +79049,53 @@ function MessageSearch({ onClose, initialQuery }) {
78814
79049
  /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Box_default, {
78815
79050
  flexDirection: "row",
78816
79051
  marginLeft: 2,
78817
- children: [
78818
- /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Text, {
78819
- dimColor: true,
78820
- children: [
78821
- msgType,
78822
- timestamp && ` · ${timestamp}`
78823
- ]
78824
- }, undefined, true, undefined, this),
78825
- agentId && /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(jsx_dev_runtime46.Fragment, {
78826
- children: [
78827
- /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Text, {
78828
- dimColor: true,
78829
- children: " · "
78830
- }, undefined, false, undefined, this),
78831
- /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(dist_default4, {
78832
- url: `https://app.letta.com/projects/default-project/agents/${agentId}?searchTerm=${encodeURIComponent(activeQuery)}&messageId=${msgId}${conversationId ? `&conversation=${encodeURIComponent(conversationId)}` : ""}`,
78833
- children: /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Text, {
78834
- color: colors.link.text,
78835
- children: "view message"
78836
- }, undefined, false, undefined, this)
78837
- }, undefined, false, undefined, this),
78838
- /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Text, {
78839
- dimColor: true,
78840
- children: " · agent: "
78841
- }, undefined, false, undefined, this),
78842
- /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(dist_default4, {
78843
- url: `https://app.letta.com/projects/default-project/agents/${agentId}${conversationId ? `?conversation=${encodeURIComponent(conversationId)}` : ""}`,
78844
- children: /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Text, {
78845
- color: colors.link.text,
78846
- children: agentId
78847
- }, undefined, false, undefined, this)
78848
- }, undefined, false, undefined, this)
78849
- ]
78850
- }, undefined, true, undefined, this),
78851
- createdAt && /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Text, {
78852
- dimColor: true,
78853
- children: [
78854
- " · ",
78855
- createdAt
78856
- ]
78857
- }, undefined, true, undefined, this)
78858
- ]
78859
- }, undefined, true, undefined, this)
79052
+ children: /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Text, {
79053
+ dimColor: true,
79054
+ children: [
79055
+ createdAt,
79056
+ idToShow && ` · ${idToShow}`
79057
+ ]
79058
+ }, undefined, true, undefined, this)
79059
+ }, undefined, false, undefined, this)
78860
79060
  ]
78861
79061
  }, uniqueKey, true, undefined, this);
78862
79062
  })
78863
79063
  }, undefined, false, undefined, this),
78864
- /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Box_default, {
79064
+ !expandedMessage && /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Box_default, {
78865
79065
  flexDirection: "column",
78866
79066
  marginTop: 1,
79067
+ paddingLeft: 2,
78867
79068
  children: [
78868
- results.length > 0 && /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Box_default, {
78869
- children: /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Text, {
78870
- dimColor: true,
78871
- children: [
78872
- "Page ",
78873
- currentPage + 1,
78874
- "/",
78875
- totalPages || 1,
78876
- " (",
78877
- results.length,
78878
- " ",
78879
- "results)"
78880
- ]
78881
- }, undefined, true, undefined, this)
78882
- }, undefined, false, undefined, this),
78883
- /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Box_default, {
78884
- children: /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Text, {
78885
- dimColor: true,
78886
- children: "Type + Enter to search · Tab mode · J/K page · Esc close"
78887
- }, undefined, false, undefined, this)
79069
+ results.length > 0 && /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Text, {
79070
+ dimColor: true,
79071
+ children: [
79072
+ selectedIndex + 1,
79073
+ "/",
79074
+ results.length,
79075
+ " results"
79076
+ ]
79077
+ }, undefined, true, undefined, this),
79078
+ /* @__PURE__ */ jsx_dev_runtime46.jsxDEV(Text, {
79079
+ dimColor: true,
79080
+ children: "Enter expand · ↑↓ navigate · Esc close"
78888
79081
  }, undefined, false, undefined, this)
78889
79082
  ]
78890
79083
  }, undefined, true, undefined, this)
78891
79084
  ]
78892
79085
  }, undefined, true, undefined, this);
78893
79086
  }
78894
- var import_react70, jsx_dev_runtime46, DISPLAY_PAGE_SIZE5 = 5, SEARCH_LIMIT = 100, SEARCH_MODES;
79087
+ var import_react70, jsx_dev_runtime46, SOLID_LINE16 = "─", VISIBLE_ITEMS = 5, SEARCH_LIMIT = 100, SEARCH_MODES, SEARCH_RANGES;
78895
79088
  var init_MessageSearch = __esm(async () => {
78896
79089
  init_useTerminalWidth();
78897
79090
  init_colors();
78898
79091
  await __promiseAll([
78899
79092
  init_build2(),
78900
- init_dist4(),
78901
79093
  init_client2()
78902
79094
  ]);
78903
79095
  import_react70 = __toESM(require_react(), 1);
78904
79096
  jsx_dev_runtime46 = __toESM(require_jsx_dev_runtime(), 1);
78905
- SEARCH_MODES = ["hybrid", "vector", "fts"];
79097
+ SEARCH_MODES = ["fts", "vector", "hybrid"];
79098
+ SEARCH_RANGES = ["all", "agent", "conv"];
78906
79099
  });
78907
79100
 
78908
79101
  // src/cli/components/ModelSelector.tsx
@@ -78914,7 +79107,7 @@ function ModelSelector({
78914
79107
  forceRefresh: forceRefreshOnMount
78915
79108
  }) {
78916
79109
  const terminalWidth = useTerminalWidth();
78917
- const solidLine = SOLID_LINE16.repeat(Math.max(terminalWidth, 10));
79110
+ const solidLine = SOLID_LINE17.repeat(Math.max(terminalWidth, 10));
78918
79111
  const typedModels = models;
78919
79112
  const [category, setCategory] = import_react71.useState("supported");
78920
79113
  const [selectedIndex, setSelectedIndex] = import_react71.useState(0);
@@ -78997,7 +79190,7 @@ function ModelSelector({
78997
79190
  description: ""
78998
79191
  }));
78999
79192
  }, [category, supportedModels, otherModelHandles]);
79000
- const visibleCount = VISIBLE_ITEMS - 1;
79193
+ const visibleCount = VISIBLE_ITEMS2 - 1;
79001
79194
  const startIndex = import_react71.useMemo(() => {
79002
79195
  if (selectedIndex < visibleCount)
79003
79196
  return 0;
@@ -79245,7 +79438,7 @@ function ModelSelector({
79245
79438
  ]
79246
79439
  }, undefined, true, undefined, this);
79247
79440
  }
79248
- var import_react71, jsx_dev_runtime47, SOLID_LINE16 = "─", VISIBLE_ITEMS = 8, MODEL_CATEGORIES;
79441
+ var import_react71, jsx_dev_runtime47, SOLID_LINE17 = "─", VISIBLE_ITEMS2 = 8, MODEL_CATEGORIES;
79249
79442
  var init_ModelSelector = __esm(async () => {
79250
79443
  init_model();
79251
79444
  init_useTerminalWidth();
@@ -79476,7 +79669,7 @@ var init_PinDialog = __esm(async () => {
79476
79669
  // src/cli/components/NewAgentDialog.tsx
79477
79670
  function NewAgentDialog({ onSubmit, onCancel }) {
79478
79671
  const terminalWidth = useTerminalWidth();
79479
- const solidLine = SOLID_LINE17.repeat(Math.max(terminalWidth, 10));
79672
+ const solidLine = SOLID_LINE18.repeat(Math.max(terminalWidth, 10));
79480
79673
  const [nameInput, setNameInput] = import_react73.useState("");
79481
79674
  const [error, setError] = import_react73.useState("");
79482
79675
  use_input_default((input, key) => {
@@ -79584,7 +79777,7 @@ function NewAgentDialog({ onSubmit, onCancel }) {
79584
79777
  ]
79585
79778
  }, undefined, true, undefined, this);
79586
79779
  }
79587
- var import_react73, jsx_dev_runtime49, SOLID_LINE17 = "─";
79780
+ var import_react73, jsx_dev_runtime49, SOLID_LINE18 = "─";
79588
79781
  var init_NewAgentDialog = __esm(async () => {
79589
79782
  init_constants();
79590
79783
  init_useTerminalWidth();
@@ -80508,7 +80701,7 @@ function SystemPromptSelector({
80508
80701
  onCancel
80509
80702
  }) {
80510
80703
  const terminalWidth = useTerminalWidth();
80511
- const solidLine = SOLID_LINE18.repeat(Math.max(terminalWidth, 10));
80704
+ const solidLine = SOLID_LINE19.repeat(Math.max(terminalWidth, 10));
80512
80705
  const [showAll, setShowAll] = import_react80.useState(false);
80513
80706
  const [selectedIndex, setSelectedIndex] = import_react80.useState(0);
80514
80707
  const featuredPrompts = import_react80.useMemo(() => SYSTEM_PROMPTS.filter((prompt) => prompt.isFeatured), []);
@@ -80629,7 +80822,7 @@ function SystemPromptSelector({
80629
80822
  ]
80630
80823
  }, undefined, true, undefined, this);
80631
80824
  }
80632
- var import_react80, jsx_dev_runtime56, SOLID_LINE18 = "─";
80825
+ var import_react80, jsx_dev_runtime56, SOLID_LINE19 = "─";
80633
80826
  var init_SystemPromptSelector = __esm(async () => {
80634
80827
  init_promptAssets();
80635
80828
  init_useTerminalWidth();
@@ -82302,7 +82495,7 @@ function ToolsetSelector({
82302
82495
  onCancel
82303
82496
  }) {
82304
82497
  const terminalWidth = useTerminalWidth();
82305
- const solidLine = SOLID_LINE19.repeat(Math.max(terminalWidth, 10));
82498
+ const solidLine = SOLID_LINE20.repeat(Math.max(terminalWidth, 10));
82306
82499
  const [showAll, setShowAll] = import_react82.useState(false);
82307
82500
  const [selectedIndex, setSelectedIndex] = import_react82.useState(0);
82308
82501
  const featuredToolsets = import_react82.useMemo(() => toolsets.filter((toolset) => toolset.isFeatured), []);
@@ -82429,7 +82622,7 @@ function ToolsetSelector({
82429
82622
  ]
82430
82623
  }, undefined, true, undefined, this);
82431
82624
  }
82432
- var import_react82, jsx_dev_runtime61, SOLID_LINE19 = "─", toolsets;
82625
+ var import_react82, jsx_dev_runtime61, SOLID_LINE20 = "─", toolsets;
82433
82626
  var init_ToolsetSelector = __esm(async () => {
82434
82627
  init_useTerminalWidth();
82435
82628
  init_colors();
@@ -85810,7 +86003,7 @@ ${newState.originalPrompt}`
85810
86003
  import_react86.useEffect(() => {
85811
86004
  processConversationRef.current = processConversation;
85812
86005
  }, [processConversation]);
85813
- const handleAgentSelect = import_react86.useCallback(async (targetAgentId, _opts) => {
86006
+ const handleAgentSelect = import_react86.useCallback(async (targetAgentId, opts) => {
85814
86007
  setActiveOverlay(null);
85815
86008
  if (targetAgentId === agentId) {
85816
86009
  const label = agentName || targetAgentId.slice(0, 12);
@@ -85860,7 +86053,7 @@ ${newState.originalPrompt}`
85860
86053
  try {
85861
86054
  const client = await getClient2();
85862
86055
  const agent = await client.agents.retrieve(targetAgentId);
85863
- const targetConversationId = "default";
86056
+ const targetConversationId = opts?.conversationId ?? "default";
85864
86057
  await updateProjectSettings({ lastAgent: targetAgentId });
85865
86058
  settingsManager.setLocalLastSession({ agentId: targetAgentId, conversationId: targetConversationId }, process.cwd());
85866
86059
  settingsManager.setGlobalLastSession({
@@ -85880,7 +86073,12 @@ ${newState.originalPrompt}`
85880
86073
  setLlmConfig(agent.llm_config);
85881
86074
  setConversationId3(targetConversationId);
85882
86075
  const agentLabel = agent.name || targetAgentId;
85883
- const successOutput = [
86076
+ const isSpecificConv = opts?.conversationId && opts.conversationId !== "default";
86077
+ const successOutput = isSpecificConv ? [
86078
+ `Switched to **${agentLabel}**`,
86079
+ `⎿ Conversation: ${opts.conversationId}`
86080
+ ].join(`
86081
+ `) : [
85884
86082
  `Resumed the default conversation with **${agentLabel}**.`,
85885
86083
  `⎿ Type /resume to browse all conversations`,
85886
86084
  `⎿ Type /new to start a new conversation`
@@ -86788,7 +86986,7 @@ Type your task to begin the loop.`,
86788
86986
  return { submitted: true };
86789
86987
  }
86790
86988
  const client = await getClient2();
86791
- const result2 = await client.agents.messages.compact(agentId);
86989
+ const result2 = await client.conversations.messages.compact(conversationIdRef.current);
86792
86990
  const outputLines = [
86793
86991
  `Compaction completed. Message buffer length reduced from ${result2.num_messages_before} to ${result2.num_messages_after}.`,
86794
86992
  "",
@@ -89329,9 +89527,12 @@ Plan file path: ${planFilePath}`;
89329
89527
  line: item
89330
89528
  }, undefined, false, undefined, this) : item.kind === "status" ? /* @__PURE__ */ jsx_dev_runtime63.jsxDEV(StatusMessage, {
89331
89529
  line: item
89332
- }, undefined, false, undefined, this) : item.kind === "separator" ? /* @__PURE__ */ jsx_dev_runtime63.jsxDEV(Text, {
89333
- dimColor: true,
89334
- children: "─".repeat(columns)
89530
+ }, undefined, false, undefined, this) : item.kind === "separator" ? /* @__PURE__ */ jsx_dev_runtime63.jsxDEV(Box_default, {
89531
+ marginTop: 1,
89532
+ children: /* @__PURE__ */ jsx_dev_runtime63.jsxDEV(Text, {
89533
+ dimColor: true,
89534
+ children: "─".repeat(columns)
89535
+ }, undefined, false, undefined, this)
89335
89536
  }, undefined, false, undefined, this) : item.kind === "command" ? /* @__PURE__ */ jsx_dev_runtime63.jsxDEV(CommandMessage, {
89336
89537
  line: item
89337
89538
  }, undefined, false, undefined, this) : item.kind === "bash_command" ? /* @__PURE__ */ jsx_dev_runtime63.jsxDEV(BashCommandMessage, {
@@ -89766,7 +89967,147 @@ Plan file path: ${planFilePath}`;
89766
89967
  }, undefined, false, undefined, this),
89767
89968
  activeOverlay === "search" && /* @__PURE__ */ jsx_dev_runtime63.jsxDEV(MessageSearch, {
89768
89969
  onClose: closeOverlay,
89769
- initialQuery: searchQuery || undefined
89970
+ initialQuery: searchQuery || undefined,
89971
+ agentId,
89972
+ conversationId,
89973
+ onOpenConversation: async (targetAgentId, targetConvId) => {
89974
+ closeOverlay();
89975
+ if (targetAgentId !== agentId) {
89976
+ await handleAgentSelect(targetAgentId, {
89977
+ conversationId: targetConvId
89978
+ });
89979
+ return;
89980
+ }
89981
+ const actualTargetConv = targetConvId || "default";
89982
+ if (actualTargetConv === conversationId) {
89983
+ return;
89984
+ }
89985
+ if (isAgentBusy()) {
89986
+ setQueuedOverlayAction({
89987
+ type: "switch_conversation",
89988
+ conversationId: actualTargetConv
89989
+ });
89990
+ const cmdId2 = uid4("cmd");
89991
+ buffersRef.current.byId.set(cmdId2, {
89992
+ kind: "command",
89993
+ id: cmdId2,
89994
+ input: "/search",
89995
+ output: `Conversation switch queued – will switch after current task completes`,
89996
+ phase: "finished",
89997
+ success: true
89998
+ });
89999
+ buffersRef.current.order.push(cmdId2);
90000
+ refreshDerived();
90001
+ return;
90002
+ }
90003
+ setCommandRunning(true);
90004
+ const cmdId = uid4("cmd");
90005
+ buffersRef.current.byId.set(cmdId, {
90006
+ kind: "command",
90007
+ id: cmdId,
90008
+ input: "/search",
90009
+ output: "Switching conversation...",
90010
+ phase: "running"
90011
+ });
90012
+ buffersRef.current.order.push(cmdId);
90013
+ refreshDerived();
90014
+ try {
90015
+ if (agentState) {
90016
+ const client = await getClient2();
90017
+ const resumeData = await getResumeData2(client, agentState, actualTargetConv);
90018
+ setConversationId3(actualTargetConv);
90019
+ settingsManager.setLocalLastSession({ agentId, conversationId: actualTargetConv }, process.cwd());
90020
+ settingsManager.setGlobalLastSession({
90021
+ agentId,
90022
+ conversationId: actualTargetConv
90023
+ });
90024
+ buffersRef.current.byId.clear();
90025
+ buffersRef.current.order = [];
90026
+ buffersRef.current.tokenCount = 0;
90027
+ emittedIdsRef.current.clear();
90028
+ setStaticItems([]);
90029
+ setStaticRenderEpoch((e) => e + 1);
90030
+ const currentAgentName = agentState.name || "Unnamed Agent";
90031
+ const successOutput = [
90032
+ `Switched to conversation with "${currentAgentName}"`,
90033
+ `⎿ Conversation: ${actualTargetConv}`
90034
+ ].join(`
90035
+ `);
90036
+ const successItem = {
90037
+ kind: "command",
90038
+ id: uid4("cmd"),
90039
+ input: "/search",
90040
+ output: successOutput,
90041
+ phase: "finished",
90042
+ success: true
90043
+ };
90044
+ if (resumeData.messageHistory.length > 0) {
90045
+ hasBackfilledRef.current = false;
90046
+ backfillBuffers(buffersRef.current, resumeData.messageHistory);
90047
+ const backfilledItems = [];
90048
+ for (const id of buffersRef.current.order) {
90049
+ const ln = buffersRef.current.byId.get(id);
90050
+ if (!ln)
90051
+ continue;
90052
+ emittedIdsRef.current.add(id);
90053
+ backfilledItems.push({ ...ln });
90054
+ }
90055
+ const separator = {
90056
+ kind: "separator",
90057
+ id: uid4("sep")
90058
+ };
90059
+ setStaticItems([
90060
+ separator,
90061
+ ...backfilledItems,
90062
+ successItem
90063
+ ]);
90064
+ setLines(toLines(buffersRef.current));
90065
+ hasBackfilledRef.current = true;
90066
+ } else {
90067
+ const separator = {
90068
+ kind: "separator",
90069
+ id: uid4("sep")
90070
+ };
90071
+ setStaticItems([separator, successItem]);
90072
+ setLines(toLines(buffersRef.current));
90073
+ }
90074
+ if (resumeData.pendingApprovals.length > 0) {
90075
+ setPendingApprovals(resumeData.pendingApprovals);
90076
+ try {
90077
+ const contexts = await Promise.all(resumeData.pendingApprovals.map(async (approval) => {
90078
+ const parsedArgs = safeJsonParseOr(approval.toolArgs, {});
90079
+ return await analyzeToolApproval(approval.toolName, parsedArgs);
90080
+ }));
90081
+ setApprovalContexts(contexts);
90082
+ } catch {}
90083
+ }
90084
+ }
90085
+ } catch (error) {
90086
+ let errorMsg = "Unknown error";
90087
+ if (error instanceof APIError2) {
90088
+ if (error.status === 404) {
90089
+ errorMsg = "Conversation not found";
90090
+ } else if (error.status === 422) {
90091
+ errorMsg = "Invalid conversation ID";
90092
+ } else {
90093
+ errorMsg = error.message;
90094
+ }
90095
+ } else if (error instanceof Error) {
90096
+ errorMsg = error.message;
90097
+ }
90098
+ buffersRef.current.byId.set(cmdId, {
90099
+ kind: "command",
90100
+ id: cmdId,
90101
+ input: "/search",
90102
+ output: `Failed: ${errorMsg}`,
90103
+ phase: "finished",
90104
+ success: false
90105
+ });
90106
+ refreshDerived();
90107
+ } finally {
90108
+ setCommandRunning(false);
90109
+ }
90110
+ }
89770
90111
  }, undefined, false, undefined, this),
89771
90112
  activeOverlay === "feedback" && /* @__PURE__ */ jsx_dev_runtime63.jsxDEV(FeedbackDialog, {
89772
90113
  onSubmit: handleFeedbackSubmit,
@@ -94648,4 +94989,4 @@ Error during initialization: ${message}`);
94648
94989
  }
94649
94990
  main();
94650
94991
 
94651
- //# debugId=24E1A24D9A66945964756E2164756E21
94992
+ //# debugId=0D26B6A9B64965F064756E2164756E21
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@letta-ai/letta-code",
3
- "version": "0.13.7",
3
+ "version": "0.13.8",
4
4
  "description": "Letta Code is a CLI tool for interacting with stateful Letta agents from the terminal.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -30,7 +30,7 @@
30
30
  "access": "public"
31
31
  },
32
32
  "dependencies": {
33
- "@letta-ai/letta-client": "^1.7.2",
33
+ "@letta-ai/letta-client": "1.7.5",
34
34
  "glob": "^13.0.0",
35
35
  "ink-link": "^5.0.0",
36
36
  "open": "^10.2.0",