@letta-ai/letta-code 0.16.8 → 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 +280 -214
- 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);
|
|
@@ -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
|
}
|
|
@@ -68580,7 +68607,7 @@ import {
|
|
|
68580
68607
|
unlinkSync as unlinkSync3,
|
|
68581
68608
|
writeFileSync as writeFileSync5
|
|
68582
68609
|
} from "node:fs";
|
|
68583
|
-
import { homedir as
|
|
68610
|
+
import { homedir as homedir12 } from "node:os";
|
|
68584
68611
|
import { join as join15 } from "node:path";
|
|
68585
68612
|
function truncateStr(value, maxLen) {
|
|
68586
68613
|
if (value === null || value === undefined)
|
|
@@ -68721,7 +68748,7 @@ class ChunkLog {
|
|
|
68721
68748
|
var MAX_ENTRIES = 100, CONTENT_TRUNCATE_LEN = 200, MAX_SESSION_FILES = 5, LOG_BASE_DIR, chunkLog;
|
|
68722
68749
|
var init_chunkLog = __esm(() => {
|
|
68723
68750
|
init_debug();
|
|
68724
|
-
LOG_BASE_DIR = join15(
|
|
68751
|
+
LOG_BASE_DIR = join15(homedir12(), ".letta", "logs", "chunk-logs");
|
|
68725
68752
|
chunkLog = new ChunkLog;
|
|
68726
68753
|
});
|
|
68727
68754
|
|
|
@@ -69167,8 +69194,8 @@ async function connectWithRetry(runtime, opts, attempt = 0, startTime = Date.now
|
|
|
69167
69194
|
const delay = Math.min(INITIAL_RETRY_DELAY_MS * 2 ** (attempt - 1), MAX_RETRY_DELAY_MS);
|
|
69168
69195
|
const maxAttempts = Math.ceil(Math.log2(MAX_RETRY_DURATION_MS / INITIAL_RETRY_DELAY_MS));
|
|
69169
69196
|
opts.onRetrying?.(attempt, maxAttempts, delay);
|
|
69170
|
-
await new Promise((
|
|
69171
|
-
runtime.reconnectTimeout = setTimeout(
|
|
69197
|
+
await new Promise((resolve21) => {
|
|
69198
|
+
runtime.reconnectTimeout = setTimeout(resolve21, delay);
|
|
69172
69199
|
});
|
|
69173
69200
|
runtime.reconnectTimeout = null;
|
|
69174
69201
|
if (runtime !== activeRuntime || runtime.intentionallyClosed) {
|
|
@@ -69704,7 +69731,7 @@ async function queryTerminalBackground(timeoutMs = 100) {
|
|
|
69704
69731
|
}
|
|
69705
69732
|
const wasRaw = process.stdin.isRaw;
|
|
69706
69733
|
const wasFlowing = process.stdin.readableFlowing;
|
|
69707
|
-
return new Promise((
|
|
69734
|
+
return new Promise((resolve23) => {
|
|
69708
69735
|
let response = "";
|
|
69709
69736
|
let resolved = false;
|
|
69710
69737
|
const cleanup = () => {
|
|
@@ -69721,7 +69748,7 @@ async function queryTerminalBackground(timeoutMs = 100) {
|
|
|
69721
69748
|
};
|
|
69722
69749
|
const timeout = setTimeout(() => {
|
|
69723
69750
|
cleanup();
|
|
69724
|
-
|
|
69751
|
+
resolve23(null);
|
|
69725
69752
|
}, timeoutMs);
|
|
69726
69753
|
const onData = (data) => {
|
|
69727
69754
|
response += data.toString();
|
|
@@ -69731,7 +69758,7 @@ async function queryTerminalBackground(timeoutMs = 100) {
|
|
|
69731
69758
|
if (match3) {
|
|
69732
69759
|
clearTimeout(timeout);
|
|
69733
69760
|
cleanup();
|
|
69734
|
-
|
|
69761
|
+
resolve23({
|
|
69735
69762
|
r: parseHexComponent(match3[1] ?? "0"),
|
|
69736
69763
|
g: parseHexComponent(match3[2] ?? "0"),
|
|
69737
69764
|
b: parseHexComponent(match3[3] ?? "0")
|
|
@@ -69746,7 +69773,7 @@ async function queryTerminalBackground(timeoutMs = 100) {
|
|
|
69746
69773
|
} catch {
|
|
69747
69774
|
clearTimeout(timeout);
|
|
69748
69775
|
cleanup();
|
|
69749
|
-
|
|
69776
|
+
resolve23(null);
|
|
69750
69777
|
}
|
|
69751
69778
|
});
|
|
69752
69779
|
}
|
|
@@ -71126,14 +71153,14 @@ var execFile9, __dirname2, localXdgOpenPath, platform2, arch, pTryEach = async (
|
|
|
71126
71153
|
}
|
|
71127
71154
|
const subprocess = childProcess.spawn(command, cliArguments, childProcessOptions);
|
|
71128
71155
|
if (options.wait) {
|
|
71129
|
-
return new Promise((
|
|
71156
|
+
return new Promise((resolve24, reject) => {
|
|
71130
71157
|
subprocess.once("error", reject);
|
|
71131
71158
|
subprocess.once("close", (exitCode) => {
|
|
71132
71159
|
if (!options.allowNonzeroExitCode && exitCode > 0) {
|
|
71133
71160
|
reject(new Error(`Exited with code ${exitCode}`));
|
|
71134
71161
|
return;
|
|
71135
71162
|
}
|
|
71136
|
-
|
|
71163
|
+
resolve24(subprocess);
|
|
71137
71164
|
});
|
|
71138
71165
|
});
|
|
71139
71166
|
}
|
|
@@ -71431,10 +71458,10 @@ __export(exports_setup, {
|
|
|
71431
71458
|
runSetup: () => runSetup
|
|
71432
71459
|
});
|
|
71433
71460
|
async function runSetup() {
|
|
71434
|
-
return new Promise((
|
|
71461
|
+
return new Promise((resolve24) => {
|
|
71435
71462
|
const { waitUntilExit } = render_default(import_react30.default.createElement(SetupUI, {
|
|
71436
71463
|
onComplete: () => {
|
|
71437
|
-
|
|
71464
|
+
resolve24();
|
|
71438
71465
|
}
|
|
71439
71466
|
}));
|
|
71440
71467
|
waitUntilExit().catch((error) => {
|
|
@@ -73470,10 +73497,10 @@ __export(exports_import, {
|
|
|
73470
73497
|
});
|
|
73471
73498
|
import { createReadStream } from "node:fs";
|
|
73472
73499
|
import { chmod, mkdir as mkdir3, readFile as readFile8, writeFile as writeFile3 } from "node:fs/promises";
|
|
73473
|
-
import { dirname as dirname10, resolve as
|
|
73500
|
+
import { dirname as dirname10, resolve as resolve24 } from "node:path";
|
|
73474
73501
|
async function importAgentFromFile(options) {
|
|
73475
73502
|
const client = await getClient2();
|
|
73476
|
-
const resolvedPath =
|
|
73503
|
+
const resolvedPath = resolve24(options.filePath);
|
|
73477
73504
|
const file = createReadStream(resolvedPath);
|
|
73478
73505
|
const importResponse = await client.agents.importFile({
|
|
73479
73506
|
file,
|
|
@@ -73508,7 +73535,7 @@ async function extractSkillsFromAf(afPath, destDir) {
|
|
|
73508
73535
|
return [];
|
|
73509
73536
|
}
|
|
73510
73537
|
for (const skill2 of afData.skills) {
|
|
73511
|
-
const skillDir =
|
|
73538
|
+
const skillDir = resolve24(destDir, skill2.name);
|
|
73512
73539
|
await mkdir3(skillDir, { recursive: true });
|
|
73513
73540
|
if (skill2.files) {
|
|
73514
73541
|
await writeSkillFiles(skillDir, skill2.files);
|
|
@@ -73528,7 +73555,7 @@ async function writeSkillFiles(skillDir, files) {
|
|
|
73528
73555
|
}
|
|
73529
73556
|
}
|
|
73530
73557
|
async function writeSkillFile(skillDir, filePath, content) {
|
|
73531
|
-
const fullPath =
|
|
73558
|
+
const fullPath = resolve24(skillDir, filePath);
|
|
73532
73559
|
await mkdir3(dirname10(fullPath), { recursive: true });
|
|
73533
73560
|
await writeFile3(fullPath, content, "utf-8");
|
|
73534
73561
|
const isScript = filePath.startsWith("scripts/") || content.trimStart().startsWith("#!");
|
|
@@ -74639,7 +74666,7 @@ ${loadedContents.join(`
|
|
|
74639
74666
|
} else {
|
|
74640
74667
|
console.error(`Conversation is busy, waiting ${CONVERSATION_BUSY_RETRY_DELAY_MS / 1000}s and retrying...`);
|
|
74641
74668
|
}
|
|
74642
|
-
await new Promise((
|
|
74669
|
+
await new Promise((resolve25) => setTimeout(resolve25, CONVERSATION_BUSY_RETRY_DELAY_MS));
|
|
74643
74670
|
continue;
|
|
74644
74671
|
}
|
|
74645
74672
|
if (preStreamAction === "retry_transient") {
|
|
@@ -74662,7 +74689,7 @@ ${loadedContents.join(`
|
|
|
74662
74689
|
const delaySeconds = Math.round(delayMs / 1000);
|
|
74663
74690
|
console.error(`Transient API error before streaming (attempt ${attempt} of ${LLM_API_ERROR_MAX_RETRIES}), retrying in ${delaySeconds}s...`);
|
|
74664
74691
|
}
|
|
74665
|
-
await new Promise((
|
|
74692
|
+
await new Promise((resolve25) => setTimeout(resolve25, delayMs));
|
|
74666
74693
|
conversationBusyRetries = 0;
|
|
74667
74694
|
continue;
|
|
74668
74695
|
}
|
|
@@ -74875,7 +74902,7 @@ ${loadedContents.join(`
|
|
|
74875
74902
|
const delaySeconds = Math.round(delayMs / 1000);
|
|
74876
74903
|
console.error(`LLM API error encountered (attempt ${attempt} of ${LLM_API_ERROR_MAX_RETRIES}), retrying in ${delaySeconds}s...`);
|
|
74877
74904
|
}
|
|
74878
|
-
await new Promise((
|
|
74905
|
+
await new Promise((resolve25) => setTimeout(resolve25, delayMs));
|
|
74879
74906
|
continue;
|
|
74880
74907
|
}
|
|
74881
74908
|
}
|
|
@@ -74951,7 +74978,7 @@ ${loadedContents.join(`
|
|
|
74951
74978
|
const delaySeconds = Math.round(delayMs / 1000);
|
|
74952
74979
|
console.error(`LLM API error encountered (attempt ${attempt} of ${LLM_API_ERROR_MAX_RETRIES}), retrying in ${delaySeconds}s...`);
|
|
74953
74980
|
}
|
|
74954
|
-
await new Promise((
|
|
74981
|
+
await new Promise((resolve25) => setTimeout(resolve25, delayMs));
|
|
74955
74982
|
continue;
|
|
74956
74983
|
}
|
|
74957
74984
|
} catch (_e) {}
|
|
@@ -75185,18 +75212,18 @@ async function runBidirectionalMode(agent, conversationId, client, _outputFormat
|
|
|
75185
75212
|
setMessageQueueAdder((queuedMessage) => {
|
|
75186
75213
|
const syntheticUserLine = serializeQueuedMessageAsUserLine(queuedMessage);
|
|
75187
75214
|
if (lineResolver) {
|
|
75188
|
-
const
|
|
75215
|
+
const resolve25 = lineResolver;
|
|
75189
75216
|
lineResolver = null;
|
|
75190
|
-
|
|
75217
|
+
resolve25(syntheticUserLine);
|
|
75191
75218
|
return;
|
|
75192
75219
|
}
|
|
75193
75220
|
lineQueue.push(syntheticUserLine);
|
|
75194
75221
|
});
|
|
75195
75222
|
rl.on("line", (line) => {
|
|
75196
75223
|
if (lineResolver) {
|
|
75197
|
-
const
|
|
75224
|
+
const resolve25 = lineResolver;
|
|
75198
75225
|
lineResolver = null;
|
|
75199
|
-
|
|
75226
|
+
resolve25(line);
|
|
75200
75227
|
} else {
|
|
75201
75228
|
lineQueue.push(line);
|
|
75202
75229
|
}
|
|
@@ -75204,17 +75231,17 @@ async function runBidirectionalMode(agent, conversationId, client, _outputFormat
|
|
|
75204
75231
|
rl.on("close", () => {
|
|
75205
75232
|
setMessageQueueAdder(null);
|
|
75206
75233
|
if (lineResolver) {
|
|
75207
|
-
const
|
|
75234
|
+
const resolve25 = lineResolver;
|
|
75208
75235
|
lineResolver = null;
|
|
75209
|
-
|
|
75236
|
+
resolve25(null);
|
|
75210
75237
|
}
|
|
75211
75238
|
});
|
|
75212
75239
|
async function getNextLine() {
|
|
75213
75240
|
if (lineQueue.length > 0) {
|
|
75214
75241
|
return lineQueue.shift() ?? null;
|
|
75215
75242
|
}
|
|
75216
|
-
return new Promise((
|
|
75217
|
-
lineResolver =
|
|
75243
|
+
return new Promise((resolve25) => {
|
|
75244
|
+
lineResolver = resolve25;
|
|
75218
75245
|
});
|
|
75219
75246
|
}
|
|
75220
75247
|
async function requestPermission(toolCallId, toolName, toolInput) {
|
|
@@ -75577,7 +75604,7 @@ async function runBidirectionalMode(agent, conversationId, client, _outputFormat
|
|
|
75577
75604
|
uuid: `retry-bidir-${randomUUID7()}`
|
|
75578
75605
|
};
|
|
75579
75606
|
console.log(JSON.stringify(retryMsg));
|
|
75580
|
-
await new Promise((
|
|
75607
|
+
await new Promise((resolve25) => setTimeout(resolve25, delayMs));
|
|
75581
75608
|
continue;
|
|
75582
75609
|
}
|
|
75583
75610
|
throw preStreamError;
|
|
@@ -75849,10 +75876,10 @@ async function detectAndEnableKittyProtocol() {
|
|
|
75849
75876
|
detectionComplete = true;
|
|
75850
75877
|
return;
|
|
75851
75878
|
}
|
|
75852
|
-
return new Promise((
|
|
75879
|
+
return new Promise((resolve25) => {
|
|
75853
75880
|
if (!process.stdin.isTTY || !process.stdout.isTTY) {
|
|
75854
75881
|
detectionComplete = true;
|
|
75855
|
-
|
|
75882
|
+
resolve25();
|
|
75856
75883
|
return;
|
|
75857
75884
|
}
|
|
75858
75885
|
const originalRawMode = process.stdin.isRaw;
|
|
@@ -75885,7 +75912,7 @@ async function detectAndEnableKittyProtocol() {
|
|
|
75885
75912
|
console.error("[kitty] protocol query unsupported; enabled anyway (best-effort)");
|
|
75886
75913
|
}
|
|
75887
75914
|
detectionComplete = true;
|
|
75888
|
-
|
|
75915
|
+
resolve25();
|
|
75889
75916
|
};
|
|
75890
75917
|
const handleData = (data) => {
|
|
75891
75918
|
if (timeoutId === undefined) {
|
|
@@ -76078,10 +76105,10 @@ __export(exports_settings, {
|
|
|
76078
76105
|
loadProjectSettings: () => loadProjectSettings,
|
|
76079
76106
|
getSetting: () => getSetting
|
|
76080
76107
|
});
|
|
76081
|
-
import { homedir as
|
|
76108
|
+
import { homedir as homedir17 } from "node:os";
|
|
76082
76109
|
import { join as join24 } from "node:path";
|
|
76083
76110
|
function getSettingsPath() {
|
|
76084
|
-
return join24(
|
|
76111
|
+
return join24(homedir17(), ".letta", "settings.json");
|
|
76085
76112
|
}
|
|
76086
76113
|
async function loadSettings() {
|
|
76087
76114
|
const settingsPath = getSettingsPath();
|
|
@@ -81977,7 +82004,7 @@ var init_plan_viewer_template = () => {};
|
|
|
81977
82004
|
|
|
81978
82005
|
// src/web/generate-plan-viewer.ts
|
|
81979
82006
|
import { chmodSync as chmodSync2, existsSync as existsSync14, mkdirSync as mkdirSync10, writeFileSync as writeFileSync7 } from "node:fs";
|
|
81980
|
-
import { homedir as
|
|
82007
|
+
import { homedir as homedir18 } from "node:os";
|
|
81981
82008
|
import { join as join25 } from "node:path";
|
|
81982
82009
|
async function generateAndOpenPlanViewer(planContent, planFilePath, options) {
|
|
81983
82010
|
const data = {
|
|
@@ -82011,7 +82038,7 @@ async function generateAndOpenPlanViewer(planContent, planFilePath, options) {
|
|
|
82011
82038
|
var VIEWERS_DIR;
|
|
82012
82039
|
var init_generate_plan_viewer = __esm(() => {
|
|
82013
82040
|
init_plan_viewer_template();
|
|
82014
|
-
VIEWERS_DIR = join25(
|
|
82041
|
+
VIEWERS_DIR = join25(homedir18(), ".letta", "viewers");
|
|
82015
82042
|
});
|
|
82016
82043
|
|
|
82017
82044
|
// src/cli/components/StaticPlanApproval.tsx
|
|
@@ -84009,7 +84036,7 @@ var init_pasteRegistry = __esm(() => {
|
|
|
84009
84036
|
import { execFileSync as execFileSync2 } from "node:child_process";
|
|
84010
84037
|
import { existsSync as existsSync15, readFileSync as readFileSync3, statSync as statSync4, unlinkSync as unlinkSync5 } from "node:fs";
|
|
84011
84038
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
84012
|
-
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";
|
|
84013
84040
|
function countLines2(text) {
|
|
84014
84041
|
return (text.match(/\r\n|\r|\n/g) || []).length + 1;
|
|
84015
84042
|
}
|
|
@@ -84057,7 +84084,7 @@ function translatePasteForImages(paste) {
|
|
|
84057
84084
|
} catch {}
|
|
84058
84085
|
}
|
|
84059
84086
|
if (!isAbsolute16(filePath))
|
|
84060
|
-
filePath =
|
|
84087
|
+
filePath = resolve25(process.cwd(), filePath);
|
|
84061
84088
|
const ext3 = extname5(filePath || "").toLowerCase();
|
|
84062
84089
|
if (IMAGE_EXTS.has(ext3) && existsSync15(filePath) && statSync4(filePath).isFile()) {
|
|
84063
84090
|
const buf = readFileSync3(filePath);
|
|
@@ -84719,7 +84746,7 @@ import {
|
|
|
84719
84746
|
readFileSync as readFileSync4,
|
|
84720
84747
|
writeFileSync as writeFileSync8
|
|
84721
84748
|
} from "node:fs";
|
|
84722
|
-
import { homedir as
|
|
84749
|
+
import { homedir as homedir19, platform as platform4 } from "node:os";
|
|
84723
84750
|
import { dirname as dirname11, join as join27 } from "node:path";
|
|
84724
84751
|
function detectTerminalType() {
|
|
84725
84752
|
if (process.env.CURSOR_TRACE_ID || process.env.CURSOR_CHANNEL) {
|
|
@@ -84752,7 +84779,7 @@ function getKeybindingsPath(terminal) {
|
|
|
84752
84779
|
}[terminal];
|
|
84753
84780
|
const os5 = platform4();
|
|
84754
84781
|
if (os5 === "darwin") {
|
|
84755
|
-
return join27(
|
|
84782
|
+
return join27(homedir19(), "Library", "Application Support", appName, "User", "keybindings.json");
|
|
84756
84783
|
}
|
|
84757
84784
|
if (os5 === "win32") {
|
|
84758
84785
|
const appData = process.env.APPDATA;
|
|
@@ -84761,7 +84788,7 @@ function getKeybindingsPath(terminal) {
|
|
|
84761
84788
|
return join27(appData, appName, "User", "keybindings.json");
|
|
84762
84789
|
}
|
|
84763
84790
|
if (os5 === "linux") {
|
|
84764
|
-
return join27(
|
|
84791
|
+
return join27(homedir19(), ".config", appName, "User", "keybindings.json");
|
|
84765
84792
|
}
|
|
84766
84793
|
return null;
|
|
84767
84794
|
}
|
|
@@ -84918,10 +84945,10 @@ function getWezTermConfigPath() {
|
|
|
84918
84945
|
if (existsSync16(xdgPath))
|
|
84919
84946
|
return xdgPath;
|
|
84920
84947
|
}
|
|
84921
|
-
const configPath = join27(
|
|
84948
|
+
const configPath = join27(homedir19(), ".config", "wezterm", "wezterm.lua");
|
|
84922
84949
|
if (existsSync16(configPath))
|
|
84923
84950
|
return configPath;
|
|
84924
|
-
return join27(
|
|
84951
|
+
return join27(homedir19(), ".wezterm.lua");
|
|
84925
84952
|
}
|
|
84926
84953
|
function wezTermDeleteFixExists(configPath) {
|
|
84927
84954
|
if (!existsSync16(configPath))
|
|
@@ -85889,12 +85916,23 @@ var init_HelpDialog = __esm(async () => {
|
|
|
85889
85916
|
});
|
|
85890
85917
|
|
|
85891
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
|
+
}
|
|
85892
85927
|
function loadHooksFromLocation(location, workingDirectory = process.cwd()) {
|
|
85893
85928
|
try {
|
|
85894
85929
|
switch (location) {
|
|
85895
85930
|
case "user":
|
|
85896
85931
|
return settingsManager.getSettings().hooks || {};
|
|
85897
85932
|
case "project":
|
|
85933
|
+
if (isProjectSettingsPathCollidingWithGlobal2(workingDirectory)) {
|
|
85934
|
+
return {};
|
|
85935
|
+
}
|
|
85898
85936
|
return settingsManager.getProjectSettings(workingDirectory)?.hooks || {};
|
|
85899
85937
|
case "project-local":
|
|
85900
85938
|
return settingsManager.getLocalProjectSettings(workingDirectory)?.hooks || {};
|
|
@@ -85910,6 +85948,10 @@ async function saveHooksToLocation(hooks, location, workingDirectory = process.c
|
|
|
85910
85948
|
settingsManager.updateSettings({ hooks });
|
|
85911
85949
|
break;
|
|
85912
85950
|
case "project":
|
|
85951
|
+
if (isProjectSettingsPathCollidingWithGlobal2(workingDirectory)) {
|
|
85952
|
+
settingsManager.updateSettings({ hooks });
|
|
85953
|
+
break;
|
|
85954
|
+
}
|
|
85913
85955
|
try {
|
|
85914
85956
|
settingsManager.getProjectSettings(workingDirectory);
|
|
85915
85957
|
} catch {
|
|
@@ -88286,7 +88328,7 @@ var init_AgentInfoBar = __esm(async () => {
|
|
|
88286
88328
|
|
|
88287
88329
|
// src/cli/helpers/fileSearch.ts
|
|
88288
88330
|
import { readdirSync as readdirSync6, statSync as statSync5 } from "node:fs";
|
|
88289
|
-
import { join as join29, resolve as
|
|
88331
|
+
import { join as join29, resolve as resolve27 } from "node:path";
|
|
88290
88332
|
function shouldExcludeEntry(entry) {
|
|
88291
88333
|
if (entry.startsWith(".")) {
|
|
88292
88334
|
return true;
|
|
@@ -88335,7 +88377,7 @@ async function searchFiles(query, deep = false) {
|
|
|
88335
88377
|
const dirPart = query.slice(0, lastSlashIndex);
|
|
88336
88378
|
const pattern = query.slice(lastSlashIndex + 1);
|
|
88337
88379
|
try {
|
|
88338
|
-
const resolvedDir =
|
|
88380
|
+
const resolvedDir = resolve27(process.cwd(), dirPart);
|
|
88339
88381
|
try {
|
|
88340
88382
|
statSync5(resolvedDir);
|
|
88341
88383
|
searchDir = resolvedDir;
|
|
@@ -94507,7 +94549,7 @@ __export(exports_generate_memory_viewer, {
|
|
|
94507
94549
|
});
|
|
94508
94550
|
import { execFile as execFileCb2 } from "node:child_process";
|
|
94509
94551
|
import { chmodSync as chmodSync3, existsSync as existsSync19, mkdirSync as mkdirSync13, writeFileSync as writeFileSync10 } from "node:fs";
|
|
94510
|
-
import { homedir as
|
|
94552
|
+
import { homedir as homedir21 } from "node:os";
|
|
94511
94553
|
import { join as join32 } from "node:path";
|
|
94512
94554
|
import { promisify as promisify10 } from "node:util";
|
|
94513
94555
|
async function runGitSafe(cwd2, args) {
|
|
@@ -94821,7 +94863,7 @@ var init_generate_memory_viewer = __esm(async () => {
|
|
|
94821
94863
|
init_memoryGit()
|
|
94822
94864
|
]);
|
|
94823
94865
|
execFile10 = promisify10(execFileCb2);
|
|
94824
|
-
VIEWERS_DIR2 = join32(
|
|
94866
|
+
VIEWERS_DIR2 = join32(homedir21(), ".letta", "viewers");
|
|
94825
94867
|
REFLECTION_PATTERN = /\(reflection\)|🔮|reflection:/i;
|
|
94826
94868
|
});
|
|
94827
94869
|
|
|
@@ -97459,11 +97501,11 @@ var init_byok_providers = __esm(async () => {
|
|
|
97459
97501
|
|
|
97460
97502
|
// src/utils/aws-credentials.ts
|
|
97461
97503
|
import { readFile as readFile10 } from "node:fs/promises";
|
|
97462
|
-
import { homedir as
|
|
97504
|
+
import { homedir as homedir22 } from "node:os";
|
|
97463
97505
|
import { join as join33 } from "node:path";
|
|
97464
97506
|
async function parseAwsCredentials() {
|
|
97465
|
-
const credentialsPath = join33(
|
|
97466
|
-
const configPath = join33(
|
|
97507
|
+
const credentialsPath = join33(homedir22(), ".aws", "credentials");
|
|
97508
|
+
const configPath = join33(homedir22(), ".aws", "config");
|
|
97467
97509
|
const profiles = new Map;
|
|
97468
97510
|
try {
|
|
97469
97511
|
const content = await readFile10(credentialsPath, "utf-8");
|
|
@@ -102774,7 +102816,7 @@ async function executeStatusLineCommand(command, payload, options) {
|
|
|
102774
102816
|
};
|
|
102775
102817
|
}
|
|
102776
102818
|
function runWithLauncher(launcher, inputJson, timeout, signal, workingDirectory, startTime) {
|
|
102777
|
-
return new Promise((
|
|
102819
|
+
return new Promise((resolve28, reject) => {
|
|
102778
102820
|
const [executable, ...args] = launcher;
|
|
102779
102821
|
if (!executable) {
|
|
102780
102822
|
reject(new Error("Empty launcher"));
|
|
@@ -102787,7 +102829,7 @@ function runWithLauncher(launcher, inputJson, timeout, signal, workingDirectory,
|
|
|
102787
102829
|
const safeResolve = (result) => {
|
|
102788
102830
|
if (!resolved) {
|
|
102789
102831
|
resolved = true;
|
|
102790
|
-
|
|
102832
|
+
resolve28(result);
|
|
102791
102833
|
}
|
|
102792
102834
|
};
|
|
102793
102835
|
let child;
|
|
@@ -103280,7 +103322,7 @@ __export(exports_shellAliases, {
|
|
|
103280
103322
|
clearAliasCache: () => clearAliasCache
|
|
103281
103323
|
});
|
|
103282
103324
|
import { existsSync as existsSync21, readFileSync as readFileSync7 } from "node:fs";
|
|
103283
|
-
import { homedir as
|
|
103325
|
+
import { homedir as homedir23 } from "node:os";
|
|
103284
103326
|
import { join as join34 } from "node:path";
|
|
103285
103327
|
function parseAliasesFromFile(filePath) {
|
|
103286
103328
|
const aliases = new Map;
|
|
@@ -103350,7 +103392,7 @@ function loadAliases(forceReload = false) {
|
|
|
103350
103392
|
if (aliasCache && !forceReload) {
|
|
103351
103393
|
return aliasCache;
|
|
103352
103394
|
}
|
|
103353
|
-
const home =
|
|
103395
|
+
const home = homedir23();
|
|
103354
103396
|
const allAliases = new Map;
|
|
103355
103397
|
for (const file of ALIAS_FILES) {
|
|
103356
103398
|
const filePath = join34(home, file);
|
|
@@ -103533,7 +103575,7 @@ async function generatePKCE() {
|
|
|
103533
103575
|
return { codeVerifier, codeChallenge };
|
|
103534
103576
|
}
|
|
103535
103577
|
function startLocalOAuthServer(expectedState, port = OPENAI_OAUTH_CONFIG.defaultPort) {
|
|
103536
|
-
return new Promise((
|
|
103578
|
+
return new Promise((resolve28, reject) => {
|
|
103537
103579
|
const server = http.createServer((req, res) => {
|
|
103538
103580
|
const url = new URL(req.url || "", `http://localhost:${port}`);
|
|
103539
103581
|
if (url.pathname === OPENAI_OAUTH_CONFIG.callbackPath) {
|
|
@@ -103579,7 +103621,7 @@ function startLocalOAuthServer(expectedState, port = OPENAI_OAUTH_CONFIG.default
|
|
|
103579
103621
|
message: "You can close this window and return to Letta Code.",
|
|
103580
103622
|
autoClose: true
|
|
103581
103623
|
}));
|
|
103582
|
-
|
|
103624
|
+
resolve28({ result: { code, state }, server });
|
|
103583
103625
|
} else {
|
|
103584
103626
|
res.writeHead(404, { "Content-Type": "text/plain" });
|
|
103585
103627
|
res.end("Not found");
|
|
@@ -104501,14 +104543,14 @@ __export(exports_export, {
|
|
|
104501
104543
|
packageSkills: () => packageSkills
|
|
104502
104544
|
});
|
|
104503
104545
|
import { readdir as readdir10, readFile as readFile11 } from "node:fs/promises";
|
|
104504
|
-
import { relative as relative8, resolve as
|
|
104546
|
+
import { relative as relative8, resolve as resolve28 } from "node:path";
|
|
104505
104547
|
async function packageSkills(agentId, skillsDir) {
|
|
104506
104548
|
const skills = [];
|
|
104507
104549
|
const skillNames = new Set;
|
|
104508
104550
|
const dirsToCheck = skillsDir ? [skillsDir] : [
|
|
104509
104551
|
agentId && getAgentSkillsDir(agentId),
|
|
104510
|
-
|
|
104511
|
-
|
|
104552
|
+
resolve28(process.cwd(), ".skills"),
|
|
104553
|
+
resolve28(process.env.HOME || "~", ".letta", "skills")
|
|
104512
104554
|
].filter((dir) => Boolean(dir));
|
|
104513
104555
|
for (const baseDir of dirsToCheck) {
|
|
104514
104556
|
try {
|
|
@@ -104518,8 +104560,8 @@ async function packageSkills(agentId, skillsDir) {
|
|
|
104518
104560
|
continue;
|
|
104519
104561
|
if (skillNames.has(entry.name))
|
|
104520
104562
|
continue;
|
|
104521
|
-
const skillDir =
|
|
104522
|
-
const skillMdPath =
|
|
104563
|
+
const skillDir = resolve28(baseDir, entry.name);
|
|
104564
|
+
const skillMdPath = resolve28(skillDir, "SKILL.md");
|
|
104523
104565
|
try {
|
|
104524
104566
|
await readFile11(skillMdPath, "utf-8");
|
|
104525
104567
|
} catch {
|
|
@@ -104549,7 +104591,7 @@ async function readSkillFiles(skillDir) {
|
|
|
104549
104591
|
async function walk(dir) {
|
|
104550
104592
|
const entries = await readdir10(dir, { withFileTypes: true });
|
|
104551
104593
|
for (const entry of entries) {
|
|
104552
|
-
const fullPath =
|
|
104594
|
+
const fullPath = resolve28(dir, entry.name);
|
|
104553
104595
|
if (entry.isDirectory()) {
|
|
104554
104596
|
await walk(fullPath);
|
|
104555
104597
|
} else {
|
|
@@ -104690,7 +104732,7 @@ __export(exports_App, {
|
|
|
104690
104732
|
default: () => App2
|
|
104691
104733
|
});
|
|
104692
104734
|
import { existsSync as existsSync22, readFileSync as readFileSync8, renameSync as renameSync2, writeFileSync as writeFileSync11 } from "node:fs";
|
|
104693
|
-
import { homedir as
|
|
104735
|
+
import { homedir as homedir24, tmpdir as tmpdir5 } from "node:os";
|
|
104694
104736
|
import { join as join35 } from "node:path";
|
|
104695
104737
|
function deriveReasoningEffort(modelSettings, llmConfig) {
|
|
104696
104738
|
if (modelSettings && "provider_type" in modelSettings) {
|
|
@@ -106540,7 +106582,7 @@ ${newState.originalPrompt}`
|
|
|
106540
106582
|
cancelled = true;
|
|
106541
106583
|
break;
|
|
106542
106584
|
}
|
|
106543
|
-
await new Promise((
|
|
106585
|
+
await new Promise((resolve29) => setTimeout(resolve29, 100));
|
|
106544
106586
|
}
|
|
106545
106587
|
buffersRef.current.byId.delete(statusId);
|
|
106546
106588
|
buffersRef.current.order = buffersRef.current.order.filter((id) => id !== statusId);
|
|
@@ -106571,7 +106613,7 @@ ${newState.originalPrompt}`
|
|
|
106571
106613
|
cancelled = true;
|
|
106572
106614
|
break;
|
|
106573
106615
|
}
|
|
106574
|
-
await new Promise((
|
|
106616
|
+
await new Promise((resolve29) => setTimeout(resolve29, 100));
|
|
106575
106617
|
}
|
|
106576
106618
|
buffersRef.current.byId.delete(statusId);
|
|
106577
106619
|
buffersRef.current.order = buffersRef.current.order.filter((id) => id !== statusId);
|
|
@@ -107253,7 +107295,7 @@ ${feedback}
|
|
|
107253
107295
|
cancelled = true;
|
|
107254
107296
|
break;
|
|
107255
107297
|
}
|
|
107256
|
-
await new Promise((
|
|
107298
|
+
await new Promise((resolve29) => setTimeout(resolve29, 100));
|
|
107257
107299
|
}
|
|
107258
107300
|
buffersRef.current.byId.delete(statusId);
|
|
107259
107301
|
buffersRef.current.order = buffersRef.current.order.filter((id) => id !== statusId);
|
|
@@ -111348,7 +111390,7 @@ ${guidance}`);
|
|
|
111348
111390
|
}
|
|
111349
111391
|
if (!planFileExists()) {
|
|
111350
111392
|
const planFilePath = permissionMode.getPlanFilePath();
|
|
111351
|
-
const plansDir = join35(
|
|
111393
|
+
const plansDir = join35(homedir24(), ".letta", "plans");
|
|
111352
111394
|
handlePlanKeepPlanning(`You must write your plan to a plan file before exiting plan mode.
|
|
111353
111395
|
` + (planFilePath ? `Plan file path: ${planFilePath}
|
|
111354
111396
|
` : "") + `Use a write tool to create your plan in ${plansDir}, then use ExitPlanMode to present the plan to the user.`);
|
|
@@ -112660,7 +112702,7 @@ import {
|
|
|
112660
112702
|
readFileSync as readFileSync9,
|
|
112661
112703
|
writeFileSync as writeFileSync12
|
|
112662
112704
|
} from "node:fs";
|
|
112663
|
-
import { homedir as
|
|
112705
|
+
import { homedir as homedir25, platform as platform5 } from "node:os";
|
|
112664
112706
|
import { dirname as dirname14, join as join36 } from "node:path";
|
|
112665
112707
|
function detectTerminalType2() {
|
|
112666
112708
|
if (process.env.CURSOR_TRACE_ID || process.env.CURSOR_CHANNEL) {
|
|
@@ -112693,7 +112735,7 @@ function getKeybindingsPath2(terminal) {
|
|
|
112693
112735
|
}[terminal];
|
|
112694
112736
|
const os6 = platform5();
|
|
112695
112737
|
if (os6 === "darwin") {
|
|
112696
|
-
return join36(
|
|
112738
|
+
return join36(homedir25(), "Library", "Application Support", appName, "User", "keybindings.json");
|
|
112697
112739
|
}
|
|
112698
112740
|
if (os6 === "win32") {
|
|
112699
112741
|
const appData = process.env.APPDATA;
|
|
@@ -112702,7 +112744,7 @@ function getKeybindingsPath2(terminal) {
|
|
|
112702
112744
|
return join36(appData, appName, "User", "keybindings.json");
|
|
112703
112745
|
}
|
|
112704
112746
|
if (os6 === "linux") {
|
|
112705
|
-
return join36(
|
|
112747
|
+
return join36(homedir25(), ".config", appName, "User", "keybindings.json");
|
|
112706
112748
|
}
|
|
112707
112749
|
return null;
|
|
112708
112750
|
}
|
|
@@ -112859,10 +112901,10 @@ function getWezTermConfigPath2() {
|
|
|
112859
112901
|
if (existsSync23(xdgPath))
|
|
112860
112902
|
return xdgPath;
|
|
112861
112903
|
}
|
|
112862
|
-
const configPath = join36(
|
|
112904
|
+
const configPath = join36(homedir25(), ".config", "wezterm", "wezterm.lua");
|
|
112863
112905
|
if (existsSync23(configPath))
|
|
112864
112906
|
return configPath;
|
|
112865
|
-
return join36(
|
|
112907
|
+
return join36(homedir25(), ".wezterm.lua");
|
|
112866
112908
|
}
|
|
112867
112909
|
function wezTermDeleteFixExists2(configPath) {
|
|
112868
112910
|
if (!existsSync23(configPath))
|
|
@@ -112960,10 +113002,10 @@ __export(exports_settings2, {
|
|
|
112960
113002
|
loadProjectSettings: () => loadProjectSettings2,
|
|
112961
113003
|
getSetting: () => getSetting2
|
|
112962
113004
|
});
|
|
112963
|
-
import { homedir as
|
|
113005
|
+
import { homedir as homedir26 } from "node:os";
|
|
112964
113006
|
import { join as join37 } from "node:path";
|
|
112965
113007
|
function getSettingsPath2() {
|
|
112966
|
-
return join37(
|
|
113008
|
+
return join37(homedir26(), ".letta", "settings.json");
|
|
112967
113009
|
}
|
|
112968
113010
|
async function loadSettings2() {
|
|
112969
113011
|
const settingsPath = getSettingsPath2();
|
|
@@ -113445,10 +113487,10 @@ __export(exports_import2, {
|
|
|
113445
113487
|
});
|
|
113446
113488
|
import { createReadStream as createReadStream2 } from "node:fs";
|
|
113447
113489
|
import { chmod as chmod2, mkdir as mkdir4, readFile as readFile12, writeFile as writeFile4 } from "node:fs/promises";
|
|
113448
|
-
import { dirname as dirname15, resolve as
|
|
113490
|
+
import { dirname as dirname15, resolve as resolve29 } from "node:path";
|
|
113449
113491
|
async function importAgentFromFile2(options) {
|
|
113450
113492
|
const client = await getClient2();
|
|
113451
|
-
const resolvedPath =
|
|
113493
|
+
const resolvedPath = resolve29(options.filePath);
|
|
113452
113494
|
const file = createReadStream2(resolvedPath);
|
|
113453
113495
|
const importResponse = await client.agents.importFile({
|
|
113454
113496
|
file,
|
|
@@ -113483,7 +113525,7 @@ async function extractSkillsFromAf2(afPath, destDir) {
|
|
|
113483
113525
|
return [];
|
|
113484
113526
|
}
|
|
113485
113527
|
for (const skill2 of afData.skills) {
|
|
113486
|
-
const skillDir =
|
|
113528
|
+
const skillDir = resolve29(destDir, skill2.name);
|
|
113487
113529
|
await mkdir4(skillDir, { recursive: true });
|
|
113488
113530
|
if (skill2.files) {
|
|
113489
113531
|
await writeSkillFiles2(skillDir, skill2.files);
|
|
@@ -113503,7 +113545,7 @@ async function writeSkillFiles2(skillDir, files) {
|
|
|
113503
113545
|
}
|
|
113504
113546
|
}
|
|
113505
113547
|
async function writeSkillFile2(skillDir, filePath, content) {
|
|
113506
|
-
const fullPath =
|
|
113548
|
+
const fullPath = resolve29(skillDir, filePath);
|
|
113507
113549
|
await mkdir4(dirname15(fullPath), { recursive: true });
|
|
113508
113550
|
await writeFile4(fullPath, content, "utf-8");
|
|
113509
113551
|
const isScript = filePath.startsWith("scripts/") || content.trimStart().startsWith("#!");
|
|
@@ -113610,15 +113652,15 @@ __export(exports_memoryFilesystem2, {
|
|
|
113610
113652
|
MEMORY_FS_AGENTS_DIR: () => MEMORY_FS_AGENTS_DIR2
|
|
113611
113653
|
});
|
|
113612
113654
|
import { existsSync as existsSync24, mkdirSync as mkdirSync15 } from "node:fs";
|
|
113613
|
-
import { homedir as
|
|
113655
|
+
import { homedir as homedir27 } from "node:os";
|
|
113614
113656
|
import { join as join38 } from "node:path";
|
|
113615
|
-
function getMemoryFilesystemRoot2(agentId, homeDir =
|
|
113657
|
+
function getMemoryFilesystemRoot2(agentId, homeDir = homedir27()) {
|
|
113616
113658
|
return join38(homeDir, MEMORY_FS_ROOT2, MEMORY_FS_AGENTS_DIR2, agentId, MEMORY_FS_MEMORY_DIR2);
|
|
113617
113659
|
}
|
|
113618
|
-
function getMemorySystemDir2(agentId, homeDir =
|
|
113660
|
+
function getMemorySystemDir2(agentId, homeDir = homedir27()) {
|
|
113619
113661
|
return join38(getMemoryFilesystemRoot2(agentId, homeDir), MEMORY_SYSTEM_DIR2);
|
|
113620
113662
|
}
|
|
113621
|
-
function ensureMemoryFilesystemDirs2(agentId, homeDir =
|
|
113663
|
+
function ensureMemoryFilesystemDirs2(agentId, homeDir = homedir27()) {
|
|
113622
113664
|
const root = getMemoryFilesystemRoot2(agentId, homeDir);
|
|
113623
113665
|
const systemDir = getMemorySystemDir2(agentId, homeDir);
|
|
113624
113666
|
if (!existsSync24(root)) {
|
|
@@ -116085,7 +116127,7 @@ async function runListenSubcommand(argv) {
|
|
|
116085
116127
|
await init_memoryGit();
|
|
116086
116128
|
import { cpSync, existsSync as existsSync9, mkdirSync as mkdirSync7, rmSync as rmSync2, statSync as statSync2 } from "node:fs";
|
|
116087
116129
|
import { readdir as readdir5 } from "node:fs/promises";
|
|
116088
|
-
import { homedir as
|
|
116130
|
+
import { homedir as homedir13 } from "node:os";
|
|
116089
116131
|
import { join as join16 } from "node:path";
|
|
116090
116132
|
import { parseArgs as parseArgs4 } from "node:util";
|
|
116091
116133
|
function printUsage3() {
|
|
@@ -116115,10 +116157,10 @@ function getAgentId3(agentFromArgs, agentIdFromArgs) {
|
|
|
116115
116157
|
return agentFromArgs || agentIdFromArgs || process.env.LETTA_AGENT_ID || "";
|
|
116116
116158
|
}
|
|
116117
116159
|
function getMemoryRoot(agentId) {
|
|
116118
|
-
return join16(
|
|
116160
|
+
return join16(homedir13(), ".letta", "agents", agentId, "memory");
|
|
116119
116161
|
}
|
|
116120
116162
|
function getAgentRoot(agentId) {
|
|
116121
|
-
return join16(
|
|
116163
|
+
return join16(homedir13(), ".letta", "agents", agentId);
|
|
116122
116164
|
}
|
|
116123
116165
|
function formatBackupTimestamp(date = new Date) {
|
|
116124
116166
|
const pad = (value) => String(value).padStart(2, "0");
|
|
@@ -116493,8 +116535,8 @@ async function runSubcommand(argv) {
|
|
|
116493
116535
|
|
|
116494
116536
|
// src/permissions/mode.ts
|
|
116495
116537
|
init_readOnlyShell();
|
|
116496
|
-
import { homedir as
|
|
116497
|
-
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";
|
|
116498
116540
|
var MODE_KEY2 = Symbol.for("@letta/permissionMode");
|
|
116499
116541
|
var PLAN_FILE_KEY2 = Symbol.for("@letta/planFilePath");
|
|
116500
116542
|
var MODE_BEFORE_PLAN_KEY2 = Symbol.for("@letta/permissionModeBeforePlan");
|
|
@@ -116530,12 +116572,12 @@ function resolvePlanTargetPath2(targetPath, workingDirectory) {
|
|
|
116530
116572
|
if (!trimmedPath)
|
|
116531
116573
|
return null;
|
|
116532
116574
|
if (trimmedPath.startsWith("~/")) {
|
|
116533
|
-
return
|
|
116575
|
+
return resolve21(homedir14(), trimmedPath.slice(2));
|
|
116534
116576
|
}
|
|
116535
116577
|
if (isAbsolute14(trimmedPath)) {
|
|
116536
|
-
return
|
|
116578
|
+
return resolve21(trimmedPath);
|
|
116537
116579
|
}
|
|
116538
|
-
return
|
|
116580
|
+
return resolve21(workingDirectory, trimmedPath);
|
|
116539
116581
|
}
|
|
116540
116582
|
function isPathInPlansDir2(path19, plansDir) {
|
|
116541
116583
|
if (!path19.endsWith(".md"))
|
|
@@ -116656,7 +116698,7 @@ class PermissionModeManager2 {
|
|
|
116656
116698
|
return "allow";
|
|
116657
116699
|
}
|
|
116658
116700
|
if (writeTools.includes(toolName)) {
|
|
116659
|
-
const plansDir = join17(
|
|
116701
|
+
const plansDir = join17(homedir14(), ".letta", "plans");
|
|
116660
116702
|
const targetPath = toolArgs?.file_path || toolArgs?.path;
|
|
116661
116703
|
let candidatePaths = [];
|
|
116662
116704
|
if ((toolName === "ApplyPatch" || toolName === "apply_patch") && toolArgs?.input) {
|
|
@@ -116727,8 +116769,8 @@ init_debug();
|
|
|
116727
116769
|
init_fs();
|
|
116728
116770
|
await init_secrets();
|
|
116729
116771
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
116730
|
-
import { homedir as
|
|
116731
|
-
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";
|
|
116732
116774
|
var DEFAULT_SETTINGS2 = {
|
|
116733
116775
|
lastAgent: null,
|
|
116734
116776
|
tokenStreaming: false,
|
|
@@ -117008,6 +117050,11 @@ class SettingsManager2 {
|
|
|
117008
117050
|
}
|
|
117009
117051
|
}
|
|
117010
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
|
+
}
|
|
117011
117058
|
const cached = this.projectSettings.get(workingDirectory);
|
|
117012
117059
|
if (cached) {
|
|
117013
117060
|
return { ...cached };
|
|
@@ -117043,6 +117090,19 @@ class SettingsManager2 {
|
|
|
117043
117090
|
return { ...cached };
|
|
117044
117091
|
}
|
|
117045
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
|
+
}
|
|
117046
117106
|
const current = this.projectSettings.get(workingDirectory);
|
|
117047
117107
|
if (!current) {
|
|
117048
117108
|
throw new Error(`Project settings for ${workingDirectory} not loaded. Call loadProjectSettings() first.`);
|
|
@@ -117060,7 +117120,7 @@ class SettingsManager2 {
|
|
|
117060
117120
|
if (!this.settings)
|
|
117061
117121
|
return;
|
|
117062
117122
|
const settingsPath = this.getSettingsPath();
|
|
117063
|
-
const home = process.env.HOME ||
|
|
117123
|
+
const home = process.env.HOME || homedir15();
|
|
117064
117124
|
const dirPath = join18(home, ".letta");
|
|
117065
117125
|
try {
|
|
117066
117126
|
if (!exists(dirPath)) {
|
|
@@ -117089,6 +117149,9 @@ class SettingsManager2 {
|
|
|
117089
117149
|
}
|
|
117090
117150
|
}
|
|
117091
117151
|
async persistProjectSettings(workingDirectory) {
|
|
117152
|
+
if (this.isProjectSettingsPathCollidingWithGlobal(workingDirectory)) {
|
|
117153
|
+
return;
|
|
117154
|
+
}
|
|
117092
117155
|
const settings = this.projectSettings.get(workingDirectory);
|
|
117093
117156
|
if (!settings)
|
|
117094
117157
|
return;
|
|
@@ -117114,12 +117177,15 @@ class SettingsManager2 {
|
|
|
117114
117177
|
}
|
|
117115
117178
|
}
|
|
117116
117179
|
getSettingsPath() {
|
|
117117
|
-
const home = process.env.HOME ||
|
|
117180
|
+
const home = process.env.HOME || homedir15();
|
|
117118
117181
|
return join18(home, ".letta", "settings.json");
|
|
117119
117182
|
}
|
|
117120
117183
|
getProjectSettingsPath(workingDirectory) {
|
|
117121
117184
|
return join18(workingDirectory, ".letta", "settings.json");
|
|
117122
117185
|
}
|
|
117186
|
+
isProjectSettingsPathCollidingWithGlobal(workingDirectory) {
|
|
117187
|
+
return resolve22(this.getProjectSettingsPath(workingDirectory)) === resolve22(this.getSettingsPath());
|
|
117188
|
+
}
|
|
117123
117189
|
getLocalProjectSettingsPath(workingDirectory) {
|
|
117124
117190
|
return join18(workingDirectory, ".letta", "settings.local.json");
|
|
117125
117191
|
}
|
|
@@ -117912,8 +117978,8 @@ function acquireSwitchLock2() {
|
|
|
117912
117978
|
const lock = getSwitchLock2();
|
|
117913
117979
|
lock.refCount++;
|
|
117914
117980
|
if (lock.refCount === 1) {
|
|
117915
|
-
lock.promise = new Promise((
|
|
117916
|
-
lock.resolve =
|
|
117981
|
+
lock.promise = new Promise((resolve23) => {
|
|
117982
|
+
lock.resolve = resolve23;
|
|
117917
117983
|
});
|
|
117918
117984
|
}
|
|
117919
117985
|
}
|
|
@@ -118423,7 +118489,7 @@ Note: Flags should use double dashes for full names (e.g., --yolo, not -yolo)`);
|
|
|
118423
118489
|
printHelp();
|
|
118424
118490
|
const helpDelayMs = Number.parseInt(process.env.LETTA_TEST_HELP_EXIT_DELAY_MS ?? "", 10);
|
|
118425
118491
|
if (Number.isFinite(helpDelayMs) && helpDelayMs > 0) {
|
|
118426
|
-
await new Promise((
|
|
118492
|
+
await new Promise((resolve30) => setTimeout(resolve30, helpDelayMs));
|
|
118427
118493
|
}
|
|
118428
118494
|
process.exit(0);
|
|
118429
118495
|
}
|
|
@@ -118638,9 +118704,9 @@ Note: Flags should use double dashes for full names (e.g., --yolo, not -yolo)`);
|
|
|
118638
118704
|
process.exit(1);
|
|
118639
118705
|
}
|
|
118640
118706
|
} else {
|
|
118641
|
-
const { resolve:
|
|
118707
|
+
const { resolve: resolve30 } = await import("path");
|
|
118642
118708
|
const { existsSync: existsSync25 } = await import("fs");
|
|
118643
|
-
const resolvedPath =
|
|
118709
|
+
const resolvedPath = resolve30(fromAfFile);
|
|
118644
118710
|
if (!existsSync25(resolvedPath)) {
|
|
118645
118711
|
console.error(`Error: AgentFile not found: ${resolvedPath}`);
|
|
118646
118712
|
process.exit(1);
|
|
@@ -119508,4 +119574,4 @@ Error during initialization: ${message}`);
|
|
|
119508
119574
|
}
|
|
119509
119575
|
main();
|
|
119510
119576
|
|
|
119511
|
-
//# debugId=
|
|
119577
|
+
//# debugId=8C35AC90E5DBC3BE64756E2164756E21
|