@letta-ai/letta-code 0.28.12 → 0.28.13
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 +351 -359
- package/package.json +1 -1
- package/scripts/source-file-size-baseline.json +2 -2
package/letta.js
CHANGED
|
@@ -4853,7 +4853,7 @@ var package_default;
|
|
|
4853
4853
|
var init_package = __esm(() => {
|
|
4854
4854
|
package_default = {
|
|
4855
4855
|
name: "@letta-ai/letta-code",
|
|
4856
|
-
version: "0.28.
|
|
4856
|
+
version: "0.28.13",
|
|
4857
4857
|
description: "Letta Code is a CLI tool for interacting with stateful Letta agents from the terminal.",
|
|
4858
4858
|
type: "module",
|
|
4859
4859
|
packageManager: "bun@1.3.0",
|
|
@@ -441753,6 +441753,115 @@ var init_PasteAwareTextInput = __esm(async () => {
|
|
|
441753
441753
|
OPTION_RIGHT_PATTERN = /^\u001b\[(?:1;)?(?:3|4|7|8|9)C$/;
|
|
441754
441754
|
});
|
|
441755
441755
|
|
|
441756
|
+
// src/agent/favorites.ts
|
|
441757
|
+
function generateFavoriteTag(ownerId) {
|
|
441758
|
+
return `${LETTA_CHAT_FAVORITE_TAG_PREFIX}${ownerId}`;
|
|
441759
|
+
}
|
|
441760
|
+
async function fetchCurrentUserMetadata() {
|
|
441761
|
+
if (currentUserMetadataFetcherOverride) {
|
|
441762
|
+
return currentUserMetadataFetcherOverride();
|
|
441763
|
+
}
|
|
441764
|
+
return apiRequest("GET", "/v1/metadata/user");
|
|
441765
|
+
}
|
|
441766
|
+
async function getCurrentCloudFavoriteTag() {
|
|
441767
|
+
try {
|
|
441768
|
+
const user = await fetchCurrentUserMetadata();
|
|
441769
|
+
return typeof user.id === "string" && user.id ? generateFavoriteTag(user.id) : null;
|
|
441770
|
+
} catch {
|
|
441771
|
+
return null;
|
|
441772
|
+
}
|
|
441773
|
+
}
|
|
441774
|
+
async function getFavoriteTagForAgent(agentId) {
|
|
441775
|
+
if (isLocalAgentId(agentId)) {
|
|
441776
|
+
return LOCAL_DESKTOP_FAVORITE_TAG;
|
|
441777
|
+
}
|
|
441778
|
+
return getCurrentCloudFavoriteTag();
|
|
441779
|
+
}
|
|
441780
|
+
function getAgentTags(agent2) {
|
|
441781
|
+
return Array.isArray(agent2.tags) ? agent2.tags : [];
|
|
441782
|
+
}
|
|
441783
|
+
function addFavoriteTag(tags, favoriteTag) {
|
|
441784
|
+
if (tags.includes(favoriteTag))
|
|
441785
|
+
return tags;
|
|
441786
|
+
return [favoriteTag, ...tags];
|
|
441787
|
+
}
|
|
441788
|
+
function removeFavoriteTag(tags, favoriteTag) {
|
|
441789
|
+
return tags.filter((tag) => tag !== favoriteTag && tag !== LETTA_CHAT_FAVORITE_TAG_BASE);
|
|
441790
|
+
}
|
|
441791
|
+
function arraysEqual2(a2, b3) {
|
|
441792
|
+
return a2.length === b3.length && a2.every((value, index) => value === b3[index]);
|
|
441793
|
+
}
|
|
441794
|
+
async function setAgentFavoriteTag(backend4, agentId) {
|
|
441795
|
+
const favoriteTag = await getFavoriteTagForAgent(agentId);
|
|
441796
|
+
if (!favoriteTag)
|
|
441797
|
+
return "unavailable";
|
|
441798
|
+
const agent2 = await backend4.retrieveAgent(agentId, {
|
|
441799
|
+
include: ["agent.tags"]
|
|
441800
|
+
});
|
|
441801
|
+
const tags = getAgentTags(agent2);
|
|
441802
|
+
const nextTags = addFavoriteTag(tags, favoriteTag);
|
|
441803
|
+
if (arraysEqual2(tags, nextTags))
|
|
441804
|
+
return "unchanged";
|
|
441805
|
+
await backend4.updateAgent(agentId, { tags: nextTags });
|
|
441806
|
+
return "changed";
|
|
441807
|
+
}
|
|
441808
|
+
async function unsetAgentFavoriteTag(backend4, agentId) {
|
|
441809
|
+
const favoriteTag = await getFavoriteTagForAgent(agentId);
|
|
441810
|
+
if (!favoriteTag)
|
|
441811
|
+
return "unavailable";
|
|
441812
|
+
const agent2 = await backend4.retrieveAgent(agentId, {
|
|
441813
|
+
include: ["agent.tags"]
|
|
441814
|
+
});
|
|
441815
|
+
const tags = getAgentTags(agent2);
|
|
441816
|
+
const nextTags = removeFavoriteTag(tags, favoriteTag);
|
|
441817
|
+
if (arraysEqual2(tags, nextTags))
|
|
441818
|
+
return "unchanged";
|
|
441819
|
+
await backend4.updateAgent(agentId, { tags: nextTags });
|
|
441820
|
+
return "changed";
|
|
441821
|
+
}
|
|
441822
|
+
async function pinAgentForCurrentUser(agentId, backend4 = getBackend()) {
|
|
441823
|
+
const wasPinnedInSettings = settingsManager.isAgentPinned(agentId);
|
|
441824
|
+
try {
|
|
441825
|
+
const result = await setAgentFavoriteTag(backend4, agentId);
|
|
441826
|
+
if (result !== "unavailable") {
|
|
441827
|
+
if (wasPinnedInSettings) {
|
|
441828
|
+
settingsManager.unpinAgent(agentId);
|
|
441829
|
+
}
|
|
441830
|
+
return result === "unchanged" || wasPinnedInSettings ? "already-pinned" : "pinned";
|
|
441831
|
+
}
|
|
441832
|
+
} catch {}
|
|
441833
|
+
if (wasPinnedInSettings)
|
|
441834
|
+
return "already-pinned";
|
|
441835
|
+
settingsManager.pinAgent(agentId);
|
|
441836
|
+
return "pinned";
|
|
441837
|
+
}
|
|
441838
|
+
async function unpinAgentForCurrentUser(agentId, backend4 = getBackend()) {
|
|
441839
|
+
const wasPinnedInSettings = settingsManager.isAgentPinned(agentId);
|
|
441840
|
+
try {
|
|
441841
|
+
const result = await unsetAgentFavoriteTag(backend4, agentId);
|
|
441842
|
+
if (result !== "unavailable") {
|
|
441843
|
+
if (wasPinnedInSettings) {
|
|
441844
|
+
settingsManager.unpinAgent(agentId);
|
|
441845
|
+
}
|
|
441846
|
+
return result === "changed" || wasPinnedInSettings ? "unpinned" : "not-pinned";
|
|
441847
|
+
}
|
|
441848
|
+
} catch (error54) {
|
|
441849
|
+
if (!wasPinnedInSettings)
|
|
441850
|
+
throw error54;
|
|
441851
|
+
}
|
|
441852
|
+
if (!wasPinnedInSettings)
|
|
441853
|
+
return "not-pinned";
|
|
441854
|
+
settingsManager.unpinAgent(agentId);
|
|
441855
|
+
return "unpinned";
|
|
441856
|
+
}
|
|
441857
|
+
var LETTA_CHAT_FAVORITE_TAG_BASE = "view:letta-chat", LETTA_CHAT_FAVORITE_TAG_PREFIX = "favorite:user:", LOCAL_FAVORITE_OWNER_ID = "local", LOCAL_DESKTOP_FAVORITE_TAG, currentUserMetadataFetcherOverride = null;
|
|
441858
|
+
var init_favorites = __esm(() => {
|
|
441859
|
+
init_backend2();
|
|
441860
|
+
init_request();
|
|
441861
|
+
init_settings_manager();
|
|
441862
|
+
LOCAL_DESKTOP_FAVORITE_TAG = generateFavoriteTag(LOCAL_FAVORITE_OWNER_ID);
|
|
441863
|
+
});
|
|
441864
|
+
|
|
441756
441865
|
// src/backend/local/index.ts
|
|
441757
441866
|
var init_local = __esm(() => {
|
|
441758
441867
|
init_context_window_overflow();
|
|
@@ -441796,6 +441905,78 @@ var init_local_agent_listing = __esm(() => {
|
|
|
441796
441905
|
init_paths();
|
|
441797
441906
|
});
|
|
441798
441907
|
|
|
441908
|
+
// src/cli/helpers/pinned-agent-listing.ts
|
|
441909
|
+
function hasCloudCredentials2() {
|
|
441910
|
+
if (process.env.LETTA_API_KEY)
|
|
441911
|
+
return true;
|
|
441912
|
+
const settings3 = settingsManager.getSettings();
|
|
441913
|
+
const cached3 = settingsManager.getCachedSecureTokens();
|
|
441914
|
+
return Boolean(cached3.apiKey || cached3.refreshToken || settings3.refreshToken || settings3.env?.LETTA_API_KEY);
|
|
441915
|
+
}
|
|
441916
|
+
async function listCloudFavoriteAgents2() {
|
|
441917
|
+
if (!hasCloudCredentials2())
|
|
441918
|
+
return [];
|
|
441919
|
+
try {
|
|
441920
|
+
const favoriteTag = await getCurrentCloudFavoriteTag();
|
|
441921
|
+
if (!favoriteTag)
|
|
441922
|
+
return [];
|
|
441923
|
+
const page = await getBackendForMode("api").listAgents({
|
|
441924
|
+
limit: PINNED_AGENT_LIMIT2,
|
|
441925
|
+
include: ["agent.blocks"],
|
|
441926
|
+
order: "desc",
|
|
441927
|
+
order_by: "last_run_completion",
|
|
441928
|
+
tags: [favoriteTag]
|
|
441929
|
+
});
|
|
441930
|
+
return Array.isArray(page) ? page : page.items ?? [];
|
|
441931
|
+
} catch {
|
|
441932
|
+
return [];
|
|
441933
|
+
}
|
|
441934
|
+
}
|
|
441935
|
+
async function retrieveLegacyPin2(agentId, backendMode) {
|
|
441936
|
+
if (backendMode === "api" && !hasCloudCredentials2()) {
|
|
441937
|
+
return { agentId, agent: null, error: "Not signed in", backendMode };
|
|
441938
|
+
}
|
|
441939
|
+
try {
|
|
441940
|
+
const agent2 = await getBackendForMode(backendMode).retrieveAgent(agentId, {
|
|
441941
|
+
include: ["agent.blocks"]
|
|
441942
|
+
});
|
|
441943
|
+
return { agentId, agent: agent2, error: null, backendMode };
|
|
441944
|
+
} catch {
|
|
441945
|
+
return { agentId, agent: null, error: "Agent not found", backendMode };
|
|
441946
|
+
}
|
|
441947
|
+
}
|
|
441948
|
+
async function listPinnedAgentsForCurrentUser2(backendModes = ["api", "local"]) {
|
|
441949
|
+
const modes = new Set(backendModes);
|
|
441950
|
+
const legacyPins = [...modes].flatMap((backendMode) => settingsManager.getPinnedAgentsForBackendMode(backendMode).map((agentId) => ({ agentId, backendMode })));
|
|
441951
|
+
const seen = new Set(legacyPins.map(({ agentId, backendMode }) => `${backendMode}:${agentId}`));
|
|
441952
|
+
const legacyData = await Promise.all(legacyPins.map(({ agentId, backendMode }) => retrieveLegacyPin2(agentId, backendMode)));
|
|
441953
|
+
const favoriteAgents = [];
|
|
441954
|
+
if (modes.has("local")) {
|
|
441955
|
+
favoriteAgents.push(...listLocalAgentsFromDisk().filter((agent2) => getAgentTags(agent2).includes(LOCAL_DESKTOP_FAVORITE_TAG)).map((agent2) => ({ agent: agent2, backendMode: "local" })));
|
|
441956
|
+
}
|
|
441957
|
+
if (modes.has("api")) {
|
|
441958
|
+
favoriteAgents.push(...(await listCloudFavoriteAgents2()).map((agent2) => ({
|
|
441959
|
+
agent: agent2,
|
|
441960
|
+
backendMode: "api"
|
|
441961
|
+
})));
|
|
441962
|
+
}
|
|
441963
|
+
const favoriteData = favoriteAgents.flatMap(({ agent: agent2, backendMode }) => {
|
|
441964
|
+
const key2 = `${backendMode}:${agent2.id}`;
|
|
441965
|
+
if (seen.has(key2))
|
|
441966
|
+
return [];
|
|
441967
|
+
seen.add(key2);
|
|
441968
|
+
return [{ agentId: agent2.id, agent: agent2, error: null, backendMode }];
|
|
441969
|
+
});
|
|
441970
|
+
return [...legacyData, ...favoriteData];
|
|
441971
|
+
}
|
|
441972
|
+
var PINNED_AGENT_LIMIT2 = 100;
|
|
441973
|
+
var init_pinned_agent_listing = __esm(() => {
|
|
441974
|
+
init_favorites();
|
|
441975
|
+
init_backend();
|
|
441976
|
+
init_settings_manager();
|
|
441977
|
+
init_local_agent_listing();
|
|
441978
|
+
});
|
|
441979
|
+
|
|
441799
441980
|
// src/cli/components/ModelReasoningSelector.tsx
|
|
441800
441981
|
function formatEffortLabel(effort, hasDistinctMaxTier) {
|
|
441801
441982
|
if (effort === "none")
|
|
@@ -473059,115 +473240,6 @@ var init_setup_ui = __esm(async () => {
|
|
|
473059
473240
|
jsx_dev_runtime14 = __toESM(require_jsx_dev_runtime(), 1);
|
|
473060
473241
|
});
|
|
473061
473242
|
|
|
473062
|
-
// src/agent/favorites.ts
|
|
473063
|
-
function generateFavoriteTag(ownerId) {
|
|
473064
|
-
return `${LETTA_CHAT_FAVORITE_TAG_PREFIX}${ownerId}`;
|
|
473065
|
-
}
|
|
473066
|
-
async function fetchCurrentUserMetadata() {
|
|
473067
|
-
if (currentUserMetadataFetcherOverride) {
|
|
473068
|
-
return currentUserMetadataFetcherOverride();
|
|
473069
|
-
}
|
|
473070
|
-
return apiRequest("GET", "/v1/metadata/user");
|
|
473071
|
-
}
|
|
473072
|
-
async function getCurrentCloudFavoriteTag() {
|
|
473073
|
-
try {
|
|
473074
|
-
const user = await fetchCurrentUserMetadata();
|
|
473075
|
-
return typeof user.id === "string" && user.id ? generateFavoriteTag(user.id) : null;
|
|
473076
|
-
} catch {
|
|
473077
|
-
return null;
|
|
473078
|
-
}
|
|
473079
|
-
}
|
|
473080
|
-
async function getFavoriteTagForAgent(agentId) {
|
|
473081
|
-
if (isLocalAgentId(agentId)) {
|
|
473082
|
-
return LOCAL_DESKTOP_FAVORITE_TAG;
|
|
473083
|
-
}
|
|
473084
|
-
return getCurrentCloudFavoriteTag();
|
|
473085
|
-
}
|
|
473086
|
-
function getAgentTags(agent2) {
|
|
473087
|
-
return Array.isArray(agent2.tags) ? agent2.tags : [];
|
|
473088
|
-
}
|
|
473089
|
-
function addFavoriteTag(tags, favoriteTag) {
|
|
473090
|
-
if (tags.includes(favoriteTag))
|
|
473091
|
-
return tags;
|
|
473092
|
-
return [favoriteTag, ...tags];
|
|
473093
|
-
}
|
|
473094
|
-
function removeFavoriteTag(tags, favoriteTag) {
|
|
473095
|
-
return tags.filter((tag) => tag !== favoriteTag && tag !== LETTA_CHAT_FAVORITE_TAG_BASE);
|
|
473096
|
-
}
|
|
473097
|
-
function arraysEqual2(a2, b3) {
|
|
473098
|
-
return a2.length === b3.length && a2.every((value, index) => value === b3[index]);
|
|
473099
|
-
}
|
|
473100
|
-
async function setAgentFavoriteTag(backend4, agentId) {
|
|
473101
|
-
const favoriteTag = await getFavoriteTagForAgent(agentId);
|
|
473102
|
-
if (!favoriteTag)
|
|
473103
|
-
return "unavailable";
|
|
473104
|
-
const agent2 = await backend4.retrieveAgent(agentId, {
|
|
473105
|
-
include: ["agent.tags"]
|
|
473106
|
-
});
|
|
473107
|
-
const tags = getAgentTags(agent2);
|
|
473108
|
-
const nextTags = addFavoriteTag(tags, favoriteTag);
|
|
473109
|
-
if (arraysEqual2(tags, nextTags))
|
|
473110
|
-
return "unchanged";
|
|
473111
|
-
await backend4.updateAgent(agentId, { tags: nextTags });
|
|
473112
|
-
return "changed";
|
|
473113
|
-
}
|
|
473114
|
-
async function unsetAgentFavoriteTag(backend4, agentId) {
|
|
473115
|
-
const favoriteTag = await getFavoriteTagForAgent(agentId);
|
|
473116
|
-
if (!favoriteTag)
|
|
473117
|
-
return "unavailable";
|
|
473118
|
-
const agent2 = await backend4.retrieveAgent(agentId, {
|
|
473119
|
-
include: ["agent.tags"]
|
|
473120
|
-
});
|
|
473121
|
-
const tags = getAgentTags(agent2);
|
|
473122
|
-
const nextTags = removeFavoriteTag(tags, favoriteTag);
|
|
473123
|
-
if (arraysEqual2(tags, nextTags))
|
|
473124
|
-
return "unchanged";
|
|
473125
|
-
await backend4.updateAgent(agentId, { tags: nextTags });
|
|
473126
|
-
return "changed";
|
|
473127
|
-
}
|
|
473128
|
-
async function pinAgentForCurrentUser(agentId, backend4 = getBackend()) {
|
|
473129
|
-
const wasPinnedInSettings = settingsManager.isAgentPinned(agentId);
|
|
473130
|
-
try {
|
|
473131
|
-
const result = await setAgentFavoriteTag(backend4, agentId);
|
|
473132
|
-
if (result !== "unavailable") {
|
|
473133
|
-
if (wasPinnedInSettings) {
|
|
473134
|
-
settingsManager.unpinAgent(agentId);
|
|
473135
|
-
}
|
|
473136
|
-
return result === "unchanged" || wasPinnedInSettings ? "already-pinned" : "pinned";
|
|
473137
|
-
}
|
|
473138
|
-
} catch {}
|
|
473139
|
-
if (wasPinnedInSettings)
|
|
473140
|
-
return "already-pinned";
|
|
473141
|
-
settingsManager.pinAgent(agentId);
|
|
473142
|
-
return "pinned";
|
|
473143
|
-
}
|
|
473144
|
-
async function unpinAgentForCurrentUser(agentId, backend4 = getBackend()) {
|
|
473145
|
-
const wasPinnedInSettings = settingsManager.isAgentPinned(agentId);
|
|
473146
|
-
try {
|
|
473147
|
-
const result = await unsetAgentFavoriteTag(backend4, agentId);
|
|
473148
|
-
if (result !== "unavailable") {
|
|
473149
|
-
if (wasPinnedInSettings) {
|
|
473150
|
-
settingsManager.unpinAgent(agentId);
|
|
473151
|
-
}
|
|
473152
|
-
return result === "changed" || wasPinnedInSettings ? "unpinned" : "not-pinned";
|
|
473153
|
-
}
|
|
473154
|
-
} catch (error54) {
|
|
473155
|
-
if (!wasPinnedInSettings)
|
|
473156
|
-
throw error54;
|
|
473157
|
-
}
|
|
473158
|
-
if (!wasPinnedInSettings)
|
|
473159
|
-
return "not-pinned";
|
|
473160
|
-
settingsManager.unpinAgent(agentId);
|
|
473161
|
-
return "unpinned";
|
|
473162
|
-
}
|
|
473163
|
-
var LETTA_CHAT_FAVORITE_TAG_BASE = "view:letta-chat", LETTA_CHAT_FAVORITE_TAG_PREFIX = "favorite:user:", LOCAL_FAVORITE_OWNER_ID = "local", LOCAL_DESKTOP_FAVORITE_TAG, currentUserMetadataFetcherOverride = null;
|
|
473164
|
-
var init_favorites = __esm(() => {
|
|
473165
|
-
init_backend2();
|
|
473166
|
-
init_request();
|
|
473167
|
-
init_settings_manager();
|
|
473168
|
-
LOCAL_DESKTOP_FAVORITE_TAG = generateFavoriteTag(LOCAL_FAVORITE_OWNER_ID);
|
|
473169
|
-
});
|
|
473170
|
-
|
|
473171
473243
|
// src/cli/components/OverlayShell.tsx
|
|
473172
473244
|
function OverlayShell({
|
|
473173
473245
|
command,
|
|
@@ -473457,20 +473529,8 @@ var init_TabBar = __esm(async () => {
|
|
|
473457
473529
|
// src/cli/components/AgentSelector.tsx
|
|
473458
473530
|
var exports_AgentSelector = {};
|
|
473459
473531
|
__export(exports_AgentSelector, {
|
|
473460
|
-
getPinnedAgentBackendMode: () => getPinnedAgentBackendMode,
|
|
473461
473532
|
AgentSelector: () => AgentSelector
|
|
473462
473533
|
});
|
|
473463
|
-
function getPinnedAgentBackendMode(agentId) {
|
|
473464
|
-
return isLocalAgentId(agentId) ? "local" : "api";
|
|
473465
|
-
}
|
|
473466
|
-
function hasCloudCredentials() {
|
|
473467
|
-
const apiKey = process.env.LETTA_API_KEY;
|
|
473468
|
-
if (apiKey)
|
|
473469
|
-
return true;
|
|
473470
|
-
const settings3 = settingsManager.getSettings();
|
|
473471
|
-
const cached3 = settingsManager.getCachedSecureTokens();
|
|
473472
|
-
return Boolean(cached3.apiKey || cached3.refreshToken || settings3.refreshToken || settings3.env?.LETTA_API_KEY);
|
|
473473
|
-
}
|
|
473474
473534
|
function formatRelativeTime3(dateStr) {
|
|
473475
473535
|
if (!dateStr)
|
|
473476
473536
|
return "Never";
|
|
@@ -473576,77 +473636,7 @@ function AgentSelector({
|
|
|
473576
473636
|
const loadPinnedAgents = import_react38.useCallback(async () => {
|
|
473577
473637
|
setPinnedLoading(true);
|
|
473578
473638
|
try {
|
|
473579
|
-
const
|
|
473580
|
-
const pinnedIdSet = new Set(pinnedIds);
|
|
473581
|
-
const localFavoriteAgents = listLocalAgentsFromDisk().filter((agent2) => agent2.tags.includes(LOCAL_DESKTOP_FAVORITE_TAG));
|
|
473582
|
-
let cloudFavoriteAgents = [];
|
|
473583
|
-
if (hasCloudCredentials()) {
|
|
473584
|
-
try {
|
|
473585
|
-
const favoriteTag = await getCurrentCloudFavoriteTag();
|
|
473586
|
-
if (favoriteTag) {
|
|
473587
|
-
const { getClient: getClient2 } = await Promise.resolve().then(() => (init_client2(), exports_client));
|
|
473588
|
-
const client = await getClient2();
|
|
473589
|
-
const agentList = await client.agents.list({
|
|
473590
|
-
limit: FETCH_PAGE_SIZE2,
|
|
473591
|
-
include: ["agent.blocks"],
|
|
473592
|
-
order: "desc",
|
|
473593
|
-
order_by: "last_run_completion",
|
|
473594
|
-
tags: [favoriteTag]
|
|
473595
|
-
});
|
|
473596
|
-
cloudFavoriteAgents = agentList.items;
|
|
473597
|
-
}
|
|
473598
|
-
} catch {}
|
|
473599
|
-
}
|
|
473600
|
-
let pinnedData = [];
|
|
473601
|
-
if (pinnedIds.length > 0) {
|
|
473602
|
-
pinnedData = await Promise.all(pinnedIds.map(async (agentId) => {
|
|
473603
|
-
const backendMode = getPinnedAgentBackendMode(agentId);
|
|
473604
|
-
try {
|
|
473605
|
-
if (backendMode === "api" && !hasCloudCredentials()) {
|
|
473606
|
-
return {
|
|
473607
|
-
agentId,
|
|
473608
|
-
agent: null,
|
|
473609
|
-
error: "Not signed in",
|
|
473610
|
-
backendMode
|
|
473611
|
-
};
|
|
473612
|
-
}
|
|
473613
|
-
const agentBackend = getBackendForMode(backendMode);
|
|
473614
|
-
const agent2 = await agentBackend.retrieveAgent(agentId, {
|
|
473615
|
-
include: ["agent.blocks"]
|
|
473616
|
-
});
|
|
473617
|
-
return {
|
|
473618
|
-
agentId,
|
|
473619
|
-
agent: agent2,
|
|
473620
|
-
error: null,
|
|
473621
|
-
backendMode
|
|
473622
|
-
};
|
|
473623
|
-
} catch {
|
|
473624
|
-
return {
|
|
473625
|
-
agentId,
|
|
473626
|
-
agent: null,
|
|
473627
|
-
error: "Agent not found",
|
|
473628
|
-
backendMode
|
|
473629
|
-
};
|
|
473630
|
-
}
|
|
473631
|
-
}));
|
|
473632
|
-
}
|
|
473633
|
-
const favoriteAgents = [
|
|
473634
|
-
...localFavoriteAgents.map((agent2) => ({
|
|
473635
|
-
agent: agent2,
|
|
473636
|
-
backendMode: "local"
|
|
473637
|
-
})),
|
|
473638
|
-
...cloudFavoriteAgents.map((agent2) => ({
|
|
473639
|
-
agent: agent2,
|
|
473640
|
-
backendMode: "api"
|
|
473641
|
-
}))
|
|
473642
|
-
];
|
|
473643
|
-
const favoriteData = favoriteAgents.filter(({ agent: agent2 }) => !pinnedIdSet.has(agent2.id)).map((agent2) => ({
|
|
473644
|
-
agentId: agent2.agent.id,
|
|
473645
|
-
agent: agent2.agent,
|
|
473646
|
-
error: null,
|
|
473647
|
-
backendMode: agent2.backendMode
|
|
473648
|
-
}));
|
|
473649
|
-
pinnedData = [...pinnedData, ...favoriteData];
|
|
473639
|
+
const pinnedData = await listPinnedAgentsForCurrentUser2();
|
|
473650
473640
|
const validPinnedData = pinnedData.filter((p2) => p2.agent !== null);
|
|
473651
473641
|
if (validPinnedData.length === 0) {
|
|
473652
473642
|
setPinnedAgents([]);
|
|
@@ -473728,7 +473718,7 @@ function AgentSelector({
|
|
|
473728
473718
|
activeQuery
|
|
473729
473719
|
]);
|
|
473730
473720
|
import_react38.useEffect(() => {
|
|
473731
|
-
setHasCloudAuth(
|
|
473721
|
+
setHasCloudAuth(hasCloudCredentials2());
|
|
473732
473722
|
}, []);
|
|
473733
473723
|
import_react38.useEffect(() => {
|
|
473734
473724
|
loadPinnedAgents();
|
|
@@ -474458,9 +474448,9 @@ var init_AgentSelector = __esm(async () => {
|
|
|
474458
474448
|
init_model();
|
|
474459
474449
|
init_backend();
|
|
474460
474450
|
init_local_agent_listing();
|
|
474451
|
+
init_pinned_agent_listing();
|
|
474461
474452
|
init_use_terminal_width();
|
|
474462
474453
|
init_constants2();
|
|
474463
|
-
init_settings_manager();
|
|
474464
474454
|
init_colors();
|
|
474465
474455
|
await __promiseAll([
|
|
474466
474456
|
init_build4(),
|
|
@@ -537640,7 +537630,7 @@ function buildStartupCommandHints(options3) {
|
|
|
537640
537630
|
isPinned,
|
|
537641
537631
|
isLocalBackend,
|
|
537642
537632
|
hasMessages,
|
|
537643
|
-
hasCloudCredentials:
|
|
537633
|
+
hasCloudCredentials: hasCloudCredentials3,
|
|
537644
537634
|
hasAvailableLocalModels
|
|
537645
537635
|
} = options3;
|
|
537646
537636
|
const baseHints = isResumingConversation ? [
|
|
@@ -537669,7 +537659,7 @@ function buildStartupCommandHints(options3) {
|
|
|
537669
537659
|
if (!hasMessages) {
|
|
537670
537660
|
onboardingHints.push("→ **/rename** name your agent", "→ **/init** initialize your agent's memory");
|
|
537671
537661
|
}
|
|
537672
|
-
if (!
|
|
537662
|
+
if (!hasCloudCredentials3) {
|
|
537673
537663
|
onboardingHints.push("→ **/login** sign in to Constellation");
|
|
537674
537664
|
}
|
|
537675
537665
|
const dedupedHints = [];
|
|
@@ -541602,24 +541592,22 @@ function resolveStartupTarget(input) {
|
|
|
541602
541592
|
if (input.forceNew) {
|
|
541603
541593
|
return { action: "create", trigger: "force-new" };
|
|
541604
541594
|
}
|
|
541605
|
-
if (input.
|
|
541606
|
-
const conversationId = input.pinnedAgentId === input.localAgentId ? input.localConversationId ?? undefined : undefined;
|
|
541595
|
+
if (input.localAgentId && input.localAgentExists) {
|
|
541607
541596
|
return {
|
|
541608
541597
|
action: "resume",
|
|
541609
|
-
agentId: input.
|
|
541610
|
-
|
|
541598
|
+
agentId: input.localAgentId,
|
|
541599
|
+
conversationId: input.localConversationId ?? undefined
|
|
541611
541600
|
};
|
|
541612
541601
|
}
|
|
541613
|
-
if (input.
|
|
541614
|
-
return { action: "select" };
|
|
541615
|
-
}
|
|
541616
|
-
if (input.localAgentId && input.localAgentExists) {
|
|
541602
|
+
if (input.pinnedAgentId && input.pinnedAgentExists) {
|
|
541617
541603
|
return {
|
|
541618
541604
|
action: "resume",
|
|
541619
|
-
agentId: input.
|
|
541620
|
-
conversationId: input.localConversationId ?? undefined
|
|
541605
|
+
agentId: input.pinnedAgentId
|
|
541621
541606
|
};
|
|
541622
541607
|
}
|
|
541608
|
+
if (input.existingPinnedCount > 1) {
|
|
541609
|
+
return { action: "select" };
|
|
541610
|
+
}
|
|
541623
541611
|
if (input.globalAgentId && input.globalAgentExists) {
|
|
541624
541612
|
return {
|
|
541625
541613
|
action: "resume",
|
|
@@ -546400,6 +546388,76 @@ async function ensureFdPath() {
|
|
|
546400
546388
|
return pendingFdPath;
|
|
546401
546389
|
}
|
|
546402
546390
|
|
|
546391
|
+
// src/cli/helpers/pinned-agent-listing.ts
|
|
546392
|
+
init_favorites();
|
|
546393
|
+
init_backend();
|
|
546394
|
+
init_settings_manager();
|
|
546395
|
+
init_local_agent_listing();
|
|
546396
|
+
var PINNED_AGENT_LIMIT = 100;
|
|
546397
|
+
function hasCloudCredentials() {
|
|
546398
|
+
if (process.env.LETTA_API_KEY)
|
|
546399
|
+
return true;
|
|
546400
|
+
const settings3 = settingsManager.getSettings();
|
|
546401
|
+
const cached3 = settingsManager.getCachedSecureTokens();
|
|
546402
|
+
return Boolean(cached3.apiKey || cached3.refreshToken || settings3.refreshToken || settings3.env?.LETTA_API_KEY);
|
|
546403
|
+
}
|
|
546404
|
+
async function listCloudFavoriteAgents() {
|
|
546405
|
+
if (!hasCloudCredentials())
|
|
546406
|
+
return [];
|
|
546407
|
+
try {
|
|
546408
|
+
const favoriteTag = await getCurrentCloudFavoriteTag();
|
|
546409
|
+
if (!favoriteTag)
|
|
546410
|
+
return [];
|
|
546411
|
+
const page = await getBackendForMode("api").listAgents({
|
|
546412
|
+
limit: PINNED_AGENT_LIMIT,
|
|
546413
|
+
include: ["agent.blocks"],
|
|
546414
|
+
order: "desc",
|
|
546415
|
+
order_by: "last_run_completion",
|
|
546416
|
+
tags: [favoriteTag]
|
|
546417
|
+
});
|
|
546418
|
+
return Array.isArray(page) ? page : page.items ?? [];
|
|
546419
|
+
} catch {
|
|
546420
|
+
return [];
|
|
546421
|
+
}
|
|
546422
|
+
}
|
|
546423
|
+
async function retrieveLegacyPin(agentId, backendMode) {
|
|
546424
|
+
if (backendMode === "api" && !hasCloudCredentials()) {
|
|
546425
|
+
return { agentId, agent: null, error: "Not signed in", backendMode };
|
|
546426
|
+
}
|
|
546427
|
+
try {
|
|
546428
|
+
const agent2 = await getBackendForMode(backendMode).retrieveAgent(agentId, {
|
|
546429
|
+
include: ["agent.blocks"]
|
|
546430
|
+
});
|
|
546431
|
+
return { agentId, agent: agent2, error: null, backendMode };
|
|
546432
|
+
} catch {
|
|
546433
|
+
return { agentId, agent: null, error: "Agent not found", backendMode };
|
|
546434
|
+
}
|
|
546435
|
+
}
|
|
546436
|
+
async function listPinnedAgentsForCurrentUser(backendModes = ["api", "local"]) {
|
|
546437
|
+
const modes = new Set(backendModes);
|
|
546438
|
+
const legacyPins = [...modes].flatMap((backendMode) => settingsManager.getPinnedAgentsForBackendMode(backendMode).map((agentId) => ({ agentId, backendMode })));
|
|
546439
|
+
const seen = new Set(legacyPins.map(({ agentId, backendMode }) => `${backendMode}:${agentId}`));
|
|
546440
|
+
const legacyData = await Promise.all(legacyPins.map(({ agentId, backendMode }) => retrieveLegacyPin(agentId, backendMode)));
|
|
546441
|
+
const favoriteAgents = [];
|
|
546442
|
+
if (modes.has("local")) {
|
|
546443
|
+
favoriteAgents.push(...listLocalAgentsFromDisk().filter((agent2) => getAgentTags(agent2).includes(LOCAL_DESKTOP_FAVORITE_TAG)).map((agent2) => ({ agent: agent2, backendMode: "local" })));
|
|
546444
|
+
}
|
|
546445
|
+
if (modes.has("api")) {
|
|
546446
|
+
favoriteAgents.push(...(await listCloudFavoriteAgents()).map((agent2) => ({
|
|
546447
|
+
agent: agent2,
|
|
546448
|
+
backendMode: "api"
|
|
546449
|
+
})));
|
|
546450
|
+
}
|
|
546451
|
+
const favoriteData = favoriteAgents.flatMap(({ agent: agent2, backendMode }) => {
|
|
546452
|
+
const key2 = `${backendMode}:${agent2.id}`;
|
|
546453
|
+
if (seen.has(key2))
|
|
546454
|
+
return [];
|
|
546455
|
+
seen.add(key2);
|
|
546456
|
+
return [{ agentId: agent2.id, agent: agent2, error: null, backendMode }];
|
|
546457
|
+
});
|
|
546458
|
+
return [...legacyData, ...favoriteData];
|
|
546459
|
+
}
|
|
546460
|
+
|
|
546403
546461
|
// src/cli/helpers/terminal-theme.ts
|
|
546404
546462
|
var TERMINAL_THEME_STATE_KEY2 = Symbol.for("letta.terminalThemeState");
|
|
546405
546463
|
function getTerminalThemeState2() {
|
|
@@ -546502,6 +546560,7 @@ async function initTerminalTheme() {
|
|
|
546502
546560
|
// src/cli/profile-selection.tsx
|
|
546503
546561
|
init_model();
|
|
546504
546562
|
init_backend2();
|
|
546563
|
+
init_pinned_agent_listing();
|
|
546505
546564
|
await init_build4();
|
|
546506
546565
|
var import_react30 = __toESM(require_react(), 1);
|
|
546507
546566
|
|
|
@@ -546603,32 +546662,6 @@ function getLabel(option2, _freshRepoMode) {
|
|
|
546603
546662
|
parts.push("pinned");
|
|
546604
546663
|
return parts.length > 0 ? ` (${parts.join(", ")})` : "";
|
|
546605
546664
|
}
|
|
546606
|
-
function buildInitialProfileOptions(lruAgentId) {
|
|
546607
|
-
const pinned = settingsManager.getPinnedAgents();
|
|
546608
|
-
const options3 = [];
|
|
546609
|
-
const seenAgentIds = new Set;
|
|
546610
|
-
if (lruAgentId) {
|
|
546611
|
-
options3.push({
|
|
546612
|
-
name: null,
|
|
546613
|
-
agentId: lruAgentId,
|
|
546614
|
-
isLru: true,
|
|
546615
|
-
agent: null
|
|
546616
|
-
});
|
|
546617
|
-
seenAgentIds.add(lruAgentId);
|
|
546618
|
-
}
|
|
546619
|
-
for (const agentId of pinned) {
|
|
546620
|
-
if (seenAgentIds.has(agentId))
|
|
546621
|
-
continue;
|
|
546622
|
-
options3.push({
|
|
546623
|
-
name: null,
|
|
546624
|
-
agentId,
|
|
546625
|
-
isLru: false,
|
|
546626
|
-
agent: null
|
|
546627
|
-
});
|
|
546628
|
-
seenAgentIds.add(agentId);
|
|
546629
|
-
}
|
|
546630
|
-
return options3;
|
|
546631
|
-
}
|
|
546632
546665
|
function ProfileSelectionUI({
|
|
546633
546666
|
lruAgentId,
|
|
546634
546667
|
externalLoading,
|
|
@@ -546639,8 +546672,9 @@ function ProfileSelectionUI({
|
|
|
546639
546672
|
serverBaseUrl,
|
|
546640
546673
|
onComplete
|
|
546641
546674
|
}) {
|
|
546642
|
-
const [options3, setOptions] = import_react30.useState(
|
|
546643
|
-
const
|
|
546675
|
+
const [options3, setOptions] = import_react30.useState([]);
|
|
546676
|
+
const [optionsLoading, setOptionsLoading] = import_react30.useState(true);
|
|
546677
|
+
const loading = externalLoading || optionsLoading;
|
|
546644
546678
|
const [selectedIndex, setSelectedIndex] = import_react30.useState(0);
|
|
546645
546679
|
const [showAll, setShowAll] = import_react30.useState(false);
|
|
546646
546680
|
const [selectingModel, setSelectingModel] = import_react30.useState(!!(serverModelsForNewAgent && serverModelsForNewAgent.length > 0));
|
|
@@ -546648,45 +546682,45 @@ function ProfileSelectionUI({
|
|
|
546648
546682
|
const [modelSearchQuery, setModelSearchQuery] = import_react30.useState("");
|
|
546649
546683
|
const [modelReasoningPrompt, setModelReasoningPrompt] = import_react30.useState(null);
|
|
546650
546684
|
const loadOptions = import_react30.useCallback(async () => {
|
|
546685
|
+
setOptionsLoading(true);
|
|
546651
546686
|
try {
|
|
546652
|
-
const pinned =
|
|
546653
|
-
|
|
546687
|
+
const pinned = await listPinnedAgentsForCurrentUser2();
|
|
546688
|
+
let fetchedOptions = [];
|
|
546654
546689
|
const seenAgentIds = new Set;
|
|
546655
546690
|
if (lruAgentId) {
|
|
546656
|
-
|
|
546657
|
-
|
|
546658
|
-
|
|
546659
|
-
|
|
546660
|
-
|
|
546661
|
-
|
|
546691
|
+
const pinnedLru = pinned.find(({ agentId, agent: agent3 }) => agentId === lruAgentId && agent3);
|
|
546692
|
+
let agent2 = pinnedLru?.agent ?? null;
|
|
546693
|
+
if (!agent2) {
|
|
546694
|
+
try {
|
|
546695
|
+
const backend4 = getBackendForMode(isLocalAgentId(lruAgentId) ? "local" : "api");
|
|
546696
|
+
agent2 = await backend4.retrieveAgent(lruAgentId, {
|
|
546697
|
+
include: ["agent.blocks"]
|
|
546698
|
+
});
|
|
546699
|
+
} catch {
|
|
546700
|
+
agent2 = null;
|
|
546701
|
+
}
|
|
546702
|
+
}
|
|
546703
|
+
if (agent2) {
|
|
546704
|
+
fetchedOptions.push({
|
|
546705
|
+
name: agent2.name,
|
|
546706
|
+
agentId: lruAgentId,
|
|
546707
|
+
isLru: true,
|
|
546708
|
+
agent: agent2
|
|
546709
|
+
});
|
|
546710
|
+
}
|
|
546662
546711
|
seenAgentIds.add(lruAgentId);
|
|
546663
546712
|
}
|
|
546664
|
-
for (const agentId of pinned) {
|
|
546665
|
-
if (!seenAgentIds.has(agentId)) {
|
|
546666
|
-
|
|
546667
|
-
name:
|
|
546713
|
+
for (const { agentId, agent: agent2 } of pinned) {
|
|
546714
|
+
if (agent2 && !seenAgentIds.has(agentId)) {
|
|
546715
|
+
fetchedOptions.push({
|
|
546716
|
+
name: agent2.name,
|
|
546668
546717
|
agentId,
|
|
546669
546718
|
isLru: false,
|
|
546670
|
-
agent:
|
|
546719
|
+
agent: agent2
|
|
546671
546720
|
});
|
|
546672
546721
|
seenAgentIds.add(agentId);
|
|
546673
546722
|
}
|
|
546674
546723
|
}
|
|
546675
|
-
let fetchedOptions = await Promise.all(optionsToFetch.map(async (opt) => {
|
|
546676
|
-
if (opt.agent) {
|
|
546677
|
-
return opt;
|
|
546678
|
-
}
|
|
546679
|
-
try {
|
|
546680
|
-
const backend4 = getBackendForMode(isLocalAgentId(opt.agentId) ? "local" : "api");
|
|
546681
|
-
const agent2 = await backend4.retrieveAgent(opt.agentId, {
|
|
546682
|
-
include: ["agent.blocks"]
|
|
546683
|
-
});
|
|
546684
|
-
return { ...opt, agent: agent2 };
|
|
546685
|
-
} catch {
|
|
546686
|
-
return { ...opt, agent: null };
|
|
546687
|
-
}
|
|
546688
|
-
}));
|
|
546689
|
-
fetchedOptions = fetchedOptions.filter((opt) => opt.agent !== null);
|
|
546690
546724
|
if (fetchedOptions.length === 0) {
|
|
546691
546725
|
const recentAgents = await getRecentAgentOptions({
|
|
546692
546726
|
includeLocal: false,
|
|
@@ -546703,14 +546737,15 @@ function ProfileSelectionUI({
|
|
|
546703
546737
|
setOptions(fetchedOptions);
|
|
546704
546738
|
} catch {
|
|
546705
546739
|
setOptions([]);
|
|
546740
|
+
} finally {
|
|
546741
|
+
setOptionsLoading(false);
|
|
546706
546742
|
}
|
|
546707
546743
|
}, [lruAgentId]);
|
|
546708
546744
|
import_react30.useEffect(() => {
|
|
546709
546745
|
if (externalLoading)
|
|
546710
546746
|
return;
|
|
546711
|
-
setOptions((current) => current.length > 0 ? current : buildInitialProfileOptions(lruAgentId));
|
|
546712
546747
|
loadOptions();
|
|
546713
|
-
}, [externalLoading, loadOptions
|
|
546748
|
+
}, [externalLoading, loadOptions]);
|
|
546714
546749
|
const displayOptions = showAll ? options3 : options3.slice(0, MAX_DISPLAY);
|
|
546715
546750
|
const hasMore = options3.length > MAX_DISPLAY;
|
|
546716
546751
|
const totalItems = displayOptions.length + 1 + (hasMore && !showAll ? 1 : 0);
|
|
@@ -547589,8 +547624,8 @@ async function resolveStartupBackendDisplay() {
|
|
|
547589
547624
|
}
|
|
547590
547625
|
const apiKey = process.env.LETTA_API_KEY || settings3.env?.LETTA_API_KEY;
|
|
547591
547626
|
const baseURL = process.env.LETTA_BASE_URL || settings3.env?.LETTA_BASE_URL || LETTA_CLOUD_API_URL;
|
|
547592
|
-
const
|
|
547593
|
-
if (baseURL === LETTA_CLOUD_API_URL && !
|
|
547627
|
+
const hasCloudCredentials3 = Boolean(apiKey || settings3.refreshToken);
|
|
547628
|
+
if (baseURL === LETTA_CLOUD_API_URL && !hasCloudCredentials3) {
|
|
547594
547629
|
return "setup";
|
|
547595
547630
|
}
|
|
547596
547631
|
return "api";
|
|
@@ -556327,19 +556362,6 @@ function getModelForToolLoading(specifiedModel, specifiedToolset) {
|
|
|
556327
556362
|
}
|
|
556328
556363
|
return specifiedModel;
|
|
556329
556364
|
}
|
|
556330
|
-
async function findLocalAgentsByName(name) {
|
|
556331
|
-
const backend4 = getBackendForMode("local");
|
|
556332
|
-
const normalizedName = name.toLowerCase();
|
|
556333
|
-
try {
|
|
556334
|
-
const page = await backend4.listAgents({
|
|
556335
|
-
query_text: name,
|
|
556336
|
-
limit: 100
|
|
556337
|
-
});
|
|
556338
|
-
return paginatedItems6(page).filter((agent2) => agent2.name?.toLowerCase() === normalizedName);
|
|
556339
|
-
} catch {
|
|
556340
|
-
return [];
|
|
556341
|
-
}
|
|
556342
|
-
}
|
|
556343
556365
|
function getStartupTargetLookupOrderForCredentials({
|
|
556344
556366
|
baseURL,
|
|
556345
556367
|
explicitBackendMode,
|
|
@@ -556356,44 +556378,24 @@ function getStartupTargetLookupOrderForCredentials({
|
|
|
556356
556378
|
}
|
|
556357
556379
|
async function resolveAgentByName2(name, backendLookupOrder) {
|
|
556358
556380
|
const normalizedSearchName = name.toLowerCase();
|
|
556381
|
+
const pinnedAgents = await listPinnedAgentsForCurrentUser(backendLookupOrder);
|
|
556359
556382
|
for (const backendMode of backendLookupOrder) {
|
|
556360
|
-
const
|
|
556361
|
-
|
|
556362
|
-
|
|
556363
|
-
|
|
556364
|
-
|
|
556365
|
-
|
|
556366
|
-
const agent2 = await backend4.retrieveAgent(id2);
|
|
556367
|
-
if (agent2.name?.toLowerCase() === normalizedSearchName) {
|
|
556368
|
-
matches3.push({ id: id2, name: agent2.name, agent: agent2, backendMode });
|
|
556369
|
-
}
|
|
556370
|
-
} catch {}
|
|
556371
|
-
}));
|
|
556372
|
-
}
|
|
556373
|
-
if (backendMode === "local") {
|
|
556374
|
-
const seen = new Set(matches3.map((match4) => match4.id));
|
|
556375
|
-
for (const agent2 of await findLocalAgentsByName(name)) {
|
|
556376
|
-
if (!seen.has(agent2.id)) {
|
|
556377
|
-
matches3.push({
|
|
556378
|
-
id: agent2.id,
|
|
556379
|
-
name: agent2.name ?? agent2.id,
|
|
556380
|
-
agent: agent2,
|
|
556381
|
-
backendMode
|
|
556382
|
-
});
|
|
556383
|
-
seen.add(agent2.id);
|
|
556384
|
-
}
|
|
556383
|
+
const matches3 = pinnedAgents.flatMap((pinned) => pinned.backendMode === backendMode && pinned.agent?.name?.toLowerCase() === normalizedSearchName ? [
|
|
556384
|
+
{
|
|
556385
|
+
id: pinned.agentId,
|
|
556386
|
+
name: pinned.agent.name,
|
|
556387
|
+
agent: pinned.agent,
|
|
556388
|
+
backendMode
|
|
556385
556389
|
}
|
|
556386
|
-
|
|
556390
|
+
] : []);
|
|
556387
556391
|
if (matches3.length === 0)
|
|
556388
556392
|
continue;
|
|
556389
556393
|
if (matches3.length === 1)
|
|
556390
556394
|
return matches3[0] ?? null;
|
|
556391
|
-
const
|
|
556392
|
-
const localMatch = matches3.find((m4) => m4.id === localSettings.lastAgent);
|
|
556395
|
+
const localMatch = matches3.find((match4) => match4.id === settingsManager2.getLocalLastAgentId());
|
|
556393
556396
|
if (localMatch)
|
|
556394
556397
|
return localMatch;
|
|
556395
|
-
const
|
|
556396
|
-
const globalMatch = matches3.find((m4) => m4.id === settings3.lastAgent);
|
|
556398
|
+
const globalMatch = matches3.find((match4) => match4.id === settingsManager2.getGlobalLastAgentId());
|
|
556397
556399
|
if (globalMatch)
|
|
556398
556400
|
return globalMatch;
|
|
556399
556401
|
return matches3[0] ?? null;
|
|
@@ -556401,18 +556403,8 @@ async function resolveAgentByName2(name, backendLookupOrder) {
|
|
|
556401
556403
|
return null;
|
|
556402
556404
|
}
|
|
556403
556405
|
async function getPinnedAgentNames(backendLookupOrder) {
|
|
556404
|
-
const
|
|
556405
|
-
|
|
556406
|
-
const backend4 = getBackendForMode(backendMode);
|
|
556407
|
-
const pinnedAgents = settingsManager2.getPinnedAgentsForBackendMode(backendMode);
|
|
556408
|
-
await Promise.all(pinnedAgents.map(async (id2) => {
|
|
556409
|
-
try {
|
|
556410
|
-
const agent2 = await backend4.retrieveAgent(id2);
|
|
556411
|
-
agents.push({ id: id2, name: agent2.name || "(unnamed)" });
|
|
556412
|
-
} catch {}
|
|
556413
|
-
}));
|
|
556414
|
-
}
|
|
556415
|
-
return agents;
|
|
556406
|
+
const pinnedAgents = await listPinnedAgentsForCurrentUser(backendLookupOrder);
|
|
556407
|
+
return pinnedAgents.flatMap(({ agentId, agent: agent2 }) => agent2 ? [{ id: agentId, name: agent2.name || "(unnamed)" }] : []);
|
|
556416
556408
|
}
|
|
556417
556409
|
async function resolveConversationAcrossBackends(conversationId, backendLookupOrder) {
|
|
556418
556410
|
for (const backendMode of backendLookupOrder) {
|
|
@@ -557256,54 +557248,54 @@ Error: ${message}`);
|
|
|
557256
557248
|
setLoadingState("assembling");
|
|
557257
557249
|
return;
|
|
557258
557250
|
}
|
|
557259
|
-
const
|
|
557260
|
-
const
|
|
557261
|
-
const
|
|
557262
|
-
const localAgentId = startupBackendMode === "local" ? rawLocalAgentId : null;
|
|
557263
|
-
const globalAgentId = startupBackendMode === "api" ? rawGlobalAgentId : null;
|
|
557264
|
-
const agentIdsToValidate = [
|
|
557265
|
-
...new Set([...pinnedAgentIds, localAgentId, globalAgentId].filter((agentId2) => Boolean(agentId2)))
|
|
557266
|
-
];
|
|
557267
|
-
const validationResults = await Promise.allSettled(agentIdsToValidate.map(async (agentId2) => ({
|
|
557268
|
-
agentId: agentId2,
|
|
557269
|
-
agent: await backend4.retrieveAgent(agentId2, {
|
|
557270
|
-
include: ["agent.tags"]
|
|
557271
|
-
})
|
|
557272
|
-
})));
|
|
557273
|
-
const cachedAgents = new Map;
|
|
557274
|
-
for (const result of validationResults) {
|
|
557275
|
-
if (result.status === "fulfilled") {
|
|
557276
|
-
cachedAgents.set(result.value.agentId, result.value.agent);
|
|
557277
|
-
}
|
|
557278
|
-
}
|
|
557279
|
-
const existingPinnedIds = pinnedAgentIds.filter((id2) => cachedAgents.has(id2));
|
|
557280
|
-
const pinnedAgentId = existingPinnedIds.length === 1 ? existingPinnedIds[0] ?? null : null;
|
|
557281
|
-
const pinnedAgentExists = pinnedAgentId !== null;
|
|
557282
|
-
let localAgentExists = false;
|
|
557283
|
-
let globalAgentExists = false;
|
|
557251
|
+
const localAgentId = settingsManager2.getLocalLastAgentId(process.cwd());
|
|
557252
|
+
const globalAgentId = startupBackendMode === "api" ? settingsManager2.getGlobalLastAgentId() : null;
|
|
557253
|
+
const localSession = settingsManager2.getLocalLastSession(process.cwd());
|
|
557284
557254
|
if (localAgentId) {
|
|
557285
|
-
|
|
557286
|
-
|
|
557255
|
+
try {
|
|
557256
|
+
const localAgent = await backend4.retrieveAgent(localAgentId, {
|
|
557257
|
+
include: ["agent.tags"]
|
|
557258
|
+
});
|
|
557259
|
+
setSelectedGlobalAgentId(localAgentId);
|
|
557260
|
+
setValidatedAgent(localAgent);
|
|
557261
|
+
if (localSession?.conversationId && !forceNewConversation) {
|
|
557262
|
+
setSelectedConversationId(localSession.conversationId);
|
|
557263
|
+
}
|
|
557264
|
+
markMilestone2("STARTUP_LRU_FETCH_DONE");
|
|
557265
|
+
setLoadingState("assembling");
|
|
557266
|
+
return;
|
|
557267
|
+
} catch {
|
|
557287
557268
|
setFailedAgentMessage(`Unable to locate recently used agent ${localAgentId}`);
|
|
557288
557269
|
}
|
|
557289
557270
|
}
|
|
557290
|
-
|
|
557291
|
-
|
|
557271
|
+
const pinnedAgents = await listPinnedAgentsForCurrentUser([
|
|
557272
|
+
startupBackendMode
|
|
557273
|
+
]);
|
|
557274
|
+
const pinnedAgentIds = pinnedAgents.map(({ agentId: agentId2 }) => agentId2);
|
|
557275
|
+
const cachedAgents = new Map(pinnedAgents.flatMap(({ agentId: agentId2, agent: agent2 }) => agent2 ? [[agentId2, agent2]] : []));
|
|
557276
|
+
if (globalAgentId && !cachedAgents.has(globalAgentId)) {
|
|
557277
|
+
try {
|
|
557278
|
+
const globalAgent = await backend4.retrieveAgent(globalAgentId, {
|
|
557279
|
+
include: ["agent.tags"]
|
|
557280
|
+
});
|
|
557281
|
+
cachedAgents.set(globalAgentId, globalAgent);
|
|
557282
|
+
} catch {}
|
|
557292
557283
|
}
|
|
557284
|
+
const existingPinnedIds = pinnedAgentIds.filter((id2) => cachedAgents.has(id2));
|
|
557285
|
+
const pinnedAgentId = existingPinnedIds.length === 1 ? existingPinnedIds[0] ?? null : null;
|
|
557286
|
+
const pinnedAgentExists = pinnedAgentId !== null;
|
|
557287
|
+
const globalAgentExists = globalAgentId ? cachedAgents.has(globalAgentId) : false;
|
|
557293
557288
|
markMilestone2("STARTUP_LRU_FETCH_DONE");
|
|
557294
|
-
const
|
|
557295
|
-
const existingPinnedCount = existingPinnedIds.length;
|
|
557296
|
-
const fallbackSession = startupBackendMode === "local" && !localAgentExists && !globalAgentExists ? await getLocalBackendStartupFallbackSession(backend4) : null;
|
|
557289
|
+
const fallbackSession = startupBackendMode === "local" && !globalAgentExists ? await getLocalBackendStartupFallbackSession(backend4) : null;
|
|
557297
557290
|
const { resolveStartupTarget: resolveStartupTarget2 } = await Promise.resolve().then(() => exports_resolve_startup_agent);
|
|
557298
|
-
const localSession = settingsManager2.getLocalLastSession(process.cwd());
|
|
557299
557291
|
const target2 = resolveStartupTarget2({
|
|
557300
557292
|
pinnedAgentId,
|
|
557301
557293
|
pinnedAgentExists,
|
|
557302
|
-
pinnedCount,
|
|
557303
|
-
existingPinnedCount,
|
|
557294
|
+
pinnedCount: pinnedAgentIds.length,
|
|
557295
|
+
existingPinnedCount: existingPinnedIds.length,
|
|
557304
557296
|
localAgentId,
|
|
557305
557297
|
localConversationId: localSession?.conversationId ?? null,
|
|
557306
|
-
localAgentExists,
|
|
557298
|
+
localAgentExists: false,
|
|
557307
557299
|
globalAgentId,
|
|
557308
557300
|
globalAgentExists,
|
|
557309
557301
|
fallbackAgentId: fallbackSession?.agentId ?? null,
|
|
@@ -557872,4 +557864,4 @@ Error during initialization: ${message}`);
|
|
|
557872
557864
|
}
|
|
557873
557865
|
main2();
|
|
557874
557866
|
|
|
557875
|
-
//# debugId=
|
|
557867
|
+
//# debugId=8849A89953C6484464756E2164756E21
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"src/cli/app/use-configuration-handlers.ts": 1392,
|
|
12
12
|
"src/cli/app/use-conversation-loop.ts": 2935,
|
|
13
13
|
"src/cli/app/use-submit-handler.ts": 4099,
|
|
14
|
-
"src/cli/components/AgentSelector.tsx":
|
|
14
|
+
"src/cli/components/AgentSelector.tsx": 1151,
|
|
15
15
|
"src/cli/components/InputRich.tsx": 2219,
|
|
16
16
|
"src/cli/components/ModelSelector.tsx": 1204,
|
|
17
17
|
"src/cli/components/ProviderSelector.tsx": 1676,
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"src/cli/subcommands/skills.ts": 1264,
|
|
25
25
|
"src/headless.ts": 5242,
|
|
26
26
|
"src/hooks/integration.test.ts": 1147,
|
|
27
|
-
"src/index.ts":
|
|
27
|
+
"src/index.ts": 2803,
|
|
28
28
|
"src/mods/learning-harness.ts": 2434,
|
|
29
29
|
"src/mods/mod-engine.test.ts": 2178,
|
|
30
30
|
"src/mods/mod-engine.ts": 1879,
|