@letta-ai/letta-code 0.16.7 → 0.16.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/letta.js +310 -229
- package/package.json +1 -1
package/letta.js
CHANGED
|
@@ -3122,7 +3122,7 @@ var package_default;
|
|
|
3122
3122
|
var init_package = __esm(() => {
|
|
3123
3123
|
package_default = {
|
|
3124
3124
|
name: "@letta-ai/letta-code",
|
|
3125
|
-
version: "0.16.
|
|
3125
|
+
version: "0.16.9",
|
|
3126
3126
|
description: "Letta Code is a CLI tool for interacting with stateful Letta agents from the terminal.",
|
|
3127
3127
|
type: "module",
|
|
3128
3128
|
bin: {
|
|
@@ -3521,7 +3521,7 @@ __export(exports_settings_manager, {
|
|
|
3521
3521
|
});
|
|
3522
3522
|
import { randomUUID } from "node:crypto";
|
|
3523
3523
|
import { homedir } from "node:os";
|
|
3524
|
-
import { join } from "node:path";
|
|
3524
|
+
import { join, resolve } from "node:path";
|
|
3525
3525
|
function isSubagentProcess() {
|
|
3526
3526
|
return process.env.LETTA_CODE_AGENT_ROLE === "subagent";
|
|
3527
3527
|
}
|
|
@@ -3781,6 +3781,11 @@ class SettingsManager {
|
|
|
3781
3781
|
}
|
|
3782
3782
|
}
|
|
3783
3783
|
async loadProjectSettings(workingDirectory = process.cwd()) {
|
|
3784
|
+
if (this.isProjectSettingsPathCollidingWithGlobal(workingDirectory)) {
|
|
3785
|
+
const defaults2 = { ...DEFAULT_PROJECT_SETTINGS };
|
|
3786
|
+
this.projectSettings.set(workingDirectory, defaults2);
|
|
3787
|
+
return defaults2;
|
|
3788
|
+
}
|
|
3784
3789
|
const cached = this.projectSettings.get(workingDirectory);
|
|
3785
3790
|
if (cached) {
|
|
3786
3791
|
return { ...cached };
|
|
@@ -3816,6 +3821,19 @@ class SettingsManager {
|
|
|
3816
3821
|
return { ...cached };
|
|
3817
3822
|
}
|
|
3818
3823
|
updateProjectSettings(updates, workingDirectory = process.cwd()) {
|
|
3824
|
+
if (this.isProjectSettingsPathCollidingWithGlobal(workingDirectory)) {
|
|
3825
|
+
const globalUpdates = {};
|
|
3826
|
+
if ("hooks" in updates) {
|
|
3827
|
+
globalUpdates.hooks = updates.hooks;
|
|
3828
|
+
}
|
|
3829
|
+
if ("statusLine" in updates) {
|
|
3830
|
+
globalUpdates.statusLine = updates.statusLine;
|
|
3831
|
+
}
|
|
3832
|
+
if (Object.keys(globalUpdates).length > 0) {
|
|
3833
|
+
this.updateSettings(globalUpdates);
|
|
3834
|
+
}
|
|
3835
|
+
return;
|
|
3836
|
+
}
|
|
3819
3837
|
const current = this.projectSettings.get(workingDirectory);
|
|
3820
3838
|
if (!current) {
|
|
3821
3839
|
throw new Error(`Project settings for ${workingDirectory} not loaded. Call loadProjectSettings() first.`);
|
|
@@ -3862,6 +3880,9 @@ class SettingsManager {
|
|
|
3862
3880
|
}
|
|
3863
3881
|
}
|
|
3864
3882
|
async persistProjectSettings(workingDirectory) {
|
|
3883
|
+
if (this.isProjectSettingsPathCollidingWithGlobal(workingDirectory)) {
|
|
3884
|
+
return;
|
|
3885
|
+
}
|
|
3865
3886
|
const settings = this.projectSettings.get(workingDirectory);
|
|
3866
3887
|
if (!settings)
|
|
3867
3888
|
return;
|
|
@@ -3893,6 +3914,9 @@ class SettingsManager {
|
|
|
3893
3914
|
getProjectSettingsPath(workingDirectory) {
|
|
3894
3915
|
return join(workingDirectory, ".letta", "settings.json");
|
|
3895
3916
|
}
|
|
3917
|
+
isProjectSettingsPathCollidingWithGlobal(workingDirectory) {
|
|
3918
|
+
return resolve(this.getProjectSettingsPath(workingDirectory)) === resolve(this.getSettingsPath());
|
|
3919
|
+
}
|
|
3896
3920
|
getLocalProjectSettingsPath(workingDirectory) {
|
|
3897
3921
|
return join(workingDirectory, ".letta", "settings.local.json");
|
|
3898
3922
|
}
|
|
@@ -7138,7 +7162,6 @@ var init_models2 = __esm(() => {
|
|
|
7138
7162
|
label: "Bedrock Opus 4.5",
|
|
7139
7163
|
shortLabel: "Opus 4.5 BR",
|
|
7140
7164
|
description: "Anthropic's best model (via AWS Bedrock)",
|
|
7141
|
-
isFeatured: true,
|
|
7142
7165
|
updateArgs: {
|
|
7143
7166
|
context_window: 180000,
|
|
7144
7167
|
max_output_tokens: 64000,
|
|
@@ -7151,7 +7174,6 @@ var init_models2 = __esm(() => {
|
|
|
7151
7174
|
handle: "anthropic/claude-haiku-4-5-20251001",
|
|
7152
7175
|
label: "Haiku 4.5",
|
|
7153
7176
|
description: "Anthropic's fastest model",
|
|
7154
|
-
isFeatured: true,
|
|
7155
7177
|
updateArgs: {
|
|
7156
7178
|
context_window: 180000,
|
|
7157
7179
|
max_output_tokens: 64000,
|
|
@@ -7451,7 +7473,6 @@ var init_models2 = __esm(() => {
|
|
|
7451
7473
|
handle: "openai/gpt-5.2-codex",
|
|
7452
7474
|
label: "GPT-5.2-Codex",
|
|
7453
7475
|
description: "GPT-5.2 variant (med reasoning) optimized for coding",
|
|
7454
|
-
isFeatured: true,
|
|
7455
7476
|
updateArgs: {
|
|
7456
7477
|
reasoning_effort: "medium",
|
|
7457
7478
|
verbosity: "medium",
|
|
@@ -7556,7 +7577,6 @@ var init_models2 = __esm(() => {
|
|
|
7556
7577
|
handle: "openai/gpt-5.1-codex",
|
|
7557
7578
|
label: "GPT-5.1-Codex",
|
|
7558
7579
|
description: "GPT-5.1 variant (med reasoning) optimized for coding",
|
|
7559
|
-
isFeatured: true,
|
|
7560
7580
|
updateArgs: {
|
|
7561
7581
|
reasoning_effort: "medium",
|
|
7562
7582
|
verbosity: "medium",
|
|
@@ -7712,7 +7732,6 @@ var init_models2 = __esm(() => {
|
|
|
7712
7732
|
handle: "zai/glm-4.7",
|
|
7713
7733
|
label: "GLM-4.7",
|
|
7714
7734
|
description: "zAI's latest coding model (legacy)",
|
|
7715
|
-
isFeatured: true,
|
|
7716
7735
|
free: true,
|
|
7717
7736
|
updateArgs: {
|
|
7718
7737
|
context_window: 200000,
|
|
@@ -7737,7 +7756,6 @@ var init_models2 = __esm(() => {
|
|
|
7737
7756
|
handle: "minimax/MiniMax-M2.1",
|
|
7738
7757
|
label: "MiniMax 2.1",
|
|
7739
7758
|
description: "MiniMax's latest coding model (legacy)",
|
|
7740
|
-
isFeatured: true,
|
|
7741
7759
|
free: true,
|
|
7742
7760
|
updateArgs: {
|
|
7743
7761
|
context_window: 160000,
|
|
@@ -7816,7 +7834,6 @@ var init_models2 = __esm(() => {
|
|
|
7816
7834
|
handle: "google_ai/gemini-3-pro-preview",
|
|
7817
7835
|
label: "Gemini 3 Pro",
|
|
7818
7836
|
description: "Google's smartest model",
|
|
7819
|
-
isFeatured: true,
|
|
7820
7837
|
updateArgs: {
|
|
7821
7838
|
context_window: 180000,
|
|
7822
7839
|
temperature: 1,
|
|
@@ -7828,7 +7845,6 @@ var init_models2 = __esm(() => {
|
|
|
7828
7845
|
handle: "google_ai/gemini-3-flash-preview",
|
|
7829
7846
|
label: "Gemini 3 Flash",
|
|
7830
7847
|
description: "Google's fastest Gemini 3 model",
|
|
7831
|
-
isFeatured: true,
|
|
7832
7848
|
updateArgs: {
|
|
7833
7849
|
context_window: 180000,
|
|
7834
7850
|
temperature: 1,
|
|
@@ -8808,7 +8824,7 @@ async function pollForToken2(deviceCode, interval = 5, expiresIn = 900, deviceId
|
|
|
8808
8824
|
const expiresInMs = expiresIn * 1000;
|
|
8809
8825
|
let pollInterval = interval * 1000;
|
|
8810
8826
|
while (Date.now() - startTime < expiresInMs) {
|
|
8811
|
-
await new Promise((
|
|
8827
|
+
await new Promise((resolve2) => setTimeout(resolve2, pollInterval));
|
|
8812
8828
|
try {
|
|
8813
8829
|
const response = await fetch(`${OAUTH_CONFIG2.authBaseUrl}/api/oauth/token`, {
|
|
8814
8830
|
method: "POST",
|
|
@@ -10551,14 +10567,14 @@ Check the top-level render call using <` + parentName + ">.";
|
|
|
10551
10567
|
var thenableResult = result;
|
|
10552
10568
|
var wasAwaited = false;
|
|
10553
10569
|
var thenable = {
|
|
10554
|
-
then: function(
|
|
10570
|
+
then: function(resolve2, reject) {
|
|
10555
10571
|
wasAwaited = true;
|
|
10556
10572
|
thenableResult.then(function(returnValue2) {
|
|
10557
10573
|
popActScope(prevActScopeDepth);
|
|
10558
10574
|
if (actScopeDepth === 0) {
|
|
10559
|
-
recursivelyFlushAsyncActWork(returnValue2,
|
|
10575
|
+
recursivelyFlushAsyncActWork(returnValue2, resolve2, reject);
|
|
10560
10576
|
} else {
|
|
10561
|
-
|
|
10577
|
+
resolve2(returnValue2);
|
|
10562
10578
|
}
|
|
10563
10579
|
}, function(error2) {
|
|
10564
10580
|
popActScope(prevActScopeDepth);
|
|
@@ -10587,20 +10603,20 @@ Check the top-level render call using <` + parentName + ">.";
|
|
|
10587
10603
|
ReactCurrentActQueue.current = null;
|
|
10588
10604
|
}
|
|
10589
10605
|
var _thenable = {
|
|
10590
|
-
then: function(
|
|
10606
|
+
then: function(resolve2, reject) {
|
|
10591
10607
|
if (ReactCurrentActQueue.current === null) {
|
|
10592
10608
|
ReactCurrentActQueue.current = [];
|
|
10593
|
-
recursivelyFlushAsyncActWork(returnValue,
|
|
10609
|
+
recursivelyFlushAsyncActWork(returnValue, resolve2, reject);
|
|
10594
10610
|
} else {
|
|
10595
|
-
|
|
10611
|
+
resolve2(returnValue);
|
|
10596
10612
|
}
|
|
10597
10613
|
}
|
|
10598
10614
|
};
|
|
10599
10615
|
return _thenable;
|
|
10600
10616
|
} else {
|
|
10601
10617
|
var _thenable2 = {
|
|
10602
|
-
then: function(
|
|
10603
|
-
|
|
10618
|
+
then: function(resolve2, reject) {
|
|
10619
|
+
resolve2(returnValue);
|
|
10604
10620
|
}
|
|
10605
10621
|
};
|
|
10606
10622
|
return _thenable2;
|
|
@@ -10616,7 +10632,7 @@ Check the top-level render call using <` + parentName + ">.";
|
|
|
10616
10632
|
actScopeDepth = prevActScopeDepth;
|
|
10617
10633
|
}
|
|
10618
10634
|
}
|
|
10619
|
-
function recursivelyFlushAsyncActWork(returnValue,
|
|
10635
|
+
function recursivelyFlushAsyncActWork(returnValue, resolve2, reject) {
|
|
10620
10636
|
{
|
|
10621
10637
|
var queue = ReactCurrentActQueue.current;
|
|
10622
10638
|
if (queue !== null) {
|
|
@@ -10625,16 +10641,16 @@ Check the top-level render call using <` + parentName + ">.";
|
|
|
10625
10641
|
enqueueTask(function() {
|
|
10626
10642
|
if (queue.length === 0) {
|
|
10627
10643
|
ReactCurrentActQueue.current = null;
|
|
10628
|
-
|
|
10644
|
+
resolve2(returnValue);
|
|
10629
10645
|
} else {
|
|
10630
|
-
recursivelyFlushAsyncActWork(returnValue,
|
|
10646
|
+
recursivelyFlushAsyncActWork(returnValue, resolve2, reject);
|
|
10631
10647
|
}
|
|
10632
10648
|
});
|
|
10633
10649
|
} catch (error2) {
|
|
10634
10650
|
reject(error2);
|
|
10635
10651
|
}
|
|
10636
10652
|
} else {
|
|
10637
|
-
|
|
10653
|
+
resolve2(returnValue);
|
|
10638
10654
|
}
|
|
10639
10655
|
}
|
|
10640
10656
|
}
|
|
@@ -31886,8 +31902,8 @@ class Ink {
|
|
|
31886
31902
|
}
|
|
31887
31903
|
}
|
|
31888
31904
|
async waitUntilExit() {
|
|
31889
|
-
this.exitPromise ||= new Promise((
|
|
31890
|
-
this.resolveExitPromise =
|
|
31905
|
+
this.exitPromise ||= new Promise((resolve2, reject) => {
|
|
31906
|
+
this.resolveExitPromise = resolve2;
|
|
31891
31907
|
this.rejectExitPromise = reject;
|
|
31892
31908
|
});
|
|
31893
31909
|
return this.exitPromise;
|
|
@@ -39691,7 +39707,7 @@ async function executeCommandHook(hook, input, workingDirectory = process.cwd())
|
|
|
39691
39707
|
};
|
|
39692
39708
|
}
|
|
39693
39709
|
function executeWithLauncher(launcher, inputJson, workingDirectory, input, timeout, command, startTime) {
|
|
39694
|
-
return new Promise((
|
|
39710
|
+
return new Promise((resolve2, reject) => {
|
|
39695
39711
|
let stdout = "";
|
|
39696
39712
|
let stderr = "";
|
|
39697
39713
|
let timedOut = false;
|
|
@@ -39718,7 +39734,7 @@ function executeWithLauncher(launcher, inputJson, workingDirectory, input, timeo
|
|
|
39718
39734
|
`);
|
|
39719
39735
|
console.log(`\x1B[90m${indented}\x1B[0m`);
|
|
39720
39736
|
}
|
|
39721
|
-
|
|
39737
|
+
resolve2(result);
|
|
39722
39738
|
}
|
|
39723
39739
|
};
|
|
39724
39740
|
let child;
|
|
@@ -39879,6 +39895,14 @@ var init_executor = __esm(async () => {
|
|
|
39879
39895
|
});
|
|
39880
39896
|
|
|
39881
39897
|
// src/hooks/loader.ts
|
|
39898
|
+
import { homedir as homedir3 } from "node:os";
|
|
39899
|
+
import { resolve as resolve2 } from "node:path";
|
|
39900
|
+
function isProjectSettingsPathCollidingWithGlobal(workingDirectory) {
|
|
39901
|
+
const home = process.env.HOME || homedir3();
|
|
39902
|
+
const globalSettingsPath = resolve2(home, ".letta", "settings.json");
|
|
39903
|
+
const projectSettingsPath = resolve2(workingDirectory, ".letta", "settings.json");
|
|
39904
|
+
return globalSettingsPath === projectSettingsPath;
|
|
39905
|
+
}
|
|
39882
39906
|
function loadGlobalHooks() {
|
|
39883
39907
|
try {
|
|
39884
39908
|
return settingsManager.getSettings().hooks || {};
|
|
@@ -39888,6 +39912,9 @@ function loadGlobalHooks() {
|
|
|
39888
39912
|
}
|
|
39889
39913
|
}
|
|
39890
39914
|
async function loadProjectHooks(workingDirectory = process.cwd()) {
|
|
39915
|
+
if (isProjectSettingsPathCollidingWithGlobal(workingDirectory)) {
|
|
39916
|
+
return {};
|
|
39917
|
+
}
|
|
39891
39918
|
try {
|
|
39892
39919
|
try {
|
|
39893
39920
|
settingsManager.getProjectSettings(workingDirectory);
|
|
@@ -40018,20 +40045,20 @@ function areHooksDisabled(workingDirectory = process.cwd()) {
|
|
|
40018
40045
|
if (projectDisabled === true) {
|
|
40019
40046
|
return true;
|
|
40020
40047
|
}
|
|
40021
|
-
} catch
|
|
40022
|
-
debugLog("hooks", "areHooksDisabled: Project settings not loaded, skipping"
|
|
40048
|
+
} catch {
|
|
40049
|
+
debugLog("hooks", "areHooksDisabled: Project settings not loaded, skipping");
|
|
40023
40050
|
}
|
|
40024
40051
|
try {
|
|
40025
40052
|
const localDisabled = settingsManager.getLocalProjectSettings(workingDirectory)?.hooks?.disabled;
|
|
40026
40053
|
if (localDisabled === true) {
|
|
40027
40054
|
return true;
|
|
40028
40055
|
}
|
|
40029
|
-
} catch
|
|
40030
|
-
debugLog("hooks", "areHooksDisabled: Local project settings not loaded, skipping"
|
|
40056
|
+
} catch {
|
|
40057
|
+
debugLog("hooks", "areHooksDisabled: Local project settings not loaded, skipping");
|
|
40031
40058
|
}
|
|
40032
40059
|
return false;
|
|
40033
|
-
} catch
|
|
40034
|
-
debugLog("hooks", "areHooksDisabled: Failed to check hooks disabled status"
|
|
40060
|
+
} catch {
|
|
40061
|
+
debugLog("hooks", "areHooksDisabled: Failed to check hooks disabled status");
|
|
40035
40062
|
return false;
|
|
40036
40063
|
}
|
|
40037
40064
|
}
|
|
@@ -41967,11 +41994,11 @@ import {
|
|
|
41967
41994
|
rmSync,
|
|
41968
41995
|
writeFileSync
|
|
41969
41996
|
} from "node:fs";
|
|
41970
|
-
import { homedir as
|
|
41997
|
+
import { homedir as homedir4 } from "node:os";
|
|
41971
41998
|
import { join as join3 } from "node:path";
|
|
41972
41999
|
import { promisify } from "node:util";
|
|
41973
42000
|
function getAgentRootDir(agentId) {
|
|
41974
|
-
return join3(
|
|
42001
|
+
return join3(homedir4(), ".letta", "agents", agentId);
|
|
41975
42002
|
}
|
|
41976
42003
|
function getMemoryRepoDir(agentId) {
|
|
41977
42004
|
return join3(getAgentRootDir(agentId), "memory");
|
|
@@ -42724,15 +42751,15 @@ __export(exports_memoryFilesystem, {
|
|
|
42724
42751
|
MEMORY_FS_AGENTS_DIR: () => MEMORY_FS_AGENTS_DIR
|
|
42725
42752
|
});
|
|
42726
42753
|
import { existsSync as existsSync5, mkdirSync as mkdirSync3 } from "node:fs";
|
|
42727
|
-
import { homedir as
|
|
42754
|
+
import { homedir as homedir5 } from "node:os";
|
|
42728
42755
|
import { join as join4 } from "node:path";
|
|
42729
|
-
function getMemoryFilesystemRoot(agentId, homeDir =
|
|
42756
|
+
function getMemoryFilesystemRoot(agentId, homeDir = homedir5()) {
|
|
42730
42757
|
return join4(homeDir, MEMORY_FS_ROOT, MEMORY_FS_AGENTS_DIR, agentId, MEMORY_FS_MEMORY_DIR);
|
|
42731
42758
|
}
|
|
42732
|
-
function getMemorySystemDir(agentId, homeDir =
|
|
42759
|
+
function getMemorySystemDir(agentId, homeDir = homedir5()) {
|
|
42733
42760
|
return join4(getMemoryFilesystemRoot(agentId, homeDir), MEMORY_SYSTEM_DIR);
|
|
42734
42761
|
}
|
|
42735
|
-
function ensureMemoryFilesystemDirs(agentId, homeDir =
|
|
42762
|
+
function ensureMemoryFilesystemDirs(agentId, homeDir = homedir5()) {
|
|
42736
42763
|
const root = getMemoryFilesystemRoot(agentId, homeDir);
|
|
42737
42764
|
const systemDir = getMemorySystemDir(agentId, homeDir);
|
|
42738
42765
|
if (!existsSync5(root)) {
|
|
@@ -43060,7 +43087,7 @@ var init_shellEnv = __esm(async () => {
|
|
|
43060
43087
|
// src/tools/impl/shellRunner.ts
|
|
43061
43088
|
import { spawn as spawn2 } from "node:child_process";
|
|
43062
43089
|
function spawnWithLauncher(launcher, options) {
|
|
43063
|
-
return new Promise((
|
|
43090
|
+
return new Promise((resolve4, reject) => {
|
|
43064
43091
|
const [executable, ...args] = launcher;
|
|
43065
43092
|
if (!executable) {
|
|
43066
43093
|
reject(new ShellExecutionError("Executable is required"));
|
|
@@ -43163,7 +43190,7 @@ function spawnWithLauncher(launcher, options) {
|
|
|
43163
43190
|
}));
|
|
43164
43191
|
return;
|
|
43165
43192
|
}
|
|
43166
|
-
|
|
43193
|
+
resolve4({ stdout, stderr, exitCode: code });
|
|
43167
43194
|
});
|
|
43168
43195
|
});
|
|
43169
43196
|
}
|
|
@@ -43575,7 +43602,7 @@ var init_Bash2 = __esm(async () => {
|
|
|
43575
43602
|
|
|
43576
43603
|
// src/tools/impl/BashOutput.ts
|
|
43577
43604
|
function sleep2(ms) {
|
|
43578
|
-
return new Promise((
|
|
43605
|
+
return new Promise((resolve4) => setTimeout(resolve4, ms));
|
|
43579
43606
|
}
|
|
43580
43607
|
function emitNewProcessOutput(proc, onOutput, indexes, filter) {
|
|
43581
43608
|
const next = { ...indexes };
|
|
@@ -43914,7 +43941,7 @@ async function edit(args) {
|
|
|
43914
43941
|
var init_Edit2 = () => {};
|
|
43915
43942
|
|
|
43916
43943
|
// src/cli/helpers/planName.ts
|
|
43917
|
-
import { homedir as
|
|
43944
|
+
import { homedir as homedir7 } from "node:os";
|
|
43918
43945
|
import { join as join7 } from "node:path";
|
|
43919
43946
|
function randomElement(arr) {
|
|
43920
43947
|
return arr[Math.floor(Math.random() * arr.length)];
|
|
@@ -43927,7 +43954,7 @@ function generatePlanName() {
|
|
|
43927
43954
|
}
|
|
43928
43955
|
function generatePlanFilePath() {
|
|
43929
43956
|
const name = generatePlanName();
|
|
43930
|
-
return join7(
|
|
43957
|
+
return join7(homedir7(), ".letta", "plans", `${name}.md`);
|
|
43931
43958
|
}
|
|
43932
43959
|
var adjectives, nouns;
|
|
43933
43960
|
var init_planName = __esm(() => {
|
|
@@ -44032,8 +44059,8 @@ var init_planName = __esm(() => {
|
|
|
44032
44059
|
});
|
|
44033
44060
|
|
|
44034
44061
|
// src/permissions/readOnlyShell.ts
|
|
44035
|
-
import { homedir as
|
|
44036
|
-
import { resolve as
|
|
44062
|
+
import { homedir as homedir8 } from "node:os";
|
|
44063
|
+
import { resolve as resolve5 } from "node:path";
|
|
44037
44064
|
function isReadOnlyShellCommand(command) {
|
|
44038
44065
|
if (!command) {
|
|
44039
44066
|
return false;
|
|
@@ -44197,14 +44224,14 @@ function hasAbsoluteOrTraversalPathArg(value) {
|
|
|
44197
44224
|
return /(^|[\\/])\.\.([\\/]|$)/.test(value);
|
|
44198
44225
|
}
|
|
44199
44226
|
function getAllowedMemoryPrefixes(agentId) {
|
|
44200
|
-
const home =
|
|
44227
|
+
const home = homedir8();
|
|
44201
44228
|
const prefixes = [
|
|
44202
|
-
normalizeSeparators(
|
|
44203
|
-
normalizeSeparators(
|
|
44229
|
+
normalizeSeparators(resolve5(home, ".letta", "agents", agentId, "memory")),
|
|
44230
|
+
normalizeSeparators(resolve5(home, ".letta", "agents", agentId, "memory-worktrees"))
|
|
44204
44231
|
];
|
|
44205
44232
|
const parentId = process.env.LETTA_PARENT_AGENT_ID;
|
|
44206
44233
|
if (parentId && parentId !== agentId) {
|
|
44207
|
-
prefixes.push(normalizeSeparators(
|
|
44234
|
+
prefixes.push(normalizeSeparators(resolve5(home, ".letta", "agents", parentId, "memory")), normalizeSeparators(resolve5(home, ".letta", "agents", parentId, "memory-worktrees")));
|
|
44208
44235
|
}
|
|
44209
44236
|
return prefixes;
|
|
44210
44237
|
}
|
|
@@ -44212,17 +44239,17 @@ function normalizeSeparators(p) {
|
|
|
44212
44239
|
return p.replace(/\\/g, "/");
|
|
44213
44240
|
}
|
|
44214
44241
|
function expandPath(p) {
|
|
44215
|
-
const home =
|
|
44242
|
+
const home = homedir8();
|
|
44216
44243
|
if (p.startsWith("~/")) {
|
|
44217
|
-
return normalizeSeparators(
|
|
44244
|
+
return normalizeSeparators(resolve5(home, p.slice(2)));
|
|
44218
44245
|
}
|
|
44219
44246
|
if (p.startsWith("$HOME/")) {
|
|
44220
|
-
return normalizeSeparators(
|
|
44247
|
+
return normalizeSeparators(resolve5(home, p.slice(6)));
|
|
44221
44248
|
}
|
|
44222
44249
|
if (p.startsWith('"$HOME/')) {
|
|
44223
|
-
return normalizeSeparators(
|
|
44250
|
+
return normalizeSeparators(resolve5(home, p.slice(7).replace(/"$/, "")));
|
|
44224
44251
|
}
|
|
44225
|
-
return normalizeSeparators(
|
|
44252
|
+
return normalizeSeparators(resolve5(p));
|
|
44226
44253
|
}
|
|
44227
44254
|
function isUnderMemoryDir(path6, prefixes) {
|
|
44228
44255
|
const resolved = expandPath(path6);
|
|
@@ -44255,7 +44282,7 @@ function isMemoryDirCommand(command, agentId) {
|
|
|
44255
44282
|
for (const part of pipeParts) {
|
|
44256
44283
|
const cdTarget = extractCdTarget(part);
|
|
44257
44284
|
if (cdTarget) {
|
|
44258
|
-
const resolved = cwd2 ? expandPath(
|
|
44285
|
+
const resolved = cwd2 ? expandPath(resolve5(expandPath(cwd2), cdTarget)) : expandPath(cdTarget);
|
|
44259
44286
|
if (!isUnderMemoryDir(resolved, prefixes)) {
|
|
44260
44287
|
return false;
|
|
44261
44288
|
}
|
|
@@ -44273,7 +44300,7 @@ function isMemoryDirCommand(command, agentId) {
|
|
|
44273
44300
|
return !isUnderMemoryDir(t, prefixes);
|
|
44274
44301
|
}
|
|
44275
44302
|
if (hasAbsoluteOrTraversalPathArg(t)) {
|
|
44276
|
-
const resolved = expandPath(
|
|
44303
|
+
const resolved = expandPath(resolve5(expandPath(currentCwd), t));
|
|
44277
44304
|
return !isUnderMemoryDir(resolved, prefixes);
|
|
44278
44305
|
}
|
|
44279
44306
|
return false;
|
|
@@ -44413,8 +44440,8 @@ var exports_mode = {};
|
|
|
44413
44440
|
__export(exports_mode, {
|
|
44414
44441
|
permissionMode: () => permissionMode
|
|
44415
44442
|
});
|
|
44416
|
-
import { homedir as
|
|
44417
|
-
import { isAbsolute as isAbsolute3, join as join8, relative, resolve as
|
|
44443
|
+
import { homedir as homedir9 } from "node:os";
|
|
44444
|
+
import { isAbsolute as isAbsolute3, join as join8, relative, resolve as resolve6 } from "node:path";
|
|
44418
44445
|
function getGlobalMode() {
|
|
44419
44446
|
const global2 = globalThis;
|
|
44420
44447
|
if (!global2[MODE_KEY]) {
|
|
@@ -44447,12 +44474,12 @@ function resolvePlanTargetPath(targetPath, workingDirectory) {
|
|
|
44447
44474
|
if (!trimmedPath)
|
|
44448
44475
|
return null;
|
|
44449
44476
|
if (trimmedPath.startsWith("~/")) {
|
|
44450
|
-
return
|
|
44477
|
+
return resolve6(homedir9(), trimmedPath.slice(2));
|
|
44451
44478
|
}
|
|
44452
44479
|
if (isAbsolute3(trimmedPath)) {
|
|
44453
|
-
return
|
|
44480
|
+
return resolve6(trimmedPath);
|
|
44454
44481
|
}
|
|
44455
|
-
return
|
|
44482
|
+
return resolve6(workingDirectory, trimmedPath);
|
|
44456
44483
|
}
|
|
44457
44484
|
function isPathInPlansDir(path6, plansDir) {
|
|
44458
44485
|
if (!path6.endsWith(".md"))
|
|
@@ -44573,7 +44600,7 @@ class PermissionModeManager {
|
|
|
44573
44600
|
return "allow";
|
|
44574
44601
|
}
|
|
44575
44602
|
if (writeTools.includes(toolName)) {
|
|
44576
|
-
const plansDir = join8(
|
|
44603
|
+
const plansDir = join8(homedir9(), ".letta", "plans");
|
|
44577
44604
|
const targetPath = toolArgs?.file_path || toolArgs?.path;
|
|
44578
44605
|
let candidatePaths = [];
|
|
44579
44606
|
if ((toolName === "ApplyPatch" || toolName === "apply_patch") && toolArgs?.input) {
|
|
@@ -46606,12 +46633,12 @@ var init_LS2 = __esm(() => {
|
|
|
46606
46633
|
|
|
46607
46634
|
// src/tools/impl/LS.ts
|
|
46608
46635
|
import { readdir as readdir2, stat } from "node:fs/promises";
|
|
46609
|
-
import { join as join10, resolve as
|
|
46636
|
+
import { join as join10, resolve as resolve10 } from "node:path";
|
|
46610
46637
|
async function ls(args) {
|
|
46611
46638
|
validateRequiredParams(args, ["path"], "LS");
|
|
46612
46639
|
validateParamTypes(args, LS_default2, "LS");
|
|
46613
46640
|
const { path: inputPath, ignore = [] } = args;
|
|
46614
|
-
const dirPath =
|
|
46641
|
+
const dirPath = resolve10(inputPath);
|
|
46615
46642
|
try {
|
|
46616
46643
|
const items = await readdir2(dirPath);
|
|
46617
46644
|
const filteredItems = items.filter((item) => !ignore.some((pattern) => import_picomatch.default.isMatch(item, pattern)));
|
|
@@ -47038,14 +47065,14 @@ var require_filesystem = __commonJS((exports, module) => {
|
|
|
47038
47065
|
fs7.close(fd, () => {});
|
|
47039
47066
|
return buffer.subarray(0, bytesRead);
|
|
47040
47067
|
};
|
|
47041
|
-
var readFile3 = (path10) => new Promise((
|
|
47068
|
+
var readFile3 = (path10) => new Promise((resolve12, reject) => {
|
|
47042
47069
|
fs7.open(path10, "r", (err, fd) => {
|
|
47043
47070
|
if (err) {
|
|
47044
47071
|
reject(err);
|
|
47045
47072
|
} else {
|
|
47046
47073
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
47047
47074
|
fs7.read(fd, buffer, 0, MAX_LENGTH, 0, (_, bytesRead) => {
|
|
47048
|
-
|
|
47075
|
+
resolve12(buffer.subarray(0, bytesRead));
|
|
47049
47076
|
fs7.close(fd, () => {});
|
|
47050
47077
|
});
|
|
47051
47078
|
}
|
|
@@ -47106,10 +47133,10 @@ var require_detect_libc = __commonJS((exports, module) => {
|
|
|
47106
47133
|
var commandOut = "";
|
|
47107
47134
|
var safeCommand = () => {
|
|
47108
47135
|
if (!commandOut) {
|
|
47109
|
-
return new Promise((
|
|
47136
|
+
return new Promise((resolve12) => {
|
|
47110
47137
|
childProcess.exec(command, (err, out) => {
|
|
47111
47138
|
commandOut = err ? " " : out;
|
|
47112
|
-
|
|
47139
|
+
resolve12(commandOut);
|
|
47113
47140
|
});
|
|
47114
47141
|
});
|
|
47115
47142
|
}
|
|
@@ -49666,14 +49693,14 @@ var require_input = __commonJS((exports, module) => {
|
|
|
49666
49693
|
return this;
|
|
49667
49694
|
} else {
|
|
49668
49695
|
if (this._isStreamInput()) {
|
|
49669
|
-
return new Promise((
|
|
49696
|
+
return new Promise((resolve12, reject) => {
|
|
49670
49697
|
const finished = () => {
|
|
49671
49698
|
this._flattenBufferIn();
|
|
49672
49699
|
sharp.metadata(this.options, (err, metadata2) => {
|
|
49673
49700
|
if (err) {
|
|
49674
49701
|
reject(is.nativeError(err, stack));
|
|
49675
49702
|
} else {
|
|
49676
|
-
|
|
49703
|
+
resolve12(metadata2);
|
|
49677
49704
|
}
|
|
49678
49705
|
});
|
|
49679
49706
|
};
|
|
@@ -49684,12 +49711,12 @@ var require_input = __commonJS((exports, module) => {
|
|
|
49684
49711
|
}
|
|
49685
49712
|
});
|
|
49686
49713
|
} else {
|
|
49687
|
-
return new Promise((
|
|
49714
|
+
return new Promise((resolve12, reject) => {
|
|
49688
49715
|
sharp.metadata(this.options, (err, metadata2) => {
|
|
49689
49716
|
if (err) {
|
|
49690
49717
|
reject(is.nativeError(err, stack));
|
|
49691
49718
|
} else {
|
|
49692
|
-
|
|
49719
|
+
resolve12(metadata2);
|
|
49693
49720
|
}
|
|
49694
49721
|
});
|
|
49695
49722
|
});
|
|
@@ -49722,25 +49749,25 @@ var require_input = __commonJS((exports, module) => {
|
|
|
49722
49749
|
return this;
|
|
49723
49750
|
} else {
|
|
49724
49751
|
if (this._isStreamInput()) {
|
|
49725
|
-
return new Promise((
|
|
49752
|
+
return new Promise((resolve12, reject) => {
|
|
49726
49753
|
this.on("finish", function() {
|
|
49727
49754
|
this._flattenBufferIn();
|
|
49728
49755
|
sharp.stats(this.options, (err, stats2) => {
|
|
49729
49756
|
if (err) {
|
|
49730
49757
|
reject(is.nativeError(err, stack));
|
|
49731
49758
|
} else {
|
|
49732
|
-
|
|
49759
|
+
resolve12(stats2);
|
|
49733
49760
|
}
|
|
49734
49761
|
});
|
|
49735
49762
|
});
|
|
49736
49763
|
});
|
|
49737
49764
|
} else {
|
|
49738
|
-
return new Promise((
|
|
49765
|
+
return new Promise((resolve12, reject) => {
|
|
49739
49766
|
sharp.stats(this.options, (err, stats2) => {
|
|
49740
49767
|
if (err) {
|
|
49741
49768
|
reject(is.nativeError(err, stack));
|
|
49742
49769
|
} else {
|
|
49743
|
-
|
|
49770
|
+
resolve12(stats2);
|
|
49744
49771
|
}
|
|
49745
49772
|
});
|
|
49746
49773
|
});
|
|
@@ -53139,7 +53166,7 @@ var require_output = __commonJS((exports, module) => {
|
|
|
53139
53166
|
return this;
|
|
53140
53167
|
} else {
|
|
53141
53168
|
if (this._isStreamInput()) {
|
|
53142
|
-
return new Promise((
|
|
53169
|
+
return new Promise((resolve12, reject) => {
|
|
53143
53170
|
this.once("finish", () => {
|
|
53144
53171
|
this._flattenBufferIn();
|
|
53145
53172
|
sharp.pipeline(this.options, (err, data, info) => {
|
|
@@ -53147,24 +53174,24 @@ var require_output = __commonJS((exports, module) => {
|
|
|
53147
53174
|
reject(is.nativeError(err, stack));
|
|
53148
53175
|
} else {
|
|
53149
53176
|
if (this.options.resolveWithObject) {
|
|
53150
|
-
|
|
53177
|
+
resolve12({ data, info });
|
|
53151
53178
|
} else {
|
|
53152
|
-
|
|
53179
|
+
resolve12(data);
|
|
53153
53180
|
}
|
|
53154
53181
|
}
|
|
53155
53182
|
});
|
|
53156
53183
|
});
|
|
53157
53184
|
});
|
|
53158
53185
|
} else {
|
|
53159
|
-
return new Promise((
|
|
53186
|
+
return new Promise((resolve12, reject) => {
|
|
53160
53187
|
sharp.pipeline(this.options, (err, data, info) => {
|
|
53161
53188
|
if (err) {
|
|
53162
53189
|
reject(is.nativeError(err, stack));
|
|
53163
53190
|
} else {
|
|
53164
53191
|
if (this.options.resolveWithObject) {
|
|
53165
|
-
|
|
53192
|
+
resolve12({ data, info });
|
|
53166
53193
|
} else {
|
|
53167
|
-
|
|
53194
|
+
resolve12(data);
|
|
53168
53195
|
}
|
|
53169
53196
|
}
|
|
53170
53197
|
});
|
|
@@ -53945,7 +53972,7 @@ var init_client3 = __esm(() => {
|
|
|
53945
53972
|
this.emit("notification", notification);
|
|
53946
53973
|
}
|
|
53947
53974
|
sendRequest(method, params) {
|
|
53948
|
-
return new Promise((
|
|
53975
|
+
return new Promise((resolve13, reject) => {
|
|
53949
53976
|
const id = ++this.requestId;
|
|
53950
53977
|
const request = {
|
|
53951
53978
|
jsonrpc: "2.0",
|
|
@@ -53954,7 +53981,7 @@ var init_client3 = __esm(() => {
|
|
|
53954
53981
|
params
|
|
53955
53982
|
};
|
|
53956
53983
|
this.pendingRequests.set(id, {
|
|
53957
|
-
resolve:
|
|
53984
|
+
resolve: resolve13,
|
|
53958
53985
|
reject
|
|
53959
53986
|
});
|
|
53960
53987
|
this.sendMessage(request);
|
|
@@ -54074,14 +54101,14 @@ var init_python = __esm(() => {
|
|
|
54074
54101
|
}
|
|
54075
54102
|
console.log("[LSP] Installing pyright...");
|
|
54076
54103
|
const { spawn: spawn4 } = await import("node:child_process");
|
|
54077
|
-
return new Promise((
|
|
54104
|
+
return new Promise((resolve13, reject) => {
|
|
54078
54105
|
const proc = spawn4("npm", ["install", "-g", "pyright"], {
|
|
54079
54106
|
stdio: "inherit"
|
|
54080
54107
|
});
|
|
54081
54108
|
proc.on("exit", (code) => {
|
|
54082
54109
|
if (code === 0) {
|
|
54083
54110
|
console.log("[LSP] Successfully installed pyright");
|
|
54084
|
-
|
|
54111
|
+
resolve13();
|
|
54085
54112
|
} else {
|
|
54086
54113
|
reject(new Error(`npm install failed with code ${code}`));
|
|
54087
54114
|
}
|
|
@@ -54123,14 +54150,14 @@ var init_typescript = __esm(() => {
|
|
|
54123
54150
|
}
|
|
54124
54151
|
console.log("[LSP] Installing typescript-language-server and typescript...");
|
|
54125
54152
|
const { spawn: spawn4 } = await import("node:child_process");
|
|
54126
|
-
return new Promise((
|
|
54153
|
+
return new Promise((resolve13, reject) => {
|
|
54127
54154
|
const proc = spawn4("npm", ["install", "-g", "typescript-language-server", "typescript"], {
|
|
54128
54155
|
stdio: "inherit"
|
|
54129
54156
|
});
|
|
54130
54157
|
proc.on("exit", (code) => {
|
|
54131
54158
|
if (code === 0) {
|
|
54132
54159
|
console.log("[LSP] Successfully installed typescript-language-server");
|
|
54133
|
-
|
|
54160
|
+
resolve13();
|
|
54134
54161
|
} else {
|
|
54135
54162
|
reject(new Error(`npm install failed with code ${code}`));
|
|
54136
54163
|
}
|
|
@@ -54361,7 +54388,7 @@ async function read_lsp(args) {
|
|
|
54361
54388
|
const userCwd = process.env.USER_CWD || process.cwd();
|
|
54362
54389
|
const resolvedPath = path12.default.isAbsolute(args.file_path) ? args.file_path : path12.default.resolve(userCwd, args.file_path);
|
|
54363
54390
|
await lspManager2.touchFile(resolvedPath, false);
|
|
54364
|
-
await new Promise((
|
|
54391
|
+
await new Promise((resolve14) => setTimeout(resolve14, 100));
|
|
54365
54392
|
const diagnostics = lspManager2.getDiagnostics(resolvedPath);
|
|
54366
54393
|
if (diagnostics.length > 0) {
|
|
54367
54394
|
const errors = diagnostics.filter((d) => d.severity === 1);
|
|
@@ -57469,10 +57496,10 @@ var init_esm4 = __esm(() => {
|
|
|
57469
57496
|
return this[ENCODING] ? buf.join("") : Buffer.concat(buf, buf.dataLength);
|
|
57470
57497
|
}
|
|
57471
57498
|
async promise() {
|
|
57472
|
-
return new Promise((
|
|
57499
|
+
return new Promise((resolve14, reject) => {
|
|
57473
57500
|
this.on(DESTROYED, () => reject(new Error("stream destroyed")));
|
|
57474
57501
|
this.on("error", (er) => reject(er));
|
|
57475
|
-
this.on("end", () =>
|
|
57502
|
+
this.on("end", () => resolve14());
|
|
57476
57503
|
});
|
|
57477
57504
|
}
|
|
57478
57505
|
[Symbol.asyncIterator]() {
|
|
@@ -57491,7 +57518,7 @@ var init_esm4 = __esm(() => {
|
|
|
57491
57518
|
return Promise.resolve({ done: false, value: res });
|
|
57492
57519
|
if (this[EOF])
|
|
57493
57520
|
return stop();
|
|
57494
|
-
let
|
|
57521
|
+
let resolve14;
|
|
57495
57522
|
let reject;
|
|
57496
57523
|
const onerr = (er) => {
|
|
57497
57524
|
this.off("data", ondata);
|
|
@@ -57505,19 +57532,19 @@ var init_esm4 = __esm(() => {
|
|
|
57505
57532
|
this.off("end", onend);
|
|
57506
57533
|
this.off(DESTROYED, ondestroy);
|
|
57507
57534
|
this.pause();
|
|
57508
|
-
|
|
57535
|
+
resolve14({ value, done: !!this[EOF] });
|
|
57509
57536
|
};
|
|
57510
57537
|
const onend = () => {
|
|
57511
57538
|
this.off("error", onerr);
|
|
57512
57539
|
this.off("data", ondata);
|
|
57513
57540
|
this.off(DESTROYED, ondestroy);
|
|
57514
57541
|
stop();
|
|
57515
|
-
|
|
57542
|
+
resolve14({ done: true, value: undefined });
|
|
57516
57543
|
};
|
|
57517
57544
|
const ondestroy = () => onerr(new Error("stream destroyed"));
|
|
57518
57545
|
return new Promise((res2, rej) => {
|
|
57519
57546
|
reject = rej;
|
|
57520
|
-
|
|
57547
|
+
resolve14 = res2;
|
|
57521
57548
|
this.once(DESTROYED, ondestroy);
|
|
57522
57549
|
this.once("error", onerr);
|
|
57523
57550
|
this.once("end", onend);
|
|
@@ -58203,8 +58230,8 @@ var init_esm5 = __esm(() => {
|
|
|
58203
58230
|
if (this.#asyncReaddirInFlight) {
|
|
58204
58231
|
await this.#asyncReaddirInFlight;
|
|
58205
58232
|
} else {
|
|
58206
|
-
let
|
|
58207
|
-
this.#asyncReaddirInFlight = new Promise((res) =>
|
|
58233
|
+
let resolve14 = () => {};
|
|
58234
|
+
this.#asyncReaddirInFlight = new Promise((res) => resolve14 = res);
|
|
58208
58235
|
try {
|
|
58209
58236
|
for (const e of await this.#fs.promises.readdir(fullpath, {
|
|
58210
58237
|
withFileTypes: true
|
|
@@ -58217,7 +58244,7 @@ var init_esm5 = __esm(() => {
|
|
|
58217
58244
|
children.provisional = 0;
|
|
58218
58245
|
}
|
|
58219
58246
|
this.#asyncReaddirInFlight = undefined;
|
|
58220
|
-
|
|
58247
|
+
resolve14();
|
|
58221
58248
|
}
|
|
58222
58249
|
return children.slice(0, children.provisional);
|
|
58223
58250
|
}
|
|
@@ -61195,9 +61222,9 @@ async function executeSubagent(type, config, model, userPrompt, baseURL, subagen
|
|
|
61195
61222
|
proc2.stderr.on("data", (data) => {
|
|
61196
61223
|
stderrChunks.push(data);
|
|
61197
61224
|
});
|
|
61198
|
-
const exitCode = await new Promise((
|
|
61199
|
-
proc2.on("close",
|
|
61200
|
-
proc2.on("error", () =>
|
|
61225
|
+
const exitCode = await new Promise((resolve15) => {
|
|
61226
|
+
proc2.on("close", resolve15);
|
|
61227
|
+
proc2.on("error", () => resolve15(null));
|
|
61201
61228
|
});
|
|
61202
61229
|
signal?.removeEventListener("abort", abortHandler);
|
|
61203
61230
|
if (wasAborted) {
|
|
@@ -61452,7 +61479,7 @@ ${result.report}
|
|
|
61452
61479
|
`);
|
|
61453
61480
|
}
|
|
61454
61481
|
function sleep3(ms) {
|
|
61455
|
-
return new Promise((
|
|
61482
|
+
return new Promise((resolve15) => setTimeout(resolve15, ms));
|
|
61456
61483
|
}
|
|
61457
61484
|
async function waitForBackgroundSubagentLink(subagentId, timeoutMs = null, signal) {
|
|
61458
61485
|
const deadline = timeoutMs !== null && timeoutMs > 0 ? Date.now() + timeoutMs : null;
|
|
@@ -64538,7 +64565,7 @@ var init_esm7 = __esm(() => {
|
|
|
64538
64565
|
});
|
|
64539
64566
|
|
|
64540
64567
|
// src/permissions/matcher.ts
|
|
64541
|
-
import { resolve as
|
|
64568
|
+
import { resolve as resolve17 } from "node:path";
|
|
64542
64569
|
function toolForMatch(toolName, options) {
|
|
64543
64570
|
return options?.canonicalizeToolNames === false ? toolName : canonicalToolName(toolName);
|
|
64544
64571
|
}
|
|
@@ -64593,7 +64620,7 @@ function resolveFilePathForMatching(filePath, workingDirectory, windowsContext)
|
|
|
64593
64620
|
if (windowsContext && isWindowsAbsolutePath(filePath)) {
|
|
64594
64621
|
return canonicalizeWindowsAbsolutePath(filePath);
|
|
64595
64622
|
}
|
|
64596
|
-
const resolved = normalizePath(
|
|
64623
|
+
const resolved = normalizePath(resolve17(workingDirectory, filePath));
|
|
64597
64624
|
return windowsContext ? canonicalizeWindowsAbsolutePath(resolved) : resolved;
|
|
64598
64625
|
}
|
|
64599
64626
|
function matchesFilePattern(query, pattern, workingDirectory, options) {
|
|
@@ -64622,8 +64649,8 @@ function matchesFilePattern(query, pattern, workingDirectory, options) {
|
|
|
64622
64649
|
globPattern = globPattern.slice(2);
|
|
64623
64650
|
}
|
|
64624
64651
|
if (globPattern.startsWith("~/")) {
|
|
64625
|
-
const
|
|
64626
|
-
globPattern = globPattern.replace(/^~/,
|
|
64652
|
+
const homedir10 = __require("node:os").homedir();
|
|
64653
|
+
globPattern = globPattern.replace(/^~/, homedir10);
|
|
64627
64654
|
}
|
|
64628
64655
|
globPattern = normalizeAbsolutePattern(globPattern, workingDirectory);
|
|
64629
64656
|
const windowsContext = isWindowsContext(workingDirectory);
|
|
@@ -64706,7 +64733,7 @@ __export(exports_checker, {
|
|
|
64706
64733
|
checkPermissionWithHooks: () => checkPermissionWithHooks,
|
|
64707
64734
|
checkPermission: () => checkPermission
|
|
64708
64735
|
});
|
|
64709
|
-
import { resolve as
|
|
64736
|
+
import { resolve as resolve18 } from "node:path";
|
|
64710
64737
|
function envFlagEnabled(name) {
|
|
64711
64738
|
const value = process.env[name];
|
|
64712
64739
|
if (!value)
|
|
@@ -64993,13 +65020,13 @@ function extractFilePath(toolArgs) {
|
|
|
64993
65020
|
return null;
|
|
64994
65021
|
}
|
|
64995
65022
|
function isWithinAllowedDirectories(filePath, permissions, workingDirectory) {
|
|
64996
|
-
const absolutePath =
|
|
65023
|
+
const absolutePath = resolve18(workingDirectory, filePath);
|
|
64997
65024
|
if (absolutePath.startsWith(workingDirectory)) {
|
|
64998
65025
|
return true;
|
|
64999
65026
|
}
|
|
65000
65027
|
if (permissions.additionalDirectories) {
|
|
65001
65028
|
for (const dir of permissions.additionalDirectories) {
|
|
65002
|
-
const resolvedDir =
|
|
65029
|
+
const resolvedDir = resolve18(workingDirectory, dir);
|
|
65003
65030
|
if (absolutePath.startsWith(resolvedDir)) {
|
|
65004
65031
|
return true;
|
|
65005
65032
|
}
|
|
@@ -65229,10 +65256,10 @@ __export(exports_loader, {
|
|
|
65229
65256
|
loadPermissions: () => loadPermissions,
|
|
65230
65257
|
getUserSettingsPaths: () => getUserSettingsPaths
|
|
65231
65258
|
});
|
|
65232
|
-
import { homedir as
|
|
65259
|
+
import { homedir as homedir10 } from "node:os";
|
|
65233
65260
|
import { join as join14 } from "node:path";
|
|
65234
65261
|
function getUserSettingsPaths(options = {}) {
|
|
65235
|
-
const homeDir = options.homeDir ||
|
|
65262
|
+
const homeDir = options.homeDir || homedir10();
|
|
65236
65263
|
const xdgConfigHome = options.xdgConfigHome || process.env.XDG_CONFIG_HOME || join14(homeDir, ".config");
|
|
65237
65264
|
return {
|
|
65238
65265
|
canonical: join14(homeDir, ".letta", "settings.json"),
|
|
@@ -65354,8 +65381,8 @@ var exports_analyzer = {};
|
|
|
65354
65381
|
__export(exports_analyzer, {
|
|
65355
65382
|
analyzeApprovalContext: () => analyzeApprovalContext
|
|
65356
65383
|
});
|
|
65357
|
-
import { homedir as
|
|
65358
|
-
import { dirname as dirname7, relative as relative2, resolve as
|
|
65384
|
+
import { homedir as homedir11 } from "node:os";
|
|
65385
|
+
import { dirname as dirname7, relative as relative2, resolve as resolve19, win32 as win322 } from "node:path";
|
|
65359
65386
|
function normalizeOsPath(path18) {
|
|
65360
65387
|
return path18.replace(/\\/g, "/");
|
|
65361
65388
|
}
|
|
@@ -65364,7 +65391,7 @@ function isWindowsPath(path18) {
|
|
|
65364
65391
|
}
|
|
65365
65392
|
function resolvePathForContext(basePath, targetPath) {
|
|
65366
65393
|
const windows = isWindowsPath(basePath) || isWindowsPath(targetPath);
|
|
65367
|
-
return windows ? win322.resolve(basePath, targetPath) :
|
|
65394
|
+
return windows ? win322.resolve(basePath, targetPath) : resolve19(basePath, targetPath);
|
|
65368
65395
|
}
|
|
65369
65396
|
function relativePathForContext(basePath, targetPath) {
|
|
65370
65397
|
const windows = isWindowsPath(basePath) || isWindowsPath(targetPath);
|
|
@@ -65391,7 +65418,7 @@ function formatAbsoluteRulePath(path18) {
|
|
|
65391
65418
|
return `//${normalized.replace(/^\/+/, "")}`;
|
|
65392
65419
|
}
|
|
65393
65420
|
function formatDisplayPath(path18) {
|
|
65394
|
-
return normalizeOsPath(path18).replace(normalizeOsPath(
|
|
65421
|
+
return normalizeOsPath(path18).replace(normalizeOsPath(homedir11()), "~");
|
|
65395
65422
|
}
|
|
65396
65423
|
function analyzeApprovalContext(toolName, toolArgs, workingDirectory) {
|
|
65397
65424
|
const canonicalTool = canonicalToolName(toolName);
|
|
@@ -65530,7 +65557,7 @@ function detectSkillScript(command, workingDir) {
|
|
|
65530
65557
|
return null;
|
|
65531
65558
|
}
|
|
65532
65559
|
const normalizedWorkingDir = normalizePathSeparators(workingDir).replace(/\/$/, "");
|
|
65533
|
-
const normalizedHomeDir = normalizePathSeparators(
|
|
65560
|
+
const normalizedHomeDir = normalizePathSeparators(homedir11()).replace(/\/$/, "");
|
|
65534
65561
|
const detect = (source, regex2) => {
|
|
65535
65562
|
for (const candidate of pathCandidates) {
|
|
65536
65563
|
const match3 = candidate.match(regex2);
|
|
@@ -65973,8 +66000,8 @@ function acquireSwitchLock() {
|
|
|
65973
66000
|
const lock = getSwitchLock();
|
|
65974
66001
|
lock.refCount++;
|
|
65975
66002
|
if (lock.refCount === 1) {
|
|
65976
|
-
lock.promise = new Promise((
|
|
65977
|
-
lock.resolve =
|
|
66003
|
+
lock.promise = new Promise((resolve20) => {
|
|
66004
|
+
lock.resolve = resolve20;
|
|
65978
66005
|
});
|
|
65979
66006
|
}
|
|
65980
66007
|
}
|
|
@@ -67113,8 +67140,9 @@ async function fetchConversationBackfillMessages2(client, conversationId) {
|
|
|
67113
67140
|
}
|
|
67114
67141
|
return sortChronological2(collected);
|
|
67115
67142
|
}
|
|
67116
|
-
async function getResumeData2(client, agent, conversationId) {
|
|
67143
|
+
async function getResumeData2(client, agent, conversationId, options = {}) {
|
|
67117
67144
|
try {
|
|
67145
|
+
const includeMessageHistory = options.includeMessageHistory ?? true;
|
|
67118
67146
|
let inContextMessageIds;
|
|
67119
67147
|
let messages = [];
|
|
67120
67148
|
const useConversationsApi = conversationId && conversationId !== "default";
|
|
@@ -67126,7 +67154,7 @@ async function getResumeData2(client, agent, conversationId) {
|
|
|
67126
67154
|
inContextMessageIds = conversation.in_context_message_ids;
|
|
67127
67155
|
if (!inContextMessageIds || inContextMessageIds.length === 0) {
|
|
67128
67156
|
debugWarn("check-approval", "No in-context messages - no pending approvals");
|
|
67129
|
-
if (isBackfillEnabled2()) {
|
|
67157
|
+
if (includeMessageHistory && isBackfillEnabled2()) {
|
|
67130
67158
|
try {
|
|
67131
67159
|
const backfill = await fetchConversationBackfillMessages2(client, conversationId);
|
|
67132
67160
|
return {
|
|
@@ -67151,7 +67179,7 @@ async function getResumeData2(client, agent, conversationId) {
|
|
|
67151
67179
|
throw new Error("Expected at least one in-context message");
|
|
67152
67180
|
}
|
|
67153
67181
|
const retrievedMessages = await client.messages.retrieve(lastInContextId);
|
|
67154
|
-
if (isBackfillEnabled2()) {
|
|
67182
|
+
if (includeMessageHistory && isBackfillEnabled2()) {
|
|
67155
67183
|
try {
|
|
67156
67184
|
messages = await fetchConversationBackfillMessages2(client, conversationId);
|
|
67157
67185
|
} catch (backfillError) {
|
|
@@ -67194,7 +67222,7 @@ async function getResumeData2(client, agent, conversationId) {
|
|
|
67194
67222
|
throw new Error("Expected at least one in-context message");
|
|
67195
67223
|
}
|
|
67196
67224
|
const retrievedMessages = await client.messages.retrieve(lastInContextId);
|
|
67197
|
-
if (isBackfillEnabled2()) {
|
|
67225
|
+
if (includeMessageHistory && isBackfillEnabled2()) {
|
|
67198
67226
|
try {
|
|
67199
67227
|
const messagesPage = await client.agents.messages.list(agent.id, {
|
|
67200
67228
|
limit: BACKFILL_PAGE_LIMIT2,
|
|
@@ -68579,7 +68607,7 @@ import {
|
|
|
68579
68607
|
unlinkSync as unlinkSync3,
|
|
68580
68608
|
writeFileSync as writeFileSync5
|
|
68581
68609
|
} from "node:fs";
|
|
68582
|
-
import { homedir as
|
|
68610
|
+
import { homedir as homedir12 } from "node:os";
|
|
68583
68611
|
import { join as join15 } from "node:path";
|
|
68584
68612
|
function truncateStr(value, maxLen) {
|
|
68585
68613
|
if (value === null || value === undefined)
|
|
@@ -68720,7 +68748,7 @@ class ChunkLog {
|
|
|
68720
68748
|
var MAX_ENTRIES = 100, CONTENT_TRUNCATE_LEN = 200, MAX_SESSION_FILES = 5, LOG_BASE_DIR, chunkLog;
|
|
68721
68749
|
var init_chunkLog = __esm(() => {
|
|
68722
68750
|
init_debug();
|
|
68723
|
-
LOG_BASE_DIR = join15(
|
|
68751
|
+
LOG_BASE_DIR = join15(homedir12(), ".letta", "logs", "chunk-logs");
|
|
68724
68752
|
chunkLog = new ChunkLog;
|
|
68725
68753
|
});
|
|
68726
68754
|
|
|
@@ -69166,8 +69194,8 @@ async function connectWithRetry(runtime, opts, attempt = 0, startTime = Date.now
|
|
|
69166
69194
|
const delay = Math.min(INITIAL_RETRY_DELAY_MS * 2 ** (attempt - 1), MAX_RETRY_DELAY_MS);
|
|
69167
69195
|
const maxAttempts = Math.ceil(Math.log2(MAX_RETRY_DURATION_MS / INITIAL_RETRY_DELAY_MS));
|
|
69168
69196
|
opts.onRetrying?.(attempt, maxAttempts, delay);
|
|
69169
|
-
await new Promise((
|
|
69170
|
-
runtime.reconnectTimeout = setTimeout(
|
|
69197
|
+
await new Promise((resolve21) => {
|
|
69198
|
+
runtime.reconnectTimeout = setTimeout(resolve21, delay);
|
|
69171
69199
|
});
|
|
69172
69200
|
runtime.reconnectTimeout = null;
|
|
69173
69201
|
if (runtime !== activeRuntime || runtime.intentionallyClosed) {
|
|
@@ -69703,7 +69731,7 @@ async function queryTerminalBackground(timeoutMs = 100) {
|
|
|
69703
69731
|
}
|
|
69704
69732
|
const wasRaw = process.stdin.isRaw;
|
|
69705
69733
|
const wasFlowing = process.stdin.readableFlowing;
|
|
69706
|
-
return new Promise((
|
|
69734
|
+
return new Promise((resolve23) => {
|
|
69707
69735
|
let response = "";
|
|
69708
69736
|
let resolved = false;
|
|
69709
69737
|
const cleanup = () => {
|
|
@@ -69720,7 +69748,7 @@ async function queryTerminalBackground(timeoutMs = 100) {
|
|
|
69720
69748
|
};
|
|
69721
69749
|
const timeout = setTimeout(() => {
|
|
69722
69750
|
cleanup();
|
|
69723
|
-
|
|
69751
|
+
resolve23(null);
|
|
69724
69752
|
}, timeoutMs);
|
|
69725
69753
|
const onData = (data) => {
|
|
69726
69754
|
response += data.toString();
|
|
@@ -69730,7 +69758,7 @@ async function queryTerminalBackground(timeoutMs = 100) {
|
|
|
69730
69758
|
if (match3) {
|
|
69731
69759
|
clearTimeout(timeout);
|
|
69732
69760
|
cleanup();
|
|
69733
|
-
|
|
69761
|
+
resolve23({
|
|
69734
69762
|
r: parseHexComponent(match3[1] ?? "0"),
|
|
69735
69763
|
g: parseHexComponent(match3[2] ?? "0"),
|
|
69736
69764
|
b: parseHexComponent(match3[3] ?? "0")
|
|
@@ -69745,7 +69773,7 @@ async function queryTerminalBackground(timeoutMs = 100) {
|
|
|
69745
69773
|
} catch {
|
|
69746
69774
|
clearTimeout(timeout);
|
|
69747
69775
|
cleanup();
|
|
69748
|
-
|
|
69776
|
+
resolve23(null);
|
|
69749
69777
|
}
|
|
69750
69778
|
});
|
|
69751
69779
|
}
|
|
@@ -71125,14 +71153,14 @@ var execFile9, __dirname2, localXdgOpenPath, platform2, arch, pTryEach = async (
|
|
|
71125
71153
|
}
|
|
71126
71154
|
const subprocess = childProcess.spawn(command, cliArguments, childProcessOptions);
|
|
71127
71155
|
if (options.wait) {
|
|
71128
|
-
return new Promise((
|
|
71156
|
+
return new Promise((resolve24, reject) => {
|
|
71129
71157
|
subprocess.once("error", reject);
|
|
71130
71158
|
subprocess.once("close", (exitCode) => {
|
|
71131
71159
|
if (!options.allowNonzeroExitCode && exitCode > 0) {
|
|
71132
71160
|
reject(new Error(`Exited with code ${exitCode}`));
|
|
71133
71161
|
return;
|
|
71134
71162
|
}
|
|
71135
|
-
|
|
71163
|
+
resolve24(subprocess);
|
|
71136
71164
|
});
|
|
71137
71165
|
});
|
|
71138
71166
|
}
|
|
@@ -71430,10 +71458,10 @@ __export(exports_setup, {
|
|
|
71430
71458
|
runSetup: () => runSetup
|
|
71431
71459
|
});
|
|
71432
71460
|
async function runSetup() {
|
|
71433
|
-
return new Promise((
|
|
71461
|
+
return new Promise((resolve24) => {
|
|
71434
71462
|
const { waitUntilExit } = render_default(import_react30.default.createElement(SetupUI, {
|
|
71435
71463
|
onComplete: () => {
|
|
71436
|
-
|
|
71464
|
+
resolve24();
|
|
71437
71465
|
}
|
|
71438
71466
|
}));
|
|
71439
71467
|
waitUntilExit().catch((error) => {
|
|
@@ -73469,10 +73497,10 @@ __export(exports_import, {
|
|
|
73469
73497
|
});
|
|
73470
73498
|
import { createReadStream } from "node:fs";
|
|
73471
73499
|
import { chmod, mkdir as mkdir3, readFile as readFile8, writeFile as writeFile3 } from "node:fs/promises";
|
|
73472
|
-
import { dirname as dirname10, resolve as
|
|
73500
|
+
import { dirname as dirname10, resolve as resolve24 } from "node:path";
|
|
73473
73501
|
async function importAgentFromFile(options) {
|
|
73474
73502
|
const client = await getClient2();
|
|
73475
|
-
const resolvedPath =
|
|
73503
|
+
const resolvedPath = resolve24(options.filePath);
|
|
73476
73504
|
const file = createReadStream(resolvedPath);
|
|
73477
73505
|
const importResponse = await client.agents.importFile({
|
|
73478
73506
|
file,
|
|
@@ -73507,7 +73535,7 @@ async function extractSkillsFromAf(afPath, destDir) {
|
|
|
73507
73535
|
return [];
|
|
73508
73536
|
}
|
|
73509
73537
|
for (const skill2 of afData.skills) {
|
|
73510
|
-
const skillDir =
|
|
73538
|
+
const skillDir = resolve24(destDir, skill2.name);
|
|
73511
73539
|
await mkdir3(skillDir, { recursive: true });
|
|
73512
73540
|
if (skill2.files) {
|
|
73513
73541
|
await writeSkillFiles(skillDir, skill2.files);
|
|
@@ -73527,7 +73555,7 @@ async function writeSkillFiles(skillDir, files) {
|
|
|
73527
73555
|
}
|
|
73528
73556
|
}
|
|
73529
73557
|
async function writeSkillFile(skillDir, filePath, content) {
|
|
73530
|
-
const fullPath =
|
|
73558
|
+
const fullPath = resolve24(skillDir, filePath);
|
|
73531
73559
|
await mkdir3(dirname10(fullPath), { recursive: true });
|
|
73532
73560
|
await writeFile3(fullPath, content, "utf-8");
|
|
73533
73561
|
const isScript = filePath.startsWith("scripts/") || content.trimStart().startsWith("#!");
|
|
@@ -74638,7 +74666,7 @@ ${loadedContents.join(`
|
|
|
74638
74666
|
} else {
|
|
74639
74667
|
console.error(`Conversation is busy, waiting ${CONVERSATION_BUSY_RETRY_DELAY_MS / 1000}s and retrying...`);
|
|
74640
74668
|
}
|
|
74641
|
-
await new Promise((
|
|
74669
|
+
await new Promise((resolve25) => setTimeout(resolve25, CONVERSATION_BUSY_RETRY_DELAY_MS));
|
|
74642
74670
|
continue;
|
|
74643
74671
|
}
|
|
74644
74672
|
if (preStreamAction === "retry_transient") {
|
|
@@ -74661,7 +74689,7 @@ ${loadedContents.join(`
|
|
|
74661
74689
|
const delaySeconds = Math.round(delayMs / 1000);
|
|
74662
74690
|
console.error(`Transient API error before streaming (attempt ${attempt} of ${LLM_API_ERROR_MAX_RETRIES}), retrying in ${delaySeconds}s...`);
|
|
74663
74691
|
}
|
|
74664
|
-
await new Promise((
|
|
74692
|
+
await new Promise((resolve25) => setTimeout(resolve25, delayMs));
|
|
74665
74693
|
conversationBusyRetries = 0;
|
|
74666
74694
|
continue;
|
|
74667
74695
|
}
|
|
@@ -74874,7 +74902,7 @@ ${loadedContents.join(`
|
|
|
74874
74902
|
const delaySeconds = Math.round(delayMs / 1000);
|
|
74875
74903
|
console.error(`LLM API error encountered (attempt ${attempt} of ${LLM_API_ERROR_MAX_RETRIES}), retrying in ${delaySeconds}s...`);
|
|
74876
74904
|
}
|
|
74877
|
-
await new Promise((
|
|
74905
|
+
await new Promise((resolve25) => setTimeout(resolve25, delayMs));
|
|
74878
74906
|
continue;
|
|
74879
74907
|
}
|
|
74880
74908
|
}
|
|
@@ -74950,7 +74978,7 @@ ${loadedContents.join(`
|
|
|
74950
74978
|
const delaySeconds = Math.round(delayMs / 1000);
|
|
74951
74979
|
console.error(`LLM API error encountered (attempt ${attempt} of ${LLM_API_ERROR_MAX_RETRIES}), retrying in ${delaySeconds}s...`);
|
|
74952
74980
|
}
|
|
74953
|
-
await new Promise((
|
|
74981
|
+
await new Promise((resolve25) => setTimeout(resolve25, delayMs));
|
|
74954
74982
|
continue;
|
|
74955
74983
|
}
|
|
74956
74984
|
} catch (_e) {}
|
|
@@ -75184,18 +75212,18 @@ async function runBidirectionalMode(agent, conversationId, client, _outputFormat
|
|
|
75184
75212
|
setMessageQueueAdder((queuedMessage) => {
|
|
75185
75213
|
const syntheticUserLine = serializeQueuedMessageAsUserLine(queuedMessage);
|
|
75186
75214
|
if (lineResolver) {
|
|
75187
|
-
const
|
|
75215
|
+
const resolve25 = lineResolver;
|
|
75188
75216
|
lineResolver = null;
|
|
75189
|
-
|
|
75217
|
+
resolve25(syntheticUserLine);
|
|
75190
75218
|
return;
|
|
75191
75219
|
}
|
|
75192
75220
|
lineQueue.push(syntheticUserLine);
|
|
75193
75221
|
});
|
|
75194
75222
|
rl.on("line", (line) => {
|
|
75195
75223
|
if (lineResolver) {
|
|
75196
|
-
const
|
|
75224
|
+
const resolve25 = lineResolver;
|
|
75197
75225
|
lineResolver = null;
|
|
75198
|
-
|
|
75226
|
+
resolve25(line);
|
|
75199
75227
|
} else {
|
|
75200
75228
|
lineQueue.push(line);
|
|
75201
75229
|
}
|
|
@@ -75203,17 +75231,17 @@ async function runBidirectionalMode(agent, conversationId, client, _outputFormat
|
|
|
75203
75231
|
rl.on("close", () => {
|
|
75204
75232
|
setMessageQueueAdder(null);
|
|
75205
75233
|
if (lineResolver) {
|
|
75206
|
-
const
|
|
75234
|
+
const resolve25 = lineResolver;
|
|
75207
75235
|
lineResolver = null;
|
|
75208
|
-
|
|
75236
|
+
resolve25(null);
|
|
75209
75237
|
}
|
|
75210
75238
|
});
|
|
75211
75239
|
async function getNextLine() {
|
|
75212
75240
|
if (lineQueue.length > 0) {
|
|
75213
75241
|
return lineQueue.shift() ?? null;
|
|
75214
75242
|
}
|
|
75215
|
-
return new Promise((
|
|
75216
|
-
lineResolver =
|
|
75243
|
+
return new Promise((resolve25) => {
|
|
75244
|
+
lineResolver = resolve25;
|
|
75217
75245
|
});
|
|
75218
75246
|
}
|
|
75219
75247
|
async function requestPermission(toolCallId, toolName, toolInput) {
|
|
@@ -75383,6 +75411,19 @@ async function runBidirectionalMode(agent, conversationId, client, _outputFormat
|
|
|
75383
75411
|
console.log(JSON.stringify(registerResponse));
|
|
75384
75412
|
} else if (subtype === "bootstrap_session_state") {
|
|
75385
75413
|
const bootstrapReq = message.request;
|
|
75414
|
+
const { getResumeData: getResumeData3 } = await Promise.resolve().then(() => (init_check_approval(), exports_check_approval));
|
|
75415
|
+
let hasPendingApproval = false;
|
|
75416
|
+
try {
|
|
75417
|
+
const freshAgent = await client.agents.retrieve(agent.id);
|
|
75418
|
+
const resume = await getResumeData3(client, freshAgent, conversationId, {
|
|
75419
|
+
includeMessageHistory: false
|
|
75420
|
+
});
|
|
75421
|
+
hasPendingApproval = (resume.pendingApprovals?.length ?? 0) > 0;
|
|
75422
|
+
} catch (error) {
|
|
75423
|
+
if (!(error instanceof APIError2) || error.status !== 404 && error.status !== 422) {
|
|
75424
|
+
console.warn(`[bootstrap] pending-approval probe failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
75425
|
+
}
|
|
75426
|
+
}
|
|
75386
75427
|
const bootstrapResp = await handleBootstrapSessionState({
|
|
75387
75428
|
bootstrapReq,
|
|
75388
75429
|
sessionContext: {
|
|
@@ -75395,7 +75436,7 @@ async function runBidirectionalMode(agent, conversationId, client, _outputFormat
|
|
|
75395
75436
|
},
|
|
75396
75437
|
requestId: requestId ?? "",
|
|
75397
75438
|
client,
|
|
75398
|
-
hasPendingApproval
|
|
75439
|
+
hasPendingApproval
|
|
75399
75440
|
});
|
|
75400
75441
|
console.log(JSON.stringify(bootstrapResp));
|
|
75401
75442
|
} else if (subtype === "list_messages") {
|
|
@@ -75563,7 +75604,7 @@ async function runBidirectionalMode(agent, conversationId, client, _outputFormat
|
|
|
75563
75604
|
uuid: `retry-bidir-${randomUUID7()}`
|
|
75564
75605
|
};
|
|
75565
75606
|
console.log(JSON.stringify(retryMsg));
|
|
75566
|
-
await new Promise((
|
|
75607
|
+
await new Promise((resolve25) => setTimeout(resolve25, delayMs));
|
|
75567
75608
|
continue;
|
|
75568
75609
|
}
|
|
75569
75610
|
throw preStreamError;
|
|
@@ -75835,10 +75876,10 @@ async function detectAndEnableKittyProtocol() {
|
|
|
75835
75876
|
detectionComplete = true;
|
|
75836
75877
|
return;
|
|
75837
75878
|
}
|
|
75838
|
-
return new Promise((
|
|
75879
|
+
return new Promise((resolve25) => {
|
|
75839
75880
|
if (!process.stdin.isTTY || !process.stdout.isTTY) {
|
|
75840
75881
|
detectionComplete = true;
|
|
75841
|
-
|
|
75882
|
+
resolve25();
|
|
75842
75883
|
return;
|
|
75843
75884
|
}
|
|
75844
75885
|
const originalRawMode = process.stdin.isRaw;
|
|
@@ -75871,7 +75912,7 @@ async function detectAndEnableKittyProtocol() {
|
|
|
75871
75912
|
console.error("[kitty] protocol query unsupported; enabled anyway (best-effort)");
|
|
75872
75913
|
}
|
|
75873
75914
|
detectionComplete = true;
|
|
75874
|
-
|
|
75915
|
+
resolve25();
|
|
75875
75916
|
};
|
|
75876
75917
|
const handleData = (data) => {
|
|
75877
75918
|
if (timeoutId === undefined) {
|
|
@@ -76064,10 +76105,10 @@ __export(exports_settings, {
|
|
|
76064
76105
|
loadProjectSettings: () => loadProjectSettings,
|
|
76065
76106
|
getSetting: () => getSetting
|
|
76066
76107
|
});
|
|
76067
|
-
import { homedir as
|
|
76108
|
+
import { homedir as homedir17 } from "node:os";
|
|
76068
76109
|
import { join as join24 } from "node:path";
|
|
76069
76110
|
function getSettingsPath() {
|
|
76070
|
-
return join24(
|
|
76111
|
+
return join24(homedir17(), ".letta", "settings.json");
|
|
76071
76112
|
}
|
|
76072
76113
|
async function loadSettings() {
|
|
76073
76114
|
const settingsPath = getSettingsPath();
|
|
@@ -81963,7 +82004,7 @@ var init_plan_viewer_template = () => {};
|
|
|
81963
82004
|
|
|
81964
82005
|
// src/web/generate-plan-viewer.ts
|
|
81965
82006
|
import { chmodSync as chmodSync2, existsSync as existsSync14, mkdirSync as mkdirSync10, writeFileSync as writeFileSync7 } from "node:fs";
|
|
81966
|
-
import { homedir as
|
|
82007
|
+
import { homedir as homedir18 } from "node:os";
|
|
81967
82008
|
import { join as join25 } from "node:path";
|
|
81968
82009
|
async function generateAndOpenPlanViewer(planContent, planFilePath, options) {
|
|
81969
82010
|
const data = {
|
|
@@ -81997,7 +82038,7 @@ async function generateAndOpenPlanViewer(planContent, planFilePath, options) {
|
|
|
81997
82038
|
var VIEWERS_DIR;
|
|
81998
82039
|
var init_generate_plan_viewer = __esm(() => {
|
|
81999
82040
|
init_plan_viewer_template();
|
|
82000
|
-
VIEWERS_DIR = join25(
|
|
82041
|
+
VIEWERS_DIR = join25(homedir18(), ".letta", "viewers");
|
|
82001
82042
|
});
|
|
82002
82043
|
|
|
82003
82044
|
// src/cli/components/StaticPlanApproval.tsx
|
|
@@ -83995,7 +84036,7 @@ var init_pasteRegistry = __esm(() => {
|
|
|
83995
84036
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
83996
84037
|
import { existsSync as existsSync15, readFileSync as readFileSync3, statSync as statSync4, unlinkSync as unlinkSync5 } from "node:fs";
|
|
83997
84038
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
83998
|
-
import { basename as basename3, extname as extname5, isAbsolute as isAbsolute16, join as join26, resolve as
|
|
84039
|
+
import { basename as basename3, extname as extname5, isAbsolute as isAbsolute16, join as join26, resolve as resolve25 } from "node:path";
|
|
83999
84040
|
function countLines2(text) {
|
|
84000
84041
|
return (text.match(/\r\n|\r|\n/g) || []).length + 1;
|
|
84001
84042
|
}
|
|
@@ -84043,7 +84084,7 @@ function translatePasteForImages(paste) {
|
|
|
84043
84084
|
} catch {}
|
|
84044
84085
|
}
|
|
84045
84086
|
if (!isAbsolute16(filePath))
|
|
84046
|
-
filePath =
|
|
84087
|
+
filePath = resolve25(process.cwd(), filePath);
|
|
84047
84088
|
const ext3 = extname5(filePath || "").toLowerCase();
|
|
84048
84089
|
if (IMAGE_EXTS.has(ext3) && existsSync15(filePath) && statSync4(filePath).isFile()) {
|
|
84049
84090
|
const buf = readFileSync3(filePath);
|
|
@@ -84705,7 +84746,7 @@ import {
|
|
|
84705
84746
|
readFileSync as readFileSync4,
|
|
84706
84747
|
writeFileSync as writeFileSync8
|
|
84707
84748
|
} from "node:fs";
|
|
84708
|
-
import { homedir as
|
|
84749
|
+
import { homedir as homedir19, platform as platform4 } from "node:os";
|
|
84709
84750
|
import { dirname as dirname11, join as join27 } from "node:path";
|
|
84710
84751
|
function detectTerminalType() {
|
|
84711
84752
|
if (process.env.CURSOR_TRACE_ID || process.env.CURSOR_CHANNEL) {
|
|
@@ -84738,7 +84779,7 @@ function getKeybindingsPath(terminal) {
|
|
|
84738
84779
|
}[terminal];
|
|
84739
84780
|
const os5 = platform4();
|
|
84740
84781
|
if (os5 === "darwin") {
|
|
84741
|
-
return join27(
|
|
84782
|
+
return join27(homedir19(), "Library", "Application Support", appName, "User", "keybindings.json");
|
|
84742
84783
|
}
|
|
84743
84784
|
if (os5 === "win32") {
|
|
84744
84785
|
const appData = process.env.APPDATA;
|
|
@@ -84747,7 +84788,7 @@ function getKeybindingsPath(terminal) {
|
|
|
84747
84788
|
return join27(appData, appName, "User", "keybindings.json");
|
|
84748
84789
|
}
|
|
84749
84790
|
if (os5 === "linux") {
|
|
84750
|
-
return join27(
|
|
84791
|
+
return join27(homedir19(), ".config", appName, "User", "keybindings.json");
|
|
84751
84792
|
}
|
|
84752
84793
|
return null;
|
|
84753
84794
|
}
|
|
@@ -84904,10 +84945,10 @@ function getWezTermConfigPath() {
|
|
|
84904
84945
|
if (existsSync16(xdgPath))
|
|
84905
84946
|
return xdgPath;
|
|
84906
84947
|
}
|
|
84907
|
-
const configPath = join27(
|
|
84948
|
+
const configPath = join27(homedir19(), ".config", "wezterm", "wezterm.lua");
|
|
84908
84949
|
if (existsSync16(configPath))
|
|
84909
84950
|
return configPath;
|
|
84910
|
-
return join27(
|
|
84951
|
+
return join27(homedir19(), ".wezterm.lua");
|
|
84911
84952
|
}
|
|
84912
84953
|
function wezTermDeleteFixExists(configPath) {
|
|
84913
84954
|
if (!existsSync16(configPath))
|
|
@@ -85875,12 +85916,23 @@ var init_HelpDialog = __esm(async () => {
|
|
|
85875
85916
|
});
|
|
85876
85917
|
|
|
85877
85918
|
// src/hooks/writer.ts
|
|
85919
|
+
import { homedir as homedir20 } from "node:os";
|
|
85920
|
+
import { resolve as resolve26 } from "node:path";
|
|
85921
|
+
function isProjectSettingsPathCollidingWithGlobal2(workingDirectory) {
|
|
85922
|
+
const home = process.env.HOME || homedir20();
|
|
85923
|
+
const globalSettingsPath = resolve26(home, ".letta", "settings.json");
|
|
85924
|
+
const projectSettingsPath = resolve26(workingDirectory, ".letta", "settings.json");
|
|
85925
|
+
return globalSettingsPath === projectSettingsPath;
|
|
85926
|
+
}
|
|
85878
85927
|
function loadHooksFromLocation(location, workingDirectory = process.cwd()) {
|
|
85879
85928
|
try {
|
|
85880
85929
|
switch (location) {
|
|
85881
85930
|
case "user":
|
|
85882
85931
|
return settingsManager.getSettings().hooks || {};
|
|
85883
85932
|
case "project":
|
|
85933
|
+
if (isProjectSettingsPathCollidingWithGlobal2(workingDirectory)) {
|
|
85934
|
+
return {};
|
|
85935
|
+
}
|
|
85884
85936
|
return settingsManager.getProjectSettings(workingDirectory)?.hooks || {};
|
|
85885
85937
|
case "project-local":
|
|
85886
85938
|
return settingsManager.getLocalProjectSettings(workingDirectory)?.hooks || {};
|
|
@@ -85896,6 +85948,10 @@ async function saveHooksToLocation(hooks, location, workingDirectory = process.c
|
|
|
85896
85948
|
settingsManager.updateSettings({ hooks });
|
|
85897
85949
|
break;
|
|
85898
85950
|
case "project":
|
|
85951
|
+
if (isProjectSettingsPathCollidingWithGlobal2(workingDirectory)) {
|
|
85952
|
+
settingsManager.updateSettings({ hooks });
|
|
85953
|
+
break;
|
|
85954
|
+
}
|
|
85899
85955
|
try {
|
|
85900
85956
|
settingsManager.getProjectSettings(workingDirectory);
|
|
85901
85957
|
} catch {
|
|
@@ -88272,7 +88328,7 @@ var init_AgentInfoBar = __esm(async () => {
|
|
|
88272
88328
|
|
|
88273
88329
|
// src/cli/helpers/fileSearch.ts
|
|
88274
88330
|
import { readdirSync as readdirSync6, statSync as statSync5 } from "node:fs";
|
|
88275
|
-
import { join as join29, resolve as
|
|
88331
|
+
import { join as join29, resolve as resolve27 } from "node:path";
|
|
88276
88332
|
function shouldExcludeEntry(entry) {
|
|
88277
88333
|
if (entry.startsWith(".")) {
|
|
88278
88334
|
return true;
|
|
@@ -88321,7 +88377,7 @@ async function searchFiles(query, deep = false) {
|
|
|
88321
88377
|
const dirPart = query.slice(0, lastSlashIndex);
|
|
88322
88378
|
const pattern = query.slice(lastSlashIndex + 1);
|
|
88323
88379
|
try {
|
|
88324
|
-
const resolvedDir =
|
|
88380
|
+
const resolvedDir = resolve27(process.cwd(), dirPart);
|
|
88325
88381
|
try {
|
|
88326
88382
|
statSync5(resolvedDir);
|
|
88327
88383
|
searchDir = resolvedDir;
|
|
@@ -94493,7 +94549,7 @@ __export(exports_generate_memory_viewer, {
|
|
|
94493
94549
|
});
|
|
94494
94550
|
import { execFile as execFileCb2 } from "node:child_process";
|
|
94495
94551
|
import { chmodSync as chmodSync3, existsSync as existsSync19, mkdirSync as mkdirSync13, writeFileSync as writeFileSync10 } from "node:fs";
|
|
94496
|
-
import { homedir as
|
|
94552
|
+
import { homedir as homedir21 } from "node:os";
|
|
94497
94553
|
import { join as join32 } from "node:path";
|
|
94498
94554
|
import { promisify as promisify10 } from "node:util";
|
|
94499
94555
|
async function runGitSafe(cwd2, args) {
|
|
@@ -94807,7 +94863,7 @@ var init_generate_memory_viewer = __esm(async () => {
|
|
|
94807
94863
|
init_memoryGit()
|
|
94808
94864
|
]);
|
|
94809
94865
|
execFile10 = promisify10(execFileCb2);
|
|
94810
|
-
VIEWERS_DIR2 = join32(
|
|
94866
|
+
VIEWERS_DIR2 = join32(homedir21(), ".letta", "viewers");
|
|
94811
94867
|
REFLECTION_PATTERN = /\(reflection\)|🔮|reflection:/i;
|
|
94812
94868
|
});
|
|
94813
94869
|
|
|
@@ -97445,11 +97501,11 @@ var init_byok_providers = __esm(async () => {
|
|
|
97445
97501
|
|
|
97446
97502
|
// src/utils/aws-credentials.ts
|
|
97447
97503
|
import { readFile as readFile10 } from "node:fs/promises";
|
|
97448
|
-
import { homedir as
|
|
97504
|
+
import { homedir as homedir22 } from "node:os";
|
|
97449
97505
|
import { join as join33 } from "node:path";
|
|
97450
97506
|
async function parseAwsCredentials() {
|
|
97451
|
-
const credentialsPath = join33(
|
|
97452
|
-
const configPath = join33(
|
|
97507
|
+
const credentialsPath = join33(homedir22(), ".aws", "credentials");
|
|
97508
|
+
const configPath = join33(homedir22(), ".aws", "config");
|
|
97453
97509
|
const profiles = new Map;
|
|
97454
97510
|
try {
|
|
97455
97511
|
const content = await readFile10(credentialsPath, "utf-8");
|
|
@@ -102760,7 +102816,7 @@ async function executeStatusLineCommand(command, payload, options) {
|
|
|
102760
102816
|
};
|
|
102761
102817
|
}
|
|
102762
102818
|
function runWithLauncher(launcher, inputJson, timeout, signal, workingDirectory, startTime) {
|
|
102763
|
-
return new Promise((
|
|
102819
|
+
return new Promise((resolve28, reject) => {
|
|
102764
102820
|
const [executable, ...args] = launcher;
|
|
102765
102821
|
if (!executable) {
|
|
102766
102822
|
reject(new Error("Empty launcher"));
|
|
@@ -102773,7 +102829,7 @@ function runWithLauncher(launcher, inputJson, timeout, signal, workingDirectory,
|
|
|
102773
102829
|
const safeResolve = (result) => {
|
|
102774
102830
|
if (!resolved) {
|
|
102775
102831
|
resolved = true;
|
|
102776
|
-
|
|
102832
|
+
resolve28(result);
|
|
102777
102833
|
}
|
|
102778
102834
|
};
|
|
102779
102835
|
let child;
|
|
@@ -103266,7 +103322,7 @@ __export(exports_shellAliases, {
|
|
|
103266
103322
|
clearAliasCache: () => clearAliasCache
|
|
103267
103323
|
});
|
|
103268
103324
|
import { existsSync as existsSync21, readFileSync as readFileSync7 } from "node:fs";
|
|
103269
|
-
import { homedir as
|
|
103325
|
+
import { homedir as homedir23 } from "node:os";
|
|
103270
103326
|
import { join as join34 } from "node:path";
|
|
103271
103327
|
function parseAliasesFromFile(filePath) {
|
|
103272
103328
|
const aliases = new Map;
|
|
@@ -103336,7 +103392,7 @@ function loadAliases(forceReload = false) {
|
|
|
103336
103392
|
if (aliasCache && !forceReload) {
|
|
103337
103393
|
return aliasCache;
|
|
103338
103394
|
}
|
|
103339
|
-
const home =
|
|
103395
|
+
const home = homedir23();
|
|
103340
103396
|
const allAliases = new Map;
|
|
103341
103397
|
for (const file of ALIAS_FILES) {
|
|
103342
103398
|
const filePath = join34(home, file);
|
|
@@ -103519,7 +103575,7 @@ async function generatePKCE() {
|
|
|
103519
103575
|
return { codeVerifier, codeChallenge };
|
|
103520
103576
|
}
|
|
103521
103577
|
function startLocalOAuthServer(expectedState, port = OPENAI_OAUTH_CONFIG.defaultPort) {
|
|
103522
|
-
return new Promise((
|
|
103578
|
+
return new Promise((resolve28, reject) => {
|
|
103523
103579
|
const server = http.createServer((req, res) => {
|
|
103524
103580
|
const url = new URL(req.url || "", `http://localhost:${port}`);
|
|
103525
103581
|
if (url.pathname === OPENAI_OAUTH_CONFIG.callbackPath) {
|
|
@@ -103565,7 +103621,7 @@ function startLocalOAuthServer(expectedState, port = OPENAI_OAUTH_CONFIG.default
|
|
|
103565
103621
|
message: "You can close this window and return to Letta Code.",
|
|
103566
103622
|
autoClose: true
|
|
103567
103623
|
}));
|
|
103568
|
-
|
|
103624
|
+
resolve28({ result: { code, state }, server });
|
|
103569
103625
|
} else {
|
|
103570
103626
|
res.writeHead(404, { "Content-Type": "text/plain" });
|
|
103571
103627
|
res.end("Not found");
|
|
@@ -104487,14 +104543,14 @@ __export(exports_export, {
|
|
|
104487
104543
|
packageSkills: () => packageSkills
|
|
104488
104544
|
});
|
|
104489
104545
|
import { readdir as readdir10, readFile as readFile11 } from "node:fs/promises";
|
|
104490
|
-
import { relative as relative8, resolve as
|
|
104546
|
+
import { relative as relative8, resolve as resolve28 } from "node:path";
|
|
104491
104547
|
async function packageSkills(agentId, skillsDir) {
|
|
104492
104548
|
const skills = [];
|
|
104493
104549
|
const skillNames = new Set;
|
|
104494
104550
|
const dirsToCheck = skillsDir ? [skillsDir] : [
|
|
104495
104551
|
agentId && getAgentSkillsDir(agentId),
|
|
104496
|
-
|
|
104497
|
-
|
|
104552
|
+
resolve28(process.cwd(), ".skills"),
|
|
104553
|
+
resolve28(process.env.HOME || "~", ".letta", "skills")
|
|
104498
104554
|
].filter((dir) => Boolean(dir));
|
|
104499
104555
|
for (const baseDir of dirsToCheck) {
|
|
104500
104556
|
try {
|
|
@@ -104504,8 +104560,8 @@ async function packageSkills(agentId, skillsDir) {
|
|
|
104504
104560
|
continue;
|
|
104505
104561
|
if (skillNames.has(entry.name))
|
|
104506
104562
|
continue;
|
|
104507
|
-
const skillDir =
|
|
104508
|
-
const skillMdPath =
|
|
104563
|
+
const skillDir = resolve28(baseDir, entry.name);
|
|
104564
|
+
const skillMdPath = resolve28(skillDir, "SKILL.md");
|
|
104509
104565
|
try {
|
|
104510
104566
|
await readFile11(skillMdPath, "utf-8");
|
|
104511
104567
|
} catch {
|
|
@@ -104535,7 +104591,7 @@ async function readSkillFiles(skillDir) {
|
|
|
104535
104591
|
async function walk(dir) {
|
|
104536
104592
|
const entries = await readdir10(dir, { withFileTypes: true });
|
|
104537
104593
|
for (const entry of entries) {
|
|
104538
|
-
const fullPath =
|
|
104594
|
+
const fullPath = resolve28(dir, entry.name);
|
|
104539
104595
|
if (entry.isDirectory()) {
|
|
104540
104596
|
await walk(fullPath);
|
|
104541
104597
|
} else {
|
|
@@ -104676,7 +104732,7 @@ __export(exports_App, {
|
|
|
104676
104732
|
default: () => App2
|
|
104677
104733
|
});
|
|
104678
104734
|
import { existsSync as existsSync22, readFileSync as readFileSync8, renameSync as renameSync2, writeFileSync as writeFileSync11 } from "node:fs";
|
|
104679
|
-
import { homedir as
|
|
104735
|
+
import { homedir as homedir24, tmpdir as tmpdir5 } from "node:os";
|
|
104680
104736
|
import { join as join35 } from "node:path";
|
|
104681
104737
|
function deriveReasoningEffort(modelSettings, llmConfig) {
|
|
104682
104738
|
if (modelSettings && "provider_type" in modelSettings) {
|
|
@@ -106526,7 +106582,7 @@ ${newState.originalPrompt}`
|
|
|
106526
106582
|
cancelled = true;
|
|
106527
106583
|
break;
|
|
106528
106584
|
}
|
|
106529
|
-
await new Promise((
|
|
106585
|
+
await new Promise((resolve29) => setTimeout(resolve29, 100));
|
|
106530
106586
|
}
|
|
106531
106587
|
buffersRef.current.byId.delete(statusId);
|
|
106532
106588
|
buffersRef.current.order = buffersRef.current.order.filter((id) => id !== statusId);
|
|
@@ -106557,7 +106613,7 @@ ${newState.originalPrompt}`
|
|
|
106557
106613
|
cancelled = true;
|
|
106558
106614
|
break;
|
|
106559
106615
|
}
|
|
106560
|
-
await new Promise((
|
|
106616
|
+
await new Promise((resolve29) => setTimeout(resolve29, 100));
|
|
106561
106617
|
}
|
|
106562
106618
|
buffersRef.current.byId.delete(statusId);
|
|
106563
106619
|
buffersRef.current.order = buffersRef.current.order.filter((id) => id !== statusId);
|
|
@@ -107239,7 +107295,7 @@ ${feedback}
|
|
|
107239
107295
|
cancelled = true;
|
|
107240
107296
|
break;
|
|
107241
107297
|
}
|
|
107242
|
-
await new Promise((
|
|
107298
|
+
await new Promise((resolve29) => setTimeout(resolve29, 100));
|
|
107243
107299
|
}
|
|
107244
107300
|
buffersRef.current.byId.delete(statusId);
|
|
107245
107301
|
buffersRef.current.order = buffersRef.current.order.filter((id) => id !== statusId);
|
|
@@ -111334,7 +111390,7 @@ ${guidance}`);
|
|
|
111334
111390
|
}
|
|
111335
111391
|
if (!planFileExists()) {
|
|
111336
111392
|
const planFilePath = permissionMode.getPlanFilePath();
|
|
111337
|
-
const plansDir = join35(
|
|
111393
|
+
const plansDir = join35(homedir24(), ".letta", "plans");
|
|
111338
111394
|
handlePlanKeepPlanning(`You must write your plan to a plan file before exiting plan mode.
|
|
111339
111395
|
` + (planFilePath ? `Plan file path: ${planFilePath}
|
|
111340
111396
|
` : "") + `Use a write tool to create your plan in ${plansDir}, then use ExitPlanMode to present the plan to the user.`);
|
|
@@ -112646,7 +112702,7 @@ import {
|
|
|
112646
112702
|
readFileSync as readFileSync9,
|
|
112647
112703
|
writeFileSync as writeFileSync12
|
|
112648
112704
|
} from "node:fs";
|
|
112649
|
-
import { homedir as
|
|
112705
|
+
import { homedir as homedir25, platform as platform5 } from "node:os";
|
|
112650
112706
|
import { dirname as dirname14, join as join36 } from "node:path";
|
|
112651
112707
|
function detectTerminalType2() {
|
|
112652
112708
|
if (process.env.CURSOR_TRACE_ID || process.env.CURSOR_CHANNEL) {
|
|
@@ -112679,7 +112735,7 @@ function getKeybindingsPath2(terminal) {
|
|
|
112679
112735
|
}[terminal];
|
|
112680
112736
|
const os6 = platform5();
|
|
112681
112737
|
if (os6 === "darwin") {
|
|
112682
|
-
return join36(
|
|
112738
|
+
return join36(homedir25(), "Library", "Application Support", appName, "User", "keybindings.json");
|
|
112683
112739
|
}
|
|
112684
112740
|
if (os6 === "win32") {
|
|
112685
112741
|
const appData = process.env.APPDATA;
|
|
@@ -112688,7 +112744,7 @@ function getKeybindingsPath2(terminal) {
|
|
|
112688
112744
|
return join36(appData, appName, "User", "keybindings.json");
|
|
112689
112745
|
}
|
|
112690
112746
|
if (os6 === "linux") {
|
|
112691
|
-
return join36(
|
|
112747
|
+
return join36(homedir25(), ".config", appName, "User", "keybindings.json");
|
|
112692
112748
|
}
|
|
112693
112749
|
return null;
|
|
112694
112750
|
}
|
|
@@ -112845,10 +112901,10 @@ function getWezTermConfigPath2() {
|
|
|
112845
112901
|
if (existsSync23(xdgPath))
|
|
112846
112902
|
return xdgPath;
|
|
112847
112903
|
}
|
|
112848
|
-
const configPath = join36(
|
|
112904
|
+
const configPath = join36(homedir25(), ".config", "wezterm", "wezterm.lua");
|
|
112849
112905
|
if (existsSync23(configPath))
|
|
112850
112906
|
return configPath;
|
|
112851
|
-
return join36(
|
|
112907
|
+
return join36(homedir25(), ".wezterm.lua");
|
|
112852
112908
|
}
|
|
112853
112909
|
function wezTermDeleteFixExists2(configPath) {
|
|
112854
112910
|
if (!existsSync23(configPath))
|
|
@@ -112946,10 +113002,10 @@ __export(exports_settings2, {
|
|
|
112946
113002
|
loadProjectSettings: () => loadProjectSettings2,
|
|
112947
113003
|
getSetting: () => getSetting2
|
|
112948
113004
|
});
|
|
112949
|
-
import { homedir as
|
|
113005
|
+
import { homedir as homedir26 } from "node:os";
|
|
112950
113006
|
import { join as join37 } from "node:path";
|
|
112951
113007
|
function getSettingsPath2() {
|
|
112952
|
-
return join37(
|
|
113008
|
+
return join37(homedir26(), ".letta", "settings.json");
|
|
112953
113009
|
}
|
|
112954
113010
|
async function loadSettings2() {
|
|
112955
113011
|
const settingsPath = getSettingsPath2();
|
|
@@ -113431,10 +113487,10 @@ __export(exports_import2, {
|
|
|
113431
113487
|
});
|
|
113432
113488
|
import { createReadStream as createReadStream2 } from "node:fs";
|
|
113433
113489
|
import { chmod as chmod2, mkdir as mkdir4, readFile as readFile12, writeFile as writeFile4 } from "node:fs/promises";
|
|
113434
|
-
import { dirname as dirname15, resolve as
|
|
113490
|
+
import { dirname as dirname15, resolve as resolve29 } from "node:path";
|
|
113435
113491
|
async function importAgentFromFile2(options) {
|
|
113436
113492
|
const client = await getClient2();
|
|
113437
|
-
const resolvedPath =
|
|
113493
|
+
const resolvedPath = resolve29(options.filePath);
|
|
113438
113494
|
const file = createReadStream2(resolvedPath);
|
|
113439
113495
|
const importResponse = await client.agents.importFile({
|
|
113440
113496
|
file,
|
|
@@ -113469,7 +113525,7 @@ async function extractSkillsFromAf2(afPath, destDir) {
|
|
|
113469
113525
|
return [];
|
|
113470
113526
|
}
|
|
113471
113527
|
for (const skill2 of afData.skills) {
|
|
113472
|
-
const skillDir =
|
|
113528
|
+
const skillDir = resolve29(destDir, skill2.name);
|
|
113473
113529
|
await mkdir4(skillDir, { recursive: true });
|
|
113474
113530
|
if (skill2.files) {
|
|
113475
113531
|
await writeSkillFiles2(skillDir, skill2.files);
|
|
@@ -113489,7 +113545,7 @@ async function writeSkillFiles2(skillDir, files) {
|
|
|
113489
113545
|
}
|
|
113490
113546
|
}
|
|
113491
113547
|
async function writeSkillFile2(skillDir, filePath, content) {
|
|
113492
|
-
const fullPath =
|
|
113548
|
+
const fullPath = resolve29(skillDir, filePath);
|
|
113493
113549
|
await mkdir4(dirname15(fullPath), { recursive: true });
|
|
113494
113550
|
await writeFile4(fullPath, content, "utf-8");
|
|
113495
113551
|
const isScript = filePath.startsWith("scripts/") || content.trimStart().startsWith("#!");
|
|
@@ -113596,15 +113652,15 @@ __export(exports_memoryFilesystem2, {
|
|
|
113596
113652
|
MEMORY_FS_AGENTS_DIR: () => MEMORY_FS_AGENTS_DIR2
|
|
113597
113653
|
});
|
|
113598
113654
|
import { existsSync as existsSync24, mkdirSync as mkdirSync15 } from "node:fs";
|
|
113599
|
-
import { homedir as
|
|
113655
|
+
import { homedir as homedir27 } from "node:os";
|
|
113600
113656
|
import { join as join38 } from "node:path";
|
|
113601
|
-
function getMemoryFilesystemRoot2(agentId, homeDir =
|
|
113657
|
+
function getMemoryFilesystemRoot2(agentId, homeDir = homedir27()) {
|
|
113602
113658
|
return join38(homeDir, MEMORY_FS_ROOT2, MEMORY_FS_AGENTS_DIR2, agentId, MEMORY_FS_MEMORY_DIR2);
|
|
113603
113659
|
}
|
|
113604
|
-
function getMemorySystemDir2(agentId, homeDir =
|
|
113660
|
+
function getMemorySystemDir2(agentId, homeDir = homedir27()) {
|
|
113605
113661
|
return join38(getMemoryFilesystemRoot2(agentId, homeDir), MEMORY_SYSTEM_DIR2);
|
|
113606
113662
|
}
|
|
113607
|
-
function ensureMemoryFilesystemDirs2(agentId, homeDir =
|
|
113663
|
+
function ensureMemoryFilesystemDirs2(agentId, homeDir = homedir27()) {
|
|
113608
113664
|
const root = getMemoryFilesystemRoot2(agentId, homeDir);
|
|
113609
113665
|
const systemDir = getMemorySystemDir2(agentId, homeDir);
|
|
113610
113666
|
if (!existsSync24(root)) {
|
|
@@ -113985,8 +114041,9 @@ async function fetchConversationBackfillMessages(client, conversationId) {
|
|
|
113985
114041
|
}
|
|
113986
114042
|
return sortChronological(collected);
|
|
113987
114043
|
}
|
|
113988
|
-
async function getResumeData(client, agent, conversationId) {
|
|
114044
|
+
async function getResumeData(client, agent, conversationId, options = {}) {
|
|
113989
114045
|
try {
|
|
114046
|
+
const includeMessageHistory = options.includeMessageHistory ?? true;
|
|
113990
114047
|
let inContextMessageIds;
|
|
113991
114048
|
let messages = [];
|
|
113992
114049
|
const useConversationsApi = conversationId && conversationId !== "default";
|
|
@@ -113998,7 +114055,7 @@ async function getResumeData(client, agent, conversationId) {
|
|
|
113998
114055
|
inContextMessageIds = conversation.in_context_message_ids;
|
|
113999
114056
|
if (!inContextMessageIds || inContextMessageIds.length === 0) {
|
|
114000
114057
|
debugWarn("check-approval", "No in-context messages - no pending approvals");
|
|
114001
|
-
if (isBackfillEnabled()) {
|
|
114058
|
+
if (includeMessageHistory && isBackfillEnabled()) {
|
|
114002
114059
|
try {
|
|
114003
114060
|
const backfill = await fetchConversationBackfillMessages(client, conversationId);
|
|
114004
114061
|
return {
|
|
@@ -114023,7 +114080,7 @@ async function getResumeData(client, agent, conversationId) {
|
|
|
114023
114080
|
throw new Error("Expected at least one in-context message");
|
|
114024
114081
|
}
|
|
114025
114082
|
const retrievedMessages = await client.messages.retrieve(lastInContextId);
|
|
114026
|
-
if (isBackfillEnabled()) {
|
|
114083
|
+
if (includeMessageHistory && isBackfillEnabled()) {
|
|
114027
114084
|
try {
|
|
114028
114085
|
messages = await fetchConversationBackfillMessages(client, conversationId);
|
|
114029
114086
|
} catch (backfillError) {
|
|
@@ -114066,7 +114123,7 @@ async function getResumeData(client, agent, conversationId) {
|
|
|
114066
114123
|
throw new Error("Expected at least one in-context message");
|
|
114067
114124
|
}
|
|
114068
114125
|
const retrievedMessages = await client.messages.retrieve(lastInContextId);
|
|
114069
|
-
if (isBackfillEnabled()) {
|
|
114126
|
+
if (includeMessageHistory && isBackfillEnabled()) {
|
|
114070
114127
|
try {
|
|
114071
114128
|
const messagesPage = await client.agents.messages.list(agent.id, {
|
|
114072
114129
|
limit: BACKFILL_PAGE_LIMIT,
|
|
@@ -116070,7 +116127,7 @@ async function runListenSubcommand(argv) {
|
|
|
116070
116127
|
await init_memoryGit();
|
|
116071
116128
|
import { cpSync, existsSync as existsSync9, mkdirSync as mkdirSync7, rmSync as rmSync2, statSync as statSync2 } from "node:fs";
|
|
116072
116129
|
import { readdir as readdir5 } from "node:fs/promises";
|
|
116073
|
-
import { homedir as
|
|
116130
|
+
import { homedir as homedir13 } from "node:os";
|
|
116074
116131
|
import { join as join16 } from "node:path";
|
|
116075
116132
|
import { parseArgs as parseArgs4 } from "node:util";
|
|
116076
116133
|
function printUsage3() {
|
|
@@ -116100,10 +116157,10 @@ function getAgentId3(agentFromArgs, agentIdFromArgs) {
|
|
|
116100
116157
|
return agentFromArgs || agentIdFromArgs || process.env.LETTA_AGENT_ID || "";
|
|
116101
116158
|
}
|
|
116102
116159
|
function getMemoryRoot(agentId) {
|
|
116103
|
-
return join16(
|
|
116160
|
+
return join16(homedir13(), ".letta", "agents", agentId, "memory");
|
|
116104
116161
|
}
|
|
116105
116162
|
function getAgentRoot(agentId) {
|
|
116106
|
-
return join16(
|
|
116163
|
+
return join16(homedir13(), ".letta", "agents", agentId);
|
|
116107
116164
|
}
|
|
116108
116165
|
function formatBackupTimestamp(date = new Date) {
|
|
116109
116166
|
const pad = (value) => String(value).padStart(2, "0");
|
|
@@ -116478,8 +116535,8 @@ async function runSubcommand(argv) {
|
|
|
116478
116535
|
|
|
116479
116536
|
// src/permissions/mode.ts
|
|
116480
116537
|
init_readOnlyShell();
|
|
116481
|
-
import { homedir as
|
|
116482
|
-
import { isAbsolute as isAbsolute14, join as join17, relative as relative3, resolve as
|
|
116538
|
+
import { homedir as homedir14 } from "node:os";
|
|
116539
|
+
import { isAbsolute as isAbsolute14, join as join17, relative as relative3, resolve as resolve21 } from "node:path";
|
|
116483
116540
|
var MODE_KEY2 = Symbol.for("@letta/permissionMode");
|
|
116484
116541
|
var PLAN_FILE_KEY2 = Symbol.for("@letta/planFilePath");
|
|
116485
116542
|
var MODE_BEFORE_PLAN_KEY2 = Symbol.for("@letta/permissionModeBeforePlan");
|
|
@@ -116515,12 +116572,12 @@ function resolvePlanTargetPath2(targetPath, workingDirectory) {
|
|
|
116515
116572
|
if (!trimmedPath)
|
|
116516
116573
|
return null;
|
|
116517
116574
|
if (trimmedPath.startsWith("~/")) {
|
|
116518
|
-
return
|
|
116575
|
+
return resolve21(homedir14(), trimmedPath.slice(2));
|
|
116519
116576
|
}
|
|
116520
116577
|
if (isAbsolute14(trimmedPath)) {
|
|
116521
|
-
return
|
|
116578
|
+
return resolve21(trimmedPath);
|
|
116522
116579
|
}
|
|
116523
|
-
return
|
|
116580
|
+
return resolve21(workingDirectory, trimmedPath);
|
|
116524
116581
|
}
|
|
116525
116582
|
function isPathInPlansDir2(path19, plansDir) {
|
|
116526
116583
|
if (!path19.endsWith(".md"))
|
|
@@ -116641,7 +116698,7 @@ class PermissionModeManager2 {
|
|
|
116641
116698
|
return "allow";
|
|
116642
116699
|
}
|
|
116643
116700
|
if (writeTools.includes(toolName)) {
|
|
116644
|
-
const plansDir = join17(
|
|
116701
|
+
const plansDir = join17(homedir14(), ".letta", "plans");
|
|
116645
116702
|
const targetPath = toolArgs?.file_path || toolArgs?.path;
|
|
116646
116703
|
let candidatePaths = [];
|
|
116647
116704
|
if ((toolName === "ApplyPatch" || toolName === "apply_patch") && toolArgs?.input) {
|
|
@@ -116712,8 +116769,8 @@ init_debug();
|
|
|
116712
116769
|
init_fs();
|
|
116713
116770
|
await init_secrets();
|
|
116714
116771
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
116715
|
-
import { homedir as
|
|
116716
|
-
import { join as join18 } from "node:path";
|
|
116772
|
+
import { homedir as homedir15 } from "node:os";
|
|
116773
|
+
import { join as join18, resolve as resolve22 } from "node:path";
|
|
116717
116774
|
var DEFAULT_SETTINGS2 = {
|
|
116718
116775
|
lastAgent: null,
|
|
116719
116776
|
tokenStreaming: false,
|
|
@@ -116993,6 +117050,11 @@ class SettingsManager2 {
|
|
|
116993
117050
|
}
|
|
116994
117051
|
}
|
|
116995
117052
|
async loadProjectSettings(workingDirectory = process.cwd()) {
|
|
117053
|
+
if (this.isProjectSettingsPathCollidingWithGlobal(workingDirectory)) {
|
|
117054
|
+
const defaults4 = { ...DEFAULT_PROJECT_SETTINGS2 };
|
|
117055
|
+
this.projectSettings.set(workingDirectory, defaults4);
|
|
117056
|
+
return defaults4;
|
|
117057
|
+
}
|
|
116996
117058
|
const cached = this.projectSettings.get(workingDirectory);
|
|
116997
117059
|
if (cached) {
|
|
116998
117060
|
return { ...cached };
|
|
@@ -117028,6 +117090,19 @@ class SettingsManager2 {
|
|
|
117028
117090
|
return { ...cached };
|
|
117029
117091
|
}
|
|
117030
117092
|
updateProjectSettings(updates, workingDirectory = process.cwd()) {
|
|
117093
|
+
if (this.isProjectSettingsPathCollidingWithGlobal(workingDirectory)) {
|
|
117094
|
+
const globalUpdates = {};
|
|
117095
|
+
if ("hooks" in updates) {
|
|
117096
|
+
globalUpdates.hooks = updates.hooks;
|
|
117097
|
+
}
|
|
117098
|
+
if ("statusLine" in updates) {
|
|
117099
|
+
globalUpdates.statusLine = updates.statusLine;
|
|
117100
|
+
}
|
|
117101
|
+
if (Object.keys(globalUpdates).length > 0) {
|
|
117102
|
+
this.updateSettings(globalUpdates);
|
|
117103
|
+
}
|
|
117104
|
+
return;
|
|
117105
|
+
}
|
|
117031
117106
|
const current = this.projectSettings.get(workingDirectory);
|
|
117032
117107
|
if (!current) {
|
|
117033
117108
|
throw new Error(`Project settings for ${workingDirectory} not loaded. Call loadProjectSettings() first.`);
|
|
@@ -117045,7 +117120,7 @@ class SettingsManager2 {
|
|
|
117045
117120
|
if (!this.settings)
|
|
117046
117121
|
return;
|
|
117047
117122
|
const settingsPath = this.getSettingsPath();
|
|
117048
|
-
const home = process.env.HOME ||
|
|
117123
|
+
const home = process.env.HOME || homedir15();
|
|
117049
117124
|
const dirPath = join18(home, ".letta");
|
|
117050
117125
|
try {
|
|
117051
117126
|
if (!exists(dirPath)) {
|
|
@@ -117074,6 +117149,9 @@ class SettingsManager2 {
|
|
|
117074
117149
|
}
|
|
117075
117150
|
}
|
|
117076
117151
|
async persistProjectSettings(workingDirectory) {
|
|
117152
|
+
if (this.isProjectSettingsPathCollidingWithGlobal(workingDirectory)) {
|
|
117153
|
+
return;
|
|
117154
|
+
}
|
|
117077
117155
|
const settings = this.projectSettings.get(workingDirectory);
|
|
117078
117156
|
if (!settings)
|
|
117079
117157
|
return;
|
|
@@ -117099,12 +117177,15 @@ class SettingsManager2 {
|
|
|
117099
117177
|
}
|
|
117100
117178
|
}
|
|
117101
117179
|
getSettingsPath() {
|
|
117102
|
-
const home = process.env.HOME ||
|
|
117180
|
+
const home = process.env.HOME || homedir15();
|
|
117103
117181
|
return join18(home, ".letta", "settings.json");
|
|
117104
117182
|
}
|
|
117105
117183
|
getProjectSettingsPath(workingDirectory) {
|
|
117106
117184
|
return join18(workingDirectory, ".letta", "settings.json");
|
|
117107
117185
|
}
|
|
117186
|
+
isProjectSettingsPathCollidingWithGlobal(workingDirectory) {
|
|
117187
|
+
return resolve22(this.getProjectSettingsPath(workingDirectory)) === resolve22(this.getSettingsPath());
|
|
117188
|
+
}
|
|
117108
117189
|
getLocalProjectSettingsPath(workingDirectory) {
|
|
117109
117190
|
return join18(workingDirectory, ".letta", "settings.local.json");
|
|
117110
117191
|
}
|
|
@@ -117897,8 +117978,8 @@ function acquireSwitchLock2() {
|
|
|
117897
117978
|
const lock = getSwitchLock2();
|
|
117898
117979
|
lock.refCount++;
|
|
117899
117980
|
if (lock.refCount === 1) {
|
|
117900
|
-
lock.promise = new Promise((
|
|
117901
|
-
lock.resolve =
|
|
117981
|
+
lock.promise = new Promise((resolve23) => {
|
|
117982
|
+
lock.resolve = resolve23;
|
|
117902
117983
|
});
|
|
117903
117984
|
}
|
|
117904
117985
|
}
|
|
@@ -118408,7 +118489,7 @@ Note: Flags should use double dashes for full names (e.g., --yolo, not -yolo)`);
|
|
|
118408
118489
|
printHelp();
|
|
118409
118490
|
const helpDelayMs = Number.parseInt(process.env.LETTA_TEST_HELP_EXIT_DELAY_MS ?? "", 10);
|
|
118410
118491
|
if (Number.isFinite(helpDelayMs) && helpDelayMs > 0) {
|
|
118411
|
-
await new Promise((
|
|
118492
|
+
await new Promise((resolve30) => setTimeout(resolve30, helpDelayMs));
|
|
118412
118493
|
}
|
|
118413
118494
|
process.exit(0);
|
|
118414
118495
|
}
|
|
@@ -118623,9 +118704,9 @@ Note: Flags should use double dashes for full names (e.g., --yolo, not -yolo)`);
|
|
|
118623
118704
|
process.exit(1);
|
|
118624
118705
|
}
|
|
118625
118706
|
} else {
|
|
118626
|
-
const { resolve:
|
|
118707
|
+
const { resolve: resolve30 } = await import("path");
|
|
118627
118708
|
const { existsSync: existsSync25 } = await import("fs");
|
|
118628
|
-
const resolvedPath =
|
|
118709
|
+
const resolvedPath = resolve30(fromAfFile);
|
|
118629
118710
|
if (!existsSync25(resolvedPath)) {
|
|
118630
118711
|
console.error(`Error: AgentFile not found: ${resolvedPath}`);
|
|
118631
118712
|
process.exit(1);
|
|
@@ -119493,4 +119574,4 @@ Error during initialization: ${message}`);
|
|
|
119493
119574
|
}
|
|
119494
119575
|
main();
|
|
119495
119576
|
|
|
119496
|
-
//# debugId=
|
|
119577
|
+
//# debugId=8C35AC90E5DBC3BE64756E2164756E21
|