@letta-ai/letta-code 0.1.9 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -14
- package/letta.js +1112 -406
- package/package.json +1 -1
package/letta.js
CHANGED
|
@@ -112942,14 +112942,20 @@ async function writeFile(path, content) {
|
|
|
112942
112942
|
function exists(path) {
|
|
112943
112943
|
return existsSync(path);
|
|
112944
112944
|
}
|
|
112945
|
+
async function mkdir(path, options) {
|
|
112946
|
+
mkdirSync(path, options);
|
|
112947
|
+
}
|
|
112945
112948
|
var init_fs = () => {};
|
|
112946
112949
|
|
|
112947
112950
|
// src/settings.ts
|
|
112948
112951
|
var exports_settings = {};
|
|
112949
112952
|
__export(exports_settings, {
|
|
112950
112953
|
updateSettings: () => updateSettings,
|
|
112954
|
+
updateProjectSettings: () => updateProjectSettings,
|
|
112951
112955
|
saveSettings: () => saveSettings,
|
|
112956
|
+
saveProjectSettings: () => saveProjectSettings,
|
|
112952
112957
|
loadSettings: () => loadSettings,
|
|
112958
|
+
loadProjectSettings: () => loadProjectSettings,
|
|
112953
112959
|
getSetting: () => getSetting
|
|
112954
112960
|
});
|
|
112955
112961
|
import { homedir } from "node:os";
|
|
@@ -112991,6 +112997,42 @@ async function getSetting(key) {
|
|
|
112991
112997
|
const settings = await loadSettings();
|
|
112992
112998
|
return settings[key];
|
|
112993
112999
|
}
|
|
113000
|
+
function getProjectSettingsPath() {
|
|
113001
|
+
return join(process.cwd(), ".letta", "settings.local.json");
|
|
113002
|
+
}
|
|
113003
|
+
async function loadProjectSettings() {
|
|
113004
|
+
const settingsPath = getProjectSettingsPath();
|
|
113005
|
+
try {
|
|
113006
|
+
if (!exists(settingsPath)) {
|
|
113007
|
+
return null;
|
|
113008
|
+
}
|
|
113009
|
+
const content = await readFile(settingsPath);
|
|
113010
|
+
const settings = JSON.parse(content);
|
|
113011
|
+
return settings;
|
|
113012
|
+
} catch (error) {
|
|
113013
|
+
console.error("Error loading project settings:", error);
|
|
113014
|
+
return null;
|
|
113015
|
+
}
|
|
113016
|
+
}
|
|
113017
|
+
async function saveProjectSettings(settings) {
|
|
113018
|
+
const settingsPath = getProjectSettingsPath();
|
|
113019
|
+
const dirPath = join(process.cwd(), ".letta");
|
|
113020
|
+
try {
|
|
113021
|
+
if (!exists(dirPath)) {
|
|
113022
|
+
await mkdir(dirPath, { recursive: true });
|
|
113023
|
+
}
|
|
113024
|
+
await writeFile(settingsPath, JSON.stringify(settings, null, 2));
|
|
113025
|
+
} catch (error) {
|
|
113026
|
+
console.error("Error saving project settings:", error);
|
|
113027
|
+
throw error;
|
|
113028
|
+
}
|
|
113029
|
+
}
|
|
113030
|
+
async function updateProjectSettings(updates) {
|
|
113031
|
+
const currentSettings = await loadProjectSettings() || { lastAgent: null };
|
|
113032
|
+
const newSettings = { ...currentSettings, ...updates };
|
|
113033
|
+
await saveProjectSettings(newSettings);
|
|
113034
|
+
return newSettings;
|
|
113035
|
+
}
|
|
112994
113036
|
var DEFAULT_SETTINGS;
|
|
112995
113037
|
var init_settings = __esm(() => {
|
|
112996
113038
|
init_fs();
|
|
@@ -113002,6 +113044,103 @@ var init_settings = __esm(() => {
|
|
|
113002
113044
|
};
|
|
113003
113045
|
});
|
|
113004
113046
|
|
|
113047
|
+
// src/settings.ts
|
|
113048
|
+
var exports_settings2 = {};
|
|
113049
|
+
__export(exports_settings2, {
|
|
113050
|
+
updateSettings: () => updateSettings2,
|
|
113051
|
+
updateProjectSettings: () => updateProjectSettings2,
|
|
113052
|
+
saveSettings: () => saveSettings2,
|
|
113053
|
+
saveProjectSettings: () => saveProjectSettings2,
|
|
113054
|
+
loadSettings: () => loadSettings2,
|
|
113055
|
+
loadProjectSettings: () => loadProjectSettings2,
|
|
113056
|
+
getSetting: () => getSetting2
|
|
113057
|
+
});
|
|
113058
|
+
import { homedir as homedir2 } from "node:os";
|
|
113059
|
+
import { join as join2 } from "node:path";
|
|
113060
|
+
function getSettingsPath2() {
|
|
113061
|
+
return join2(homedir2(), ".letta", "settings.json");
|
|
113062
|
+
}
|
|
113063
|
+
async function loadSettings2() {
|
|
113064
|
+
const settingsPath = getSettingsPath2();
|
|
113065
|
+
try {
|
|
113066
|
+
if (!exists(settingsPath)) {
|
|
113067
|
+
await saveSettings2(DEFAULT_SETTINGS2);
|
|
113068
|
+
return DEFAULT_SETTINGS2;
|
|
113069
|
+
}
|
|
113070
|
+
const content = await readFile(settingsPath);
|
|
113071
|
+
const settings = JSON.parse(content);
|
|
113072
|
+
return { ...DEFAULT_SETTINGS2, ...settings };
|
|
113073
|
+
} catch (error) {
|
|
113074
|
+
console.error("Error loading settings, using defaults:", error);
|
|
113075
|
+
return DEFAULT_SETTINGS2;
|
|
113076
|
+
}
|
|
113077
|
+
}
|
|
113078
|
+
async function saveSettings2(settings) {
|
|
113079
|
+
const settingsPath = getSettingsPath2();
|
|
113080
|
+
try {
|
|
113081
|
+
await writeFile(settingsPath, JSON.stringify(settings, null, 2));
|
|
113082
|
+
} catch (error) {
|
|
113083
|
+
console.error("Error saving settings:", error);
|
|
113084
|
+
throw error;
|
|
113085
|
+
}
|
|
113086
|
+
}
|
|
113087
|
+
async function updateSettings2(updates) {
|
|
113088
|
+
const currentSettings = await loadSettings2();
|
|
113089
|
+
const newSettings = { ...currentSettings, ...updates };
|
|
113090
|
+
await saveSettings2(newSettings);
|
|
113091
|
+
return newSettings;
|
|
113092
|
+
}
|
|
113093
|
+
async function getSetting2(key) {
|
|
113094
|
+
const settings = await loadSettings2();
|
|
113095
|
+
return settings[key];
|
|
113096
|
+
}
|
|
113097
|
+
function getProjectSettingsPath2() {
|
|
113098
|
+
return join2(process.cwd(), ".letta", "settings.local.json");
|
|
113099
|
+
}
|
|
113100
|
+
async function loadProjectSettings2() {
|
|
113101
|
+
const settingsPath = getProjectSettingsPath2();
|
|
113102
|
+
try {
|
|
113103
|
+
if (!exists(settingsPath)) {
|
|
113104
|
+
return null;
|
|
113105
|
+
}
|
|
113106
|
+
const content = await readFile(settingsPath);
|
|
113107
|
+
const settings = JSON.parse(content);
|
|
113108
|
+
return settings;
|
|
113109
|
+
} catch (error) {
|
|
113110
|
+
console.error("Error loading project settings:", error);
|
|
113111
|
+
return null;
|
|
113112
|
+
}
|
|
113113
|
+
}
|
|
113114
|
+
async function saveProjectSettings2(settings) {
|
|
113115
|
+
const settingsPath = getProjectSettingsPath2();
|
|
113116
|
+
const dirPath = join2(process.cwd(), ".letta");
|
|
113117
|
+
try {
|
|
113118
|
+
if (!exists(dirPath)) {
|
|
113119
|
+
await mkdir(dirPath, { recursive: true });
|
|
113120
|
+
}
|
|
113121
|
+
await writeFile(settingsPath, JSON.stringify(settings, null, 2));
|
|
113122
|
+
} catch (error) {
|
|
113123
|
+
console.error("Error saving project settings:", error);
|
|
113124
|
+
throw error;
|
|
113125
|
+
}
|
|
113126
|
+
}
|
|
113127
|
+
async function updateProjectSettings2(updates) {
|
|
113128
|
+
const currentSettings = await loadProjectSettings2() || { lastAgent: null };
|
|
113129
|
+
const newSettings = { ...currentSettings, ...updates };
|
|
113130
|
+
await saveProjectSettings2(newSettings);
|
|
113131
|
+
return newSettings;
|
|
113132
|
+
}
|
|
113133
|
+
var DEFAULT_SETTINGS2;
|
|
113134
|
+
var init_settings2 = __esm(() => {
|
|
113135
|
+
init_fs();
|
|
113136
|
+
DEFAULT_SETTINGS2 = {
|
|
113137
|
+
uiMode: "simple",
|
|
113138
|
+
lastAgent: null,
|
|
113139
|
+
tokenStreaming: false,
|
|
113140
|
+
globalSharedBlockIds: {}
|
|
113141
|
+
};
|
|
113142
|
+
});
|
|
113143
|
+
|
|
113005
113144
|
// src/tools/descriptions/Bash.md
|
|
113006
113145
|
var Bash_default = `# Bash
|
|
113007
113146
|
|
|
@@ -113453,10 +113592,20 @@ var init_process_manager = __esm(() => {
|
|
|
113453
113592
|
backgroundProcesses = new Map;
|
|
113454
113593
|
});
|
|
113455
113594
|
|
|
113595
|
+
// src/tools/impl/validation.ts
|
|
113596
|
+
function validateRequiredParams(args, required, toolName) {
|
|
113597
|
+
const missing = required.filter((key) => !(key in args));
|
|
113598
|
+
if (missing.length > 0) {
|
|
113599
|
+
const received = Object.keys(args).join(", ");
|
|
113600
|
+
throw new Error(`${toolName} tool missing required parameter${missing.length > 1 ? "s" : ""}: ${missing.join(", ")}. ` + `Received parameters: ${received}`);
|
|
113601
|
+
}
|
|
113602
|
+
}
|
|
113603
|
+
|
|
113456
113604
|
// src/tools/impl/Bash.ts
|
|
113457
113605
|
import { exec, spawn } from "node:child_process";
|
|
113458
113606
|
import { promisify } from "node:util";
|
|
113459
113607
|
async function bash(args) {
|
|
113608
|
+
validateRequiredParams(args, ["command"], "Bash");
|
|
113460
113609
|
const {
|
|
113461
113610
|
command,
|
|
113462
113611
|
timeout = 120000,
|
|
@@ -113589,6 +113738,7 @@ var init_Bash2 = __esm(() => {
|
|
|
113589
113738
|
|
|
113590
113739
|
// src/tools/impl/BashOutput.ts
|
|
113591
113740
|
async function bash_output(args) {
|
|
113741
|
+
validateRequiredParams(args, ["bash_id"], "BashOutput");
|
|
113592
113742
|
const { bash_id, filter } = args;
|
|
113593
113743
|
const proc = backgroundProcesses.get(bash_id);
|
|
113594
113744
|
if (!proc)
|
|
@@ -113616,6 +113766,7 @@ var init_BashOutput2 = __esm(() => {
|
|
|
113616
113766
|
import { promises as fs } from "node:fs";
|
|
113617
113767
|
import * as path from "node:path";
|
|
113618
113768
|
async function edit(args) {
|
|
113769
|
+
validateRequiredParams(args, ["file_path", "old_string", "new_string"], "Edit");
|
|
113619
113770
|
const { file_path, old_string, new_string, replace_all = false } = args;
|
|
113620
113771
|
if (!path.isAbsolute(file_path))
|
|
113621
113772
|
throw new Error(`File path must be absolute, got: ${file_path}`);
|
|
@@ -113663,12 +113814,14 @@ var init_Edit2 = () => {};
|
|
|
113663
113814
|
|
|
113664
113815
|
// src/tools/impl/ExitPlanMode.ts
|
|
113665
113816
|
async function exit_plan_mode(args) {
|
|
113817
|
+
validateRequiredParams(args, ["plan"], "ExitPlanMode");
|
|
113666
113818
|
const { plan: _plan } = args;
|
|
113667
113819
|
return {
|
|
113668
113820
|
message: `User has approved your plan. You can now start coding.
|
|
113669
113821
|
Start with updating your todo list if applicable`
|
|
113670
113822
|
};
|
|
113671
113823
|
}
|
|
113824
|
+
var init_ExitPlanMode2 = () => {};
|
|
113672
113825
|
|
|
113673
113826
|
// node_modules/picomatch/lib/constants.js
|
|
113674
113827
|
var require_constants = __commonJS((exports, module) => {
|
|
@@ -115130,6 +115283,7 @@ async function walkDirectory(dir) {
|
|
|
115130
115283
|
return files;
|
|
115131
115284
|
}
|
|
115132
115285
|
async function glob(args) {
|
|
115286
|
+
validateRequiredParams(args, ["pattern"], "Glob");
|
|
115133
115287
|
const { pattern, path: searchPath } = args;
|
|
115134
115288
|
const userCwd = process.env.USER_CWD || process.cwd();
|
|
115135
115289
|
let baseDir;
|
|
@@ -115187,6 +115341,7 @@ function getRipgrepPath() {
|
|
|
115187
115341
|
}
|
|
115188
115342
|
}
|
|
115189
115343
|
async function grep(args) {
|
|
115344
|
+
validateRequiredParams(args, ["pattern"], "Grep");
|
|
115190
115345
|
const {
|
|
115191
115346
|
pattern,
|
|
115192
115347
|
path: searchPath,
|
|
@@ -115318,6 +115473,7 @@ var init_Grep2 = __esm(() => {
|
|
|
115318
115473
|
|
|
115319
115474
|
// src/tools/impl/KillBash.ts
|
|
115320
115475
|
async function kill_bash(args) {
|
|
115476
|
+
validateRequiredParams(args, ["shell_id"], "KillBash");
|
|
115321
115477
|
const { shell_id } = args;
|
|
115322
115478
|
const proc = backgroundProcesses.get(shell_id);
|
|
115323
115479
|
if (!proc)
|
|
@@ -115336,15 +115492,16 @@ var init_KillBash2 = __esm(() => {
|
|
|
115336
115492
|
|
|
115337
115493
|
// src/tools/impl/LS.ts
|
|
115338
115494
|
import { readdir, stat } from "node:fs/promises";
|
|
115339
|
-
import { join as
|
|
115495
|
+
import { join as join4, resolve as resolve3 } from "node:path";
|
|
115340
115496
|
async function ls(args) {
|
|
115497
|
+
validateRequiredParams(args, ["path"], "LS");
|
|
115341
115498
|
const { path: inputPath, ignore = [] } = args;
|
|
115342
115499
|
const dirPath = resolve3(inputPath);
|
|
115343
115500
|
try {
|
|
115344
115501
|
const items = await readdir(dirPath);
|
|
115345
115502
|
const filteredItems = items.filter((item) => !ignore.some((pattern) => import_picomatch2.default.isMatch(item, pattern)));
|
|
115346
115503
|
const fileInfos = await Promise.all(filteredItems.map(async (item) => {
|
|
115347
|
-
const fullPath =
|
|
115504
|
+
const fullPath = join4(dirPath, item);
|
|
115348
115505
|
try {
|
|
115349
115506
|
const stats = await stat(fullPath);
|
|
115350
115507
|
return {
|
|
@@ -115401,12 +115558,14 @@ var init_LS2 = __esm(() => {
|
|
|
115401
115558
|
import { promises as fs3 } from "node:fs";
|
|
115402
115559
|
import * as path4 from "node:path";
|
|
115403
115560
|
async function multi_edit(args) {
|
|
115561
|
+
validateRequiredParams(args, ["file_path", "edits"], "MultiEdit");
|
|
115404
115562
|
const { file_path, edits } = args;
|
|
115405
115563
|
if (!path4.isAbsolute(file_path))
|
|
115406
115564
|
throw new Error(`File path must be absolute, got: ${file_path}`);
|
|
115407
115565
|
if (!edits || edits.length === 0)
|
|
115408
115566
|
throw new Error("No edits provided");
|
|
115409
115567
|
for (let i = 0;i < edits.length; i++) {
|
|
115568
|
+
validateRequiredParams(edits[i], ["old_string", "new_string"], `MultiEdit (edit ${i + 1})`);
|
|
115410
115569
|
if (edits[i].old_string === edits[i].new_string)
|
|
115411
115570
|
throw new Error(`Edit ${i + 1}: No changes to make: old_string and new_string are exactly the same.`);
|
|
115412
115571
|
}
|
|
@@ -115518,6 +115677,7 @@ function formatWithLineNumbers(content, offset, limit) {
|
|
|
115518
115677
|
`);
|
|
115519
115678
|
}
|
|
115520
115679
|
async function read(args) {
|
|
115680
|
+
validateRequiredParams(args, ["file_path"], "Read");
|
|
115521
115681
|
const { file_path, offset, limit } = args;
|
|
115522
115682
|
if (!path5.isAbsolute(file_path))
|
|
115523
115683
|
throw new Error(`File path must be absolute, got: ${file_path}`);
|
|
@@ -115552,6 +115712,7 @@ var init_Read2 = () => {};
|
|
|
115552
115712
|
|
|
115553
115713
|
// src/tools/impl/TodoWrite.ts
|
|
115554
115714
|
async function todo_write(args) {
|
|
115715
|
+
validateRequiredParams(args, ["todos"], "TodoWrite");
|
|
115555
115716
|
if (!args.todos || !Array.isArray(args.todos))
|
|
115556
115717
|
throw new Error("todos must be an array");
|
|
115557
115718
|
for (const todo of args.todos) {
|
|
@@ -115568,11 +115729,13 @@ async function todo_write(args) {
|
|
|
115568
115729
|
message: "Todos have been modified successfully. Ensure that you continue to use the todo list to track your progress. Please proceed with the current tasks if applicable"
|
|
115569
115730
|
};
|
|
115570
115731
|
}
|
|
115732
|
+
var init_TodoWrite2 = () => {};
|
|
115571
115733
|
|
|
115572
115734
|
// src/tools/impl/Write.ts
|
|
115573
115735
|
import { promises as fs5 } from "node:fs";
|
|
115574
115736
|
import * as path6 from "node:path";
|
|
115575
115737
|
async function write(args) {
|
|
115738
|
+
validateRequiredParams(args, ["file_path", "content"], "Write");
|
|
115576
115739
|
const { file_path, content } = args;
|
|
115577
115740
|
if (!path6.isAbsolute(file_path))
|
|
115578
115741
|
throw new Error(`File path must be absolute, got: ${file_path}`);
|
|
@@ -115701,7 +115864,7 @@ var init_Edit3 = __esm(() => {
|
|
|
115701
115864
|
|
|
115702
115865
|
// src/tools/schemas/ExitPlanMode.json
|
|
115703
115866
|
var ExitPlanMode_default2;
|
|
115704
|
-
var
|
|
115867
|
+
var init_ExitPlanMode3 = __esm(() => {
|
|
115705
115868
|
ExitPlanMode_default2 = {
|
|
115706
115869
|
$schema: "http://json-schema.org/draft-07/schema#",
|
|
115707
115870
|
type: "object",
|
|
@@ -115908,7 +116071,7 @@ var init_Read3 = __esm(() => {
|
|
|
115908
116071
|
|
|
115909
116072
|
// src/tools/schemas/TodoWrite.json
|
|
115910
116073
|
var TodoWrite_default2;
|
|
115911
|
-
var
|
|
116074
|
+
var init_TodoWrite3 = __esm(() => {
|
|
115912
116075
|
TodoWrite_default2 = {
|
|
115913
116076
|
type: "object",
|
|
115914
116077
|
properties: {
|
|
@@ -115984,24 +116147,26 @@ var init_toolDefinitions = __esm(() => {
|
|
|
115984
116147
|
init_Bash2();
|
|
115985
116148
|
init_BashOutput2();
|
|
115986
116149
|
init_Edit2();
|
|
116150
|
+
init_ExitPlanMode2();
|
|
115987
116151
|
init_Glob2();
|
|
115988
116152
|
init_Grep2();
|
|
115989
116153
|
init_KillBash2();
|
|
115990
116154
|
init_LS2();
|
|
115991
116155
|
init_MultiEdit2();
|
|
115992
116156
|
init_Read2();
|
|
116157
|
+
init_TodoWrite2();
|
|
115993
116158
|
init_Write2();
|
|
115994
116159
|
init_Bash3();
|
|
115995
116160
|
init_BashOutput3();
|
|
115996
116161
|
init_Edit3();
|
|
115997
|
-
|
|
116162
|
+
init_ExitPlanMode3();
|
|
115998
116163
|
init_Glob3();
|
|
115999
116164
|
init_Grep3();
|
|
116000
116165
|
init_KillBash3();
|
|
116001
116166
|
init_LS3();
|
|
116002
116167
|
init_MultiEdit3();
|
|
116003
116168
|
init_Read3();
|
|
116004
|
-
|
|
116169
|
+
init_TodoWrite3();
|
|
116005
116170
|
init_Write3();
|
|
116006
116171
|
toolDefinitions = {
|
|
116007
116172
|
Bash: {
|
|
@@ -116109,7 +116274,7 @@ var package_default;
|
|
|
116109
116274
|
var init_package = __esm(() => {
|
|
116110
116275
|
package_default = {
|
|
116111
116276
|
name: "@letta-ai/letta-code",
|
|
116112
|
-
version: "0.1.
|
|
116277
|
+
version: "0.1.10",
|
|
116113
116278
|
description: "Letta Code is a CLI tool for interacting with stateful Letta agents from the terminal.",
|
|
116114
116279
|
type: "module",
|
|
116115
116280
|
bin: {
|
|
@@ -116294,26 +116459,44 @@ var exports_client = {};
|
|
|
116294
116459
|
__export(exports_client, {
|
|
116295
116460
|
getClient: () => getClient2
|
|
116296
116461
|
});
|
|
116297
|
-
function getClient2() {
|
|
116298
|
-
const
|
|
116462
|
+
async function getClient2() {
|
|
116463
|
+
const settings = await loadSettings();
|
|
116464
|
+
const token = process.env.LETTA_API_KEY || settings.env?.LETTA_API_KEY;
|
|
116299
116465
|
if (!token) {
|
|
116300
116466
|
console.error("Missing LETTA_API_KEY");
|
|
116467
|
+
console.error("Set it via environment variable or add it to ~/.letta/settings.json:");
|
|
116468
|
+
console.error(' { "env": { "LETTA_API_KEY": "sk-let-..." } }');
|
|
116301
116469
|
process.exit(1);
|
|
116302
116470
|
}
|
|
116303
|
-
|
|
116471
|
+
const baseUrl = process.env.LETTA_BASE_URL || settings.env?.LETTA_BASE_URL || "https://api.letta.com";
|
|
116472
|
+
let needsUpdate = false;
|
|
116473
|
+
const updatedEnv = { ...settings.env };
|
|
116474
|
+
if (process.env.LETTA_API_KEY && !settings.env?.LETTA_API_KEY) {
|
|
116475
|
+
updatedEnv.LETTA_API_KEY = process.env.LETTA_API_KEY;
|
|
116476
|
+
needsUpdate = true;
|
|
116477
|
+
}
|
|
116478
|
+
if (process.env.LETTA_BASE_URL && !settings.env?.LETTA_BASE_URL) {
|
|
116479
|
+
updatedEnv.LETTA_BASE_URL = process.env.LETTA_BASE_URL;
|
|
116480
|
+
needsUpdate = true;
|
|
116481
|
+
}
|
|
116482
|
+
if (needsUpdate) {
|
|
116483
|
+
await updateSettings({ env: updatedEnv });
|
|
116484
|
+
}
|
|
116485
|
+
return new import_letta_client2.LettaClient({ token, baseUrl });
|
|
116304
116486
|
}
|
|
116305
116487
|
var import_letta_client2;
|
|
116306
116488
|
var init_client = __esm(() => {
|
|
116489
|
+
init_settings();
|
|
116307
116490
|
import_letta_client2 = __toESM(require_letta_client(), 1);
|
|
116308
116491
|
});
|
|
116309
116492
|
|
|
116310
116493
|
// src/project-settings.ts
|
|
116311
|
-
import { join as
|
|
116312
|
-
function
|
|
116313
|
-
return
|
|
116494
|
+
import { join as join5 } from "node:path";
|
|
116495
|
+
function getProjectSettingsPath3(workingDirectory) {
|
|
116496
|
+
return join5(workingDirectory, ".letta", "settings.json");
|
|
116314
116497
|
}
|
|
116315
|
-
async function
|
|
116316
|
-
const settingsPath =
|
|
116498
|
+
async function loadProjectSettings3(workingDirectory = process.cwd()) {
|
|
116499
|
+
const settingsPath = getProjectSettingsPath3(workingDirectory);
|
|
116317
116500
|
try {
|
|
116318
116501
|
if (!exists(settingsPath)) {
|
|
116319
116502
|
return DEFAULT_PROJECT_SETTINGS;
|
|
@@ -116328,8 +116511,8 @@ async function loadProjectSettings(workingDirectory = process.cwd()) {
|
|
|
116328
116511
|
return DEFAULT_PROJECT_SETTINGS;
|
|
116329
116512
|
}
|
|
116330
116513
|
}
|
|
116331
|
-
async function
|
|
116332
|
-
const settingsPath =
|
|
116514
|
+
async function saveProjectSettings3(workingDirectory, updates) {
|
|
116515
|
+
const settingsPath = getProjectSettingsPath3(workingDirectory);
|
|
116333
116516
|
try {
|
|
116334
116517
|
let existingSettings = {};
|
|
116335
116518
|
if (exists(settingsPath)) {
|
|
@@ -116346,9 +116529,9 @@ async function saveProjectSettings(workingDirectory, updates) {
|
|
|
116346
116529
|
throw error;
|
|
116347
116530
|
}
|
|
116348
116531
|
}
|
|
116349
|
-
async function
|
|
116350
|
-
await
|
|
116351
|
-
return
|
|
116532
|
+
async function updateProjectSettings3(workingDirectory, updates) {
|
|
116533
|
+
await saveProjectSettings3(workingDirectory, updates);
|
|
116534
|
+
return loadProjectSettings3(workingDirectory);
|
|
116352
116535
|
}
|
|
116353
116536
|
var DEFAULT_PROJECT_SETTINGS;
|
|
116354
116537
|
var init_project_settings = __esm(() => {
|
|
@@ -116358,64 +116541,6 @@ var init_project_settings = __esm(() => {
|
|
|
116358
116541
|
};
|
|
116359
116542
|
});
|
|
116360
116543
|
|
|
116361
|
-
// src/settings.ts
|
|
116362
|
-
var exports_settings2 = {};
|
|
116363
|
-
__export(exports_settings2, {
|
|
116364
|
-
updateSettings: () => updateSettings2,
|
|
116365
|
-
saveSettings: () => saveSettings2,
|
|
116366
|
-
loadSettings: () => loadSettings2,
|
|
116367
|
-
getSetting: () => getSetting2
|
|
116368
|
-
});
|
|
116369
|
-
import { homedir as homedir2 } from "node:os";
|
|
116370
|
-
import { join as join5 } from "node:path";
|
|
116371
|
-
function getSettingsPath2() {
|
|
116372
|
-
return join5(homedir2(), ".letta", "settings.json");
|
|
116373
|
-
}
|
|
116374
|
-
async function loadSettings2() {
|
|
116375
|
-
const settingsPath = getSettingsPath2();
|
|
116376
|
-
try {
|
|
116377
|
-
if (!exists(settingsPath)) {
|
|
116378
|
-
await saveSettings2(DEFAULT_SETTINGS2);
|
|
116379
|
-
return DEFAULT_SETTINGS2;
|
|
116380
|
-
}
|
|
116381
|
-
const content = await readFile(settingsPath);
|
|
116382
|
-
const settings = JSON.parse(content);
|
|
116383
|
-
return { ...DEFAULT_SETTINGS2, ...settings };
|
|
116384
|
-
} catch (error) {
|
|
116385
|
-
console.error("Error loading settings, using defaults:", error);
|
|
116386
|
-
return DEFAULT_SETTINGS2;
|
|
116387
|
-
}
|
|
116388
|
-
}
|
|
116389
|
-
async function saveSettings2(settings) {
|
|
116390
|
-
const settingsPath = getSettingsPath2();
|
|
116391
|
-
try {
|
|
116392
|
-
await writeFile(settingsPath, JSON.stringify(settings, null, 2));
|
|
116393
|
-
} catch (error) {
|
|
116394
|
-
console.error("Error saving settings:", error);
|
|
116395
|
-
throw error;
|
|
116396
|
-
}
|
|
116397
|
-
}
|
|
116398
|
-
async function updateSettings2(updates) {
|
|
116399
|
-
const currentSettings = await loadSettings2();
|
|
116400
|
-
const newSettings = { ...currentSettings, ...updates };
|
|
116401
|
-
await saveSettings2(newSettings);
|
|
116402
|
-
return newSettings;
|
|
116403
|
-
}
|
|
116404
|
-
async function getSetting2(key) {
|
|
116405
|
-
const settings = await loadSettings2();
|
|
116406
|
-
return settings[key];
|
|
116407
|
-
}
|
|
116408
|
-
var DEFAULT_SETTINGS2;
|
|
116409
|
-
var init_settings2 = __esm(() => {
|
|
116410
|
-
init_fs();
|
|
116411
|
-
DEFAULT_SETTINGS2 = {
|
|
116412
|
-
uiMode: "simple",
|
|
116413
|
-
lastAgent: null,
|
|
116414
|
-
tokenStreaming: false,
|
|
116415
|
-
globalSharedBlockIds: {}
|
|
116416
|
-
};
|
|
116417
|
-
});
|
|
116418
|
-
|
|
116419
116544
|
// src/permissions/cli.ts
|
|
116420
116545
|
class CliPermissions2 {
|
|
116421
116546
|
allowedTools = [];
|
|
@@ -119152,7 +119277,7 @@ var init_memory = __esm(() => {
|
|
|
119152
119277
|
|
|
119153
119278
|
// src/agent/create.ts
|
|
119154
119279
|
async function createAgent(name = "letta-cli-agent", model = "anthropic/claude-sonnet-4-5-20250929") {
|
|
119155
|
-
const client = getClient2();
|
|
119280
|
+
const client = await getClient2();
|
|
119156
119281
|
const toolNames = [
|
|
119157
119282
|
...getToolNames(),
|
|
119158
119283
|
"memory",
|
|
@@ -119160,9 +119285,9 @@ async function createAgent(name = "letta-cli-agent", model = "anthropic/claude-s
|
|
|
119160
119285
|
"conversation_search"
|
|
119161
119286
|
];
|
|
119162
119287
|
const defaultMemoryBlocks = await getDefaultMemoryBlocks();
|
|
119163
|
-
const settings = await
|
|
119288
|
+
const settings = await loadSettings();
|
|
119164
119289
|
const globalSharedBlockIds = settings.globalSharedBlockIds;
|
|
119165
|
-
const projectSettings = await
|
|
119290
|
+
const projectSettings = await loadProjectSettings3();
|
|
119166
119291
|
const localSharedBlockIds = projectSettings.localSharedBlockIds;
|
|
119167
119292
|
const existingBlocks = new Map;
|
|
119168
119293
|
for (const [label, blockId] of Object.entries(globalSharedBlockIds)) {
|
|
@@ -119214,7 +119339,7 @@ async function createAgent(name = "letta-cli-agent", model = "anthropic/claude-s
|
|
|
119214
119339
|
}
|
|
119215
119340
|
}
|
|
119216
119341
|
if (Object.keys(newGlobalBlockIds).length > 0) {
|
|
119217
|
-
await
|
|
119342
|
+
await updateSettings({
|
|
119218
119343
|
globalSharedBlockIds: {
|
|
119219
119344
|
...globalSharedBlockIds,
|
|
119220
119345
|
...newGlobalBlockIds
|
|
@@ -119222,7 +119347,7 @@ async function createAgent(name = "letta-cli-agent", model = "anthropic/claude-s
|
|
|
119222
119347
|
});
|
|
119223
119348
|
}
|
|
119224
119349
|
if (Object.keys(newLocalBlockIds).length > 0) {
|
|
119225
|
-
await
|
|
119350
|
+
await updateProjectSettings3(process.cwd(), {
|
|
119226
119351
|
localSharedBlockIds: {
|
|
119227
119352
|
...localSharedBlockIds,
|
|
119228
119353
|
...newLocalBlockIds
|
|
@@ -119246,7 +119371,7 @@ async function createAgent(name = "letta-cli-agent", model = "anthropic/claude-s
|
|
|
119246
119371
|
var import_letta_client3;
|
|
119247
119372
|
var init_create = __esm(() => {
|
|
119248
119373
|
init_project_settings();
|
|
119249
|
-
|
|
119374
|
+
init_settings();
|
|
119250
119375
|
init_manager();
|
|
119251
119376
|
init_client();
|
|
119252
119377
|
init_memory();
|
|
@@ -119256,7 +119381,7 @@ var init_create = __esm(() => {
|
|
|
119256
119381
|
|
|
119257
119382
|
// src/agent/message.ts
|
|
119258
119383
|
async function sendMessageStream(agentId, messages, opts = { streamTokens: true, background: true }) {
|
|
119259
|
-
const client = getClient2();
|
|
119384
|
+
const client = await getClient2();
|
|
119260
119385
|
return client.agents.messages.createStream(agentId, {
|
|
119261
119386
|
messages,
|
|
119262
119387
|
streamTokens: opts.streamTokens ?? true,
|
|
@@ -119314,6 +119439,14 @@ class SessionStats {
|
|
|
119314
119439
|
}
|
|
119315
119440
|
|
|
119316
119441
|
// src/cli/helpers/accumulator.ts
|
|
119442
|
+
var exports_accumulator = {};
|
|
119443
|
+
__export(exports_accumulator, {
|
|
119444
|
+
toLines: () => toLines,
|
|
119445
|
+
onChunk: () => onChunk,
|
|
119446
|
+
markIncompleteToolsAsCancelled: () => markIncompleteToolsAsCancelled,
|
|
119447
|
+
markCurrentLineAsFinished: () => markCurrentLineAsFinished,
|
|
119448
|
+
createBuffers: () => createBuffers
|
|
119449
|
+
});
|
|
119317
119450
|
function createBuffers() {
|
|
119318
119451
|
return {
|
|
119319
119452
|
tokenCount: 0,
|
|
@@ -119399,6 +119532,20 @@ function extractTextPart(v) {
|
|
|
119399
119532
|
return "";
|
|
119400
119533
|
}
|
|
119401
119534
|
function onChunk(b, chunk) {
|
|
119535
|
+
const chunkWithError = chunk;
|
|
119536
|
+
if (chunkWithError.error && !chunk.messageType) {
|
|
119537
|
+
const errorId = `err-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
|
|
119538
|
+
const errorMsg = chunkWithError.error.message || "An error occurred";
|
|
119539
|
+
const errorDetail = chunkWithError.error.detail || "";
|
|
119540
|
+
const fullErrorText = errorDetail ? `${errorMsg}: ${errorDetail}` : errorMsg;
|
|
119541
|
+
b.byId.set(errorId, {
|
|
119542
|
+
kind: "error",
|
|
119543
|
+
id: errorId,
|
|
119544
|
+
text: `⚠ ${fullErrorText}`
|
|
119545
|
+
});
|
|
119546
|
+
b.order.push(errorId);
|
|
119547
|
+
return;
|
|
119548
|
+
}
|
|
119402
119549
|
switch (chunk.messageType) {
|
|
119403
119550
|
case "reasoning_message": {
|
|
119404
119551
|
const id = chunk.otid;
|
|
@@ -119627,11 +119774,12 @@ __export(exports_headless, {
|
|
|
119627
119774
|
});
|
|
119628
119775
|
import { parseArgs } from "node:util";
|
|
119629
119776
|
async function handleHeadlessCommand(argv) {
|
|
119630
|
-
const settings = await
|
|
119777
|
+
const settings = await loadSettings();
|
|
119631
119778
|
const { values, positionals } = parseArgs({
|
|
119632
119779
|
args: argv,
|
|
119633
119780
|
options: {
|
|
119634
119781
|
continue: { type: "boolean", short: "c" },
|
|
119782
|
+
new: { type: "boolean" },
|
|
119635
119783
|
agent: { type: "string", short: "a" },
|
|
119636
119784
|
"output-format": { type: "string" }
|
|
119637
119785
|
},
|
|
@@ -119652,10 +119800,11 @@ async function handleHeadlessCommand(argv) {
|
|
|
119652
119800
|
console.error("Error: No prompt provided");
|
|
119653
119801
|
process.exit(1);
|
|
119654
119802
|
}
|
|
119655
|
-
const client = getClient2();
|
|
119803
|
+
const client = await getClient2();
|
|
119656
119804
|
let agent = null;
|
|
119657
119805
|
const specifiedAgentId = values.agent;
|
|
119658
119806
|
const shouldContinue = values.continue;
|
|
119807
|
+
const forceNew = values.new;
|
|
119659
119808
|
if (specifiedAgentId) {
|
|
119660
119809
|
try {
|
|
119661
119810
|
agent = await client.agents.retrieve(specifiedAgentId);
|
|
@@ -119663,6 +119812,20 @@ async function handleHeadlessCommand(argv) {
|
|
|
119663
119812
|
console.error(`Agent ${specifiedAgentId} not found, creating new one...`);
|
|
119664
119813
|
}
|
|
119665
119814
|
}
|
|
119815
|
+
if (!agent && forceNew) {
|
|
119816
|
+
agent = await createAgent();
|
|
119817
|
+
}
|
|
119818
|
+
if (!agent) {
|
|
119819
|
+
const { loadProjectSettings: loadProjectSettings4 } = await Promise.resolve().then(() => (init_settings(), exports_settings));
|
|
119820
|
+
const projectSettings = await loadProjectSettings4();
|
|
119821
|
+
if (projectSettings?.lastAgent) {
|
|
119822
|
+
try {
|
|
119823
|
+
agent = await client.agents.retrieve(projectSettings.lastAgent);
|
|
119824
|
+
} catch (_error) {
|
|
119825
|
+
console.error(`Project agent ${projectSettings.lastAgent} not found, creating new one...`);
|
|
119826
|
+
}
|
|
119827
|
+
}
|
|
119828
|
+
}
|
|
119666
119829
|
if (!agent && shouldContinue && settings.lastAgent) {
|
|
119667
119830
|
try {
|
|
119668
119831
|
agent = await client.agents.retrieve(settings.lastAgent);
|
|
@@ -119672,8 +119835,10 @@ async function handleHeadlessCommand(argv) {
|
|
|
119672
119835
|
}
|
|
119673
119836
|
if (!agent) {
|
|
119674
119837
|
agent = await createAgent();
|
|
119675
|
-
await updateSettings2({ lastAgent: agent.id });
|
|
119676
119838
|
}
|
|
119839
|
+
const { updateProjectSettings: updateProjectSettings4 } = await Promise.resolve().then(() => (init_settings(), exports_settings));
|
|
119840
|
+
await updateProjectSettings4({ lastAgent: agent.id });
|
|
119841
|
+
await updateSettings({ lastAgent: agent.id });
|
|
119677
119842
|
const outputFormat = values["output-format"] || "text";
|
|
119678
119843
|
if (!["text", "json", "stream-json"].includes(outputFormat)) {
|
|
119679
119844
|
console.error(`Error: Invalid output format "${outputFormat}". Valid formats: text, json, stream-json`);
|
|
@@ -119681,6 +119846,15 @@ async function handleHeadlessCommand(argv) {
|
|
|
119681
119846
|
}
|
|
119682
119847
|
const buffers = createBuffers();
|
|
119683
119848
|
const sessionStats = new SessionStats;
|
|
119849
|
+
if (outputFormat === "stream-json") {
|
|
119850
|
+
const initEvent = {
|
|
119851
|
+
type: "init",
|
|
119852
|
+
agent_id: agent.id,
|
|
119853
|
+
model: agent.llmConfig?.model,
|
|
119854
|
+
tools: agent.tools?.map((t) => t.name) || []
|
|
119855
|
+
};
|
|
119856
|
+
console.log(JSON.stringify(initEvent));
|
|
119857
|
+
}
|
|
119684
119858
|
let currentInput = [
|
|
119685
119859
|
{
|
|
119686
119860
|
role: import_letta_client5.Letta.MessageCreateRole.User,
|
|
@@ -119690,7 +119864,44 @@ async function handleHeadlessCommand(argv) {
|
|
|
119690
119864
|
try {
|
|
119691
119865
|
while (true) {
|
|
119692
119866
|
const stream = await sendMessageStream(agent.id, currentInput);
|
|
119693
|
-
|
|
119867
|
+
let stopReason;
|
|
119868
|
+
let approval = null;
|
|
119869
|
+
let apiDurationMs;
|
|
119870
|
+
if (outputFormat === "stream-json") {
|
|
119871
|
+
const startTime = performance.now();
|
|
119872
|
+
let lastStopReason = null;
|
|
119873
|
+
for await (const chunk of stream) {
|
|
119874
|
+
console.log(JSON.stringify({
|
|
119875
|
+
type: "message",
|
|
119876
|
+
...chunk
|
|
119877
|
+
}));
|
|
119878
|
+
const { onChunk: onChunk2 } = await Promise.resolve().then(() => exports_accumulator);
|
|
119879
|
+
onChunk2(buffers, chunk);
|
|
119880
|
+
if (chunk.messageType === "stop_reason") {
|
|
119881
|
+
lastStopReason = chunk.stopReason;
|
|
119882
|
+
}
|
|
119883
|
+
if (chunk.messageType === "approval_request_message") {
|
|
119884
|
+
const chunkWithToolCall = chunk;
|
|
119885
|
+
const toolCall = chunkWithToolCall.toolCall;
|
|
119886
|
+
if (toolCall?.toolCallId && toolCall?.name) {
|
|
119887
|
+
approval = {
|
|
119888
|
+
toolCallId: toolCall.toolCallId,
|
|
119889
|
+
toolName: toolCall.name,
|
|
119890
|
+
toolArgs: toolCall.arguments || "{}"
|
|
119891
|
+
};
|
|
119892
|
+
}
|
|
119893
|
+
}
|
|
119894
|
+
}
|
|
119895
|
+
stopReason = lastStopReason || import_letta_client5.Letta.StopReasonType.Error;
|
|
119896
|
+
apiDurationMs = performance.now() - startTime;
|
|
119897
|
+
const { markCurrentLineAsFinished: markCurrentLineAsFinished2 } = await Promise.resolve().then(() => exports_accumulator);
|
|
119898
|
+
markCurrentLineAsFinished2(buffers);
|
|
119899
|
+
} else {
|
|
119900
|
+
const result = await drainStream(stream, buffers, () => {});
|
|
119901
|
+
stopReason = result.stopReason;
|
|
119902
|
+
approval = result.approval || null;
|
|
119903
|
+
apiDurationMs = result.apiDurationMs;
|
|
119904
|
+
}
|
|
119694
119905
|
sessionStats.endTurn(apiDurationMs);
|
|
119695
119906
|
if (stopReason === import_letta_client5.Letta.StopReasonType.EndTurn) {
|
|
119696
119907
|
break;
|
|
@@ -119765,16 +119976,32 @@ async function handleHeadlessCommand(argv) {
|
|
|
119765
119976
|
duration_api_ms: Math.round(stats.totalApiMs),
|
|
119766
119977
|
num_turns: stats.usage.stepCount,
|
|
119767
119978
|
result: resultText,
|
|
119768
|
-
|
|
119979
|
+
agent_id: agent.id,
|
|
119769
119980
|
usage: {
|
|
119770
|
-
|
|
119771
|
-
|
|
119981
|
+
prompt_tokens: stats.usage.promptTokens,
|
|
119982
|
+
completion_tokens: stats.usage.completionTokens,
|
|
119983
|
+
total_tokens: stats.usage.totalTokens
|
|
119772
119984
|
}
|
|
119773
119985
|
};
|
|
119774
119986
|
console.log(JSON.stringify(output, null, 2));
|
|
119775
119987
|
} else if (outputFormat === "stream-json") {
|
|
119776
|
-
|
|
119777
|
-
|
|
119988
|
+
const stats = sessionStats.getSnapshot();
|
|
119989
|
+
const resultEvent = {
|
|
119990
|
+
type: "result",
|
|
119991
|
+
subtype: "success",
|
|
119992
|
+
is_error: false,
|
|
119993
|
+
duration_ms: Math.round(stats.totalWallMs),
|
|
119994
|
+
duration_api_ms: Math.round(stats.totalApiMs),
|
|
119995
|
+
num_turns: stats.usage.stepCount,
|
|
119996
|
+
result: resultText,
|
|
119997
|
+
agent_id: agent.id,
|
|
119998
|
+
usage: {
|
|
119999
|
+
prompt_tokens: stats.usage.promptTokens,
|
|
120000
|
+
completion_tokens: stats.usage.completionTokens,
|
|
120001
|
+
total_tokens: stats.usage.totalTokens
|
|
120002
|
+
}
|
|
120003
|
+
};
|
|
120004
|
+
console.log(JSON.stringify(resultEvent));
|
|
119778
120005
|
} else {
|
|
119779
120006
|
if (!lastAssistant || !("text" in lastAssistant)) {
|
|
119780
120007
|
console.error("No assistant response found");
|
|
@@ -119789,7 +120016,7 @@ var init_headless = __esm(() => {
|
|
|
119789
120016
|
init_create();
|
|
119790
120017
|
init_message();
|
|
119791
120018
|
init_stream();
|
|
119792
|
-
|
|
120019
|
+
init_settings();
|
|
119793
120020
|
init_manager();
|
|
119794
120021
|
import_letta_client5 = __toESM(require_letta_client(), 1);
|
|
119795
120022
|
});
|
|
@@ -146101,7 +146328,9 @@ function PasteAwareTextInput({
|
|
|
146101
146328
|
onChange,
|
|
146102
146329
|
onSubmit,
|
|
146103
146330
|
placeholder,
|
|
146104
|
-
focus = true
|
|
146331
|
+
focus = true,
|
|
146332
|
+
cursorPosition,
|
|
146333
|
+
onCursorMove
|
|
146105
146334
|
}) {
|
|
146106
146335
|
const [displayValue, setDisplayValue] = import_react25.useState(value);
|
|
146107
146336
|
const [actualValue, setActualValue] = import_react25.useState(value);
|
|
@@ -146109,6 +146338,15 @@ function PasteAwareTextInput({
|
|
|
146109
146338
|
const suppressNextChangeRef = import_react25.useRef(false);
|
|
146110
146339
|
const caretOffsetRef = import_react25.useRef((value || "").length);
|
|
146111
146340
|
const [nudgeCursorOffset, setNudgeCursorOffset] = import_react25.useState(undefined);
|
|
146341
|
+
import_react25.useEffect(() => {
|
|
146342
|
+
if (typeof cursorPosition === "number") {
|
|
146343
|
+
setNudgeCursorOffset(cursorPosition);
|
|
146344
|
+
caretOffsetRef.current = cursorPosition;
|
|
146345
|
+
}
|
|
146346
|
+
}, [cursorPosition]);
|
|
146347
|
+
import_react25.useEffect(() => {
|
|
146348
|
+
onCursorMove?.(displayValue.length);
|
|
146349
|
+
}, [displayValue, onCursorMove]);
|
|
146112
146350
|
const TextInputAny = build_default;
|
|
146113
146351
|
import_react25.useEffect(() => {
|
|
146114
146352
|
setDisplayValue(value);
|
|
@@ -146303,6 +146541,28 @@ var import_react26, jsx_dev_runtime4, OptionsRenderer, DynamicPreview = ({
|
|
|
146303
146541
|
]
|
|
146304
146542
|
}, undefined, true, undefined, this);
|
|
146305
146543
|
}
|
|
146544
|
+
if (t === "ls") {
|
|
146545
|
+
const pathVal = parsedArgs?.path;
|
|
146546
|
+
const path8 = typeof pathVal === "string" ? pathVal : "(current directory)";
|
|
146547
|
+
const ignoreVal = parsedArgs?.ignore;
|
|
146548
|
+
const ignore = Array.isArray(ignoreVal) && ignoreVal.length > 0 ? ` (ignoring: ${ignoreVal.join(", ")})` : "";
|
|
146549
|
+
return /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Box_default, {
|
|
146550
|
+
flexDirection: "column",
|
|
146551
|
+
paddingLeft: 2,
|
|
146552
|
+
children: [
|
|
146553
|
+
/* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Text, {
|
|
146554
|
+
children: [
|
|
146555
|
+
"List files in: ",
|
|
146556
|
+
path8
|
|
146557
|
+
]
|
|
146558
|
+
}, undefined, true, undefined, this),
|
|
146559
|
+
ignore ? /* @__PURE__ */ jsx_dev_runtime4.jsxDEV(Text, {
|
|
146560
|
+
dimColor: true,
|
|
146561
|
+
children: ignore
|
|
146562
|
+
}, undefined, false, undefined, this) : null
|
|
146563
|
+
]
|
|
146564
|
+
}, undefined, true, undefined, this);
|
|
146565
|
+
}
|
|
146306
146566
|
if ((t === "write" || t === "edit" || t === "multiedit") && parsedArgs) {
|
|
146307
146567
|
try {
|
|
146308
146568
|
const filePath = String(parsedArgs.file_path || "");
|
|
@@ -146640,7 +146900,10 @@ var init_ApprovalDialogRich = __esm(async () => {
|
|
|
146640
146900
|
});
|
|
146641
146901
|
|
|
146642
146902
|
// src/cli/components/InlineMarkdownRenderer.tsx
|
|
146643
|
-
var jsx_dev_runtime5, InlineMarkdown = ({
|
|
146903
|
+
var jsx_dev_runtime5, InlineMarkdown = ({
|
|
146904
|
+
text,
|
|
146905
|
+
dimColor
|
|
146906
|
+
}) => {
|
|
146644
146907
|
if (!/[*~`[]/.test(text)) {
|
|
146645
146908
|
return /* @__PURE__ */ jsx_dev_runtime5.jsxDEV(jsx_dev_runtime5.Fragment, {
|
|
146646
146909
|
children: text
|
|
@@ -146659,16 +146922,19 @@ var jsx_dev_runtime5, InlineMarkdown = ({ text }) => {
|
|
|
146659
146922
|
if (fullMatch.startsWith("**") && fullMatch.endsWith("**") && fullMatch.length > 4) {
|
|
146660
146923
|
nodes.push(/* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Text, {
|
|
146661
146924
|
bold: true,
|
|
146925
|
+
dimColor,
|
|
146662
146926
|
children: fullMatch.slice(2, -2)
|
|
146663
146927
|
}, key, false, undefined, this));
|
|
146664
146928
|
} else if (fullMatch.length > 2 && fullMatch.startsWith("*") && fullMatch.endsWith("*")) {
|
|
146665
146929
|
nodes.push(/* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Text, {
|
|
146666
146930
|
italic: true,
|
|
146931
|
+
dimColor,
|
|
146667
146932
|
children: fullMatch.slice(1, -1)
|
|
146668
146933
|
}, key, false, undefined, this));
|
|
146669
146934
|
} else if (fullMatch.startsWith("~~") && fullMatch.endsWith("~~") && fullMatch.length > 4) {
|
|
146670
146935
|
nodes.push(/* @__PURE__ */ jsx_dev_runtime5.jsxDEV(Text, {
|
|
146671
146936
|
strikethrough: true,
|
|
146937
|
+
dimColor,
|
|
146672
146938
|
children: fullMatch.slice(2, -2)
|
|
146673
146939
|
}, key, false, undefined, this));
|
|
146674
146940
|
} else if (fullMatch.startsWith("`") && fullMatch.endsWith("`")) {
|
|
@@ -146774,7 +147040,8 @@ var jsx_dev_runtime6, MarkdownDisplay = ({
|
|
|
146774
147040
|
bold: true,
|
|
146775
147041
|
color: colors.heading.primary,
|
|
146776
147042
|
children: /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(InlineMarkdown, {
|
|
146777
|
-
text: content
|
|
147043
|
+
text: content,
|
|
147044
|
+
dimColor
|
|
146778
147045
|
}, undefined, false, undefined, this)
|
|
146779
147046
|
}, undefined, false, undefined, this);
|
|
146780
147047
|
} else if (level === 2) {
|
|
@@ -146782,21 +147049,24 @@ var jsx_dev_runtime6, MarkdownDisplay = ({
|
|
|
146782
147049
|
bold: true,
|
|
146783
147050
|
color: colors.heading.secondary,
|
|
146784
147051
|
children: /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(InlineMarkdown, {
|
|
146785
|
-
text: content
|
|
147052
|
+
text: content,
|
|
147053
|
+
dimColor
|
|
146786
147054
|
}, undefined, false, undefined, this)
|
|
146787
147055
|
}, undefined, false, undefined, this);
|
|
146788
147056
|
} else if (level === 3) {
|
|
146789
147057
|
headerElement = /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Text, {
|
|
146790
147058
|
bold: true,
|
|
146791
147059
|
children: /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(InlineMarkdown, {
|
|
146792
|
-
text: content
|
|
147060
|
+
text: content,
|
|
147061
|
+
dimColor
|
|
146793
147062
|
}, undefined, false, undefined, this)
|
|
146794
147063
|
}, undefined, false, undefined, this);
|
|
146795
147064
|
} else {
|
|
146796
147065
|
headerElement = /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Text, {
|
|
146797
147066
|
italic: true,
|
|
146798
147067
|
children: /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(InlineMarkdown, {
|
|
146799
|
-
text: content
|
|
147068
|
+
text: content,
|
|
147069
|
+
dimColor
|
|
146800
147070
|
}, undefined, false, undefined, this)
|
|
146801
147071
|
}, undefined, false, undefined, this);
|
|
146802
147072
|
}
|
|
@@ -146832,7 +147102,8 @@ var jsx_dev_runtime6, MarkdownDisplay = ({
|
|
|
146832
147102
|
wrap: "wrap",
|
|
146833
147103
|
dimColor,
|
|
146834
147104
|
children: /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(InlineMarkdown, {
|
|
146835
|
-
text: content
|
|
147105
|
+
text: content,
|
|
147106
|
+
dimColor
|
|
146836
147107
|
}, undefined, false, undefined, this)
|
|
146837
147108
|
}, undefined, false, undefined, this)
|
|
146838
147109
|
}, undefined, false, undefined, this)
|
|
@@ -146853,7 +147124,8 @@ var jsx_dev_runtime6, MarkdownDisplay = ({
|
|
|
146853
147124
|
wrap: "wrap",
|
|
146854
147125
|
dimColor,
|
|
146855
147126
|
children: /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(InlineMarkdown, {
|
|
146856
|
-
text: blockquoteMatch[1]
|
|
147127
|
+
text: blockquoteMatch[1],
|
|
147128
|
+
dimColor
|
|
146857
147129
|
}, undefined, false, undefined, this)
|
|
146858
147130
|
}, undefined, false, undefined, this)
|
|
146859
147131
|
]
|
|
@@ -146883,14 +147155,16 @@ var jsx_dev_runtime6, MarkdownDisplay = ({
|
|
|
146883
147155
|
wrap: "wrap",
|
|
146884
147156
|
dimColor,
|
|
146885
147157
|
children: /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(InlineMarkdown, {
|
|
146886
|
-
text: line
|
|
147158
|
+
text: line,
|
|
147159
|
+
dimColor
|
|
146887
147160
|
}, undefined, false, undefined, this)
|
|
146888
147161
|
}, undefined, false, undefined, this)
|
|
146889
147162
|
}, undefined, false, undefined, this) : /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(Text, {
|
|
146890
147163
|
wrap: "wrap",
|
|
146891
147164
|
dimColor,
|
|
146892
147165
|
children: /* @__PURE__ */ jsx_dev_runtime6.jsxDEV(InlineMarkdown, {
|
|
146893
|
-
text: line
|
|
147166
|
+
text: line,
|
|
147167
|
+
dimColor
|
|
146894
147168
|
}, undefined, false, undefined, this)
|
|
146895
147169
|
}, undefined, false, undefined, this)
|
|
146896
147170
|
}, key, false, undefined, this));
|
|
@@ -148835,8 +149109,317 @@ var init_CommandPreview = __esm(async () => {
|
|
|
148835
149109
|
}));
|
|
148836
149110
|
});
|
|
148837
149111
|
|
|
149112
|
+
// src/cli/helpers/fileSearch.ts
|
|
149113
|
+
import { readdirSync, statSync as statSync2 } from "node:fs";
|
|
149114
|
+
import { join as join7, resolve as resolve8 } from "node:path";
|
|
149115
|
+
function searchDirectoryRecursive(dir, pattern, maxDepth = 3, currentDepth = 0, maxResults = 100, results = []) {
|
|
149116
|
+
if (currentDepth > maxDepth || results.length >= maxResults) {
|
|
149117
|
+
return results;
|
|
149118
|
+
}
|
|
149119
|
+
try {
|
|
149120
|
+
const entries = readdirSync(dir);
|
|
149121
|
+
for (const entry of entries) {
|
|
149122
|
+
if (entry.startsWith(".") || entry === "node_modules" || entry === "dist" || entry === "build") {
|
|
149123
|
+
continue;
|
|
149124
|
+
}
|
|
149125
|
+
try {
|
|
149126
|
+
const fullPath = join7(dir, entry);
|
|
149127
|
+
const stats = statSync2(fullPath);
|
|
149128
|
+
const matches = pattern.length === 0 || entry.toLowerCase().includes(pattern.toLowerCase());
|
|
149129
|
+
if (matches) {
|
|
149130
|
+
const relativePath = fullPath.startsWith(process.cwd()) ? fullPath.slice(process.cwd().length + 1) : fullPath;
|
|
149131
|
+
results.push({
|
|
149132
|
+
path: relativePath,
|
|
149133
|
+
type: stats.isDirectory() ? "dir" : "file"
|
|
149134
|
+
});
|
|
149135
|
+
if (results.length >= maxResults) {
|
|
149136
|
+
return results;
|
|
149137
|
+
}
|
|
149138
|
+
}
|
|
149139
|
+
if (stats.isDirectory()) {
|
|
149140
|
+
searchDirectoryRecursive(fullPath, pattern, maxDepth, currentDepth + 1, maxResults, results);
|
|
149141
|
+
}
|
|
149142
|
+
} catch {}
|
|
149143
|
+
}
|
|
149144
|
+
} catch {}
|
|
149145
|
+
return results;
|
|
149146
|
+
}
|
|
149147
|
+
async function searchFiles(query, deep = false) {
|
|
149148
|
+
const results = [];
|
|
149149
|
+
try {
|
|
149150
|
+
let searchDir = process.cwd();
|
|
149151
|
+
let searchPattern = query;
|
|
149152
|
+
if (query.includes("/")) {
|
|
149153
|
+
const lastSlashIndex = query.lastIndexOf("/");
|
|
149154
|
+
const dirPart = query.slice(0, lastSlashIndex);
|
|
149155
|
+
searchPattern = query.slice(lastSlashIndex + 1);
|
|
149156
|
+
try {
|
|
149157
|
+
searchDir = resolve8(process.cwd(), dirPart);
|
|
149158
|
+
} catch {
|
|
149159
|
+
return [];
|
|
149160
|
+
}
|
|
149161
|
+
}
|
|
149162
|
+
if (deep) {
|
|
149163
|
+
const deepResults = searchDirectoryRecursive(searchDir, searchPattern, 3, 0, 100);
|
|
149164
|
+
results.push(...deepResults);
|
|
149165
|
+
} else {
|
|
149166
|
+
let entries = [];
|
|
149167
|
+
try {
|
|
149168
|
+
entries = readdirSync(searchDir);
|
|
149169
|
+
} catch {
|
|
149170
|
+
return [];
|
|
149171
|
+
}
|
|
149172
|
+
const matchingEntries = searchPattern.length === 0 ? entries : entries.filter((entry) => entry.toLowerCase().includes(searchPattern.toLowerCase()));
|
|
149173
|
+
for (const entry of matchingEntries.slice(0, 50)) {
|
|
149174
|
+
try {
|
|
149175
|
+
const fullPath = join7(searchDir, entry);
|
|
149176
|
+
const stats = statSync2(fullPath);
|
|
149177
|
+
const relativePath = fullPath.startsWith(process.cwd()) ? fullPath.slice(process.cwd().length + 1) : fullPath;
|
|
149178
|
+
results.push({
|
|
149179
|
+
path: relativePath,
|
|
149180
|
+
type: stats.isDirectory() ? "dir" : "file"
|
|
149181
|
+
});
|
|
149182
|
+
} catch {}
|
|
149183
|
+
}
|
|
149184
|
+
}
|
|
149185
|
+
results.sort((a, b) => {
|
|
149186
|
+
if (a.type === "dir" && b.type !== "dir")
|
|
149187
|
+
return -1;
|
|
149188
|
+
if (a.type !== "dir" && b.type === "dir")
|
|
149189
|
+
return 1;
|
|
149190
|
+
return a.path.localeCompare(b.path);
|
|
149191
|
+
});
|
|
149192
|
+
} catch (error) {
|
|
149193
|
+
console.error("File search error:", error);
|
|
149194
|
+
return [];
|
|
149195
|
+
}
|
|
149196
|
+
return results;
|
|
149197
|
+
}
|
|
149198
|
+
var init_fileSearch = () => {};
|
|
149199
|
+
|
|
149200
|
+
// src/cli/components/FileAutocomplete.tsx
|
|
149201
|
+
function FileAutocomplete({
|
|
149202
|
+
currentInput,
|
|
149203
|
+
cursorPosition = currentInput.length,
|
|
149204
|
+
onSelect,
|
|
149205
|
+
onActiveChange
|
|
149206
|
+
}) {
|
|
149207
|
+
const [matches, setMatches] = import_react31.useState([]);
|
|
149208
|
+
const [isLoading, setIsLoading] = import_react31.useState(false);
|
|
149209
|
+
const [selectedIndex, setSelectedIndex] = import_react31.useState(0);
|
|
149210
|
+
const [lastValidQuery, setLastValidQuery] = import_react31.useState("");
|
|
149211
|
+
const extractSearchQuery = import_react31.useCallback((input, cursor) => {
|
|
149212
|
+
const atPositions = [];
|
|
149213
|
+
for (let i = 0;i < input.length; i++) {
|
|
149214
|
+
if (input[i] === "@") {
|
|
149215
|
+
if (i === 0 || input[i - 1] === " ") {
|
|
149216
|
+
atPositions.push(i);
|
|
149217
|
+
}
|
|
149218
|
+
}
|
|
149219
|
+
}
|
|
149220
|
+
if (atPositions.length === 0)
|
|
149221
|
+
return null;
|
|
149222
|
+
let atIndex = -1;
|
|
149223
|
+
for (const pos of atPositions) {
|
|
149224
|
+
const afterAt2 = input.slice(pos + 1);
|
|
149225
|
+
const spaceIndex2 = afterAt2.indexOf(" ");
|
|
149226
|
+
const endPos = spaceIndex2 === -1 ? input.length : pos + 1 + spaceIndex2;
|
|
149227
|
+
if (cursor >= pos && cursor <= endPos) {
|
|
149228
|
+
atIndex = pos;
|
|
149229
|
+
break;
|
|
149230
|
+
}
|
|
149231
|
+
}
|
|
149232
|
+
if (atIndex === -1)
|
|
149233
|
+
return null;
|
|
149234
|
+
const afterAt = input.slice(atIndex + 1);
|
|
149235
|
+
const spaceIndex = afterAt.indexOf(" ");
|
|
149236
|
+
const query = spaceIndex === -1 ? afterAt : afterAt.slice(0, spaceIndex);
|
|
149237
|
+
const hasSpaceAfter = spaceIndex !== -1;
|
|
149238
|
+
return { query, hasSpaceAfter, atIndex };
|
|
149239
|
+
}, []);
|
|
149240
|
+
use_input_default((_input, key) => {
|
|
149241
|
+
if (!matches.length || isLoading)
|
|
149242
|
+
return;
|
|
149243
|
+
const maxIndex = Math.min(matches.length, 10) - 1;
|
|
149244
|
+
if (key.upArrow) {
|
|
149245
|
+
setSelectedIndex((prev) => prev > 0 ? prev - 1 : maxIndex);
|
|
149246
|
+
} else if (key.downArrow) {
|
|
149247
|
+
setSelectedIndex((prev) => prev < maxIndex ? prev + 1 : 0);
|
|
149248
|
+
} else if ((key.tab || key.return) && onSelect) {
|
|
149249
|
+
const selected = matches[selectedIndex];
|
|
149250
|
+
if (selected) {
|
|
149251
|
+
onSelect(selected.path);
|
|
149252
|
+
}
|
|
149253
|
+
}
|
|
149254
|
+
});
|
|
149255
|
+
import_react31.useEffect(() => {
|
|
149256
|
+
const result = extractSearchQuery(currentInput, cursorPosition);
|
|
149257
|
+
if (!result) {
|
|
149258
|
+
setMatches([]);
|
|
149259
|
+
setSelectedIndex(0);
|
|
149260
|
+
onActiveChange?.(false);
|
|
149261
|
+
return;
|
|
149262
|
+
}
|
|
149263
|
+
const { query, hasSpaceAfter } = result;
|
|
149264
|
+
if (hasSpaceAfter && query.length > 0) {
|
|
149265
|
+
const atIndex = currentInput.lastIndexOf("@");
|
|
149266
|
+
const afterSpace = currentInput.slice(atIndex + 1 + query.length + 1);
|
|
149267
|
+
if (afterSpace.trim().length > 0 || afterSpace.includes("@")) {
|
|
149268
|
+
setMatches([]);
|
|
149269
|
+
setSelectedIndex(0);
|
|
149270
|
+
onActiveChange?.(false);
|
|
149271
|
+
return;
|
|
149272
|
+
}
|
|
149273
|
+
if (query === lastValidQuery && lastValidQuery.length > 0) {
|
|
149274
|
+
if (matches[0]?.path !== query) {
|
|
149275
|
+
setMatches([{ path: query, type: "file" }]);
|
|
149276
|
+
setSelectedIndex(0);
|
|
149277
|
+
}
|
|
149278
|
+
onActiveChange?.(false);
|
|
149279
|
+
return;
|
|
149280
|
+
}
|
|
149281
|
+
setMatches([]);
|
|
149282
|
+
setSelectedIndex(0);
|
|
149283
|
+
onActiveChange?.(false);
|
|
149284
|
+
return;
|
|
149285
|
+
}
|
|
149286
|
+
if (query.length === 0) {
|
|
149287
|
+
setIsLoading(true);
|
|
149288
|
+
onActiveChange?.(true);
|
|
149289
|
+
searchFiles("", false).then((results) => {
|
|
149290
|
+
setMatches(results);
|
|
149291
|
+
setSelectedIndex(0);
|
|
149292
|
+
setIsLoading(false);
|
|
149293
|
+
onActiveChange?.(results.length > 0);
|
|
149294
|
+
}).catch(() => {
|
|
149295
|
+
setMatches([]);
|
|
149296
|
+
setSelectedIndex(0);
|
|
149297
|
+
setIsLoading(false);
|
|
149298
|
+
onActiveChange?.(false);
|
|
149299
|
+
});
|
|
149300
|
+
return;
|
|
149301
|
+
}
|
|
149302
|
+
if (query.startsWith("http://") || query.startsWith("https://")) {
|
|
149303
|
+
setMatches([{ path: query, type: "url" }]);
|
|
149304
|
+
setSelectedIndex(0);
|
|
149305
|
+
onActiveChange?.(true);
|
|
149306
|
+
return;
|
|
149307
|
+
}
|
|
149308
|
+
setIsLoading(true);
|
|
149309
|
+
onActiveChange?.(true);
|
|
149310
|
+
searchFiles(query, true).then((results) => {
|
|
149311
|
+
setMatches(results);
|
|
149312
|
+
setSelectedIndex(0);
|
|
149313
|
+
setIsLoading(false);
|
|
149314
|
+
onActiveChange?.(results.length > 0);
|
|
149315
|
+
if (results.length > 0) {
|
|
149316
|
+
setLastValidQuery(query);
|
|
149317
|
+
}
|
|
149318
|
+
}).catch(() => {
|
|
149319
|
+
setMatches([]);
|
|
149320
|
+
setSelectedIndex(0);
|
|
149321
|
+
setIsLoading(false);
|
|
149322
|
+
onActiveChange?.(false);
|
|
149323
|
+
});
|
|
149324
|
+
}, [
|
|
149325
|
+
currentInput,
|
|
149326
|
+
cursorPosition,
|
|
149327
|
+
onActiveChange,
|
|
149328
|
+
extractSearchQuery,
|
|
149329
|
+
lastValidQuery,
|
|
149330
|
+
matches[0]?.path
|
|
149331
|
+
]);
|
|
149332
|
+
if (!currentInput.includes("@")) {
|
|
149333
|
+
return null;
|
|
149334
|
+
}
|
|
149335
|
+
if (matches.length === 0 && !isLoading) {
|
|
149336
|
+
return null;
|
|
149337
|
+
}
|
|
149338
|
+
return /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(Box_default, {
|
|
149339
|
+
flexDirection: "column",
|
|
149340
|
+
borderStyle: "round",
|
|
149341
|
+
borderColor: colors.command.border,
|
|
149342
|
+
paddingX: 1,
|
|
149343
|
+
marginBottom: 1,
|
|
149344
|
+
children: [
|
|
149345
|
+
/* @__PURE__ */ jsx_dev_runtime11.jsxDEV(Text, {
|
|
149346
|
+
dimColor: true,
|
|
149347
|
+
children: "File/URL autocomplete (↑↓ to navigate, Tab/Enter to select):"
|
|
149348
|
+
}, undefined, false, undefined, this),
|
|
149349
|
+
isLoading ? /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(Text, {
|
|
149350
|
+
dimColor: true,
|
|
149351
|
+
children: "Searching..."
|
|
149352
|
+
}, undefined, false, undefined, this) : matches.slice(0, 10).map((item, idx) => /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(Box_default, {
|
|
149353
|
+
flexDirection: "row",
|
|
149354
|
+
gap: 1,
|
|
149355
|
+
children: [
|
|
149356
|
+
/* @__PURE__ */ jsx_dev_runtime11.jsxDEV(Text, {
|
|
149357
|
+
color: idx === selectedIndex ? colors.status.success : item.type === "dir" ? colors.status.processing : undefined,
|
|
149358
|
+
bold: idx === selectedIndex,
|
|
149359
|
+
children: [
|
|
149360
|
+
idx === selectedIndex ? "▶ " : " ",
|
|
149361
|
+
item.type === "dir" ? "\uD83D\uDCC1" : item.type === "url" ? "\uD83D\uDD17" : "\uD83D\uDCC4"
|
|
149362
|
+
]
|
|
149363
|
+
}, undefined, true, undefined, this),
|
|
149364
|
+
/* @__PURE__ */ jsx_dev_runtime11.jsxDEV(Text, {
|
|
149365
|
+
bold: idx === selectedIndex,
|
|
149366
|
+
children: item.path
|
|
149367
|
+
}, undefined, false, undefined, this)
|
|
149368
|
+
]
|
|
149369
|
+
}, item.path, true, undefined, this)),
|
|
149370
|
+
matches.length > 10 && /* @__PURE__ */ jsx_dev_runtime11.jsxDEV(Text, {
|
|
149371
|
+
dimColor: true,
|
|
149372
|
+
children: [
|
|
149373
|
+
"... and ",
|
|
149374
|
+
matches.length - 10,
|
|
149375
|
+
" more"
|
|
149376
|
+
]
|
|
149377
|
+
}, undefined, true, undefined, this)
|
|
149378
|
+
]
|
|
149379
|
+
}, undefined, true, undefined, this);
|
|
149380
|
+
}
|
|
149381
|
+
var import_react31, jsx_dev_runtime11;
|
|
149382
|
+
var init_FileAutocomplete = __esm(async () => {
|
|
149383
|
+
init_fileSearch();
|
|
149384
|
+
init_colors();
|
|
149385
|
+
await init_build3();
|
|
149386
|
+
import_react31 = __toESM(require_react2(), 1);
|
|
149387
|
+
jsx_dev_runtime11 = __toESM(require_jsx_dev_runtime(), 1);
|
|
149388
|
+
});
|
|
149389
|
+
|
|
149390
|
+
// src/cli/components/InputAssist.tsx
|
|
149391
|
+
function InputAssist({
|
|
149392
|
+
currentInput,
|
|
149393
|
+
cursorPosition,
|
|
149394
|
+
onFileSelect,
|
|
149395
|
+
onAutocompleteActiveChange
|
|
149396
|
+
}) {
|
|
149397
|
+
if (currentInput.includes("@")) {
|
|
149398
|
+
return /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(FileAutocomplete, {
|
|
149399
|
+
currentInput,
|
|
149400
|
+
cursorPosition,
|
|
149401
|
+
onSelect: onFileSelect,
|
|
149402
|
+
onActiveChange: onAutocompleteActiveChange
|
|
149403
|
+
}, undefined, false, undefined, this);
|
|
149404
|
+
}
|
|
149405
|
+
if (currentInput.startsWith("/")) {
|
|
149406
|
+
return /* @__PURE__ */ jsx_dev_runtime12.jsxDEV(CommandPreview, {
|
|
149407
|
+
currentInput
|
|
149408
|
+
}, undefined, false, undefined, this);
|
|
149409
|
+
}
|
|
149410
|
+
return null;
|
|
149411
|
+
}
|
|
149412
|
+
var jsx_dev_runtime12;
|
|
149413
|
+
var init_InputAssist = __esm(async () => {
|
|
149414
|
+
await __promiseAll([
|
|
149415
|
+
init_CommandPreview(),
|
|
149416
|
+
init_FileAutocomplete()
|
|
149417
|
+
]);
|
|
149418
|
+
jsx_dev_runtime12 = __toESM(require_jsx_dev_runtime(), 1);
|
|
149419
|
+
});
|
|
149420
|
+
|
|
148838
149421
|
// src/cli/components/ShimmerText.tsx
|
|
148839
|
-
var
|
|
149422
|
+
var jsx_dev_runtime13, ShimmerText = ({
|
|
148840
149423
|
color = colors.status.processing,
|
|
148841
149424
|
message,
|
|
148842
149425
|
shimmerOffset
|
|
@@ -148849,7 +149432,7 @@ var jsx_dev_runtime11, ShimmerText = ({
|
|
|
148849
149432
|
}
|
|
148850
149433
|
return source_default.hex(color)(char);
|
|
148851
149434
|
}).join("");
|
|
148852
|
-
return /* @__PURE__ */
|
|
149435
|
+
return /* @__PURE__ */ jsx_dev_runtime13.jsxDEV(Text, {
|
|
148853
149436
|
children: shimmerText
|
|
148854
149437
|
}, undefined, false, undefined, this);
|
|
148855
149438
|
};
|
|
@@ -148857,7 +149440,7 @@ var init_ShimmerText = __esm(async () => {
|
|
|
148857
149440
|
init_source();
|
|
148858
149441
|
init_colors();
|
|
148859
149442
|
await init_build3();
|
|
148860
|
-
|
|
149443
|
+
jsx_dev_runtime13 = __toESM(require_jsx_dev_runtime(), 1);
|
|
148861
149444
|
});
|
|
148862
149445
|
|
|
148863
149446
|
// src/cli/components/InputRich.tsx
|
|
@@ -148874,19 +149457,25 @@ function Input({
|
|
|
148874
149457
|
onInterrupt,
|
|
148875
149458
|
interruptRequested = false
|
|
148876
149459
|
}) {
|
|
148877
|
-
const [value, setValue] =
|
|
148878
|
-
const [escapePressed, setEscapePressed] =
|
|
148879
|
-
const escapeTimerRef =
|
|
148880
|
-
const [ctrlCPressed, setCtrlCPressed] =
|
|
148881
|
-
const ctrlCTimerRef =
|
|
148882
|
-
const previousValueRef =
|
|
148883
|
-
const [currentMode, setCurrentMode] =
|
|
148884
|
-
|
|
149460
|
+
const [value, setValue] = import_react32.useState("");
|
|
149461
|
+
const [escapePressed, setEscapePressed] = import_react32.useState(false);
|
|
149462
|
+
const escapeTimerRef = import_react32.useRef(null);
|
|
149463
|
+
const [ctrlCPressed, setCtrlCPressed] = import_react32.useState(false);
|
|
149464
|
+
const ctrlCTimerRef = import_react32.useRef(null);
|
|
149465
|
+
const previousValueRef = import_react32.useRef(value);
|
|
149466
|
+
const [currentMode, setCurrentMode] = import_react32.useState(externalMode || permissionMode2.getMode());
|
|
149467
|
+
const [isAutocompleteActive, setIsAutocompleteActive] = import_react32.useState(false);
|
|
149468
|
+
const [cursorPos, setCursorPos] = import_react32.useState(undefined);
|
|
149469
|
+
const [currentCursorPosition, setCurrentCursorPosition] = import_react32.useState(0);
|
|
149470
|
+
const [history, setHistory] = import_react32.useState([]);
|
|
149471
|
+
const [historyIndex, setHistoryIndex] = import_react32.useState(-1);
|
|
149472
|
+
const [temporaryInput, setTemporaryInput] = import_react32.useState("");
|
|
149473
|
+
import_react32.useEffect(() => {
|
|
148885
149474
|
if (externalMode !== undefined) {
|
|
148886
149475
|
setCurrentMode(externalMode);
|
|
148887
149476
|
}
|
|
148888
149477
|
}, [externalMode]);
|
|
148889
|
-
const [shimmerOffset, setShimmerOffset] =
|
|
149478
|
+
const [shimmerOffset, setShimmerOffset] = import_react32.useState(-3);
|
|
148890
149479
|
const columns = useTerminalWidth();
|
|
148891
149480
|
const contentWidth = Math.max(0, columns - 2);
|
|
148892
149481
|
use_input_default((_input, key) => {
|
|
@@ -148946,7 +149535,34 @@ function Input({
|
|
|
148946
149535
|
}
|
|
148947
149536
|
}
|
|
148948
149537
|
});
|
|
148949
|
-
|
|
149538
|
+
use_input_default((_input, key) => {
|
|
149539
|
+
if (isAutocompleteActive) {
|
|
149540
|
+
return;
|
|
149541
|
+
}
|
|
149542
|
+
if (key.upArrow) {
|
|
149543
|
+
if (history.length === 0)
|
|
149544
|
+
return;
|
|
149545
|
+
if (historyIndex === -1) {
|
|
149546
|
+
setTemporaryInput(value);
|
|
149547
|
+
setHistoryIndex(history.length - 1);
|
|
149548
|
+
setValue(history[history.length - 1] ?? "");
|
|
149549
|
+
} else if (historyIndex > 0) {
|
|
149550
|
+
setHistoryIndex(historyIndex - 1);
|
|
149551
|
+
setValue(history[historyIndex - 1] ?? "");
|
|
149552
|
+
}
|
|
149553
|
+
} else if (key.downArrow) {
|
|
149554
|
+
if (historyIndex === -1)
|
|
149555
|
+
return;
|
|
149556
|
+
if (historyIndex < history.length - 1) {
|
|
149557
|
+
setHistoryIndex(historyIndex + 1);
|
|
149558
|
+
setValue(history[historyIndex + 1] ?? "");
|
|
149559
|
+
} else {
|
|
149560
|
+
setHistoryIndex(-1);
|
|
149561
|
+
setValue(temporaryInput);
|
|
149562
|
+
}
|
|
149563
|
+
}
|
|
149564
|
+
});
|
|
149565
|
+
import_react32.useEffect(() => {
|
|
148950
149566
|
if (value !== previousValueRef.current && value !== "") {
|
|
148951
149567
|
setEscapePressed(false);
|
|
148952
149568
|
if (escapeTimerRef.current)
|
|
@@ -148957,7 +149573,13 @@ function Input({
|
|
|
148957
149573
|
}
|
|
148958
149574
|
previousValueRef.current = value;
|
|
148959
149575
|
}, [value]);
|
|
148960
|
-
|
|
149576
|
+
import_react32.useEffect(() => {
|
|
149577
|
+
if (historyIndex !== -1 && value !== history[historyIndex]) {
|
|
149578
|
+
setHistoryIndex(-1);
|
|
149579
|
+
setTemporaryInput("");
|
|
149580
|
+
}
|
|
149581
|
+
}, [value, historyIndex, history]);
|
|
149582
|
+
import_react32.useEffect(() => {
|
|
148961
149583
|
return () => {
|
|
148962
149584
|
if (escapeTimerRef.current)
|
|
148963
149585
|
clearTimeout(escapeTimerRef.current);
|
|
@@ -148965,7 +149587,7 @@ function Input({
|
|
|
148965
149587
|
clearTimeout(ctrlCTimerRef.current);
|
|
148966
149588
|
};
|
|
148967
149589
|
}, []);
|
|
148968
|
-
|
|
149590
|
+
import_react32.useEffect(() => {
|
|
148969
149591
|
if (!streaming || !visible)
|
|
148970
149592
|
return;
|
|
148971
149593
|
const id = setInterval(() => {
|
|
@@ -148978,16 +149600,45 @@ function Input({
|
|
|
148978
149600
|
return () => clearInterval(id);
|
|
148979
149601
|
}, [streaming, thinkingMessage, visible]);
|
|
148980
149602
|
const handleSubmit = async () => {
|
|
149603
|
+
if (isAutocompleteActive) {
|
|
149604
|
+
return;
|
|
149605
|
+
}
|
|
148981
149606
|
if (streaming || commandRunning) {
|
|
148982
149607
|
return;
|
|
148983
149608
|
}
|
|
148984
149609
|
const previousValue = value;
|
|
149610
|
+
if (previousValue.trim() && previousValue !== history[history.length - 1]) {
|
|
149611
|
+
setHistory([...history, previousValue]);
|
|
149612
|
+
}
|
|
149613
|
+
setHistoryIndex(-1);
|
|
149614
|
+
setTemporaryInput("");
|
|
148985
149615
|
setValue("");
|
|
148986
149616
|
const result = await onSubmit(previousValue);
|
|
148987
149617
|
if (!result.submitted) {
|
|
148988
149618
|
setValue(previousValue);
|
|
148989
149619
|
}
|
|
148990
149620
|
};
|
|
149621
|
+
const handleFileSelect = (selectedPath) => {
|
|
149622
|
+
const atIndex = value.lastIndexOf("@");
|
|
149623
|
+
if (atIndex === -1)
|
|
149624
|
+
return;
|
|
149625
|
+
const beforeAt = value.slice(0, atIndex);
|
|
149626
|
+
const afterAt = value.slice(atIndex + 1);
|
|
149627
|
+
const spaceIndex = afterAt.indexOf(" ");
|
|
149628
|
+
let newValue;
|
|
149629
|
+
let newCursorPos;
|
|
149630
|
+
if (spaceIndex === -1) {
|
|
149631
|
+
newValue = `${beforeAt}@${selectedPath} `;
|
|
149632
|
+
newCursorPos = newValue.length;
|
|
149633
|
+
} else {
|
|
149634
|
+
const afterQuery = afterAt.slice(spaceIndex);
|
|
149635
|
+
newValue = `${beforeAt}@${selectedPath}${afterQuery}`;
|
|
149636
|
+
newCursorPos = beforeAt.length + selectedPath.length + 1;
|
|
149637
|
+
}
|
|
149638
|
+
setValue(newValue);
|
|
149639
|
+
setCursorPos(newCursorPos);
|
|
149640
|
+
setTimeout(() => setCursorPos(undefined), 50);
|
|
149641
|
+
};
|
|
148991
149642
|
const getModeInfo = () => {
|
|
148992
149643
|
switch (currentMode) {
|
|
148993
149644
|
case "acceptEdits":
|
|
@@ -149009,31 +149660,31 @@ function Input({
|
|
|
149009
149660
|
if (!visible) {
|
|
149010
149661
|
return null;
|
|
149011
149662
|
}
|
|
149012
|
-
return /* @__PURE__ */
|
|
149663
|
+
return /* @__PURE__ */ jsx_dev_runtime14.jsxDEV(Box_default, {
|
|
149013
149664
|
flexDirection: "column",
|
|
149014
149665
|
children: [
|
|
149015
|
-
streaming && /* @__PURE__ */
|
|
149666
|
+
streaming && /* @__PURE__ */ jsx_dev_runtime14.jsxDEV(Box_default, {
|
|
149016
149667
|
flexDirection: "row",
|
|
149017
149668
|
marginBottom: 1,
|
|
149018
149669
|
children: [
|
|
149019
|
-
/* @__PURE__ */
|
|
149670
|
+
/* @__PURE__ */ jsx_dev_runtime14.jsxDEV(Box_default, {
|
|
149020
149671
|
width: 2,
|
|
149021
149672
|
flexShrink: 0,
|
|
149022
|
-
children: /* @__PURE__ */
|
|
149673
|
+
children: /* @__PURE__ */ jsx_dev_runtime14.jsxDEV(Text, {
|
|
149023
149674
|
color: colors.status.processing,
|
|
149024
|
-
children: /* @__PURE__ */
|
|
149675
|
+
children: /* @__PURE__ */ jsx_dev_runtime14.jsxDEV(Spinner2, {
|
|
149025
149676
|
type: "layer"
|
|
149026
149677
|
}, undefined, false, undefined, this)
|
|
149027
149678
|
}, undefined, false, undefined, this)
|
|
149028
149679
|
}, undefined, false, undefined, this),
|
|
149029
|
-
/* @__PURE__ */
|
|
149680
|
+
/* @__PURE__ */ jsx_dev_runtime14.jsxDEV(Box_default, {
|
|
149030
149681
|
flexGrow: 1,
|
|
149031
149682
|
children: [
|
|
149032
|
-
/* @__PURE__ */
|
|
149683
|
+
/* @__PURE__ */ jsx_dev_runtime14.jsxDEV(ShimmerText, {
|
|
149033
149684
|
message: thinkingMessage,
|
|
149034
149685
|
shimmerOffset
|
|
149035
149686
|
}, undefined, false, undefined, this),
|
|
149036
|
-
/* @__PURE__ */
|
|
149687
|
+
/* @__PURE__ */ jsx_dev_runtime14.jsxDEV(Text, {
|
|
149037
149688
|
dimColor: true,
|
|
149038
149689
|
children: [
|
|
149039
149690
|
" (",
|
|
@@ -149046,66 +149697,72 @@ function Input({
|
|
|
149046
149697
|
}, undefined, true, undefined, this)
|
|
149047
149698
|
]
|
|
149048
149699
|
}, undefined, true, undefined, this),
|
|
149049
|
-
/* @__PURE__ */
|
|
149700
|
+
/* @__PURE__ */ jsx_dev_runtime14.jsxDEV(Box_default, {
|
|
149050
149701
|
flexDirection: "column",
|
|
149051
149702
|
children: [
|
|
149052
|
-
/* @__PURE__ */
|
|
149703
|
+
/* @__PURE__ */ jsx_dev_runtime14.jsxDEV(Text, {
|
|
149053
149704
|
dimColor: true,
|
|
149054
149705
|
children: horizontalLine
|
|
149055
149706
|
}, undefined, false, undefined, this),
|
|
149056
|
-
/* @__PURE__ */
|
|
149707
|
+
/* @__PURE__ */ jsx_dev_runtime14.jsxDEV(Box_default, {
|
|
149057
149708
|
flexDirection: "row",
|
|
149058
149709
|
children: [
|
|
149059
|
-
/* @__PURE__ */
|
|
149710
|
+
/* @__PURE__ */ jsx_dev_runtime14.jsxDEV(Box_default, {
|
|
149060
149711
|
width: 2,
|
|
149061
149712
|
flexShrink: 0,
|
|
149062
149713
|
children: [
|
|
149063
|
-
/* @__PURE__ */
|
|
149714
|
+
/* @__PURE__ */ jsx_dev_runtime14.jsxDEV(Text, {
|
|
149064
149715
|
color: colors.input.prompt,
|
|
149065
149716
|
children: ">"
|
|
149066
149717
|
}, undefined, false, undefined, this),
|
|
149067
|
-
/* @__PURE__ */
|
|
149718
|
+
/* @__PURE__ */ jsx_dev_runtime14.jsxDEV(Text, {
|
|
149068
149719
|
children: " "
|
|
149069
149720
|
}, undefined, false, undefined, this)
|
|
149070
149721
|
]
|
|
149071
149722
|
}, undefined, true, undefined, this),
|
|
149072
|
-
/* @__PURE__ */
|
|
149723
|
+
/* @__PURE__ */ jsx_dev_runtime14.jsxDEV(Box_default, {
|
|
149073
149724
|
flexGrow: 1,
|
|
149074
149725
|
width: contentWidth,
|
|
149075
|
-
children: /* @__PURE__ */
|
|
149726
|
+
children: /* @__PURE__ */ jsx_dev_runtime14.jsxDEV(PasteAwareTextInput, {
|
|
149076
149727
|
value,
|
|
149077
149728
|
onChange: setValue,
|
|
149078
|
-
onSubmit: handleSubmit
|
|
149729
|
+
onSubmit: handleSubmit,
|
|
149730
|
+
cursorPosition: cursorPos,
|
|
149731
|
+
onCursorMove: setCurrentCursorPosition
|
|
149079
149732
|
}, undefined, false, undefined, this)
|
|
149080
149733
|
}, undefined, false, undefined, this)
|
|
149081
149734
|
]
|
|
149082
149735
|
}, undefined, true, undefined, this),
|
|
149083
|
-
/* @__PURE__ */
|
|
149736
|
+
/* @__PURE__ */ jsx_dev_runtime14.jsxDEV(Text, {
|
|
149084
149737
|
dimColor: true,
|
|
149085
149738
|
children: horizontalLine
|
|
149086
149739
|
}, undefined, false, undefined, this),
|
|
149087
|
-
|
|
149088
|
-
currentInput: value
|
|
149089
|
-
|
|
149740
|
+
/* @__PURE__ */ jsx_dev_runtime14.jsxDEV(InputAssist, {
|
|
149741
|
+
currentInput: value,
|
|
149742
|
+
cursorPosition: currentCursorPosition,
|
|
149743
|
+
onFileSelect: handleFileSelect,
|
|
149744
|
+
onAutocompleteActiveChange: setIsAutocompleteActive
|
|
149745
|
+
}, undefined, false, undefined, this),
|
|
149746
|
+
/* @__PURE__ */ jsx_dev_runtime14.jsxDEV(Box_default, {
|
|
149090
149747
|
justifyContent: "space-between",
|
|
149091
149748
|
marginBottom: 1,
|
|
149092
149749
|
children: [
|
|
149093
|
-
ctrlCPressed ? /* @__PURE__ */
|
|
149750
|
+
ctrlCPressed ? /* @__PURE__ */ jsx_dev_runtime14.jsxDEV(Text, {
|
|
149094
149751
|
dimColor: true,
|
|
149095
149752
|
children: "Press CTRL-C again to exit"
|
|
149096
|
-
}, undefined, false, undefined, this) : escapePressed ? /* @__PURE__ */
|
|
149753
|
+
}, undefined, false, undefined, this) : escapePressed ? /* @__PURE__ */ jsx_dev_runtime14.jsxDEV(Text, {
|
|
149097
149754
|
dimColor: true,
|
|
149098
149755
|
children: "Press Esc again to clear"
|
|
149099
|
-
}, undefined, false, undefined, this) : modeInfo ? /* @__PURE__ */
|
|
149756
|
+
}, undefined, false, undefined, this) : modeInfo ? /* @__PURE__ */ jsx_dev_runtime14.jsxDEV(Text, {
|
|
149100
149757
|
children: [
|
|
149101
|
-
/* @__PURE__ */
|
|
149758
|
+
/* @__PURE__ */ jsx_dev_runtime14.jsxDEV(Text, {
|
|
149102
149759
|
color: modeInfo.color,
|
|
149103
149760
|
children: [
|
|
149104
149761
|
"⏵⏵ ",
|
|
149105
149762
|
modeInfo.name
|
|
149106
149763
|
]
|
|
149107
149764
|
}, undefined, true, undefined, this),
|
|
149108
|
-
/* @__PURE__ */
|
|
149765
|
+
/* @__PURE__ */ jsx_dev_runtime14.jsxDEV(Text, {
|
|
149109
149766
|
color: modeInfo.color,
|
|
149110
149767
|
dimColor: true,
|
|
149111
149768
|
children: [
|
|
@@ -149114,11 +149771,11 @@ function Input({
|
|
|
149114
149771
|
]
|
|
149115
149772
|
}, undefined, true, undefined, this)
|
|
149116
149773
|
]
|
|
149117
|
-
}, undefined, true, undefined, this) : /* @__PURE__ */
|
|
149774
|
+
}, undefined, true, undefined, this) : /* @__PURE__ */ jsx_dev_runtime14.jsxDEV(Text, {
|
|
149118
149775
|
dimColor: true,
|
|
149119
|
-
children: "Press / for commands"
|
|
149776
|
+
children: "Press / for commands or @ for files"
|
|
149120
149777
|
}, undefined, false, undefined, this),
|
|
149121
|
-
/* @__PURE__ */
|
|
149778
|
+
/* @__PURE__ */ jsx_dev_runtime14.jsxDEV(Text, {
|
|
149122
149779
|
dimColor: true,
|
|
149123
149780
|
children: "https://discord.gg/letta"
|
|
149124
149781
|
}, undefined, false, undefined, this)
|
|
@@ -149129,7 +149786,7 @@ function Input({
|
|
|
149129
149786
|
]
|
|
149130
149787
|
}, undefined, true, undefined, this);
|
|
149131
149788
|
}
|
|
149132
|
-
var
|
|
149789
|
+
var import_react32, jsx_dev_runtime14, Spinner2, COUNTER_VISIBLE_THRESHOLD = 1000;
|
|
149133
149790
|
var init_InputRich = __esm(async () => {
|
|
149134
149791
|
init_mode();
|
|
149135
149792
|
init_useTerminalWidth();
|
|
@@ -149137,12 +149794,12 @@ var init_InputRich = __esm(async () => {
|
|
|
149137
149794
|
await __promiseAll([
|
|
149138
149795
|
init_build3(),
|
|
149139
149796
|
init_build5(),
|
|
149140
|
-
|
|
149797
|
+
init_InputAssist(),
|
|
149141
149798
|
init_PasteAwareTextInput(),
|
|
149142
149799
|
init_ShimmerText()
|
|
149143
149800
|
]);
|
|
149144
|
-
|
|
149145
|
-
|
|
149801
|
+
import_react32 = __toESM(require_react2(), 1);
|
|
149802
|
+
jsx_dev_runtime14 = __toESM(require_jsx_dev_runtime(), 1);
|
|
149146
149803
|
Spinner2 = build_default2;
|
|
149147
149804
|
});
|
|
149148
149805
|
|
|
@@ -149256,7 +149913,7 @@ function ModelSelector({
|
|
|
149256
149913
|
onSelect,
|
|
149257
149914
|
onCancel
|
|
149258
149915
|
}) {
|
|
149259
|
-
const [selectedIndex, setSelectedIndex] =
|
|
149916
|
+
const [selectedIndex, setSelectedIndex] = import_react33.useState(0);
|
|
149260
149917
|
use_input_default((_input, key) => {
|
|
149261
149918
|
if (key.upArrow) {
|
|
149262
149919
|
setSelectedIndex((prev) => Math.max(0, prev - 1));
|
|
@@ -149271,45 +149928,45 @@ function ModelSelector({
|
|
|
149271
149928
|
onCancel();
|
|
149272
149929
|
}
|
|
149273
149930
|
});
|
|
149274
|
-
return /* @__PURE__ */
|
|
149931
|
+
return /* @__PURE__ */ jsx_dev_runtime15.jsxDEV(Box_default, {
|
|
149275
149932
|
flexDirection: "column",
|
|
149276
149933
|
gap: 1,
|
|
149277
149934
|
children: [
|
|
149278
|
-
/* @__PURE__ */
|
|
149279
|
-
children: /* @__PURE__ */
|
|
149935
|
+
/* @__PURE__ */ jsx_dev_runtime15.jsxDEV(Box_default, {
|
|
149936
|
+
children: /* @__PURE__ */ jsx_dev_runtime15.jsxDEV(Text, {
|
|
149280
149937
|
bold: true,
|
|
149281
149938
|
color: colors.selector.title,
|
|
149282
149939
|
children: "Select Model (↑↓ to navigate, Enter to select, ESC to cancel)"
|
|
149283
149940
|
}, undefined, false, undefined, this)
|
|
149284
149941
|
}, undefined, false, undefined, this),
|
|
149285
|
-
/* @__PURE__ */
|
|
149942
|
+
/* @__PURE__ */ jsx_dev_runtime15.jsxDEV(Box_default, {
|
|
149286
149943
|
flexDirection: "column",
|
|
149287
149944
|
children: import_models.default.map((model, index) => {
|
|
149288
149945
|
const isSelected = index === selectedIndex;
|
|
149289
149946
|
const isCurrent = model.handle === currentModel;
|
|
149290
|
-
return /* @__PURE__ */
|
|
149947
|
+
return /* @__PURE__ */ jsx_dev_runtime15.jsxDEV(Box_default, {
|
|
149291
149948
|
flexDirection: "row",
|
|
149292
149949
|
gap: 1,
|
|
149293
149950
|
children: [
|
|
149294
|
-
/* @__PURE__ */
|
|
149951
|
+
/* @__PURE__ */ jsx_dev_runtime15.jsxDEV(Text, {
|
|
149295
149952
|
color: isSelected ? colors.selector.itemHighlighted : undefined,
|
|
149296
149953
|
children: isSelected ? "›" : " "
|
|
149297
149954
|
}, undefined, false, undefined, this),
|
|
149298
|
-
/* @__PURE__ */
|
|
149955
|
+
/* @__PURE__ */ jsx_dev_runtime15.jsxDEV(Box_default, {
|
|
149299
149956
|
flexDirection: "row",
|
|
149300
149957
|
children: [
|
|
149301
|
-
/* @__PURE__ */
|
|
149958
|
+
/* @__PURE__ */ jsx_dev_runtime15.jsxDEV(Text, {
|
|
149302
149959
|
bold: isSelected,
|
|
149303
149960
|
color: isSelected ? colors.selector.itemHighlighted : undefined,
|
|
149304
149961
|
children: [
|
|
149305
149962
|
model.label,
|
|
149306
|
-
isCurrent && /* @__PURE__ */
|
|
149963
|
+
isCurrent && /* @__PURE__ */ jsx_dev_runtime15.jsxDEV(Text, {
|
|
149307
149964
|
color: colors.selector.itemCurrent,
|
|
149308
149965
|
children: " (current)"
|
|
149309
149966
|
}, undefined, false, undefined, this)
|
|
149310
149967
|
]
|
|
149311
149968
|
}, undefined, true, undefined, this),
|
|
149312
|
-
/* @__PURE__ */
|
|
149969
|
+
/* @__PURE__ */ jsx_dev_runtime15.jsxDEV(Text, {
|
|
149313
149970
|
dimColor: true,
|
|
149314
149971
|
children: [
|
|
149315
149972
|
" ",
|
|
@@ -149325,17 +149982,17 @@ function ModelSelector({
|
|
|
149325
149982
|
]
|
|
149326
149983
|
}, undefined, true, undefined, this);
|
|
149327
149984
|
}
|
|
149328
|
-
var
|
|
149985
|
+
var import_react33, import_models, jsx_dev_runtime15;
|
|
149329
149986
|
var init_ModelSelector = __esm(async () => {
|
|
149330
149987
|
init_colors();
|
|
149331
149988
|
await init_build3();
|
|
149332
|
-
|
|
149989
|
+
import_react33 = __toESM(require_react2(), 1);
|
|
149333
149990
|
import_models = __toESM(require_models3(), 1);
|
|
149334
|
-
|
|
149991
|
+
jsx_dev_runtime15 = __toESM(require_jsx_dev_runtime(), 1);
|
|
149335
149992
|
});
|
|
149336
149993
|
|
|
149337
149994
|
// src/cli/components/PlanModeDialog.tsx
|
|
149338
|
-
var
|
|
149995
|
+
var import_react34, jsx_dev_runtime16, OptionsRenderer2, PlanModeDialog;
|
|
149339
149996
|
var init_PlanModeDialog = __esm(async () => {
|
|
149340
149997
|
init_pasteRegistry();
|
|
149341
149998
|
init_colors();
|
|
@@ -149344,20 +150001,20 @@ var init_PlanModeDialog = __esm(async () => {
|
|
|
149344
150001
|
init_MarkdownDisplay(),
|
|
149345
150002
|
init_PasteAwareTextInput()
|
|
149346
150003
|
]);
|
|
149347
|
-
|
|
149348
|
-
|
|
149349
|
-
OptionsRenderer2 =
|
|
150004
|
+
import_react34 = __toESM(require_react2(), 1);
|
|
150005
|
+
jsx_dev_runtime16 = __toESM(require_jsx_dev_runtime(), 1);
|
|
150006
|
+
OptionsRenderer2 = import_react34.memo(({
|
|
149350
150007
|
options,
|
|
149351
150008
|
selectedOption
|
|
149352
150009
|
}) => {
|
|
149353
|
-
return /* @__PURE__ */
|
|
150010
|
+
return /* @__PURE__ */ jsx_dev_runtime16.jsxDEV(Box_default, {
|
|
149354
150011
|
flexDirection: "column",
|
|
149355
150012
|
children: options.map((option, index) => {
|
|
149356
150013
|
const isSelected = index === selectedOption;
|
|
149357
150014
|
const color = isSelected ? colors.approval.header : undefined;
|
|
149358
|
-
return /* @__PURE__ */
|
|
150015
|
+
return /* @__PURE__ */ jsx_dev_runtime16.jsxDEV(Box_default, {
|
|
149359
150016
|
flexDirection: "row",
|
|
149360
|
-
children: /* @__PURE__ */
|
|
150017
|
+
children: /* @__PURE__ */ jsx_dev_runtime16.jsxDEV(Text, {
|
|
149361
150018
|
color,
|
|
149362
150019
|
children: [
|
|
149363
150020
|
isSelected ? "❯" : " ",
|
|
@@ -149372,10 +150029,10 @@ var init_PlanModeDialog = __esm(async () => {
|
|
|
149372
150029
|
}, undefined, false, undefined, this);
|
|
149373
150030
|
});
|
|
149374
150031
|
OptionsRenderer2.displayName = "OptionsRenderer";
|
|
149375
|
-
PlanModeDialog =
|
|
149376
|
-
const [selectedOption, setSelectedOption] =
|
|
149377
|
-
const [isEnteringReason, setIsEnteringReason] =
|
|
149378
|
-
const [denyReason, setDenyReason] =
|
|
150032
|
+
PlanModeDialog = import_react34.memo(({ plan, onApprove, onApproveAndAcceptEdits, onKeepPlanning }) => {
|
|
150033
|
+
const [selectedOption, setSelectedOption] = import_react34.useState(0);
|
|
150034
|
+
const [isEnteringReason, setIsEnteringReason] = import_react34.useState(false);
|
|
150035
|
+
const [denyReason, setDenyReason] = import_react34.useState("");
|
|
149379
150036
|
const options = [
|
|
149380
150037
|
{ label: "Yes, and auto-accept edits", action: onApproveAndAcceptEdits },
|
|
149381
150038
|
{ label: "Yes, and manually approve edits", action: onApprove },
|
|
@@ -149409,30 +150066,30 @@ var init_PlanModeDialog = __esm(async () => {
|
|
|
149409
150066
|
}
|
|
149410
150067
|
});
|
|
149411
150068
|
if (isEnteringReason) {
|
|
149412
|
-
return /* @__PURE__ */
|
|
150069
|
+
return /* @__PURE__ */ jsx_dev_runtime16.jsxDEV(Box_default, {
|
|
149413
150070
|
flexDirection: "column",
|
|
149414
150071
|
children: [
|
|
149415
|
-
/* @__PURE__ */
|
|
150072
|
+
/* @__PURE__ */ jsx_dev_runtime16.jsxDEV(Box_default, {
|
|
149416
150073
|
borderStyle: "round",
|
|
149417
150074
|
borderColor: colors.approval.border,
|
|
149418
150075
|
width: "100%",
|
|
149419
150076
|
flexDirection: "column",
|
|
149420
150077
|
paddingX: 1,
|
|
149421
150078
|
children: [
|
|
149422
|
-
/* @__PURE__ */
|
|
150079
|
+
/* @__PURE__ */ jsx_dev_runtime16.jsxDEV(Text, {
|
|
149423
150080
|
bold: true,
|
|
149424
150081
|
children: "Enter feedback to continue planning (ESC to cancel):"
|
|
149425
150082
|
}, undefined, false, undefined, this),
|
|
149426
|
-
/* @__PURE__ */
|
|
150083
|
+
/* @__PURE__ */ jsx_dev_runtime16.jsxDEV(Box_default, {
|
|
149427
150084
|
height: 1
|
|
149428
150085
|
}, undefined, false, undefined, this),
|
|
149429
|
-
/* @__PURE__ */
|
|
150086
|
+
/* @__PURE__ */ jsx_dev_runtime16.jsxDEV(Box_default, {
|
|
149430
150087
|
children: [
|
|
149431
|
-
/* @__PURE__ */
|
|
150088
|
+
/* @__PURE__ */ jsx_dev_runtime16.jsxDEV(Text, {
|
|
149432
150089
|
dimColor: true,
|
|
149433
150090
|
children: "> "
|
|
149434
150091
|
}, undefined, false, undefined, this),
|
|
149435
|
-
/* @__PURE__ */
|
|
150092
|
+
/* @__PURE__ */ jsx_dev_runtime16.jsxDEV(PasteAwareTextInput, {
|
|
149436
150093
|
value: denyReason,
|
|
149437
150094
|
onChange: setDenyReason
|
|
149438
150095
|
}, undefined, false, undefined, this)
|
|
@@ -149440,49 +150097,49 @@ var init_PlanModeDialog = __esm(async () => {
|
|
|
149440
150097
|
}, undefined, true, undefined, this)
|
|
149441
150098
|
]
|
|
149442
150099
|
}, undefined, true, undefined, this),
|
|
149443
|
-
/* @__PURE__ */
|
|
150100
|
+
/* @__PURE__ */ jsx_dev_runtime16.jsxDEV(Box_default, {
|
|
149444
150101
|
height: 1
|
|
149445
150102
|
}, undefined, false, undefined, this)
|
|
149446
150103
|
]
|
|
149447
150104
|
}, undefined, true, undefined, this);
|
|
149448
150105
|
}
|
|
149449
|
-
return /* @__PURE__ */
|
|
150106
|
+
return /* @__PURE__ */ jsx_dev_runtime16.jsxDEV(Box_default, {
|
|
149450
150107
|
flexDirection: "column",
|
|
149451
150108
|
borderStyle: "round",
|
|
149452
150109
|
borderColor: colors.approval.border,
|
|
149453
150110
|
paddingX: 1,
|
|
149454
150111
|
children: [
|
|
149455
|
-
/* @__PURE__ */
|
|
150112
|
+
/* @__PURE__ */ jsx_dev_runtime16.jsxDEV(Text, {
|
|
149456
150113
|
bold: true,
|
|
149457
150114
|
color: colors.approval.header,
|
|
149458
150115
|
children: "Ready to code?"
|
|
149459
150116
|
}, undefined, false, undefined, this),
|
|
149460
|
-
/* @__PURE__ */
|
|
150117
|
+
/* @__PURE__ */ jsx_dev_runtime16.jsxDEV(Box_default, {
|
|
149461
150118
|
height: 1
|
|
149462
150119
|
}, undefined, false, undefined, this),
|
|
149463
|
-
/* @__PURE__ */
|
|
150120
|
+
/* @__PURE__ */ jsx_dev_runtime16.jsxDEV(Text, {
|
|
149464
150121
|
children: "Here's the proposed plan:"
|
|
149465
150122
|
}, undefined, false, undefined, this),
|
|
149466
|
-
/* @__PURE__ */
|
|
150123
|
+
/* @__PURE__ */ jsx_dev_runtime16.jsxDEV(Box_default, {
|
|
149467
150124
|
height: 1
|
|
149468
150125
|
}, undefined, false, undefined, this),
|
|
149469
|
-
/* @__PURE__ */
|
|
150126
|
+
/* @__PURE__ */ jsx_dev_runtime16.jsxDEV(Box_default, {
|
|
149470
150127
|
borderStyle: "round",
|
|
149471
150128
|
paddingX: 1,
|
|
149472
|
-
children: /* @__PURE__ */
|
|
150129
|
+
children: /* @__PURE__ */ jsx_dev_runtime16.jsxDEV(MarkdownDisplay, {
|
|
149473
150130
|
text: plan
|
|
149474
150131
|
}, undefined, false, undefined, this)
|
|
149475
150132
|
}, undefined, false, undefined, this),
|
|
149476
|
-
/* @__PURE__ */
|
|
150133
|
+
/* @__PURE__ */ jsx_dev_runtime16.jsxDEV(Box_default, {
|
|
149477
150134
|
height: 1
|
|
149478
150135
|
}, undefined, false, undefined, this),
|
|
149479
|
-
/* @__PURE__ */
|
|
150136
|
+
/* @__PURE__ */ jsx_dev_runtime16.jsxDEV(Text, {
|
|
149480
150137
|
children: "Would you like to proceed?"
|
|
149481
150138
|
}, undefined, false, undefined, this),
|
|
149482
|
-
/* @__PURE__ */
|
|
150139
|
+
/* @__PURE__ */ jsx_dev_runtime16.jsxDEV(Box_default, {
|
|
149483
150140
|
height: 1
|
|
149484
150141
|
}, undefined, false, undefined, this),
|
|
149485
|
-
/* @__PURE__ */
|
|
150142
|
+
/* @__PURE__ */ jsx_dev_runtime16.jsxDEV(OptionsRenderer2, {
|
|
149486
150143
|
options,
|
|
149487
150144
|
selectedOption
|
|
149488
150145
|
}, undefined, false, undefined, this)
|
|
@@ -149493,7 +150150,7 @@ var init_PlanModeDialog = __esm(async () => {
|
|
|
149493
150150
|
});
|
|
149494
150151
|
|
|
149495
150152
|
// src/cli/components/ReasoningMessageRich.tsx
|
|
149496
|
-
var
|
|
150153
|
+
var import_react35, jsx_dev_runtime17, normalize2 = (s) => s.replace(/\r\n/g, `
|
|
149497
150154
|
`).replace(/[ \t]+$/gm, "").replace(/\n{3,}/g, `
|
|
149498
150155
|
|
|
149499
150156
|
`).replace(/^\n+|\n+$/g, ""), ReasoningMessage;
|
|
@@ -149503,53 +150160,53 @@ var init_ReasoningMessageRich = __esm(async () => {
|
|
|
149503
150160
|
init_build3(),
|
|
149504
150161
|
init_MarkdownDisplay()
|
|
149505
150162
|
]);
|
|
149506
|
-
|
|
149507
|
-
|
|
149508
|
-
ReasoningMessage =
|
|
150163
|
+
import_react35 = __toESM(require_react2(), 1);
|
|
150164
|
+
jsx_dev_runtime17 = __toESM(require_jsx_dev_runtime(), 1);
|
|
150165
|
+
ReasoningMessage = import_react35.memo(({ line }) => {
|
|
149509
150166
|
const columns = useTerminalWidth();
|
|
149510
150167
|
const contentWidth = Math.max(0, columns - 2);
|
|
149511
150168
|
const normalizedText = normalize2(line.text);
|
|
149512
|
-
return /* @__PURE__ */
|
|
150169
|
+
return /* @__PURE__ */ jsx_dev_runtime17.jsxDEV(Box_default, {
|
|
149513
150170
|
flexDirection: "column",
|
|
149514
150171
|
children: [
|
|
149515
|
-
/* @__PURE__ */
|
|
150172
|
+
/* @__PURE__ */ jsx_dev_runtime17.jsxDEV(Box_default, {
|
|
149516
150173
|
flexDirection: "row",
|
|
149517
150174
|
children: [
|
|
149518
|
-
/* @__PURE__ */
|
|
150175
|
+
/* @__PURE__ */ jsx_dev_runtime17.jsxDEV(Box_default, {
|
|
149519
150176
|
width: 2,
|
|
149520
150177
|
flexShrink: 0,
|
|
149521
|
-
children: /* @__PURE__ */
|
|
150178
|
+
children: /* @__PURE__ */ jsx_dev_runtime17.jsxDEV(Text, {
|
|
149522
150179
|
dimColor: true,
|
|
149523
150180
|
children: "✻"
|
|
149524
150181
|
}, undefined, false, undefined, this)
|
|
149525
150182
|
}, undefined, false, undefined, this),
|
|
149526
|
-
/* @__PURE__ */
|
|
150183
|
+
/* @__PURE__ */ jsx_dev_runtime17.jsxDEV(Box_default, {
|
|
149527
150184
|
flexGrow: 1,
|
|
149528
150185
|
width: contentWidth,
|
|
149529
|
-
children: /* @__PURE__ */
|
|
150186
|
+
children: /* @__PURE__ */ jsx_dev_runtime17.jsxDEV(Text, {
|
|
149530
150187
|
dimColor: true,
|
|
149531
150188
|
children: "Thinking…"
|
|
149532
150189
|
}, undefined, false, undefined, this)
|
|
149533
150190
|
}, undefined, false, undefined, this)
|
|
149534
150191
|
]
|
|
149535
150192
|
}, undefined, true, undefined, this),
|
|
149536
|
-
/* @__PURE__ */
|
|
150193
|
+
/* @__PURE__ */ jsx_dev_runtime17.jsxDEV(Box_default, {
|
|
149537
150194
|
height: 1
|
|
149538
150195
|
}, undefined, false, undefined, this),
|
|
149539
|
-
/* @__PURE__ */
|
|
150196
|
+
/* @__PURE__ */ jsx_dev_runtime17.jsxDEV(Box_default, {
|
|
149540
150197
|
flexDirection: "row",
|
|
149541
150198
|
children: [
|
|
149542
|
-
/* @__PURE__ */
|
|
150199
|
+
/* @__PURE__ */ jsx_dev_runtime17.jsxDEV(Box_default, {
|
|
149543
150200
|
width: 2,
|
|
149544
150201
|
flexShrink: 0,
|
|
149545
|
-
children: /* @__PURE__ */
|
|
150202
|
+
children: /* @__PURE__ */ jsx_dev_runtime17.jsxDEV(Text, {
|
|
149546
150203
|
children: " "
|
|
149547
150204
|
}, undefined, false, undefined, this)
|
|
149548
150205
|
}, undefined, false, undefined, this),
|
|
149549
|
-
/* @__PURE__ */
|
|
150206
|
+
/* @__PURE__ */ jsx_dev_runtime17.jsxDEV(Box_default, {
|
|
149550
150207
|
flexGrow: 1,
|
|
149551
150208
|
width: contentWidth,
|
|
149552
|
-
children: /* @__PURE__ */
|
|
150209
|
+
children: /* @__PURE__ */ jsx_dev_runtime17.jsxDEV(MarkdownDisplay, {
|
|
149553
150210
|
text: normalizedText,
|
|
149554
150211
|
dimColor: true
|
|
149555
150212
|
}, undefined, false, undefined, this)
|
|
@@ -149575,25 +150232,25 @@ function formatNumber(n) {
|
|
|
149575
150232
|
function SessionStats2({ stats, agentId }) {
|
|
149576
150233
|
const wallDuration = formatDuration(stats.totalWallMs);
|
|
149577
150234
|
const apiDuration = formatDuration(stats.totalApiMs);
|
|
149578
|
-
return /* @__PURE__ */
|
|
150235
|
+
return /* @__PURE__ */ jsx_dev_runtime18.jsxDEV(Box_default, {
|
|
149579
150236
|
flexDirection: "column",
|
|
149580
150237
|
paddingTop: 1,
|
|
149581
150238
|
children: [
|
|
149582
|
-
/* @__PURE__ */
|
|
150239
|
+
/* @__PURE__ */ jsx_dev_runtime18.jsxDEV(Text, {
|
|
149583
150240
|
dimColor: true,
|
|
149584
150241
|
children: [
|
|
149585
150242
|
"Total duration (API): ",
|
|
149586
150243
|
apiDuration
|
|
149587
150244
|
]
|
|
149588
150245
|
}, undefined, true, undefined, this),
|
|
149589
|
-
/* @__PURE__ */
|
|
150246
|
+
/* @__PURE__ */ jsx_dev_runtime18.jsxDEV(Text, {
|
|
149590
150247
|
dimColor: true,
|
|
149591
150248
|
children: [
|
|
149592
150249
|
"Total duration (wall): ",
|
|
149593
150250
|
wallDuration
|
|
149594
150251
|
]
|
|
149595
150252
|
}, undefined, true, undefined, this),
|
|
149596
|
-
/* @__PURE__ */
|
|
150253
|
+
/* @__PURE__ */ jsx_dev_runtime18.jsxDEV(Text, {
|
|
149597
150254
|
dimColor: true,
|
|
149598
150255
|
children: [
|
|
149599
150256
|
"Usage: ",
|
|
@@ -149607,7 +150264,7 @@ function SessionStats2({ stats, agentId }) {
|
|
|
149607
150264
|
" output"
|
|
149608
150265
|
]
|
|
149609
150266
|
}, undefined, true, undefined, this),
|
|
149610
|
-
agentId && /* @__PURE__ */
|
|
150267
|
+
agentId && /* @__PURE__ */ jsx_dev_runtime18.jsxDEV(Text, {
|
|
149611
150268
|
dimColor: true,
|
|
149612
150269
|
children: [
|
|
149613
150270
|
"Agent ID: ",
|
|
@@ -149617,10 +150274,10 @@ function SessionStats2({ stats, agentId }) {
|
|
|
149617
150274
|
]
|
|
149618
150275
|
}, undefined, true, undefined, this);
|
|
149619
150276
|
}
|
|
149620
|
-
var
|
|
150277
|
+
var jsx_dev_runtime18;
|
|
149621
150278
|
var init_SessionStats = __esm(async () => {
|
|
149622
150279
|
await init_build3();
|
|
149623
|
-
|
|
150280
|
+
jsx_dev_runtime18 = __toESM(require_jsx_dev_runtime(), 1);
|
|
149624
150281
|
});
|
|
149625
150282
|
|
|
149626
150283
|
// src/cli/helpers/formatArgsDisplay.ts
|
|
@@ -149682,14 +150339,14 @@ function formatArgsDisplay(argsJson) {
|
|
|
149682
150339
|
var isRecord3 = (v) => typeof v === "object" && v !== null;
|
|
149683
150340
|
|
|
149684
150341
|
// src/cli/components/TodoRenderer.tsx
|
|
149685
|
-
var
|
|
149686
|
-
return /* @__PURE__ */
|
|
150342
|
+
var jsx_dev_runtime19, TodoRenderer = ({ todos }) => {
|
|
150343
|
+
return /* @__PURE__ */ jsx_dev_runtime19.jsxDEV(Box_default, {
|
|
149687
150344
|
flexDirection: "column",
|
|
149688
150345
|
children: todos.map((todo, index) => {
|
|
149689
150346
|
const checkbox = todo.status === "completed" ? "☒" : "☐";
|
|
149690
150347
|
let textElement;
|
|
149691
150348
|
if (todo.status === "completed") {
|
|
149692
|
-
textElement = /* @__PURE__ */
|
|
150349
|
+
textElement = /* @__PURE__ */ jsx_dev_runtime19.jsxDEV(Text, {
|
|
149693
150350
|
color: colors.todo.completed,
|
|
149694
150351
|
strikethrough: true,
|
|
149695
150352
|
children: [
|
|
@@ -149699,7 +150356,7 @@ var jsx_dev_runtime17, TodoRenderer = ({ todos }) => {
|
|
|
149699
150356
|
]
|
|
149700
150357
|
}, undefined, true, undefined, this);
|
|
149701
150358
|
} else if (todo.status === "in_progress") {
|
|
149702
|
-
textElement = /* @__PURE__ */
|
|
150359
|
+
textElement = /* @__PURE__ */ jsx_dev_runtime19.jsxDEV(Text, {
|
|
149703
150360
|
color: colors.todo.inProgress,
|
|
149704
150361
|
bold: true,
|
|
149705
150362
|
children: [
|
|
@@ -149709,7 +150366,7 @@ var jsx_dev_runtime17, TodoRenderer = ({ todos }) => {
|
|
|
149709
150366
|
]
|
|
149710
150367
|
}, undefined, true, undefined, this);
|
|
149711
150368
|
} else {
|
|
149712
|
-
textElement = /* @__PURE__ */
|
|
150369
|
+
textElement = /* @__PURE__ */ jsx_dev_runtime19.jsxDEV(Text, {
|
|
149713
150370
|
children: [
|
|
149714
150371
|
checkbox,
|
|
149715
150372
|
" ",
|
|
@@ -149718,9 +150375,9 @@ var jsx_dev_runtime17, TodoRenderer = ({ todos }) => {
|
|
|
149718
150375
|
}, undefined, true, undefined, this);
|
|
149719
150376
|
}
|
|
149720
150377
|
const prefix = index === 0 ? " ⎿ " : " ";
|
|
149721
|
-
return /* @__PURE__ */
|
|
150378
|
+
return /* @__PURE__ */ jsx_dev_runtime19.jsxDEV(Box_default, {
|
|
149722
150379
|
children: [
|
|
149723
|
-
/* @__PURE__ */
|
|
150380
|
+
/* @__PURE__ */ jsx_dev_runtime19.jsxDEV(Text, {
|
|
149724
150381
|
children: prefix
|
|
149725
150382
|
}, undefined, false, undefined, this),
|
|
149726
150383
|
textElement
|
|
@@ -149732,19 +150389,19 @@ var jsx_dev_runtime17, TodoRenderer = ({ todos }) => {
|
|
|
149732
150389
|
var init_TodoRenderer = __esm(async () => {
|
|
149733
150390
|
init_colors();
|
|
149734
150391
|
await init_build3();
|
|
149735
|
-
|
|
150392
|
+
jsx_dev_runtime19 = __toESM(require_jsx_dev_runtime(), 1);
|
|
149736
150393
|
});
|
|
149737
150394
|
|
|
149738
150395
|
// src/cli/components/ToolCallMessageRich.tsx
|
|
149739
|
-
var
|
|
150396
|
+
var import_react36, jsx_dev_runtime20, BlinkDot2 = ({
|
|
149740
150397
|
color = colors.tool.pending
|
|
149741
150398
|
}) => {
|
|
149742
|
-
const [on, setOn] =
|
|
149743
|
-
|
|
150399
|
+
const [on, setOn] = import_react36.useState(true);
|
|
150400
|
+
import_react36.useEffect(() => {
|
|
149744
150401
|
const t = setInterval(() => setOn((v) => !v), 400);
|
|
149745
150402
|
return () => clearInterval(t);
|
|
149746
150403
|
}, []);
|
|
149747
|
-
return /* @__PURE__ */
|
|
150404
|
+
return /* @__PURE__ */ jsx_dev_runtime20.jsxDEV(Text, {
|
|
149748
150405
|
color,
|
|
149749
150406
|
children: on ? "●" : " "
|
|
149750
150407
|
}, undefined, false, undefined, this);
|
|
@@ -149758,9 +150415,9 @@ var init_ToolCallMessageRich = __esm(async () => {
|
|
|
149758
150415
|
init_MarkdownDisplay(),
|
|
149759
150416
|
init_TodoRenderer()
|
|
149760
150417
|
]);
|
|
149761
|
-
|
|
149762
|
-
|
|
149763
|
-
ToolCallMessage =
|
|
150418
|
+
import_react36 = __toESM(require_react2(), 1);
|
|
150419
|
+
jsx_dev_runtime20 = __toESM(require_jsx_dev_runtime(), 1);
|
|
150420
|
+
ToolCallMessage = import_react36.memo(({ line }) => {
|
|
149764
150421
|
const columns = useTerminalWidth();
|
|
149765
150422
|
const rawName = line.name ?? "?";
|
|
149766
150423
|
const argsText = line.argsText ?? "...";
|
|
@@ -149790,31 +150447,31 @@ var init_ToolCallMessageRich = __esm(async () => {
|
|
|
149790
150447
|
const getDotElement = () => {
|
|
149791
150448
|
switch (line.phase) {
|
|
149792
150449
|
case "streaming":
|
|
149793
|
-
return /* @__PURE__ */
|
|
150450
|
+
return /* @__PURE__ */ jsx_dev_runtime20.jsxDEV(Text, {
|
|
149794
150451
|
color: colors.tool.streaming,
|
|
149795
150452
|
children: "●"
|
|
149796
150453
|
}, undefined, false, undefined, this);
|
|
149797
150454
|
case "ready":
|
|
149798
|
-
return /* @__PURE__ */
|
|
150455
|
+
return /* @__PURE__ */ jsx_dev_runtime20.jsxDEV(BlinkDot2, {
|
|
149799
150456
|
color: colors.tool.pending
|
|
149800
150457
|
}, undefined, false, undefined, this);
|
|
149801
150458
|
case "running":
|
|
149802
|
-
return /* @__PURE__ */
|
|
150459
|
+
return /* @__PURE__ */ jsx_dev_runtime20.jsxDEV(BlinkDot2, {
|
|
149803
150460
|
color: colors.tool.running
|
|
149804
150461
|
}, undefined, false, undefined, this);
|
|
149805
150462
|
case "finished":
|
|
149806
150463
|
if (line.resultOk === false) {
|
|
149807
|
-
return /* @__PURE__ */
|
|
150464
|
+
return /* @__PURE__ */ jsx_dev_runtime20.jsxDEV(Text, {
|
|
149808
150465
|
color: colors.tool.error,
|
|
149809
150466
|
children: "●"
|
|
149810
150467
|
}, undefined, false, undefined, this);
|
|
149811
150468
|
}
|
|
149812
|
-
return /* @__PURE__ */
|
|
150469
|
+
return /* @__PURE__ */ jsx_dev_runtime20.jsxDEV(Text, {
|
|
149813
150470
|
color: colors.tool.completed,
|
|
149814
150471
|
children: "●"
|
|
149815
150472
|
}, undefined, false, undefined, this);
|
|
149816
150473
|
default:
|
|
149817
|
-
return /* @__PURE__ */
|
|
150474
|
+
return /* @__PURE__ */ jsx_dev_runtime20.jsxDEV(Text, {
|
|
149818
150475
|
children: "●"
|
|
149819
150476
|
}, undefined, false, undefined, this);
|
|
149820
150477
|
}
|
|
@@ -149826,20 +150483,20 @@ var init_ToolCallMessageRich = __esm(async () => {
|
|
|
149826
150483
|
const prefixWidth = 5;
|
|
149827
150484
|
const contentWidth = Math.max(0, columns - prefixWidth);
|
|
149828
150485
|
if (line.resultText === "Running...") {
|
|
149829
|
-
return /* @__PURE__ */
|
|
150486
|
+
return /* @__PURE__ */ jsx_dev_runtime20.jsxDEV(Box_default, {
|
|
149830
150487
|
flexDirection: "row",
|
|
149831
150488
|
children: [
|
|
149832
|
-
/* @__PURE__ */
|
|
150489
|
+
/* @__PURE__ */ jsx_dev_runtime20.jsxDEV(Box_default, {
|
|
149833
150490
|
width: prefixWidth,
|
|
149834
150491
|
flexShrink: 0,
|
|
149835
|
-
children: /* @__PURE__ */
|
|
150492
|
+
children: /* @__PURE__ */ jsx_dev_runtime20.jsxDEV(Text, {
|
|
149836
150493
|
children: prefix
|
|
149837
150494
|
}, undefined, false, undefined, this)
|
|
149838
150495
|
}, undefined, false, undefined, this),
|
|
149839
|
-
/* @__PURE__ */
|
|
150496
|
+
/* @__PURE__ */ jsx_dev_runtime20.jsxDEV(Box_default, {
|
|
149840
150497
|
flexGrow: 1,
|
|
149841
150498
|
width: contentWidth,
|
|
149842
|
-
children: /* @__PURE__ */
|
|
150499
|
+
children: /* @__PURE__ */ jsx_dev_runtime20.jsxDEV(Text, {
|
|
149843
150500
|
dimColor: true,
|
|
149844
150501
|
children: "Running..."
|
|
149845
150502
|
}, undefined, false, undefined, this)
|
|
@@ -149848,20 +150505,20 @@ var init_ToolCallMessageRich = __esm(async () => {
|
|
|
149848
150505
|
}, undefined, true, undefined, this);
|
|
149849
150506
|
}
|
|
149850
150507
|
if (line.resultText === "Interrupted by user") {
|
|
149851
|
-
return /* @__PURE__ */
|
|
150508
|
+
return /* @__PURE__ */ jsx_dev_runtime20.jsxDEV(Box_default, {
|
|
149852
150509
|
flexDirection: "row",
|
|
149853
150510
|
children: [
|
|
149854
|
-
/* @__PURE__ */
|
|
150511
|
+
/* @__PURE__ */ jsx_dev_runtime20.jsxDEV(Box_default, {
|
|
149855
150512
|
width: prefixWidth,
|
|
149856
150513
|
flexShrink: 0,
|
|
149857
|
-
children: /* @__PURE__ */
|
|
150514
|
+
children: /* @__PURE__ */ jsx_dev_runtime20.jsxDEV(Text, {
|
|
149858
150515
|
children: prefix
|
|
149859
150516
|
}, undefined, false, undefined, this)
|
|
149860
150517
|
}, undefined, false, undefined, this),
|
|
149861
|
-
/* @__PURE__ */
|
|
150518
|
+
/* @__PURE__ */ jsx_dev_runtime20.jsxDEV(Box_default, {
|
|
149862
150519
|
flexGrow: 1,
|
|
149863
150520
|
width: contentWidth,
|
|
149864
|
-
children: /* @__PURE__ */
|
|
150521
|
+
children: /* @__PURE__ */ jsx_dev_runtime20.jsxDEV(Text, {
|
|
149865
150522
|
color: colors.status.interrupt,
|
|
149866
150523
|
children: "Interrupted by user"
|
|
149867
150524
|
}, undefined, false, undefined, this)
|
|
@@ -149884,7 +150541,7 @@ var init_ToolCallMessageRich = __esm(async () => {
|
|
|
149884
150541
|
const priority = rec.priority === "high" ? "high" : rec.priority === "medium" ? "medium" : rec.priority === "low" ? "low" : undefined;
|
|
149885
150542
|
return { content, status, id, priority };
|
|
149886
150543
|
});
|
|
149887
|
-
return /* @__PURE__ */
|
|
150544
|
+
return /* @__PURE__ */ jsx_dev_runtime20.jsxDEV(TodoRenderer, {
|
|
149888
150545
|
todos: safeTodos
|
|
149889
150546
|
}, undefined, false, undefined, this);
|
|
149890
150547
|
}
|
|
@@ -149898,59 +150555,59 @@ var init_ToolCallMessageRich = __esm(async () => {
|
|
|
149898
150555
|
displayText = parsed.error;
|
|
149899
150556
|
}
|
|
149900
150557
|
} catch {}
|
|
149901
|
-
return /* @__PURE__ */
|
|
150558
|
+
return /* @__PURE__ */ jsx_dev_runtime20.jsxDEV(Box_default, {
|
|
149902
150559
|
flexDirection: "row",
|
|
149903
150560
|
children: [
|
|
149904
|
-
/* @__PURE__ */
|
|
150561
|
+
/* @__PURE__ */ jsx_dev_runtime20.jsxDEV(Box_default, {
|
|
149905
150562
|
width: prefixWidth,
|
|
149906
150563
|
flexShrink: 0,
|
|
149907
|
-
children: /* @__PURE__ */
|
|
150564
|
+
children: /* @__PURE__ */ jsx_dev_runtime20.jsxDEV(Text, {
|
|
149908
150565
|
children: prefix
|
|
149909
150566
|
}, undefined, false, undefined, this)
|
|
149910
150567
|
}, undefined, false, undefined, this),
|
|
149911
|
-
/* @__PURE__ */
|
|
150568
|
+
/* @__PURE__ */ jsx_dev_runtime20.jsxDEV(Box_default, {
|
|
149912
150569
|
flexGrow: 1,
|
|
149913
150570
|
width: contentWidth,
|
|
149914
|
-
children: isError ? /* @__PURE__ */
|
|
150571
|
+
children: isError ? /* @__PURE__ */ jsx_dev_runtime20.jsxDEV(Text, {
|
|
149915
150572
|
color: colors.status.error,
|
|
149916
150573
|
children: displayText
|
|
149917
|
-
}, undefined, false, undefined, this) : /* @__PURE__ */
|
|
150574
|
+
}, undefined, false, undefined, this) : /* @__PURE__ */ jsx_dev_runtime20.jsxDEV(MarkdownDisplay, {
|
|
149918
150575
|
text: displayText
|
|
149919
150576
|
}, undefined, false, undefined, this)
|
|
149920
150577
|
}, undefined, false, undefined, this)
|
|
149921
150578
|
]
|
|
149922
150579
|
}, undefined, true, undefined, this);
|
|
149923
150580
|
};
|
|
149924
|
-
return /* @__PURE__ */
|
|
150581
|
+
return /* @__PURE__ */ jsx_dev_runtime20.jsxDEV(Box_default, {
|
|
149925
150582
|
flexDirection: "column",
|
|
149926
150583
|
children: [
|
|
149927
|
-
/* @__PURE__ */
|
|
150584
|
+
/* @__PURE__ */ jsx_dev_runtime20.jsxDEV(Box_default, {
|
|
149928
150585
|
flexDirection: "row",
|
|
149929
150586
|
children: [
|
|
149930
|
-
/* @__PURE__ */
|
|
150587
|
+
/* @__PURE__ */ jsx_dev_runtime20.jsxDEV(Box_default, {
|
|
149931
150588
|
width: 2,
|
|
149932
150589
|
flexShrink: 0,
|
|
149933
150590
|
children: [
|
|
149934
150591
|
getDotElement(),
|
|
149935
|
-
/* @__PURE__ */
|
|
150592
|
+
/* @__PURE__ */ jsx_dev_runtime20.jsxDEV(Text, {}, undefined, false, undefined, this)
|
|
149936
150593
|
]
|
|
149937
150594
|
}, undefined, true, undefined, this),
|
|
149938
|
-
/* @__PURE__ */
|
|
150595
|
+
/* @__PURE__ */ jsx_dev_runtime20.jsxDEV(Box_default, {
|
|
149939
150596
|
flexGrow: 1,
|
|
149940
150597
|
width: rightWidth,
|
|
149941
|
-
children: fallback ? /* @__PURE__ */
|
|
150598
|
+
children: fallback ? /* @__PURE__ */ jsx_dev_runtime20.jsxDEV(Text, {
|
|
149942
150599
|
wrap: "wrap",
|
|
149943
150600
|
children: `${displayName}${args}`
|
|
149944
|
-
}, undefined, false, undefined, this) : /* @__PURE__ */
|
|
150601
|
+
}, undefined, false, undefined, this) : /* @__PURE__ */ jsx_dev_runtime20.jsxDEV(Box_default, {
|
|
149945
150602
|
flexDirection: "row",
|
|
149946
150603
|
children: [
|
|
149947
|
-
/* @__PURE__ */
|
|
150604
|
+
/* @__PURE__ */ jsx_dev_runtime20.jsxDEV(Text, {
|
|
149948
150605
|
children: displayName
|
|
149949
150606
|
}, undefined, false, undefined, this),
|
|
149950
|
-
args ? /* @__PURE__ */
|
|
150607
|
+
args ? /* @__PURE__ */ jsx_dev_runtime20.jsxDEV(Box_default, {
|
|
149951
150608
|
flexGrow: 1,
|
|
149952
150609
|
width: Math.max(0, rightWidth - displayName.length),
|
|
149953
|
-
children: /* @__PURE__ */
|
|
150610
|
+
children: /* @__PURE__ */ jsx_dev_runtime20.jsxDEV(Text, {
|
|
149954
150611
|
wrap: "wrap",
|
|
149955
150612
|
children: args
|
|
149956
150613
|
}, undefined, false, undefined, this)
|
|
@@ -149968,35 +150625,35 @@ var init_ToolCallMessageRich = __esm(async () => {
|
|
|
149968
150625
|
});
|
|
149969
150626
|
|
|
149970
150627
|
// src/cli/components/UserMessageRich.tsx
|
|
149971
|
-
var
|
|
150628
|
+
var import_react37, jsx_dev_runtime21, UserMessage;
|
|
149972
150629
|
var init_UserMessageRich = __esm(async () => {
|
|
149973
150630
|
init_useTerminalWidth();
|
|
149974
150631
|
await __promiseAll([
|
|
149975
150632
|
init_build3(),
|
|
149976
150633
|
init_MarkdownDisplay()
|
|
149977
150634
|
]);
|
|
149978
|
-
|
|
149979
|
-
|
|
149980
|
-
UserMessage =
|
|
150635
|
+
import_react37 = __toESM(require_react2(), 1);
|
|
150636
|
+
jsx_dev_runtime21 = __toESM(require_jsx_dev_runtime(), 1);
|
|
150637
|
+
UserMessage = import_react37.memo(({ line }) => {
|
|
149981
150638
|
const columns = useTerminalWidth();
|
|
149982
150639
|
const contentWidth = Math.max(0, columns - 2);
|
|
149983
|
-
return /* @__PURE__ */
|
|
150640
|
+
return /* @__PURE__ */ jsx_dev_runtime21.jsxDEV(Box_default, {
|
|
149984
150641
|
flexDirection: "row",
|
|
149985
150642
|
children: [
|
|
149986
|
-
/* @__PURE__ */
|
|
150643
|
+
/* @__PURE__ */ jsx_dev_runtime21.jsxDEV(Box_default, {
|
|
149987
150644
|
width: 2,
|
|
149988
150645
|
flexShrink: 0,
|
|
149989
|
-
children: /* @__PURE__ */
|
|
150646
|
+
children: /* @__PURE__ */ jsx_dev_runtime21.jsxDEV(Text, {
|
|
149990
150647
|
children: [
|
|
149991
150648
|
">",
|
|
149992
150649
|
" "
|
|
149993
150650
|
]
|
|
149994
150651
|
}, undefined, true, undefined, this)
|
|
149995
150652
|
}, undefined, false, undefined, this),
|
|
149996
|
-
/* @__PURE__ */
|
|
150653
|
+
/* @__PURE__ */ jsx_dev_runtime21.jsxDEV(Box_default, {
|
|
149997
150654
|
flexGrow: 1,
|
|
149998
150655
|
width: contentWidth,
|
|
149999
|
-
children: /* @__PURE__ */
|
|
150656
|
+
children: /* @__PURE__ */ jsx_dev_runtime21.jsxDEV(MarkdownDisplay, {
|
|
150000
150657
|
text: line.text
|
|
150001
150658
|
}, undefined, false, undefined, this)
|
|
150002
150659
|
}, undefined, false, undefined, this)
|
|
@@ -150595,7 +151252,7 @@ var require_react_jsx_runtime_development = __commonJS((exports) => {
|
|
|
150595
151252
|
}
|
|
150596
151253
|
return element;
|
|
150597
151254
|
};
|
|
150598
|
-
function
|
|
151255
|
+
function jsxDEV22(type, config, maybeKey, source, self2) {
|
|
150599
151256
|
{
|
|
150600
151257
|
var propName;
|
|
150601
151258
|
var props = {};
|
|
@@ -150829,7 +151486,7 @@ Check the top-level render call using <` + parentName + ">.";
|
|
|
150829
151486
|
}
|
|
150830
151487
|
error("React.jsx: type is invalid -- expected a string (for " + "built-in components) or a class/function (for composite " + "components) but got: %s.%s", typeString, info);
|
|
150831
151488
|
}
|
|
150832
|
-
var element =
|
|
151489
|
+
var element = jsxDEV22(type, props, key, source, self2);
|
|
150833
151490
|
if (element == null) {
|
|
150834
151491
|
return element;
|
|
150835
151492
|
}
|
|
@@ -151262,7 +151919,7 @@ function WelcomeScreen({
|
|
|
151262
151919
|
};
|
|
151263
151920
|
const getAgentLink = () => {
|
|
151264
151921
|
if (loadingState === "ready" && agentId) {
|
|
151265
|
-
const url = `https://app.letta.com/
|
|
151922
|
+
const url = `https://app.letta.com/agents/${agentId}`;
|
|
151266
151923
|
if (isWide2) {
|
|
151267
151924
|
return { text: url, url };
|
|
151268
151925
|
}
|
|
@@ -151276,25 +151933,25 @@ function WelcomeScreen({
|
|
|
151276
151933
|
const agentMessage = getAgentMessage();
|
|
151277
151934
|
const pathLine = getPathLine();
|
|
151278
151935
|
const agentLink = getAgentLink();
|
|
151279
|
-
return /* @__PURE__ */
|
|
151936
|
+
return /* @__PURE__ */ jsx_dev_runtime22.jsxDEV(Box_default, {
|
|
151280
151937
|
flexDirection: "row",
|
|
151281
151938
|
marginTop: 1,
|
|
151282
151939
|
children: [
|
|
151283
|
-
/* @__PURE__ */
|
|
151940
|
+
/* @__PURE__ */ jsx_dev_runtime22.jsxDEV(Box_default, {
|
|
151284
151941
|
flexDirection: "column",
|
|
151285
151942
|
paddingLeft: 1,
|
|
151286
151943
|
paddingRight: 2,
|
|
151287
|
-
children: logoLines.map((line, idx) => /* @__PURE__ */
|
|
151944
|
+
children: logoLines.map((line, idx) => /* @__PURE__ */ jsx_dev_runtime22.jsxDEV(Text, {
|
|
151288
151945
|
bold: true,
|
|
151289
151946
|
color: colors.welcome.accent,
|
|
151290
151947
|
children: idx === 0 ? ` ${line}` : line
|
|
151291
151948
|
}, idx, false, undefined, this))
|
|
151292
151949
|
}, undefined, false, undefined, this),
|
|
151293
|
-
/* @__PURE__ */
|
|
151950
|
+
/* @__PURE__ */ jsx_dev_runtime22.jsxDEV(Box_default, {
|
|
151294
151951
|
flexDirection: "column",
|
|
151295
151952
|
marginTop: 0,
|
|
151296
151953
|
children: [
|
|
151297
|
-
/* @__PURE__ */
|
|
151954
|
+
/* @__PURE__ */ jsx_dev_runtime22.jsxDEV(Text, {
|
|
151298
151955
|
bold: true,
|
|
151299
151956
|
color: colors.welcome.accent,
|
|
151300
151957
|
children: [
|
|
@@ -151302,17 +151959,17 @@ function WelcomeScreen({
|
|
|
151302
151959
|
version
|
|
151303
151960
|
]
|
|
151304
151961
|
}, undefined, true, undefined, this),
|
|
151305
|
-
/* @__PURE__ */
|
|
151962
|
+
/* @__PURE__ */ jsx_dev_runtime22.jsxDEV(Text, {
|
|
151306
151963
|
dimColor: true,
|
|
151307
151964
|
children: pathLine
|
|
151308
151965
|
}, undefined, false, undefined, this),
|
|
151309
|
-
agentMessage && /* @__PURE__ */
|
|
151966
|
+
agentMessage && /* @__PURE__ */ jsx_dev_runtime22.jsxDEV(Text, {
|
|
151310
151967
|
dimColor: true,
|
|
151311
151968
|
children: agentMessage
|
|
151312
151969
|
}, undefined, false, undefined, this),
|
|
151313
|
-
agentLink && /* @__PURE__ */
|
|
151970
|
+
agentLink && /* @__PURE__ */ jsx_dev_runtime22.jsxDEV(dist_default4, {
|
|
151314
151971
|
url: agentLink.url,
|
|
151315
|
-
children: /* @__PURE__ */
|
|
151972
|
+
children: /* @__PURE__ */ jsx_dev_runtime22.jsxDEV(Text, {
|
|
151316
151973
|
dimColor: true,
|
|
151317
151974
|
children: agentLink.text
|
|
151318
151975
|
}, undefined, false, undefined, this)
|
|
@@ -151322,7 +151979,7 @@ function WelcomeScreen({
|
|
|
151322
151979
|
]
|
|
151323
151980
|
}, undefined, true, undefined, this);
|
|
151324
151981
|
}
|
|
151325
|
-
var
|
|
151982
|
+
var jsx_dev_runtime22;
|
|
151326
151983
|
var init_WelcomeScreen = __esm(async () => {
|
|
151327
151984
|
init_version2();
|
|
151328
151985
|
init_useTerminalWidth();
|
|
@@ -151331,7 +151988,7 @@ var init_WelcomeScreen = __esm(async () => {
|
|
|
151331
151988
|
init_build3(),
|
|
151332
151989
|
init_dist4()
|
|
151333
151990
|
]);
|
|
151334
|
-
|
|
151991
|
+
jsx_dev_runtime22 = __toESM(require_jsx_dev_runtime(), 1);
|
|
151335
151992
|
});
|
|
151336
151993
|
|
|
151337
151994
|
// src/cli/helpers/backfill.ts
|
|
@@ -151503,7 +152160,7 @@ __export(exports_modify, {
|
|
|
151503
152160
|
updateAgentLLMConfig: () => updateAgentLLMConfig
|
|
151504
152161
|
});
|
|
151505
152162
|
async function updateAgentLLMConfig(agentId, modelHandle, updateArgs) {
|
|
151506
|
-
const client = getClient2();
|
|
152163
|
+
const client = await getClient2();
|
|
151507
152164
|
await client.agents.modify(agentId, { model: modelHandle });
|
|
151508
152165
|
const agent = await client.agents.retrieve(agentId);
|
|
151509
152166
|
let finalConfig = agent.llmConfig;
|
|
@@ -151546,27 +152203,27 @@ function App2({
|
|
|
151546
152203
|
messageHistory = [],
|
|
151547
152204
|
tokenStreaming = true
|
|
151548
152205
|
}) {
|
|
151549
|
-
const [streaming, setStreaming] =
|
|
151550
|
-
const [interruptRequested, setInterruptRequested] =
|
|
151551
|
-
const [commandRunning, setCommandRunning] =
|
|
151552
|
-
const [pendingApproval, setPendingApproval] =
|
|
151553
|
-
const [approvalContext, setApprovalContext] =
|
|
151554
|
-
const [planApprovalPending, setPlanApprovalPending] =
|
|
151555
|
-
const [modelSelectorOpen, setModelSelectorOpen] =
|
|
151556
|
-
const [llmConfig, setLlmConfig] =
|
|
151557
|
-
const [tokenStreamingEnabled, setTokenStreamingEnabled] =
|
|
151558
|
-
const [tokenCount, setTokenCount] =
|
|
151559
|
-
const [thinkingMessage, setThinkingMessage] =
|
|
151560
|
-
const sessionStatsRef =
|
|
151561
|
-
const [showExitStats, setShowExitStats] =
|
|
151562
|
-
const [staticItems, setStaticItems] =
|
|
151563
|
-
const emittedIdsRef =
|
|
151564
|
-
const welcomeCommittedRef =
|
|
151565
|
-
const abortControllerRef =
|
|
152206
|
+
const [streaming, setStreaming] = import_react38.useState(false);
|
|
152207
|
+
const [interruptRequested, setInterruptRequested] = import_react38.useState(false);
|
|
152208
|
+
const [commandRunning, setCommandRunning] = import_react38.useState(false);
|
|
152209
|
+
const [pendingApproval, setPendingApproval] = import_react38.useState(null);
|
|
152210
|
+
const [approvalContext, setApprovalContext] = import_react38.useState(null);
|
|
152211
|
+
const [planApprovalPending, setPlanApprovalPending] = import_react38.useState(null);
|
|
152212
|
+
const [modelSelectorOpen, setModelSelectorOpen] = import_react38.useState(false);
|
|
152213
|
+
const [llmConfig, setLlmConfig] = import_react38.useState(null);
|
|
152214
|
+
const [tokenStreamingEnabled, setTokenStreamingEnabled] = import_react38.useState(tokenStreaming);
|
|
152215
|
+
const [tokenCount, setTokenCount] = import_react38.useState(0);
|
|
152216
|
+
const [thinkingMessage, setThinkingMessage] = import_react38.useState(getRandomThinkingMessage());
|
|
152217
|
+
const sessionStatsRef = import_react38.useRef(new SessionStats);
|
|
152218
|
+
const [showExitStats, setShowExitStats] = import_react38.useState(false);
|
|
152219
|
+
const [staticItems, setStaticItems] = import_react38.useState([]);
|
|
152220
|
+
const emittedIdsRef = import_react38.useRef(new Set);
|
|
152221
|
+
const welcomeCommittedRef = import_react38.useRef(false);
|
|
152222
|
+
const abortControllerRef = import_react38.useRef(null);
|
|
151566
152223
|
const columns = useTerminalWidth();
|
|
151567
|
-
const prevColumnsRef =
|
|
151568
|
-
const [staticRenderEpoch, setStaticRenderEpoch] =
|
|
151569
|
-
|
|
152224
|
+
const prevColumnsRef = import_react38.useRef(columns);
|
|
152225
|
+
const [staticRenderEpoch, setStaticRenderEpoch] = import_react38.useState(0);
|
|
152226
|
+
import_react38.useEffect(() => {
|
|
151570
152227
|
const prev = prevColumnsRef.current;
|
|
151571
152228
|
if (columns === prev)
|
|
151572
152229
|
return;
|
|
@@ -151576,7 +152233,7 @@ function App2({
|
|
|
151576
152233
|
setStaticRenderEpoch((epoch) => epoch + 1);
|
|
151577
152234
|
prevColumnsRef.current = columns;
|
|
151578
152235
|
}, [columns]);
|
|
151579
|
-
const commitEligibleLines =
|
|
152236
|
+
const commitEligibleLines = import_react38.useCallback((b) => {
|
|
151580
152237
|
const newlyCommitted = [];
|
|
151581
152238
|
for (const id of b.order) {
|
|
151582
152239
|
if (emittedIdsRef.current.has(id))
|
|
@@ -151605,17 +152262,17 @@ function App2({
|
|
|
151605
152262
|
setStaticItems((prev) => [...prev, ...newlyCommitted]);
|
|
151606
152263
|
}
|
|
151607
152264
|
}, []);
|
|
151608
|
-
const [lines, setLines] =
|
|
151609
|
-
const buffersRef =
|
|
151610
|
-
const hasBackfilledRef =
|
|
151611
|
-
const refreshDerived =
|
|
152265
|
+
const [lines, setLines] = import_react38.useState([]);
|
|
152266
|
+
const buffersRef = import_react38.useRef(createBuffers());
|
|
152267
|
+
const hasBackfilledRef = import_react38.useRef(false);
|
|
152268
|
+
const refreshDerived = import_react38.useCallback(() => {
|
|
151612
152269
|
const b = buffersRef.current;
|
|
151613
152270
|
setTokenCount(b.tokenCount);
|
|
151614
152271
|
const newLines = toLines(b);
|
|
151615
152272
|
setLines(newLines);
|
|
151616
152273
|
commitEligibleLines(b);
|
|
151617
152274
|
}, [commitEligibleLines]);
|
|
151618
|
-
const refreshDerivedThrottled =
|
|
152275
|
+
const refreshDerivedThrottled = import_react38.useCallback(() => {
|
|
151619
152276
|
if (!buffersRef.current.pendingRefresh) {
|
|
151620
152277
|
buffersRef.current.pendingRefresh = true;
|
|
151621
152278
|
setTimeout(() => {
|
|
@@ -151624,7 +152281,7 @@ function App2({
|
|
|
151624
152281
|
}, 16);
|
|
151625
152282
|
}
|
|
151626
152283
|
}, [refreshDerived]);
|
|
151627
|
-
|
|
152284
|
+
import_react38.useEffect(() => {
|
|
151628
152285
|
if (loadingState === "ready" && startupApproval) {
|
|
151629
152286
|
if (startupApproval.toolName === "ExitPlanMode") {
|
|
151630
152287
|
const parsedArgs = safeJsonParseOr(startupApproval.toolArgs, {});
|
|
@@ -151649,7 +152306,7 @@ function App2({
|
|
|
151649
152306
|
}
|
|
151650
152307
|
}
|
|
151651
152308
|
}, [loadingState, startupApproval]);
|
|
151652
|
-
|
|
152309
|
+
import_react38.useEffect(() => {
|
|
151653
152310
|
if (loadingState === "ready" && messageHistory.length > 0 && !hasBackfilledRef.current) {
|
|
151654
152311
|
hasBackfilledRef.current = true;
|
|
151655
152312
|
if (!welcomeCommittedRef.current) {
|
|
@@ -151680,12 +152337,12 @@ function App2({
|
|
|
151680
152337
|
columns,
|
|
151681
152338
|
agentState
|
|
151682
152339
|
]);
|
|
151683
|
-
|
|
152340
|
+
import_react38.useEffect(() => {
|
|
151684
152341
|
if (loadingState === "ready" && agentId && agentId !== "loading") {
|
|
151685
152342
|
const fetchConfig = async () => {
|
|
151686
152343
|
try {
|
|
151687
152344
|
const { getClient: getClient3 } = await Promise.resolve().then(() => (init_client(), exports_client));
|
|
151688
|
-
const client = getClient3();
|
|
152345
|
+
const client = await getClient3();
|
|
151689
152346
|
const agent = await client.agents.retrieve(agentId);
|
|
151690
152347
|
setLlmConfig(agent.llmConfig);
|
|
151691
152348
|
} catch (error) {
|
|
@@ -151695,7 +152352,7 @@ function App2({
|
|
|
151695
152352
|
fetchConfig();
|
|
151696
152353
|
}
|
|
151697
152354
|
}, [loadingState, agentId]);
|
|
151698
|
-
const appendError =
|
|
152355
|
+
const appendError = import_react38.useCallback((message) => {
|
|
151699
152356
|
const id = uid("err");
|
|
151700
152357
|
buffersRef.current.byId.set(id, {
|
|
151701
152358
|
kind: "error",
|
|
@@ -151705,7 +152362,7 @@ function App2({
|
|
|
151705
152362
|
buffersRef.current.order.push(id);
|
|
151706
152363
|
refreshDerived();
|
|
151707
152364
|
}, [refreshDerived]);
|
|
151708
|
-
const processConversation =
|
|
152365
|
+
const processConversation = import_react38.useCallback(async (initialInput) => {
|
|
151709
152366
|
let currentInput = initialInput;
|
|
151710
152367
|
try {
|
|
151711
152368
|
setStreaming(true);
|
|
@@ -151801,18 +152458,18 @@ function App2({
|
|
|
151801
152458
|
abortControllerRef.current = null;
|
|
151802
152459
|
}
|
|
151803
152460
|
}, [agentId, appendError, refreshDerived, refreshDerivedThrottled]);
|
|
151804
|
-
const handleExit =
|
|
152461
|
+
const handleExit = import_react38.useCallback(() => {
|
|
151805
152462
|
setShowExitStats(true);
|
|
151806
152463
|
setTimeout(() => {
|
|
151807
152464
|
process.exit(0);
|
|
151808
152465
|
}, 100);
|
|
151809
152466
|
}, []);
|
|
151810
|
-
const handleInterrupt =
|
|
152467
|
+
const handleInterrupt = import_react38.useCallback(async () => {
|
|
151811
152468
|
if (!streaming || interruptRequested)
|
|
151812
152469
|
return;
|
|
151813
152470
|
setInterruptRequested(true);
|
|
151814
152471
|
try {
|
|
151815
|
-
const client = getClient2();
|
|
152472
|
+
const client = await getClient2();
|
|
151816
152473
|
await client.agents.messages.cancel(agentId);
|
|
151817
152474
|
if (abortControllerRef.current) {
|
|
151818
152475
|
abortControllerRef.current.abort();
|
|
@@ -151822,12 +152479,12 @@ function App2({
|
|
|
151822
152479
|
setInterruptRequested(false);
|
|
151823
152480
|
}
|
|
151824
152481
|
}, [agentId, streaming, interruptRequested, appendError]);
|
|
151825
|
-
|
|
152482
|
+
import_react38.useEffect(() => {
|
|
151826
152483
|
if (!streaming) {
|
|
151827
152484
|
setInterruptRequested(false);
|
|
151828
152485
|
}
|
|
151829
152486
|
}, [streaming]);
|
|
151830
|
-
const onSubmit =
|
|
152487
|
+
const onSubmit = import_react38.useCallback(async (message) => {
|
|
151831
152488
|
const msg = message?.trim() ?? "";
|
|
151832
152489
|
if (!msg || streaming || commandRunning)
|
|
151833
152490
|
return { submitted: false };
|
|
@@ -151870,7 +152527,7 @@ function App2({
|
|
|
151870
152527
|
setCommandRunning(true);
|
|
151871
152528
|
try {
|
|
151872
152529
|
setTokenStreamingEnabled(newValue);
|
|
151873
|
-
const { updateSettings: updateSettings3 } = await Promise.resolve().then(() => (
|
|
152530
|
+
const { updateSettings: updateSettings3 } = await Promise.resolve().then(() => (init_settings(), exports_settings));
|
|
151874
152531
|
await updateSettings3({ tokenStreaming: newValue });
|
|
151875
152532
|
buffersRef.current.byId.set(cmdId2, {
|
|
151876
152533
|
kind: "command",
|
|
@@ -151953,7 +152610,7 @@ function App2({
|
|
|
151953
152610
|
refreshDerived();
|
|
151954
152611
|
if (CHECK_PENDING_APPROVALS_BEFORE_SEND) {
|
|
151955
152612
|
try {
|
|
151956
|
-
const client = getClient2();
|
|
152613
|
+
const client = await getClient2();
|
|
151957
152614
|
const { pendingApproval: existingApproval } = await getResumeData2(client, agentId);
|
|
151958
152615
|
if (existingApproval) {
|
|
151959
152616
|
setStreaming(false);
|
|
@@ -151984,7 +152641,7 @@ function App2({
|
|
|
151984
152641
|
agentId,
|
|
151985
152642
|
handleExit
|
|
151986
152643
|
]);
|
|
151987
|
-
const handleApprove =
|
|
152644
|
+
const handleApprove = import_react38.useCallback(async () => {
|
|
151988
152645
|
if (!pendingApproval)
|
|
151989
152646
|
return;
|
|
151990
152647
|
const { toolCallId, toolName, toolArgs } = pendingApproval;
|
|
@@ -152024,7 +152681,7 @@ function App2({
|
|
|
152024
152681
|
setStreaming(false);
|
|
152025
152682
|
}
|
|
152026
152683
|
}, [pendingApproval, processConversation, appendError, refreshDerived]);
|
|
152027
|
-
const handleApproveAlways =
|
|
152684
|
+
const handleApproveAlways = import_react38.useCallback(async (scope) => {
|
|
152028
152685
|
if (!pendingApproval || !approvalContext)
|
|
152029
152686
|
return;
|
|
152030
152687
|
const rule = approvalContext.recommendedRule;
|
|
@@ -152043,7 +152700,7 @@ function App2({
|
|
|
152043
152700
|
setApprovalContext(null);
|
|
152044
152701
|
await handleApprove();
|
|
152045
152702
|
}, [pendingApproval, approvalContext, handleApprove, refreshDerived]);
|
|
152046
|
-
const handleDeny =
|
|
152703
|
+
const handleDeny = import_react38.useCallback(async (reason) => {
|
|
152047
152704
|
if (!pendingApproval)
|
|
152048
152705
|
return;
|
|
152049
152706
|
const { toolCallId } = pendingApproval;
|
|
@@ -152063,7 +152720,7 @@ function App2({
|
|
|
152063
152720
|
setStreaming(false);
|
|
152064
152721
|
}
|
|
152065
152722
|
}, [pendingApproval, processConversation, appendError]);
|
|
152066
|
-
const handleModelSelect =
|
|
152723
|
+
const handleModelSelect = import_react38.useCallback(async (modelId) => {
|
|
152067
152724
|
setModelSelectorOpen(false);
|
|
152068
152725
|
let cmdId = null;
|
|
152069
152726
|
try {
|
|
@@ -152123,8 +152780,8 @@ function App2({
|
|
|
152123
152780
|
setCommandRunning(false);
|
|
152124
152781
|
}
|
|
152125
152782
|
}, [agentId, refreshDerived]);
|
|
152126
|
-
const [uiPermissionMode, setUiPermissionMode] =
|
|
152127
|
-
const handlePlanApprove =
|
|
152783
|
+
const [uiPermissionMode, setUiPermissionMode] = import_react38.useState(permissionMode2.getMode());
|
|
152784
|
+
const handlePlanApprove = import_react38.useCallback(async (acceptEdits = false) => {
|
|
152128
152785
|
if (!planApprovalPending)
|
|
152129
152786
|
return;
|
|
152130
152787
|
const { toolCallId, toolArgs } = planApprovalPending;
|
|
@@ -152167,7 +152824,7 @@ function App2({
|
|
|
152167
152824
|
setStreaming(false);
|
|
152168
152825
|
}
|
|
152169
152826
|
}, [planApprovalPending, processConversation, appendError, refreshDerived]);
|
|
152170
|
-
const handlePlanKeepPlanning =
|
|
152827
|
+
const handlePlanKeepPlanning = import_react38.useCallback(async (reason) => {
|
|
152171
152828
|
if (!planApprovalPending)
|
|
152172
152829
|
return;
|
|
152173
152830
|
const { toolCallId } = planApprovalPending;
|
|
@@ -152187,7 +152844,7 @@ function App2({
|
|
|
152187
152844
|
setStreaming(false);
|
|
152188
152845
|
}
|
|
152189
152846
|
}, [planApprovalPending, processConversation, appendError]);
|
|
152190
|
-
const liveItems =
|
|
152847
|
+
const liveItems = import_react38.useMemo(() => {
|
|
152191
152848
|
return lines.filter((ln) => {
|
|
152192
152849
|
if (!("phase" in ln))
|
|
152193
152850
|
return false;
|
|
@@ -152204,7 +152861,7 @@ function App2({
|
|
|
152204
152861
|
return ln.phase === "streaming";
|
|
152205
152862
|
});
|
|
152206
152863
|
}, [lines, tokenStreamingEnabled]);
|
|
152207
|
-
|
|
152864
|
+
import_react38.useEffect(() => {
|
|
152208
152865
|
if (loadingState === "ready" && !welcomeCommittedRef.current && messageHistory.length === 0) {
|
|
152209
152866
|
welcomeCommittedRef.current = true;
|
|
152210
152867
|
setStaticItems((prev) => [
|
|
@@ -152227,71 +152884,71 @@ function App2({
|
|
|
152227
152884
|
columns,
|
|
152228
152885
|
agentState
|
|
152229
152886
|
]);
|
|
152230
|
-
return /* @__PURE__ */
|
|
152887
|
+
return /* @__PURE__ */ jsx_dev_runtime23.jsxDEV(Box_default, {
|
|
152231
152888
|
flexDirection: "column",
|
|
152232
152889
|
gap: 1,
|
|
152233
152890
|
children: [
|
|
152234
|
-
/* @__PURE__ */
|
|
152891
|
+
/* @__PURE__ */ jsx_dev_runtime23.jsxDEV(Static, {
|
|
152235
152892
|
items: staticItems,
|
|
152236
152893
|
style: { flexDirection: "column" },
|
|
152237
|
-
children: (item, index) => /* @__PURE__ */
|
|
152894
|
+
children: (item, index) => /* @__PURE__ */ jsx_dev_runtime23.jsxDEV(Box_default, {
|
|
152238
152895
|
marginTop: index > 0 ? 1 : 0,
|
|
152239
|
-
children: item.kind === "welcome" ? /* @__PURE__ */
|
|
152896
|
+
children: item.kind === "welcome" ? /* @__PURE__ */ jsx_dev_runtime23.jsxDEV(WelcomeScreen, {
|
|
152240
152897
|
loadingState: "ready",
|
|
152241
152898
|
...item.snapshot
|
|
152242
|
-
}, undefined, false, undefined, this) : item.kind === "user" ? /* @__PURE__ */
|
|
152899
|
+
}, undefined, false, undefined, this) : item.kind === "user" ? /* @__PURE__ */ jsx_dev_runtime23.jsxDEV(UserMessage, {
|
|
152243
152900
|
line: item
|
|
152244
|
-
}, undefined, false, undefined, this) : item.kind === "reasoning" ? /* @__PURE__ */
|
|
152901
|
+
}, undefined, false, undefined, this) : item.kind === "reasoning" ? /* @__PURE__ */ jsx_dev_runtime23.jsxDEV(ReasoningMessage, {
|
|
152245
152902
|
line: item
|
|
152246
|
-
}, undefined, false, undefined, this) : item.kind === "assistant" ? /* @__PURE__ */
|
|
152903
|
+
}, undefined, false, undefined, this) : item.kind === "assistant" ? /* @__PURE__ */ jsx_dev_runtime23.jsxDEV(AssistantMessage, {
|
|
152247
152904
|
line: item
|
|
152248
|
-
}, undefined, false, undefined, this) : item.kind === "tool_call" ? /* @__PURE__ */
|
|
152905
|
+
}, undefined, false, undefined, this) : item.kind === "tool_call" ? /* @__PURE__ */ jsx_dev_runtime23.jsxDEV(ToolCallMessage, {
|
|
152249
152906
|
line: item
|
|
152250
|
-
}, undefined, false, undefined, this) : item.kind === "error" ? /* @__PURE__ */
|
|
152907
|
+
}, undefined, false, undefined, this) : item.kind === "error" ? /* @__PURE__ */ jsx_dev_runtime23.jsxDEV(ErrorMessage, {
|
|
152251
152908
|
line: item
|
|
152252
|
-
}, undefined, false, undefined, this) : /* @__PURE__ */
|
|
152909
|
+
}, undefined, false, undefined, this) : /* @__PURE__ */ jsx_dev_runtime23.jsxDEV(CommandMessage, {
|
|
152253
152910
|
line: item
|
|
152254
152911
|
}, undefined, false, undefined, this)
|
|
152255
152912
|
}, item.id, false, undefined, this)
|
|
152256
152913
|
}, staticRenderEpoch, false, undefined, this),
|
|
152257
|
-
/* @__PURE__ */
|
|
152914
|
+
/* @__PURE__ */ jsx_dev_runtime23.jsxDEV(Box_default, {
|
|
152258
152915
|
flexDirection: "column",
|
|
152259
152916
|
gap: 1,
|
|
152260
152917
|
children: [
|
|
152261
|
-
loadingState !== "ready" && /* @__PURE__ */
|
|
152918
|
+
loadingState !== "ready" && /* @__PURE__ */ jsx_dev_runtime23.jsxDEV(WelcomeScreen, {
|
|
152262
152919
|
loadingState,
|
|
152263
152920
|
continueSession,
|
|
152264
152921
|
agentState
|
|
152265
152922
|
}, undefined, false, undefined, this),
|
|
152266
|
-
loadingState === "ready" && /* @__PURE__ */
|
|
152923
|
+
loadingState === "ready" && /* @__PURE__ */ jsx_dev_runtime23.jsxDEV(jsx_dev_runtime23.Fragment, {
|
|
152267
152924
|
children: [
|
|
152268
|
-
liveItems.length > 0 && !pendingApproval && !planApprovalPending && /* @__PURE__ */
|
|
152925
|
+
liveItems.length > 0 && !pendingApproval && !planApprovalPending && /* @__PURE__ */ jsx_dev_runtime23.jsxDEV(Box_default, {
|
|
152269
152926
|
flexDirection: "column",
|
|
152270
|
-
children: liveItems.map((ln) => /* @__PURE__ */
|
|
152927
|
+
children: liveItems.map((ln) => /* @__PURE__ */ jsx_dev_runtime23.jsxDEV(Box_default, {
|
|
152271
152928
|
marginTop: 1,
|
|
152272
|
-
children: ln.kind === "user" ? /* @__PURE__ */
|
|
152929
|
+
children: ln.kind === "user" ? /* @__PURE__ */ jsx_dev_runtime23.jsxDEV(UserMessage, {
|
|
152273
152930
|
line: ln
|
|
152274
|
-
}, undefined, false, undefined, this) : ln.kind === "reasoning" ? /* @__PURE__ */
|
|
152931
|
+
}, undefined, false, undefined, this) : ln.kind === "reasoning" ? /* @__PURE__ */ jsx_dev_runtime23.jsxDEV(ReasoningMessage, {
|
|
152275
152932
|
line: ln
|
|
152276
|
-
}, undefined, false, undefined, this) : ln.kind === "assistant" ? /* @__PURE__ */
|
|
152933
|
+
}, undefined, false, undefined, this) : ln.kind === "assistant" ? /* @__PURE__ */ jsx_dev_runtime23.jsxDEV(AssistantMessage, {
|
|
152277
152934
|
line: ln
|
|
152278
|
-
}, undefined, false, undefined, this) : ln.kind === "tool_call" ? /* @__PURE__ */
|
|
152935
|
+
}, undefined, false, undefined, this) : ln.kind === "tool_call" ? /* @__PURE__ */ jsx_dev_runtime23.jsxDEV(ToolCallMessage, {
|
|
152279
152936
|
line: ln
|
|
152280
|
-
}, undefined, false, undefined, this) : ln.kind === "error" ? /* @__PURE__ */
|
|
152937
|
+
}, undefined, false, undefined, this) : ln.kind === "error" ? /* @__PURE__ */ jsx_dev_runtime23.jsxDEV(ErrorMessage, {
|
|
152281
152938
|
line: ln
|
|
152282
|
-
}, undefined, false, undefined, this) : /* @__PURE__ */
|
|
152939
|
+
}, undefined, false, undefined, this) : /* @__PURE__ */ jsx_dev_runtime23.jsxDEV(CommandMessage, {
|
|
152283
152940
|
line: ln
|
|
152284
152941
|
}, undefined, false, undefined, this)
|
|
152285
152942
|
}, ln.id, false, undefined, this))
|
|
152286
152943
|
}, undefined, false, undefined, this),
|
|
152287
|
-
liveItems.length === 0 && /* @__PURE__ */
|
|
152944
|
+
liveItems.length === 0 && /* @__PURE__ */ jsx_dev_runtime23.jsxDEV(Box_default, {
|
|
152288
152945
|
height: 1
|
|
152289
152946
|
}, undefined, false, undefined, this),
|
|
152290
|
-
showExitStats && /* @__PURE__ */
|
|
152947
|
+
showExitStats && /* @__PURE__ */ jsx_dev_runtime23.jsxDEV(SessionStats2, {
|
|
152291
152948
|
stats: sessionStatsRef.current.getSnapshot(),
|
|
152292
152949
|
agentId
|
|
152293
152950
|
}, undefined, false, undefined, this),
|
|
152294
|
-
/* @__PURE__ */
|
|
152951
|
+
/* @__PURE__ */ jsx_dev_runtime23.jsxDEV(Input, {
|
|
152295
152952
|
visible: !showExitStats && !pendingApproval && !modelSelectorOpen && !planApprovalPending,
|
|
152296
152953
|
streaming,
|
|
152297
152954
|
commandRunning,
|
|
@@ -152304,17 +152961,17 @@ function App2({
|
|
|
152304
152961
|
onInterrupt: handleInterrupt,
|
|
152305
152962
|
interruptRequested
|
|
152306
152963
|
}, undefined, false, undefined, this),
|
|
152307
|
-
modelSelectorOpen && /* @__PURE__ */
|
|
152964
|
+
modelSelectorOpen && /* @__PURE__ */ jsx_dev_runtime23.jsxDEV(ModelSelector, {
|
|
152308
152965
|
currentModel: llmConfig?.model,
|
|
152309
152966
|
onSelect: handleModelSelect,
|
|
152310
152967
|
onCancel: () => setModelSelectorOpen(false)
|
|
152311
152968
|
}, undefined, false, undefined, this),
|
|
152312
|
-
planApprovalPending && /* @__PURE__ */
|
|
152969
|
+
planApprovalPending && /* @__PURE__ */ jsx_dev_runtime23.jsxDEV(jsx_dev_runtime23.Fragment, {
|
|
152313
152970
|
children: [
|
|
152314
|
-
/* @__PURE__ */
|
|
152971
|
+
/* @__PURE__ */ jsx_dev_runtime23.jsxDEV(Box_default, {
|
|
152315
152972
|
height: 1
|
|
152316
152973
|
}, undefined, false, undefined, this),
|
|
152317
|
-
/* @__PURE__ */
|
|
152974
|
+
/* @__PURE__ */ jsx_dev_runtime23.jsxDEV(PlanModeDialog, {
|
|
152318
152975
|
plan: planApprovalPending.plan,
|
|
152319
152976
|
onApprove: () => handlePlanApprove(false),
|
|
152320
152977
|
onApproveAndAcceptEdits: () => handlePlanApprove(true),
|
|
@@ -152322,12 +152979,12 @@ function App2({
|
|
|
152322
152979
|
}, undefined, false, undefined, this)
|
|
152323
152980
|
]
|
|
152324
152981
|
}, undefined, true, undefined, this),
|
|
152325
|
-
pendingApproval && /* @__PURE__ */
|
|
152982
|
+
pendingApproval && /* @__PURE__ */ jsx_dev_runtime23.jsxDEV(jsx_dev_runtime23.Fragment, {
|
|
152326
152983
|
children: [
|
|
152327
|
-
/* @__PURE__ */
|
|
152984
|
+
/* @__PURE__ */ jsx_dev_runtime23.jsxDEV(Box_default, {
|
|
152328
152985
|
height: 1
|
|
152329
152986
|
}, undefined, false, undefined, this),
|
|
152330
|
-
/* @__PURE__ */
|
|
152987
|
+
/* @__PURE__ */ jsx_dev_runtime23.jsxDEV(ApprovalDialog, {
|
|
152331
152988
|
approvalRequest: pendingApproval,
|
|
152332
152989
|
approvalContext,
|
|
152333
152990
|
onApprove: handleApprove,
|
|
@@ -152343,7 +153000,7 @@ function App2({
|
|
|
152343
153000
|
]
|
|
152344
153001
|
}, undefined, true, undefined, this);
|
|
152345
153002
|
}
|
|
152346
|
-
var import_letta_client6,
|
|
153003
|
+
var import_letta_client6, import_react38, jsx_dev_runtime23, CLEAR_SCREEN_AND_HOME = "\x1B[2J\x1B[H", CHECK_PENDING_APPROVALS_BEFORE_SEND = true;
|
|
152347
153004
|
var init_App2 = __esm(async () => {
|
|
152348
153005
|
init_client();
|
|
152349
153006
|
init_message();
|
|
@@ -152369,8 +153026,8 @@ var init_App2 = __esm(async () => {
|
|
|
152369
153026
|
init_WelcomeScreen()
|
|
152370
153027
|
]);
|
|
152371
153028
|
import_letta_client6 = __toESM(require_letta_client(), 1);
|
|
152372
|
-
|
|
152373
|
-
|
|
153029
|
+
import_react38 = __toESM(require_react2(), 1);
|
|
153030
|
+
jsx_dev_runtime23 = __toESM(require_jsx_dev_runtime(), 1);
|
|
152374
153031
|
});
|
|
152375
153032
|
|
|
152376
153033
|
// src/agent/create.ts
|
|
@@ -152379,7 +153036,7 @@ __export(exports_create, {
|
|
|
152379
153036
|
createAgent: () => createAgent2
|
|
152380
153037
|
});
|
|
152381
153038
|
async function createAgent2(name = "letta-cli-agent", model = "anthropic/claude-sonnet-4-5-20250929") {
|
|
152382
|
-
const client = getClient2();
|
|
153039
|
+
const client = await getClient2();
|
|
152383
153040
|
const toolNames = [
|
|
152384
153041
|
...getToolNames(),
|
|
152385
153042
|
"memory",
|
|
@@ -152387,9 +153044,9 @@ async function createAgent2(name = "letta-cli-agent", model = "anthropic/claude-
|
|
|
152387
153044
|
"conversation_search"
|
|
152388
153045
|
];
|
|
152389
153046
|
const defaultMemoryBlocks = await getDefaultMemoryBlocks();
|
|
152390
|
-
const settings = await
|
|
153047
|
+
const settings = await loadSettings();
|
|
152391
153048
|
const globalSharedBlockIds = settings.globalSharedBlockIds;
|
|
152392
|
-
const projectSettings = await
|
|
153049
|
+
const projectSettings = await loadProjectSettings3();
|
|
152393
153050
|
const localSharedBlockIds = projectSettings.localSharedBlockIds;
|
|
152394
153051
|
const existingBlocks = new Map;
|
|
152395
153052
|
for (const [label, blockId] of Object.entries(globalSharedBlockIds)) {
|
|
@@ -152441,7 +153098,7 @@ async function createAgent2(name = "letta-cli-agent", model = "anthropic/claude-
|
|
|
152441
153098
|
}
|
|
152442
153099
|
}
|
|
152443
153100
|
if (Object.keys(newGlobalBlockIds).length > 0) {
|
|
152444
|
-
await
|
|
153101
|
+
await updateSettings({
|
|
152445
153102
|
globalSharedBlockIds: {
|
|
152446
153103
|
...globalSharedBlockIds,
|
|
152447
153104
|
...newGlobalBlockIds
|
|
@@ -152449,7 +153106,7 @@ async function createAgent2(name = "letta-cli-agent", model = "anthropic/claude-
|
|
|
152449
153106
|
});
|
|
152450
153107
|
}
|
|
152451
153108
|
if (Object.keys(newLocalBlockIds).length > 0) {
|
|
152452
|
-
await
|
|
153109
|
+
await updateProjectSettings3(process.cwd(), {
|
|
152453
153110
|
localSharedBlockIds: {
|
|
152454
153111
|
...localSharedBlockIds,
|
|
152455
153112
|
...newLocalBlockIds
|
|
@@ -152473,7 +153130,7 @@ async function createAgent2(name = "letta-cli-agent", model = "anthropic/claude-
|
|
|
152473
153130
|
var import_letta_client7;
|
|
152474
153131
|
var init_create3 = __esm(() => {
|
|
152475
153132
|
init_project_settings();
|
|
152476
|
-
|
|
153133
|
+
init_settings();
|
|
152477
153134
|
init_manager();
|
|
152478
153135
|
init_client();
|
|
152479
153136
|
init_memory();
|
|
@@ -152516,14 +153173,32 @@ async function getResumeData(client, agentId) {
|
|
|
152516
153173
|
}
|
|
152517
153174
|
|
|
152518
153175
|
// src/agent/client.ts
|
|
153176
|
+
init_settings();
|
|
152519
153177
|
var import_letta_client = __toESM(require_letta_client(), 1);
|
|
152520
|
-
function getClient() {
|
|
152521
|
-
const
|
|
153178
|
+
async function getClient() {
|
|
153179
|
+
const settings = await loadSettings();
|
|
153180
|
+
const token = process.env.LETTA_API_KEY || settings.env?.LETTA_API_KEY;
|
|
152522
153181
|
if (!token) {
|
|
152523
153182
|
console.error("Missing LETTA_API_KEY");
|
|
153183
|
+
console.error("Set it via environment variable or add it to ~/.letta/settings.json:");
|
|
153184
|
+
console.error(' { "env": { "LETTA_API_KEY": "sk-let-..." } }');
|
|
152524
153185
|
process.exit(1);
|
|
152525
153186
|
}
|
|
152526
|
-
|
|
153187
|
+
const baseUrl = process.env.LETTA_BASE_URL || settings.env?.LETTA_BASE_URL || "https://api.letta.com";
|
|
153188
|
+
let needsUpdate = false;
|
|
153189
|
+
const updatedEnv = { ...settings.env };
|
|
153190
|
+
if (process.env.LETTA_API_KEY && !settings.env?.LETTA_API_KEY) {
|
|
153191
|
+
updatedEnv.LETTA_API_KEY = process.env.LETTA_API_KEY;
|
|
153192
|
+
needsUpdate = true;
|
|
153193
|
+
}
|
|
153194
|
+
if (process.env.LETTA_BASE_URL && !settings.env?.LETTA_BASE_URL) {
|
|
153195
|
+
updatedEnv.LETTA_BASE_URL = process.env.LETTA_BASE_URL;
|
|
153196
|
+
needsUpdate = true;
|
|
153197
|
+
}
|
|
153198
|
+
if (needsUpdate) {
|
|
153199
|
+
await updateSettings({ env: updatedEnv });
|
|
153200
|
+
}
|
|
153201
|
+
return new import_letta_client.LettaClient({ token, baseUrl });
|
|
152527
153202
|
}
|
|
152528
153203
|
|
|
152529
153204
|
// src/permissions/mode.ts
|
|
@@ -152598,7 +153273,7 @@ class PermissionModeManager {
|
|
|
152598
153273
|
var permissionMode = new PermissionModeManager;
|
|
152599
153274
|
|
|
152600
153275
|
// src/index.ts
|
|
152601
|
-
|
|
153276
|
+
init_settings2();
|
|
152602
153277
|
|
|
152603
153278
|
// src/tools/manager.ts
|
|
152604
153279
|
init_toolDefinitions();
|
|
@@ -152678,26 +153353,32 @@ Letta Code is a general purpose CLI for interacting with Letta agents
|
|
|
152678
153353
|
|
|
152679
153354
|
USAGE
|
|
152680
153355
|
# interactive TUI
|
|
152681
|
-
letta
|
|
152682
|
-
letta --
|
|
153356
|
+
letta Auto-resume project agent (from .letta/settings.local.json)
|
|
153357
|
+
letta --new Force create a new agent
|
|
153358
|
+
letta --continue Resume global last agent (deprecated, use project-based)
|
|
152683
153359
|
letta --agent <id> Open a specific agent by ID
|
|
152684
153360
|
|
|
152685
153361
|
# headless
|
|
152686
|
-
letta
|
|
153362
|
+
letta -p "..." One-off prompt in headless mode (no TTY UI)
|
|
152687
153363
|
|
|
152688
153364
|
OPTIONS
|
|
152689
153365
|
-h, --help Show this help and exit
|
|
152690
153366
|
-v, --version Print version and exit
|
|
152691
|
-
|
|
153367
|
+
--new Force create new agent (skip auto-resume)
|
|
153368
|
+
-c, --continue Resume previous session (uses global lastAgent, deprecated)
|
|
152692
153369
|
-a, --agent <id> Use a specific agent ID
|
|
152693
153370
|
-p, --prompt Headless prompt mode
|
|
152694
153371
|
--output-format <fmt> Output format for headless mode (text, json, stream-json)
|
|
152695
153372
|
Default: text
|
|
152696
153373
|
|
|
153374
|
+
BEHAVIOR
|
|
153375
|
+
By default, letta auto-resumes the last agent used in the current directory
|
|
153376
|
+
(stored in .letta/settings.local.json). Use --new to force a new agent.
|
|
153377
|
+
|
|
152697
153378
|
EXAMPLES
|
|
152698
153379
|
# when installed as an executable
|
|
152699
|
-
letta
|
|
152700
|
-
letta --
|
|
153380
|
+
letta # Auto-resume project agent or create new
|
|
153381
|
+
letta --new # Force new agent
|
|
152701
153382
|
letta --agent agent_123
|
|
152702
153383
|
|
|
152703
153384
|
# headless with JSON output (includes stats)
|
|
@@ -152707,14 +153388,16 @@ EXAMPLES
|
|
|
152707
153388
|
console.log(usage);
|
|
152708
153389
|
}
|
|
152709
153390
|
async function main() {
|
|
152710
|
-
const settings = await
|
|
153391
|
+
const settings = await loadSettings2();
|
|
152711
153392
|
let values;
|
|
152712
153393
|
try {
|
|
152713
153394
|
const parsed = parseArgs2({
|
|
152714
153395
|
args: process.argv,
|
|
152715
153396
|
options: {
|
|
152716
153397
|
help: { type: "boolean", short: "h" },
|
|
153398
|
+
version: { type: "boolean", short: "v" },
|
|
152717
153399
|
continue: { type: "boolean", short: "c" },
|
|
153400
|
+
new: { type: "boolean" },
|
|
152718
153401
|
agent: { type: "string", short: "a" },
|
|
152719
153402
|
prompt: { type: "boolean", short: "p" },
|
|
152720
153403
|
run: { type: "boolean" },
|
|
@@ -152751,11 +153434,14 @@ Note: Flags should use double dashes for full names (e.g., --yolo, not -yolo)`);
|
|
|
152751
153434
|
process.exit(0);
|
|
152752
153435
|
}
|
|
152753
153436
|
const shouldContinue = values.continue ?? false;
|
|
153437
|
+
const forceNew = values.new ?? false;
|
|
152754
153438
|
const specifiedAgentId = values.agent ?? null;
|
|
152755
153439
|
const isHeadless = values.prompt || values.run || !process.stdin.isTTY;
|
|
152756
|
-
const apiKey = process.env.LETTA_API_KEY;
|
|
153440
|
+
const apiKey = process.env.LETTA_API_KEY || settings.env?.LETTA_API_KEY;
|
|
152757
153441
|
if (!apiKey) {
|
|
152758
153442
|
console.error("Missing LETTA_API_KEY");
|
|
153443
|
+
console.error("Set it via environment variable or add it to ~/.letta/settings.json:");
|
|
153444
|
+
console.error(' { "env": { "LETTA_API_KEY": "sk-let-..." } }');
|
|
152759
153445
|
process.exit(1);
|
|
152760
153446
|
}
|
|
152761
153447
|
if (values.tools !== undefined) {
|
|
@@ -152794,7 +153480,7 @@ Note: Flags should use double dashes for full names (e.g., --yolo, not -yolo)`);
|
|
|
152794
153480
|
}
|
|
152795
153481
|
if (isHeadless) {
|
|
152796
153482
|
await loadTools();
|
|
152797
|
-
const client = getClient();
|
|
153483
|
+
const client = await getClient();
|
|
152798
153484
|
await upsertToolsToServer(client);
|
|
152799
153485
|
const { handleHeadlessCommand: handleHeadlessCommand2 } = await Promise.resolve().then(() => (init_headless(), exports_headless));
|
|
152800
153486
|
await handleHeadlessCommand2(process.argv);
|
|
@@ -152802,27 +153488,29 @@ Note: Flags should use double dashes for full names (e.g., --yolo, not -yolo)`);
|
|
|
152802
153488
|
}
|
|
152803
153489
|
const React12 = await Promise.resolve().then(() => __toESM(require_react(), 1));
|
|
152804
153490
|
const { render: render2 } = await init_build2().then(() => exports_build);
|
|
152805
|
-
const { useState:
|
|
153491
|
+
const { useState: useState14, useEffect: useEffect12 } = React12;
|
|
152806
153492
|
const AppModule = await init_App2().then(() => exports_App);
|
|
152807
153493
|
const App3 = AppModule.default;
|
|
152808
153494
|
function LoadingApp({
|
|
152809
153495
|
continueSession,
|
|
153496
|
+
forceNew: forceNew2,
|
|
152810
153497
|
agentIdArg
|
|
152811
153498
|
}) {
|
|
152812
|
-
const [loadingState, setLoadingState] =
|
|
152813
|
-
const [agentId, setAgentId] =
|
|
152814
|
-
const [agentState, setAgentState] =
|
|
152815
|
-
const [resumeData, setResumeData] =
|
|
152816
|
-
|
|
153499
|
+
const [loadingState, setLoadingState] = useState14("assembling");
|
|
153500
|
+
const [agentId, setAgentId] = useState14(null);
|
|
153501
|
+
const [agentState, setAgentState] = useState14(null);
|
|
153502
|
+
const [resumeData, setResumeData] = useState14(null);
|
|
153503
|
+
const [isResumingSession, setIsResumingSession] = useState14(false);
|
|
153504
|
+
useEffect12(() => {
|
|
152817
153505
|
async function init() {
|
|
152818
153506
|
setLoadingState("assembling");
|
|
152819
153507
|
await loadTools();
|
|
152820
153508
|
setLoadingState("upserting");
|
|
152821
|
-
const client = getClient();
|
|
153509
|
+
const client = await getClient();
|
|
152822
153510
|
await upsertToolsToServer(client);
|
|
152823
153511
|
setLoadingState("initializing");
|
|
152824
153512
|
const { createAgent: createAgent3 } = await Promise.resolve().then(() => (init_create3(), exports_create));
|
|
152825
|
-
const { updateSettings: updateSettings3 } = await Promise.resolve().then(() => (
|
|
153513
|
+
const { updateSettings: updateSettings3, loadProjectSettings: loadProjectSettings4, updateProjectSettings: updateProjectSettings4 } = await Promise.resolve().then(() => (init_settings2(), exports_settings2));
|
|
152826
153514
|
let agent = null;
|
|
152827
153515
|
if (agentIdArg) {
|
|
152828
153516
|
try {
|
|
@@ -152831,6 +153519,19 @@ Note: Flags should use double dashes for full names (e.g., --yolo, not -yolo)`);
|
|
|
152831
153519
|
console.error(`Agent ${agentIdArg} not found (error: ${JSON.stringify(error)}), creating new one...`);
|
|
152832
153520
|
}
|
|
152833
153521
|
}
|
|
153522
|
+
if (!agent && forceNew2) {
|
|
153523
|
+
agent = await createAgent3();
|
|
153524
|
+
}
|
|
153525
|
+
if (!agent) {
|
|
153526
|
+
const projectSettings2 = await loadProjectSettings4();
|
|
153527
|
+
if (projectSettings2?.lastAgent) {
|
|
153528
|
+
try {
|
|
153529
|
+
agent = await client.agents.retrieve(projectSettings2.lastAgent);
|
|
153530
|
+
} catch (error) {
|
|
153531
|
+
console.error(`Project agent ${projectSettings2.lastAgent} not found (error: ${JSON.stringify(error)}), creating new one...`);
|
|
153532
|
+
}
|
|
153533
|
+
}
|
|
153534
|
+
}
|
|
152834
153535
|
if (!agent && continueSession && settings.lastAgent) {
|
|
152835
153536
|
try {
|
|
152836
153537
|
agent = await client.agents.retrieve(settings.lastAgent);
|
|
@@ -152840,9 +153541,14 @@ Note: Flags should use double dashes for full names (e.g., --yolo, not -yolo)`);
|
|
|
152840
153541
|
}
|
|
152841
153542
|
if (!agent) {
|
|
152842
153543
|
agent = await createAgent3();
|
|
152843
|
-
await updateSettings3({ lastAgent: agent.id });
|
|
152844
153544
|
}
|
|
152845
|
-
|
|
153545
|
+
await updateProjectSettings4({ lastAgent: agent.id });
|
|
153546
|
+
await updateSettings3({ lastAgent: agent.id });
|
|
153547
|
+
const projectSettings = await loadProjectSettings4();
|
|
153548
|
+
const isResumingProject = !forceNew2 && projectSettings?.lastAgent && agent.id === projectSettings.lastAgent;
|
|
153549
|
+
const resuming = continueSession || !!agentIdArg || isResumingProject;
|
|
153550
|
+
setIsResumingSession(resuming);
|
|
153551
|
+
if (resuming) {
|
|
152846
153552
|
setLoadingState("checking");
|
|
152847
153553
|
const data = await getResumeData(client, agent.id);
|
|
152848
153554
|
setResumeData(data);
|
|
@@ -152852,8 +153558,7 @@ Note: Flags should use double dashes for full names (e.g., --yolo, not -yolo)`);
|
|
|
152852
153558
|
setLoadingState("ready");
|
|
152853
153559
|
}
|
|
152854
153560
|
init();
|
|
152855
|
-
}, [continueSession, agentIdArg]);
|
|
152856
|
-
const isResumingSession = continueSession || !!agentIdArg;
|
|
153561
|
+
}, [continueSession, forceNew2, agentIdArg]);
|
|
152857
153562
|
if (!agentId) {
|
|
152858
153563
|
return React12.createElement(App3, {
|
|
152859
153564
|
agentId: "loading",
|
|
@@ -152876,6 +153581,7 @@ Note: Flags should use double dashes for full names (e.g., --yolo, not -yolo)`);
|
|
|
152876
153581
|
}
|
|
152877
153582
|
render2(React12.createElement(LoadingApp, {
|
|
152878
153583
|
continueSession: shouldContinue,
|
|
153584
|
+
forceNew,
|
|
152879
153585
|
agentIdArg: specifiedAgentId
|
|
152880
153586
|
}), {
|
|
152881
153587
|
exitOnCtrlC: false
|
|
@@ -152883,4 +153589,4 @@ Note: Flags should use double dashes for full names (e.g., --yolo, not -yolo)`);
|
|
|
152883
153589
|
}
|
|
152884
153590
|
main();
|
|
152885
153591
|
|
|
152886
|
-
//# debugId=
|
|
153592
|
+
//# debugId=96F7CCA7BD2849D564756E2164756E21
|