@letta-ai/letta-code 0.16.15 → 0.17.0
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/README.md +1 -1
- package/letta.js +851 -372
- package/package.json +2 -2
package/letta.js
CHANGED
|
@@ -342,7 +342,7 @@ var init_values = __esm(() => {
|
|
|
342
342
|
var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
343
343
|
|
|
344
344
|
// node_modules/@letta-ai/letta-client/version.mjs
|
|
345
|
-
var VERSION = "1.7.
|
|
345
|
+
var VERSION = "1.7.11";
|
|
346
346
|
|
|
347
347
|
// node_modules/@letta-ai/letta-client/internal/detect-platform.mjs
|
|
348
348
|
function getDetectedPlatform() {
|
|
@@ -868,9 +868,11 @@ var init_stringify = __esm(() => {
|
|
|
868
868
|
sentinel = {};
|
|
869
869
|
});
|
|
870
870
|
|
|
871
|
-
// node_modules/@letta-ai/letta-client/internal/
|
|
872
|
-
|
|
873
|
-
|
|
871
|
+
// node_modules/@letta-ai/letta-client/internal/utils/query.mjs
|
|
872
|
+
function stringifyQuery(query) {
|
|
873
|
+
return stringify(query, { allowDots: true, arrayFormat: "repeat" });
|
|
874
|
+
}
|
|
875
|
+
var init_query = __esm(() => {
|
|
874
876
|
init_stringify();
|
|
875
877
|
});
|
|
876
878
|
|
|
@@ -2273,8 +2275,12 @@ var init_conversations = __esm(() => {
|
|
|
2273
2275
|
delete(conversationID, options) {
|
|
2274
2276
|
return this._client.delete(path`/v1/conversations/${conversationID}`, options);
|
|
2275
2277
|
}
|
|
2276
|
-
cancel(conversationID, options) {
|
|
2277
|
-
|
|
2278
|
+
cancel(conversationID, params = {}, options) {
|
|
2279
|
+
const { agent_id } = params ?? {};
|
|
2280
|
+
return this._client.post(path`/v1/conversations/${conversationID}/cancel`, {
|
|
2281
|
+
query: { agent_id },
|
|
2282
|
+
...options
|
|
2283
|
+
});
|
|
2278
2284
|
}
|
|
2279
2285
|
};
|
|
2280
2286
|
Conversations.Messages = Messages2;
|
|
@@ -2841,7 +2847,7 @@ class Letta {
|
|
|
2841
2847
|
return buildHeaders([{ Authorization: `Bearer ${this.apiKey}` }]);
|
|
2842
2848
|
}
|
|
2843
2849
|
stringifyQuery(query) {
|
|
2844
|
-
return
|
|
2850
|
+
return stringifyQuery(query);
|
|
2845
2851
|
}
|
|
2846
2852
|
getUserAgent() {
|
|
2847
2853
|
return `${this.constructor.name}/JS ${VERSION}`;
|
|
@@ -3137,7 +3143,7 @@ var init_client = __esm(() => {
|
|
|
3137
3143
|
init_tslib();
|
|
3138
3144
|
init_values();
|
|
3139
3145
|
init_detect_platform();
|
|
3140
|
-
|
|
3146
|
+
init_query();
|
|
3141
3147
|
init_error();
|
|
3142
3148
|
init_pagination();
|
|
3143
3149
|
init_uploads2();
|
|
@@ -3216,7 +3222,7 @@ var package_default;
|
|
|
3216
3222
|
var init_package = __esm(() => {
|
|
3217
3223
|
package_default = {
|
|
3218
3224
|
name: "@letta-ai/letta-code",
|
|
3219
|
-
version: "0.
|
|
3225
|
+
version: "0.17.0",
|
|
3220
3226
|
description: "Letta Code is a CLI tool for interacting with stateful Letta agents from the terminal.",
|
|
3221
3227
|
type: "module",
|
|
3222
3228
|
bin: {
|
|
@@ -3249,7 +3255,7 @@ var init_package = __esm(() => {
|
|
|
3249
3255
|
access: "public"
|
|
3250
3256
|
},
|
|
3251
3257
|
dependencies: {
|
|
3252
|
-
"@letta-ai/letta-client": "^1.7.
|
|
3258
|
+
"@letta-ai/letta-client": "^1.7.11",
|
|
3253
3259
|
glob: "^13.0.0",
|
|
3254
3260
|
"ink-link": "^5.0.0",
|
|
3255
3261
|
open: "^10.2.0",
|
|
@@ -4695,6 +4701,12 @@ var approval_recovery_alert_default = `<system-reminder>Automated keep-alive pin
|
|
|
4695
4701
|
`;
|
|
4696
4702
|
var init_approval_recovery_alert = () => {};
|
|
4697
4703
|
|
|
4704
|
+
// src/agent/prompts/auto_init_reminder.txt
|
|
4705
|
+
var auto_init_reminder_default = `<system-reminder>
|
|
4706
|
+
A background agent is initializing this agent's memory system. Briefly let the user know that memory is being set up in the background, then respond to their message normally.
|
|
4707
|
+
</system-reminder>`;
|
|
4708
|
+
var init_auto_init_reminder = () => {};
|
|
4709
|
+
|
|
4698
4710
|
// src/agent/prompts/claude.md
|
|
4699
4711
|
var claude_default = `You are Letta Code, a state-of-the-art coding agent running within the Letta Code CLI on a user's computer.
|
|
4700
4712
|
You are an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.
|
|
@@ -7182,6 +7194,7 @@ __export(exports_promptAssets, {
|
|
|
7182
7194
|
MEMORY_PROMPTS: () => MEMORY_PROMPTS,
|
|
7183
7195
|
MEMORY_CHECK_REMINDER: () => MEMORY_CHECK_REMINDER,
|
|
7184
7196
|
INTERRUPT_RECOVERY_ALERT: () => INTERRUPT_RECOVERY_ALERT,
|
|
7197
|
+
AUTO_INIT_REMINDER: () => AUTO_INIT_REMINDER,
|
|
7185
7198
|
APPROVAL_RECOVERY_PROMPT: () => APPROVAL_RECOVERY_PROMPT
|
|
7186
7199
|
});
|
|
7187
7200
|
async function resolveSystemPrompt(systemPromptPreset) {
|
|
@@ -7200,9 +7213,10 @@ async function resolveSystemPrompt(systemPromptPreset) {
|
|
|
7200
7213
|
}
|
|
7201
7214
|
return SYSTEM_PROMPT;
|
|
7202
7215
|
}
|
|
7203
|
-
var SYSTEM_PROMPT, SYSTEM_PROMPT_MEMORY_ADDON, SYSTEM_PROMPT_MEMFS_ADDON, PLAN_MODE_REMINDER, SKILL_CREATOR_PROMPT, REMEMBER_PROMPT, MEMORY_CHECK_REMINDER, MEMORY_REFLECTION_REMINDER, APPROVAL_RECOVERY_PROMPT, INTERRUPT_RECOVERY_ALERT, MEMORY_PROMPTS, SYSTEM_PROMPTS;
|
|
7216
|
+
var SYSTEM_PROMPT, SYSTEM_PROMPT_MEMORY_ADDON, SYSTEM_PROMPT_MEMFS_ADDON, PLAN_MODE_REMINDER, SKILL_CREATOR_PROMPT, REMEMBER_PROMPT, MEMORY_CHECK_REMINDER, MEMORY_REFLECTION_REMINDER, APPROVAL_RECOVERY_PROMPT, AUTO_INIT_REMINDER, INTERRUPT_RECOVERY_ALERT, MEMORY_PROMPTS, SYSTEM_PROMPTS;
|
|
7204
7217
|
var init_promptAssets = __esm(() => {
|
|
7205
7218
|
init_approval_recovery_alert();
|
|
7219
|
+
init_auto_init_reminder();
|
|
7206
7220
|
init_claude();
|
|
7207
7221
|
init_codex();
|
|
7208
7222
|
init_gemini();
|
|
@@ -7235,6 +7249,7 @@ var init_promptAssets = __esm(() => {
|
|
|
7235
7249
|
MEMORY_CHECK_REMINDER = memory_check_reminder_default;
|
|
7236
7250
|
MEMORY_REFLECTION_REMINDER = memory_reflection_reminder_default;
|
|
7237
7251
|
APPROVAL_RECOVERY_PROMPT = approval_recovery_alert_default;
|
|
7252
|
+
AUTO_INIT_REMINDER = auto_init_reminder_default;
|
|
7238
7253
|
INTERRUPT_RECOVERY_ALERT = interrupt_recovery_alert_default;
|
|
7239
7254
|
MEMORY_PROMPTS = {
|
|
7240
7255
|
"persona.mdx": persona_default,
|
|
@@ -7301,6 +7316,20 @@ var init_promptAssets = __esm(() => {
|
|
|
7301
7316
|
var models_default;
|
|
7302
7317
|
var init_models2 = __esm(() => {
|
|
7303
7318
|
models_default = [
|
|
7319
|
+
{
|
|
7320
|
+
id: "auto",
|
|
7321
|
+
handle: "letta/auto",
|
|
7322
|
+
label: "Auto",
|
|
7323
|
+
description: "Automatically select the best model",
|
|
7324
|
+
isFeatured: true
|
|
7325
|
+
},
|
|
7326
|
+
{
|
|
7327
|
+
id: "auto-fast",
|
|
7328
|
+
handle: "letta/auto-fast",
|
|
7329
|
+
label: "Auto Fast",
|
|
7330
|
+
description: "Automatically select the best fast model",
|
|
7331
|
+
isFeatured: true
|
|
7332
|
+
},
|
|
7304
7333
|
{
|
|
7305
7334
|
id: "sonnet",
|
|
7306
7335
|
handle: "anthropic/claude-sonnet-4-6",
|
|
@@ -7370,6 +7399,19 @@ var init_models2 = __esm(() => {
|
|
|
7370
7399
|
parallel_tool_calls: true
|
|
7371
7400
|
}
|
|
7372
7401
|
},
|
|
7402
|
+
{
|
|
7403
|
+
id: "sonnet-4.6-xhigh",
|
|
7404
|
+
handle: "anthropic/claude-sonnet-4-6",
|
|
7405
|
+
label: "Sonnet 4.6",
|
|
7406
|
+
description: "Sonnet 4.6 (max reasoning)",
|
|
7407
|
+
updateArgs: {
|
|
7408
|
+
context_window: 200000,
|
|
7409
|
+
max_output_tokens: 128000,
|
|
7410
|
+
reasoning_effort: "xhigh",
|
|
7411
|
+
enable_reasoner: true,
|
|
7412
|
+
parallel_tool_calls: true
|
|
7413
|
+
}
|
|
7414
|
+
},
|
|
7373
7415
|
{
|
|
7374
7416
|
id: "sonnet-4.5",
|
|
7375
7417
|
handle: "anthropic/claude-sonnet-4-5-20250929",
|
|
@@ -7449,18 +7491,74 @@ var init_models2 = __esm(() => {
|
|
|
7449
7491
|
parallel_tool_calls: true
|
|
7450
7492
|
}
|
|
7451
7493
|
},
|
|
7494
|
+
{
|
|
7495
|
+
id: "opus-4.6-xhigh",
|
|
7496
|
+
handle: "anthropic/claude-opus-4-6",
|
|
7497
|
+
label: "Opus 4.6",
|
|
7498
|
+
description: "Opus 4.6 (max reasoning)",
|
|
7499
|
+
updateArgs: {
|
|
7500
|
+
context_window: 200000,
|
|
7501
|
+
max_output_tokens: 128000,
|
|
7502
|
+
reasoning_effort: "xhigh",
|
|
7503
|
+
enable_reasoner: true,
|
|
7504
|
+
parallel_tool_calls: true
|
|
7505
|
+
}
|
|
7506
|
+
},
|
|
7452
7507
|
{
|
|
7453
7508
|
id: "opus-4.5",
|
|
7454
7509
|
handle: "anthropic/claude-opus-4-5-20251101",
|
|
7455
7510
|
label: "Opus 4.5",
|
|
7456
|
-
description: "Anthropic's (legacy) best model",
|
|
7511
|
+
description: "Anthropic's (legacy) best model (high reasoning)",
|
|
7457
7512
|
updateArgs: {
|
|
7458
7513
|
context_window: 180000,
|
|
7459
7514
|
max_output_tokens: 64000,
|
|
7515
|
+
reasoning_effort: "high",
|
|
7516
|
+
enable_reasoner: true,
|
|
7460
7517
|
max_reasoning_tokens: 31999,
|
|
7461
7518
|
parallel_tool_calls: true
|
|
7462
7519
|
}
|
|
7463
7520
|
},
|
|
7521
|
+
{
|
|
7522
|
+
id: "opus-4.5-no-reasoning",
|
|
7523
|
+
handle: "anthropic/claude-opus-4-5-20251101",
|
|
7524
|
+
label: "Opus 4.5",
|
|
7525
|
+
description: "Opus 4.5 with no reasoning (faster)",
|
|
7526
|
+
updateArgs: {
|
|
7527
|
+
context_window: 180000,
|
|
7528
|
+
max_output_tokens: 64000,
|
|
7529
|
+
reasoning_effort: "none",
|
|
7530
|
+
enable_reasoner: false,
|
|
7531
|
+
parallel_tool_calls: true
|
|
7532
|
+
}
|
|
7533
|
+
},
|
|
7534
|
+
{
|
|
7535
|
+
id: "opus-4.5-low",
|
|
7536
|
+
handle: "anthropic/claude-opus-4-5-20251101",
|
|
7537
|
+
label: "Opus 4.5",
|
|
7538
|
+
description: "Opus 4.5 (low reasoning)",
|
|
7539
|
+
updateArgs: {
|
|
7540
|
+
context_window: 180000,
|
|
7541
|
+
max_output_tokens: 64000,
|
|
7542
|
+
reasoning_effort: "low",
|
|
7543
|
+
enable_reasoner: true,
|
|
7544
|
+
max_reasoning_tokens: 4000,
|
|
7545
|
+
parallel_tool_calls: true
|
|
7546
|
+
}
|
|
7547
|
+
},
|
|
7548
|
+
{
|
|
7549
|
+
id: "opus-4.5-medium",
|
|
7550
|
+
handle: "anthropic/claude-opus-4-5-20251101",
|
|
7551
|
+
label: "Opus 4.5",
|
|
7552
|
+
description: "Opus 4.5 (med reasoning)",
|
|
7553
|
+
updateArgs: {
|
|
7554
|
+
context_window: 180000,
|
|
7555
|
+
max_output_tokens: 64000,
|
|
7556
|
+
reasoning_effort: "medium",
|
|
7557
|
+
enable_reasoner: true,
|
|
7558
|
+
max_reasoning_tokens: 12000,
|
|
7559
|
+
parallel_tool_calls: true
|
|
7560
|
+
}
|
|
7561
|
+
},
|
|
7464
7562
|
{
|
|
7465
7563
|
id: "bedrock-opus",
|
|
7466
7564
|
handle: "bedrock/us.anthropic.claude-opus-4-5-20251101-v1:0",
|
|
@@ -34613,6 +34711,27 @@ var init_MarkdownDisplay = __esm(async () => {
|
|
|
34613
34711
|
defaultHeaderStyle = { italic: true };
|
|
34614
34712
|
});
|
|
34615
34713
|
|
|
34714
|
+
// src/cli/helpers/appUrls.ts
|
|
34715
|
+
function buildChatUrl(agentId, options) {
|
|
34716
|
+
const base2 = `${APP_BASE}/chat/${agentId}`;
|
|
34717
|
+
const params = new URLSearchParams;
|
|
34718
|
+
if (options?.view) {
|
|
34719
|
+
params.set("view", options.view);
|
|
34720
|
+
}
|
|
34721
|
+
if (options?.deviceId) {
|
|
34722
|
+
params.set("deviceId", options.deviceId);
|
|
34723
|
+
}
|
|
34724
|
+
if (options?.conversationId && options.conversationId !== "default") {
|
|
34725
|
+
params.set("conversation", options.conversationId);
|
|
34726
|
+
}
|
|
34727
|
+
const qs = params.toString();
|
|
34728
|
+
return qs ? `${base2}?${qs}` : base2;
|
|
34729
|
+
}
|
|
34730
|
+
function buildAppUrl(path2) {
|
|
34731
|
+
return `${APP_BASE}${path2}`;
|
|
34732
|
+
}
|
|
34733
|
+
var APP_BASE = "https://app.letta.com";
|
|
34734
|
+
|
|
34616
34735
|
// src/cli/helpers/errorContext.ts
|
|
34617
34736
|
function setErrorContext(context2) {
|
|
34618
34737
|
currentContext = { ...currentContext, ...context2 };
|
|
@@ -60492,6 +60611,7 @@ function buildSubagentArgs(type, config, model, userPrompt, existingAgentId, exi
|
|
|
60492
60611
|
}
|
|
60493
60612
|
} else {
|
|
60494
60613
|
args.push("--new-agent", "--system", type);
|
|
60614
|
+
args.push("--tags", `type:${type}`);
|
|
60495
60615
|
if (model) {
|
|
60496
60616
|
args.push("--model", model);
|
|
60497
60617
|
}
|
|
@@ -66624,9 +66744,6 @@ async function getResumeData2(client, agent, conversationId, options = {}) {
|
|
|
66624
66744
|
let inContextMessageIds;
|
|
66625
66745
|
let messages = [];
|
|
66626
66746
|
const useConversationsApi = conversationId && conversationId !== "default";
|
|
66627
|
-
if (process.env.DEBUG) {
|
|
66628
|
-
console.log(`[DEBUG] getResumeData: conversationId=${conversationId}, useConversationsApi=${useConversationsApi}, agentId=${agent.id}`);
|
|
66629
|
-
}
|
|
66630
66747
|
if (useConversationsApi) {
|
|
66631
66748
|
const conversation = await client.conversations.retrieve(conversationId);
|
|
66632
66749
|
inContextMessageIds = conversation.in_context_message_ids;
|
|
@@ -66702,13 +66819,14 @@ async function getResumeData2(client, agent, conversationId, options = {}) {
|
|
|
66702
66819
|
const retrievedMessages = await client.messages.retrieve(lastInContextId);
|
|
66703
66820
|
if (includeMessageHistory && isBackfillEnabled2()) {
|
|
66704
66821
|
try {
|
|
66705
|
-
const messagesPage = await client.conversations.messages.list(
|
|
66822
|
+
const messagesPage = await client.conversations.messages.list("default", {
|
|
66823
|
+
agent_id: agent.id,
|
|
66706
66824
|
limit: BACKFILL_PAGE_LIMIT2,
|
|
66707
66825
|
order: "desc"
|
|
66708
66826
|
});
|
|
66709
66827
|
messages = sortChronological2(messagesPage.getPaginatedItems());
|
|
66710
66828
|
if (process.env.DEBUG) {
|
|
66711
|
-
console.log(`[DEBUG] conversations.messages.list(
|
|
66829
|
+
console.log(`[DEBUG] conversations.messages.list(default, agent_id=${agent.id}) returned ${messages.length} messages`);
|
|
66712
66830
|
}
|
|
66713
66831
|
} catch (backfillError) {
|
|
66714
66832
|
debugWarn("check-approval", `Failed to load message history: ${backfillError instanceof Error ? backfillError.message : String(backfillError)}`);
|
|
@@ -66768,21 +66886,24 @@ async function sendMessageStream(conversationId, messages, opts = { streamTokens
|
|
|
66768
66886
|
const client = await getClient2();
|
|
66769
66887
|
await waitForToolsetReady();
|
|
66770
66888
|
const { clientTools, contextId } = captureToolExecutionContext();
|
|
66771
|
-
const
|
|
66772
|
-
if (!
|
|
66889
|
+
const isDefaultConversation = conversationId === "default";
|
|
66890
|
+
if (isDefaultConversation && !opts.agentId) {
|
|
66773
66891
|
throw new Error("agentId is required in opts when using default conversation");
|
|
66774
66892
|
}
|
|
66775
|
-
|
|
66776
|
-
|
|
66777
|
-
}
|
|
66778
|
-
const stream2 = await client.conversations.messages.create(resolvedConversationId, {
|
|
66893
|
+
const resolvedConversationId = conversationId;
|
|
66894
|
+
const requestBody = {
|
|
66779
66895
|
messages,
|
|
66780
66896
|
streaming: true,
|
|
66781
66897
|
stream_tokens: opts.streamTokens ?? true,
|
|
66782
66898
|
background: opts.background ?? true,
|
|
66783
66899
|
client_tools: clientTools,
|
|
66784
|
-
include_compaction_messages: true
|
|
66785
|
-
|
|
66900
|
+
include_compaction_messages: true,
|
|
66901
|
+
...isDefaultConversation ? { agent_id: opts.agentId } : {}
|
|
66902
|
+
};
|
|
66903
|
+
if (process.env.DEBUG) {
|
|
66904
|
+
console.log(`[DEBUG] sendMessageStream: conversationId=${conversationId}, agentId=${opts.agentId ?? "(none)"}`);
|
|
66905
|
+
}
|
|
66906
|
+
const stream2 = await client.conversations.messages.create(resolvedConversationId, requestBody, requestOptions);
|
|
66786
66907
|
if (requestStartTime !== undefined) {
|
|
66787
66908
|
streamRequestStartTimes.set(stream2, requestStartTime);
|
|
66788
66909
|
}
|
|
@@ -67262,14 +67383,16 @@ function getProviderDisplayName() {
|
|
|
67262
67383
|
return ENDPOINT_TYPE_DISPLAY_NAMES[modelEndpointType] ?? modelEndpointType;
|
|
67263
67384
|
}
|
|
67264
67385
|
function createAgentLink2(runId, agentId, conversationId) {
|
|
67265
|
-
const url =
|
|
67386
|
+
const url = buildChatUrl(agentId, { conversationId });
|
|
67266
67387
|
return `View agent: \x1B]8;;${url}\x1B\\${agentId}\x1B]8;;\x1B\\ (run: ${runId})`;
|
|
67267
67388
|
}
|
|
67268
|
-
var LETTA_USAGE_URL2
|
|
67389
|
+
var LETTA_USAGE_URL2, LETTA_AGENTS_URL2, CLOUDFLARE_EDGE_5XX_MARKER_PATTERN2, CLOUDFLARE_EDGE_5XX_TITLE_PATTERN2, CHATGPT_USAGE_LIMIT_HINT2 = "Switch models with /model, or connect your own provider keys with /connect.", ENCRYPTED_CONTENT_HINT2, DEFAULT_RETRY_MESSAGE = "Unexpected downstream LLM API error, retrying...", ENDPOINT_TYPE_DISPLAY_NAMES;
|
|
67269
67390
|
var init_errorFormatter = __esm(() => {
|
|
67270
67391
|
init_error();
|
|
67271
67392
|
init_errorContext();
|
|
67272
67393
|
init_zaiErrors();
|
|
67394
|
+
LETTA_USAGE_URL2 = buildAppUrl("/settings/organization/usage");
|
|
67395
|
+
LETTA_AGENTS_URL2 = buildAppUrl("/projects/default-project/agents");
|
|
67273
67396
|
CLOUDFLARE_EDGE_5XX_MARKER_PATTERN2 = /(^|\s)(502|52[0-6])\s*<!doctype html|error code\s*(502|52[0-6])/i;
|
|
67274
67397
|
CLOUDFLARE_EDGE_5XX_TITLE_PATTERN2 = /\|\s*(502|52[0-6])\s*:/i;
|
|
67275
67398
|
ENCRYPTED_CONTENT_HINT2 = [
|
|
@@ -72353,19 +72476,19 @@ __export(exports_skills2, {
|
|
|
72353
72476
|
SKILLS_DIR: () => SKILLS_DIR2,
|
|
72354
72477
|
GLOBAL_SKILLS_DIR: () => GLOBAL_SKILLS_DIR2
|
|
72355
72478
|
});
|
|
72356
|
-
import { existsSync as
|
|
72479
|
+
import { existsSync as existsSync13 } from "node:fs";
|
|
72357
72480
|
import { readdir as readdir6, readFile as readFile5, realpath as realpath3, stat as stat3 } from "node:fs/promises";
|
|
72358
|
-
import { dirname as dirname8, join as
|
|
72481
|
+
import { dirname as dirname8, join as join22 } from "node:path";
|
|
72359
72482
|
import { fileURLToPath as fileURLToPath8 } from "node:url";
|
|
72360
72483
|
function getBundledSkillsPath2() {
|
|
72361
72484
|
const thisDir = dirname8(fileURLToPath8(import.meta.url));
|
|
72362
72485
|
if (thisDir.includes("src/agent") || thisDir.includes("src\\agent")) {
|
|
72363
|
-
return
|
|
72486
|
+
return join22(thisDir, "../skills/builtin");
|
|
72364
72487
|
}
|
|
72365
|
-
return
|
|
72488
|
+
return join22(thisDir, "skills");
|
|
72366
72489
|
}
|
|
72367
72490
|
function getAgentSkillsDir2(agentId) {
|
|
72368
|
-
return
|
|
72491
|
+
return join22(process.env.HOME || process.env.USERPROFILE || "~", ".letta/agents", agentId, "skills");
|
|
72369
72492
|
}
|
|
72370
72493
|
async function getBundledSkills2() {
|
|
72371
72494
|
const bundledPath = getBundledSkillsPath2();
|
|
@@ -72374,7 +72497,7 @@ async function getBundledSkills2() {
|
|
|
72374
72497
|
}
|
|
72375
72498
|
async function discoverSkillsFromDir2(skillsPath, source) {
|
|
72376
72499
|
const errors = [];
|
|
72377
|
-
if (!
|
|
72500
|
+
if (!existsSync13(skillsPath)) {
|
|
72378
72501
|
return { skills: [], errors: [] };
|
|
72379
72502
|
}
|
|
72380
72503
|
const skills = [];
|
|
@@ -72388,7 +72511,7 @@ async function discoverSkillsFromDir2(skillsPath, source) {
|
|
|
72388
72511
|
}
|
|
72389
72512
|
return { skills, errors };
|
|
72390
72513
|
}
|
|
72391
|
-
async function discoverSkills2(projectSkillsPath =
|
|
72514
|
+
async function discoverSkills2(projectSkillsPath = join22(process.cwd(), SKILLS_DIR2), agentId, options) {
|
|
72392
72515
|
const allErrors = [];
|
|
72393
72516
|
const skillsById = new Map;
|
|
72394
72517
|
const sourceSet = new Set(options?.sources ?? ALL_SKILL_SOURCES);
|
|
@@ -72443,7 +72566,7 @@ async function findSkillFiles2(currentPath, rootPath, skills, errors, source, vi
|
|
|
72443
72566
|
try {
|
|
72444
72567
|
const entries = await readdir6(currentPath, { withFileTypes: true });
|
|
72445
72568
|
for (const entry of entries) {
|
|
72446
|
-
const fullPath =
|
|
72569
|
+
const fullPath = join22(currentPath, entry.name);
|
|
72447
72570
|
try {
|
|
72448
72571
|
let isDirectory = entry.isDirectory();
|
|
72449
72572
|
let isFile = entry.isFile();
|
|
@@ -72532,7 +72655,7 @@ ${lines.join(`
|
|
|
72532
72655
|
var SKILLS_DIR2 = ".skills", GLOBAL_SKILLS_DIR2;
|
|
72533
72656
|
var init_skills2 = __esm(() => {
|
|
72534
72657
|
init_skillSources();
|
|
72535
|
-
GLOBAL_SKILLS_DIR2 =
|
|
72658
|
+
GLOBAL_SKILLS_DIR2 = join22(process.env.HOME || process.env.USERPROFILE || "~", ".letta/skills");
|
|
72536
72659
|
});
|
|
72537
72660
|
|
|
72538
72661
|
// src/utils/fs.ts
|
|
@@ -72546,10 +72669,10 @@ __export(exports_fs, {
|
|
|
72546
72669
|
exists: () => exists2
|
|
72547
72670
|
});
|
|
72548
72671
|
import {
|
|
72549
|
-
existsSync as
|
|
72672
|
+
existsSync as existsSync14,
|
|
72550
72673
|
readFileSync as fsReadFileSync2,
|
|
72551
72674
|
writeFileSync as fsWriteFileSync2,
|
|
72552
|
-
mkdirSync as
|
|
72675
|
+
mkdirSync as mkdirSync11
|
|
72553
72676
|
} from "node:fs";
|
|
72554
72677
|
import { dirname as dirname9 } from "node:path";
|
|
72555
72678
|
async function readFile6(path20) {
|
|
@@ -72557,16 +72680,16 @@ async function readFile6(path20) {
|
|
|
72557
72680
|
}
|
|
72558
72681
|
async function writeFile2(path20, content) {
|
|
72559
72682
|
const dir = dirname9(path20);
|
|
72560
|
-
if (!
|
|
72561
|
-
|
|
72683
|
+
if (!existsSync14(dir)) {
|
|
72684
|
+
mkdirSync11(dir, { recursive: true });
|
|
72562
72685
|
}
|
|
72563
72686
|
fsWriteFileSync2(path20, content, { encoding: "utf-8", flush: true });
|
|
72564
72687
|
}
|
|
72565
72688
|
function exists2(path20) {
|
|
72566
|
-
return
|
|
72689
|
+
return existsSync14(path20);
|
|
72567
72690
|
}
|
|
72568
72691
|
async function mkdir2(path20, options) {
|
|
72569
|
-
|
|
72692
|
+
mkdirSync11(path20, options);
|
|
72570
72693
|
}
|
|
72571
72694
|
async function readJsonFile(path20) {
|
|
72572
72695
|
const text = await readFile6(path20);
|
|
@@ -72886,9 +73009,9 @@ __export(exports_auto_update, {
|
|
|
72886
73009
|
import { execFile as execFile9 } from "node:child_process";
|
|
72887
73010
|
import { realpathSync as realpathSync2 } from "node:fs";
|
|
72888
73011
|
import { readdir as readdir7, rm } from "node:fs/promises";
|
|
72889
|
-
import { join as
|
|
73012
|
+
import { join as join23 } from "node:path";
|
|
72890
73013
|
import { promisify as promisify9 } from "node:util";
|
|
72891
|
-
function
|
|
73014
|
+
function debugLog3(...args) {
|
|
72892
73015
|
if (DEBUG) {
|
|
72893
73016
|
console.error("[auto-update]", ...args);
|
|
72894
73017
|
}
|
|
@@ -72955,10 +73078,10 @@ function detectPackageManager() {
|
|
|
72955
73078
|
const envOverride = process.env.LETTA_PACKAGE_MANAGER;
|
|
72956
73079
|
if (envOverride) {
|
|
72957
73080
|
if (VALID_PACKAGE_MANAGERS.has(envOverride)) {
|
|
72958
|
-
|
|
73081
|
+
debugLog3("Package manager from LETTA_PACKAGE_MANAGER:", envOverride);
|
|
72959
73082
|
return envOverride;
|
|
72960
73083
|
}
|
|
72961
|
-
|
|
73084
|
+
debugLog3(`Invalid LETTA_PACKAGE_MANAGER="${envOverride}", falling back to path detection`);
|
|
72962
73085
|
}
|
|
72963
73086
|
const argv = process.argv[1] || "";
|
|
72964
73087
|
let resolvedPath = argv;
|
|
@@ -72966,14 +73089,14 @@ function detectPackageManager() {
|
|
|
72966
73089
|
resolvedPath = realpathSync2(argv);
|
|
72967
73090
|
} catch {}
|
|
72968
73091
|
if (/[/\\]\.bun[/\\]/.test(resolvedPath)) {
|
|
72969
|
-
|
|
73092
|
+
debugLog3("Detected package manager from path: bun");
|
|
72970
73093
|
return "bun";
|
|
72971
73094
|
}
|
|
72972
73095
|
if (/[/\\]\.?pnpm[/\\]/.test(resolvedPath)) {
|
|
72973
|
-
|
|
73096
|
+
debugLog3("Detected package manager from path: pnpm");
|
|
72974
73097
|
return "pnpm";
|
|
72975
73098
|
}
|
|
72976
|
-
|
|
73099
|
+
debugLog3("Detected package manager from path: npm (default)");
|
|
72977
73100
|
return "npm";
|
|
72978
73101
|
}
|
|
72979
73102
|
function isAutoUpdateEnabled() {
|
|
@@ -72985,22 +73108,22 @@ function isRunningLocally() {
|
|
|
72985
73108
|
try {
|
|
72986
73109
|
resolvedPath = realpathSync2(argv);
|
|
72987
73110
|
} catch {}
|
|
72988
|
-
|
|
72989
|
-
|
|
73111
|
+
debugLog3("argv[1]:", argv);
|
|
73112
|
+
debugLog3("resolved path:", resolvedPath);
|
|
72990
73113
|
return !resolvedPath.includes("node_modules");
|
|
72991
73114
|
}
|
|
72992
73115
|
async function checkForUpdate() {
|
|
72993
73116
|
const currentVersion = getVersion();
|
|
72994
|
-
|
|
73117
|
+
debugLog3("Current version:", currentVersion);
|
|
72995
73118
|
if (currentVersion.includes("-")) {
|
|
72996
|
-
|
|
73119
|
+
debugLog3("Prerelease version detected, skipping auto-update check");
|
|
72997
73120
|
return { updateAvailable: false, currentVersion };
|
|
72998
73121
|
}
|
|
72999
73122
|
const packageName = resolveUpdatePackageName();
|
|
73000
73123
|
const registryBaseUrl = resolveUpdateRegistryBaseUrl();
|
|
73001
73124
|
const latestUrl = buildLatestVersionUrl(packageName, registryBaseUrl);
|
|
73002
73125
|
try {
|
|
73003
|
-
|
|
73126
|
+
debugLog3("Checking registry for latest version:", latestUrl);
|
|
73004
73127
|
const res = await fetch(latestUrl, {
|
|
73005
73128
|
signal: AbortSignal.timeout(5000)
|
|
73006
73129
|
});
|
|
@@ -73012,18 +73135,18 @@ async function checkForUpdate() {
|
|
|
73012
73135
|
throw new Error("Unexpected registry response shape");
|
|
73013
73136
|
}
|
|
73014
73137
|
const latestVersion = data.version;
|
|
73015
|
-
|
|
73138
|
+
debugLog3("Latest version from registry:", latestVersion);
|
|
73016
73139
|
if (latestVersion !== currentVersion) {
|
|
73017
|
-
|
|
73140
|
+
debugLog3("Update available!");
|
|
73018
73141
|
return {
|
|
73019
73142
|
updateAvailable: true,
|
|
73020
73143
|
latestVersion,
|
|
73021
73144
|
currentVersion
|
|
73022
73145
|
};
|
|
73023
73146
|
}
|
|
73024
|
-
|
|
73147
|
+
debugLog3("Already on latest version");
|
|
73025
73148
|
} catch (error) {
|
|
73026
|
-
|
|
73149
|
+
debugLog3("Failed to check for updates:", error);
|
|
73027
73150
|
return {
|
|
73028
73151
|
updateAvailable: false,
|
|
73029
73152
|
currentVersion,
|
|
@@ -73046,13 +73169,13 @@ async function getNpmGlobalPath() {
|
|
|
73046
73169
|
}
|
|
73047
73170
|
}
|
|
73048
73171
|
async function cleanupOrphanedDirs(globalPath) {
|
|
73049
|
-
const lettaAiDir =
|
|
73172
|
+
const lettaAiDir = join23(globalPath, "lib/node_modules/@letta-ai");
|
|
73050
73173
|
try {
|
|
73051
73174
|
const entries = await readdir7(lettaAiDir);
|
|
73052
73175
|
for (const entry of entries) {
|
|
73053
73176
|
if (entry.startsWith(".letta-code-")) {
|
|
73054
|
-
const orphanPath =
|
|
73055
|
-
|
|
73177
|
+
const orphanPath = join23(lettaAiDir, entry);
|
|
73178
|
+
debugLog3("Cleaning orphaned temp directory:", orphanPath);
|
|
73056
73179
|
await rm(orphanPath, { recursive: true, force: true });
|
|
73057
73180
|
}
|
|
73058
73181
|
}
|
|
@@ -73062,33 +73185,33 @@ async function performUpdate() {
|
|
|
73062
73185
|
const pm = detectPackageManager();
|
|
73063
73186
|
const installCmd = buildInstallCommand(pm);
|
|
73064
73187
|
const installArgs = buildInstallArgs(pm);
|
|
73065
|
-
|
|
73066
|
-
|
|
73188
|
+
debugLog3("Detected package manager:", pm);
|
|
73189
|
+
debugLog3("Install command:", installCmd);
|
|
73067
73190
|
let globalPath = null;
|
|
73068
73191
|
if (pm === "npm") {
|
|
73069
73192
|
globalPath = await getNpmGlobalPath();
|
|
73070
73193
|
if (globalPath) {
|
|
73071
|
-
|
|
73194
|
+
debugLog3("Pre-cleaning orphaned directories in:", globalPath);
|
|
73072
73195
|
await cleanupOrphanedDirs(globalPath);
|
|
73073
73196
|
}
|
|
73074
73197
|
}
|
|
73075
73198
|
try {
|
|
73076
|
-
|
|
73199
|
+
debugLog3(`Running ${installCmd}...`);
|
|
73077
73200
|
await execFileAsync7(pm, installArgs, { timeout: 60000 });
|
|
73078
|
-
|
|
73201
|
+
debugLog3("Update completed successfully");
|
|
73079
73202
|
return { success: true };
|
|
73080
73203
|
} catch (error) {
|
|
73081
73204
|
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
73082
73205
|
if (pm === "npm" && errorMsg.includes("ENOTEMPTY") && globalPath) {
|
|
73083
|
-
|
|
73206
|
+
debugLog3("ENOTEMPTY detected, attempting cleanup and retry...");
|
|
73084
73207
|
await cleanupOrphanedDirs(globalPath);
|
|
73085
73208
|
try {
|
|
73086
73209
|
await execFileAsync7(pm, installArgs, { timeout: 60000 });
|
|
73087
|
-
|
|
73210
|
+
debugLog3("Update succeeded after cleanup retry");
|
|
73088
73211
|
return { success: true };
|
|
73089
73212
|
} catch (retryError) {
|
|
73090
73213
|
const retryMsg = retryError instanceof Error ? retryError.message : String(retryError);
|
|
73091
|
-
|
|
73214
|
+
debugLog3("Update failed after retry:", retryMsg);
|
|
73092
73215
|
if (retryMsg.includes("ENOTEMPTY")) {
|
|
73093
73216
|
return {
|
|
73094
73217
|
success: false,
|
|
@@ -73101,21 +73224,21 @@ async function performUpdate() {
|
|
|
73101
73224
|
}
|
|
73102
73225
|
const isNpmRaceCondition = pm === "npm" && (errorMsg.includes("TAR_ENTRY_ERROR") || errorMsg.includes("uv_cwd") || errorMsg.includes("spawn sh") && errorMsg.includes("ENOENT"));
|
|
73103
73226
|
if (isNpmRaceCondition) {
|
|
73104
|
-
|
|
73227
|
+
debugLog3("npm race condition detected, cleaning up and retrying...");
|
|
73105
73228
|
if (globalPath) {
|
|
73106
73229
|
await cleanupOrphanedDirs(globalPath);
|
|
73107
73230
|
}
|
|
73108
73231
|
try {
|
|
73109
73232
|
await execFileAsync7(pm, installArgs, { timeout: 60000 });
|
|
73110
|
-
|
|
73233
|
+
debugLog3("Update succeeded after race condition retry");
|
|
73111
73234
|
return { success: true };
|
|
73112
73235
|
} catch (retryError) {
|
|
73113
73236
|
const retryMsg = retryError instanceof Error ? retryError.message : String(retryError);
|
|
73114
|
-
|
|
73237
|
+
debugLog3("Update failed after race condition retry:", retryMsg);
|
|
73115
73238
|
return { success: false, error: retryMsg };
|
|
73116
73239
|
}
|
|
73117
73240
|
}
|
|
73118
|
-
|
|
73241
|
+
debugLog3("Update failed:", error);
|
|
73119
73242
|
return { success: false, error: errorMsg };
|
|
73120
73243
|
}
|
|
73121
73244
|
}
|
|
@@ -73129,16 +73252,16 @@ function isSignificantUpdate(current, latest) {
|
|
|
73129
73252
|
return false;
|
|
73130
73253
|
}
|
|
73131
73254
|
async function checkAndAutoUpdate() {
|
|
73132
|
-
|
|
73133
|
-
|
|
73255
|
+
debugLog3("Auto-update check starting...");
|
|
73256
|
+
debugLog3("isAutoUpdateEnabled:", isAutoUpdateEnabled());
|
|
73134
73257
|
const runningLocally = isRunningLocally();
|
|
73135
|
-
|
|
73258
|
+
debugLog3("isRunningLocally:", runningLocally);
|
|
73136
73259
|
if (!isAutoUpdateEnabled()) {
|
|
73137
|
-
|
|
73260
|
+
debugLog3("Auto-update disabled via DISABLE_AUTOUPDATER=1");
|
|
73138
73261
|
return;
|
|
73139
73262
|
}
|
|
73140
73263
|
if (runningLocally) {
|
|
73141
|
-
|
|
73264
|
+
debugLog3("Running locally, skipping auto-update");
|
|
73142
73265
|
return;
|
|
73143
73266
|
}
|
|
73144
73267
|
const result = await checkForUpdate();
|
|
@@ -73313,6 +73436,7 @@ __export(exports_promptAssets2, {
|
|
|
73313
73436
|
MEMORY_PROMPTS: () => MEMORY_PROMPTS2,
|
|
73314
73437
|
MEMORY_CHECK_REMINDER: () => MEMORY_CHECK_REMINDER2,
|
|
73315
73438
|
INTERRUPT_RECOVERY_ALERT: () => INTERRUPT_RECOVERY_ALERT2,
|
|
73439
|
+
AUTO_INIT_REMINDER: () => AUTO_INIT_REMINDER2,
|
|
73316
73440
|
APPROVAL_RECOVERY_PROMPT: () => APPROVAL_RECOVERY_PROMPT2
|
|
73317
73441
|
});
|
|
73318
73442
|
async function resolveSystemPrompt2(systemPromptPreset) {
|
|
@@ -73331,9 +73455,10 @@ async function resolveSystemPrompt2(systemPromptPreset) {
|
|
|
73331
73455
|
}
|
|
73332
73456
|
return SYSTEM_PROMPT2;
|
|
73333
73457
|
}
|
|
73334
|
-
var SYSTEM_PROMPT2, SYSTEM_PROMPT_MEMORY_ADDON2, SYSTEM_PROMPT_MEMFS_ADDON2, PLAN_MODE_REMINDER2, SKILL_CREATOR_PROMPT2, REMEMBER_PROMPT2, MEMORY_CHECK_REMINDER2, MEMORY_REFLECTION_REMINDER2, APPROVAL_RECOVERY_PROMPT2, INTERRUPT_RECOVERY_ALERT2, MEMORY_PROMPTS2, SYSTEM_PROMPTS2;
|
|
73458
|
+
var SYSTEM_PROMPT2, SYSTEM_PROMPT_MEMORY_ADDON2, SYSTEM_PROMPT_MEMFS_ADDON2, PLAN_MODE_REMINDER2, SKILL_CREATOR_PROMPT2, REMEMBER_PROMPT2, MEMORY_CHECK_REMINDER2, MEMORY_REFLECTION_REMINDER2, APPROVAL_RECOVERY_PROMPT2, AUTO_INIT_REMINDER2, INTERRUPT_RECOVERY_ALERT2, MEMORY_PROMPTS2, SYSTEM_PROMPTS2;
|
|
73335
73459
|
var init_promptAssets2 = __esm(() => {
|
|
73336
73460
|
init_approval_recovery_alert();
|
|
73461
|
+
init_auto_init_reminder();
|
|
73337
73462
|
init_claude();
|
|
73338
73463
|
init_codex();
|
|
73339
73464
|
init_gemini();
|
|
@@ -73366,6 +73491,7 @@ var init_promptAssets2 = __esm(() => {
|
|
|
73366
73491
|
MEMORY_CHECK_REMINDER2 = memory_check_reminder_default;
|
|
73367
73492
|
MEMORY_REFLECTION_REMINDER2 = memory_reflection_reminder_default;
|
|
73368
73493
|
APPROVAL_RECOVERY_PROMPT2 = approval_recovery_alert_default;
|
|
73494
|
+
AUTO_INIT_REMINDER2 = auto_init_reminder_default;
|
|
73369
73495
|
INTERRUPT_RECOVERY_ALERT2 = interrupt_recovery_alert_default;
|
|
73370
73496
|
MEMORY_PROMPTS2 = {
|
|
73371
73497
|
"persona.mdx": persona_default,
|
|
@@ -73438,9 +73564,9 @@ __export(exports_subagents2, {
|
|
|
73438
73564
|
GLOBAL_AGENTS_DIR: () => GLOBAL_AGENTS_DIR2,
|
|
73439
73565
|
AGENTS_DIR: () => AGENTS_DIR2
|
|
73440
73566
|
});
|
|
73441
|
-
import { existsSync as
|
|
73567
|
+
import { existsSync as existsSync16 } from "node:fs";
|
|
73442
73568
|
import { readdir as readdir8, readFile as readFile7 } from "node:fs/promises";
|
|
73443
|
-
import { join as
|
|
73569
|
+
import { join as join25 } from "node:path";
|
|
73444
73570
|
function isValidName2(name) {
|
|
73445
73571
|
return /^[a-z][a-z0-9-]*$/.test(name);
|
|
73446
73572
|
}
|
|
@@ -73522,7 +73648,7 @@ function getBuiltinSubagentNames2() {
|
|
|
73522
73648
|
return new Set(Object.keys(getBuiltinSubagents2()));
|
|
73523
73649
|
}
|
|
73524
73650
|
async function discoverSubagentsFromDir2(agentsDir, seenNames, subagents, errors) {
|
|
73525
|
-
if (!
|
|
73651
|
+
if (!existsSync16(agentsDir)) {
|
|
73526
73652
|
return;
|
|
73527
73653
|
}
|
|
73528
73654
|
try {
|
|
@@ -73531,7 +73657,7 @@ async function discoverSubagentsFromDir2(agentsDir, seenNames, subagents, errors
|
|
|
73531
73657
|
if (!entry.isFile() || !entry.name.endsWith(".md")) {
|
|
73532
73658
|
continue;
|
|
73533
73659
|
}
|
|
73534
|
-
const filePath =
|
|
73660
|
+
const filePath = join25(agentsDir, entry.name);
|
|
73535
73661
|
try {
|
|
73536
73662
|
const config = await parseSubagentFile2(filePath);
|
|
73537
73663
|
if (config) {
|
|
@@ -73563,7 +73689,7 @@ async function discoverSubagents2(workingDirectory = process.cwd()) {
|
|
|
73563
73689
|
const subagents = [];
|
|
73564
73690
|
const seenNames = new Set;
|
|
73565
73691
|
await discoverSubagentsFromDir2(GLOBAL_AGENTS_DIR2, seenNames, subagents, errors);
|
|
73566
|
-
const projectAgentsDir =
|
|
73692
|
+
const projectAgentsDir = join25(workingDirectory, AGENTS_DIR2);
|
|
73567
73693
|
await discoverSubagentsFromDir2(projectAgentsDir, seenNames, subagents, errors);
|
|
73568
73694
|
return { subagents, errors };
|
|
73569
73695
|
}
|
|
@@ -73606,7 +73732,7 @@ var init_subagents2 = __esm(() => {
|
|
|
73606
73732
|
recall_default,
|
|
73607
73733
|
reflection_default
|
|
73608
73734
|
];
|
|
73609
|
-
GLOBAL_AGENTS_DIR2 =
|
|
73735
|
+
GLOBAL_AGENTS_DIR2 = join25(process.env.HOME || process.env.USERPROFILE || "~", ".letta/agents");
|
|
73610
73736
|
VALID_MEMORY_BLOCKS2 = new Set(MEMORY_BLOCK_LABELS);
|
|
73611
73737
|
cache5 = {
|
|
73612
73738
|
builtins: null,
|
|
@@ -74003,7 +74129,7 @@ function resolveListMessagesRoute(listReq, sessionConvId, sessionAgentId) {
|
|
|
74003
74129
|
return { kind: "conversations", conversationId: targetConvId };
|
|
74004
74130
|
}
|
|
74005
74131
|
const agentId = listReq.agent_id ?? sessionAgentId;
|
|
74006
|
-
return { kind: "conversations", conversationId: agentId };
|
|
74132
|
+
return { kind: "conversations", conversationId: "default", agentId };
|
|
74007
74133
|
}
|
|
74008
74134
|
|
|
74009
74135
|
// src/agent/bootstrapHandler.ts
|
|
@@ -74022,7 +74148,7 @@ async function handleBootstrapSessionState(params) {
|
|
|
74022
74148
|
try {
|
|
74023
74149
|
const route = resolveListMessagesRoute({ conversation_id: undefined, agent_id: sessionContext.agentId }, sessionContext.conversationId, sessionContext.agentId);
|
|
74024
74150
|
const listStart = Date.now();
|
|
74025
|
-
const page = await client.conversations.messages.list(route.conversationId, { limit: limit2, order });
|
|
74151
|
+
const page = await client.conversations.messages.list(route.conversationId, { limit: limit2, order, ...route.agentId ? { agent_id: route.agentId } : {} });
|
|
74026
74152
|
const items = page.getPaginatedItems();
|
|
74027
74153
|
const listEnd = Date.now();
|
|
74028
74154
|
const hasMore = items.length >= limit2;
|
|
@@ -74377,7 +74503,12 @@ async function handleListMessages(params) {
|
|
|
74377
74503
|
};
|
|
74378
74504
|
try {
|
|
74379
74505
|
const route = resolveListMessagesRoute(listReq, sessionConversationId, sessionAgentId);
|
|
74380
|
-
const page = await client.conversations.messages.list(route.conversationId, {
|
|
74506
|
+
const page = await client.conversations.messages.list(route.conversationId, {
|
|
74507
|
+
limit: limit2,
|
|
74508
|
+
order,
|
|
74509
|
+
...route.agentId ? { agent_id: route.agentId } : {},
|
|
74510
|
+
...cursorOpts
|
|
74511
|
+
});
|
|
74381
74512
|
const items = page.getPaginatedItems();
|
|
74382
74513
|
const hasMore = items.length >= limit2;
|
|
74383
74514
|
const oldestId = items.length > 0 ? items[items.length - 1]?.id : undefined;
|
|
@@ -74998,6 +75129,11 @@ var init_catalog = __esm(() => {
|
|
|
74998
75129
|
description: "Compaction-triggered reflection reminder/auto-launch behavior",
|
|
74999
75130
|
modes: ["interactive", "headless-one-shot", "headless-bidirectional"]
|
|
75000
75131
|
},
|
|
75132
|
+
{
|
|
75133
|
+
id: "deep-init",
|
|
75134
|
+
description: "Auto-launch deep memory init after shallow init + turn gate",
|
|
75135
|
+
modes: ["interactive"]
|
|
75136
|
+
},
|
|
75001
75137
|
{
|
|
75002
75138
|
id: "command-io",
|
|
75003
75139
|
description: "Recent slash command input/output context",
|
|
@@ -75007,6 +75143,11 @@ var init_catalog = __esm(() => {
|
|
|
75007
75143
|
id: "toolset-change",
|
|
75008
75144
|
description: "Client-side toolset change context",
|
|
75009
75145
|
modes: ["interactive"]
|
|
75146
|
+
},
|
|
75147
|
+
{
|
|
75148
|
+
id: "auto-init",
|
|
75149
|
+
description: "Auto-init background onboarding notification",
|
|
75150
|
+
modes: ["interactive"]
|
|
75010
75151
|
}
|
|
75011
75152
|
];
|
|
75012
75153
|
SHARED_REMINDER_IDS = SHARED_REMINDER_CATALOG.map((entry) => entry.id);
|
|
@@ -75014,7 +75155,7 @@ var init_catalog = __esm(() => {
|
|
|
75014
75155
|
});
|
|
75015
75156
|
|
|
75016
75157
|
// src/reminders/engine.ts
|
|
75017
|
-
import { join as
|
|
75158
|
+
import { join as join26 } from "node:path";
|
|
75018
75159
|
async function buildAgentInfoReminder(context3) {
|
|
75019
75160
|
if (context3.state.hasSentAgentInfo) {
|
|
75020
75161
|
return null;
|
|
@@ -75046,7 +75187,7 @@ async function buildSkillsReminder(context3) {
|
|
|
75046
75187
|
const previousSkillsReminder = context3.state.cachedSkillsReminder;
|
|
75047
75188
|
let latestSkillsReminder = previousSkillsReminder ?? "";
|
|
75048
75189
|
try {
|
|
75049
|
-
const skillsDir = getSkillsDirectory() ||
|
|
75190
|
+
const skillsDir = getSkillsDirectory() || join26(process.cwd(), SKILLS_DIR);
|
|
75050
75191
|
const { skills } = await discoverSkills(skillsDir, context3.agent.id, {
|
|
75051
75192
|
sources: context3.skillSources
|
|
75052
75193
|
});
|
|
@@ -75129,6 +75270,30 @@ async function buildReflectionCompactionReminder(context3) {
|
|
|
75129
75270
|
}
|
|
75130
75271
|
return buildCompactionMemoryReminder(context3.agent.id);
|
|
75131
75272
|
}
|
|
75273
|
+
async function buildAutoInitReminder(context3) {
|
|
75274
|
+
if (!context3.state.pendingAutoInitReminder)
|
|
75275
|
+
return null;
|
|
75276
|
+
context3.state.pendingAutoInitReminder = false;
|
|
75277
|
+
const { AUTO_INIT_REMINDER: AUTO_INIT_REMINDER3 } = await Promise.resolve().then(() => (init_promptAssets(), exports_promptAssets));
|
|
75278
|
+
return AUTO_INIT_REMINDER3;
|
|
75279
|
+
}
|
|
75280
|
+
async function maybeLaunchDeepInit(context3) {
|
|
75281
|
+
if (!DEEP_INIT_AUTO_LAUNCH_ENABLED)
|
|
75282
|
+
return null;
|
|
75283
|
+
if (!context3.state.shallowInitCompleted)
|
|
75284
|
+
return null;
|
|
75285
|
+
if (context3.state.deepInitFired)
|
|
75286
|
+
return null;
|
|
75287
|
+
if (context3.state.turnCount < 8)
|
|
75288
|
+
return null;
|
|
75289
|
+
const memfsEnabled = settingsManager.isMemfsEnabled(context3.agent.id);
|
|
75290
|
+
if (!memfsEnabled)
|
|
75291
|
+
return null;
|
|
75292
|
+
if (context3.maybeLaunchDeepInitSubagent) {
|
|
75293
|
+
await context3.maybeLaunchDeepInitSubagent();
|
|
75294
|
+
}
|
|
75295
|
+
return null;
|
|
75296
|
+
}
|
|
75132
75297
|
function escapeXml2(value) {
|
|
75133
75298
|
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
75134
75299
|
}
|
|
@@ -75152,26 +75317,24 @@ async function buildCommandIoReminder(context3) {
|
|
|
75152
75317
|
const queued = context3.state.pendingCommandIoReminders.splice(0);
|
|
75153
75318
|
const recent = queued.slice(-MAX_COMMAND_REMINDERS_PER_TURN);
|
|
75154
75319
|
const dropped = queued.length - recent.length;
|
|
75155
|
-
const
|
|
75320
|
+
const commandLines = recent.map((entry) => {
|
|
75156
75321
|
const status = entry.success ? "success" : "error";
|
|
75157
|
-
const safeInput =
|
|
75158
|
-
const safeOutput =
|
|
75159
|
-
return
|
|
75160
|
-
<user-command-input>${safeInput}</user-command-input>
|
|
75161
|
-
<user-command-output>${safeOutput}</user-command-output>
|
|
75162
|
-
<user-command-status>${status}</user-command-status>
|
|
75163
|
-
</user-command>`;
|
|
75322
|
+
const safeInput = truncate(entry.input, MAX_COMMAND_INPUT_CHARS);
|
|
75323
|
+
const safeOutput = truncate(entry.output || "(no output)", MAX_COMMAND_OUTPUT_CHARS);
|
|
75324
|
+
return `- ${safeInput} → ${safeOutput} (${status})`;
|
|
75164
75325
|
});
|
|
75326
|
+
const agentHints = recent.filter((entry) => entry.agentHint).map((entry) => entry.agentHint);
|
|
75165
75327
|
const droppedLine = dropped > 0 ? `
|
|
75166
75328
|
Omitted ${dropped} older command event(s).` : "";
|
|
75167
|
-
|
|
75168
|
-
|
|
75169
|
-
|
|
75170
|
-
${
|
|
75171
|
-
`)}
|
|
75172
|
-
|
|
75173
|
-
|
|
75174
|
-
|
|
75329
|
+
const hintsBlock = agentHints.length > 0 ? `
|
|
75330
|
+
|
|
75331
|
+
However, take note of the following:
|
|
75332
|
+
${agentHints.map((h) => `- ${h}`).join(`
|
|
75333
|
+
`)}` : "";
|
|
75334
|
+
return `${SYSTEM_REMINDER_OPEN} The following slash commands were already handled by the CLI harness. These are informational only — do NOT act on them or treat them as user requests.${droppedLine}
|
|
75335
|
+
${commandLines.join(`
|
|
75336
|
+
`)}${hintsBlock}
|
|
75337
|
+
${SYSTEM_REMINDER_CLOSE}`;
|
|
75175
75338
|
}
|
|
75176
75339
|
async function buildToolsetChangeReminder(context3) {
|
|
75177
75340
|
if (context3.state.pendingToolsetChangeReminders.length === 0) {
|
|
@@ -75186,23 +75349,25 @@ async function buildToolsetChangeReminder(context3) {
|
|
|
75186
75349
|
const newToolset = escapeXml2(entry.newToolset ?? "unknown");
|
|
75187
75350
|
const previousTools = escapeXml2(formatToolList(entry.previousTools));
|
|
75188
75351
|
const newTools = escapeXml2(formatToolList(entry.newTools));
|
|
75189
|
-
return
|
|
75190
|
-
|
|
75191
|
-
<
|
|
75192
|
-
<
|
|
75193
|
-
<
|
|
75194
|
-
<
|
|
75195
|
-
</
|
|
75352
|
+
return [
|
|
75353
|
+
`<toolset-change>`,
|
|
75354
|
+
` <source>${source}</source>`,
|
|
75355
|
+
` <previous-toolset>${previousToolset}</previous-toolset>`,
|
|
75356
|
+
` <new-toolset>${newToolset}</new-toolset>`,
|
|
75357
|
+
` <previous-tools>${previousTools}</previous-tools>`,
|
|
75358
|
+
` <new-tools>${newTools}</new-tools>`,
|
|
75359
|
+
`</toolset-change>`
|
|
75360
|
+
].join(`
|
|
75361
|
+
`);
|
|
75196
75362
|
});
|
|
75197
75363
|
const droppedLine = dropped > 0 ? `
|
|
75198
75364
|
Omitted ${dropped} older toolset change event(s).` : "";
|
|
75199
|
-
return `${SYSTEM_REMINDER_OPEN}
|
|
75200
|
-
|
|
75365
|
+
return `${SYSTEM_REMINDER_OPEN} The user just changed your toolset (specifically, client-side tools that are attached to the Letta Code harness, which may be a subset of your total tools).${droppedLine}
|
|
75366
|
+
|
|
75201
75367
|
${changeBlocks.join(`
|
|
75202
|
-
`)}
|
|
75203
|
-
${SYSTEM_REMINDER_CLOSE}
|
|
75204
75368
|
|
|
75205
|
-
|
|
75369
|
+
`)}
|
|
75370
|
+
${SYSTEM_REMINDER_CLOSE}`;
|
|
75206
75371
|
}
|
|
75207
75372
|
function assertSharedReminderCoverage() {
|
|
75208
75373
|
const catalogIds = new Set(SHARED_REMINDER_CATALOG.map((entry) => entry.id));
|
|
@@ -75250,7 +75415,7 @@ function prependReminderPartsToContent(content, reminderParts) {
|
|
|
75250
75415
|
}
|
|
75251
75416
|
return content;
|
|
75252
75417
|
}
|
|
75253
|
-
var PERMISSION_MODE_DESCRIPTIONS, MAX_COMMAND_REMINDERS_PER_TURN = 10, MAX_TOOLSET_REMINDERS_PER_TURN = 5, MAX_COMMAND_INPUT_CHARS = 2000, MAX_COMMAND_OUTPUT_CHARS = 4000, MAX_TOOL_LIST_CHARS = 3000, sharedReminderProviders;
|
|
75418
|
+
var PERMISSION_MODE_DESCRIPTIONS, DEEP_INIT_AUTO_LAUNCH_ENABLED = false, MAX_COMMAND_REMINDERS_PER_TURN = 10, MAX_TOOLSET_REMINDERS_PER_TURN = 5, MAX_COMMAND_INPUT_CHARS = 2000, MAX_COMMAND_OUTPUT_CHARS = 4000, MAX_TOOL_LIST_CHARS = 3000, sharedReminderProviders;
|
|
75254
75419
|
var init_engine = __esm(async () => {
|
|
75255
75420
|
init_context();
|
|
75256
75421
|
init_skills();
|
|
@@ -75277,8 +75442,10 @@ var init_engine = __esm(async () => {
|
|
|
75277
75442
|
"plan-mode": buildPlanModeReminder,
|
|
75278
75443
|
"reflection-step-count": buildReflectionStepReminder,
|
|
75279
75444
|
"reflection-compaction": buildReflectionCompactionReminder,
|
|
75445
|
+
"deep-init": maybeLaunchDeepInit,
|
|
75280
75446
|
"command-io": buildCommandIoReminder,
|
|
75281
|
-
"toolset-change": buildToolsetChangeReminder
|
|
75447
|
+
"toolset-change": buildToolsetChangeReminder,
|
|
75448
|
+
"auto-init": buildAutoInitReminder
|
|
75282
75449
|
};
|
|
75283
75450
|
assertSharedReminderCoverage();
|
|
75284
75451
|
});
|
|
@@ -75295,8 +75462,11 @@ function createSharedReminderState() {
|
|
|
75295
75462
|
turnCount: 0,
|
|
75296
75463
|
pendingSkillsReinject: false,
|
|
75297
75464
|
pendingReflectionTrigger: false,
|
|
75465
|
+
pendingAutoInitReminder: false,
|
|
75298
75466
|
pendingCommandIoReminders: [],
|
|
75299
|
-
pendingToolsetChangeReminders: []
|
|
75467
|
+
pendingToolsetChangeReminders: [],
|
|
75468
|
+
shallowInitCompleted: false,
|
|
75469
|
+
deepInitFired: false
|
|
75300
75470
|
};
|
|
75301
75471
|
}
|
|
75302
75472
|
function resetSharedReminderState(state) {
|
|
@@ -75480,7 +75650,7 @@ function parseRegistryHandle(handle) {
|
|
|
75480
75650
|
}
|
|
75481
75651
|
async function importAgentFromRegistry(options) {
|
|
75482
75652
|
const { tmpdir: tmpdir3 } = await import("node:os");
|
|
75483
|
-
const { join:
|
|
75653
|
+
const { join: join27 } = await import("node:path");
|
|
75484
75654
|
const { writeFile: writeFile4, unlink } = await import("node:fs/promises");
|
|
75485
75655
|
const { author, name } = parseRegistryHandle(options.handle);
|
|
75486
75656
|
const rawUrl = `https://raw.githubusercontent.com/${AGENT_REGISTRY_OWNER}/${AGENT_REGISTRY_REPO}/refs/heads/${AGENT_REGISTRY_BRANCH}/agents/@${author}/${name}/${name}.af`;
|
|
@@ -75492,7 +75662,7 @@ async function importAgentFromRegistry(options) {
|
|
|
75492
75662
|
throw new Error(`Failed to download agent @${author}/${name}: ${response.statusText}`);
|
|
75493
75663
|
}
|
|
75494
75664
|
const afContent = await response.text();
|
|
75495
|
-
const tempPath =
|
|
75665
|
+
const tempPath = join27(tmpdir3(), `letta-import-${author}-${name}-${Date.now()}.af`);
|
|
75496
75666
|
await writeFile4(tempPath, afContent, "utf-8");
|
|
75497
75667
|
try {
|
|
75498
75668
|
const result = await importAgentFromFile({
|
|
@@ -75985,6 +76155,7 @@ In headless mode, use:
|
|
|
75985
76155
|
}
|
|
75986
76156
|
if (specifiedConversationId && specifiedConversationId !== "default") {
|
|
75987
76157
|
try {
|
|
76158
|
+
debugLog("conversations", `retrieve(${specifiedConversationId}) [headless conv→agent lookup]`);
|
|
75988
76159
|
const conversation = await client.conversations.retrieve(specifiedConversationId);
|
|
75989
76160
|
agent = await client.agents.retrieve(conversation.agent_id);
|
|
75990
76161
|
} catch (_error) {
|
|
@@ -76162,6 +76333,7 @@ In headless mode, use:
|
|
|
76162
76333
|
conversationId = "default";
|
|
76163
76334
|
} else {
|
|
76164
76335
|
try {
|
|
76336
|
+
debugLog("conversations", `retrieve(${specifiedConversationId}) [headless --conv validate]`);
|
|
76165
76337
|
await client.conversations.retrieve(specifiedConversationId);
|
|
76166
76338
|
conversationId = specifiedConversationId;
|
|
76167
76339
|
} catch {
|
|
@@ -76177,6 +76349,7 @@ In headless mode, use:
|
|
|
76177
76349
|
conversationId = "default";
|
|
76178
76350
|
} else {
|
|
76179
76351
|
try {
|
|
76352
|
+
debugLog("conversations", `retrieve(${lastSession.conversationId}) [headless lastSession resume]`);
|
|
76180
76353
|
await client.conversations.retrieve(lastSession.conversationId);
|
|
76181
76354
|
conversationId = lastSession.conversationId;
|
|
76182
76355
|
} catch {
|
|
@@ -76493,21 +76666,22 @@ ${loadedContents.join(`
|
|
|
76493
76666
|
}
|
|
76494
76667
|
if (preStreamAction === "retry_conversation_busy") {
|
|
76495
76668
|
conversationBusyRetries += 1;
|
|
76669
|
+
const retryDelayMs = CONVERSATION_BUSY_RETRY_BASE_DELAY_MS * 2 ** (conversationBusyRetries - 1);
|
|
76496
76670
|
if (outputFormat === "stream-json") {
|
|
76497
76671
|
const retryMsg = {
|
|
76498
76672
|
type: "retry",
|
|
76499
76673
|
reason: "error",
|
|
76500
76674
|
attempt: conversationBusyRetries,
|
|
76501
76675
|
max_attempts: CONVERSATION_BUSY_MAX_RETRIES,
|
|
76502
|
-
delay_ms:
|
|
76676
|
+
delay_ms: retryDelayMs,
|
|
76503
76677
|
session_id: sessionId,
|
|
76504
76678
|
uuid: `retry-conversation-busy-${randomUUID7()}`
|
|
76505
76679
|
};
|
|
76506
76680
|
console.log(JSON.stringify(retryMsg));
|
|
76507
76681
|
} else {
|
|
76508
|
-
console.error(`Conversation is busy, waiting ${
|
|
76682
|
+
console.error(`Conversation is busy, waiting ${Math.round(retryDelayMs / 1000)}s and retrying...`);
|
|
76509
76683
|
}
|
|
76510
|
-
await new Promise((resolve25) => setTimeout(resolve25,
|
|
76684
|
+
await new Promise((resolve25) => setTimeout(resolve25, retryDelayMs));
|
|
76511
76685
|
continue;
|
|
76512
76686
|
}
|
|
76513
76687
|
if (preStreamAction === "retry_transient") {
|
|
@@ -77789,7 +77963,7 @@ async function runBidirectionalMode(agent, conversationId, client, _outputFormat
|
|
|
77789
77963
|
setMessageQueueAdder(null);
|
|
77790
77964
|
process.exit(0);
|
|
77791
77965
|
}
|
|
77792
|
-
var LLM_API_ERROR_MAX_RETRIES2 = 3, EMPTY_RESPONSE_MAX_RETRIES = 2, CONVERSATION_BUSY_MAX_RETRIES =
|
|
77966
|
+
var LLM_API_ERROR_MAX_RETRIES2 = 3, EMPTY_RESPONSE_MAX_RETRIES = 2, CONVERSATION_BUSY_MAX_RETRIES = 3, CONVERSATION_BUSY_RETRY_BASE_DELAY_MS = 1e4;
|
|
77793
77967
|
var init_headless = __esm(async () => {
|
|
77794
77968
|
init_error();
|
|
77795
77969
|
init_bootstrapHandler();
|
|
@@ -77802,6 +77976,7 @@ var init_headless = __esm(async () => {
|
|
|
77802
77976
|
init_constants();
|
|
77803
77977
|
init_diffPreview();
|
|
77804
77978
|
init_interactivePolicy();
|
|
77979
|
+
init_debug();
|
|
77805
77980
|
init_timing();
|
|
77806
77981
|
await __promiseAll([
|
|
77807
77982
|
init_approval_recovery(),
|
|
@@ -78111,10 +78286,10 @@ __export(exports_settings, {
|
|
|
78111
78286
|
loadProjectSettings: () => loadProjectSettings,
|
|
78112
78287
|
getSetting: () => getSetting
|
|
78113
78288
|
});
|
|
78114
|
-
import { homedir as
|
|
78115
|
-
import { join as
|
|
78289
|
+
import { homedir as homedir21 } from "node:os";
|
|
78290
|
+
import { join as join28 } from "node:path";
|
|
78116
78291
|
function getSettingsPath() {
|
|
78117
|
-
return
|
|
78292
|
+
return join28(homedir21(), ".letta", "settings.json");
|
|
78118
78293
|
}
|
|
78119
78294
|
async function loadSettings() {
|
|
78120
78295
|
const settingsPath = getSettingsPath();
|
|
@@ -78151,7 +78326,7 @@ async function getSetting(key) {
|
|
|
78151
78326
|
return settings[key];
|
|
78152
78327
|
}
|
|
78153
78328
|
function getProjectSettingsPath() {
|
|
78154
|
-
return
|
|
78329
|
+
return join28(process.cwd(), ".letta", "settings.local.json");
|
|
78155
78330
|
}
|
|
78156
78331
|
async function loadProjectSettings() {
|
|
78157
78332
|
const settingsPath = getProjectSettingsPath();
|
|
@@ -78169,7 +78344,7 @@ async function loadProjectSettings() {
|
|
|
78169
78344
|
}
|
|
78170
78345
|
async function saveProjectSettings(settings) {
|
|
78171
78346
|
const settingsPath = getProjectSettingsPath();
|
|
78172
|
-
const dirPath =
|
|
78347
|
+
const dirPath = join28(process.cwd(), ".letta");
|
|
78173
78348
|
try {
|
|
78174
78349
|
if (!exists(dirPath)) {
|
|
78175
78350
|
await mkdir(dirPath, { recursive: true });
|
|
@@ -78671,6 +78846,13 @@ function createCommandRunner({
|
|
|
78671
78846
|
onCommandFinished
|
|
78672
78847
|
}) {
|
|
78673
78848
|
function getHandle(id, input) {
|
|
78849
|
+
const handle = {
|
|
78850
|
+
id,
|
|
78851
|
+
input,
|
|
78852
|
+
update: null,
|
|
78853
|
+
finish: null,
|
|
78854
|
+
fail: null
|
|
78855
|
+
};
|
|
78674
78856
|
const update = (updateData) => {
|
|
78675
78857
|
const previous = buffersRef.current.byId.get(id);
|
|
78676
78858
|
const wasFinished = previous?.kind === "command" && previous.phase === "finished";
|
|
@@ -78687,24 +78869,26 @@ function createCommandRunner({
|
|
|
78687
78869
|
output: next.output,
|
|
78688
78870
|
success: next.success !== false,
|
|
78689
78871
|
dimOutput: next.dimOutput,
|
|
78690
|
-
preformatted: next.preformatted
|
|
78872
|
+
preformatted: next.preformatted,
|
|
78873
|
+
agentHint: handle.agentHint
|
|
78691
78874
|
});
|
|
78692
78875
|
}
|
|
78693
78876
|
refreshDerived();
|
|
78694
78877
|
};
|
|
78695
|
-
|
|
78878
|
+
handle.update = update;
|
|
78879
|
+
handle.finish = (finalOutput, success = true, dimOutput, preformatted) => update({
|
|
78696
78880
|
output: finalOutput,
|
|
78697
78881
|
phase: "finished",
|
|
78698
78882
|
success,
|
|
78699
78883
|
dimOutput,
|
|
78700
78884
|
preformatted
|
|
78701
78885
|
});
|
|
78702
|
-
|
|
78886
|
+
handle.fail = (finalOutput) => update({
|
|
78703
78887
|
output: finalOutput,
|
|
78704
78888
|
phase: "finished",
|
|
78705
78889
|
success: false
|
|
78706
78890
|
});
|
|
78707
|
-
return
|
|
78891
|
+
return handle;
|
|
78708
78892
|
}
|
|
78709
78893
|
function start(input, output) {
|
|
78710
78894
|
const id = createId("cmd");
|
|
@@ -80477,9 +80661,9 @@ function getFileEditHeader(toolName, toolArgs) {
|
|
|
80477
80661
|
const relPath = relative9(cwd2, filePath);
|
|
80478
80662
|
const displayPath = relPath.startsWith("..") ? filePath : relPath;
|
|
80479
80663
|
if (t === "write" || t === "write_file" || t === "writefile" || t === "write_file_gemini" || t === "writefilegemini") {
|
|
80480
|
-
const { existsSync:
|
|
80664
|
+
const { existsSync: existsSync18 } = __require("node:fs");
|
|
80481
80665
|
try {
|
|
80482
|
-
if (
|
|
80666
|
+
if (existsSync18(filePath)) {
|
|
80483
80667
|
return `Overwrite ${displayPath}?`;
|
|
80484
80668
|
}
|
|
80485
80669
|
} catch {}
|
|
@@ -81181,9 +81365,9 @@ function getHeaderText(fileEdit) {
|
|
|
81181
81365
|
const relPath = relative9(cwd2, fileEdit.filePath);
|
|
81182
81366
|
const displayPath = relPath.startsWith("..") ? fileEdit.filePath : relPath;
|
|
81183
81367
|
if (t === "write" || t === "write_file" || t === "writefile" || t === "write_file_gemini" || t === "writefilegemini") {
|
|
81184
|
-
const { existsSync:
|
|
81368
|
+
const { existsSync: existsSync18 } = __require("node:fs");
|
|
81185
81369
|
try {
|
|
81186
|
-
if (
|
|
81370
|
+
if (existsSync18(fileEdit.filePath)) {
|
|
81187
81371
|
return `Overwrite ${displayPath}?`;
|
|
81188
81372
|
}
|
|
81189
81373
|
} catch {}
|
|
@@ -82821,9 +83005,9 @@ html.dark .agent-name { color: var(--text-dim); }
|
|
|
82821
83005
|
var init_plan_viewer_template = () => {};
|
|
82822
83006
|
|
|
82823
83007
|
// src/web/generate-plan-viewer.ts
|
|
82824
|
-
import { chmodSync as chmodSync2, existsSync as
|
|
82825
|
-
import { homedir as
|
|
82826
|
-
import { join as
|
|
83008
|
+
import { chmodSync as chmodSync2, existsSync as existsSync18, mkdirSync as mkdirSync14, writeFileSync as writeFileSync8 } from "node:fs";
|
|
83009
|
+
import { homedir as homedir22 } from "node:os";
|
|
83010
|
+
import { join as join29 } from "node:path";
|
|
82827
83011
|
async function generateAndOpenPlanViewer(planContent, planFilePath, options) {
|
|
82828
83012
|
const data = {
|
|
82829
83013
|
agent: { name: options?.agentName ?? "" },
|
|
@@ -82833,13 +83017,13 @@ async function generateAndOpenPlanViewer(planContent, planFilePath, options) {
|
|
|
82833
83017
|
};
|
|
82834
83018
|
const jsonPayload = JSON.stringify(data).replace(/</g, "\\u003c");
|
|
82835
83019
|
const html = plan_viewer_template_default.replace("<!--LETTA_PLAN_DATA_PLACEHOLDER-->", () => jsonPayload);
|
|
82836
|
-
if (!
|
|
82837
|
-
|
|
83020
|
+
if (!existsSync18(VIEWERS_DIR)) {
|
|
83021
|
+
mkdirSync14(VIEWERS_DIR, { recursive: true, mode: 448 });
|
|
82838
83022
|
}
|
|
82839
83023
|
try {
|
|
82840
83024
|
chmodSync2(VIEWERS_DIR, 448);
|
|
82841
83025
|
} catch {}
|
|
82842
|
-
const filePath =
|
|
83026
|
+
const filePath = join29(VIEWERS_DIR, "plan.html");
|
|
82843
83027
|
writeFileSync8(filePath, html);
|
|
82844
83028
|
chmodSync2(filePath, 384);
|
|
82845
83029
|
const skipOpen = Boolean(process.env.TMUX) || Boolean(process.env.SSH_CONNECTION) || Boolean(process.env.SSH_TTY);
|
|
@@ -82856,7 +83040,7 @@ async function generateAndOpenPlanViewer(planContent, planFilePath, options) {
|
|
|
82856
83040
|
var VIEWERS_DIR;
|
|
82857
83041
|
var init_generate_plan_viewer = __esm(() => {
|
|
82858
83042
|
init_plan_viewer_template();
|
|
82859
|
-
VIEWERS_DIR =
|
|
83043
|
+
VIEWERS_DIR = join29(homedir22(), ".letta", "viewers");
|
|
82860
83044
|
});
|
|
82861
83045
|
|
|
82862
83046
|
// src/cli/components/StaticPlanApproval.tsx
|
|
@@ -84054,7 +84238,8 @@ function ConversationSelector2({
|
|
|
84054
84238
|
let defaultConversation = null;
|
|
84055
84239
|
if (!afterCursor) {
|
|
84056
84240
|
try {
|
|
84057
|
-
const defaultMessages = await client.conversations.messages.list(
|
|
84241
|
+
const defaultMessages = await client.conversations.messages.list("default", {
|
|
84242
|
+
agent_id: agentId,
|
|
84058
84243
|
limit: 20,
|
|
84059
84244
|
order: "desc"
|
|
84060
84245
|
});
|
|
@@ -84829,9 +85014,9 @@ var init_pasteRegistry = __esm(() => {
|
|
|
84829
85014
|
|
|
84830
85015
|
// src/cli/helpers/clipboard.ts
|
|
84831
85016
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
84832
|
-
import { existsSync as
|
|
85017
|
+
import { existsSync as existsSync19, readFileSync as readFileSync6, statSync as statSync4, unlinkSync as unlinkSync8 } from "node:fs";
|
|
84833
85018
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
84834
|
-
import { basename as basename4, extname as extname5, isAbsolute as isAbsolute16, join as
|
|
85019
|
+
import { basename as basename4, extname as extname5, isAbsolute as isAbsolute16, join as join30, resolve as resolve25 } from "node:path";
|
|
84835
85020
|
function countLines2(text) {
|
|
84836
85021
|
return (text.match(/\r\n|\r|\n/g) || []).length + 1;
|
|
84837
85022
|
}
|
|
@@ -84881,8 +85066,8 @@ function translatePasteForImages(paste) {
|
|
|
84881
85066
|
if (!isAbsolute16(filePath))
|
|
84882
85067
|
filePath = resolve25(process.cwd(), filePath);
|
|
84883
85068
|
const ext3 = extname5(filePath || "").toLowerCase();
|
|
84884
|
-
if (IMAGE_EXTS.has(ext3) &&
|
|
84885
|
-
const buf =
|
|
85069
|
+
if (IMAGE_EXTS.has(ext3) && existsSync19(filePath) && statSync4(filePath).isFile()) {
|
|
85070
|
+
const buf = readFileSync6(filePath);
|
|
84886
85071
|
const b64 = buf.toString("base64");
|
|
84887
85072
|
const mt = ext3 === ".png" ? "image/png" : ext3 === ".jpg" || ext3 === ".jpeg" ? "image/jpeg" : ext3 === ".gif" ? "image/gif" : ext3 === ".webp" ? "image/webp" : ext3 === ".bmp" ? "image/bmp" : ext3 === ".svg" ? "image/svg+xml" : ext3 === ".tif" || ext3 === ".tiff" ? "image/tiff" : ext3 === ".heic" ? "image/heic" : ext3 === ".heif" ? "image/heif" : ext3 === ".avif" ? "image/avif" : "application/octet-stream";
|
|
84888
85073
|
const id = allocateImage({
|
|
@@ -84899,7 +85084,7 @@ function translatePasteForImages(paste) {
|
|
|
84899
85084
|
function getClipboardImageToTempFile() {
|
|
84900
85085
|
if (process.platform !== "darwin")
|
|
84901
85086
|
return null;
|
|
84902
|
-
const tempPath =
|
|
85087
|
+
const tempPath = join30(tmpdir3(), `letta-clipboard-${Date.now()}.bin`);
|
|
84903
85088
|
try {
|
|
84904
85089
|
const jxa = `
|
|
84905
85090
|
ObjC.import('AppKit');
|
|
@@ -84922,13 +85107,13 @@ function getClipboardImageToTempFile() {
|
|
|
84922
85107
|
encoding: "utf8",
|
|
84923
85108
|
stdio: ["ignore", "pipe", "ignore"]
|
|
84924
85109
|
}).trim();
|
|
84925
|
-
if (!uti || !
|
|
85110
|
+
if (!uti || !existsSync19(tempPath))
|
|
84926
85111
|
return null;
|
|
84927
85112
|
return { tempPath, uti };
|
|
84928
85113
|
} catch {
|
|
84929
|
-
if (
|
|
85114
|
+
if (existsSync19(tempPath)) {
|
|
84930
85115
|
try {
|
|
84931
|
-
|
|
85116
|
+
unlinkSync8(tempPath);
|
|
84932
85117
|
} catch {}
|
|
84933
85118
|
}
|
|
84934
85119
|
return null;
|
|
@@ -84942,9 +85127,9 @@ async function tryImportClipboardImageMac() {
|
|
|
84942
85127
|
return null;
|
|
84943
85128
|
const { tempPath, uti } = clipboardResult;
|
|
84944
85129
|
try {
|
|
84945
|
-
const buffer =
|
|
85130
|
+
const buffer = readFileSync6(tempPath);
|
|
84946
85131
|
try {
|
|
84947
|
-
|
|
85132
|
+
unlinkSync8(tempPath);
|
|
84948
85133
|
} catch {}
|
|
84949
85134
|
const mediaType = UTI_TO_MEDIA_TYPE[uti] || "image/png";
|
|
84950
85135
|
const resized = await resizeImageIfNeeded3(buffer, mediaType);
|
|
@@ -84959,9 +85144,9 @@ async function tryImportClipboardImageMac() {
|
|
|
84959
85144
|
height: resized.height
|
|
84960
85145
|
};
|
|
84961
85146
|
} catch (err) {
|
|
84962
|
-
if (
|
|
85147
|
+
if (existsSync19(tempPath)) {
|
|
84963
85148
|
try {
|
|
84964
|
-
|
|
85149
|
+
unlinkSync8(tempPath);
|
|
84965
85150
|
} catch {}
|
|
84966
85151
|
}
|
|
84967
85152
|
const message = err instanceof Error ? err.message : String(err);
|
|
@@ -85536,13 +85721,13 @@ __export(exports_terminalKeybindingInstaller, {
|
|
|
85536
85721
|
});
|
|
85537
85722
|
import {
|
|
85538
85723
|
copyFileSync,
|
|
85539
|
-
existsSync as
|
|
85540
|
-
mkdirSync as
|
|
85541
|
-
readFileSync as
|
|
85724
|
+
existsSync as existsSync20,
|
|
85725
|
+
mkdirSync as mkdirSync15,
|
|
85726
|
+
readFileSync as readFileSync7,
|
|
85542
85727
|
writeFileSync as writeFileSync9
|
|
85543
85728
|
} from "node:fs";
|
|
85544
|
-
import { homedir as
|
|
85545
|
-
import { dirname as dirname11, join as
|
|
85729
|
+
import { homedir as homedir23, platform as platform4 } from "node:os";
|
|
85730
|
+
import { dirname as dirname11, join as join31 } from "node:path";
|
|
85546
85731
|
function detectTerminalType() {
|
|
85547
85732
|
if (process.env.CURSOR_TRACE_ID || process.env.CURSOR_CHANNEL) {
|
|
85548
85733
|
return "cursor";
|
|
@@ -85574,16 +85759,16 @@ function getKeybindingsPath(terminal) {
|
|
|
85574
85759
|
}[terminal];
|
|
85575
85760
|
const os6 = platform4();
|
|
85576
85761
|
if (os6 === "darwin") {
|
|
85577
|
-
return
|
|
85762
|
+
return join31(homedir23(), "Library", "Application Support", appName, "User", "keybindings.json");
|
|
85578
85763
|
}
|
|
85579
85764
|
if (os6 === "win32") {
|
|
85580
85765
|
const appData = process.env.APPDATA;
|
|
85581
85766
|
if (!appData)
|
|
85582
85767
|
return null;
|
|
85583
|
-
return
|
|
85768
|
+
return join31(appData, appName, "User", "keybindings.json");
|
|
85584
85769
|
}
|
|
85585
85770
|
if (os6 === "linux") {
|
|
85586
|
-
return
|
|
85771
|
+
return join31(homedir23(), ".config", appName, "User", "keybindings.json");
|
|
85587
85772
|
}
|
|
85588
85773
|
return null;
|
|
85589
85774
|
}
|
|
@@ -85605,10 +85790,10 @@ function parseKeybindings(content) {
|
|
|
85605
85790
|
}
|
|
85606
85791
|
}
|
|
85607
85792
|
function keybindingExists(keybindingsPath) {
|
|
85608
|
-
if (!
|
|
85793
|
+
if (!existsSync20(keybindingsPath))
|
|
85609
85794
|
return false;
|
|
85610
85795
|
try {
|
|
85611
|
-
const content =
|
|
85796
|
+
const content = readFileSync7(keybindingsPath, { encoding: "utf-8" });
|
|
85612
85797
|
const keybindings = parseKeybindings(content);
|
|
85613
85798
|
if (!keybindings)
|
|
85614
85799
|
return false;
|
|
@@ -85618,7 +85803,7 @@ function keybindingExists(keybindingsPath) {
|
|
|
85618
85803
|
}
|
|
85619
85804
|
}
|
|
85620
85805
|
function createBackup(keybindingsPath) {
|
|
85621
|
-
if (!
|
|
85806
|
+
if (!existsSync20(keybindingsPath))
|
|
85622
85807
|
return null;
|
|
85623
85808
|
const backupPath = `${keybindingsPath}.letta-backup`;
|
|
85624
85809
|
try {
|
|
@@ -85634,14 +85819,14 @@ function installKeybinding(keybindingsPath) {
|
|
|
85634
85819
|
return { success: true, alreadyExists: true };
|
|
85635
85820
|
}
|
|
85636
85821
|
const parentDir = dirname11(keybindingsPath);
|
|
85637
|
-
if (!
|
|
85638
|
-
|
|
85822
|
+
if (!existsSync20(parentDir)) {
|
|
85823
|
+
mkdirSync15(parentDir, { recursive: true });
|
|
85639
85824
|
}
|
|
85640
85825
|
let keybindings = [];
|
|
85641
85826
|
let backupPath = null;
|
|
85642
|
-
if (
|
|
85827
|
+
if (existsSync20(keybindingsPath)) {
|
|
85643
85828
|
backupPath = createBackup(keybindingsPath);
|
|
85644
|
-
const content =
|
|
85829
|
+
const content = readFileSync7(keybindingsPath, { encoding: "utf-8" });
|
|
85645
85830
|
const parsed = parseKeybindings(content);
|
|
85646
85831
|
if (parsed === null) {
|
|
85647
85832
|
return {
|
|
@@ -85669,10 +85854,10 @@ function installKeybinding(keybindingsPath) {
|
|
|
85669
85854
|
}
|
|
85670
85855
|
function removeKeybinding(keybindingsPath) {
|
|
85671
85856
|
try {
|
|
85672
|
-
if (!
|
|
85857
|
+
if (!existsSync20(keybindingsPath)) {
|
|
85673
85858
|
return { success: true };
|
|
85674
85859
|
}
|
|
85675
|
-
const content =
|
|
85860
|
+
const content = readFileSync7(keybindingsPath, { encoding: "utf-8" });
|
|
85676
85861
|
const keybindings = parseKeybindings(content);
|
|
85677
85862
|
if (!keybindings) {
|
|
85678
85863
|
return {
|
|
@@ -85736,20 +85921,20 @@ function getWezTermConfigPath() {
|
|
|
85736
85921
|
}
|
|
85737
85922
|
const xdgConfig = process.env.XDG_CONFIG_HOME;
|
|
85738
85923
|
if (xdgConfig) {
|
|
85739
|
-
const xdgPath =
|
|
85740
|
-
if (
|
|
85924
|
+
const xdgPath = join31(xdgConfig, "wezterm", "wezterm.lua");
|
|
85925
|
+
if (existsSync20(xdgPath))
|
|
85741
85926
|
return xdgPath;
|
|
85742
85927
|
}
|
|
85743
|
-
const configPath =
|
|
85744
|
-
if (
|
|
85928
|
+
const configPath = join31(homedir23(), ".config", "wezterm", "wezterm.lua");
|
|
85929
|
+
if (existsSync20(configPath))
|
|
85745
85930
|
return configPath;
|
|
85746
|
-
return
|
|
85931
|
+
return join31(homedir23(), ".wezterm.lua");
|
|
85747
85932
|
}
|
|
85748
85933
|
function wezTermDeleteFixExists(configPath) {
|
|
85749
|
-
if (!
|
|
85934
|
+
if (!existsSync20(configPath))
|
|
85750
85935
|
return false;
|
|
85751
85936
|
try {
|
|
85752
|
-
const content =
|
|
85937
|
+
const content = readFileSync7(configPath, { encoding: "utf-8" });
|
|
85753
85938
|
return content.includes("Letta Code: Fix Delete key") || content.includes("key = 'Delete'") && content.includes("SendString") && content.includes("\\x1b[3~");
|
|
85754
85939
|
} catch {
|
|
85755
85940
|
return false;
|
|
@@ -85763,10 +85948,10 @@ function installWezTermDeleteFix() {
|
|
|
85763
85948
|
}
|
|
85764
85949
|
let content = "";
|
|
85765
85950
|
let backupPath = null;
|
|
85766
|
-
if (
|
|
85951
|
+
if (existsSync20(configPath)) {
|
|
85767
85952
|
backupPath = `${configPath}.letta-backup`;
|
|
85768
85953
|
copyFileSync(configPath, backupPath);
|
|
85769
|
-
content =
|
|
85954
|
+
content = readFileSync7(configPath, { encoding: "utf-8" });
|
|
85770
85955
|
}
|
|
85771
85956
|
if (content.includes("return {") && !content.includes("local config")) {
|
|
85772
85957
|
content = content.replace(/return\s*\{/, "local config = {");
|
|
@@ -85793,8 +85978,8 @@ ${WEZTERM_DELETE_FIX}
|
|
|
85793
85978
|
`;
|
|
85794
85979
|
}
|
|
85795
85980
|
const parentDir = dirname11(configPath);
|
|
85796
|
-
if (!
|
|
85797
|
-
|
|
85981
|
+
if (!existsSync20(parentDir)) {
|
|
85982
|
+
mkdirSync15(parentDir, { recursive: true });
|
|
85798
85983
|
}
|
|
85799
85984
|
writeFileSync9(configPath, content, { encoding: "utf-8" });
|
|
85800
85985
|
return {
|
|
@@ -86316,9 +86501,9 @@ __export(exports_custom, {
|
|
|
86316
86501
|
GLOBAL_COMMANDS_DIR: () => GLOBAL_COMMANDS_DIR,
|
|
86317
86502
|
COMMANDS_DIR: () => COMMANDS_DIR
|
|
86318
86503
|
});
|
|
86319
|
-
import { existsSync as
|
|
86504
|
+
import { existsSync as existsSync21 } from "node:fs";
|
|
86320
86505
|
import { readdir as readdir9, readFile as readFile9 } from "node:fs/promises";
|
|
86321
|
-
import { basename as basename5, dirname as dirname12, join as
|
|
86506
|
+
import { basename as basename5, dirname as dirname12, join as join32 } from "node:path";
|
|
86322
86507
|
async function getCustomCommands() {
|
|
86323
86508
|
if (cachedCommands !== null) {
|
|
86324
86509
|
return cachedCommands;
|
|
@@ -86329,7 +86514,7 @@ async function getCustomCommands() {
|
|
|
86329
86514
|
function refreshCustomCommands() {
|
|
86330
86515
|
cachedCommands = null;
|
|
86331
86516
|
}
|
|
86332
|
-
async function discoverCustomCommands(projectPath =
|
|
86517
|
+
async function discoverCustomCommands(projectPath = join32(process.cwd(), COMMANDS_DIR)) {
|
|
86333
86518
|
const commandsById = new Map;
|
|
86334
86519
|
const userCommands = await discoverFromDirectory(GLOBAL_COMMANDS_DIR, "user");
|
|
86335
86520
|
for (const cmd of userCommands) {
|
|
@@ -86350,7 +86535,7 @@ async function discoverCustomCommands(projectPath = join31(process.cwd(), COMMAN
|
|
|
86350
86535
|
return result;
|
|
86351
86536
|
}
|
|
86352
86537
|
async function discoverFromDirectory(dirPath, source) {
|
|
86353
|
-
if (!
|
|
86538
|
+
if (!existsSync21(dirPath)) {
|
|
86354
86539
|
return [];
|
|
86355
86540
|
}
|
|
86356
86541
|
const commands2 = [];
|
|
@@ -86361,7 +86546,7 @@ async function findCommandFiles(currentPath, rootPath, commands2, source) {
|
|
|
86361
86546
|
try {
|
|
86362
86547
|
const entries = await readdir9(currentPath, { withFileTypes: true });
|
|
86363
86548
|
for (const entry of entries) {
|
|
86364
|
-
const fullPath =
|
|
86549
|
+
const fullPath = join32(currentPath, entry.name);
|
|
86365
86550
|
if (entry.isDirectory()) {
|
|
86366
86551
|
await findCommandFiles(fullPath, rootPath, commands2, source);
|
|
86367
86552
|
} else if (entry.isFile() && entry.name.endsWith(".md")) {
|
|
@@ -86446,7 +86631,7 @@ async function findCustomCommand(commandName) {
|
|
|
86446
86631
|
}
|
|
86447
86632
|
var COMMANDS_DIR = ".commands", GLOBAL_COMMANDS_DIR, cachedCommands = null;
|
|
86448
86633
|
var init_custom = __esm(() => {
|
|
86449
|
-
GLOBAL_COMMANDS_DIR =
|
|
86634
|
+
GLOBAL_COMMANDS_DIR = join32(process.env.HOME || process.env.USERPROFILE || "~", ".letta/commands");
|
|
86450
86635
|
});
|
|
86451
86636
|
|
|
86452
86637
|
// src/cli/components/HelpDialog.tsx
|
|
@@ -86727,10 +86912,10 @@ var init_HelpDialog = __esm(async () => {
|
|
|
86727
86912
|
});
|
|
86728
86913
|
|
|
86729
86914
|
// src/hooks/writer.ts
|
|
86730
|
-
import { homedir as
|
|
86915
|
+
import { homedir as homedir24 } from "node:os";
|
|
86731
86916
|
import { resolve as resolve26 } from "node:path";
|
|
86732
86917
|
function isProjectSettingsPathCollidingWithGlobal2(workingDirectory) {
|
|
86733
|
-
const home = process.env.HOME ||
|
|
86918
|
+
const home = process.env.HOME || homedir24();
|
|
86734
86919
|
const globalSettingsPath = resolve26(home, ".letta", "settings.json");
|
|
86735
86920
|
const projectSettingsPath = resolve26(workingDirectory, ".letta", "settings.json");
|
|
86736
86921
|
return globalSettingsPath === projectSettingsPath;
|
|
@@ -87782,28 +87967,28 @@ var require_react_jsx_runtime_development = __commonJS((exports) => {
|
|
|
87782
87967
|
return null;
|
|
87783
87968
|
}
|
|
87784
87969
|
var ReactSharedInternals = React14.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
87785
|
-
function error(
|
|
87970
|
+
function error(format3) {
|
|
87786
87971
|
{
|
|
87787
87972
|
{
|
|
87788
87973
|
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1;_key2 < _len2; _key2++) {
|
|
87789
87974
|
args[_key2 - 1] = arguments[_key2];
|
|
87790
87975
|
}
|
|
87791
|
-
printWarning("error",
|
|
87976
|
+
printWarning("error", format3, args);
|
|
87792
87977
|
}
|
|
87793
87978
|
}
|
|
87794
87979
|
}
|
|
87795
|
-
function printWarning(level,
|
|
87980
|
+
function printWarning(level, format3, args) {
|
|
87796
87981
|
{
|
|
87797
87982
|
var ReactDebugCurrentFrame2 = ReactSharedInternals.ReactDebugCurrentFrame;
|
|
87798
87983
|
var stack = ReactDebugCurrentFrame2.getStackAddendum();
|
|
87799
87984
|
if (stack !== "") {
|
|
87800
|
-
|
|
87985
|
+
format3 += "%s";
|
|
87801
87986
|
args = args.concat([stack]);
|
|
87802
87987
|
}
|
|
87803
87988
|
var argsWithFormat = args.map(function(item) {
|
|
87804
87989
|
return String(item);
|
|
87805
87990
|
});
|
|
87806
|
-
argsWithFormat.unshift("Warning: " +
|
|
87991
|
+
argsWithFormat.unshift("Warning: " + format3);
|
|
87807
87992
|
Function.prototype.apply.call(console[level], console, argsWithFormat);
|
|
87808
87993
|
}
|
|
87809
87994
|
}
|
|
@@ -89019,7 +89204,7 @@ var init_AgentInfoBar = __esm(async () => {
|
|
|
89019
89204
|
return localPinned.includes(agentId) || globalPinned.includes(agentId);
|
|
89020
89205
|
}, [agentId]);
|
|
89021
89206
|
const isCloudUser = serverUrl?.includes("api.letta.com");
|
|
89022
|
-
const adeConversationUrl = agentId && agentId !== "loading" ?
|
|
89207
|
+
const adeConversationUrl = agentId && agentId !== "loading" ? buildChatUrl(agentId, { conversationId }) : "";
|
|
89023
89208
|
const showBottomBar = agentId && agentId !== "loading";
|
|
89024
89209
|
const reasoningLabel = formatReasoningLabel(currentReasoningEffort);
|
|
89025
89210
|
const modelLine = currentModel ? `${currentModel}${reasoningLabel ? ` (${reasoningLabel})` : ""}` : null;
|
|
@@ -89090,7 +89275,7 @@ var init_AgentInfoBar = __esm(async () => {
|
|
|
89090
89275
|
children: "· "
|
|
89091
89276
|
}, undefined, false, undefined, this),
|
|
89092
89277
|
/* @__PURE__ */ jsx_dev_runtime41.jsxDEV(dist_default4, {
|
|
89093
|
-
url: "
|
|
89278
|
+
url: buildAppUrl("/settings/organization/usage"),
|
|
89094
89279
|
children: /* @__PURE__ */ jsx_dev_runtime41.jsxDEV(Text2, {
|
|
89095
89280
|
children: "View usage ↗"
|
|
89096
89281
|
}, undefined, false, undefined, this)
|
|
@@ -89103,7 +89288,7 @@ var init_AgentInfoBar = __esm(async () => {
|
|
|
89103
89288
|
children: /* @__PURE__ */ jsx_dev_runtime41.jsxDEV(Text2, {
|
|
89104
89289
|
dimColor: true,
|
|
89105
89290
|
wrap: "truncate-end",
|
|
89106
|
-
children: truncateText(`Open in ADE: ${adeConversationUrl} · Usage:
|
|
89291
|
+
children: truncateText(`Open in ADE: ${adeConversationUrl} · Usage: ${buildAppUrl("/settings/organization/usage")}`, rightWidth)
|
|
89107
89292
|
}, undefined, false, undefined, this)
|
|
89108
89293
|
}, undefined, false, undefined, this),
|
|
89109
89294
|
!isCloudUser && /* @__PURE__ */ jsx_dev_runtime41.jsxDEV(Box_default, {
|
|
@@ -89179,8 +89364,8 @@ var init_AgentInfoBar = __esm(async () => {
|
|
|
89179
89364
|
});
|
|
89180
89365
|
|
|
89181
89366
|
// src/cli/helpers/fileSearch.ts
|
|
89182
|
-
import { readdirSync as
|
|
89183
|
-
import { join as
|
|
89367
|
+
import { readdirSync as readdirSync9, statSync as statSync5 } from "node:fs";
|
|
89368
|
+
import { join as join33, resolve as resolve27 } from "node:path";
|
|
89184
89369
|
function shouldExcludeEntry(entry) {
|
|
89185
89370
|
if (entry.startsWith(".")) {
|
|
89186
89371
|
return true;
|
|
@@ -89192,13 +89377,13 @@ function searchDirectoryRecursive(dir, pattern, maxResults = 200, results = [],
|
|
|
89192
89377
|
return results;
|
|
89193
89378
|
}
|
|
89194
89379
|
try {
|
|
89195
|
-
const entries =
|
|
89380
|
+
const entries = readdirSync9(dir);
|
|
89196
89381
|
for (const entry of entries) {
|
|
89197
89382
|
if (shouldExcludeEntry(entry)) {
|
|
89198
89383
|
continue;
|
|
89199
89384
|
}
|
|
89200
89385
|
try {
|
|
89201
|
-
const fullPath =
|
|
89386
|
+
const fullPath = join33(dir, entry);
|
|
89202
89387
|
const stats = statSync5(fullPath);
|
|
89203
89388
|
const relativePath = fullPath.startsWith(process.cwd()) ? fullPath.slice(process.cwd().length + 1) : fullPath;
|
|
89204
89389
|
const matches = pattern.length === 0 || relativePath.toLowerCase().includes(pattern.toLowerCase());
|
|
@@ -89246,14 +89431,14 @@ async function searchFiles(query, deep = false) {
|
|
|
89246
89431
|
} else {
|
|
89247
89432
|
let entries = [];
|
|
89248
89433
|
try {
|
|
89249
|
-
entries =
|
|
89434
|
+
entries = readdirSync9(searchDir);
|
|
89250
89435
|
} catch {
|
|
89251
89436
|
return [];
|
|
89252
89437
|
}
|
|
89253
89438
|
const matchingEntries = entries.filter((entry) => !shouldExcludeEntry(entry)).filter((entry) => searchPattern.length === 0 || entry.toLowerCase().includes(searchPattern.toLowerCase()));
|
|
89254
89439
|
for (const entry of matchingEntries.slice(0, 50)) {
|
|
89255
89440
|
try {
|
|
89256
|
-
const fullPath =
|
|
89441
|
+
const fullPath = join33(searchDir, entry);
|
|
89257
89442
|
const stats = statSync5(fullPath);
|
|
89258
89443
|
const relativePath = fullPath.startsWith(process.cwd()) ? fullPath.slice(process.cwd().length + 1) : fullPath;
|
|
89259
89444
|
results.push({
|
|
@@ -91206,15 +91391,15 @@ var init_InputRich = __esm(async () => {
|
|
|
91206
91391
|
// src/cli/commands/install-github-app.ts
|
|
91207
91392
|
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
91208
91393
|
import {
|
|
91209
|
-
existsSync as
|
|
91210
|
-
mkdirSync as
|
|
91394
|
+
existsSync as existsSync22,
|
|
91395
|
+
mkdirSync as mkdirSync16,
|
|
91211
91396
|
mkdtempSync,
|
|
91212
|
-
readFileSync as
|
|
91397
|
+
readFileSync as readFileSync8,
|
|
91213
91398
|
rmSync as rmSync3,
|
|
91214
91399
|
writeFileSync as writeFileSync10
|
|
91215
91400
|
} from "node:fs";
|
|
91216
91401
|
import { tmpdir as tmpdir4 } from "node:os";
|
|
91217
|
-
import { dirname as dirname13, join as
|
|
91402
|
+
import { dirname as dirname13, join as join34 } from "node:path";
|
|
91218
91403
|
function runCommand(command, args, cwd2, input) {
|
|
91219
91404
|
try {
|
|
91220
91405
|
return execFileSync3(command, args, {
|
|
@@ -91448,8 +91633,8 @@ async function createLettaAgent(apiKey, name) {
|
|
|
91448
91633
|
return { id: data.id, name: data.name };
|
|
91449
91634
|
}
|
|
91450
91635
|
function cloneRepoToTemp(repo) {
|
|
91451
|
-
const tempDir = mkdtempSync(
|
|
91452
|
-
const repoDir =
|
|
91636
|
+
const tempDir = mkdtempSync(join34(tmpdir4(), "letta-install-github-app-"));
|
|
91637
|
+
const repoDir = join34(tempDir, "repo");
|
|
91453
91638
|
runCommand("gh", ["repo", "clone", repo, repoDir, "--", "--depth=1"]);
|
|
91454
91639
|
return { tempDir, repoDir };
|
|
91455
91640
|
}
|
|
@@ -91460,14 +91645,14 @@ function runGit2(args, cwd2) {
|
|
|
91460
91645
|
return runCommand("git", args, cwd2);
|
|
91461
91646
|
}
|
|
91462
91647
|
function writeWorkflow(repoDir, workflowPath, content) {
|
|
91463
|
-
const absolutePath =
|
|
91464
|
-
if (!
|
|
91465
|
-
|
|
91648
|
+
const absolutePath = join34(repoDir, workflowPath);
|
|
91649
|
+
if (!existsSync22(dirname13(absolutePath))) {
|
|
91650
|
+
mkdirSync16(dirname13(absolutePath), { recursive: true });
|
|
91466
91651
|
}
|
|
91467
91652
|
const next = `${content.trimEnd()}
|
|
91468
91653
|
`;
|
|
91469
|
-
if (
|
|
91470
|
-
const previous =
|
|
91654
|
+
if (existsSync22(absolutePath)) {
|
|
91655
|
+
const previous = readFileSync8(absolutePath, "utf8");
|
|
91471
91656
|
if (previous === next) {
|
|
91472
91657
|
return false;
|
|
91473
91658
|
}
|
|
@@ -91573,7 +91758,7 @@ async function installGithubApp(options) {
|
|
|
91573
91758
|
committed: false,
|
|
91574
91759
|
secretAction: "set",
|
|
91575
91760
|
agentId: resolvedAgentId,
|
|
91576
|
-
agentUrl: resolvedAgentId ?
|
|
91761
|
+
agentUrl: resolvedAgentId ? buildChatUrl(resolvedAgentId) : null
|
|
91577
91762
|
};
|
|
91578
91763
|
}
|
|
91579
91764
|
runGit2(["add", workflowPath], repoDir);
|
|
@@ -91590,7 +91775,7 @@ async function installGithubApp(options) {
|
|
|
91590
91775
|
committed: true,
|
|
91591
91776
|
secretAction: "set",
|
|
91592
91777
|
agentId: resolvedAgentId,
|
|
91593
|
-
agentUrl: resolvedAgentId ?
|
|
91778
|
+
agentUrl: resolvedAgentId ? buildChatUrl(resolvedAgentId) : null
|
|
91594
91779
|
};
|
|
91595
91780
|
} finally {
|
|
91596
91781
|
rmSync3(tempDir, { recursive: true, force: true });
|
|
@@ -93731,21 +93916,21 @@ var init_McpSelector = __esm(async () => {
|
|
|
93731
93916
|
});
|
|
93732
93917
|
|
|
93733
93918
|
// src/agent/memoryScanner.ts
|
|
93734
|
-
import { readdirSync as
|
|
93735
|
-
import { join as
|
|
93919
|
+
import { readdirSync as readdirSync10, readFileSync as readFileSync9, statSync as statSync6 } from "node:fs";
|
|
93920
|
+
import { join as join35, relative as relative9 } from "node:path";
|
|
93736
93921
|
function scanMemoryFilesystem(memoryRoot) {
|
|
93737
93922
|
const nodes = [];
|
|
93738
93923
|
const scanDir = (dir, depth, parentIsLast) => {
|
|
93739
93924
|
let entries;
|
|
93740
93925
|
try {
|
|
93741
|
-
entries =
|
|
93926
|
+
entries = readdirSync10(dir);
|
|
93742
93927
|
} catch {
|
|
93743
93928
|
return;
|
|
93744
93929
|
}
|
|
93745
93930
|
const filtered = entries.filter((name) => !name.startsWith("."));
|
|
93746
93931
|
const sorted = filtered.sort((a, b) => {
|
|
93747
|
-
const aPath =
|
|
93748
|
-
const bPath =
|
|
93932
|
+
const aPath = join35(dir, a);
|
|
93933
|
+
const bPath = join35(dir, b);
|
|
93749
93934
|
let aIsDir = false;
|
|
93750
93935
|
let bIsDir = false;
|
|
93751
93936
|
try {
|
|
@@ -93765,7 +93950,7 @@ function scanMemoryFilesystem(memoryRoot) {
|
|
|
93765
93950
|
return a.localeCompare(b);
|
|
93766
93951
|
});
|
|
93767
93952
|
sorted.forEach((name, index) => {
|
|
93768
|
-
const fullPath =
|
|
93953
|
+
const fullPath = join35(dir, name);
|
|
93769
93954
|
let isDir = false;
|
|
93770
93955
|
try {
|
|
93771
93956
|
isDir = statSync6(fullPath).isDirectory();
|
|
@@ -93796,7 +93981,7 @@ function getFileNodes(nodes) {
|
|
|
93796
93981
|
}
|
|
93797
93982
|
function readFileContent(fullPath) {
|
|
93798
93983
|
try {
|
|
93799
|
-
return
|
|
93984
|
+
return readFileSync9(fullPath, "utf-8");
|
|
93800
93985
|
} catch {
|
|
93801
93986
|
return "(unable to read file)";
|
|
93802
93987
|
}
|
|
@@ -94758,7 +94943,7 @@ html.dark .warning-badge { background: hsl(42, 30%, 18%); color: hsl(42, 80%, 70
|
|
|
94758
94943
|
} else {
|
|
94759
94944
|
adeBase = 'https://app.letta.com';
|
|
94760
94945
|
}
|
|
94761
|
-
agentIdEl.href = adeBase + '/
|
|
94946
|
+
agentIdEl.href = adeBase + '/chat/' + encodeURIComponent(agentId);
|
|
94762
94947
|
agentIdEl.target = '_blank';
|
|
94763
94948
|
}
|
|
94764
94949
|
document.getElementById('generated-at').textContent = 'Generated ' + new Date(DATA.generatedAt).toLocaleString();
|
|
@@ -95440,9 +95625,9 @@ __export(exports_generate_memory_viewer, {
|
|
|
95440
95625
|
generateAndOpenMemoryViewer: () => generateAndOpenMemoryViewer
|
|
95441
95626
|
});
|
|
95442
95627
|
import { execFile as execFileCb2 } from "node:child_process";
|
|
95443
|
-
import { chmodSync as chmodSync3, existsSync as
|
|
95444
|
-
import { homedir as
|
|
95445
|
-
import { join as
|
|
95628
|
+
import { chmodSync as chmodSync3, existsSync as existsSync23, mkdirSync as mkdirSync17, writeFileSync as writeFileSync11 } from "node:fs";
|
|
95629
|
+
import { homedir as homedir25 } from "node:os";
|
|
95630
|
+
import { join as join36 } from "node:path";
|
|
95446
95631
|
import { promisify as promisify10 } from "node:util";
|
|
95447
95632
|
async function runGitSafe(cwd2, args) {
|
|
95448
95633
|
try {
|
|
@@ -95725,13 +95910,13 @@ async function generateAndOpenMemoryViewer(agentId, options) {
|
|
|
95725
95910
|
}
|
|
95726
95911
|
const jsonPayload = JSON.stringify(data).replace(/</g, "\\u003c");
|
|
95727
95912
|
const html = memory_viewer_template_default.replace("<!--LETTA_DATA_PLACEHOLDER-->", () => jsonPayload);
|
|
95728
|
-
if (!
|
|
95729
|
-
|
|
95913
|
+
if (!existsSync23(VIEWERS_DIR2)) {
|
|
95914
|
+
mkdirSync17(VIEWERS_DIR2, { recursive: true, mode: 448 });
|
|
95730
95915
|
}
|
|
95731
95916
|
try {
|
|
95732
95917
|
chmodSync3(VIEWERS_DIR2, 448);
|
|
95733
95918
|
} catch {}
|
|
95734
|
-
const filePath =
|
|
95919
|
+
const filePath = join36(VIEWERS_DIR2, `memory-${encodeURIComponent(agentId)}.html`);
|
|
95735
95920
|
writeFileSync11(filePath, html);
|
|
95736
95921
|
chmodSync3(filePath, 384);
|
|
95737
95922
|
const skipOpen = Boolean(process.env.TMUX) || Boolean(process.env.SSH_CONNECTION) || Boolean(process.env.SSH_TTY);
|
|
@@ -95755,12 +95940,12 @@ var init_generate_memory_viewer = __esm(async () => {
|
|
|
95755
95940
|
init_memoryGit()
|
|
95756
95941
|
]);
|
|
95757
95942
|
execFile10 = promisify10(execFileCb2);
|
|
95758
|
-
VIEWERS_DIR2 =
|
|
95943
|
+
VIEWERS_DIR2 = join36(homedir25(), ".letta", "viewers");
|
|
95759
95944
|
REFLECTION_PATTERN = /\(reflection\)|🔮|reflection:/i;
|
|
95760
95945
|
});
|
|
95761
95946
|
|
|
95762
95947
|
// src/cli/components/MemfsTreeViewer.tsx
|
|
95763
|
-
import { existsSync as
|
|
95948
|
+
import { existsSync as existsSync24 } from "node:fs";
|
|
95764
95949
|
function renderTreePrefix(node) {
|
|
95765
95950
|
let prefix = "";
|
|
95766
95951
|
for (let i = 0;i < node.depth; i++) {
|
|
@@ -95778,7 +95963,7 @@ function MemfsTreeViewer({
|
|
|
95778
95963
|
const terminalWidth = useTerminalWidth();
|
|
95779
95964
|
const solidLine = SOLID_LINE18.repeat(Math.max(terminalWidth, 10));
|
|
95780
95965
|
const isTmux = Boolean(process.env.TMUX);
|
|
95781
|
-
const adeUrl =
|
|
95966
|
+
const adeUrl = buildChatUrl(agentId, { view: "memory", conversationId });
|
|
95782
95967
|
const [selectedIndex, setSelectedIndex] = import_react75.useState(0);
|
|
95783
95968
|
const [treeScrollOffset, setTreeScrollOffset] = import_react75.useState(0);
|
|
95784
95969
|
const [viewMode, setViewMode] = import_react75.useState("split");
|
|
@@ -95786,7 +95971,7 @@ function MemfsTreeViewer({
|
|
|
95786
95971
|
const [status, setStatus] = import_react75.useState(null);
|
|
95787
95972
|
const statusTimerRef = import_react75.useRef(null);
|
|
95788
95973
|
const memoryRoot = getMemoryFilesystemRoot(agentId);
|
|
95789
|
-
const memoryExists =
|
|
95974
|
+
const memoryExists = existsSync24(memoryRoot);
|
|
95790
95975
|
const hasGitRepo = import_react75.useMemo(() => isGitRepo(agentId), [agentId]);
|
|
95791
95976
|
function showStatus(msg, durationMs) {
|
|
95792
95977
|
if (statusTimerRef.current)
|
|
@@ -96258,7 +96443,7 @@ function MemoryTabViewer({
|
|
|
96258
96443
|
const terminalWidth = useTerminalWidth();
|
|
96259
96444
|
const solidLine = SOLID_LINE19.repeat(Math.max(terminalWidth, 10));
|
|
96260
96445
|
const isTmux = Boolean(process.env.TMUX);
|
|
96261
|
-
const adeUrl =
|
|
96446
|
+
const adeUrl = buildChatUrl(agentId, { view: "memory", conversationId });
|
|
96262
96447
|
const [selectedTabIndex, setSelectedTabIndex] = import_react76.useState(0);
|
|
96263
96448
|
const [scrollOffset, setScrollOffset] = import_react76.useState(0);
|
|
96264
96449
|
const [freshBlocks, setFreshBlocks] = import_react76.useState(null);
|
|
@@ -97260,6 +97445,17 @@ function getModelCategories(billingTier, isSelfHosted) {
|
|
|
97260
97445
|
const isFreeTier = billingTier?.toLowerCase() === "free";
|
|
97261
97446
|
return isFreeTier ? ["byok", "byok-all", "supported", "all"] : ["supported", "all", "byok", "byok-all"];
|
|
97262
97447
|
}
|
|
97448
|
+
function filterModelsByAvailabilityForSelector(typedModels, availableHandles, allApiHandles) {
|
|
97449
|
+
if (availableHandles === null) {
|
|
97450
|
+
return typedModels.filter((m) => {
|
|
97451
|
+
if (!API_GATED_MODEL_HANDLES.has(m.handle)) {
|
|
97452
|
+
return true;
|
|
97453
|
+
}
|
|
97454
|
+
return allApiHandles.includes(m.handle);
|
|
97455
|
+
});
|
|
97456
|
+
}
|
|
97457
|
+
return typedModels.filter((m) => availableHandles.has(m.handle));
|
|
97458
|
+
}
|
|
97263
97459
|
function ModelSelector({
|
|
97264
97460
|
currentModelId,
|
|
97265
97461
|
onSelect,
|
|
@@ -97330,7 +97526,7 @@ function ModelSelector({
|
|
|
97330
97526
|
const supportedModels = import_react79.useMemo(() => {
|
|
97331
97527
|
if (availableHandles === undefined)
|
|
97332
97528
|
return [];
|
|
97333
|
-
let available =
|
|
97529
|
+
let available = filterModelsByAvailabilityForSelector(typedModels, availableHandles, allApiHandles);
|
|
97334
97530
|
if (filterProvider) {
|
|
97335
97531
|
available = available.filter((m) => m.handle.startsWith(`${filterProvider}/`));
|
|
97336
97532
|
}
|
|
@@ -97359,6 +97555,7 @@ function ModelSelector({
|
|
|
97359
97555
|
}, [
|
|
97360
97556
|
typedModels,
|
|
97361
97557
|
availableHandles,
|
|
97558
|
+
allApiHandles,
|
|
97362
97559
|
filterProvider,
|
|
97363
97560
|
searchQuery,
|
|
97364
97561
|
isFreeTier,
|
|
@@ -97816,7 +98013,7 @@ function ModelSelector({
|
|
|
97816
98013
|
]
|
|
97817
98014
|
}, undefined, true, undefined, this);
|
|
97818
98015
|
}
|
|
97819
|
-
var import_react79, jsx_dev_runtime56, SOLID_LINE22 = "─", VISIBLE_ITEMS2 = 8, BYOK_PROVIDER_PREFIXES;
|
|
98016
|
+
var import_react79, jsx_dev_runtime56, SOLID_LINE22 = "─", VISIBLE_ITEMS2 = 8, BYOK_PROVIDER_PREFIXES, API_GATED_MODEL_HANDLES;
|
|
97820
98017
|
var init_ModelSelector = __esm(async () => {
|
|
97821
98018
|
init_useTerminalWidth();
|
|
97822
98019
|
init_colors();
|
|
@@ -97829,6 +98026,7 @@ var init_ModelSelector = __esm(async () => {
|
|
|
97829
98026
|
import_react79 = __toESM(require_react(), 1);
|
|
97830
98027
|
jsx_dev_runtime56 = __toESM(require_jsx_dev_runtime(), 1);
|
|
97831
98028
|
BYOK_PROVIDER_PREFIXES = ["chatgpt-plus-pro/", "lc-"];
|
|
98029
|
+
API_GATED_MODEL_HANDLES = new Set(["letta/auto", "letta/auto-fast"]);
|
|
97832
98030
|
});
|
|
97833
98031
|
|
|
97834
98032
|
// src/cli/components/PinDialog.tsx
|
|
@@ -98238,11 +98436,11 @@ var init_PendingApprovalStub = __esm(async () => {
|
|
|
98238
98436
|
|
|
98239
98437
|
// src/utils/aws-credentials.ts
|
|
98240
98438
|
import { readFile as readFile10 } from "node:fs/promises";
|
|
98241
|
-
import { homedir as
|
|
98242
|
-
import { join as
|
|
98439
|
+
import { homedir as homedir26 } from "node:os";
|
|
98440
|
+
import { join as join37 } from "node:path";
|
|
98243
98441
|
async function parseAwsCredentials() {
|
|
98244
|
-
const credentialsPath =
|
|
98245
|
-
const configPath =
|
|
98442
|
+
const credentialsPath = join37(homedir26(), ".aws", "credentials");
|
|
98443
|
+
const configPath = join37(homedir26(), ".aws", "config");
|
|
98246
98444
|
const profiles = new Map;
|
|
98247
98445
|
try {
|
|
98248
98446
|
const content = await readFile10(credentialsPath, "utf-8");
|
|
@@ -99318,7 +99516,7 @@ function formatUsageStats({
|
|
|
99318
99516
|
const monthlyCredits = Math.round(balance.monthly_credit_balance);
|
|
99319
99517
|
const purchasedCredits = Math.round(balance.purchased_credit_balance);
|
|
99320
99518
|
const toDollars = (credits) => (credits / 1000).toFixed(2);
|
|
99321
|
-
outputLines.push(`Plan: [${balance.billing_tier}]`, "
|
|
99519
|
+
outputLines.push(`Plan: [${balance.billing_tier}]`, buildAppUrl("/settings/organization/usage"), "", `Available credits: ◎${formatNumber(totalCredits)} ($${toDollars(totalCredits)})`, `Monthly credits: ◎${formatNumber(monthlyCredits)} ($${toDollars(monthlyCredits)})`, `Purchased credits: ◎${formatNumber(purchasedCredits)} ($${toDollars(purchasedCredits)})`);
|
|
99322
99520
|
}
|
|
99323
99521
|
return outputLines.join(`
|
|
99324
99522
|
`);
|
|
@@ -99350,8 +99548,8 @@ function SkillsDialog({ onClose, agentId }) {
|
|
|
99350
99548
|
try {
|
|
99351
99549
|
const { discoverSkills: discoverSkills3, SKILLS_DIR: SKILLS_DIR3 } = await Promise.resolve().then(() => (init_skills(), exports_skills));
|
|
99352
99550
|
const { getSkillsDirectory: getSkillsDirectory2, getSkillSources: getSkillSources2 } = await Promise.resolve().then(() => (init_context(), exports_context));
|
|
99353
|
-
const { join:
|
|
99354
|
-
const skillsDir = getSkillsDirectory2() ||
|
|
99551
|
+
const { join: join38 } = await import("node:path");
|
|
99552
|
+
const skillsDir = getSkillsDirectory2() || join38(process.cwd(), SKILLS_DIR3);
|
|
99355
99553
|
const result = await discoverSkills3(skillsDir, agentId, {
|
|
99356
99554
|
sources: getSkillSources2()
|
|
99357
99555
|
});
|
|
@@ -103295,6 +103493,7 @@ ${recentCommits}
|
|
|
103295
103493
|
}
|
|
103296
103494
|
}
|
|
103297
103495
|
function buildMemoryInitRuntimePrompt(args) {
|
|
103496
|
+
const depth = args.depth ?? "deep";
|
|
103298
103497
|
return `
|
|
103299
103498
|
The user ran /init for the current project.
|
|
103300
103499
|
|
|
@@ -103302,6 +103501,7 @@ Runtime context:
|
|
|
103302
103501
|
- parent_agent_id: ${args.agentId}
|
|
103303
103502
|
- working_directory: ${args.workingDirectory}
|
|
103304
103503
|
- memory_dir: ${args.memoryDir}
|
|
103504
|
+
- research_depth: ${depth}
|
|
103305
103505
|
|
|
103306
103506
|
Git/project context:
|
|
103307
103507
|
${args.gitContext}
|
|
@@ -103309,6 +103509,8 @@ ${args.gitContext}
|
|
|
103309
103509
|
Task:
|
|
103310
103510
|
Initialize or reorganize the parent agent's filesystem-backed memory for this project.
|
|
103311
103511
|
|
|
103512
|
+
${depth === "shallow" ? SHALLOW_INSTRUCTIONS : DEEP_INSTRUCTIONS}
|
|
103513
|
+
|
|
103312
103514
|
Instructions:
|
|
103313
103515
|
- Use the pre-loaded initializing-memory skill as your operating guide
|
|
103314
103516
|
- Inspect existing memory before editing
|
|
@@ -103318,6 +103520,29 @@ Instructions:
|
|
|
103318
103520
|
- If the memory filesystem is unavailable or unsafe to modify, stop and explain why
|
|
103319
103521
|
`.trim();
|
|
103320
103522
|
}
|
|
103523
|
+
async function fireAutoInit(agentId, onComplete) {
|
|
103524
|
+
if (hasActiveInitSubagent())
|
|
103525
|
+
return false;
|
|
103526
|
+
if (!settingsManager.isMemfsEnabled(agentId))
|
|
103527
|
+
return false;
|
|
103528
|
+
const gitContext = gatherGitContext();
|
|
103529
|
+
const initPrompt = buildMemoryInitRuntimePrompt({
|
|
103530
|
+
agentId,
|
|
103531
|
+
workingDirectory: process.cwd(),
|
|
103532
|
+
memoryDir: getMemoryFilesystemRoot(agentId),
|
|
103533
|
+
gitContext,
|
|
103534
|
+
depth: "shallow"
|
|
103535
|
+
});
|
|
103536
|
+
const { spawnBackgroundSubagentTask: spawnBackgroundSubagentTask2 } = await init_Task2().then(() => exports_Task);
|
|
103537
|
+
spawnBackgroundSubagentTask2({
|
|
103538
|
+
subagentType: "init",
|
|
103539
|
+
prompt: initPrompt,
|
|
103540
|
+
description: "Initializing memory",
|
|
103541
|
+
silentCompletion: true,
|
|
103542
|
+
onComplete
|
|
103543
|
+
});
|
|
103544
|
+
return true;
|
|
103545
|
+
}
|
|
103321
103546
|
function buildLegacyInitMessage(args) {
|
|
103322
103547
|
return `${SYSTEM_REMINDER_OPEN}
|
|
103323
103548
|
The user has requested memory initialization via /init.
|
|
@@ -103338,9 +103563,27 @@ Once invoked, follow the instructions from the \`initializing-memory\` skill to
|
|
|
103338
103563
|
${args.gitContext}
|
|
103339
103564
|
${SYSTEM_REMINDER_CLOSE}`;
|
|
103340
103565
|
}
|
|
103341
|
-
var
|
|
103566
|
+
var SHALLOW_INSTRUCTIONS, DEEP_INSTRUCTIONS;
|
|
103567
|
+
var init_initCommand = __esm(async () => {
|
|
103568
|
+
init_memoryFilesystem();
|
|
103342
103569
|
init_constants();
|
|
103343
103570
|
init_subagentState();
|
|
103571
|
+
await init_settings_manager();
|
|
103572
|
+
SHALLOW_INSTRUCTIONS = `
|
|
103573
|
+
Shallow init — fast project basics only (~5 tool calls max):
|
|
103574
|
+
- Only read: CLAUDE.md, AGENTS.md, package.json/pyproject.toml/Cargo.toml, README.md (first 100 lines), top-level directory listing
|
|
103575
|
+
- Detect user identity from the git context provided above (already in the prompt — no extra calls)
|
|
103576
|
+
- Run one git call: git log --format="%an <%ae>" | sort -u | head -5
|
|
103577
|
+
- Write exactly 4 files: project/overview.md, project/commands.md, project/conventions.md, human/identity.md
|
|
103578
|
+
- Skip: deep directory exploration, architecture mapping, config analysis, historical sessions, persona files, reflection/checkpoint phase
|
|
103579
|
+
`.trim();
|
|
103580
|
+
DEEP_INSTRUCTIONS = `
|
|
103581
|
+
Deep init — full exploration (follow the initializing-memory skill fully):
|
|
103582
|
+
- Read all existing memory files first — do NOT recreate what already exists
|
|
103583
|
+
- Then follow the full initializing-memory skill as your operating guide
|
|
103584
|
+
- Expand and deepen existing shallow files, add new ones to reach 15-25 target
|
|
103585
|
+
- If shallow init already ran, build on its output rather than starting over
|
|
103586
|
+
`.trim();
|
|
103344
103587
|
});
|
|
103345
103588
|
|
|
103346
103589
|
// src/cli/helpers/queuedMessageParts.ts
|
|
@@ -103528,9 +103771,11 @@ var init_statusLineSchema = __esm(() => {
|
|
|
103528
103771
|
{ path: "workspace.current_dir" },
|
|
103529
103772
|
{ path: "workspace.project_dir" },
|
|
103530
103773
|
{ path: "session_id" },
|
|
103774
|
+
{ path: "last_run_id" },
|
|
103531
103775
|
{ path: "version" },
|
|
103532
103776
|
{ path: "model.id" },
|
|
103533
103777
|
{ path: "model.display_name" },
|
|
103778
|
+
{ path: "agent.id" },
|
|
103534
103779
|
{ path: "agent.name" },
|
|
103535
103780
|
{ path: "cost.total_duration_ms" },
|
|
103536
103781
|
{ path: "cost.total_api_duration_ms" },
|
|
@@ -103624,6 +103869,7 @@ function buildStatusLinePayload(input) {
|
|
|
103624
103869
|
project_dir: input.projectDirectory
|
|
103625
103870
|
},
|
|
103626
103871
|
...input.sessionId ? { session_id: input.sessionId } : {},
|
|
103872
|
+
last_run_id: input.lastRunId ?? null,
|
|
103627
103873
|
transcript_path: null,
|
|
103628
103874
|
version: getVersion(),
|
|
103629
103875
|
reasoning_effort: input.reasoningEffort ?? null,
|
|
@@ -103654,6 +103900,7 @@ function buildStatusLinePayload(input) {
|
|
|
103654
103900
|
exceeds_200k_tokens: usedContextTokens > 200000,
|
|
103655
103901
|
vim: null,
|
|
103656
103902
|
agent: {
|
|
103903
|
+
id: input.agentId ?? null,
|
|
103657
103904
|
name: input.agentName ?? null
|
|
103658
103905
|
},
|
|
103659
103906
|
permission_mode: input.permissionMode ?? null,
|
|
@@ -104032,7 +104279,9 @@ function toPayloadInput(inputs) {
|
|
|
104032
104279
|
currentDirectory: inputs.currentDirectory,
|
|
104033
104280
|
projectDirectory: inputs.projectDirectory,
|
|
104034
104281
|
sessionId: inputs.sessionId,
|
|
104282
|
+
agentId: inputs.agentId,
|
|
104035
104283
|
agentName: inputs.agentName,
|
|
104284
|
+
lastRunId: inputs.lastRunId,
|
|
104036
104285
|
totalDurationMs: inputs.totalDurationMs,
|
|
104037
104286
|
totalApiDurationMs: inputs.totalApiDurationMs,
|
|
104038
104287
|
totalInputTokens: inputs.totalInputTokens,
|
|
@@ -104238,16 +104487,16 @@ __export(exports_shellAliases, {
|
|
|
104238
104487
|
expandAliases: () => expandAliases,
|
|
104239
104488
|
clearAliasCache: () => clearAliasCache
|
|
104240
104489
|
});
|
|
104241
|
-
import { existsSync as
|
|
104242
|
-
import { homedir as
|
|
104243
|
-
import { join as
|
|
104490
|
+
import { existsSync as existsSync25, readFileSync as readFileSync10 } from "node:fs";
|
|
104491
|
+
import { homedir as homedir27 } from "node:os";
|
|
104492
|
+
import { join as join38 } from "node:path";
|
|
104244
104493
|
function parseAliasesFromFile(filePath) {
|
|
104245
104494
|
const aliases = new Map;
|
|
104246
|
-
if (!
|
|
104495
|
+
if (!existsSync25(filePath)) {
|
|
104247
104496
|
return aliases;
|
|
104248
104497
|
}
|
|
104249
104498
|
try {
|
|
104250
|
-
const content =
|
|
104499
|
+
const content = readFileSync10(filePath, "utf-8");
|
|
104251
104500
|
const lines = content.split(`
|
|
104252
104501
|
`);
|
|
104253
104502
|
let inFunction = false;
|
|
@@ -104309,10 +104558,10 @@ function loadAliases(forceReload = false) {
|
|
|
104309
104558
|
if (aliasCache && !forceReload) {
|
|
104310
104559
|
return aliasCache;
|
|
104311
104560
|
}
|
|
104312
|
-
const home =
|
|
104561
|
+
const home = homedir27();
|
|
104313
104562
|
const allAliases = new Map;
|
|
104314
104563
|
for (const file of ALIAS_FILES) {
|
|
104315
|
-
const filePath =
|
|
104564
|
+
const filePath = join38(home, file);
|
|
104316
104565
|
const fileAliases = parseAliasesFromFile(filePath);
|
|
104317
104566
|
for (const [name, value] of fileAliases) {
|
|
104318
104567
|
allAliases.set(name, value);
|
|
@@ -104802,10 +105051,11 @@ Listener disconnected from Letta Cloud.`, true);
|
|
|
104802
105051
|
return;
|
|
104803
105052
|
}
|
|
104804
105053
|
if (msg.includes("--help") || msg.includes("-h")) {
|
|
104805
|
-
addCommandResult4(ctx.buffersRef, ctx.refreshDerived, msg, `Usage: /
|
|
104806
|
-
/
|
|
105054
|
+
addCommandResult4(ctx.buffersRef, ctx.refreshDerived, msg, `Usage: /server [--env-name <name>]
|
|
105055
|
+
/server off
|
|
104807
105056
|
|
|
104808
105057
|
Register this letta-code instance to receive messages from Letta Cloud.
|
|
105058
|
+
Alias: /remote
|
|
104809
105059
|
|
|
104810
105060
|
Options:
|
|
104811
105061
|
--env-name <name> Friendly name for this environment (uses hostname if not provided)
|
|
@@ -104813,9 +105063,9 @@ Options:
|
|
|
104813
105063
|
-h, --help Show this help message
|
|
104814
105064
|
|
|
104815
105065
|
Examples:
|
|
104816
|
-
/
|
|
104817
|
-
/
|
|
104818
|
-
/
|
|
105066
|
+
/server # Start listener with hostname
|
|
105067
|
+
/server --env-name "work-laptop" # Start with custom name
|
|
105068
|
+
/server off # Stop listening
|
|
104819
105069
|
|
|
104820
105070
|
Once connected, this instance will listen for incoming messages from cloud agents.
|
|
104821
105071
|
Messages will be executed locally using your letta-code environment.`, true);
|
|
@@ -104837,11 +105087,10 @@ Messages will be executed locally using your letta-code environment.`, true);
|
|
|
104837
105087
|
const buildConnectionUrl = (connId) => {
|
|
104838
105088
|
if (!ctx.agentId)
|
|
104839
105089
|
return "";
|
|
104840
|
-
|
|
104841
|
-
|
|
104842
|
-
|
|
104843
|
-
}
|
|
104844
|
-
return url;
|
|
105090
|
+
return buildChatUrl(ctx.agentId, {
|
|
105091
|
+
deviceId: connId,
|
|
105092
|
+
conversationId: ctx.conversationId ?? undefined
|
|
105093
|
+
});
|
|
104845
105094
|
};
|
|
104846
105095
|
ctx.setCommandRunning(true);
|
|
104847
105096
|
const cmdId = addCommandResult4(ctx.buffersRef, ctx.refreshDerived, msg, "Connecting to Letta Cloud...", true, "running");
|
|
@@ -105142,9 +105391,9 @@ var exports_App = {};
|
|
|
105142
105391
|
__export(exports_App, {
|
|
105143
105392
|
default: () => App2
|
|
105144
105393
|
});
|
|
105145
|
-
import { existsSync as
|
|
105146
|
-
import { homedir as
|
|
105147
|
-
import { join as
|
|
105394
|
+
import { existsSync as existsSync26, readFileSync as readFileSync11, renameSync as renameSync2, writeFileSync as writeFileSync12 } from "node:fs";
|
|
105395
|
+
import { homedir as homedir28, tmpdir as tmpdir5 } from "node:os";
|
|
105396
|
+
import { join as join39, relative as relative11 } from "node:path";
|
|
105148
105397
|
function deriveReasoningEffort(modelSettings, llmConfig) {
|
|
105149
105398
|
if (modelSettings && "provider_type" in modelSettings) {
|
|
105150
105399
|
if (modelSettings.provider_type === "openai" && "reasoning" in modelSettings && modelSettings.reasoning) {
|
|
@@ -105371,18 +105620,18 @@ ${SYSTEM_REMINDER_CLOSE}
|
|
|
105371
105620
|
}
|
|
105372
105621
|
function planFileExists() {
|
|
105373
105622
|
const planFilePath = permissionMode.getPlanFilePath();
|
|
105374
|
-
return !!planFilePath &&
|
|
105623
|
+
return !!planFilePath && existsSync26(planFilePath);
|
|
105375
105624
|
}
|
|
105376
105625
|
function _readPlanFile() {
|
|
105377
105626
|
const planFilePath = permissionMode.getPlanFilePath();
|
|
105378
105627
|
if (!planFilePath) {
|
|
105379
105628
|
return "No plan file path set.";
|
|
105380
105629
|
}
|
|
105381
|
-
if (!
|
|
105630
|
+
if (!existsSync26(planFilePath)) {
|
|
105382
105631
|
return `Plan file not found at ${planFilePath}`;
|
|
105383
105632
|
}
|
|
105384
105633
|
try {
|
|
105385
|
-
return
|
|
105634
|
+
return readFileSync11(planFilePath, "utf-8");
|
|
105386
105635
|
} catch {
|
|
105387
105636
|
return `Failed to read plan file at ${planFilePath}`;
|
|
105388
105637
|
}
|
|
@@ -105519,8 +105768,11 @@ function App2({
|
|
|
105519
105768
|
import_react99.useEffect(() => {
|
|
105520
105769
|
conversationIdRef.current = conversationId;
|
|
105521
105770
|
}, [conversationId]);
|
|
105771
|
+
const lastRunIdRef = import_react99.useRef(null);
|
|
105522
105772
|
const resumeKey = useSuspend();
|
|
105523
105773
|
const pendingConversationSwitchRef = import_react99.useRef(null);
|
|
105774
|
+
const autoInitPendingAgentIdsRef = import_react99.useRef(new Set);
|
|
105775
|
+
const startupAutoInitConsumedRef = import_react99.useRef(false);
|
|
105524
105776
|
const prevInitialAgentIdRef = import_react99.useRef(initialAgentId);
|
|
105525
105777
|
const prevInitialAgentStateRef = import_react99.useRef(initialAgentState);
|
|
105526
105778
|
const prevInitialConversationIdRef = import_react99.useRef(initialConversationId);
|
|
@@ -105857,6 +106109,15 @@ function App2({
|
|
|
105857
106109
|
}, []);
|
|
105858
106110
|
const [showExitStats, setShowExitStats] = import_react99.useState(false);
|
|
105859
106111
|
const sharedReminderStateRef = import_react99.useRef(createSharedReminderState());
|
|
106112
|
+
const initProgressByAgentRef = import_react99.useRef(new Map);
|
|
106113
|
+
const updateInitProgress = (forAgentId, update) => {
|
|
106114
|
+
const progress2 = initProgressByAgentRef.current.get(forAgentId) ?? {
|
|
106115
|
+
shallowCompleted: false,
|
|
106116
|
+
deepFired: false
|
|
106117
|
+
};
|
|
106118
|
+
Object.assign(progress2, update);
|
|
106119
|
+
initProgressByAgentRef.current.set(forAgentId, progress2);
|
|
106120
|
+
};
|
|
105860
106121
|
const hasSetConversationSummaryRef = import_react99.useRef(resumedExistingConversation);
|
|
105861
106122
|
const firstUserQueryRef = import_react99.useRef(null);
|
|
105862
106123
|
const resetBootstrapReminderState = import_react99.useCallback(() => {
|
|
@@ -106342,7 +106603,9 @@ function App2({
|
|
|
106342
106603
|
currentDirectory: process.cwd(),
|
|
106343
106604
|
projectDirectory,
|
|
106344
106605
|
sessionId: conversationId,
|
|
106606
|
+
agentId,
|
|
106345
106607
|
agentName,
|
|
106608
|
+
lastRunId: lastRunIdRef.current,
|
|
106346
106609
|
totalDurationMs: sessionStatsSnapshot.totalWallMs,
|
|
106347
106610
|
totalApiDurationMs: sessionStatsSnapshot.totalApiMs,
|
|
106348
106611
|
totalInputTokens: sessionStatsSnapshot.usage.promptTokens,
|
|
@@ -106494,7 +106757,8 @@ function App2({
|
|
|
106494
106757
|
enqueueCommandIoReminder(sharedReminderStateRef.current, {
|
|
106495
106758
|
input,
|
|
106496
106759
|
output: event.output,
|
|
106497
|
-
success: event.success
|
|
106760
|
+
success: event.success,
|
|
106761
|
+
agentHint: event.agentHint
|
|
106498
106762
|
});
|
|
106499
106763
|
}, []);
|
|
106500
106764
|
const maybeRecordToolsetChangeReminder = import_react99.useCallback((params) => {
|
|
@@ -106637,10 +106901,10 @@ function App2({
|
|
|
106637
106901
|
if (!planFilePath)
|
|
106638
106902
|
return;
|
|
106639
106903
|
try {
|
|
106640
|
-
const { readFileSync:
|
|
106641
|
-
if (!
|
|
106904
|
+
const { readFileSync: readFileSync12, existsSync: existsSync27 } = __require("node:fs");
|
|
106905
|
+
if (!existsSync27(planFilePath))
|
|
106642
106906
|
return;
|
|
106643
|
-
const planContent =
|
|
106907
|
+
const planContent = readFileSync12(planFilePath, "utf-8");
|
|
106644
106908
|
const previewItem = {
|
|
106645
106909
|
kind: "approval_preview",
|
|
106646
106910
|
id: `approval-preview-${toolCallId}`,
|
|
@@ -106853,6 +107117,7 @@ function App2({
|
|
|
106853
107117
|
}
|
|
106854
107118
|
try {
|
|
106855
107119
|
const client = await getClient2();
|
|
107120
|
+
debugLog("conversations", `retrieve(${conversationId}) [syncConversationModel]`);
|
|
106856
107121
|
const conversation = await client.conversations.retrieve(conversationId);
|
|
106857
107122
|
if (cancelled)
|
|
106858
107123
|
return;
|
|
@@ -107018,9 +107283,9 @@ Memory may be stale. Try running: git -C ~/.letta/agents/${agentId}/memory pull`
|
|
|
107018
107283
|
(async () => {
|
|
107019
107284
|
try {
|
|
107020
107285
|
const { watch } = await import("node:fs");
|
|
107021
|
-
const { existsSync:
|
|
107286
|
+
const { existsSync: existsSync27 } = await import("node:fs");
|
|
107022
107287
|
const memRoot = getMemoryFilesystemRoot(agentId);
|
|
107023
|
-
if (!
|
|
107288
|
+
if (!existsSync27(memRoot))
|
|
107024
107289
|
return;
|
|
107025
107290
|
watcher = watch(memRoot, { recursive: true }, () => {});
|
|
107026
107291
|
memfsWatcherRef.current = watcher;
|
|
@@ -107264,7 +107529,7 @@ ${newState.originalPrompt}`
|
|
|
107264
107529
|
}
|
|
107265
107530
|
if (preStreamAction === "retry_conversation_busy") {
|
|
107266
107531
|
conversationBusyRetriesRef.current += 1;
|
|
107267
|
-
const retryDelayMs =
|
|
107532
|
+
const retryDelayMs = CONVERSATION_BUSY_RETRY_BASE_DELAY_MS2 * 2 ** (conversationBusyRetriesRef.current - 1);
|
|
107268
107533
|
telemetry.trackError("retry_conversation_busy", formatTelemetryErrorMessage(errorDetail || "Conversation is busy"), "pre_stream_retry", {
|
|
107269
107534
|
httpStatus: preStreamError instanceof APIError2 ? preStreamError.status : undefined,
|
|
107270
107535
|
modelId: currentModelId || undefined
|
|
@@ -107441,6 +107706,8 @@ ${newState.originalPrompt}`
|
|
|
107441
107706
|
fallbackError
|
|
107442
107707
|
} = await drainStreamWithResume(stream2, buffersRef.current, refreshDerivedThrottled, signal, handleFirstMessage, undefined, contextTrackerRef.current);
|
|
107443
107708
|
currentRunId = lastRunId ?? undefined;
|
|
107709
|
+
if (lastRunId)
|
|
107710
|
+
lastRunIdRef.current = lastRunId;
|
|
107444
107711
|
sessionStatsRef.current.endTurn(apiDurationMs);
|
|
107445
107712
|
const usageDelta = sessionStatsRef.current.updateUsageFromBuffers(buffersRef.current);
|
|
107446
107713
|
const tokenDelta = Math.max(0, buffersRef.current.tokenCount - runTokenStart);
|
|
@@ -108293,8 +108560,12 @@ ${feedback}
|
|
|
108293
108560
|
toolResultsInFlightRef.current = false;
|
|
108294
108561
|
refreshDerived();
|
|
108295
108562
|
getClient2().then((client) => {
|
|
108296
|
-
|
|
108297
|
-
|
|
108563
|
+
if (conversationIdRef.current === "default") {
|
|
108564
|
+
return client.conversations.cancel("default", {
|
|
108565
|
+
agent_id: agentIdRef.current
|
|
108566
|
+
});
|
|
108567
|
+
}
|
|
108568
|
+
return client.conversations.cancel(conversationIdRef.current);
|
|
108298
108569
|
}).catch(() => {});
|
|
108299
108570
|
setTimeout(() => {
|
|
108300
108571
|
userCancelledRef.current = false;
|
|
@@ -108362,8 +108633,12 @@ ${feedback}
|
|
|
108362
108633
|
setAutoHandledResults([]);
|
|
108363
108634
|
setAutoDeniedApprovals([]);
|
|
108364
108635
|
getClient2().then((client) => {
|
|
108365
|
-
|
|
108366
|
-
|
|
108636
|
+
if (conversationIdRef.current === "default") {
|
|
108637
|
+
return client.conversations.cancel("default", {
|
|
108638
|
+
agent_id: agentIdRef.current
|
|
108639
|
+
});
|
|
108640
|
+
}
|
|
108641
|
+
return client.conversations.cancel(conversationIdRef.current);
|
|
108367
108642
|
}).catch(() => {});
|
|
108368
108643
|
setTimeout(() => {
|
|
108369
108644
|
userCancelledRef.current = false;
|
|
@@ -108374,8 +108649,13 @@ ${feedback}
|
|
|
108374
108649
|
setInterruptRequested(true);
|
|
108375
108650
|
try {
|
|
108376
108651
|
const client = await getClient2();
|
|
108377
|
-
|
|
108378
|
-
|
|
108652
|
+
if (conversationIdRef.current === "default") {
|
|
108653
|
+
await client.conversations.cancel("default", {
|
|
108654
|
+
agent_id: agentIdRef.current
|
|
108655
|
+
});
|
|
108656
|
+
} else {
|
|
108657
|
+
await client.conversations.cancel(conversationIdRef.current);
|
|
108658
|
+
}
|
|
108379
108659
|
if (abortControllerRef.current) {
|
|
108380
108660
|
abortControllerRef.current.abort();
|
|
108381
108661
|
abortControllerRef.current = null;
|
|
@@ -108543,6 +108823,9 @@ ${feedback}
|
|
|
108543
108823
|
const { agent } = await createAgent(name);
|
|
108544
108824
|
const { enableMemfsIfCloud: enableMemfsIfCloud2 } = await Promise.resolve().then(() => (init_memoryFilesystem(), exports_memoryFilesystem));
|
|
108545
108825
|
await enableMemfsIfCloud2(agent.id);
|
|
108826
|
+
if (settingsManager.isMemfsEnabled(agent.id)) {
|
|
108827
|
+
autoInitPendingAgentIdsRef.current.add(agent.id);
|
|
108828
|
+
}
|
|
108546
108829
|
await updateProjectSettings({ lastAgent: agent.id });
|
|
108547
108830
|
const targetConversationId = "default";
|
|
108548
108831
|
settingsManager.setLocalLastSession({ agentId: agent.id, conversationId: targetConversationId }, process.cwd());
|
|
@@ -108550,11 +108833,12 @@ ${feedback}
|
|
|
108550
108833
|
agentId: agent.id,
|
|
108551
108834
|
conversationId: targetConversationId
|
|
108552
108835
|
});
|
|
108553
|
-
const agentUrl =
|
|
108836
|
+
const agentUrl = buildChatUrl(agent.id);
|
|
108837
|
+
const memfsTip = settingsManager.isMemfsEnabled(agent.id) ? "Memory will be auto-initialized on your first message." : "Tip: use /init to initialize your agent's memory system!";
|
|
108554
108838
|
const successOutput = [
|
|
108555
108839
|
`Created **${agent.name || agent.id}** (use /pin to save)`,
|
|
108556
108840
|
`⎿ ${agentUrl}`,
|
|
108557
|
-
`⎿
|
|
108841
|
+
`⎿ ${memfsTip}`
|
|
108558
108842
|
].join(`
|
|
108559
108843
|
`);
|
|
108560
108844
|
cmd.finish(successOutput, true);
|
|
@@ -108969,7 +109253,9 @@ ${SYSTEM_REMINDER_CLOSE}` : "";
|
|
|
108969
109253
|
return { submitted: true };
|
|
108970
109254
|
}
|
|
108971
109255
|
if (trimmed === "/ade") {
|
|
108972
|
-
const adeUrl =
|
|
109256
|
+
const adeUrl = buildChatUrl(agentId, {
|
|
109257
|
+
conversationId: conversationIdRef.current
|
|
109258
|
+
});
|
|
108973
109259
|
const cmd = commandRunner.start("/ade", "Opening ADE...");
|
|
108974
109260
|
Promise.resolve().then(() => (init_open(), exports_open)).then(({ default: open2 }) => open2(adeUrl, { wait: false })).catch(() => {});
|
|
108975
109261
|
cmd.finish(`Opening ADE...
|
|
@@ -109115,7 +109401,7 @@ ${SYSTEM_REMINDER_CLOSE}` : "";
|
|
|
109115
109401
|
}
|
|
109116
109402
|
return { submitted: true };
|
|
109117
109403
|
}
|
|
109118
|
-
if (trimmed === "/remote" || trimmed.startsWith("/remote ")) {
|
|
109404
|
+
if (trimmed === "/server" || trimmed.startsWith("/server ") || trimmed === "/remote" || trimmed.startsWith("/remote ")) {
|
|
109119
109405
|
const parts = Array.from(trimmed.matchAll(/"([^"\\]*(?:\\.[^"\\]*)*)"|'([^'\\]*(?:\\.[^'\\]*)*)'|(\S+)/g), (match3) => match3[1] ?? match3[2] ?? match3[3]);
|
|
109120
109406
|
let name;
|
|
109121
109407
|
let _listenAgentId;
|
|
@@ -109241,7 +109527,9 @@ ${SYSTEM_REMINDER_CLOSE}` : "";
|
|
|
109241
109527
|
currentDirectory: wd,
|
|
109242
109528
|
projectDirectory,
|
|
109243
109529
|
sessionId: conversationIdRef.current,
|
|
109530
|
+
agentId,
|
|
109244
109531
|
agentName,
|
|
109532
|
+
lastRunId: lastRunIdRef.current,
|
|
109245
109533
|
totalDurationMs: stats.totalWallMs,
|
|
109246
109534
|
totalApiDurationMs: stats.totalApiMs,
|
|
109247
109535
|
totalInputTokens: stats.usage.promptTokens,
|
|
@@ -109611,8 +109899,12 @@ Type your task to begin the loop.`, true);
|
|
|
109611
109899
|
mode: modeArg
|
|
109612
109900
|
}
|
|
109613
109901
|
} : undefined;
|
|
109614
|
-
const
|
|
109615
|
-
const
|
|
109902
|
+
const compactConversationId = conversationIdRef.current;
|
|
109903
|
+
const compactBody = compactConversationId === "default" ? {
|
|
109904
|
+
agent_id: agentId,
|
|
109905
|
+
...compactParams ?? {}
|
|
109906
|
+
} : compactParams;
|
|
109907
|
+
const result2 = await client.conversations.messages.compact(compactConversationId, compactBody);
|
|
109616
109908
|
const outputLines = [
|
|
109617
109909
|
`Compaction completed${modeDisplay}. Message buffer length reduced from ${result2.num_messages_before} to ${result2.num_messages_after}.`,
|
|
109618
109910
|
"",
|
|
@@ -109708,6 +110000,7 @@ Type your task to begin the loop.`, true);
|
|
|
109708
110000
|
const client = await getClient2();
|
|
109709
110001
|
await client.agents.update(agentId, { name: newValue });
|
|
109710
110002
|
updateAgentName(newValue);
|
|
110003
|
+
cmd.agentHint = `Your name is now "${newValue}" — acknowledge this and save your new name to memory.`;
|
|
109711
110004
|
cmd.finish(`Agent renamed to "${newValue}"`, true);
|
|
109712
110005
|
} catch (error) {
|
|
109713
110006
|
const errorDetails = formatErrorDetails2(error, agentId);
|
|
@@ -110079,7 +110372,7 @@ Press Enter to continue, or type anything to cancel.`, false, "running");
|
|
|
110079
110372
|
try {
|
|
110080
110373
|
const client = await getClient2();
|
|
110081
110374
|
const exportParams = {};
|
|
110082
|
-
if (conversationId !== "default") {
|
|
110375
|
+
if (conversationId !== "default" && conversationId !== agentId) {
|
|
110083
110376
|
exportParams.conversation_id = conversationId;
|
|
110084
110377
|
}
|
|
110085
110378
|
const { packageSkills: packageSkills2 } = await Promise.resolve().then(() => (init_export(), exports_export));
|
|
@@ -110201,11 +110494,11 @@ Path: ${result2.memoryDir}`, true, msg);
|
|
|
110201
110494
|
setCommandRunning(true);
|
|
110202
110495
|
try {
|
|
110203
110496
|
const memoryDir = getMemoryFilesystemRoot(agentId);
|
|
110204
|
-
if (!
|
|
110497
|
+
if (!existsSync26(memoryDir)) {
|
|
110205
110498
|
updateMemorySyncCommand(cmdId, "No local memory filesystem found to reset.", true, msg);
|
|
110206
110499
|
return { submitted: true };
|
|
110207
110500
|
}
|
|
110208
|
-
const backupDir =
|
|
110501
|
+
const backupDir = join39(tmpdir5(), `letta-memfs-reset-${agentId}-${Date.now()}`);
|
|
110209
110502
|
renameSync2(memoryDir, backupDir);
|
|
110210
110503
|
ensureMemoryFilesystemDirs(agentId);
|
|
110211
110504
|
updateMemorySyncCommand(cmdId, `Memory filesystem reset.
|
|
@@ -110233,8 +110526,8 @@ Run \`/memfs sync\` to repopulate from API.`, true, msg);
|
|
|
110233
110526
|
await removeGitMemoryTag2(agentId);
|
|
110234
110527
|
let backupInfo = "";
|
|
110235
110528
|
const memoryDir = getMemoryFilesystemRoot(agentId);
|
|
110236
|
-
if (
|
|
110237
|
-
const backupDir =
|
|
110529
|
+
if (existsSync26(memoryDir)) {
|
|
110530
|
+
const backupDir = join39(tmpdir5(), `letta-memfs-disable-${agentId}-${Date.now()}`);
|
|
110238
110531
|
renameSync2(memoryDir, backupDir);
|
|
110239
110532
|
backupInfo = `
|
|
110240
110533
|
Local files backed up to ${backupDir}`;
|
|
@@ -110358,7 +110651,8 @@ ${SYSTEM_REMINDER_CLOSE}`;
|
|
|
110358
110651
|
agentId,
|
|
110359
110652
|
workingDirectory: process.cwd(),
|
|
110360
110653
|
memoryDir: getMemoryFilesystemRoot(agentId),
|
|
110361
|
-
gitContext
|
|
110654
|
+
gitContext,
|
|
110655
|
+
depth: "deep"
|
|
110362
110656
|
});
|
|
110363
110657
|
const { spawnBackgroundSubagentTask: spawnBackgroundSubagentTask2 } = await init_Task2().then(() => exports_Task);
|
|
110364
110658
|
spawnBackgroundSubagentTask2({
|
|
@@ -110367,10 +110661,14 @@ ${SYSTEM_REMINDER_CLOSE}`;
|
|
|
110367
110661
|
description: "Initializing memory",
|
|
110368
110662
|
silentCompletion: true,
|
|
110369
110663
|
onComplete: ({ success, error }) => {
|
|
110370
|
-
|
|
110664
|
+
if (success) {
|
|
110665
|
+
updateInitProgress(agentId, { deepFired: true });
|
|
110666
|
+
}
|
|
110667
|
+
const msg2 = success ? "Built a memory palace of you. Visit it with /palace." : `Memory initialization failed: ${error || "Unknown error"}`;
|
|
110371
110668
|
appendTaskNotificationEvents([msg2]);
|
|
110372
110669
|
}
|
|
110373
110670
|
});
|
|
110671
|
+
autoInitPendingAgentIdsRef.current.delete(agentId);
|
|
110374
110672
|
cmd.finish("Learning about you and your codebase in the background. You'll be notified when ready.", true);
|
|
110375
110673
|
const reminders = sharedReminderStateRef.current.pendingCommandIoReminders;
|
|
110376
110674
|
const idx = reminders.findIndex((r) => r.input === "/init");
|
|
@@ -110382,6 +110680,7 @@ ${SYSTEM_REMINDER_CLOSE}`;
|
|
|
110382
110680
|
cmd.fail(`Failed to start memory initialization: ${errorDetails}`);
|
|
110383
110681
|
}
|
|
110384
110682
|
} else {
|
|
110683
|
+
autoInitPendingAgentIdsRef.current.delete(agentId);
|
|
110385
110684
|
setCommandRunning(true);
|
|
110386
110685
|
try {
|
|
110387
110686
|
cmd.finish("Assimilating project context and defragmenting memories...", true);
|
|
@@ -110461,6 +110760,21 @@ ${SYSTEM_REMINDER_CLOSE}`)
|
|
|
110461
110760
|
return { submitted: true };
|
|
110462
110761
|
}
|
|
110463
110762
|
}
|
|
110763
|
+
if (autoInitPendingAgentIdsRef.current.has(agentId) && !isSystemOnly) {
|
|
110764
|
+
try {
|
|
110765
|
+
const fired = await fireAutoInit(agentId, ({ success, error }) => {
|
|
110766
|
+
if (success) {
|
|
110767
|
+
updateInitProgress(agentId, { shallowCompleted: true });
|
|
110768
|
+
}
|
|
110769
|
+
const msg2 = success ? "Built a memory palace of you. Visit it with /palace." : `Memory initialization failed: ${error || "Unknown error"}`;
|
|
110770
|
+
appendTaskNotificationEvents([msg2]);
|
|
110771
|
+
});
|
|
110772
|
+
if (fired) {
|
|
110773
|
+
autoInitPendingAgentIdsRef.current.delete(agentId);
|
|
110774
|
+
sharedReminderStateRef.current.pendingAutoInitReminder = true;
|
|
110775
|
+
}
|
|
110776
|
+
} catch {}
|
|
110777
|
+
}
|
|
110464
110778
|
const contentParts = overrideContentParts ?? buildMessageContentFromDisplay(msg);
|
|
110465
110779
|
let ralphModeReminder = "";
|
|
110466
110780
|
if (ralphMode.getState().isActive) {
|
|
@@ -110558,7 +110872,45 @@ ${SYSTEM_REMINDER_CLOSE}
|
|
|
110558
110872
|
return false;
|
|
110559
110873
|
}
|
|
110560
110874
|
};
|
|
110875
|
+
const maybeLaunchDeepInitSubagent = async () => {
|
|
110876
|
+
if (!memfsEnabledForAgent)
|
|
110877
|
+
return false;
|
|
110878
|
+
if (hasActiveInitSubagent())
|
|
110879
|
+
return false;
|
|
110880
|
+
try {
|
|
110881
|
+
const gitContext = gatherGitContext();
|
|
110882
|
+
const initPrompt = buildMemoryInitRuntimePrompt({
|
|
110883
|
+
agentId,
|
|
110884
|
+
workingDirectory: process.cwd(),
|
|
110885
|
+
memoryDir: getMemoryFilesystemRoot(agentId),
|
|
110886
|
+
gitContext,
|
|
110887
|
+
depth: "deep"
|
|
110888
|
+
});
|
|
110889
|
+
const { spawnBackgroundSubagentTask: spawnBackgroundSubagentTask2 } = await init_Task2().then(() => exports_Task);
|
|
110890
|
+
spawnBackgroundSubagentTask2({
|
|
110891
|
+
subagentType: "init",
|
|
110892
|
+
prompt: initPrompt,
|
|
110893
|
+
description: "Deep memory initialization",
|
|
110894
|
+
silentCompletion: true,
|
|
110895
|
+
onComplete: ({ success, error }) => {
|
|
110896
|
+
if (success) {
|
|
110897
|
+
updateInitProgress(agentId, { deepFired: true });
|
|
110898
|
+
}
|
|
110899
|
+
const msg2 = success ? "Built a memory palace of you. Visit it with /palace." : `Deep memory initialization failed: ${error || "Unknown error"}`;
|
|
110900
|
+
appendTaskNotificationEvents([msg2]);
|
|
110901
|
+
}
|
|
110902
|
+
});
|
|
110903
|
+
debugLog("memory", "Auto-launched deep init subagent");
|
|
110904
|
+
return true;
|
|
110905
|
+
} catch (error) {
|
|
110906
|
+
debugWarn("memory", `Failed to auto-launch deep init subagent: ${error instanceof Error ? error.message : String(error)}`);
|
|
110907
|
+
return false;
|
|
110908
|
+
}
|
|
110909
|
+
};
|
|
110561
110910
|
syncReminderStateFromContextTracker(sharedReminderStateRef.current, contextTrackerRef.current);
|
|
110911
|
+
const initProgress = initProgressByAgentRef.current.get(agentId);
|
|
110912
|
+
sharedReminderStateRef.current.shallowInitCompleted = initProgress?.shallowCompleted ?? false;
|
|
110913
|
+
sharedReminderStateRef.current.deepInitFired = initProgress?.deepFired ?? false;
|
|
110562
110914
|
const { getSkillSources: getSkillSources2 } = await Promise.resolve().then(() => (init_context(), exports_context));
|
|
110563
110915
|
const { parts: sharedReminderParts } = await buildSharedReminderParts({
|
|
110564
110916
|
mode: "interactive",
|
|
@@ -110573,7 +110925,8 @@ ${SYSTEM_REMINDER_CLOSE}
|
|
|
110573
110925
|
reflectionSettings,
|
|
110574
110926
|
skillSources: getSkillSources2(),
|
|
110575
110927
|
resolvePlanModeReminder: getPlanModeReminder,
|
|
110576
|
-
maybeLaunchReflectionSubagent
|
|
110928
|
+
maybeLaunchReflectionSubagent,
|
|
110929
|
+
maybeLaunchDeepInitSubagent
|
|
110577
110930
|
});
|
|
110578
110931
|
for (const part of sharedReminderParts) {
|
|
110579
110932
|
reminderParts.push(part);
|
|
@@ -112307,7 +112660,7 @@ ${guidance}`);
|
|
|
112307
112660
|
}
|
|
112308
112661
|
if (!planFileExists()) {
|
|
112309
112662
|
const planFilePath = permissionMode.getPlanFilePath();
|
|
112310
|
-
const plansDir =
|
|
112663
|
+
const plansDir = join39(homedir28(), ".letta", "plans");
|
|
112311
112664
|
handlePlanKeepPlanning(`You must write your plan to a plan file before exiting plan mode.
|
|
112312
112665
|
` + (planFilePath ? `Plan file path: ${planFilePath}
|
|
112313
112666
|
` : "") + `Use a write tool to create your plan in ${plansDir}, then use ExitPlanMode to present the plan to the user.`);
|
|
@@ -112512,6 +112865,14 @@ If using apply_patch, use this exact relative patch path: ${applyPatchRelativePa
|
|
|
112512
112865
|
return estimatedLiveHeight < resumeThreshold;
|
|
112513
112866
|
});
|
|
112514
112867
|
}, [estimatedLiveHeight, terminalRows]);
|
|
112868
|
+
import_react99.useEffect(() => {
|
|
112869
|
+
if (loadingState === "ready" && agentProvenance?.isNew && agentId && !startupAutoInitConsumedRef.current) {
|
|
112870
|
+
startupAutoInitConsumedRef.current = true;
|
|
112871
|
+
if (settingsManager.isMemfsEnabled(agentId)) {
|
|
112872
|
+
autoInitPendingAgentIdsRef.current.add(agentId);
|
|
112873
|
+
}
|
|
112874
|
+
}
|
|
112875
|
+
}, [loadingState, agentProvenance, agentId]);
|
|
112515
112876
|
import_react99.useEffect(() => {
|
|
112516
112877
|
if (loadingState === "ready" && !welcomeCommittedRef.current && messageHistory.length === 0) {
|
|
112517
112878
|
if (!continueSession && !agentProvenance) {
|
|
@@ -112822,7 +113183,7 @@ If using apply_patch, use this exact relative patch path: ${applyPatchRelativePa
|
|
|
112822
113183
|
color: colors.link.url,
|
|
112823
113184
|
children: agentName && (settingsManager.getLocalPinnedAgents().includes(agentId) || settingsManager.getGlobalPinnedAgents().includes(agentId)) ? `letta -n "${agentName}"` : `letta --agent ${agentId}`
|
|
112824
113185
|
}, undefined, false, undefined, this),
|
|
112825
|
-
conversationId !== "default" && /* @__PURE__ */ jsx_dev_runtime76.jsxDEV(jsx_dev_runtime76.Fragment, {
|
|
113186
|
+
conversationId !== "default" && conversationId !== agentId && /* @__PURE__ */ jsx_dev_runtime76.jsxDEV(jsx_dev_runtime76.Fragment, {
|
|
112826
113187
|
children: [
|
|
112827
113188
|
/* @__PURE__ */ jsx_dev_runtime76.jsxDEV(Box_default, {
|
|
112828
113189
|
height: 1
|
|
@@ -113446,6 +113807,9 @@ Open /mcp to attach or detach tools for this server.`, true);
|
|
|
113446
113807
|
} else {
|
|
113447
113808
|
settingsManager.pinGlobal(agentId);
|
|
113448
113809
|
}
|
|
113810
|
+
if (newName && newName !== agentName) {
|
|
113811
|
+
cmd.agentHint = `Your name is now "${newName}" — acknowledge this and save your new name to memory.`;
|
|
113812
|
+
}
|
|
113449
113813
|
cmd.finish(`Pinned "${newName || agentName || agentId.slice(0, 12)}" ${scopeText}.`, true);
|
|
113450
113814
|
} catch (error) {
|
|
113451
113815
|
cmd.fail(`Failed to pin: ${error}`);
|
|
@@ -113463,7 +113827,7 @@ Open /mcp to attach or detach tools for this server.`, true);
|
|
|
113463
113827
|
]
|
|
113464
113828
|
}, resumeKey, true, undefined, this);
|
|
113465
113829
|
}
|
|
113466
|
-
var import_react99, jsx_dev_runtime76, CLEAR_SCREEN_AND_HOME = "\x1B[2J\x1B[H", MIN_RESIZE_DELTA = 2, RESIZE_SETTLE_MS = 250, MIN_CLEAR_INTERVAL_MS = 750, STABLE_WIDTH_SETTLE_MS = 180, TOOL_CALL_COMMIT_DEFER_MS = 50, ANIMATION_RESUME_HYSTERESIS_ROWS = 2, EAGER_CANCEL = true, LLM_API_ERROR_MAX_RETRIES3 = 3, EMPTY_RESPONSE_MAX_RETRIES2 = 2, CONVERSATION_BUSY_MAX_RETRIES2 = 3,
|
|
113830
|
+
var import_react99, jsx_dev_runtime76, CLEAR_SCREEN_AND_HOME = "\x1B[2J\x1B[H", MIN_RESIZE_DELTA = 2, RESIZE_SETTLE_MS = 250, MIN_CLEAR_INTERVAL_MS = 750, STABLE_WIDTH_SETTLE_MS = 180, TOOL_CALL_COMMIT_DEFER_MS = 50, ANIMATION_RESUME_HYSTERESIS_ROWS = 2, EAGER_CANCEL = true, LLM_API_ERROR_MAX_RETRIES3 = 3, EMPTY_RESPONSE_MAX_RETRIES2 = 2, CONVERSATION_BUSY_MAX_RETRIES2 = 3, CONVERSATION_BUSY_RETRY_BASE_DELAY_MS2 = 1e4, INTERRUPT_MESSAGE = "Interrupted – tell the agent what to do differently. Something went wrong? Use /feedback to report issues.", ERROR_FEEDBACK_HINT = "Something went wrong? Use /feedback to report issues.", OPUS_BEDROCK_FALLBACK_HINT = "Downstream provider issues? Use /model to switch to Bedrock Opus 4.5", PROVIDER_FALLBACK_HINT = "Downstream provider issues? Use /model to switch to another provider", INTERACTIVE_SLASH_COMMANDS, NON_STATE_COMMANDS, APPROVAL_OPTIONS_HEIGHT = 8, APPROVAL_PREVIEW_BUFFER = 4, MIN_WRAP_WIDTH = 10, TEXT_WRAP_GUTTER = 6, DIFF_WRAP_GUTTER = 12, AUTO_REFLECTION_DESCRIPTION = "Reflect on recent conversations", AUTO_REFLECTION_PROMPT = "Review recent conversation history and update memory files with important information worth preserving.";
|
|
113467
113831
|
var init_App2 = __esm(async () => {
|
|
113468
113832
|
init_error();
|
|
113469
113833
|
init_check_approval();
|
|
@@ -113489,7 +113853,6 @@ var init_App2 = __esm(async () => {
|
|
|
113489
113853
|
init_diff2();
|
|
113490
113854
|
init_errorContext();
|
|
113491
113855
|
init_errorFormatter();
|
|
113492
|
-
init_initCommand();
|
|
113493
113856
|
init_messageQueueBridge();
|
|
113494
113857
|
init_pasteRegistry();
|
|
113495
113858
|
init_planName();
|
|
@@ -113563,6 +113926,7 @@ var init_App2 = __esm(async () => {
|
|
|
113563
113926
|
init_accumulator(),
|
|
113564
113927
|
init_approvalClassification(),
|
|
113565
113928
|
init_formatArgsDisplay(),
|
|
113929
|
+
init_initCommand(),
|
|
113566
113930
|
init_memoryReminder(),
|
|
113567
113931
|
init_statusLineConfig(),
|
|
113568
113932
|
init_stream(),
|
|
@@ -113628,13 +113992,13 @@ __export(exports_terminalKeybindingInstaller2, {
|
|
|
113628
113992
|
});
|
|
113629
113993
|
import {
|
|
113630
113994
|
copyFileSync as copyFileSync2,
|
|
113631
|
-
existsSync as
|
|
113632
|
-
mkdirSync as
|
|
113633
|
-
readFileSync as
|
|
113995
|
+
existsSync as existsSync27,
|
|
113996
|
+
mkdirSync as mkdirSync18,
|
|
113997
|
+
readFileSync as readFileSync12,
|
|
113634
113998
|
writeFileSync as writeFileSync13
|
|
113635
113999
|
} from "node:fs";
|
|
113636
|
-
import { homedir as
|
|
113637
|
-
import { dirname as dirname14, join as
|
|
114000
|
+
import { homedir as homedir29, platform as platform5 } from "node:os";
|
|
114001
|
+
import { dirname as dirname14, join as join40 } from "node:path";
|
|
113638
114002
|
function detectTerminalType2() {
|
|
113639
114003
|
if (process.env.CURSOR_TRACE_ID || process.env.CURSOR_CHANNEL) {
|
|
113640
114004
|
return "cursor";
|
|
@@ -113666,16 +114030,16 @@ function getKeybindingsPath2(terminal) {
|
|
|
113666
114030
|
}[terminal];
|
|
113667
114031
|
const os7 = platform5();
|
|
113668
114032
|
if (os7 === "darwin") {
|
|
113669
|
-
return
|
|
114033
|
+
return join40(homedir29(), "Library", "Application Support", appName, "User", "keybindings.json");
|
|
113670
114034
|
}
|
|
113671
114035
|
if (os7 === "win32") {
|
|
113672
114036
|
const appData = process.env.APPDATA;
|
|
113673
114037
|
if (!appData)
|
|
113674
114038
|
return null;
|
|
113675
|
-
return
|
|
114039
|
+
return join40(appData, appName, "User", "keybindings.json");
|
|
113676
114040
|
}
|
|
113677
114041
|
if (os7 === "linux") {
|
|
113678
|
-
return
|
|
114042
|
+
return join40(homedir29(), ".config", appName, "User", "keybindings.json");
|
|
113679
114043
|
}
|
|
113680
114044
|
return null;
|
|
113681
114045
|
}
|
|
@@ -113697,10 +114061,10 @@ function parseKeybindings2(content) {
|
|
|
113697
114061
|
}
|
|
113698
114062
|
}
|
|
113699
114063
|
function keybindingExists2(keybindingsPath) {
|
|
113700
|
-
if (!
|
|
114064
|
+
if (!existsSync27(keybindingsPath))
|
|
113701
114065
|
return false;
|
|
113702
114066
|
try {
|
|
113703
|
-
const content =
|
|
114067
|
+
const content = readFileSync12(keybindingsPath, { encoding: "utf-8" });
|
|
113704
114068
|
const keybindings = parseKeybindings2(content);
|
|
113705
114069
|
if (!keybindings)
|
|
113706
114070
|
return false;
|
|
@@ -113710,7 +114074,7 @@ function keybindingExists2(keybindingsPath) {
|
|
|
113710
114074
|
}
|
|
113711
114075
|
}
|
|
113712
114076
|
function createBackup2(keybindingsPath) {
|
|
113713
|
-
if (!
|
|
114077
|
+
if (!existsSync27(keybindingsPath))
|
|
113714
114078
|
return null;
|
|
113715
114079
|
const backupPath = `${keybindingsPath}.letta-backup`;
|
|
113716
114080
|
try {
|
|
@@ -113726,14 +114090,14 @@ function installKeybinding2(keybindingsPath) {
|
|
|
113726
114090
|
return { success: true, alreadyExists: true };
|
|
113727
114091
|
}
|
|
113728
114092
|
const parentDir = dirname14(keybindingsPath);
|
|
113729
|
-
if (!
|
|
113730
|
-
|
|
114093
|
+
if (!existsSync27(parentDir)) {
|
|
114094
|
+
mkdirSync18(parentDir, { recursive: true });
|
|
113731
114095
|
}
|
|
113732
114096
|
let keybindings = [];
|
|
113733
114097
|
let backupPath = null;
|
|
113734
|
-
if (
|
|
114098
|
+
if (existsSync27(keybindingsPath)) {
|
|
113735
114099
|
backupPath = createBackup2(keybindingsPath);
|
|
113736
|
-
const content =
|
|
114100
|
+
const content = readFileSync12(keybindingsPath, { encoding: "utf-8" });
|
|
113737
114101
|
const parsed = parseKeybindings2(content);
|
|
113738
114102
|
if (parsed === null) {
|
|
113739
114103
|
return {
|
|
@@ -113761,10 +114125,10 @@ function installKeybinding2(keybindingsPath) {
|
|
|
113761
114125
|
}
|
|
113762
114126
|
function removeKeybinding2(keybindingsPath) {
|
|
113763
114127
|
try {
|
|
113764
|
-
if (!
|
|
114128
|
+
if (!existsSync27(keybindingsPath)) {
|
|
113765
114129
|
return { success: true };
|
|
113766
114130
|
}
|
|
113767
|
-
const content =
|
|
114131
|
+
const content = readFileSync12(keybindingsPath, { encoding: "utf-8" });
|
|
113768
114132
|
const keybindings = parseKeybindings2(content);
|
|
113769
114133
|
if (!keybindings) {
|
|
113770
114134
|
return {
|
|
@@ -113828,20 +114192,20 @@ function getWezTermConfigPath2() {
|
|
|
113828
114192
|
}
|
|
113829
114193
|
const xdgConfig = process.env.XDG_CONFIG_HOME;
|
|
113830
114194
|
if (xdgConfig) {
|
|
113831
|
-
const xdgPath =
|
|
113832
|
-
if (
|
|
114195
|
+
const xdgPath = join40(xdgConfig, "wezterm", "wezterm.lua");
|
|
114196
|
+
if (existsSync27(xdgPath))
|
|
113833
114197
|
return xdgPath;
|
|
113834
114198
|
}
|
|
113835
|
-
const configPath =
|
|
113836
|
-
if (
|
|
114199
|
+
const configPath = join40(homedir29(), ".config", "wezterm", "wezterm.lua");
|
|
114200
|
+
if (existsSync27(configPath))
|
|
113837
114201
|
return configPath;
|
|
113838
|
-
return
|
|
114202
|
+
return join40(homedir29(), ".wezterm.lua");
|
|
113839
114203
|
}
|
|
113840
114204
|
function wezTermDeleteFixExists2(configPath) {
|
|
113841
|
-
if (!
|
|
114205
|
+
if (!existsSync27(configPath))
|
|
113842
114206
|
return false;
|
|
113843
114207
|
try {
|
|
113844
|
-
const content =
|
|
114208
|
+
const content = readFileSync12(configPath, { encoding: "utf-8" });
|
|
113845
114209
|
return content.includes("Letta Code: Fix Delete key") || content.includes("key = 'Delete'") && content.includes("SendString") && content.includes("\\x1b[3~");
|
|
113846
114210
|
} catch {
|
|
113847
114211
|
return false;
|
|
@@ -113855,10 +114219,10 @@ function installWezTermDeleteFix2() {
|
|
|
113855
114219
|
}
|
|
113856
114220
|
let content = "";
|
|
113857
114221
|
let backupPath = null;
|
|
113858
|
-
if (
|
|
114222
|
+
if (existsSync27(configPath)) {
|
|
113859
114223
|
backupPath = `${configPath}.letta-backup`;
|
|
113860
114224
|
copyFileSync2(configPath, backupPath);
|
|
113861
|
-
content =
|
|
114225
|
+
content = readFileSync12(configPath, { encoding: "utf-8" });
|
|
113862
114226
|
}
|
|
113863
114227
|
if (content.includes("return {") && !content.includes("local config")) {
|
|
113864
114228
|
content = content.replace(/return\s*\{/, "local config = {");
|
|
@@ -113885,8 +114249,8 @@ ${WEZTERM_DELETE_FIX2}
|
|
|
113885
114249
|
`;
|
|
113886
114250
|
}
|
|
113887
114251
|
const parentDir = dirname14(configPath);
|
|
113888
|
-
if (!
|
|
113889
|
-
|
|
114252
|
+
if (!existsSync27(parentDir)) {
|
|
114253
|
+
mkdirSync18(parentDir, { recursive: true });
|
|
113890
114254
|
}
|
|
113891
114255
|
writeFileSync13(configPath, content, { encoding: "utf-8" });
|
|
113892
114256
|
return {
|
|
@@ -113933,10 +114297,10 @@ __export(exports_settings2, {
|
|
|
113933
114297
|
loadProjectSettings: () => loadProjectSettings2,
|
|
113934
114298
|
getSetting: () => getSetting2
|
|
113935
114299
|
});
|
|
113936
|
-
import { homedir as
|
|
113937
|
-
import { join as
|
|
114300
|
+
import { homedir as homedir30 } from "node:os";
|
|
114301
|
+
import { join as join41 } from "node:path";
|
|
113938
114302
|
function getSettingsPath2() {
|
|
113939
|
-
return
|
|
114303
|
+
return join41(homedir30(), ".letta", "settings.json");
|
|
113940
114304
|
}
|
|
113941
114305
|
async function loadSettings2() {
|
|
113942
114306
|
const settingsPath = getSettingsPath2();
|
|
@@ -113973,7 +114337,7 @@ async function getSetting2(key) {
|
|
|
113973
114337
|
return settings[key];
|
|
113974
114338
|
}
|
|
113975
114339
|
function getProjectSettingsPath2() {
|
|
113976
|
-
return
|
|
114340
|
+
return join41(process.cwd(), ".letta", "settings.local.json");
|
|
113977
114341
|
}
|
|
113978
114342
|
async function loadProjectSettings2() {
|
|
113979
114343
|
const settingsPath = getProjectSettingsPath2();
|
|
@@ -113991,7 +114355,7 @@ async function loadProjectSettings2() {
|
|
|
113991
114355
|
}
|
|
113992
114356
|
async function saveProjectSettings2(settings) {
|
|
113993
114357
|
const settingsPath = getProjectSettingsPath2();
|
|
113994
|
-
const dirPath =
|
|
114358
|
+
const dirPath = join41(process.cwd(), ".letta");
|
|
113995
114359
|
try {
|
|
113996
114360
|
if (!exists(dirPath)) {
|
|
113997
114361
|
await mkdir(dirPath, { recursive: true });
|
|
@@ -114530,7 +114894,7 @@ function parseRegistryHandle2(handle) {
|
|
|
114530
114894
|
}
|
|
114531
114895
|
async function importAgentFromRegistry2(options) {
|
|
114532
114896
|
const { tmpdir: tmpdir6 } = await import("node:os");
|
|
114533
|
-
const { join:
|
|
114897
|
+
const { join: join42 } = await import("node:path");
|
|
114534
114898
|
const { writeFile: writeFile5, unlink } = await import("node:fs/promises");
|
|
114535
114899
|
const { author, name } = parseRegistryHandle2(options.handle);
|
|
114536
114900
|
const rawUrl = `https://raw.githubusercontent.com/${AGENT_REGISTRY_OWNER2}/${AGENT_REGISTRY_REPO2}/refs/heads/${AGENT_REGISTRY_BRANCH2}/agents/@${author}/${name}/${name}.af`;
|
|
@@ -114542,7 +114906,7 @@ async function importAgentFromRegistry2(options) {
|
|
|
114542
114906
|
throw new Error(`Failed to download agent @${author}/${name}: ${response.statusText}`);
|
|
114543
114907
|
}
|
|
114544
114908
|
const afContent = await response.text();
|
|
114545
|
-
const tempPath =
|
|
114909
|
+
const tempPath = join42(tmpdir6(), `letta-import-${author}-${name}-${Date.now()}.af`);
|
|
114546
114910
|
await writeFile5(tempPath, afContent, "utf-8");
|
|
114547
114911
|
try {
|
|
114548
114912
|
const result = await importAgentFromFile2({
|
|
@@ -114582,23 +114946,23 @@ __export(exports_memoryFilesystem2, {
|
|
|
114582
114946
|
MEMORY_FS_MEMORY_DIR: () => MEMORY_FS_MEMORY_DIR2,
|
|
114583
114947
|
MEMORY_FS_AGENTS_DIR: () => MEMORY_FS_AGENTS_DIR2
|
|
114584
114948
|
});
|
|
114585
|
-
import { existsSync as
|
|
114586
|
-
import { homedir as
|
|
114587
|
-
import { join as
|
|
114588
|
-
function getMemoryFilesystemRoot2(agentId, homeDir =
|
|
114589
|
-
return
|
|
114949
|
+
import { existsSync as existsSync28, mkdirSync as mkdirSync19 } from "node:fs";
|
|
114950
|
+
import { homedir as homedir31 } from "node:os";
|
|
114951
|
+
import { join as join42 } from "node:path";
|
|
114952
|
+
function getMemoryFilesystemRoot2(agentId, homeDir = homedir31()) {
|
|
114953
|
+
return join42(homeDir, MEMORY_FS_ROOT2, MEMORY_FS_AGENTS_DIR2, agentId, MEMORY_FS_MEMORY_DIR2);
|
|
114590
114954
|
}
|
|
114591
|
-
function getMemorySystemDir2(agentId, homeDir =
|
|
114592
|
-
return
|
|
114955
|
+
function getMemorySystemDir2(agentId, homeDir = homedir31()) {
|
|
114956
|
+
return join42(getMemoryFilesystemRoot2(agentId, homeDir), MEMORY_SYSTEM_DIR2);
|
|
114593
114957
|
}
|
|
114594
|
-
function ensureMemoryFilesystemDirs2(agentId, homeDir =
|
|
114958
|
+
function ensureMemoryFilesystemDirs2(agentId, homeDir = homedir31()) {
|
|
114595
114959
|
const root = getMemoryFilesystemRoot2(agentId, homeDir);
|
|
114596
114960
|
const systemDir = getMemorySystemDir2(agentId, homeDir);
|
|
114597
|
-
if (!
|
|
114598
|
-
|
|
114961
|
+
if (!existsSync28(root)) {
|
|
114962
|
+
mkdirSync19(root, { recursive: true });
|
|
114599
114963
|
}
|
|
114600
|
-
if (!
|
|
114601
|
-
|
|
114964
|
+
if (!existsSync28(systemDir)) {
|
|
114965
|
+
mkdirSync19(systemDir, { recursive: true });
|
|
114602
114966
|
}
|
|
114603
114967
|
}
|
|
114604
114968
|
function labelFromRelativePath2(relativePath) {
|
|
@@ -114975,9 +115339,6 @@ async function getResumeData(client, agent, conversationId, options = {}) {
|
|
|
114975
115339
|
let inContextMessageIds;
|
|
114976
115340
|
let messages = [];
|
|
114977
115341
|
const useConversationsApi = conversationId && conversationId !== "default";
|
|
114978
|
-
if (process.env.DEBUG) {
|
|
114979
|
-
console.log(`[DEBUG] getResumeData: conversationId=${conversationId}, useConversationsApi=${useConversationsApi}, agentId=${agent.id}`);
|
|
114980
|
-
}
|
|
114981
115342
|
if (useConversationsApi) {
|
|
114982
115343
|
const conversation = await client.conversations.retrieve(conversationId);
|
|
114983
115344
|
inContextMessageIds = conversation.in_context_message_ids;
|
|
@@ -115053,13 +115414,14 @@ async function getResumeData(client, agent, conversationId, options = {}) {
|
|
|
115053
115414
|
const retrievedMessages = await client.messages.retrieve(lastInContextId);
|
|
115054
115415
|
if (includeMessageHistory && isBackfillEnabled()) {
|
|
115055
115416
|
try {
|
|
115056
|
-
const messagesPage = await client.conversations.messages.list(
|
|
115417
|
+
const messagesPage = await client.conversations.messages.list("default", {
|
|
115418
|
+
agent_id: agent.id,
|
|
115057
115419
|
limit: BACKFILL_PAGE_LIMIT,
|
|
115058
115420
|
order: "desc"
|
|
115059
115421
|
});
|
|
115060
115422
|
messages = sortChronological(messagesPage.getPaginatedItems());
|
|
115061
115423
|
if (process.env.DEBUG) {
|
|
115062
|
-
console.log(`[DEBUG] conversations.messages.list(
|
|
115424
|
+
console.log(`[DEBUG] conversations.messages.list(default, agent_id=${agent.id}) returned ${messages.length} messages`);
|
|
115063
115425
|
}
|
|
115064
115426
|
} catch (backfillError) {
|
|
115065
115427
|
debugWarn("check-approval", `Failed to load message history: ${backfillError instanceof Error ? backfillError.message : String(backfillError)}`);
|
|
@@ -115742,7 +116104,8 @@ function ConversationSelector({
|
|
|
115742
116104
|
let defaultConversation = null;
|
|
115743
116105
|
if (!afterCursor) {
|
|
115744
116106
|
try {
|
|
115745
|
-
const defaultMessages = await client.conversations.messages.list(
|
|
116107
|
+
const defaultMessages = await client.conversations.messages.list("default", {
|
|
116108
|
+
agent_id: agentId,
|
|
115746
116109
|
limit: 20,
|
|
115747
116110
|
order: "desc"
|
|
115748
116111
|
});
|
|
@@ -116152,8 +116515,8 @@ function parseJsonArrayFlag(rawValue, flagName) {
|
|
|
116152
116515
|
init_error();
|
|
116153
116516
|
init_errorContext();
|
|
116154
116517
|
init_zaiErrors();
|
|
116155
|
-
var LETTA_USAGE_URL = "
|
|
116156
|
-
var LETTA_AGENTS_URL = "
|
|
116518
|
+
var LETTA_USAGE_URL = buildAppUrl("/settings/organization/usage");
|
|
116519
|
+
var LETTA_AGENTS_URL = buildAppUrl("/projects/default-project/agents");
|
|
116157
116520
|
function extractReasonList(value) {
|
|
116158
116521
|
if (!Array.isArray(value))
|
|
116159
116522
|
return [];
|
|
@@ -116585,7 +116948,7 @@ ${createAgentLink(runId, agentId, conversationId)}` : baseError;
|
|
|
116585
116948
|
return String(e);
|
|
116586
116949
|
}
|
|
116587
116950
|
function createAgentLink(runId, agentId, conversationId) {
|
|
116588
|
-
const url =
|
|
116951
|
+
const url = buildChatUrl(agentId, { conversationId });
|
|
116589
116952
|
return `View agent: \x1B]8;;${url}\x1B\\${agentId}\x1B]8;;\x1B\\ (run: ${runId})`;
|
|
116590
116953
|
}
|
|
116591
116954
|
|
|
@@ -117792,7 +118155,7 @@ async function runListenSubcommand(argv) {
|
|
|
117792
118155
|
});
|
|
117793
118156
|
const debugMode = !!values.debug;
|
|
117794
118157
|
if (values.help) {
|
|
117795
|
-
console.log(`Usage: letta
|
|
118158
|
+
console.log(`Usage: letta server [--env-name <name>] [--debug]
|
|
117796
118159
|
`);
|
|
117797
118160
|
console.log(`Register this letta-code instance to receive messages from Letta Cloud.
|
|
117798
118161
|
`);
|
|
@@ -117802,9 +118165,9 @@ async function runListenSubcommand(argv) {
|
|
|
117802
118165
|
console.log(` -h, --help Show this help message
|
|
117803
118166
|
`);
|
|
117804
118167
|
console.log("Examples:");
|
|
117805
|
-
console.log(" letta
|
|
117806
|
-
console.log(' letta
|
|
117807
|
-
console.log(` letta
|
|
118168
|
+
console.log(" letta server # Uses hostname as default");
|
|
118169
|
+
console.log(' letta server --env-name "work-laptop"');
|
|
118170
|
+
console.log(` letta server --debug # Log all WS events
|
|
117808
118171
|
`);
|
|
117809
118172
|
console.log("Once connected, this instance will listen for incoming messages from cloud agents.");
|
|
117810
118173
|
console.log("Messages will be executed locally using your letta-code environment.");
|
|
@@ -118389,7 +118752,8 @@ async function runMessagesSubcommand(argv) {
|
|
|
118389
118752
|
console.error(`Invalid --order "${orderRaw}". Use "asc" or "desc".`);
|
|
118390
118753
|
return 1;
|
|
118391
118754
|
}
|
|
118392
|
-
const response = await client.conversations.messages.list(
|
|
118755
|
+
const response = await client.conversations.messages.list("default", {
|
|
118756
|
+
agent_id: agentId,
|
|
118393
118757
|
limit: parseLimit3(parsed.values.limit, 20),
|
|
118394
118758
|
after: parsed.values.after,
|
|
118395
118759
|
before: parsed.values.before,
|
|
@@ -118441,6 +118805,7 @@ async function runSubcommand(argv) {
|
|
|
118441
118805
|
return runMessagesSubcommand(rest);
|
|
118442
118806
|
case "blocks":
|
|
118443
118807
|
return runBlocksSubcommand(rest);
|
|
118808
|
+
case "server":
|
|
118444
118809
|
case "remote":
|
|
118445
118810
|
return runListenSubcommand(rest);
|
|
118446
118811
|
case "connect":
|
|
@@ -120145,6 +120510,119 @@ ${agentsSection}
|
|
|
120145
120510
|
${after}`;
|
|
120146
120511
|
}
|
|
120147
120512
|
|
|
120513
|
+
// src/utils/debug.ts
|
|
120514
|
+
import {
|
|
120515
|
+
appendFileSync as appendFileSync3,
|
|
120516
|
+
existsSync as existsSync12,
|
|
120517
|
+
mkdirSync as mkdirSync10,
|
|
120518
|
+
readdirSync as readdirSync7,
|
|
120519
|
+
readFileSync as readFileSync4,
|
|
120520
|
+
unlinkSync as unlinkSync6
|
|
120521
|
+
} from "node:fs";
|
|
120522
|
+
import { homedir as homedir18 } from "node:os";
|
|
120523
|
+
import { join as join21 } from "node:path";
|
|
120524
|
+
import { format as format2 } from "node:util";
|
|
120525
|
+
function isDebugEnabled2() {
|
|
120526
|
+
const debug = process.env.LETTA_DEBUG;
|
|
120527
|
+
return debug === "1" || debug === "true";
|
|
120528
|
+
}
|
|
120529
|
+
function getDebugFile2() {
|
|
120530
|
+
const path20 = process.env.LETTA_DEBUG_FILE;
|
|
120531
|
+
return path20 && path20.trim().length > 0 ? path20 : null;
|
|
120532
|
+
}
|
|
120533
|
+
function printDebugLine2(line) {
|
|
120534
|
+
const debugFile = getDebugFile2();
|
|
120535
|
+
if (debugFile) {
|
|
120536
|
+
try {
|
|
120537
|
+
appendFileSync3(debugFile, line, { encoding: "utf8" });
|
|
120538
|
+
return;
|
|
120539
|
+
} catch {}
|
|
120540
|
+
}
|
|
120541
|
+
console.log(line.trimEnd());
|
|
120542
|
+
}
|
|
120543
|
+
var DEBUG_LOG_DIR2 = join21(homedir18(), ".letta", "logs", "debug");
|
|
120544
|
+
var MAX_SESSION_FILES3 = 5;
|
|
120545
|
+
var DEFAULT_TAIL_LINES2 = 50;
|
|
120546
|
+
|
|
120547
|
+
class DebugLogFile2 {
|
|
120548
|
+
logPath = null;
|
|
120549
|
+
agentDir = null;
|
|
120550
|
+
dirCreated = false;
|
|
120551
|
+
init(agentId, sessionId) {
|
|
120552
|
+
const telem = process.env.LETTA_CODE_TELEM;
|
|
120553
|
+
if (telem === "0" || telem === "false")
|
|
120554
|
+
return;
|
|
120555
|
+
this.agentDir = join21(DEBUG_LOG_DIR2, agentId);
|
|
120556
|
+
this.logPath = join21(this.agentDir, `${sessionId}.log`);
|
|
120557
|
+
this.dirCreated = false;
|
|
120558
|
+
this.pruneOldSessions();
|
|
120559
|
+
}
|
|
120560
|
+
appendLine(line) {
|
|
120561
|
+
if (!this.logPath)
|
|
120562
|
+
return;
|
|
120563
|
+
this.ensureDir();
|
|
120564
|
+
try {
|
|
120565
|
+
appendFileSync3(this.logPath, line, { encoding: "utf8" });
|
|
120566
|
+
} catch {}
|
|
120567
|
+
}
|
|
120568
|
+
getTail(maxLines = DEFAULT_TAIL_LINES2) {
|
|
120569
|
+
if (!this.logPath)
|
|
120570
|
+
return;
|
|
120571
|
+
try {
|
|
120572
|
+
if (!existsSync12(this.logPath))
|
|
120573
|
+
return;
|
|
120574
|
+
const content = readFileSync4(this.logPath, "utf8");
|
|
120575
|
+
const lines = content.trimEnd().split(`
|
|
120576
|
+
`);
|
|
120577
|
+
return lines.slice(-maxLines).join(`
|
|
120578
|
+
`);
|
|
120579
|
+
} catch {
|
|
120580
|
+
return;
|
|
120581
|
+
}
|
|
120582
|
+
}
|
|
120583
|
+
ensureDir() {
|
|
120584
|
+
if (this.dirCreated || !this.agentDir)
|
|
120585
|
+
return;
|
|
120586
|
+
try {
|
|
120587
|
+
if (!existsSync12(this.agentDir)) {
|
|
120588
|
+
mkdirSync10(this.agentDir, { recursive: true });
|
|
120589
|
+
}
|
|
120590
|
+
this.dirCreated = true;
|
|
120591
|
+
} catch {}
|
|
120592
|
+
}
|
|
120593
|
+
pruneOldSessions() {
|
|
120594
|
+
if (!this.agentDir)
|
|
120595
|
+
return;
|
|
120596
|
+
try {
|
|
120597
|
+
if (!existsSync12(this.agentDir))
|
|
120598
|
+
return;
|
|
120599
|
+
const files = readdirSync7(this.agentDir).filter((f) => f.endsWith(".log")).sort();
|
|
120600
|
+
if (files.length >= MAX_SESSION_FILES3) {
|
|
120601
|
+
const toDelete = files.slice(0, files.length - MAX_SESSION_FILES3 + 1);
|
|
120602
|
+
for (const file of toDelete) {
|
|
120603
|
+
try {
|
|
120604
|
+
unlinkSync6(join21(this.agentDir, file));
|
|
120605
|
+
} catch {}
|
|
120606
|
+
}
|
|
120607
|
+
}
|
|
120608
|
+
} catch {}
|
|
120609
|
+
}
|
|
120610
|
+
}
|
|
120611
|
+
var debugLogFile2 = new DebugLogFile2;
|
|
120612
|
+
function writeDebugLine2(prefix, message, args) {
|
|
120613
|
+
const ts = new Date().toISOString();
|
|
120614
|
+
const body = format2(`[${prefix}] ${message}`, ...args);
|
|
120615
|
+
const line = `${ts} ${body}
|
|
120616
|
+
`;
|
|
120617
|
+
debugLogFile2.appendLine(line);
|
|
120618
|
+
if (isDebugEnabled2()) {
|
|
120619
|
+
printDebugLine2(line);
|
|
120620
|
+
}
|
|
120621
|
+
}
|
|
120622
|
+
function debugLog2(prefix, message, ...args) {
|
|
120623
|
+
writeDebugLine2(prefix, message, args);
|
|
120624
|
+
}
|
|
120625
|
+
|
|
120148
120626
|
// src/utils/timing.ts
|
|
120149
120627
|
function isTimingsEnabled2() {
|
|
120150
120628
|
const val = process.env.LETTA_DEBUG_TIMINGS;
|
|
@@ -120251,12 +120729,12 @@ EXAMPLES
|
|
|
120251
120729
|
console.log(usage);
|
|
120252
120730
|
}
|
|
120253
120731
|
async function printInfo() {
|
|
120254
|
-
const { join:
|
|
120732
|
+
const { join: join43 } = await import("path");
|
|
120255
120733
|
const { getVersion: getVersion3 } = await Promise.resolve().then(() => (init_version2(), exports_version));
|
|
120256
120734
|
const { SKILLS_DIR: SKILLS_DIR3 } = await Promise.resolve().then(() => (init_skills2(), exports_skills2));
|
|
120257
120735
|
const { exists: exists3 } = await Promise.resolve().then(() => (init_fs2(), exports_fs));
|
|
120258
120736
|
const cwd2 = process.cwd();
|
|
120259
|
-
const skillsDir =
|
|
120737
|
+
const skillsDir = join43(cwd2, SKILLS_DIR3);
|
|
120260
120738
|
const skillsExist = exists3(skillsDir);
|
|
120261
120739
|
await settingsManager2.loadLocalProjectSettings(cwd2);
|
|
120262
120740
|
const localPinned = settingsManager2.getLocalPinnedAgents(cwd2);
|
|
@@ -120650,9 +121128,9 @@ Note: Flags should use double dashes for full names (e.g., --yolo, not -yolo)`);
|
|
|
120650
121128
|
}
|
|
120651
121129
|
} else {
|
|
120652
121130
|
const { resolve: resolve30 } = await import("path");
|
|
120653
|
-
const { existsSync:
|
|
121131
|
+
const { existsSync: existsSync29 } = await import("fs");
|
|
120654
121132
|
const resolvedPath = resolve30(fromAfFile);
|
|
120655
|
-
if (!
|
|
121133
|
+
if (!existsSync29(resolvedPath)) {
|
|
120656
121134
|
console.error(`Error: AgentFile not found: ${resolvedPath}`);
|
|
120657
121135
|
process.exit(1);
|
|
120658
121136
|
}
|
|
@@ -120930,6 +121408,7 @@ Error: ${message}`);
|
|
|
120930
121408
|
return;
|
|
120931
121409
|
}
|
|
120932
121410
|
try {
|
|
121411
|
+
debugLog2("conversations", `retrieve(${specifiedConversationId}) [TUI conv\u2192agent lookup]`);
|
|
120933
121412
|
const conversation = await client.conversations.retrieve(specifiedConversationId);
|
|
120934
121413
|
setSelectedGlobalAgentId(conversation.agent_id);
|
|
120935
121414
|
setSelectedConversationId(specifiedConversationId);
|
|
@@ -121531,4 +122010,4 @@ Error during initialization: ${message}`);
|
|
|
121531
122010
|
}
|
|
121532
122011
|
main();
|
|
121533
122012
|
|
|
121534
|
-
//# debugId=
|
|
122013
|
+
//# debugId=B02B981CD008C36564756E2164756E21
|