@letta-ai/letta-code 0.34.59 → 0.34.60
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/dist/mcp-client.js +2 -2
- package/dist/mcp-client.js.map +1 -1
- package/dist/mcp-oauth.js +2 -2
- package/dist/mcp-oauth.js.map +1 -1
- package/letta.js +423 -388
- package/npm-shrinkwrap.json +5 -5
- package/package.json +2 -2
- package/skills/working-across-computers/references/connect-a-computer-for-remote-access.md +2 -25
package/letta.js
CHANGED
|
@@ -6135,7 +6135,7 @@ var package_default;
|
|
|
6135
6135
|
var init_package = __esm(() => {
|
|
6136
6136
|
package_default = {
|
|
6137
6137
|
name: "@letta-ai/letta-code",
|
|
6138
|
-
version: "0.34.
|
|
6138
|
+
version: "0.34.60",
|
|
6139
6139
|
lettaStartupLogProtocol: 1,
|
|
6140
6140
|
lettaConfigDirProtocol: 1,
|
|
6141
6141
|
description: "Letta Code is a CLI tool for interacting with stateful Letta agents from the terminal.",
|
|
@@ -6422,7 +6422,7 @@ var init_package = __esm(() => {
|
|
|
6422
6422
|
},
|
|
6423
6423
|
lettaLifecycleProtocol: 1,
|
|
6424
6424
|
lettaRuntimeGraphProtocol: 1,
|
|
6425
|
-
lettaRuntimeGraphSha512: "sha512-
|
|
6425
|
+
lettaRuntimeGraphSha512: "sha512-WIuDCHjU7HpMkupg3IJU9kpdNZeagbwQQttyZaFDwGbI5Joz+NYvDSWoXrYPaA1w2Oxy6HVIBBPtv/lzIoENmg==",
|
|
6426
6426
|
patchedDependencies: {
|
|
6427
6427
|
"@earendil-works/pi-ai@1.5.2": "patches/@earendil-works%2Fpi-ai@1.5.2.patch"
|
|
6428
6428
|
}
|
|
@@ -203262,7 +203262,7 @@ var init_mcp_client = __esm(() => {
|
|
|
203262
203262
|
init_streamableHttp();
|
|
203263
203263
|
DEFAULT_CLIENT_INFO = {
|
|
203264
203264
|
name: "letta-code",
|
|
203265
|
-
version: "0.34.
|
|
203265
|
+
version: "0.34.60"
|
|
203266
203266
|
};
|
|
203267
203267
|
});
|
|
203268
203268
|
|
|
@@ -240125,7 +240125,7 @@ class CodexAppServerClient {
|
|
|
240125
240125
|
await this.request("initialize", {
|
|
240126
240126
|
clientInfo: {
|
|
240127
240127
|
name: "letta-code",
|
|
240128
|
-
version: "0.34.
|
|
240128
|
+
version: "0.34.60"
|
|
240129
240129
|
},
|
|
240130
240130
|
capabilities: null
|
|
240131
240131
|
});
|
|
@@ -439504,6 +439504,38 @@ var init_mod_adapter = __esm(() => {
|
|
|
439504
439504
|
});
|
|
439505
439505
|
|
|
439506
439506
|
// src/websocket/listener/memfs-sync.ts
|
|
439507
|
+
import { execFileSync as execFileSync11 } from "node:child_process";
|
|
439508
|
+
import { lstat as lstat2, realpath as realpath6, rm as rm11 } from "node:fs/promises";
|
|
439509
|
+
import { isAbsolute as isAbsolute26, join as join83, relative as relative7, resolve as resolve37, sep as sep8 } from "node:path";
|
|
439510
|
+
async function removeRefusedCheckout(agentId, error4) {
|
|
439511
|
+
const message2 = error4 instanceof Error ? error4.message : String(error4);
|
|
439512
|
+
if (isLocalBackendEnvEnabled() || !/(?:returned error:|HTTP(?: status)?)[ :]*403\b/i.test(message2))
|
|
439513
|
+
return;
|
|
439514
|
+
try {
|
|
439515
|
+
const { getScopedMemoryFilesystemRoot: getScopedMemoryFilesystemRoot2 } = await Promise.resolve().then(() => (init_memory_filesystem2(), exports_memory_filesystem));
|
|
439516
|
+
const { isMemfsRemoteUrlForAgent: isMemfsRemoteUrlForAgent2 } = await Promise.resolve().then(() => (init_memory_git(), exports_memory_git));
|
|
439517
|
+
const configDir = await realpath6(resolveGlobalConfigDir());
|
|
439518
|
+
if (!agentId || agentId === "." || agentId === ".." || /[/\\]/.test(agentId))
|
|
439519
|
+
return;
|
|
439520
|
+
const expected = join83(configDir, "agents", agentId, "memory");
|
|
439521
|
+
const checkout = resolve37(getScopedMemoryFilesystemRoot2(agentId));
|
|
439522
|
+
if (await realpath6(checkout) !== expected || !(await lstat2(checkout)).isDirectory())
|
|
439523
|
+
return;
|
|
439524
|
+
const cwdRelative = relative7(expected, await realpath6(process.cwd()));
|
|
439525
|
+
if (!cwdRelative || !cwdRelative.startsWith(`..${sep8}`) && cwdRelative !== ".." && !isAbsolute26(cwdRelative))
|
|
439526
|
+
return;
|
|
439527
|
+
if (!(await lstat2(join83(checkout, ".git"))).isDirectory())
|
|
439528
|
+
return;
|
|
439529
|
+
const origin = execFileSync11("git", ["-C", checkout, "remote", "get-url", "origin"], {
|
|
439530
|
+
encoding: "utf8",
|
|
439531
|
+
timeout: 5000,
|
|
439532
|
+
stdio: ["ignore", "pipe", "ignore"]
|
|
439533
|
+
}).trim();
|
|
439534
|
+
if (!isMemfsRemoteUrlForAgent2(origin, agentId))
|
|
439535
|
+
return;
|
|
439536
|
+
await rm11(checkout, { recursive: true, force: true });
|
|
439537
|
+
} catch {}
|
|
439538
|
+
}
|
|
439507
439539
|
async function syncMemfsForAgent(agentId) {
|
|
439508
439540
|
const { settingsManager: settingsManager2 } = await Promise.resolve().then(() => (init_settings_manager(), exports_settings_manager));
|
|
439509
439541
|
if (settingsManager2.isMemfsExplicitlyDisabled(agentId)) {
|
|
@@ -439550,9 +439582,10 @@ async function ensureMemfsSyncedForAgent(listener, agentId) {
|
|
|
439550
439582
|
if (existing) {
|
|
439551
439583
|
return existing;
|
|
439552
439584
|
}
|
|
439553
|
-
const promise2 = syncMemfsForAgent(agentId).then(() => true, (err) => {
|
|
439585
|
+
const promise2 = syncMemfsForAgent(agentId).then(() => true, async (err) => {
|
|
439554
439586
|
debugWarn("memfs-sync", `Failed to sync memfs for agent ${agentId}: ${err instanceof Error ? err.message : String(err)}`);
|
|
439555
439587
|
if (isMemoryAccessRefusal(err)) {
|
|
439588
|
+
await removeRefusedCheckout(agentId, err);
|
|
439556
439589
|
markMemoryUnavailable(agentId);
|
|
439557
439590
|
} else {
|
|
439558
439591
|
listener.memfsSyncedAgents.delete(agentId);
|
|
@@ -439563,13 +439596,15 @@ async function ensureMemfsSyncedForAgent(listener, agentId) {
|
|
|
439563
439596
|
return promise2;
|
|
439564
439597
|
}
|
|
439565
439598
|
var init_memfs_sync = __esm(() => {
|
|
439599
|
+
init_paths();
|
|
439566
439600
|
init_debug();
|
|
439567
439601
|
init_memory_access();
|
|
439602
|
+
init_settings_path();
|
|
439568
439603
|
});
|
|
439569
439604
|
|
|
439570
439605
|
// src/websocket/listener/mod-adapter.ts
|
|
439571
439606
|
import { createHash as createHash18 } from "node:crypto";
|
|
439572
|
-
import { join as
|
|
439607
|
+
import { join as join84 } from "node:path";
|
|
439573
439608
|
async function getUnavailableListenerClient() {
|
|
439574
439609
|
throw new Error("letta.client is not available in listener mods");
|
|
439575
439610
|
}
|
|
@@ -439645,14 +439680,14 @@ function ensureListenerModAdapter(runtime) {
|
|
|
439645
439680
|
}
|
|
439646
439681
|
function resolveListenerAgentModsDirectory(agentId) {
|
|
439647
439682
|
try {
|
|
439648
|
-
return settingsManager.isMemfsEnabled(agentId) ?
|
|
439683
|
+
return settingsManager.isMemfsEnabled(agentId) ? join84(getScopedMemoryFilesystemRoot(agentId), "mods") : null;
|
|
439649
439684
|
} catch {
|
|
439650
439685
|
return null;
|
|
439651
439686
|
}
|
|
439652
439687
|
}
|
|
439653
439688
|
function resolveListenerAgentModCacheDirectory(agentId) {
|
|
439654
439689
|
const cacheKey = createHash18("sha256").update(agentId).digest("hex");
|
|
439655
|
-
return
|
|
439690
|
+
return join84(getModCacheDirectory(), "listener-agents", cacheKey);
|
|
439656
439691
|
}
|
|
439657
439692
|
async function ensureListenerAgentModAdapter(runtime, agentId) {
|
|
439658
439693
|
runtime.agentModAdapters ??= new Map;
|
|
@@ -440474,7 +440509,7 @@ async function mergeSettledRecoveryResultRetriably(store3, params, retryDelayMs
|
|
|
440474
440509
|
if (!(error4 instanceof Error) || error4.message !== "Timed out acquiring durable filesystem lock") {
|
|
440475
440510
|
throw error4;
|
|
440476
440511
|
}
|
|
440477
|
-
await new Promise((
|
|
440512
|
+
await new Promise((resolve38) => setTimeout(resolve38, retryDelayMs));
|
|
440478
440513
|
}
|
|
440479
440514
|
}
|
|
440480
440515
|
}
|
|
@@ -441369,11 +441404,11 @@ async function retryApprovalRecoveryRead(read2, assertCurrent, signal) {
|
|
|
441369
441404
|
detail
|
|
441370
441405
|
}))
|
|
441371
441406
|
throw error4;
|
|
441372
|
-
await new Promise((
|
|
441407
|
+
await new Promise((resolve38) => {
|
|
441373
441408
|
const done = () => {
|
|
441374
441409
|
clearTimeout(timer);
|
|
441375
441410
|
signal.removeEventListener("abort", done);
|
|
441376
|
-
|
|
441411
|
+
resolve38();
|
|
441377
441412
|
};
|
|
441378
441413
|
const timer = setTimeout(done, getRetryDelayMs2({
|
|
441379
441414
|
category: "transient_provider",
|
|
@@ -441446,7 +441481,7 @@ async function sleepWithAbort3(delayMs, abortSignal) {
|
|
|
441446
441481
|
if (delayMs <= 0) {
|
|
441447
441482
|
return;
|
|
441448
441483
|
}
|
|
441449
|
-
await new Promise((
|
|
441484
|
+
await new Promise((resolve38, reject2) => {
|
|
441450
441485
|
let timeout = null;
|
|
441451
441486
|
function cleanup() {
|
|
441452
441487
|
if (timeout) {
|
|
@@ -441466,7 +441501,7 @@ async function sleepWithAbort3(delayMs, abortSignal) {
|
|
|
441466
441501
|
abortSignal?.addEventListener("abort", onAbort, { once: true });
|
|
441467
441502
|
timeout = setTimeout(() => {
|
|
441468
441503
|
cleanup();
|
|
441469
|
-
|
|
441504
|
+
resolve38();
|
|
441470
441505
|
}, delayMs);
|
|
441471
441506
|
});
|
|
441472
441507
|
}
|
|
@@ -441815,7 +441850,7 @@ async function sendMessageStreamWithRetry(conversationId, messages, opts, socket
|
|
|
441815
441850
|
conversationId
|
|
441816
441851
|
});
|
|
441817
441852
|
}
|
|
441818
|
-
await new Promise((
|
|
441853
|
+
await new Promise((resolve38) => setTimeout(resolve38, delayMs));
|
|
441819
441854
|
if (abortSignal?.aborted) {
|
|
441820
441855
|
throw new Error("Cancelled by user");
|
|
441821
441856
|
}
|
|
@@ -441963,7 +441998,7 @@ async function sendApprovalContinuationWithRetry(conversationId, messages, opts,
|
|
|
441963
441998
|
conversationId
|
|
441964
441999
|
});
|
|
441965
442000
|
}
|
|
441966
|
-
await new Promise((
|
|
442001
|
+
await new Promise((resolve38) => setTimeout(resolve38, delayMs));
|
|
441967
442002
|
if (abortSignal?.aborted) {
|
|
441968
442003
|
throw new Error("Cancelled by user");
|
|
441969
442004
|
}
|
|
@@ -442975,7 +443010,7 @@ var init_diff2 = __esm(() => {
|
|
|
442975
443010
|
});
|
|
442976
443011
|
|
|
442977
443012
|
// src/cli/helpers/shell-semantic-display.ts
|
|
442978
|
-
import { relative as
|
|
443013
|
+
import { relative as relative8 } from "node:path";
|
|
442979
443014
|
function quoteSummaryValue(value) {
|
|
442980
443015
|
return JSON.stringify(value);
|
|
442981
443016
|
}
|
|
@@ -443042,7 +443077,7 @@ function formatDisplayPath2(filePath) {
|
|
|
443042
443077
|
return ".";
|
|
443043
443078
|
}
|
|
443044
443079
|
const cwd2 = process.cwd();
|
|
443045
|
-
const relativePath =
|
|
443080
|
+
const relativePath = relative8(cwd2, filePath);
|
|
443046
443081
|
if (relativePath === "") {
|
|
443047
443082
|
return ".";
|
|
443048
443083
|
}
|
|
@@ -443667,13 +443702,13 @@ __export(exports_format_args_display, {
|
|
|
443667
443702
|
parsePatchInput: () => parsePatchInput,
|
|
443668
443703
|
formatArgsDisplay: () => formatArgsDisplay
|
|
443669
443704
|
});
|
|
443670
|
-
import { relative as
|
|
443705
|
+
import { relative as relative9 } from "node:path";
|
|
443671
443706
|
function formatItemCount(count) {
|
|
443672
443707
|
return `${String(count)} item${count === 1 ? "" : "s"}`;
|
|
443673
443708
|
}
|
|
443674
443709
|
function formatDisplayPath3(filePath) {
|
|
443675
443710
|
const cwd2 = process.cwd();
|
|
443676
|
-
const relativePath =
|
|
443711
|
+
const relativePath = relative9(cwd2, filePath);
|
|
443677
443712
|
if (relativePath.startsWith("..")) {
|
|
443678
443713
|
return filePath;
|
|
443679
443714
|
}
|
|
@@ -444369,7 +444404,7 @@ async function waitForApprovalTransportOpen(isDeliveryReady, shouldInterrupt) {
|
|
|
444369
444404
|
if (isDeliveryReady())
|
|
444370
444405
|
return "open";
|
|
444371
444406
|
while (!shouldInterrupt()) {
|
|
444372
|
-
await new Promise((
|
|
444407
|
+
await new Promise((resolve38) => setTimeout(resolve38, APPROVAL_TRANSPORT_REOPEN_POLL_MS));
|
|
444373
444408
|
if (isDeliveryReady())
|
|
444374
444409
|
return "open";
|
|
444375
444410
|
}
|
|
@@ -444980,7 +445015,7 @@ var init_turn_approval = __esm(() => {
|
|
|
444980
445015
|
|
|
444981
445016
|
// src/agent/attached-repository-git-sync.ts
|
|
444982
445017
|
import { existsSync as existsSync59 } from "node:fs";
|
|
444983
|
-
import { join as
|
|
445018
|
+
import { join as join85 } from "node:path";
|
|
444984
445019
|
async function getPendingCommitCount(path41) {
|
|
444985
445020
|
const divergence = await getMemoryAheadBehind(path41);
|
|
444986
445021
|
if (divergence) {
|
|
@@ -445010,7 +445045,7 @@ async function syncPendingAttachedRepositoryCommitsUnlocked(params) {
|
|
|
445010
445045
|
path: path41,
|
|
445011
445046
|
permissions: params.repository.permissions ?? "unknown"
|
|
445012
445047
|
};
|
|
445013
|
-
if (!existsSync59(
|
|
445048
|
+
if (!existsSync59(join85(path41, ".git"))) {
|
|
445014
445049
|
return {
|
|
445015
445050
|
...resultBase,
|
|
445016
445051
|
status: "skipped",
|
|
@@ -445181,7 +445216,7 @@ var init_attached_repository_git_sync = __esm(() => {
|
|
|
445181
445216
|
|
|
445182
445217
|
// src/reminders/memory-git-sync.ts
|
|
445183
445218
|
import { existsSync as existsSync60 } from "node:fs";
|
|
445184
|
-
import { join as
|
|
445219
|
+
import { join as join86 } from "node:path";
|
|
445185
445220
|
function formatMemoryRepairInProgressReminder(result3) {
|
|
445186
445221
|
return `${SYSTEM_REMINDER_OPEN}
|
|
445187
445222
|
MEMORY REPAIR RUNNING: A background worker is repairing the memory repository.
|
|
@@ -445291,7 +445326,7 @@ async function runPostTurnMemorySync(params, dependencies = {}) {
|
|
|
445291
445326
|
if (memorySyncEnabled) {
|
|
445292
445327
|
try {
|
|
445293
445328
|
const memoryDir = getScopedMemoryFilesystemRoot(params.agentId);
|
|
445294
|
-
const release = existsSync60(
|
|
445329
|
+
const release = existsSync60(join86(memoryDir, ".git")) ? await (dependencies.claimOperation ?? claimMemoryOperation)(memoryDir) : undefined;
|
|
445295
445330
|
if (release !== null) {
|
|
445296
445331
|
try {
|
|
445297
445332
|
const result3 = await syncMemory(params.agentId);
|
|
@@ -447526,7 +447561,7 @@ var init_core5 = __esm(() => {
|
|
|
447526
447561
|
import { spawn as spawn12 } from "node:child_process";
|
|
447527
447562
|
import { accessSync as accessSync2, constants as constants6 } from "node:fs";
|
|
447528
447563
|
import { homedir as homedir23 } from "node:os";
|
|
447529
|
-
import { join as
|
|
447564
|
+
import { join as join87 } from "node:path";
|
|
447530
447565
|
import { fileURLToPath as fileURLToPath9 } from "node:url";
|
|
447531
447566
|
async function normalizeCheckpoint(input) {
|
|
447532
447567
|
const { decoded, bounds, filters } = await decodeCheckpoint(input);
|
|
@@ -447550,10 +447585,10 @@ async function decodeCheckpoint(input) {
|
|
|
447550
447585
|
}
|
|
447551
447586
|
async function loadDeepAgentsCheckpoint(checkpoint) {
|
|
447552
447587
|
validateLocation(checkpoint);
|
|
447553
|
-
const path41 = checkpoint.path ??
|
|
447588
|
+
const path41 = checkpoint.path ?? join87(homedir23(), ".deepagents", "sessions.db");
|
|
447554
447589
|
const python = checkpoint.pythonExecutable ?? process.env.PYTHON ?? "python3";
|
|
447555
447590
|
const helper = resolveHelperPath();
|
|
447556
|
-
return await new Promise((
|
|
447591
|
+
return await new Promise((resolve38, reject2) => {
|
|
447557
447592
|
const child = spawn12(python, [helper], {
|
|
447558
447593
|
stdio: ["pipe", "pipe", "pipe"],
|
|
447559
447594
|
windowsHide: true
|
|
@@ -447610,7 +447645,7 @@ async function loadDeepAgentsCheckpoint(checkpoint) {
|
|
|
447610
447645
|
reject2(new NormalizationError("invalid_checkpoint_state", "Deep Agents checkpoint helper returned an invalid message envelope."));
|
|
447611
447646
|
return;
|
|
447612
447647
|
}
|
|
447613
|
-
|
|
447648
|
+
resolve38({ ...response.data, threadId: checkpoint.threadId });
|
|
447614
447649
|
});
|
|
447615
447650
|
child.stdin.on("error", () => {});
|
|
447616
447651
|
child.stdin.end(JSON.stringify({
|
|
@@ -447770,7 +447805,7 @@ var init_deepagents = __esm(() => {
|
|
|
447770
447805
|
|
|
447771
447806
|
// node_modules/@letta-ai/trajectory/dist/adapters/listing-shared.js
|
|
447772
447807
|
import { readdirSync as readdirSync24, statSync as statSync24 } from "node:fs";
|
|
447773
|
-
import { join as
|
|
447808
|
+
import { join as join88 } from "node:path";
|
|
447774
447809
|
function sortListings(items) {
|
|
447775
447810
|
return items.sort((left, right) => {
|
|
447776
447811
|
const l3 = left.updatedAt ?? "";
|
|
@@ -447815,7 +447850,7 @@ function collectFiles(root2, extension, depth) {
|
|
|
447815
447850
|
return [];
|
|
447816
447851
|
const collected = [];
|
|
447817
447852
|
for (const entry of safeReadDir(root2)) {
|
|
447818
|
-
const full =
|
|
447853
|
+
const full = join88(root2, entry.name);
|
|
447819
447854
|
if (entry.isFile && entry.name.endsWith(extension)) {
|
|
447820
447855
|
collected.push(full);
|
|
447821
447856
|
} else if (entry.isDirectory) {
|
|
@@ -447900,18 +447935,18 @@ var init_listing_shared = __esm(() => {
|
|
|
447900
447935
|
|
|
447901
447936
|
// node_modules/@letta-ai/trajectory/dist/adapters/claude-code/list.js
|
|
447902
447937
|
import { homedir as homedir24 } from "node:os";
|
|
447903
|
-
import { basename as basename25, join as
|
|
447938
|
+
import { basename as basename25, join as join89 } from "node:path";
|
|
447904
447939
|
async function listClaudeCodeTrajectories(root2) {
|
|
447905
|
-
const base2 = root2 ??
|
|
447940
|
+
const base2 = root2 ?? join89(homedir24(), ".claude", "projects");
|
|
447906
447941
|
const items = [];
|
|
447907
447942
|
for (const project of safeReadDir(base2)) {
|
|
447908
447943
|
if (!project.isDirectory)
|
|
447909
447944
|
continue;
|
|
447910
|
-
const projectPath =
|
|
447945
|
+
const projectPath = join89(base2, project.name);
|
|
447911
447946
|
for (const entry of safeReadDir(projectPath)) {
|
|
447912
447947
|
if (!entry.isFile || !entry.name.endsWith(".jsonl"))
|
|
447913
447948
|
continue;
|
|
447914
|
-
const path41 =
|
|
447949
|
+
const path41 = join89(projectPath, entry.name);
|
|
447915
447950
|
const listing = listingFromFile(basename25(entry.name, ".jsonl"), path41);
|
|
447916
447951
|
if (listing)
|
|
447917
447952
|
items.push(listing);
|
|
@@ -447925,9 +447960,9 @@ var init_list = __esm(() => {
|
|
|
447925
447960
|
|
|
447926
447961
|
// node_modules/@letta-ai/trajectory/dist/adapters/codex/list.js
|
|
447927
447962
|
import { homedir as homedir25 } from "node:os";
|
|
447928
|
-
import { basename as basename26, join as
|
|
447963
|
+
import { basename as basename26, join as join90 } from "node:path";
|
|
447929
447964
|
async function listCodexTrajectories(root2) {
|
|
447930
|
-
const base2 = root2 ??
|
|
447965
|
+
const base2 = root2 ?? join90(homedir25(), ".codex", "sessions");
|
|
447931
447966
|
const items = [];
|
|
447932
447967
|
for (const path41 of collectFiles(base2, ".jsonl", 4)) {
|
|
447933
447968
|
const listing = listingFromFile(basename26(path41, ".jsonl"), path41);
|
|
@@ -447942,7 +447977,7 @@ var init_list2 = __esm(() => {
|
|
|
447942
447977
|
|
|
447943
447978
|
// node_modules/@letta-ai/trajectory/dist/adapters/deepagents/list.js
|
|
447944
447979
|
import { homedir as homedir26 } from "node:os";
|
|
447945
|
-
import { join as
|
|
447980
|
+
import { join as join91 } from "node:path";
|
|
447946
447981
|
async function listDeepAgentsTrajectories(root2) {
|
|
447947
447982
|
const path41 = resolveStorePath(root2);
|
|
447948
447983
|
if (!safeStat(path41))
|
|
@@ -447963,8 +447998,8 @@ async function listDeepAgentsTrajectories(root2) {
|
|
|
447963
447998
|
}
|
|
447964
447999
|
function resolveStorePath(root2) {
|
|
447965
448000
|
if (root2 === undefined)
|
|
447966
|
-
return
|
|
447967
|
-
return root2.endsWith(".db") ? root2 :
|
|
448001
|
+
return join91(homedir26(), ".deepagents", "sessions.db");
|
|
448002
|
+
return root2.endsWith(".db") ? root2 : join91(root2, "sessions.db");
|
|
447968
448003
|
}
|
|
447969
448004
|
var init_list3 = __esm(() => {
|
|
447970
448005
|
init_listing_shared();
|
|
@@ -447972,7 +448007,7 @@ var init_list3 = __esm(() => {
|
|
|
447972
448007
|
|
|
447973
448008
|
// node_modules/@letta-ai/trajectory/dist/adapters/hermes/list.js
|
|
447974
448009
|
import { homedir as homedir27 } from "node:os";
|
|
447975
|
-
import { join as
|
|
448010
|
+
import { join as join92 } from "node:path";
|
|
447976
448011
|
async function listHermesTrajectories(root2) {
|
|
447977
448012
|
const path41 = resolveStorePath2(root2);
|
|
447978
448013
|
if (!safeStat(path41))
|
|
@@ -447999,8 +448034,8 @@ async function listHermesTrajectories(root2) {
|
|
|
447999
448034
|
}
|
|
448000
448035
|
function resolveStorePath2(root2) {
|
|
448001
448036
|
if (root2 === undefined)
|
|
448002
|
-
return
|
|
448003
|
-
return root2.endsWith(".db") ? root2 :
|
|
448037
|
+
return join92(homedir27(), ".hermes", "state.db");
|
|
448038
|
+
return root2.endsWith(".db") ? root2 : join92(root2, "state.db");
|
|
448004
448039
|
}
|
|
448005
448040
|
function numeric2(value) {
|
|
448006
448041
|
return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : undefined;
|
|
@@ -448011,18 +448046,18 @@ var init_list4 = __esm(() => {
|
|
|
448011
448046
|
|
|
448012
448047
|
// node_modules/@letta-ai/trajectory/dist/adapters/letta-code/list.js
|
|
448013
448048
|
import { homedir as homedir28 } from "node:os";
|
|
448014
|
-
import { join as
|
|
448049
|
+
import { join as join93 } from "node:path";
|
|
448015
448050
|
async function listLettaCodeTrajectories(root2) {
|
|
448016
|
-
const base2 = root2 ??
|
|
448051
|
+
const base2 = root2 ?? join93(homedir28(), ".letta", "transcripts");
|
|
448017
448052
|
const items = [];
|
|
448018
448053
|
for (const agent of safeReadDir(base2)) {
|
|
448019
448054
|
if (!agent.isDirectory)
|
|
448020
448055
|
continue;
|
|
448021
|
-
const agentPath2 =
|
|
448056
|
+
const agentPath2 = join93(base2, agent.name);
|
|
448022
448057
|
for (const conversation of safeReadDir(agentPath2)) {
|
|
448023
448058
|
if (!conversation.isDirectory)
|
|
448024
448059
|
continue;
|
|
448025
|
-
const path41 =
|
|
448060
|
+
const path41 = join93(agentPath2, conversation.name, "transcript.jsonl");
|
|
448026
448061
|
const listing = listingFromFile(`${agent.name}/${conversation.name}`, path41);
|
|
448027
448062
|
if (listing && (listing.sizeBytes ?? 0) > 0)
|
|
448028
448063
|
items.push(listing);
|
|
@@ -448037,19 +448072,19 @@ var init_list5 = __esm(() => {
|
|
|
448037
448072
|
// node_modules/@letta-ai/trajectory/dist/adapters/openclaw/list.js
|
|
448038
448073
|
import { existsSync as existsSync61 } from "node:fs";
|
|
448039
448074
|
import { homedir as homedir29 } from "node:os";
|
|
448040
|
-
import { basename as basename27, join as
|
|
448075
|
+
import { basename as basename27, join as join94 } from "node:path";
|
|
448041
448076
|
async function listOpenClawTrajectories(root2) {
|
|
448042
448077
|
const base2 = root2 ?? defaultStateDir();
|
|
448043
448078
|
const items = [];
|
|
448044
|
-
const agentsPath =
|
|
448079
|
+
const agentsPath = join94(base2, "agents");
|
|
448045
448080
|
for (const agent of safeReadDir(agentsPath)) {
|
|
448046
448081
|
if (!agent.isDirectory)
|
|
448047
448082
|
continue;
|
|
448048
|
-
const sessionsPath =
|
|
448083
|
+
const sessionsPath = join94(agentsPath, agent.name, "sessions");
|
|
448049
448084
|
for (const entry of safeReadDir(sessionsPath)) {
|
|
448050
448085
|
if (!entry.isFile || !entry.name.endsWith(".jsonl"))
|
|
448051
448086
|
continue;
|
|
448052
|
-
const path41 =
|
|
448087
|
+
const path41 = join94(sessionsPath, entry.name);
|
|
448053
448088
|
const listing = listingFromFile(basename27(entry.name, ".jsonl"), path41);
|
|
448054
448089
|
if (listing)
|
|
448055
448090
|
items.push(listing);
|
|
@@ -448061,10 +448096,10 @@ function defaultStateDir() {
|
|
|
448061
448096
|
const override = process.env.OPENCLAW_STATE_DIR?.trim() || process.env.CLAWDBOT_STATE_DIR?.trim();
|
|
448062
448097
|
if (override)
|
|
448063
448098
|
return override;
|
|
448064
|
-
const current =
|
|
448099
|
+
const current = join94(homedir29(), ".openclaw");
|
|
448065
448100
|
if (existsSync61(current))
|
|
448066
448101
|
return current;
|
|
448067
|
-
return
|
|
448102
|
+
return join94(homedir29(), ".clawdbot");
|
|
448068
448103
|
}
|
|
448069
448104
|
var init_list6 = __esm(() => {
|
|
448070
448105
|
init_listing_shared();
|
|
@@ -448072,14 +448107,14 @@ var init_list6 = __esm(() => {
|
|
|
448072
448107
|
|
|
448073
448108
|
// node_modules/@letta-ai/trajectory/dist/adapters/openhands/list.js
|
|
448074
448109
|
import { homedir as homedir30 } from "node:os";
|
|
448075
|
-
import { join as
|
|
448110
|
+
import { join as join95 } from "node:path";
|
|
448076
448111
|
async function listOpenHandsTrajectories(root2) {
|
|
448077
|
-
const base2 = root2 ??
|
|
448112
|
+
const base2 = root2 ?? join95(homedir30(), ".openhands", "sessions");
|
|
448078
448113
|
const items = [];
|
|
448079
448114
|
for (const entry of safeReadDir(base2)) {
|
|
448080
448115
|
if (!entry.isDirectory)
|
|
448081
448116
|
continue;
|
|
448082
|
-
const path41 =
|
|
448117
|
+
const path41 = join95(base2, entry.name);
|
|
448083
448118
|
const facts = safeStat(path41);
|
|
448084
448119
|
items.push({
|
|
448085
448120
|
id: entry.name,
|
|
@@ -448253,7 +448288,7 @@ __export(exports_memory_scanner, {
|
|
|
448253
448288
|
getFileNodes: () => getFileNodes
|
|
448254
448289
|
});
|
|
448255
448290
|
import { readdirSync as readdirSync25, readFileSync as readFileSync50, statSync as statSync25 } from "node:fs";
|
|
448256
|
-
import { join as
|
|
448291
|
+
import { join as join96, relative as relative10 } from "node:path";
|
|
448257
448292
|
function scanMemoryFilesystem(memoryRoot) {
|
|
448258
448293
|
const nodes = [];
|
|
448259
448294
|
const scanDir = (dir, depth, parentIsLast) => {
|
|
@@ -448265,8 +448300,8 @@ function scanMemoryFilesystem(memoryRoot) {
|
|
|
448265
448300
|
}
|
|
448266
448301
|
const filtered = entries2.filter((name) => !name.startsWith("."));
|
|
448267
448302
|
const sorted = filtered.sort((a2, b3) => {
|
|
448268
|
-
const aPath =
|
|
448269
|
-
const bPath =
|
|
448303
|
+
const aPath = join96(dir, a2);
|
|
448304
|
+
const bPath = join96(dir, b3);
|
|
448270
448305
|
let aIsDir = false;
|
|
448271
448306
|
let bIsDir = false;
|
|
448272
448307
|
try {
|
|
@@ -448286,14 +448321,14 @@ function scanMemoryFilesystem(memoryRoot) {
|
|
|
448286
448321
|
return a2.localeCompare(b3);
|
|
448287
448322
|
});
|
|
448288
448323
|
sorted.forEach((name, index) => {
|
|
448289
|
-
const fullPath =
|
|
448324
|
+
const fullPath = join96(dir, name);
|
|
448290
448325
|
let isDir = false;
|
|
448291
448326
|
try {
|
|
448292
448327
|
isDir = statSync25(fullPath).isDirectory();
|
|
448293
448328
|
} catch {
|
|
448294
448329
|
return;
|
|
448295
448330
|
}
|
|
448296
|
-
const relativePath =
|
|
448331
|
+
const relativePath = relative10(memoryRoot, fullPath).replace(/\\/g, "/");
|
|
448297
448332
|
const isLast = index === sorted.length - 1;
|
|
448298
448333
|
nodes.push({
|
|
448299
448334
|
name: isDir ? `${name}/` : name,
|
|
@@ -448404,7 +448439,7 @@ import {
|
|
|
448404
448439
|
stat as stat12,
|
|
448405
448440
|
writeFile as writeFile15
|
|
448406
448441
|
} from "node:fs/promises";
|
|
448407
|
-
import { join as
|
|
448442
|
+
import { join as join97 } from "node:path";
|
|
448408
448443
|
function buildReflectionSelectorPrompt(options) {
|
|
448409
448444
|
const lines = [
|
|
448410
448445
|
'You are selecting conversation transcripts for memory reflection. The transcript candidates path is available as the `$TRANSCRIPT_PATH` env var — read it via Bash (e.g. `wc -c "$TRANSCRIPT_PATH"`). Note: `$TRANSCRIPT_PATH` only expands in shell commands; Edit file_path is literal and does NOT expand env vars.',
|
|
@@ -448438,7 +448473,7 @@ async function collectParentMemoryFiles(memoryDir) {
|
|
|
448438
448473
|
return a2.name.localeCompare(b3.name);
|
|
448439
448474
|
});
|
|
448440
448475
|
for (const entry of sortedEntries) {
|
|
448441
|
-
const entryPath =
|
|
448476
|
+
const entryPath = join97(currentDir, entry.name);
|
|
448442
448477
|
const relativePath = relativeDir ? `${relativeDir}/${entry.name}` : entry.name;
|
|
448443
448478
|
if (entry.isDirectory()) {
|
|
448444
448479
|
await walk3(entryPath, relativePath);
|
|
@@ -448854,17 +448889,17 @@ async function writeState(paths, state2) {
|
|
|
448854
448889
|
}
|
|
448855
448890
|
function buildPayloadPath(rootDir, kind) {
|
|
448856
448891
|
const nonce = Math.random().toString(36).slice(2, 8);
|
|
448857
|
-
return
|
|
448892
|
+
return join97(rootDir, `payload-${kind}-${nonce}.json`);
|
|
448858
448893
|
}
|
|
448859
448894
|
function getAgentTranscriptRoot(agentId) {
|
|
448860
|
-
return
|
|
448895
|
+
return join97(getTranscriptRoot(), sanitizePathSegment2(agentId));
|
|
448861
448896
|
}
|
|
448862
448897
|
function getReflectionTranscriptPaths(agentId, conversationId) {
|
|
448863
|
-
const rootDir =
|
|
448898
|
+
const rootDir = join97(getTranscriptRoot(), sanitizePathSegment2(agentId), sanitizePathSegment2(conversationId));
|
|
448864
448899
|
return {
|
|
448865
448900
|
rootDir,
|
|
448866
|
-
transcriptPath:
|
|
448867
|
-
statePath:
|
|
448901
|
+
transcriptPath: join97(rootDir, "transcript.jsonl"),
|
|
448902
|
+
statePath: join97(rootDir, "state.json")
|
|
448868
448903
|
};
|
|
448869
448904
|
}
|
|
448870
448905
|
async function appendTranscriptDeltaJsonl(agentId, conversationId, lines) {
|
|
@@ -448954,7 +448989,7 @@ async function getTranscriptLastUpdatedAt(paths) {
|
|
|
448954
448989
|
}
|
|
448955
448990
|
}
|
|
448956
448991
|
async function ensureAgentPayloadRoot(agentId) {
|
|
448957
|
-
const root2 =
|
|
448992
|
+
const root2 = join97(getAgentTranscriptRoot(agentId), "multi-reflection-payloads");
|
|
448958
448993
|
await mkdir12(root2, { recursive: true });
|
|
448959
448994
|
return root2;
|
|
448960
448995
|
}
|
|
@@ -449518,7 +449553,7 @@ import { execFile as execFileCb3 } from "node:child_process";
|
|
|
449518
449553
|
import { randomUUID as randomUUID54 } from "node:crypto";
|
|
449519
449554
|
import { existsSync as existsSync62 } from "node:fs";
|
|
449520
449555
|
import { mkdir as mkdir13 } from "node:fs/promises";
|
|
449521
|
-
import { dirname as dirname37, isAbsolute as
|
|
449556
|
+
import { dirname as dirname37, isAbsolute as isAbsolute27, join as join98, resolve as resolve38 } from "node:path";
|
|
449522
449557
|
import { promisify as promisify18 } from "node:util";
|
|
449523
449558
|
async function runGit4(cwd2, args) {
|
|
449524
449559
|
try {
|
|
@@ -449555,7 +449590,7 @@ function normalizeGitPath(path41, cwd2) {
|
|
|
449555
449590
|
const trimmed = path41.trim();
|
|
449556
449591
|
if (!trimmed)
|
|
449557
449592
|
return trimmed;
|
|
449558
|
-
return
|
|
449593
|
+
return isAbsolute27(trimmed) ? trimmed : resolve38(cwd2, trimmed);
|
|
449559
449594
|
}
|
|
449560
449595
|
function buildReflectionWorktreeId(now2 = new Date) {
|
|
449561
449596
|
const timestamp = now2.toISOString().replace(/[^0-9]/g, "").slice(0, 14);
|
|
@@ -449576,11 +449611,11 @@ async function buildReflectionMergeMessage(parentMemoryDir, branchName) {
|
|
|
449576
449611
|
return `merge(reflection): ${summary}`;
|
|
449577
449612
|
}
|
|
449578
449613
|
async function createReflectionMemoryWorktree(options) {
|
|
449579
|
-
const parentMemoryDir =
|
|
449614
|
+
const parentMemoryDir = resolve38(options.parentMemoryDir);
|
|
449580
449615
|
const id = buildReflectionWorktreeId(options.now);
|
|
449581
|
-
const worktreeBaseDir =
|
|
449616
|
+
const worktreeBaseDir = join98(dirname37(parentMemoryDir), "memory-worktrees");
|
|
449582
449617
|
const label = options.label ?? "reflection";
|
|
449583
|
-
const worktreeDir =
|
|
449618
|
+
const worktreeDir = join98(worktreeBaseDir, `${label}-${id}`);
|
|
449584
449619
|
const branchName = `letta/${label}/${id}`;
|
|
449585
449620
|
await mkdir13(worktreeBaseDir, { recursive: true });
|
|
449586
449621
|
const { stdout: baseHeadOut } = await runGit4(parentMemoryDir, [
|
|
@@ -449645,7 +449680,7 @@ async function getStatusPorcelain(cwd2) {
|
|
|
449645
449680
|
return stdout.trim();
|
|
449646
449681
|
}
|
|
449647
449682
|
async function reflectionMemoryParentHasChanges(parentMemoryDir) {
|
|
449648
|
-
return (await getStatusPorcelain(
|
|
449683
|
+
return (await getStatusPorcelain(resolve38(parentMemoryDir))).length > 0;
|
|
449649
449684
|
}
|
|
449650
449685
|
async function getCommitCount(worktree) {
|
|
449651
449686
|
const { stdout } = await runGit4(worktree.worktreeDir, [
|
|
@@ -450481,7 +450516,7 @@ async function runExplicitReflectionIntegration(params) {
|
|
|
450481
450516
|
spawnBackgroundSubagentTask: spawnBackgroundSubagentTask2,
|
|
450482
450517
|
waitForBackgroundSubagentConversationId: waitForBackgroundSubagentConversationId2
|
|
450483
450518
|
} = await Promise.resolve().then(() => (init_task(), exports_task));
|
|
450484
|
-
return await new Promise((
|
|
450519
|
+
return await new Promise((resolve39) => {
|
|
450485
450520
|
try {
|
|
450486
450521
|
const { subagentId } = spawnBackgroundSubagentTask2({
|
|
450487
450522
|
subagentType: "general-purpose",
|
|
@@ -450500,7 +450535,7 @@ async function runExplicitReflectionIntegration(params) {
|
|
|
450500
450535
|
},
|
|
450501
450536
|
silentCompletion: true,
|
|
450502
450537
|
onComplete: (result3) => {
|
|
450503
|
-
|
|
450538
|
+
resolve39({
|
|
450504
450539
|
success: result3.success,
|
|
450505
450540
|
error: result3.success ? undefined : result3.error ?? "Reflection integration did not complete",
|
|
450506
450541
|
conversationId: result3.conversationId
|
|
@@ -450517,7 +450552,7 @@ async function runExplicitReflectionIntegration(params) {
|
|
|
450517
450552
|
debugWarn("memory", `Failed to title reflection integration conversation: ${error4 instanceof Error ? error4.message : String(error4)}`);
|
|
450518
450553
|
});
|
|
450519
450554
|
} catch (error4) {
|
|
450520
|
-
|
|
450555
|
+
resolve39({
|
|
450521
450556
|
success: false,
|
|
450522
450557
|
error: error4 instanceof Error ? error4.message : String(error4)
|
|
450523
450558
|
});
|
|
@@ -451280,7 +451315,7 @@ async function prepareProviderRetryInput(params) {
|
|
|
451280
451315
|
agentId: params.agentId,
|
|
451281
451316
|
conversationId: params.conversationId
|
|
451282
451317
|
});
|
|
451283
|
-
await new Promise((
|
|
451318
|
+
await new Promise((resolve39) => setTimeout(resolve39, delayMs));
|
|
451284
451319
|
if (params.turnLease.signal.aborted) {
|
|
451285
451320
|
throw new Error("Cancelled by user");
|
|
451286
451321
|
}
|
|
@@ -452244,7 +452279,7 @@ async function handleIncomingMessageInner(msg, socket, runtime, onStatusChange,
|
|
|
452244
452279
|
agentId,
|
|
452245
452280
|
conversationId
|
|
452246
452281
|
});
|
|
452247
|
-
await new Promise((
|
|
452282
|
+
await new Promise((resolve39) => setTimeout(resolve39, delayMs));
|
|
452248
452283
|
if (turnAbortSignal.aborted) {
|
|
452249
452284
|
throw new Error("Cancelled by user");
|
|
452250
452285
|
}
|
|
@@ -453055,14 +453090,14 @@ function localSources() {
|
|
|
453055
453090
|
cpu: cpus()[0]?.model,
|
|
453056
453091
|
memoryBytes: Math.min(totalmem(), limit4 || Number.POSITIVE_INFINITY),
|
|
453057
453092
|
read: (path41, signal) => readFile25(path41, { encoding: "utf8", signal }),
|
|
453058
|
-
run: (command, args, signal) => new Promise((
|
|
453093
|
+
run: (command, args, signal) => new Promise((resolve39, reject2) => {
|
|
453059
453094
|
execFile19(command, args, {
|
|
453060
453095
|
encoding: "utf8",
|
|
453061
453096
|
signal,
|
|
453062
453097
|
killSignal: "SIGKILL",
|
|
453063
453098
|
windowsHide: true,
|
|
453064
453099
|
maxBuffer: 512 * 1024
|
|
453065
|
-
}, (error4, stdout) => error4 ? reject2(error4) :
|
|
453100
|
+
}, (error4, stdout) => error4 ? reject2(error4) : resolve39(stdout));
|
|
453066
453101
|
})
|
|
453067
453102
|
};
|
|
453068
453103
|
}
|
|
@@ -453179,10 +453214,10 @@ async function collectMachineMetadata(sources = localSources(), timeoutMs = COLL
|
|
|
453179
453214
|
try {
|
|
453180
453215
|
await Promise.race([
|
|
453181
453216
|
probe2().catch(() => {}),
|
|
453182
|
-
new Promise((
|
|
453217
|
+
new Promise((resolve39) => {
|
|
453183
453218
|
timer = setTimeout(() => {
|
|
453184
453219
|
controller.abort();
|
|
453185
|
-
|
|
453220
|
+
resolve39();
|
|
453186
453221
|
}, timeoutMs);
|
|
453187
453222
|
})
|
|
453188
453223
|
]);
|
|
@@ -453316,7 +453351,7 @@ async function registerWithCloud(opts, fetchImpl = fetch) {
|
|
|
453316
453351
|
async function registerWithCloudRetry(opts, callbacks) {
|
|
453317
453352
|
const startTime = Date.now();
|
|
453318
453353
|
const maxDurationMs = callbacks?.maxDurationMs ?? REGISTER_MAX_DURATION_MS;
|
|
453319
|
-
const sleep12 = callbacks?.sleep ?? ((delayMs) => new Promise((
|
|
453354
|
+
const sleep12 = callbacks?.sleep ?? ((delayMs) => new Promise((resolve39) => setTimeout(resolve39, delayMs)));
|
|
453320
453355
|
let attempt2 = 0;
|
|
453321
453356
|
for (;; ) {
|
|
453322
453357
|
try {
|
|
@@ -453758,7 +453793,7 @@ var init_connection_state_sync = __esm(() => {
|
|
|
453758
453793
|
});
|
|
453759
453794
|
|
|
453760
453795
|
// src/websocket/listener/control-inputs.ts
|
|
453761
|
-
import { realpath as
|
|
453796
|
+
import { realpath as realpath7, stat as stat13 } from "node:fs/promises";
|
|
453762
453797
|
import path41 from "node:path";
|
|
453763
453798
|
function trackListenerError(errorType, error4, context3) {
|
|
453764
453799
|
trackBoundaryError({
|
|
@@ -454027,7 +454062,7 @@ async function handleAbortMessageInput(listener, params, deps = {}) {
|
|
|
454027
454062
|
while (cancellation.lease && scopedRuntime.turnLifecycle.isCurrent(cancellation.lease)) {
|
|
454028
454063
|
if (Date.now() >= deadline)
|
|
454029
454064
|
throw new Error("The listener turn did not stop");
|
|
454030
|
-
await new Promise((
|
|
454065
|
+
await new Promise((resolve39) => setTimeout(resolve39, 20));
|
|
454031
454066
|
}
|
|
454032
454067
|
} else {
|
|
454033
454068
|
settlementPromise.catch(() => {
|
|
@@ -454049,7 +454084,7 @@ async function handleCwdChange(msg, socket, runtime) {
|
|
|
454049
454084
|
throw new Error("Working directory cannot be empty");
|
|
454050
454085
|
}
|
|
454051
454086
|
const resolvedPath = path41.isAbsolute(requestedPath) ? requestedPath : path41.resolve(currentWorkingDirectory, requestedPath);
|
|
454052
|
-
const normalizedPath = await
|
|
454087
|
+
const normalizedPath = await realpath7(resolvedPath);
|
|
454053
454088
|
const stats = await stat13(normalizedPath);
|
|
454054
454089
|
if (!stats.isDirectory()) {
|
|
454055
454090
|
throw new Error(`Not a directory: ${normalizedPath}`);
|
|
@@ -454170,7 +454205,7 @@ async function runGrepInFiles(args) {
|
|
|
454170
454205
|
});
|
|
454171
454206
|
}
|
|
454172
454207
|
function runRipgrep2(rgArgs) {
|
|
454173
|
-
return new Promise((
|
|
454208
|
+
return new Promise((resolve39, reject2) => {
|
|
454174
454209
|
const child = execFile20(rgPath, rgArgs, {
|
|
454175
454210
|
maxBuffer: 50 * 1024 * 1024,
|
|
454176
454211
|
windowsHide: true
|
|
@@ -454179,7 +454214,7 @@ function runRipgrep2(rgArgs) {
|
|
|
454179
454214
|
reject2(error4);
|
|
454180
454215
|
return;
|
|
454181
454216
|
}
|
|
454182
|
-
|
|
454217
|
+
resolve39(stdout);
|
|
454183
454218
|
});
|
|
454184
454219
|
const timer = setTimeout(() => {
|
|
454185
454220
|
child.kill("SIGTERM");
|
|
@@ -455545,8 +455580,8 @@ function normalizeAbsPath(value) {
|
|
|
455545
455580
|
return path44.resolve(value);
|
|
455546
455581
|
}
|
|
455547
455582
|
function isWithinOrEqual(parent, child) {
|
|
455548
|
-
const
|
|
455549
|
-
return
|
|
455583
|
+
const relative12 = path44.relative(parent, child);
|
|
455584
|
+
return relative12 === "" || !relative12.startsWith("..") && !path44.isAbsolute(relative12);
|
|
455550
455585
|
}
|
|
455551
455586
|
function getHomeDirectory() {
|
|
455552
455587
|
return normalizeAbsPath(process.env.HOME || homedir32());
|
|
@@ -455559,10 +455594,10 @@ function getProtectedHomeSegment(absPath) {
|
|
|
455559
455594
|
const target = normalizeAbsPath(absPath);
|
|
455560
455595
|
if (!isWithinOrEqual(home, target))
|
|
455561
455596
|
return null;
|
|
455562
|
-
const
|
|
455563
|
-
if (!
|
|
455597
|
+
const relative12 = path44.relative(home, target);
|
|
455598
|
+
if (!relative12)
|
|
455564
455599
|
return null;
|
|
455565
|
-
const [firstSegment] =
|
|
455600
|
+
const [firstSegment] = relative12.split(path44.sep);
|
|
455566
455601
|
const normalized = firstSegment?.toLowerCase();
|
|
455567
455602
|
return normalized && PROTECTED_HOME_NAMES.has(normalized) ? normalized : null;
|
|
455568
455603
|
}
|
|
@@ -456680,9 +456715,9 @@ __export(exports_custom, {
|
|
|
456680
456715
|
});
|
|
456681
456716
|
import { existsSync as existsSync63 } from "node:fs";
|
|
456682
456717
|
import { readdir as readdir11, readFile as readFile27 } from "node:fs/promises";
|
|
456683
|
-
import { basename as basename29, dirname as dirname38, join as
|
|
456718
|
+
import { basename as basename29, dirname as dirname38, join as join99 } from "node:path";
|
|
456684
456719
|
function getGlobalCommandsDir() {
|
|
456685
|
-
return
|
|
456720
|
+
return join99(resolveGlobalConfigDir(), "commands");
|
|
456686
456721
|
}
|
|
456687
456722
|
async function getCustomCommands() {
|
|
456688
456723
|
if (cachedCommands !== null) {
|
|
@@ -456694,7 +456729,7 @@ async function getCustomCommands() {
|
|
|
456694
456729
|
function refreshCustomCommands() {
|
|
456695
456730
|
cachedCommands = null;
|
|
456696
456731
|
}
|
|
456697
|
-
async function discoverCustomCommands(projectPath =
|
|
456732
|
+
async function discoverCustomCommands(projectPath = join99(process.cwd(), COMMANDS_DIR)) {
|
|
456698
456733
|
const commandsById = new Map;
|
|
456699
456734
|
const userCommands = await discoverFromDirectory(getGlobalCommandsDir(), "user");
|
|
456700
456735
|
for (const cmd of userCommands) {
|
|
@@ -456726,7 +456761,7 @@ async function findCommandFiles(currentPath, rootPath, commands, source) {
|
|
|
456726
456761
|
try {
|
|
456727
456762
|
const entries2 = await readdir11(currentPath, { withFileTypes: true });
|
|
456728
456763
|
for (const entry of entries2) {
|
|
456729
|
-
const fullPath =
|
|
456764
|
+
const fullPath = join99(currentPath, entry.name);
|
|
456730
456765
|
if (entry.isDirectory()) {
|
|
456731
456766
|
await findCommandFiles(fullPath, rootPath, commands, source);
|
|
456732
456767
|
} else if (entry.isFile() && entry.name.endsWith(".md")) {
|
|
@@ -458122,7 +458157,7 @@ var init_app_server_info = __esm(() => {
|
|
|
458122
458157
|
});
|
|
458123
458158
|
|
|
458124
458159
|
// src/websocket/listener/commands/boot-working-directory.ts
|
|
458125
|
-
import { realpath as
|
|
458160
|
+
import { realpath as realpath8, stat as stat14 } from "node:fs/promises";
|
|
458126
458161
|
import path45 from "node:path";
|
|
458127
458162
|
async function resolveDirectory(requestedPath, currentBootWorkingDirectory) {
|
|
458128
458163
|
const trimmedPath = requestedPath.trim();
|
|
@@ -458130,7 +458165,7 @@ async function resolveDirectory(requestedPath, currentBootWorkingDirectory) {
|
|
|
458130
458165
|
throw new Error("Working directory cannot be empty");
|
|
458131
458166
|
}
|
|
458132
458167
|
const resolvedPath = path45.isAbsolute(trimmedPath) ? trimmedPath : path45.resolve(currentBootWorkingDirectory, trimmedPath);
|
|
458133
|
-
const normalizedPath = await
|
|
458168
|
+
const normalizedPath = await realpath8(resolvedPath);
|
|
458134
458169
|
const stats = await stat14(normalizedPath);
|
|
458135
458170
|
if (!stats.isDirectory()) {
|
|
458136
458171
|
throw new Error(`Not a directory: ${normalizedPath}`);
|
|
@@ -459437,8 +459472,8 @@ async function awaitMemoryPushBounded(commandName, agentId, memoryRoot) {
|
|
|
459437
459472
|
}
|
|
459438
459473
|
};
|
|
459439
459474
|
let timer;
|
|
459440
|
-
const capPromise = new Promise((
|
|
459441
|
-
timer = setTimeout(() =>
|
|
459475
|
+
const capPromise = new Promise((resolve39) => {
|
|
459476
|
+
timer = setTimeout(() => resolve39("timed_out"), MEMORY_PUSH_AWAIT_CAP_MS);
|
|
459442
459477
|
});
|
|
459443
459478
|
try {
|
|
459444
459479
|
const result3 = await Promise.race([syncPromise, capPromise]);
|
|
@@ -459470,9 +459505,9 @@ async function handleListMemoryCommand(parsed, socket, safeSocketSend, overrides
|
|
|
459470
459505
|
const { scanMemoryFilesystem: scanMemoryFilesystem2, getFileNodes: getFileNodes2, readFileContent: readFileContent2 } = await Promise.resolve().then(() => (init_memory_scanner(), exports_memory_scanner));
|
|
459471
459506
|
const { parseFrontmatter: parseFrontmatter2 } = await Promise.resolve().then(() => exports_frontmatter);
|
|
459472
459507
|
const { existsSync: existsSync64, statSync: statSync26 } = await import("node:fs");
|
|
459473
|
-
const { join:
|
|
459508
|
+
const { join: join100, posix: posix4 } = await import("node:path");
|
|
459474
459509
|
const memoryRoot = getMemoryFilesystemRoot2(parsed.agent_id);
|
|
459475
|
-
let memfsInitialized = existsSync64(
|
|
459510
|
+
let memfsInitialized = existsSync64(join100(memoryRoot, ".git"));
|
|
459476
459511
|
const memfsEnabled = memfsInitialized ? true : await isMemfsEnabledOnServer2(parsed.agent_id);
|
|
459477
459512
|
if (!memfsEnabled) {
|
|
459478
459513
|
safeSocketSend(socket, {
|
|
@@ -459490,7 +459525,7 @@ async function handleListMemoryCommand(parsed, socket, safeSocketSend, overrides
|
|
|
459490
459525
|
await ensureLocalMemfsCheckout2(parsed.agent_id, {
|
|
459491
459526
|
pullOnExistingRepo: true
|
|
459492
459527
|
});
|
|
459493
|
-
memfsInitialized = existsSync64(
|
|
459528
|
+
memfsInitialized = existsSync64(join100(memoryRoot, ".git"));
|
|
459494
459529
|
if (!memfsInitialized) {
|
|
459495
459530
|
throw new Error("MemFS is enabled, but the local memory checkout could not be initialized.");
|
|
459496
459531
|
}
|
|
@@ -459791,33 +459826,33 @@ function handleMemoryProtocolCommand(parsed, context3) {
|
|
|
459791
459826
|
} = await Promise.resolve().then(() => (init_memory_filesystem2(), exports_memory_filesystem));
|
|
459792
459827
|
const { readFile: readFile28 } = await import("node:fs/promises");
|
|
459793
459828
|
const { existsSync: existsSync64 } = await import("node:fs");
|
|
459794
|
-
const { isAbsolute:
|
|
459795
|
-
if (
|
|
459829
|
+
const { isAbsolute: isAbsolute28, join: join100, normalize: normalize5, relative: relative12, sep: sep9 } = await import("node:path");
|
|
459830
|
+
if (isAbsolute28(parsed.path) || parsed.path.length === 0) {
|
|
459796
459831
|
sendFailure("path must be a non-empty relative path");
|
|
459797
459832
|
return;
|
|
459798
459833
|
}
|
|
459799
459834
|
const memoryRoot = getScopedMemoryFilesystemRoot2(parsed.agent_id);
|
|
459800
|
-
const absolutePath = normalize5(
|
|
459801
|
-
const rel =
|
|
459802
|
-
if (rel.startsWith("..") || rel === "" ||
|
|
459835
|
+
const absolutePath = normalize5(join100(memoryRoot, parsed.path));
|
|
459836
|
+
const rel = relative12(memoryRoot, absolutePath);
|
|
459837
|
+
if (rel.startsWith("..") || rel === "" || isAbsolute28(rel) || rel.split(sep9).includes("..")) {
|
|
459803
459838
|
sendFailure("path must resolve inside the memory root");
|
|
459804
459839
|
return;
|
|
459805
459840
|
}
|
|
459806
|
-
if (!existsSync64(
|
|
459841
|
+
if (!existsSync64(join100(memoryRoot, ".git"))) {
|
|
459807
459842
|
const enabled = await isMemfsEnabledOnServer2(parsed.agent_id);
|
|
459808
459843
|
if (!enabled) {
|
|
459809
459844
|
sendFailure("memfs is not enabled for this agent");
|
|
459810
459845
|
return;
|
|
459811
459846
|
}
|
|
459812
459847
|
await ensureLocalMemfsCheckout2(parsed.agent_id);
|
|
459813
|
-
if (!existsSync64(
|
|
459848
|
+
if (!existsSync64(join100(memoryRoot, ".git"))) {
|
|
459814
459849
|
sendFailure("failed to initialize local memory checkout");
|
|
459815
459850
|
return;
|
|
459816
459851
|
}
|
|
459817
459852
|
}
|
|
459818
459853
|
const buffer = await readFile28(absolutePath);
|
|
459819
459854
|
const content = encoding === "base64" ? buffer.toString("base64") : buffer.toString("utf-8");
|
|
459820
|
-
const pathspec = rel.split(
|
|
459855
|
+
const pathspec = rel.split(sep9).join("/");
|
|
459821
459856
|
safeSocketSend(socket, {
|
|
459822
459857
|
type: "read_memory_file_response",
|
|
459823
459858
|
request_id: parsed.request_id,
|
|
@@ -459857,26 +459892,26 @@ function handleMemoryProtocolCommand(parsed, context3) {
|
|
|
459857
459892
|
const { commitMemoryWrite: commitMemoryWrite2 } = await Promise.resolve().then(() => (init_memory_git(), exports_memory_git));
|
|
459858
459893
|
const { writeFile: writeFile17, mkdir: mkdir15 } = await import("node:fs/promises");
|
|
459859
459894
|
const { existsSync: existsSync64 } = await import("node:fs");
|
|
459860
|
-
const { dirname: dirname39, isAbsolute:
|
|
459861
|
-
if (
|
|
459895
|
+
const { dirname: dirname39, isAbsolute: isAbsolute28, join: join100, normalize: normalize5, relative: relative12, sep: sep9 } = await import("node:path");
|
|
459896
|
+
if (isAbsolute28(parsed.path) || parsed.path.length === 0) {
|
|
459862
459897
|
sendFailure("write_memory_file: path must be a non-empty relative path");
|
|
459863
459898
|
return;
|
|
459864
459899
|
}
|
|
459865
459900
|
const memoryRoot = getScopedMemoryFilesystemRoot2(parsed.agent_id);
|
|
459866
|
-
const absolutePath = normalize5(
|
|
459867
|
-
const rel =
|
|
459868
|
-
if (rel.startsWith("..") || rel === "" ||
|
|
459901
|
+
const absolutePath = normalize5(join100(memoryRoot, parsed.path));
|
|
459902
|
+
const rel = relative12(memoryRoot, absolutePath);
|
|
459903
|
+
if (rel.startsWith("..") || rel === "" || isAbsolute28(rel) || rel.split(sep9).includes("..")) {
|
|
459869
459904
|
sendFailure("write_memory_file: path must resolve inside the memory root");
|
|
459870
459905
|
return;
|
|
459871
459906
|
}
|
|
459872
|
-
if (!existsSync64(
|
|
459907
|
+
if (!existsSync64(join100(memoryRoot, ".git"))) {
|
|
459873
459908
|
const enabled = await isMemfsEnabledOnServer2(parsed.agent_id);
|
|
459874
459909
|
if (!enabled) {
|
|
459875
459910
|
sendFailure("write_memory_file: memfs is not enabled for this agent");
|
|
459876
459911
|
return;
|
|
459877
459912
|
}
|
|
459878
459913
|
await ensureLocalMemfsCheckout2(parsed.agent_id);
|
|
459879
|
-
if (!existsSync64(
|
|
459914
|
+
if (!existsSync64(join100(memoryRoot, ".git"))) {
|
|
459880
459915
|
sendFailure("write_memory_file: failed to initialize local memory checkout");
|
|
459881
459916
|
return;
|
|
459882
459917
|
}
|
|
@@ -459894,7 +459929,7 @@ function handleMemoryProtocolCommand(parsed, context3) {
|
|
|
459894
459929
|
agentName = agent.name.trim();
|
|
459895
459930
|
}
|
|
459896
459931
|
} catch {}
|
|
459897
|
-
const pathspec = rel.split(
|
|
459932
|
+
const pathspec = rel.split(sep9).join("/");
|
|
459898
459933
|
const reason = parsed.commit_message?.trim() || `Update memory file ${pathspec}`;
|
|
459899
459934
|
const commitResult = await commitMemoryWrite2({
|
|
459900
459935
|
memoryDir: memoryRoot,
|
|
@@ -459955,31 +459990,31 @@ function handleMemoryProtocolCommand(parsed, context3) {
|
|
|
459955
459990
|
const { commitMemoryWrite: commitMemoryWrite2 } = await Promise.resolve().then(() => (init_memory_git(), exports_memory_git));
|
|
459956
459991
|
const { unlink: unlink3 } = await import("node:fs/promises");
|
|
459957
459992
|
const { existsSync: existsSync64 } = await import("node:fs");
|
|
459958
|
-
const { isAbsolute:
|
|
459959
|
-
if (
|
|
459993
|
+
const { isAbsolute: isAbsolute28, join: join100, normalize: normalize5, relative: relative12, sep: sep9 } = await import("node:path");
|
|
459994
|
+
if (isAbsolute28(parsed.path) || parsed.path.length === 0) {
|
|
459960
459995
|
sendFailure("delete_memory_file: path must be a non-empty relative path");
|
|
459961
459996
|
return;
|
|
459962
459997
|
}
|
|
459963
459998
|
const memoryRoot = getScopedMemoryFilesystemRoot2(parsed.agent_id);
|
|
459964
|
-
const absolutePath = normalize5(
|
|
459965
|
-
const rel =
|
|
459966
|
-
if (rel.startsWith("..") || rel === "" ||
|
|
459999
|
+
const absolutePath = normalize5(join100(memoryRoot, parsed.path));
|
|
460000
|
+
const rel = relative12(memoryRoot, absolutePath);
|
|
460001
|
+
if (rel.startsWith("..") || rel === "" || isAbsolute28(rel) || rel.split(sep9).includes("..")) {
|
|
459967
460002
|
sendFailure("delete_memory_file: path must resolve inside the memory root");
|
|
459968
460003
|
return;
|
|
459969
460004
|
}
|
|
459970
|
-
if (!existsSync64(
|
|
460005
|
+
if (!existsSync64(join100(memoryRoot, ".git"))) {
|
|
459971
460006
|
const enabled = await isMemfsEnabledOnServer2(parsed.agent_id);
|
|
459972
460007
|
if (!enabled) {
|
|
459973
460008
|
sendFailure("delete_memory_file: memfs is not enabled for this agent");
|
|
459974
460009
|
return;
|
|
459975
460010
|
}
|
|
459976
460011
|
await ensureLocalMemfsCheckout2(parsed.agent_id);
|
|
459977
|
-
if (!existsSync64(
|
|
460012
|
+
if (!existsSync64(join100(memoryRoot, ".git"))) {
|
|
459978
460013
|
sendFailure("delete_memory_file: failed to initialize local memory checkout");
|
|
459979
460014
|
return;
|
|
459980
460015
|
}
|
|
459981
460016
|
}
|
|
459982
|
-
const pathspec = rel.split(
|
|
460017
|
+
const pathspec = rel.split(sep9).join("/");
|
|
459983
460018
|
const removeIfPresent = async () => {
|
|
459984
460019
|
if (!existsSync64(absolutePath))
|
|
459985
460020
|
return false;
|
|
@@ -460108,10 +460143,10 @@ __export(exports_remote_model_catalog, {
|
|
|
460108
460143
|
__testResetRemoteModelCatalog: () => __testResetRemoteModelCatalog
|
|
460109
460144
|
});
|
|
460110
460145
|
import { existsSync as existsSync64, mkdirSync as mkdirSync50, readFileSync as readFileSync51, writeFileSync as writeFileSync43 } from "node:fs";
|
|
460111
|
-
import { dirname as dirname39, join as
|
|
460146
|
+
import { dirname as dirname39, join as join100 } from "node:path";
|
|
460112
460147
|
function catalogCachePath() {
|
|
460113
|
-
const dir = process.env.LETTA_MODEL_CATALOG_CACHE_DIR ||
|
|
460114
|
-
return
|
|
460148
|
+
const dir = process.env.LETTA_MODEL_CATALOG_CACHE_DIR || join100(resolveGlobalConfigDir(), "cache");
|
|
460149
|
+
return join100(dir, "model-catalog.json");
|
|
460115
460150
|
}
|
|
460116
460151
|
function normalizeCatalogSource(source) {
|
|
460117
460152
|
try {
|
|
@@ -461530,7 +461565,7 @@ async function handleSkillCommand(parsed, socket, safeSocketSend) {
|
|
|
461530
461565
|
symlinkSync: symlinkSync2,
|
|
461531
461566
|
unlinkSync: unlinkSync18
|
|
461532
461567
|
} = await import("node:fs");
|
|
461533
|
-
const { basename: basename30, join:
|
|
461568
|
+
const { basename: basename30, join: join101 } = await import("node:path");
|
|
461534
461569
|
const globalSkillsDir = getGlobalSkillsDir();
|
|
461535
461570
|
if (parsed.type === "skill_enable") {
|
|
461536
461571
|
try {
|
|
@@ -461543,7 +461578,7 @@ async function handleSkillCommand(parsed, socket, safeSocketSend) {
|
|
|
461543
461578
|
}, "listener_skill_send_failed", "listener_skill_command");
|
|
461544
461579
|
return true;
|
|
461545
461580
|
}
|
|
461546
|
-
const skillMdPath =
|
|
461581
|
+
const skillMdPath = join101(parsed.skill_path, "SKILL.md");
|
|
461547
461582
|
if (!existsSync65(skillMdPath)) {
|
|
461548
461583
|
safeSocketSend(socket, {
|
|
461549
461584
|
type: "skill_enable_response",
|
|
@@ -461554,7 +461589,7 @@ async function handleSkillCommand(parsed, socket, safeSocketSend) {
|
|
|
461554
461589
|
return true;
|
|
461555
461590
|
}
|
|
461556
461591
|
const linkName = basename30(parsed.skill_path);
|
|
461557
|
-
const linkPath =
|
|
461592
|
+
const linkPath = join101(globalSkillsDir, linkName);
|
|
461558
461593
|
mkdirSync51(globalSkillsDir, { recursive: true });
|
|
461559
461594
|
if (existsSync65(linkPath)) {
|
|
461560
461595
|
const stat15 = lstatSync4(linkPath);
|
|
@@ -461597,7 +461632,7 @@ async function handleSkillCommand(parsed, socket, safeSocketSend) {
|
|
|
461597
461632
|
}
|
|
461598
461633
|
if (parsed.type === "skill_disable") {
|
|
461599
461634
|
try {
|
|
461600
|
-
const linkPath =
|
|
461635
|
+
const linkPath = join101(globalSkillsDir, parsed.name);
|
|
461601
461636
|
if (!existsSync65(linkPath)) {
|
|
461602
461637
|
safeSocketSend(socket, {
|
|
461603
461638
|
type: "skill_disable_response",
|
|
@@ -462369,7 +462404,7 @@ async function waitForPairedSocketAcceptance(socket, identity3) {
|
|
|
462369
462404
|
return { status: "closed" };
|
|
462370
462405
|
}
|
|
462371
462406
|
const timeoutMs = getStreamOpenTimeoutMs();
|
|
462372
|
-
return await new Promise((
|
|
462407
|
+
return await new Promise((resolve39) => {
|
|
462373
462408
|
let settled = false;
|
|
462374
462409
|
const timeout = setTimeout(() => settle3({ status: "timed_out", timeoutMs }), timeoutMs);
|
|
462375
462410
|
timeout.unref?.();
|
|
@@ -462384,7 +462419,7 @@ async function waitForPairedSocketAcceptance(socket, identity3) {
|
|
|
462384
462419
|
return;
|
|
462385
462420
|
settled = true;
|
|
462386
462421
|
cleanup();
|
|
462387
|
-
|
|
462422
|
+
resolve39(result3);
|
|
462388
462423
|
}
|
|
462389
462424
|
function handleFailure() {
|
|
462390
462425
|
settle3({ status: "closed" });
|
|
@@ -462412,7 +462447,7 @@ async function waitForStreamSocketOpen(streamSocket) {
|
|
|
462412
462447
|
return { status: "closed" };
|
|
462413
462448
|
}
|
|
462414
462449
|
const timeoutMs = getStreamOpenTimeoutMs();
|
|
462415
|
-
return await new Promise((
|
|
462450
|
+
return await new Promise((resolve39) => {
|
|
462416
462451
|
let timeout = null;
|
|
462417
462452
|
let settled = false;
|
|
462418
462453
|
function cleanup() {
|
|
@@ -462430,7 +462465,7 @@ async function waitForStreamSocketOpen(streamSocket) {
|
|
|
462430
462465
|
}
|
|
462431
462466
|
settled = true;
|
|
462432
462467
|
cleanup();
|
|
462433
|
-
|
|
462468
|
+
resolve39(result3);
|
|
462434
462469
|
}
|
|
462435
462470
|
function handleOpen() {
|
|
462436
462471
|
settle3({ status: "open", transport: streamSocket });
|
|
@@ -463587,7 +463622,7 @@ var init_message_router = __esm(() => {
|
|
|
463587
463622
|
});
|
|
463588
463623
|
|
|
463589
463624
|
// src/websocket/listener/process-services.ts
|
|
463590
|
-
import { join as
|
|
463625
|
+
import { join as join101 } from "node:path";
|
|
463591
463626
|
function installProcessEventRouting(params) {
|
|
463592
463627
|
const { runtime, processTransport, opts, processQueuedTurn } = params;
|
|
463593
463628
|
runtime._unsubscribeSubagentState?.();
|
|
@@ -463677,7 +463712,7 @@ function installProcessEventRouting(params) {
|
|
|
463677
463712
|
scheduleQueuePump(targetRuntime, processTransport, opts, processQueuedTurn);
|
|
463678
463713
|
});
|
|
463679
463714
|
runtime._stopDiskSpaceWatch?.();
|
|
463680
|
-
runtime._stopDiskSpaceWatch = watchSandboxDiskSpace(getCurrentWorkingDirectory, (text3) => deliverSandboxDiskAlert(runtime, text3), { reserveDirectory:
|
|
463715
|
+
runtime._stopDiskSpaceWatch = watchSandboxDiskSpace(getCurrentWorkingDirectory, (text3) => deliverSandboxDiskAlert(runtime, text3), { reserveDirectory: join101(resolveGlobalConfigDir(), "state") });
|
|
463681
463716
|
}
|
|
463682
463717
|
function deliverSandboxDiskAlert(runtime, text3) {
|
|
463683
463718
|
const target = getMostRecentlyActiveConversation(runtime);
|
|
@@ -464751,11 +464786,11 @@ async function replaySyncStateForRuntime(listenerRuntime, socket, scope, opts) {
|
|
|
464751
464786
|
if (syncScopedRuntime.recoveredApprovalState && (syncScopedRuntime.recoveredApprovalState.autoDecisions?.length ?? 0) > 0) {
|
|
464752
464787
|
let signalLeaseReady;
|
|
464753
464788
|
let releaseLeaseBarrier;
|
|
464754
|
-
const leaseReady = new Promise((
|
|
464755
|
-
signalLeaseReady =
|
|
464789
|
+
const leaseReady = new Promise((resolve39) => {
|
|
464790
|
+
signalLeaseReady = resolve39;
|
|
464756
464791
|
});
|
|
464757
|
-
const leaseBarrier = new Promise((
|
|
464758
|
-
releaseLeaseBarrier =
|
|
464792
|
+
const leaseBarrier = new Promise((resolve39) => {
|
|
464793
|
+
releaseLeaseBarrier = resolve39;
|
|
464759
464794
|
});
|
|
464760
464795
|
const recovery = startRecoveredApprovalContinuation(syncScopedRuntime, getOrCreateProcessTransport(listenerRuntime), opts?.processIncomingMessage ?? handleIncomingMessage, {
|
|
464761
464796
|
onStatusChange: opts?.onStatusChange,
|
|
@@ -465159,8 +465194,8 @@ async function connectWithRetry(runtime, opts, attempt2 = 0, startTime = Date.no
|
|
|
465159
465194
|
}
|
|
465160
465195
|
const delay7 = Math.min(INITIAL_RETRY_DELAY_MS2 * 2 ** (attempt2 - 1), MAX_RETRY_DELAY_MS);
|
|
465161
465196
|
opts.onRetrying?.(attempt2, MAX_RETRY_ATTEMPTS, delay7, opts.connectionId);
|
|
465162
|
-
await new Promise((
|
|
465163
|
-
runtime.reconnectTimeout = setTimeout(
|
|
465197
|
+
await new Promise((resolve39) => {
|
|
465198
|
+
runtime.reconnectTimeout = setTimeout(resolve39, delay7);
|
|
465164
465199
|
});
|
|
465165
465200
|
runtime.reconnectTimeout = null;
|
|
465166
465201
|
if (runtime !== getActiveRuntime() || runtime.intentionallyClosed) {
|
|
@@ -465521,7 +465556,7 @@ async function runTurnViaListenerRuntime(params) {
|
|
|
465521
465556
|
}
|
|
465522
465557
|
};
|
|
465523
465558
|
const processQueuedTurn = createConnectionTurnProcessor(listener);
|
|
465524
|
-
return await new Promise((
|
|
465559
|
+
return await new Promise((resolve39) => {
|
|
465525
465560
|
let text3 = "";
|
|
465526
465561
|
let reasoning = "";
|
|
465527
465562
|
let usage = {
|
|
@@ -465548,7 +465583,7 @@ async function runTurnViaListenerRuntime(params) {
|
|
|
465548
465583
|
observers.delete(observer);
|
|
465549
465584
|
unregisterTurnObserver();
|
|
465550
465585
|
toolTracker?.dispose();
|
|
465551
|
-
|
|
465586
|
+
resolve39({ text: text3, reasoning, usage, error: error4 });
|
|
465552
465587
|
};
|
|
465553
465588
|
const observer = (message2) => {
|
|
465554
465589
|
if (message2.type === "runtime_stopped") {
|
|
@@ -466688,14 +466723,14 @@ async function startAppServer(options = {}) {
|
|
|
466688
466723
|
clearInterval(heartbeatInterval);
|
|
466689
466724
|
});
|
|
466690
466725
|
try {
|
|
466691
|
-
await new Promise((
|
|
466726
|
+
await new Promise((resolve39, reject2) => {
|
|
466692
466727
|
const onError = (error4) => {
|
|
466693
466728
|
server2.off("listening", onListening);
|
|
466694
466729
|
reject2(error4);
|
|
466695
466730
|
};
|
|
466696
466731
|
const onListening = () => {
|
|
466697
466732
|
server2.off("error", onError);
|
|
466698
|
-
|
|
466733
|
+
resolve39();
|
|
466699
466734
|
};
|
|
466700
466735
|
server2.once("error", onError);
|
|
466701
466736
|
server2.once("listening", onListening);
|
|
@@ -466716,7 +466751,7 @@ async function startAppServer(options = {}) {
|
|
|
466716
466751
|
setActiveRuntime(runtime);
|
|
466717
466752
|
} else if (getActiveRuntime() !== runtime) {
|
|
466718
466753
|
clearInterval(heartbeatInterval);
|
|
466719
|
-
await new Promise((
|
|
466754
|
+
await new Promise((resolve39) => server2.close(() => resolve39()));
|
|
466720
466755
|
throw new Error("Shared app-server runtime must be the active listener runtime");
|
|
466721
466756
|
}
|
|
466722
466757
|
if (ownsRuntime) {
|
|
@@ -466744,16 +466779,16 @@ async function startAppServer(options = {}) {
|
|
|
466744
466779
|
stopRuntime(runtime, true);
|
|
466745
466780
|
setActiveRuntime(null);
|
|
466746
466781
|
}
|
|
466747
|
-
await new Promise((
|
|
466782
|
+
await new Promise((resolve39, reject2) => {
|
|
466748
466783
|
wss.close();
|
|
466749
|
-
const timeout = setTimeout(
|
|
466784
|
+
const timeout = setTimeout(resolve39, 1000);
|
|
466750
466785
|
server2.close((serverError) => {
|
|
466751
466786
|
clearTimeout(timeout);
|
|
466752
466787
|
if (serverError) {
|
|
466753
466788
|
reject2(serverError);
|
|
466754
466789
|
return;
|
|
466755
466790
|
}
|
|
466756
|
-
|
|
466791
|
+
resolve39();
|
|
466757
466792
|
});
|
|
466758
466793
|
});
|
|
466759
466794
|
}
|
|
@@ -466801,7 +466836,7 @@ Examples:
|
|
|
466801
466836
|
letta server --listen ws://127.0.0.1:4500 --openai-api`);
|
|
466802
466837
|
}
|
|
466803
466838
|
async function waitForShutdown(close) {
|
|
466804
|
-
return await new Promise((
|
|
466839
|
+
return await new Promise((resolve39) => {
|
|
466805
466840
|
let shuttingDown = false;
|
|
466806
466841
|
const shutdown = (signal) => {
|
|
466807
466842
|
if (shuttingDown)
|
|
@@ -466810,10 +466845,10 @@ async function waitForShutdown(close) {
|
|
|
466810
466845
|
close().then(() => {
|
|
466811
466846
|
console.log(`
|
|
466812
466847
|
Stopped App Server (${signal}).`);
|
|
466813
|
-
|
|
466848
|
+
resolve39(0);
|
|
466814
466849
|
}).catch((error4) => {
|
|
466815
466850
|
console.error(error4 instanceof Error ? `Error: ${error4.message}` : String(error4));
|
|
466816
|
-
|
|
466851
|
+
resolve39(1);
|
|
466817
466852
|
});
|
|
466818
466853
|
};
|
|
466819
466854
|
process.once("SIGINT", shutdown);
|
|
@@ -467199,7 +467234,7 @@ import {
|
|
|
467199
467234
|
readdirSync as readdirSync26,
|
|
467200
467235
|
unlinkSync as unlinkSync18
|
|
467201
467236
|
} from "node:fs";
|
|
467202
|
-
import { join as
|
|
467237
|
+
import { join as join102 } from "node:path";
|
|
467203
467238
|
function formatTimestamp2() {
|
|
467204
467239
|
const now2 = new Date;
|
|
467205
467240
|
const h3 = String(now2.getHours()).padStart(2, "0");
|
|
@@ -467220,7 +467255,7 @@ function pruneOldLogs(dir, maxFiles) {
|
|
|
467220
467255
|
const toDelete = files.slice(0, files.length - maxFiles + 1);
|
|
467221
467256
|
for (const file of toDelete) {
|
|
467222
467257
|
try {
|
|
467223
|
-
unlinkSync18(
|
|
467258
|
+
unlinkSync18(join102(dir, file));
|
|
467224
467259
|
} catch {}
|
|
467225
467260
|
}
|
|
467226
467261
|
}
|
|
@@ -467259,7 +467294,7 @@ class RemoteSessionLog {
|
|
|
467259
467294
|
freshPath() {
|
|
467260
467295
|
const stamp = formatFileTimestamp(new Date);
|
|
467261
467296
|
const suffix = this.rotation > 0 ? `.${this.rotation}` : "";
|
|
467262
|
-
return
|
|
467297
|
+
return join102(this.dir, `${stamp}${suffix}.log`);
|
|
467263
467298
|
}
|
|
467264
467299
|
rotate() {
|
|
467265
467300
|
const previous = this.path;
|
|
@@ -467300,13 +467335,13 @@ var REMOTE_LOG_DIR, MAX_LOG_FILES = 10, MAX_LOG_BYTES2;
|
|
|
467300
467335
|
var init_listen_log = __esm(() => {
|
|
467301
467336
|
init_settings_path();
|
|
467302
467337
|
init_ws_event_redaction();
|
|
467303
|
-
REMOTE_LOG_DIR =
|
|
467338
|
+
REMOTE_LOG_DIR = join102(resolveGlobalConfigDir(), "logs", "remote");
|
|
467304
467339
|
MAX_LOG_BYTES2 = 10 * 1024 * 1024;
|
|
467305
467340
|
});
|
|
467306
467341
|
|
|
467307
467342
|
// src/websocket/listener/manual-instance-lock.ts
|
|
467308
467343
|
import { createHash as createHash21, randomUUID as randomUUID60 } from "node:crypto";
|
|
467309
|
-
import { link as link4, mkdir as mkdir15, readFile as readFile28, rm as
|
|
467344
|
+
import { link as link4, mkdir as mkdir15, readFile as readFile28, rm as rm12, unlink as unlink3, writeFile as writeFile17 } from "node:fs/promises";
|
|
467310
467345
|
import { uptime as uptime2 } from "node:os";
|
|
467311
467346
|
import path46 from "node:path";
|
|
467312
467347
|
function hasErrorCode3(error4, code) {
|
|
@@ -467380,7 +467415,7 @@ async function publishInitializedFile(targetPath, contents) {
|
|
|
467380
467415
|
} catch (error4) {
|
|
467381
467416
|
publicationError = error4;
|
|
467382
467417
|
}
|
|
467383
|
-
await
|
|
467418
|
+
await rm12(candidatePath, { force: true }).catch(() => {});
|
|
467384
467419
|
return publicationError;
|
|
467385
467420
|
}
|
|
467386
467421
|
function getRecoveryClaimPath2(lockPath, staleContents, depth) {
|
|
@@ -467389,7 +467424,7 @@ function getRecoveryClaimPath2(lockPath, staleContents, depth) {
|
|
|
467389
467424
|
}
|
|
467390
467425
|
async function cleanupRecoveryClaims2(lockPath, staleContents, deepestClaim) {
|
|
467391
467426
|
for (let depth = deepestClaim;depth >= 0; depth--) {
|
|
467392
|
-
await
|
|
467427
|
+
await rm12(getRecoveryClaimPath2(lockPath, staleContents, depth), {
|
|
467393
467428
|
force: true
|
|
467394
467429
|
}).catch(() => {});
|
|
467395
467430
|
}
|
|
@@ -468050,8 +468085,8 @@ async function startChannelGatewaySupervisor(options) {
|
|
|
468050
468085
|
let resolveInitialReady = null;
|
|
468051
468086
|
let rejectInitialReady = null;
|
|
468052
468087
|
const pendingCommands = new Map;
|
|
468053
|
-
const initialReady = new Promise((
|
|
468054
|
-
resolveInitialReady =
|
|
468088
|
+
const initialReady = new Promise((resolve39, reject2) => {
|
|
468089
|
+
resolveInitialReady = resolve39;
|
|
468055
468090
|
rejectInitialReady = reject2;
|
|
468056
468091
|
});
|
|
468057
468092
|
function clearStableTimer() {
|
|
@@ -468277,7 +468312,7 @@ async function startChannelGatewaySupervisor(options) {
|
|
|
468277
468312
|
clearTimeout(startupTimeout);
|
|
468278
468313
|
}
|
|
468279
468314
|
return {
|
|
468280
|
-
request: (command) => new Promise((
|
|
468315
|
+
request: (command) => new Promise((resolve39, reject2) => {
|
|
468281
468316
|
const activeChild = readyChild;
|
|
468282
468317
|
if (!activeChild?.stdin?.writable) {
|
|
468283
468318
|
reject2(new Error("ChannelGateway process is not available"));
|
|
@@ -468288,7 +468323,7 @@ async function startChannelGatewaySupervisor(options) {
|
|
|
468288
468323
|
pendingCommands.delete(requestId);
|
|
468289
468324
|
reject2(new Error(`ChannelGateway command timed out: ${command.kind}`));
|
|
468290
468325
|
}, COMMAND_TIMEOUT_MS);
|
|
468291
|
-
pendingCommands.set(requestId, { resolve:
|
|
468326
|
+
pendingCommands.set(requestId, { resolve: resolve39, reject: reject2, timeout });
|
|
468292
468327
|
activeChild.stdin.write(`${JSON.stringify({ type: "command", requestId, command })}
|
|
468293
468328
|
`, (error4) => {
|
|
468294
468329
|
if (!error4)
|
|
@@ -468313,14 +468348,14 @@ async function startChannelGatewaySupervisor(options) {
|
|
|
468313
468348
|
rejectPendingCommands(closeError);
|
|
468314
468349
|
if (!activeChild || activeChild.exitCode !== null)
|
|
468315
468350
|
return;
|
|
468316
|
-
await new Promise((
|
|
468351
|
+
await new Promise((resolve39) => {
|
|
468317
468352
|
const timeout = setTimeout(() => {
|
|
468318
468353
|
activeChild.kill("SIGKILL");
|
|
468319
|
-
|
|
468354
|
+
resolve39();
|
|
468320
468355
|
}, SHUTDOWN_TIMEOUT_MS);
|
|
468321
468356
|
activeChild.once("exit", () => {
|
|
468322
468357
|
clearTimeout(timeout);
|
|
468323
|
-
|
|
468358
|
+
resolve39();
|
|
468324
468359
|
});
|
|
468325
468360
|
activeChild.kill("SIGTERM");
|
|
468326
468361
|
});
|
|
@@ -469026,7 +469061,7 @@ import {
|
|
|
469026
469061
|
readFileSync as readFileSync52,
|
|
469027
469062
|
writeFileSync as writeFileSync44
|
|
469028
469063
|
} from "node:fs";
|
|
469029
|
-
import { join as
|
|
469064
|
+
import { join as join103 } from "node:path";
|
|
469030
469065
|
function readJsonl(path47) {
|
|
469031
469066
|
if (!existsSync66(path47))
|
|
469032
469067
|
return [];
|
|
@@ -469309,7 +469344,7 @@ function convertMessages4(messages, mode, nextId2) {
|
|
|
469309
469344
|
}
|
|
469310
469345
|
function migrateLocalBackendTranscripts(input) {
|
|
469311
469346
|
const storageDir = input.storageDir;
|
|
469312
|
-
const conversationsDir =
|
|
469347
|
+
const conversationsDir = join103(storageDir, "conversations");
|
|
469313
469348
|
const result3 = {
|
|
469314
469349
|
storageDir,
|
|
469315
469350
|
converted: [],
|
|
@@ -469319,9 +469354,9 @@ function migrateLocalBackendTranscripts(input) {
|
|
|
469319
469354
|
if (!existsSync66(conversationsDir))
|
|
469320
469355
|
return result3;
|
|
469321
469356
|
for (const name of readdirSync27(conversationsDir)) {
|
|
469322
|
-
const conversationDir =
|
|
469323
|
-
const messagesPath =
|
|
469324
|
-
const manifestPath =
|
|
469357
|
+
const conversationDir = join103(conversationsDir, name);
|
|
469358
|
+
const messagesPath = join103(conversationDir, "messages.jsonl");
|
|
469359
|
+
const manifestPath = join103(conversationDir, "manifest.json");
|
|
469325
469360
|
const hasManifest = existsSync66(manifestPath);
|
|
469326
469361
|
const existingManifest = hasManifest ? (() => {
|
|
469327
469362
|
try {
|
|
@@ -469364,7 +469399,7 @@ function migrateLocalBackendTranscripts(input) {
|
|
|
469364
469399
|
const backupPath = `${messagesPath}.pre-pi-backup-${timestampSuffix()}`;
|
|
469365
469400
|
if (!input.dryRun) {
|
|
469366
469401
|
copyFileSync3(messagesPath, backupPath);
|
|
469367
|
-
const conversationPath =
|
|
469402
|
+
const conversationPath = join103(conversationDir, "conversation.json");
|
|
469368
469403
|
let conversation;
|
|
469369
469404
|
if (existsSync66(conversationPath)) {
|
|
469370
469405
|
try {
|
|
@@ -469562,7 +469597,7 @@ var init_memory_tokens = __esm(() => {
|
|
|
469562
469597
|
// src/cli/subcommands/memory.ts
|
|
469563
469598
|
import { cpSync, existsSync as existsSync67, mkdirSync as mkdirSync53, rmSync as rmSync24, statSync as statSync26 } from "node:fs";
|
|
469564
469599
|
import { readdir as readdir12 } from "node:fs/promises";
|
|
469565
|
-
import { dirname as dirname40, join as
|
|
469600
|
+
import { dirname as dirname40, join as join104 } from "node:path";
|
|
469566
469601
|
import { parseArgs as parseArgs12 } from "node:util";
|
|
469567
469602
|
function printUsage8() {
|
|
469568
469603
|
console.log(`
|
|
@@ -469632,7 +469667,7 @@ async function listBackups(agentId) {
|
|
|
469632
469667
|
continue;
|
|
469633
469668
|
if (!entry.name.startsWith("memory-backup-"))
|
|
469634
469669
|
continue;
|
|
469635
|
-
const path47 =
|
|
469670
|
+
const path47 = join104(agentRoot, entry.name);
|
|
469636
469671
|
let createdAt = null;
|
|
469637
469672
|
try {
|
|
469638
469673
|
const stat15 = statSync26(path47);
|
|
@@ -469649,7 +469684,7 @@ function resolveBackupPath(agentId, from) {
|
|
|
469649
469684
|
if (from.startsWith("/") || /^[A-Za-z]:[/\\]/.test(from)) {
|
|
469650
469685
|
return from;
|
|
469651
469686
|
}
|
|
469652
|
-
return
|
|
469687
|
+
return join104(getAgentRoot(agentId), from);
|
|
469653
469688
|
}
|
|
469654
469689
|
async function runMemorySubcommand(argv, deps = {}) {
|
|
469655
469690
|
let parsed;
|
|
@@ -469733,7 +469768,7 @@ async function runMemorySubcommand(argv, deps = {}) {
|
|
|
469733
469768
|
}
|
|
469734
469769
|
const agentRoot = getAgentRoot(agentId);
|
|
469735
469770
|
const backupName = `memory-backup-${formatBackupTimestamp()}`;
|
|
469736
|
-
const backupPath =
|
|
469771
|
+
const backupPath = join104(agentRoot, backupName);
|
|
469737
469772
|
if (existsSync67(backupPath)) {
|
|
469738
469773
|
console.error(`Backup already exists at ${backupPath}`);
|
|
469739
469774
|
return 1;
|
|
@@ -469834,7 +469869,7 @@ var init_memory6 = __esm(() => {
|
|
|
469834
469869
|
|
|
469835
469870
|
// src/backend/local/transcript-search.ts
|
|
469836
469871
|
import { existsSync as existsSync68, readdirSync as readdirSync28, readFileSync as readFileSync53, statSync as statSync27 } from "node:fs";
|
|
469837
|
-
import { join as
|
|
469872
|
+
import { join as join105 } from "node:path";
|
|
469838
469873
|
function readJsonFile3(path47) {
|
|
469839
469874
|
if (!existsSync68(path47))
|
|
469840
469875
|
return;
|
|
@@ -470079,7 +470114,7 @@ function collectConversationMessages(input) {
|
|
|
470079
470114
|
return [];
|
|
470080
470115
|
if (input.conversationId && conversation.id !== input.conversationId)
|
|
470081
470116
|
return [];
|
|
470082
|
-
const manifest2 = readJsonFile3(
|
|
470117
|
+
const manifest2 = readJsonFile3(join105(conversationDir, "manifest.json"));
|
|
470083
470118
|
let format3 = transcriptFormatFromManifest(manifest2);
|
|
470084
470119
|
const records2 = [];
|
|
470085
470120
|
const echoToolCallIds = [];
|
|
@@ -470139,7 +470174,7 @@ function collectConversationMessages(input) {
|
|
|
470139
470174
|
}
|
|
470140
470175
|
addRow(row, rowIndex);
|
|
470141
470176
|
};
|
|
470142
|
-
const messagesPath =
|
|
470177
|
+
const messagesPath = join105(conversationDir, "messages.jsonl");
|
|
470143
470178
|
let rowError;
|
|
470144
470179
|
try {
|
|
470145
470180
|
forEachJsonlRow(messagesPath, (row) => {
|
|
@@ -470168,11 +470203,11 @@ function collectConversationMessages(input) {
|
|
|
470168
470203
|
return records2;
|
|
470169
470204
|
}
|
|
470170
470205
|
function conversationDirectories(storageDir) {
|
|
470171
|
-
const conversationsDir =
|
|
470206
|
+
const conversationsDir = join105(storageDir, "conversations");
|
|
470172
470207
|
if (!existsSync68(conversationsDir))
|
|
470173
470208
|
return [];
|
|
470174
470209
|
try {
|
|
470175
|
-
return readdirSync28(conversationsDir).map((entry) =>
|
|
470210
|
+
return readdirSync28(conversationsDir).map((entry) => join105(conversationsDir, entry)).filter((entryPath) => statSync27(entryPath).isDirectory());
|
|
470176
470211
|
} catch {
|
|
470177
470212
|
return [];
|
|
470178
470213
|
}
|
|
@@ -470199,7 +470234,7 @@ function searchLocalTranscriptMessages(storageDir, body3, options = {}) {
|
|
|
470199
470234
|
const endDate = typeof body3.end_date === "string" ? body3.end_date : undefined;
|
|
470200
470235
|
const includeHidden = body3.include_hidden === true;
|
|
470201
470236
|
const records2 = conversationDirectories(storageDir).flatMap((conversationDir) => {
|
|
470202
|
-
const conversation = conversationSearchRecord(readJsonFile3(
|
|
470237
|
+
const conversation = conversationSearchRecord(readJsonFile3(join105(conversationDir, "conversation.json")));
|
|
470203
470238
|
if (!conversation)
|
|
470204
470239
|
return [];
|
|
470205
470240
|
if (conversation.hidden && !includeHidden)
|
|
@@ -470303,7 +470338,7 @@ var init_message_status = __esm(() => {
|
|
|
470303
470338
|
|
|
470304
470339
|
// src/cli/subcommands/messages.ts
|
|
470305
470340
|
import { writeFile as writeFile18 } from "node:fs/promises";
|
|
470306
|
-
import { resolve as
|
|
470341
|
+
import { resolve as resolve39 } from "node:path";
|
|
470307
470342
|
import { parseArgs as parseArgs13 } from "node:util";
|
|
470308
470343
|
function printUsage9() {
|
|
470309
470344
|
console.log(`
|
|
@@ -470633,7 +470668,7 @@ async function runMessagesSubcommand(argv, deps = {}) {
|
|
|
470633
470668
|
const pageLimit = Math.max(1, parseLimit3(parsed.values.limit, 100));
|
|
470634
470669
|
const maxPages = Math.max(1, parseLimit3(parsed.values["max-pages"], 200));
|
|
470635
470670
|
const outputPathRaw = parsed.values.out || parsed.values.output;
|
|
470636
|
-
const outputPath = outputPathRaw ?
|
|
470671
|
+
const outputPath = outputPathRaw ? resolve39(process.cwd(), outputPathRaw) : undefined;
|
|
470637
470672
|
const { messages, truncated } = await fetchConversationMessages(conversationId, agentId || undefined, pageLimit, maxPages);
|
|
470638
470673
|
const transcript2 = messages.flatMap((msg) => formatEntry(msg)).join(`
|
|
470639
470674
|
|
|
@@ -470871,9 +470906,9 @@ function filterStructuredOutputRows(rows) {
|
|
|
470871
470906
|
return { supported, unknownCount };
|
|
470872
470907
|
}
|
|
470873
470908
|
async function printJson3(value) {
|
|
470874
|
-
await new Promise((
|
|
470909
|
+
await new Promise((resolve40, reject2) => {
|
|
470875
470910
|
process.stdout.write(`${JSON.stringify(value, null, 2)}
|
|
470876
|
-
`, (error4) => error4 ? reject2(error4) :
|
|
470911
|
+
`, (error4) => error4 ? reject2(error4) : resolve40());
|
|
470877
470912
|
});
|
|
470878
470913
|
}
|
|
470879
470914
|
async function runModelSubcommand(argv) {
|
|
@@ -471250,8 +471285,8 @@ function isRecord21(value) {
|
|
|
471250
471285
|
function isPathInsideOrEqual2(childPath, parentPath) {
|
|
471251
471286
|
const child = path47.resolve(childPath);
|
|
471252
471287
|
const parent = path47.resolve(parentPath);
|
|
471253
|
-
const
|
|
471254
|
-
return
|
|
471288
|
+
const relative12 = path47.relative(parent, child);
|
|
471289
|
+
return relative12 === "" || !!relative12 && !relative12.startsWith("..") && !path47.isAbsolute(relative12);
|
|
471255
471290
|
}
|
|
471256
471291
|
function readPackageJson(packageJsonPath) {
|
|
471257
471292
|
let parsed;
|
|
@@ -471592,7 +471627,7 @@ function writeNpmInstallManifest(tempRoot) {
|
|
|
471592
471627
|
`);
|
|
471593
471628
|
}
|
|
471594
471629
|
function runProcess2(params) {
|
|
471595
|
-
return new Promise((
|
|
471630
|
+
return new Promise((resolve40, reject2) => {
|
|
471596
471631
|
const child = params.spawnImpl(params.command, params.args, {
|
|
471597
471632
|
cwd: params.cwd,
|
|
471598
471633
|
stdio: ["ignore", "pipe", "pipe"]
|
|
@@ -471608,7 +471643,7 @@ function runProcess2(params) {
|
|
|
471608
471643
|
child.on("error", reject2);
|
|
471609
471644
|
child.on("exit", (code) => {
|
|
471610
471645
|
if (code === 0) {
|
|
471611
|
-
|
|
471646
|
+
resolve40({ stderr: stderr.join(""), stdout: stdout.join("") });
|
|
471612
471647
|
return;
|
|
471613
471648
|
}
|
|
471614
471649
|
const details = stderr.join("").trim() || stdout.join("").trim();
|
|
@@ -472228,7 +472263,7 @@ var init_package_scaffolder = __esm(() => {
|
|
|
472228
472263
|
});
|
|
472229
472264
|
|
|
472230
472265
|
// src/cli/subcommands/mods.ts
|
|
472231
|
-
import { dirname as dirname41, join as
|
|
472266
|
+
import { dirname as dirname41, join as join106 } from "node:path";
|
|
472232
472267
|
import { parseArgs as parseArgs15 } from "node:util";
|
|
472233
472268
|
function printUsage11() {
|
|
472234
472269
|
console.log(`
|
|
@@ -472267,7 +472302,7 @@ function getExplicitAgentId(values4) {
|
|
|
472267
472302
|
return typeof explicitAgent === "string" && explicitAgent.trim() ? explicitAgent.trim() : null;
|
|
472268
472303
|
}
|
|
472269
472304
|
function getAgentModsDirectory(agentId) {
|
|
472270
|
-
return
|
|
472305
|
+
return join106(getScopedMemoryFilesystemRoot(agentId), "mods");
|
|
472271
472306
|
}
|
|
472272
472307
|
function directFilesForSource(source) {
|
|
472273
472308
|
return source.files.filter((file) => dirname41(file) === source.root);
|
|
@@ -472754,7 +472789,7 @@ var init_sandbox_files = __esm(() => {
|
|
|
472754
472789
|
|
|
472755
472790
|
// src/cli/subcommands/sandbox.ts
|
|
472756
472791
|
import { readFile as readFile29, stat as stat15, writeFile as writeFile19 } from "node:fs/promises";
|
|
472757
|
-
import { basename as basename30, resolve as
|
|
472792
|
+
import { basename as basename30, resolve as resolve40 } from "node:path";
|
|
472758
472793
|
import { parseArgs as parseArgs17 } from "node:util";
|
|
472759
472794
|
function printUsage13() {
|
|
472760
472795
|
console.log(`
|
|
@@ -472977,7 +473012,7 @@ async function runSandboxSubcommand(argv, deps = {}) {
|
|
|
472977
473012
|
if (path49 === undefined)
|
|
472978
473013
|
throw new Error("Missing file path");
|
|
472979
473014
|
if (action === "upload") {
|
|
472980
|
-
const localPath3 =
|
|
473015
|
+
const localPath3 = resolve40(path49);
|
|
472981
473016
|
const fileStat = await (deps.statLocalPath ?? stat15)(localPath3);
|
|
472982
473017
|
if (!fileStat.isFile())
|
|
472983
473018
|
throw new Error(`${localPath3} is not a file`);
|
|
@@ -472989,7 +473024,7 @@ async function runSandboxSubcommand(argv, deps = {}) {
|
|
|
472989
473024
|
}
|
|
472990
473025
|
const sandbox = await ensureSandbox();
|
|
472991
473026
|
const data = await (deps.downloadFile ?? downloadFileFromSandbox)(sandbox.sandboxId, path49);
|
|
472992
|
-
const localPath2 =
|
|
473027
|
+
const localPath2 = resolve40(parsed.values.to ?? basename30(path49));
|
|
472993
473028
|
await (deps.writeLocalFile ?? writeFile19)(localPath2, data);
|
|
472994
473029
|
console.log(JSON.stringify({
|
|
472995
473030
|
path: localPath2,
|
|
@@ -473758,7 +473793,7 @@ __export(exports_setup, {
|
|
|
473758
473793
|
runSetup: () => runSetup
|
|
473759
473794
|
});
|
|
473760
473795
|
async function runSetup(options = {}) {
|
|
473761
|
-
return new Promise((
|
|
473796
|
+
return new Promise((resolve41) => {
|
|
473762
473797
|
let settled = false;
|
|
473763
473798
|
let instance2;
|
|
473764
473799
|
const settle3 = (result3) => {
|
|
@@ -473767,7 +473802,7 @@ async function runSetup(options = {}) {
|
|
|
473767
473802
|
}
|
|
473768
473803
|
settled = true;
|
|
473769
473804
|
instance2.unmount();
|
|
473770
|
-
|
|
473805
|
+
resolve41(result3);
|
|
473771
473806
|
};
|
|
473772
473807
|
instance2 = render_default(import_react35.default.createElement(SetupUI, {
|
|
473773
473808
|
initialMode: options.initialMode,
|
|
@@ -473822,7 +473857,7 @@ var init_setup7 = __esm(async () => {
|
|
|
473822
473857
|
|
|
473823
473858
|
// src/cli/subcommands/shared-memory.ts
|
|
473824
473859
|
import { existsSync as existsSync71 } from "node:fs";
|
|
473825
|
-
import { join as
|
|
473860
|
+
import { join as join107 } from "node:path";
|
|
473826
473861
|
import { parseArgs as parseArgs19 } from "node:util";
|
|
473827
473862
|
function printUsage16() {
|
|
473828
473863
|
console.log(`
|
|
@@ -474029,7 +474064,7 @@ async function runSharedMemorySubcommand(argv, deps = {}) {
|
|
|
474029
474064
|
invalidateClientSkills(agentId);
|
|
474030
474065
|
const recompileError = await recompileAndReportFailure(recompileAgent, agentId);
|
|
474031
474066
|
const mountDir = getRepositoryMountDir(agentId, repository.name);
|
|
474032
|
-
const mounted = existsSync71(
|
|
474067
|
+
const mounted = existsSync71(join107(mountDir, ".git"));
|
|
474033
474068
|
console.log(JSON.stringify({
|
|
474034
474069
|
attached: true,
|
|
474035
474070
|
repository: { id: repository.id, name: repository.name },
|
|
@@ -475621,7 +475656,7 @@ import {
|
|
|
475621
475656
|
} from "node:fs";
|
|
475622
475657
|
import { mkdir as mkdir16, readdir as readdir13 } from "node:fs/promises";
|
|
475623
475658
|
import { tmpdir as tmpdir15 } from "node:os";
|
|
475624
|
-
import { basename as basename31, dirname as dirname42, join as
|
|
475659
|
+
import { basename as basename31, dirname as dirname42, join as join108, normalize as normalize5, resolve as resolve41, sep as sep9 } from "node:path";
|
|
475625
475660
|
import { parseArgs as parseArgs20, TextDecoder as TextDecoder2, TextEncoder as TextEncoder2 } from "node:util";
|
|
475626
475661
|
function printUsage17() {
|
|
475627
475662
|
console.log(`
|
|
@@ -475892,14 +475927,14 @@ async function resolveBranchAndSubdir(location) {
|
|
|
475892
475927
|
}
|
|
475893
475928
|
async function cloneSkillSource(location) {
|
|
475894
475929
|
const resolvedLocation = await resolveBranchAndSubdir(location);
|
|
475895
|
-
const tmpDir = mkdtempSync6(
|
|
475930
|
+
const tmpDir = mkdtempSync6(join108(tmpdir15(), "letta-skill-install-"));
|
|
475896
475931
|
const args = ["clone", "--depth", "1"];
|
|
475897
475932
|
if (resolvedLocation.branch) {
|
|
475898
475933
|
args.push("--branch", resolvedLocation.branch);
|
|
475899
475934
|
}
|
|
475900
475935
|
args.push(resolvedLocation.repoUrl, tmpDir);
|
|
475901
475936
|
await execFile22("git", args, { timeout: 120000 });
|
|
475902
|
-
const sourceDir = resolvedLocation.subdir ?
|
|
475937
|
+
const sourceDir = resolvedLocation.subdir ? join108(tmpDir, resolvedLocation.subdir) : tmpDir;
|
|
475903
475938
|
return { tmpDir, sourceDir };
|
|
475904
475939
|
}
|
|
475905
475940
|
function assertDirectSkillFileSize(receivedBytes, maxBytes) {
|
|
@@ -475954,11 +475989,11 @@ async function downloadDirectSkillFileSource(location, options = {}) {
|
|
|
475954
475989
|
throw new Error(`Direct skill file download failed for ${location.url}: ${response.status}`);
|
|
475955
475990
|
}
|
|
475956
475991
|
const skillText = await readResponseTextWithLimit(response, MAX_DIRECT_SKILL_FILE_BYTES);
|
|
475957
|
-
const tmpDir = mkdtempSync6(
|
|
475992
|
+
const tmpDir = mkdtempSync6(join108(tmpdir15(), "letta-direct-skill-"));
|
|
475958
475993
|
try {
|
|
475959
|
-
const sourceDir =
|
|
475994
|
+
const sourceDir = join108(tmpDir, "skill");
|
|
475960
475995
|
await mkdir16(sourceDir, { recursive: true });
|
|
475961
|
-
writeFileSync47(
|
|
475996
|
+
writeFileSync47(join108(sourceDir, "SKILL.md"), skillText, "utf8");
|
|
475962
475997
|
return { tmpDir, sourceDir };
|
|
475963
475998
|
} catch (error4) {
|
|
475964
475999
|
rmSync27(tmpDir, { recursive: true, force: true });
|
|
@@ -475999,9 +476034,9 @@ function assertSafeZipMember(name) {
|
|
|
475999
476034
|
}
|
|
476000
476035
|
async function downloadClawHubSkillSource(location) {
|
|
476001
476036
|
const version3 = await resolveClawHubVersion(location);
|
|
476002
|
-
const tmpDir = mkdtempSync6(
|
|
476003
|
-
const zipPath =
|
|
476004
|
-
const sourceDir =
|
|
476037
|
+
const tmpDir = mkdtempSync6(join108(tmpdir15(), "letta-clawhub-skill-"));
|
|
476038
|
+
const zipPath = join108(tmpDir, "skill.zip");
|
|
476039
|
+
const sourceDir = join108(tmpDir, "skill");
|
|
476005
476040
|
await mkdir16(sourceDir, { recursive: true });
|
|
476006
476041
|
const url2 = new URL(`${CLAWHUB_API_BASE_URL}/download`);
|
|
476007
476042
|
url2.searchParams.set("slug", location.slug);
|
|
@@ -476026,9 +476061,9 @@ async function downloadClawHubSkillSource(location) {
|
|
|
476026
476061
|
return { tmpDir, sourceDir };
|
|
476027
476062
|
}
|
|
476028
476063
|
function assertInside(parent, child) {
|
|
476029
|
-
const parentPath =
|
|
476030
|
-
const childPath =
|
|
476031
|
-
if (childPath !== parentPath && !childPath.startsWith(`${parentPath}${
|
|
476064
|
+
const parentPath = resolve41(parent);
|
|
476065
|
+
const childPath = resolve41(child);
|
|
476066
|
+
if (childPath !== parentPath && !childPath.startsWith(`${parentPath}${sep9}`)) {
|
|
476032
476067
|
throw new Error(`Resolved path is outside target directory: ${child}`);
|
|
476033
476068
|
}
|
|
476034
476069
|
}
|
|
@@ -476040,16 +476075,16 @@ function sanitizeSkillName(name) {
|
|
|
476040
476075
|
return trimmed;
|
|
476041
476076
|
}
|
|
476042
476077
|
function getSkillName(sourceDir) {
|
|
476043
|
-
const skillMd = readFileSync55(
|
|
476078
|
+
const skillMd = readFileSync55(join108(sourceDir, "SKILL.md"), "utf8");
|
|
476044
476079
|
const { frontmatter } = parseFrontmatter(skillMd);
|
|
476045
476080
|
const frontmatterName = frontmatter.name;
|
|
476046
476081
|
const name = typeof frontmatterName === "string" && frontmatterName.trim() ? frontmatterName : basename31(sourceDir);
|
|
476047
476082
|
return sanitizeSkillName(name);
|
|
476048
476083
|
}
|
|
476049
476084
|
async function installSkillDirectory(params) {
|
|
476050
|
-
const sourceDir =
|
|
476051
|
-
const memoryDir =
|
|
476052
|
-
const skillMdPath =
|
|
476085
|
+
const sourceDir = resolve41(params.sourceDir);
|
|
476086
|
+
const memoryDir = resolve41(params.memoryDir);
|
|
476087
|
+
const skillMdPath = join108(sourceDir, "SKILL.md");
|
|
476053
476088
|
if (!existsSync72(skillMdPath)) {
|
|
476054
476089
|
throw new Error("No SKILL.md found in the skill directory.");
|
|
476055
476090
|
}
|
|
@@ -476057,8 +476092,8 @@ async function installSkillDirectory(params) {
|
|
|
476057
476092
|
throw new Error(`Skill source is not a directory: ${sourceDir}`);
|
|
476058
476093
|
}
|
|
476059
476094
|
const name = getSkillName(sourceDir);
|
|
476060
|
-
const skillsDir =
|
|
476061
|
-
const targetPath =
|
|
476095
|
+
const skillsDir = join108(memoryDir, "skills");
|
|
476096
|
+
const targetPath = join108(skillsDir, name);
|
|
476062
476097
|
assertInside(skillsDir, targetPath);
|
|
476063
476098
|
if (existsSync72(targetPath)) {
|
|
476064
476099
|
if (!params.force) {
|
|
@@ -476074,8 +476109,8 @@ async function installSkillDirectory(params) {
|
|
|
476074
476109
|
return { name, path: normalize5(targetPath) };
|
|
476075
476110
|
}
|
|
476076
476111
|
async function listSkillDirectories(params) {
|
|
476077
|
-
const memoryDir =
|
|
476078
|
-
const skillsDir =
|
|
476112
|
+
const memoryDir = resolve41(params.memoryDir);
|
|
476113
|
+
const skillsDir = join108(memoryDir, "skills");
|
|
476079
476114
|
if (!existsSync72(skillsDir))
|
|
476080
476115
|
return [];
|
|
476081
476116
|
const entries2 = await readdir13(skillsDir, { withFileTypes: true });
|
|
@@ -476083,8 +476118,8 @@ async function listSkillDirectories(params) {
|
|
|
476083
476118
|
for (const entry of entries2) {
|
|
476084
476119
|
if (!entry.isDirectory())
|
|
476085
476120
|
continue;
|
|
476086
|
-
const skillDir =
|
|
476087
|
-
const skillMdPath =
|
|
476121
|
+
const skillDir = join108(skillsDir, entry.name);
|
|
476122
|
+
const skillMdPath = join108(skillDir, "SKILL.md");
|
|
476088
476123
|
if (!existsSync72(skillMdPath))
|
|
476089
476124
|
continue;
|
|
476090
476125
|
let name = entry.name;
|
|
@@ -476104,10 +476139,10 @@ async function listSkillDirectories(params) {
|
|
|
476104
476139
|
return skills.sort((a2, b3) => a2.name.localeCompare(b3.name));
|
|
476105
476140
|
}
|
|
476106
476141
|
async function deleteSkillDirectory(params) {
|
|
476107
|
-
const memoryDir =
|
|
476108
|
-
const skillsDir =
|
|
476142
|
+
const memoryDir = resolve41(params.memoryDir);
|
|
476143
|
+
const skillsDir = join108(memoryDir, "skills");
|
|
476109
476144
|
const name = sanitizeSkillName(params.name);
|
|
476110
|
-
const targetPath =
|
|
476145
|
+
const targetPath = join108(skillsDir, name);
|
|
476111
476146
|
assertInside(skillsDir, targetPath);
|
|
476112
476147
|
if (!existsSync72(targetPath)) {
|
|
476113
476148
|
throw new Error(`Skill "${name}" is not installed at ${targetPath}.`);
|
|
@@ -476156,7 +476191,7 @@ async function installSkill(specifier, agentId, force) {
|
|
|
476156
476191
|
downloaded = await downloadClawHubSkillSource(source.location);
|
|
476157
476192
|
}
|
|
476158
476193
|
tmpDir = downloaded.tmpDir;
|
|
476159
|
-
const sourceDir =
|
|
476194
|
+
const sourceDir = resolve41(downloaded.sourceDir);
|
|
476160
476195
|
assertInside(tmpDir, sourceDir);
|
|
476161
476196
|
if (!existsSync72(sourceDir)) {
|
|
476162
476197
|
const missingPath = source.type === "git" ? source.location.subdir ?? "." : source.type === "direct-file" ? source.location.url : source.location.slug;
|
|
@@ -476339,7 +476374,7 @@ async function runInstall(argv, options = {}) {
|
|
|
476339
476374
|
return 1;
|
|
476340
476375
|
}
|
|
476341
476376
|
}
|
|
476342
|
-
const maybeLocalPath =
|
|
476377
|
+
const maybeLocalPath = resolve41(specifier);
|
|
476343
476378
|
if (isLocalLettaModPackageDirectory(maybeLocalPath)) {
|
|
476344
476379
|
if (hasInstallAgentScope(parsed.values)) {
|
|
476345
476380
|
console.error("Agent-scoped mod package install is not supported yet.");
|
|
@@ -476654,20 +476689,20 @@ async function runTeleportSubcommand(argv, deps = {}) {
|
|
|
476654
476689
|
throw new Error(channelError);
|
|
476655
476690
|
let targetConnectionId;
|
|
476656
476691
|
if (action === "cloud") {
|
|
476657
|
-
const
|
|
476658
|
-
const result4 = await
|
|
476692
|
+
const resolve42 = deps.resolveAgentSandboxConnectionId ?? resolveAgentSandboxConnectionId;
|
|
476693
|
+
const result4 = await resolve42(session3.agentId, {
|
|
476659
476694
|
conversationId: session3.conversationId
|
|
476660
476695
|
});
|
|
476661
476696
|
targetConnectionId = result4.connectionId;
|
|
476662
476697
|
} else if (action === "local") {
|
|
476663
|
-
const
|
|
476664
|
-
const result4 = await
|
|
476698
|
+
const resolve42 = deps.resolveDesktopEnvironmentConnectionId ?? resolveDesktopEnvironmentConnectionId;
|
|
476699
|
+
const result4 = await resolve42();
|
|
476665
476700
|
targetConnectionId = result4.connectionId;
|
|
476666
476701
|
} else if (action === "back") {
|
|
476667
476702
|
throw new Error("Teleport back is not supported. Use `letta teleport local` or choose an explicit computer.");
|
|
476668
476703
|
} else {
|
|
476669
|
-
const
|
|
476670
|
-
const resolved = await
|
|
476704
|
+
const resolve42 = deps.resolveEnvironmentConnectionId ?? resolveEnvironmentConnectionId;
|
|
476705
|
+
const resolved = await resolve42(action);
|
|
476671
476706
|
assertTeleportableRemoteEnvironment(resolved.environment);
|
|
476672
476707
|
targetConnectionId = resolved.connectionId;
|
|
476673
476708
|
}
|
|
@@ -476693,7 +476728,7 @@ var init_teleport2 = __esm(() => {
|
|
|
476693
476728
|
|
|
476694
476729
|
// src/cli/subcommands/trajectories/readers.ts
|
|
476695
476730
|
import { readdir as readdir14, readFile as readFile30, stat as stat16 } from "node:fs/promises";
|
|
476696
|
-
import { join as
|
|
476731
|
+
import { join as join109 } from "node:path";
|
|
476697
476732
|
async function loadSessionTranscript(item) {
|
|
476698
476733
|
const stats = await stat16(item.path);
|
|
476699
476734
|
if (stats.isDirectory()) {
|
|
@@ -476705,13 +476740,13 @@ async function loadSessionTranscript(item) {
|
|
|
476705
476740
|
return readFile30(item.path, "utf-8");
|
|
476706
476741
|
}
|
|
476707
476742
|
async function assembleEventDirectory(sessionDir) {
|
|
476708
|
-
const eventsSubdir =
|
|
476743
|
+
const eventsSubdir = join109(sessionDir, "events");
|
|
476709
476744
|
const eventsDir = (await stat16(eventsSubdir).catch(() => null))?.isDirectory() ? eventsSubdir : sessionDir;
|
|
476710
476745
|
const names = (await readdir14(eventsDir, { withFileTypes: true })).filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => entry.name).sort((a2, b3) => Number.parseInt(a2, 10) - Number.parseInt(b3, 10) || a2.localeCompare(b3));
|
|
476711
476746
|
if (names.length === 0) {
|
|
476712
476747
|
throw new Error(`No event files found in ${eventsDir}`);
|
|
476713
476748
|
}
|
|
476714
|
-
const events = await Promise.all(names.map(async (name) => JSON.parse(await readFile30(
|
|
476749
|
+
const events = await Promise.all(names.map(async (name) => JSON.parse(await readFile30(join109(eventsDir, name), "utf-8"))));
|
|
476715
476750
|
return JSON.stringify(events);
|
|
476716
476751
|
}
|
|
476717
476752
|
async function openReadOnlyDatabase(path49) {
|
|
@@ -476785,11 +476820,11 @@ import {
|
|
|
476785
476820
|
mkdir as mkdir17,
|
|
476786
476821
|
readdir as readdir15,
|
|
476787
476822
|
readFile as readFile31,
|
|
476788
|
-
rm as
|
|
476823
|
+
rm as rm13,
|
|
476789
476824
|
stat as stat17,
|
|
476790
476825
|
writeFile as writeFile20
|
|
476791
476826
|
} from "node:fs/promises";
|
|
476792
|
-
import { basename as basename32, join as
|
|
476827
|
+
import { basename as basename32, join as join110 } from "node:path";
|
|
476793
476828
|
function fileTimestamp(startedAt) {
|
|
476794
476829
|
if (!startedAt)
|
|
476795
476830
|
return "unknown-date";
|
|
@@ -476859,7 +476894,7 @@ async function prepareOutDir(outDir) {
|
|
|
476859
476894
|
throw new Error(`--out ${outDir} is not empty and has no ${MANIFEST_NAME}; refusing to overwrite a directory this tool did not create`);
|
|
476860
476895
|
}
|
|
476861
476896
|
for (const entry of entries2) {
|
|
476862
|
-
await
|
|
476897
|
+
await rm13(join110(outDir, entry), { recursive: true, force: true });
|
|
476863
476898
|
}
|
|
476864
476899
|
} catch (error4) {
|
|
476865
476900
|
if (error4.code !== "ENOENT")
|
|
@@ -476902,14 +476937,14 @@ async function runTrajectoryExport(options) {
|
|
|
476902
476937
|
}
|
|
476903
476938
|
const sessionId = sessionHash(source, id);
|
|
476904
476939
|
const base2 = `${fileTimestamp(stats.startedAt)}_${sessionId}`;
|
|
476905
|
-
let file =
|
|
476940
|
+
let file = join110(source, `${base2}.json`);
|
|
476906
476941
|
for (let suffix = 2;usedFiles.has(file); suffix += 1) {
|
|
476907
|
-
file =
|
|
476942
|
+
file = join110(source, `${base2}-${suffix}.json`);
|
|
476908
476943
|
}
|
|
476909
476944
|
usedFiles.add(file);
|
|
476910
476945
|
const body3 = JSON.stringify(records2);
|
|
476911
|
-
await mkdir17(
|
|
476912
|
-
await writeFile20(
|
|
476946
|
+
await mkdir17(join110(options.outDir, source), { recursive: true });
|
|
476947
|
+
await writeFile20(join110(options.outDir, file), body3, "utf-8");
|
|
476913
476948
|
counts.exported += 1;
|
|
476914
476949
|
manifest2.sessions.push({
|
|
476915
476950
|
source,
|
|
@@ -476963,7 +476998,7 @@ async function runTrajectoryExport(options) {
|
|
|
476963
476998
|
await exportCheckpoint(checkpoint, `${basename32(checkpoint.path)}-${checkpoint.threadId}`);
|
|
476964
476999
|
}
|
|
476965
477000
|
manifest2.sessions.sort((a2, b3) => (a2.startedAt ?? "").localeCompare(b3.startedAt ?? ""));
|
|
476966
|
-
await writeFile20(
|
|
477001
|
+
await writeFile20(join110(options.outDir, MANIFEST_NAME), JSON.stringify(manifest2, null, 2), "utf-8");
|
|
476967
477002
|
return manifest2;
|
|
476968
477003
|
}
|
|
476969
477004
|
var MANIFEST_NAME = "manifest.json", FIRST_PROMPT_MAX_CHARS = 200, LIST_PAGE_LIMIT = 1000;
|
|
@@ -476975,13 +477010,13 @@ var init_export = __esm(() => {
|
|
|
476975
477010
|
|
|
476976
477011
|
// src/cli/subcommands/trajectories/review.ts
|
|
476977
477012
|
import { readFile as readFile32 } from "node:fs/promises";
|
|
476978
|
-
import { isAbsolute as
|
|
477013
|
+
import { isAbsolute as isAbsolute28, join as join111 } from "node:path";
|
|
476979
477014
|
async function readManifest(dir) {
|
|
476980
477015
|
let raw2;
|
|
476981
477016
|
try {
|
|
476982
|
-
raw2 = await readFile32(
|
|
477017
|
+
raw2 = await readFile32(join111(dir, "manifest.json"), "utf-8");
|
|
476983
477018
|
} catch {
|
|
476984
|
-
throw new Error(`No manifest at ${
|
|
477019
|
+
throw new Error(`No manifest at ${join111(dir, "manifest.json")}. Run: letta trajectories export --out ${dir}`);
|
|
476985
477020
|
}
|
|
476986
477021
|
return JSON.parse(raw2);
|
|
476987
477022
|
}
|
|
@@ -476990,7 +477025,7 @@ function filterSessions(sessions5, filter3) {
|
|
|
476990
477025
|
}
|
|
476991
477026
|
async function resolveSessionFile(dir, target) {
|
|
476992
477027
|
if (target.endsWith(".json")) {
|
|
476993
|
-
const direct =
|
|
477028
|
+
const direct = isAbsolute28(target) ? target : join111(dir, target);
|
|
476994
477029
|
try {
|
|
476995
477030
|
await readFile32(direct, "utf-8");
|
|
476996
477031
|
return direct;
|
|
@@ -477001,7 +477036,7 @@ async function resolveSessionFile(dir, target) {
|
|
|
477001
477036
|
if (!entry) {
|
|
477002
477037
|
throw new Error(`No session "${target}" in ${dir} (pass a file path, a manifest-relative file, or a sessionId)`);
|
|
477003
477038
|
}
|
|
477004
|
-
return
|
|
477039
|
+
return join111(dir, entry.file);
|
|
477005
477040
|
}
|
|
477006
477041
|
function stamp(timestamp) {
|
|
477007
477042
|
return (timestamp ?? "").slice(0, 19);
|
|
@@ -477044,7 +477079,7 @@ async function searchSessions(dir, keyword, options = {}) {
|
|
|
477044
477079
|
for (const session3 of filterSessions(manifest2.sessions, options)) {
|
|
477045
477080
|
let records2;
|
|
477046
477081
|
try {
|
|
477047
|
-
records2 = JSON.parse(await readFile32(
|
|
477082
|
+
records2 = JSON.parse(await readFile32(join111(dir, session3.file), "utf-8"));
|
|
477048
477083
|
} catch {
|
|
477049
477084
|
continue;
|
|
477050
477085
|
}
|
|
@@ -477380,8 +477415,8 @@ Current plan: ${balance.billing_tier}
|
|
|
477380
477415
|
* Quota Window End: ${quota.quotaWindowEnd}
|
|
477381
477416
|
* Daily Quota Window End: ${quota.dailyQuotaWindowEnd ?? "Unavailable"}
|
|
477382
477417
|
`;
|
|
477383
|
-
await new Promise((
|
|
477384
|
-
process.stdout.write(usage, (error4) => error4 ? reject2(error4) :
|
|
477418
|
+
await new Promise((resolve42, reject2) => {
|
|
477419
|
+
process.stdout.write(usage, (error4) => error4 ? reject2(error4) : resolve42());
|
|
477385
477420
|
});
|
|
477386
477421
|
return 0;
|
|
477387
477422
|
} catch (error4) {
|
|
@@ -481498,12 +481533,12 @@ function createRoutedRuntimeRegistrationRefresher(options) {
|
|
|
481498
481533
|
});
|
|
481499
481534
|
return run;
|
|
481500
481535
|
};
|
|
481501
|
-
const waitForRetry = () => new Promise((
|
|
481502
|
-
resolveRetry =
|
|
481536
|
+
const waitForRetry = () => new Promise((resolve42) => {
|
|
481537
|
+
resolveRetry = resolve42;
|
|
481503
481538
|
retryTimer = setTimeout(() => {
|
|
481504
481539
|
retryTimer = null;
|
|
481505
481540
|
resolveRetry = null;
|
|
481506
|
-
|
|
481541
|
+
resolve42();
|
|
481507
481542
|
}, retryDelayMs);
|
|
481508
481543
|
retryTimer.unref?.();
|
|
481509
481544
|
});
|
|
@@ -482139,7 +482174,7 @@ async function runChannelGatewaySubcommand(argv) {
|
|
|
482139
482174
|
await ensureChannelRuntimeInstalled2(channelName);
|
|
482140
482175
|
}
|
|
482141
482176
|
}
|
|
482142
|
-
return await new Promise((
|
|
482177
|
+
return await new Promise((resolve42) => {
|
|
482143
482178
|
let closing2 = false;
|
|
482144
482179
|
let closeGateway = null;
|
|
482145
482180
|
const finish2 = (code) => {
|
|
@@ -482147,10 +482182,10 @@ async function runChannelGatewaySubcommand(argv) {
|
|
|
482147
482182
|
return;
|
|
482148
482183
|
closing2 = true;
|
|
482149
482184
|
if (!closeGateway) {
|
|
482150
|
-
|
|
482185
|
+
resolve42(code);
|
|
482151
482186
|
return;
|
|
482152
482187
|
}
|
|
482153
|
-
closeGateway().finally(() =>
|
|
482188
|
+
closeGateway().finally(() => resolve42(code));
|
|
482154
482189
|
};
|
|
482155
482190
|
startLocalChannelGateway({
|
|
482156
482191
|
appServerUrl,
|
|
@@ -482198,7 +482233,7 @@ async function runChannelGatewaySubcommand(argv) {
|
|
|
482198
482233
|
gateway.close();
|
|
482199
482234
|
}).catch((error4) => {
|
|
482200
482235
|
console.error(error4 instanceof Error ? error4.message : String(error4));
|
|
482201
|
-
|
|
482236
|
+
resolve42(1);
|
|
482202
482237
|
});
|
|
482203
482238
|
});
|
|
482204
482239
|
}
|
|
@@ -482445,10 +482480,10 @@ async function detectAndEnableKittyProtocol() {
|
|
|
482445
482480
|
detectionComplete = true;
|
|
482446
482481
|
return;
|
|
482447
482482
|
}
|
|
482448
|
-
return new Promise((
|
|
482483
|
+
return new Promise((resolve42) => {
|
|
482449
482484
|
if (!process.stdin.isTTY || !process.stdout.isTTY) {
|
|
482450
482485
|
detectionComplete = true;
|
|
482451
|
-
|
|
482486
|
+
resolve42();
|
|
482452
482487
|
return;
|
|
482453
482488
|
}
|
|
482454
482489
|
const originalRawMode = process.stdin.isRaw;
|
|
@@ -482481,7 +482516,7 @@ async function detectAndEnableKittyProtocol() {
|
|
|
482481
482516
|
console.error("[kitty] protocol query unsupported; enabled anyway (best-effort)");
|
|
482482
482517
|
}
|
|
482483
482518
|
detectionComplete = true;
|
|
482484
|
-
|
|
482519
|
+
resolve42();
|
|
482485
482520
|
};
|
|
482486
482521
|
const handleData = (data) => {
|
|
482487
482522
|
if (timeoutId === undefined) {
|
|
@@ -483000,8 +483035,8 @@ async function waitForEnqueuedReply(params) {
|
|
|
483000
483035
|
let timer;
|
|
483001
483036
|
const event = await Promise.race([
|
|
483002
483037
|
next,
|
|
483003
|
-
new Promise((
|
|
483004
|
-
timer = setTimeout(() =>
|
|
483038
|
+
new Promise((resolve42) => {
|
|
483039
|
+
timer = setTimeout(() => resolve42(null), params.pollMs ?? 1000);
|
|
483005
483040
|
})
|
|
483006
483041
|
]).finally(() => clearTimeout(timer));
|
|
483007
483042
|
if (event) {
|
|
@@ -483378,7 +483413,7 @@ function resolveHeadlessMemfsPolicy(options) {
|
|
|
483378
483413
|
var init_headless_memfs_policy = () => {};
|
|
483379
483414
|
|
|
483380
483415
|
// src/headless-mod-adapter.ts
|
|
483381
|
-
import { join as
|
|
483416
|
+
import { join as join112 } from "node:path";
|
|
483382
483417
|
function isHeadlessMemfsEnabled(agentId) {
|
|
483383
483418
|
try {
|
|
483384
483419
|
return settingsManager.isMemfsEnabled(agentId);
|
|
@@ -483449,7 +483484,7 @@ function createHeadlessModContext(options) {
|
|
|
483449
483484
|
};
|
|
483450
483485
|
}
|
|
483451
483486
|
function createHeadlessModAdapter(options) {
|
|
483452
|
-
const agentModsDirectory = isHeadlessMemfsEnabled(options.agent.id) ?
|
|
483487
|
+
const agentModsDirectory = isHeadlessMemfsEnabled(options.agent.id) ? join112(getScopedMemoryFilesystemRoot(options.agent.id), "mods") : undefined;
|
|
483453
483488
|
return createModAdapter({
|
|
483454
483489
|
...agentModsDirectory ? { agentModsDirectory } : {},
|
|
483455
483490
|
...options.cacheDirectory ? { cacheDirectory: options.cacheDirectory } : {},
|
|
@@ -483571,9 +483606,9 @@ function writeWireMessage(msg) {
|
|
|
483571
483606
|
async function writeWireMessageAsync(msg) {
|
|
483572
483607
|
const line = `${JSON.stringify(stampWireMessage(msg))}
|
|
483573
483608
|
`;
|
|
483574
|
-
return await new Promise((
|
|
483609
|
+
return await new Promise((resolve42, reject2) => {
|
|
483575
483610
|
if (process.stdout.destroyed || process.stdout.writableEnded) {
|
|
483576
|
-
|
|
483611
|
+
resolve42(false);
|
|
483577
483612
|
return;
|
|
483578
483613
|
}
|
|
483579
483614
|
process.stdout.write(line, (error4) => {
|
|
@@ -483581,7 +483616,7 @@ async function writeWireMessageAsync(msg) {
|
|
|
483581
483616
|
reject2(error4);
|
|
483582
483617
|
return;
|
|
483583
483618
|
}
|
|
483584
|
-
|
|
483619
|
+
resolve42(true);
|
|
483585
483620
|
});
|
|
483586
483621
|
});
|
|
483587
483622
|
}
|
|
@@ -483972,10 +484007,10 @@ async function sendScopedApprovalMessages(params) {
|
|
|
483972
484007
|
}
|
|
483973
484008
|
async function flushAndExit(code) {
|
|
483974
484009
|
await shutdownMonitors();
|
|
483975
|
-
const flushWritable = (stream11) => new Promise((
|
|
484010
|
+
const flushWritable = (stream11) => new Promise((resolve42) => {
|
|
483976
484011
|
if (stream11.destroyed || stream11.writableEnded)
|
|
483977
|
-
return
|
|
483978
|
-
stream11.write("", () =>
|
|
484012
|
+
return resolve42();
|
|
484013
|
+
stream11.write("", () => resolve42());
|
|
483979
484014
|
});
|
|
483980
484015
|
await closeClientMcpServers();
|
|
483981
484016
|
await Promise.allSettled([
|
|
@@ -483985,12 +484020,12 @@ async function flushAndExit(code) {
|
|
|
483985
484020
|
process.exit(code);
|
|
483986
484021
|
}
|
|
483987
484022
|
async function writeFinalHeadlessStdout(text3) {
|
|
483988
|
-
await new Promise((
|
|
484023
|
+
await new Promise((resolve42) => {
|
|
483989
484024
|
if (process.stdout.destroyed || process.stdout.writableEnded) {
|
|
483990
|
-
|
|
484025
|
+
resolve42();
|
|
483991
484026
|
return;
|
|
483992
484027
|
}
|
|
483993
|
-
process.stdout.write(text3, () =>
|
|
484028
|
+
process.stdout.write(text3, () => resolve42());
|
|
483994
484029
|
});
|
|
483995
484030
|
}
|
|
483996
484031
|
async function handleHeadlessCommand(parsedArgs, model2, skillsDirectoryOverride, skillSourcesOverride, systemInfoReminderEnabledOverride, startupOptions = {}) {
|
|
@@ -485105,7 +485140,7 @@ Current session AGENT_ID=${process.env.AGENT_ID}; --backend local switches to a
|
|
|
485105
485140
|
} else {
|
|
485106
485141
|
console.error(`Conversation is busy, waiting ${Math.round(retryDelayMs / 1000)}s and retrying...`);
|
|
485107
485142
|
}
|
|
485108
|
-
await new Promise((
|
|
485143
|
+
await new Promise((resolve42) => setTimeout(resolve42, retryDelayMs));
|
|
485109
485144
|
continue;
|
|
485110
485145
|
}
|
|
485111
485146
|
}
|
|
@@ -485134,7 +485169,7 @@ Current session AGENT_ID=${process.env.AGENT_ID}; --backend local switches to a
|
|
|
485134
485169
|
const delaySeconds = Math.round(delayMs / 1000);
|
|
485135
485170
|
console.error(`Transient API error before streaming (attempt ${attempt2} of ${LLM_API_ERROR_MAX_RETRIES2}), retrying in ${delaySeconds}s...`);
|
|
485136
485171
|
}
|
|
485137
|
-
await new Promise((
|
|
485172
|
+
await new Promise((resolve42) => setTimeout(resolve42, delayMs));
|
|
485138
485173
|
conversationBusyRetries = 0;
|
|
485139
485174
|
continue;
|
|
485140
485175
|
}
|
|
@@ -485384,7 +485419,7 @@ Current session AGENT_ID=${process.env.AGENT_ID}; --backend local switches to a
|
|
|
485384
485419
|
const delaySeconds = Math.round(delayMs / 1000);
|
|
485385
485420
|
console.error(`LLM API error encountered (attempt ${attempt2} of ${LLM_API_ERROR_MAX_RETRIES2}), retrying in ${delaySeconds}s...`);
|
|
485386
485421
|
}
|
|
485387
|
-
await new Promise((
|
|
485422
|
+
await new Promise((resolve42) => setTimeout(resolve42, delayMs));
|
|
485388
485423
|
currentInput = refreshInputOtidsForNewRequest(currentInput);
|
|
485389
485424
|
continue;
|
|
485390
485425
|
}
|
|
@@ -485476,7 +485511,7 @@ Current session AGENT_ID=${process.env.AGENT_ID}; --backend local switches to a
|
|
|
485476
485511
|
} else {
|
|
485477
485512
|
console.error(`Empty LLM response, retrying (attempt ${attempt2} of ${EMPTY_RESPONSE_MAX_RETRIES2})...`);
|
|
485478
485513
|
}
|
|
485479
|
-
await new Promise((
|
|
485514
|
+
await new Promise((resolve42) => setTimeout(resolve42, delayMs));
|
|
485480
485515
|
currentInput = refreshInputOtidsForNewRequest(currentInput);
|
|
485481
485516
|
continue;
|
|
485482
485517
|
}
|
|
@@ -485504,7 +485539,7 @@ Current session AGENT_ID=${process.env.AGENT_ID}; --backend local switches to a
|
|
|
485504
485539
|
const delaySeconds = Math.round(delayMs / 1000);
|
|
485505
485540
|
console.error(`LLM API error encountered (attempt ${attempt2} of ${LLM_API_ERROR_MAX_RETRIES2}), retrying in ${delaySeconds}s...`);
|
|
485506
485541
|
}
|
|
485507
|
-
await new Promise((
|
|
485542
|
+
await new Promise((resolve42) => setTimeout(resolve42, delayMs));
|
|
485508
485543
|
currentInput = refreshInputOtidsForNewRequest(currentInput);
|
|
485509
485544
|
continue;
|
|
485510
485545
|
}
|
|
@@ -485534,7 +485569,7 @@ Current session AGENT_ID=${process.env.AGENT_ID}; --backend local switches to a
|
|
|
485534
485569
|
const delaySeconds = Math.round(delayMs / 1000);
|
|
485535
485570
|
console.error(`LLM API error encountered (attempt ${attempt2} of ${LLM_API_ERROR_MAX_RETRIES2}), retrying in ${delaySeconds}s...`);
|
|
485536
485571
|
}
|
|
485537
|
-
await new Promise((
|
|
485572
|
+
await new Promise((resolve42) => setTimeout(resolve42, delayMs));
|
|
485538
485573
|
currentInput = refreshInputOtidsForNewRequest(currentInput);
|
|
485539
485574
|
continue;
|
|
485540
485575
|
}
|
|
@@ -485934,9 +485969,9 @@ async function runBidirectionalMode(agent, conversationId, effectiveModel, _outp
|
|
|
485934
485969
|
const syntheticUserLine = serializeQueuedMessageAsUserLine(queuedMessage);
|
|
485935
485970
|
maybeNotifyBlocked(syntheticUserLine);
|
|
485936
485971
|
if (lineResolver) {
|
|
485937
|
-
const
|
|
485972
|
+
const resolve42 = lineResolver;
|
|
485938
485973
|
lineResolver = null;
|
|
485939
|
-
|
|
485974
|
+
resolve42(syntheticUserLine);
|
|
485940
485975
|
return;
|
|
485941
485976
|
}
|
|
485942
485977
|
lineQueue.push(syntheticUserLine);
|
|
@@ -485956,9 +485991,9 @@ async function runBidirectionalMode(agent, conversationId, effectiveModel, _outp
|
|
|
485956
485991
|
if (action === "abort-active") {
|
|
485957
485992
|
currentAbortController.abort();
|
|
485958
485993
|
if (lineResolver) {
|
|
485959
|
-
const
|
|
485994
|
+
const resolve42 = lineResolver;
|
|
485960
485995
|
lineResolver = null;
|
|
485961
|
-
|
|
485996
|
+
resolve42(null);
|
|
485962
485997
|
}
|
|
485963
485998
|
} else if (action === "latch") {
|
|
485964
485999
|
pendingInterrupt = true;
|
|
@@ -485978,9 +486013,9 @@ async function runBidirectionalMode(agent, conversationId, effectiveModel, _outp
|
|
|
485978
486013
|
if (lineResolver) {
|
|
485979
486014
|
if (parsedLine?.type === "user")
|
|
485980
486015
|
turnStarting = true;
|
|
485981
|
-
const
|
|
486016
|
+
const resolve42 = lineResolver;
|
|
485982
486017
|
lineResolver = null;
|
|
485983
|
-
|
|
486018
|
+
resolve42(line);
|
|
485984
486019
|
} else {
|
|
485985
486020
|
lineQueue.push(line);
|
|
485986
486021
|
}
|
|
@@ -485989,17 +486024,17 @@ async function runBidirectionalMode(agent, conversationId, effectiveModel, _outp
|
|
|
485989
486024
|
setMessageQueueAdder(null);
|
|
485990
486025
|
msgQueueRuntime.clear("shutdown");
|
|
485991
486026
|
if (lineResolver) {
|
|
485992
|
-
const
|
|
486027
|
+
const resolve42 = lineResolver;
|
|
485993
486028
|
lineResolver = null;
|
|
485994
|
-
|
|
486029
|
+
resolve42(null);
|
|
485995
486030
|
}
|
|
485996
486031
|
});
|
|
485997
486032
|
async function getNextLine() {
|
|
485998
486033
|
if (lineQueue.length > 0) {
|
|
485999
486034
|
return lineQueue.shift() ?? null;
|
|
486000
486035
|
}
|
|
486001
|
-
return new Promise((
|
|
486002
|
-
lineResolver =
|
|
486036
|
+
return new Promise((resolve42) => {
|
|
486037
|
+
lineResolver = resolve42;
|
|
486003
486038
|
});
|
|
486004
486039
|
}
|
|
486005
486040
|
const EXTERNAL_TOOL_WAIT_ABORTED = Symbol("externalToolWaitAborted");
|
|
@@ -486010,17 +486045,17 @@ async function runBidirectionalMode(agent, conversationId, effectiveModel, _outp
|
|
|
486010
486045
|
return lineQueue.shift() ?? null;
|
|
486011
486046
|
if (!signal)
|
|
486012
486047
|
return getNextLine();
|
|
486013
|
-
return new Promise((
|
|
486048
|
+
return new Promise((resolve42) => {
|
|
486014
486049
|
const cleanup = () => signal.removeEventListener("abort", onAbort);
|
|
486015
486050
|
const onAbort = () => {
|
|
486016
486051
|
cleanup();
|
|
486017
486052
|
if (lineResolver === settle3)
|
|
486018
486053
|
lineResolver = null;
|
|
486019
|
-
|
|
486054
|
+
resolve42(EXTERNAL_TOOL_WAIT_ABORTED);
|
|
486020
486055
|
};
|
|
486021
486056
|
const settle3 = (line) => {
|
|
486022
486057
|
cleanup();
|
|
486023
|
-
|
|
486058
|
+
resolve42(line);
|
|
486024
486059
|
};
|
|
486025
486060
|
signal.addEventListener("abort", onAbort);
|
|
486026
486061
|
lineResolver = settle3;
|
|
@@ -486548,7 +486583,7 @@ async function runBidirectionalMode(agent, conversationId, effectiveModel, _outp
|
|
|
486548
486583
|
uuid: `retry-bidir-${randomUUID66()}`
|
|
486549
486584
|
};
|
|
486550
486585
|
writeWireMessage(retryMsg);
|
|
486551
|
-
await new Promise((
|
|
486586
|
+
await new Promise((resolve42) => setTimeout(resolve42, delayMs));
|
|
486552
486587
|
continue;
|
|
486553
486588
|
}
|
|
486554
486589
|
throw preStreamError;
|
|
@@ -487298,7 +487333,7 @@ var BYTES_PER_TOKEN = 4;
|
|
|
487298
487333
|
|
|
487299
487334
|
// src/cli/helpers/window-title-config.ts
|
|
487300
487335
|
import { homedir as homedir33 } from "node:os";
|
|
487301
|
-
import { basename as basename33, resolve as
|
|
487336
|
+
import { basename as basename33, resolve as resolve42 } from "node:path";
|
|
487302
487337
|
function isWindowTitleField(value) {
|
|
487303
487338
|
return WINDOW_TITLE_FIELDS.includes(value);
|
|
487304
487339
|
}
|
|
@@ -487456,7 +487491,7 @@ function terminalTitleProjectName(data) {
|
|
|
487456
487491
|
const directory = titleDirectory(data);
|
|
487457
487492
|
if (!directory)
|
|
487458
487493
|
return null;
|
|
487459
|
-
const resolved =
|
|
487494
|
+
const resolved = resolve42(directory);
|
|
487460
487495
|
const name = basename33(resolved) || formatDirectoryDisplay(resolved) || resolved;
|
|
487461
487496
|
return truncateTerminalTitlePart(name, 24);
|
|
487462
487497
|
}
|
|
@@ -487466,7 +487501,7 @@ function titleDirectory(data) {
|
|
|
487466
487501
|
function formatDirectoryDisplay(directory) {
|
|
487467
487502
|
if (!directory)
|
|
487468
487503
|
return null;
|
|
487469
|
-
const resolved =
|
|
487504
|
+
const resolved = resolve42(directory);
|
|
487470
487505
|
const home = homedir33();
|
|
487471
487506
|
if (resolved === home)
|
|
487472
487507
|
return "~";
|
|
@@ -488142,10 +488177,10 @@ import { execFile as execFileCb4 } from "node:child_process";
|
|
|
488142
488177
|
import { existsSync as existsSync75 } from "node:fs";
|
|
488143
488178
|
import { appendFile as appendFile3, chmod, mkdir as mkdir18, writeFile as writeFile21 } from "node:fs/promises";
|
|
488144
488179
|
import { homedir as homedir34 } from "node:os";
|
|
488145
|
-
import { join as
|
|
488180
|
+
import { join as join114 } from "node:path";
|
|
488146
488181
|
import { promisify as promisify20 } from "node:util";
|
|
488147
488182
|
function getReflectionArenaHfCacheRoot(env6 = process.env, fallbackHome = homedir34()) {
|
|
488148
|
-
return
|
|
488183
|
+
return join114(resolveGlobalConfigDir(env6, fallbackHome), "reflection-arena", "hf-upload");
|
|
488149
488184
|
}
|
|
488150
488185
|
function buildGitEnv(token2, askpassPath) {
|
|
488151
488186
|
return {
|
|
@@ -488181,7 +488216,7 @@ async function runGit6(cwd2, args, env6) {
|
|
|
488181
488216
|
}
|
|
488182
488217
|
}
|
|
488183
488218
|
async function writeGitAskpass(repoRoot) {
|
|
488184
|
-
const askpassPath =
|
|
488219
|
+
const askpassPath = join114(repoRoot, "hf-askpass.sh");
|
|
488185
488220
|
await writeFile21(askpassPath, [
|
|
488186
488221
|
"#!/bin/sh",
|
|
488187
488222
|
'case "$1" in',
|
|
@@ -488196,7 +488231,7 @@ async function writeGitAskpass(repoRoot) {
|
|
|
488196
488231
|
}
|
|
488197
488232
|
async function prepareHfRepo(env6) {
|
|
488198
488233
|
await mkdir18(HF_CACHE_ROOT, { recursive: true });
|
|
488199
|
-
if (!existsSync75(
|
|
488234
|
+
if (!existsSync75(join114(HF_REPO_DIR, ".git"))) {
|
|
488200
488235
|
await runGit6(HF_CACHE_ROOT, ["clone", "--depth", "1", HF_REPO_URL, HF_REPO_DIR], env6);
|
|
488201
488236
|
return HF_REPO_DIR;
|
|
488202
488237
|
}
|
|
@@ -488231,8 +488266,8 @@ async function maybeUploadReflectionArenaChoiceToHf(row) {
|
|
|
488231
488266
|
const env6 = buildGitEnv(token2, askpassPath);
|
|
488232
488267
|
try {
|
|
488233
488268
|
const repoDir = await prepareHfRepo(env6);
|
|
488234
|
-
await mkdir18(
|
|
488235
|
-
await appendFile3(
|
|
488269
|
+
await mkdir18(join114(repoDir, "data"), { recursive: true });
|
|
488270
|
+
await appendFile3(join114(repoDir, HF_DATASET_PATH), `${JSON.stringify(row)}
|
|
488236
488271
|
`, {
|
|
488237
488272
|
encoding: "utf-8"
|
|
488238
488273
|
});
|
|
@@ -488262,14 +488297,14 @@ var init_reflection_arena_hf_upload = __esm(() => {
|
|
|
488262
488297
|
execFile23 = promisify20(execFileCb4);
|
|
488263
488298
|
HF_REPO_URL = `https://huggingface.co/datasets/${HF_REPO_ID}`;
|
|
488264
488299
|
HF_CACHE_ROOT = getReflectionArenaHfCacheRoot();
|
|
488265
|
-
HF_REPO_DIR =
|
|
488300
|
+
HF_REPO_DIR = join114(HF_CACHE_ROOT, "repo");
|
|
488266
488301
|
});
|
|
488267
488302
|
|
|
488268
488303
|
// src/cli/helpers/reflection-arena.ts
|
|
488269
488304
|
import { execFile as execFileCb5 } from "node:child_process";
|
|
488270
488305
|
import { randomInt as randomInt2, randomUUID as randomUUID67 } from "node:crypto";
|
|
488271
488306
|
import { appendFile as appendFile4, mkdir as mkdir19, readFile as readFile34, writeFile as writeFile22 } from "node:fs/promises";
|
|
488272
|
-
import { join as
|
|
488307
|
+
import { join as join115 } from "node:path";
|
|
488273
488308
|
import { promisify as promisify21 } from "node:util";
|
|
488274
488309
|
function sampleReflectionArenaComparisonModel(excludedModels = []) {
|
|
488275
488310
|
const excluded = new Set(excludedModels);
|
|
@@ -488318,16 +488353,16 @@ function candidateIsConfirmedNoOp(candidate) {
|
|
|
488318
488353
|
return candidate.result?.success === true && candidate.result.memoryNoChanges === true && candidate.result.memoryHead === candidate.worktree.baseHead;
|
|
488319
488354
|
}
|
|
488320
488355
|
function getReflectionArenaRoot() {
|
|
488321
|
-
return
|
|
488356
|
+
return join115(resolveGlobalConfigDir(), "reflection-arena");
|
|
488322
488357
|
}
|
|
488323
488358
|
function getReflectionArenaRunsDir() {
|
|
488324
|
-
return
|
|
488359
|
+
return join115(getReflectionArenaRoot(), "runs");
|
|
488325
488360
|
}
|
|
488326
488361
|
function getReflectionArenaChoiceLogPath() {
|
|
488327
|
-
return
|
|
488362
|
+
return join115(getReflectionArenaRoot(), "choices.jsonl");
|
|
488328
488363
|
}
|
|
488329
488364
|
function getReflectionArenaRunPath(runId) {
|
|
488330
|
-
return
|
|
488365
|
+
return join115(getReflectionArenaRunsDir(), `${runId}.json`);
|
|
488331
488366
|
}
|
|
488332
488367
|
async function saveReflectionArenaRun(run) {
|
|
488333
488368
|
await mkdir19(getReflectionArenaRunsDir(), { recursive: true });
|
|
@@ -489387,8 +489422,8 @@ async function pushToMemoryRepositoryWithTimeout(agentId) {
|
|
|
489387
489422
|
try {
|
|
489388
489423
|
return await Promise.race([
|
|
489389
489424
|
pushToMemoryRepository(agentId),
|
|
489390
|
-
new Promise((
|
|
489391
|
-
timeout = setTimeout(() =>
|
|
489425
|
+
new Promise((resolve43) => {
|
|
489426
|
+
timeout = setTimeout(() => resolve43("timeout"), INITIAL_PUSH_TIMEOUT_MS);
|
|
489392
489427
|
})
|
|
489393
489428
|
]);
|
|
489394
489429
|
} finally {
|
|
@@ -489868,7 +489903,7 @@ import {
|
|
|
489868
489903
|
writeFileSync as writeFileSync50
|
|
489869
489904
|
} from "node:fs";
|
|
489870
489905
|
import { homedir as homedir35, platform as platform10 } from "node:os";
|
|
489871
|
-
import { dirname as dirname43, join as
|
|
489906
|
+
import { dirname as dirname43, join as join116 } from "node:path";
|
|
489872
489907
|
function detectTerminalType() {
|
|
489873
489908
|
if (process.env.CURSOR_TRACE_ID || process.env.CURSOR_CHANNEL) {
|
|
489874
489909
|
return "cursor";
|
|
@@ -489900,16 +489935,16 @@ function getKeybindingsPath(terminal) {
|
|
|
489900
489935
|
}[terminal];
|
|
489901
489936
|
const os7 = platform10();
|
|
489902
489937
|
if (os7 === "darwin") {
|
|
489903
|
-
return
|
|
489938
|
+
return join116(homedir35(), "Library", "Application Support", appName, "User", "keybindings.json");
|
|
489904
489939
|
}
|
|
489905
489940
|
if (os7 === "win32") {
|
|
489906
489941
|
const appData = process.env.APPDATA;
|
|
489907
489942
|
if (!appData)
|
|
489908
489943
|
return null;
|
|
489909
|
-
return
|
|
489944
|
+
return join116(appData, appName, "User", "keybindings.json");
|
|
489910
489945
|
}
|
|
489911
489946
|
if (os7 === "linux") {
|
|
489912
|
-
return
|
|
489947
|
+
return join116(homedir35(), ".config", appName, "User", "keybindings.json");
|
|
489913
489948
|
}
|
|
489914
489949
|
return null;
|
|
489915
489950
|
}
|
|
@@ -490062,14 +490097,14 @@ function getWezTermConfigPath() {
|
|
|
490062
490097
|
}
|
|
490063
490098
|
const xdgConfig = process.env.XDG_CONFIG_HOME;
|
|
490064
490099
|
if (xdgConfig) {
|
|
490065
|
-
const xdgPath =
|
|
490100
|
+
const xdgPath = join116(xdgConfig, "wezterm", "wezterm.lua");
|
|
490066
490101
|
if (existsSync76(xdgPath))
|
|
490067
490102
|
return xdgPath;
|
|
490068
490103
|
}
|
|
490069
|
-
const configPath =
|
|
490104
|
+
const configPath = join116(homedir35(), ".config", "wezterm", "wezterm.lua");
|
|
490070
490105
|
if (existsSync76(configPath))
|
|
490071
490106
|
return configPath;
|
|
490072
|
-
return
|
|
490107
|
+
return join116(homedir35(), ".wezterm.lua");
|
|
490073
490108
|
}
|
|
490074
490109
|
function stripLuaCommentsFromLine(line, blockCommentEnd) {
|
|
490075
490110
|
let code = "";
|
|
@@ -490247,7 +490282,7 @@ __export(exports_settings, {
|
|
|
490247
490282
|
loadProjectSettings: () => loadProjectSettings,
|
|
490248
490283
|
getSetting: () => getSetting
|
|
490249
490284
|
});
|
|
490250
|
-
import { join as
|
|
490285
|
+
import { join as join117 } from "node:path";
|
|
490251
490286
|
function getSettingsPath() {
|
|
490252
490287
|
return resolveGlobalSettingsPath();
|
|
490253
490288
|
}
|
|
@@ -490289,7 +490324,7 @@ async function getSetting(key4) {
|
|
|
490289
490324
|
return settings[key4];
|
|
490290
490325
|
}
|
|
490291
490326
|
function getProjectSettingsPath() {
|
|
490292
|
-
return
|
|
490327
|
+
return join117(process.cwd(), ".letta", "settings.local.json");
|
|
490293
490328
|
}
|
|
490294
490329
|
async function loadProjectSettings() {
|
|
490295
490330
|
if (shouldIsolateHomeProjectConfig(process.cwd()))
|
|
@@ -490311,7 +490346,7 @@ async function saveProjectSettings(settings) {
|
|
|
490311
490346
|
if (shouldIsolateHomeProjectConfig(process.cwd()))
|
|
490312
490347
|
return;
|
|
490313
490348
|
const settingsPath = getProjectSettingsPath();
|
|
490314
|
-
const dirPath =
|
|
490349
|
+
const dirPath = join117(process.cwd(), ".letta");
|
|
490315
490350
|
try {
|
|
490316
490351
|
if (!exists(dirPath)) {
|
|
490317
490352
|
await mkdir(dirPath, { recursive: true });
|
|
@@ -491376,10 +491411,10 @@ var init_InlineBashApproval = __esm(async () => {
|
|
|
491376
491411
|
});
|
|
491377
491412
|
|
|
491378
491413
|
// src/cli/components/DiffRenderer.tsx
|
|
491379
|
-
import { relative as
|
|
491414
|
+
import { relative as relative12 } from "node:path";
|
|
491380
491415
|
function formatDisplayPath4(filePath) {
|
|
491381
491416
|
const cwd2 = process.cwd();
|
|
491382
|
-
const relativePath =
|
|
491417
|
+
const relativePath = relative12(cwd2, filePath);
|
|
491383
491418
|
if (relativePath.startsWith("..")) {
|
|
491384
491419
|
return filePath;
|
|
491385
491420
|
}
|
|
@@ -491738,10 +491773,10 @@ var init_DiffRenderer = __esm(async () => {
|
|
|
491738
491773
|
});
|
|
491739
491774
|
|
|
491740
491775
|
// src/cli/components/AdvancedDiffRenderer.tsx
|
|
491741
|
-
import { relative as
|
|
491776
|
+
import { relative as relative13 } from "node:path";
|
|
491742
491777
|
function formatRelativePath(filePath) {
|
|
491743
491778
|
const cwd2 = process.cwd();
|
|
491744
|
-
const relativePath =
|
|
491779
|
+
const relativePath = relative13(cwd2, filePath);
|
|
491745
491780
|
return relativePath.startsWith("..") ? relativePath : `./${relativePath}`;
|
|
491746
491781
|
}
|
|
491747
491782
|
function padLeft(n, width) {
|
|
@@ -492004,7 +492039,7 @@ function AdvancedDiffRenderer(props) {
|
|
|
492004
492039
|
}
|
|
492005
492040
|
const { hunks } = result3;
|
|
492006
492041
|
const filePath = props.filePath;
|
|
492007
|
-
const
|
|
492042
|
+
const relative14 = formatRelativePath(filePath);
|
|
492008
492043
|
const lang = languageFromPath(filePath);
|
|
492009
492044
|
const shouldHighlight = lang && !exceedsAdvancedDiffHighlightLimits(hunks);
|
|
492010
492045
|
const hunkSyntaxLines = [];
|
|
@@ -492027,7 +492062,7 @@ function AdvancedDiffRenderer(props) {
|
|
|
492027
492062
|
const rows = buildAdvancedDiffRows(hunks, hunkSyntaxLines);
|
|
492028
492063
|
const maxDisplayNo = rows.reduce((m4, r5) => Math.max(m4, r5.displayNo), 1);
|
|
492029
492064
|
const gutterWidth = String(maxDisplayNo).length;
|
|
492030
|
-
const header = props.kind === "write" ? `Wrote changes to ${
|
|
492065
|
+
const header = props.kind === "write" ? `Wrote changes to ${relative14}` : `Updated ${relative14}`;
|
|
492031
492066
|
if (rows.length === 0) {
|
|
492032
492067
|
const noChangesGutter = 4;
|
|
492033
492068
|
return /* @__PURE__ */ jsx_dev_runtime24.jsxDEV(Box_default, {
|
|
@@ -492078,7 +492113,7 @@ function AdvancedDiffRenderer(props) {
|
|
|
492078
492113
|
"No changes to ",
|
|
492079
492114
|
/* @__PURE__ */ jsx_dev_runtime24.jsxDEV(Text2, {
|
|
492080
492115
|
bold: true,
|
|
492081
|
-
children:
|
|
492116
|
+
children: relative14
|
|
492082
492117
|
}, undefined, false, undefined, this),
|
|
492083
492118
|
" (file content identical)"
|
|
492084
492119
|
]
|
|
@@ -492184,9 +492219,9 @@ function getHeaderText(fileEdit) {
|
|
|
492184
492219
|
} else if (operations2.length === 1) {
|
|
492185
492220
|
const op = operations2[0];
|
|
492186
492221
|
if (op) {
|
|
492187
|
-
const { relative:
|
|
492222
|
+
const { relative: relative15 } = __require("node:path");
|
|
492188
492223
|
const cwd3 = process.cwd();
|
|
492189
|
-
const relPath2 =
|
|
492224
|
+
const relPath2 = relative15(cwd3, op.path);
|
|
492190
492225
|
const displayPath2 = relPath2.startsWith("..") ? op.path : relPath2;
|
|
492191
492226
|
if (op.kind === "add") {
|
|
492192
492227
|
return `Write to ${displayPath2}?`;
|
|
@@ -492200,9 +492235,9 @@ function getHeaderText(fileEdit) {
|
|
|
492200
492235
|
}
|
|
492201
492236
|
return "Apply patch?";
|
|
492202
492237
|
}
|
|
492203
|
-
const { relative:
|
|
492238
|
+
const { relative: relative14 } = __require("node:path");
|
|
492204
492239
|
const cwd2 = process.cwd();
|
|
492205
|
-
const relPath =
|
|
492240
|
+
const relPath = relative14(cwd2, fileEdit.filePath);
|
|
492206
492241
|
const displayPath = relPath.startsWith("..") ? fileEdit.filePath : relPath;
|
|
492207
492242
|
if (t2 === "write") {
|
|
492208
492243
|
const { existsSync: existsSync77 } = __require("node:fs");
|
|
@@ -492375,9 +492410,9 @@ var init_InlineFileEditApproval = __esm(async () => {
|
|
|
492375
492410
|
children: fileEdit.patchInput ? /* @__PURE__ */ jsx_dev_runtime25.jsxDEV(Box_default, {
|
|
492376
492411
|
flexDirection: "column",
|
|
492377
492412
|
children: parsePatchOperations(fileEdit.patchInput).map((op, idx) => {
|
|
492378
|
-
const { relative:
|
|
492413
|
+
const { relative: relative14 } = __require("node:path");
|
|
492379
492414
|
const cwd2 = process.cwd();
|
|
492380
|
-
const relPath =
|
|
492415
|
+
const relPath = relative14(cwd2, op.path);
|
|
492381
492416
|
const displayPath = relPath.startsWith("..") ? op.path : relPath;
|
|
492382
492417
|
const diffKey = fileEdit.toolCallId ? `${fileEdit.toolCallId}:${op.path}` : undefined;
|
|
492383
492418
|
const opDiff = diffKey && allDiffs ? allDiffs.get(diffKey) : undefined;
|
|
@@ -501121,7 +501156,7 @@ var init_InputRich = __esm(async () => {
|
|
|
501121
501156
|
});
|
|
501122
501157
|
|
|
501123
501158
|
// src/cli/commands/install-github-app.ts
|
|
501124
|
-
import { execFileSync as
|
|
501159
|
+
import { execFileSync as execFileSync12 } from "node:child_process";
|
|
501125
501160
|
import {
|
|
501126
501161
|
existsSync as existsSync77,
|
|
501127
501162
|
mkdirSync as mkdirSync59,
|
|
@@ -501131,10 +501166,10 @@ import {
|
|
|
501131
501166
|
writeFileSync as writeFileSync51
|
|
501132
501167
|
} from "node:fs";
|
|
501133
501168
|
import { tmpdir as tmpdir16 } from "node:os";
|
|
501134
|
-
import { dirname as dirname44, join as
|
|
501169
|
+
import { dirname as dirname44, join as join118 } from "node:path";
|
|
501135
501170
|
function runCommand(command, args, cwd2, input) {
|
|
501136
501171
|
try {
|
|
501137
|
-
return
|
|
501172
|
+
return execFileSync12(command, args, {
|
|
501138
501173
|
cwd: cwd2,
|
|
501139
501174
|
encoding: "utf8",
|
|
501140
501175
|
stdio: [input ? "pipe" : "ignore", "pipe", "pipe"],
|
|
@@ -501352,8 +501387,8 @@ async function createLettaAgent(apiKey, name) {
|
|
|
501352
501387
|
return createMinimalAgent(apiKey, name);
|
|
501353
501388
|
}
|
|
501354
501389
|
function cloneRepoToTemp(repo) {
|
|
501355
|
-
const tempDir = mkdtempSync7(
|
|
501356
|
-
const repoDir =
|
|
501390
|
+
const tempDir = mkdtempSync7(join118(tmpdir16(), "letta-install-github-app-"));
|
|
501391
|
+
const repoDir = join118(tempDir, "repo");
|
|
501357
501392
|
runCommand("gh", ["repo", "clone", repo, repoDir, "--", "--depth=1"]);
|
|
501358
501393
|
return { tempDir, repoDir };
|
|
501359
501394
|
}
|
|
@@ -501364,7 +501399,7 @@ function runGit7(args, cwd2) {
|
|
|
501364
501399
|
return runCommand("git", args, cwd2);
|
|
501365
501400
|
}
|
|
501366
501401
|
function writeWorkflow(repoDir, workflowPath, content) {
|
|
501367
|
-
const absolutePath =
|
|
501402
|
+
const absolutePath = join118(repoDir, workflowPath);
|
|
501368
501403
|
if (!existsSync77(dirname44(absolutePath))) {
|
|
501369
501404
|
mkdirSync59(dirname44(absolutePath), { recursive: true });
|
|
501370
501405
|
}
|
|
@@ -505254,7 +505289,7 @@ __export(exports_generate_memory_viewer, {
|
|
|
505254
505289
|
});
|
|
505255
505290
|
import { execFile as execFileCb6 } from "node:child_process";
|
|
505256
505291
|
import { chmodSync as chmodSync11, existsSync as existsSync78, mkdirSync as mkdirSync60, writeFileSync as writeFileSync52 } from "node:fs";
|
|
505257
|
-
import { join as
|
|
505292
|
+
import { join as join119 } from "node:path";
|
|
505258
505293
|
import { promisify as promisify22 } from "node:util";
|
|
505259
505294
|
function messagesFromOverview(overview) {
|
|
505260
505295
|
return overview.messages?.map((message2) => ({
|
|
@@ -505564,7 +505599,7 @@ ${m4.body}` : m4.subject;
|
|
|
505564
505599
|
async function generateAndOpenMemoryViewer(agentId, options) {
|
|
505565
505600
|
const memoryRoot = getScopedMemoryFilesystemRoot(agentId);
|
|
505566
505601
|
const repoDir = memoryRoot;
|
|
505567
|
-
if (!existsSync78(
|
|
505602
|
+
if (!existsSync78(join119(repoDir, ".git"))) {
|
|
505568
505603
|
throw new Error("Memory viewer requires memfs. Run /memfs enable first.");
|
|
505569
505604
|
}
|
|
505570
505605
|
const data = await collectMemoryData(agentId, repoDir, memoryRoot, options?.conversationId);
|
|
@@ -505580,7 +505615,7 @@ async function generateAndOpenMemoryViewer(agentId, options) {
|
|
|
505580
505615
|
try {
|
|
505581
505616
|
chmodSync11(VIEWERS_DIR, 448);
|
|
505582
505617
|
} catch {}
|
|
505583
|
-
const filePath =
|
|
505618
|
+
const filePath = join119(VIEWERS_DIR, `memory-${encodeURIComponent(agentId)}.html`);
|
|
505584
505619
|
writeFileSync52(filePath, html5);
|
|
505585
505620
|
chmodSync11(filePath, 384);
|
|
505586
505621
|
const skipOpen = Boolean(process.env.TMUX) || Boolean(process.env.SSH_CONNECTION) || Boolean(process.env.SSH_TTY);
|
|
@@ -505608,13 +505643,13 @@ var init_generate_memory_viewer = __esm(() => {
|
|
|
505608
505643
|
init_local_memory_context();
|
|
505609
505644
|
init_memory_viewer_template();
|
|
505610
505645
|
execFile25 = promisify22(execFileCb6);
|
|
505611
|
-
VIEWERS_DIR =
|
|
505646
|
+
VIEWERS_DIR = join119(resolveGlobalConfigDir(), "viewers");
|
|
505612
505647
|
REFLECTION_PATTERN = /\(reflection\)|🔮|reflection:/i;
|
|
505613
505648
|
});
|
|
505614
505649
|
|
|
505615
505650
|
// src/cli/components/MemfsTreeViewer.tsx
|
|
505616
505651
|
import { existsSync as existsSync79 } from "node:fs";
|
|
505617
|
-
import { join as
|
|
505652
|
+
import { join as join120 } from "node:path";
|
|
505618
505653
|
function renderTreePrefix(node) {
|
|
505619
505654
|
let prefix = "";
|
|
505620
505655
|
for (let i4 = 0;i4 < node.depth; i4++) {
|
|
@@ -505643,7 +505678,7 @@ function MemfsTreeViewer({
|
|
|
505643
505678
|
const statusTimerRef = import_react88.useRef(null);
|
|
505644
505679
|
const memoryRoot = getScopedMemoryFilesystemRoot(agentId);
|
|
505645
505680
|
const memoryExists = existsSync79(memoryRoot);
|
|
505646
|
-
const hasGitRepo = import_react88.useMemo(() => existsSync79(
|
|
505681
|
+
const hasGitRepo = import_react88.useMemo(() => existsSync79(join120(memoryRoot, ".git")), [memoryRoot]);
|
|
505647
505682
|
function showStatus(msg, durationMs) {
|
|
505648
505683
|
if (statusTimerRef.current)
|
|
505649
505684
|
clearTimeout(statusTimerRef.current);
|
|
@@ -508375,10 +508410,10 @@ var init_use_chatgpt_rate_limit_state = __esm(() => {
|
|
|
508375
508410
|
// src/utils/aws-credentials.ts
|
|
508376
508411
|
import { readFile as readFile35 } from "node:fs/promises";
|
|
508377
508412
|
import { homedir as homedir36 } from "node:os";
|
|
508378
|
-
import { join as
|
|
508413
|
+
import { join as join121 } from "node:path";
|
|
508379
508414
|
async function parseAwsCredentials() {
|
|
508380
|
-
const credentialsPath =
|
|
508381
|
-
const configPath =
|
|
508415
|
+
const credentialsPath = join121(homedir36(), ".aws", "credentials");
|
|
508416
|
+
const configPath = join121(homedir36(), ".aws", "config");
|
|
508382
508417
|
const profiles = new Map;
|
|
508383
508418
|
try {
|
|
508384
508419
|
const content = await readFile35(credentialsPath, "utf-8");
|
|
@@ -510141,7 +510176,7 @@ var init_ReasoningMessageRich = __esm(async () => {
|
|
|
510141
510176
|
});
|
|
510142
510177
|
|
|
510143
510178
|
// src/cli/components/skills-dialog-paths.ts
|
|
510144
|
-
import { join as
|
|
510179
|
+
import { join as join122 } from "node:path";
|
|
510145
510180
|
function displayDirectory(path50) {
|
|
510146
510181
|
return `${path50.replace(/\\/g, "/").replace(/\/$/, "")}/`;
|
|
510147
510182
|
}
|
|
@@ -510151,7 +510186,7 @@ function getSkillsTabDescription(tab2, agentId, env6 = process.env) {
|
|
|
510151
510186
|
return ".agents/skills/";
|
|
510152
510187
|
case "agent": {
|
|
510153
510188
|
const memoryDir = resolveScopedMemoryDir({ agentId, env: env6 });
|
|
510154
|
-
return memoryDir ? displayDirectory(
|
|
510189
|
+
return memoryDir ? displayDirectory(join122(memoryDir, "skills")) : "$MEMORY_DIR/skills/";
|
|
510155
510190
|
}
|
|
510156
510191
|
case "global":
|
|
510157
510192
|
return displayDirectory(getGlobalSkillsDir(env6));
|
|
@@ -510179,8 +510214,8 @@ function SkillsDialog({ onClose, agentId }) {
|
|
|
510179
510214
|
try {
|
|
510180
510215
|
const { discoverSkills: discoverSkills2, SKILLS_DIR: SKILLS_DIR2 } = await Promise.resolve().then(() => (init_skills5(), exports_skills2));
|
|
510181
510216
|
const { getSkillsDirectory: getSkillsDirectory2, getSkillSources: getSkillSources2 } = await Promise.resolve().then(() => (init_context(), exports_context));
|
|
510182
|
-
const { join:
|
|
510183
|
-
const skillsDir = getSkillsDirectory2() ||
|
|
510217
|
+
const { join: join123 } = await import("node:path");
|
|
510218
|
+
const skillsDir = getSkillsDirectory2() || join123(process.cwd(), SKILLS_DIR2);
|
|
510184
510219
|
const result3 = await discoverSkills2(skillsDir, agentId, {
|
|
510185
510220
|
sources: getSkillSources2()
|
|
510186
510221
|
});
|
|
@@ -514486,9 +514521,9 @@ function getFileEditHeader(toolName2, toolArgs) {
|
|
|
514486
514521
|
} else if (operations2.length === 1) {
|
|
514487
514522
|
const op = operations2[0];
|
|
514488
514523
|
if (op) {
|
|
514489
|
-
const { relative:
|
|
514524
|
+
const { relative: relative15 } = __require("node:path");
|
|
514490
514525
|
const cwd3 = process.cwd();
|
|
514491
|
-
const relPath2 =
|
|
514526
|
+
const relPath2 = relative15(cwd3, op.path);
|
|
514492
514527
|
const displayPath2 = relPath2.startsWith("..") ? op.path : relPath2;
|
|
514493
514528
|
if (op.kind === "add")
|
|
514494
514529
|
return `Write to ${displayPath2}?`;
|
|
@@ -514502,9 +514537,9 @@ function getFileEditHeader(toolName2, toolArgs) {
|
|
|
514502
514537
|
return "Apply patch?";
|
|
514503
514538
|
}
|
|
514504
514539
|
const filePath = args.file_path || "";
|
|
514505
|
-
const { relative:
|
|
514540
|
+
const { relative: relative14 } = __require("node:path");
|
|
514506
514541
|
const cwd2 = process.cwd();
|
|
514507
|
-
const relPath =
|
|
514542
|
+
const relPath = relative14(cwd2, filePath);
|
|
514508
514543
|
const displayPath = relPath.startsWith("..") ? filePath : relPath;
|
|
514509
514544
|
if (t2 === "write") {
|
|
514510
514545
|
const { existsSync: existsSync80 } = __require("node:fs");
|
|
@@ -514589,9 +514624,9 @@ var init_ApprovalPreview = __esm(async () => {
|
|
|
514589
514624
|
/* @__PURE__ */ jsx_dev_runtime96.jsxDEV(Box_default, {
|
|
514590
514625
|
flexDirection: "column",
|
|
514591
514626
|
children: operations2.map((op, idx) => {
|
|
514592
|
-
const { relative:
|
|
514627
|
+
const { relative: relative14 } = __require("node:path");
|
|
514593
514628
|
const cwd2 = process.cwd();
|
|
514594
|
-
const relPath =
|
|
514629
|
+
const relPath = relative14(cwd2, op.path);
|
|
514595
514630
|
const displayPath = relPath.startsWith("..") ? op.path : relPath;
|
|
514596
514631
|
const diffKey = toolCallId ? `${toolCallId}:${op.path}` : undefined;
|
|
514597
514632
|
const opDiff = diffKey && allDiffs ? allDiffs.get(diffKey) : undefined;
|
|
@@ -516278,7 +516313,7 @@ __export(exports_generate_diff_viewer, {
|
|
|
516278
516313
|
});
|
|
516279
516314
|
import { execFile as execFileCb7 } from "node:child_process";
|
|
516280
516315
|
import { chmodSync as chmodSync12, existsSync as existsSync80, mkdirSync as mkdirSync61, writeFileSync as writeFileSync53 } from "node:fs";
|
|
516281
|
-
import { isAbsolute as
|
|
516316
|
+
import { isAbsolute as isAbsolute29, join as join123, resolve as resolve43 } from "node:path";
|
|
516282
516317
|
import { promisify as promisify23 } from "node:util";
|
|
516283
516318
|
async function runGit8(cwd2, args) {
|
|
516284
516319
|
try {
|
|
@@ -516480,7 +516515,7 @@ function escapeHtml3(value) {
|
|
|
516480
516515
|
function resolveTargetPath(targetPath) {
|
|
516481
516516
|
if (!targetPath?.trim())
|
|
516482
516517
|
return process.cwd();
|
|
516483
|
-
return
|
|
516518
|
+
return isAbsolute29(targetPath) ? targetPath : resolve43(process.cwd(), targetPath);
|
|
516484
516519
|
}
|
|
516485
516520
|
function shouldSkipOpen() {
|
|
516486
516521
|
return Boolean(process.env.TMUX) || Boolean(process.env.SSH_CONNECTION) || Boolean(process.env.SSH_TTY);
|
|
@@ -516507,7 +516542,7 @@ async function generateAndOpenDiffViewer(targetPath) {
|
|
|
516507
516542
|
try {
|
|
516508
516543
|
chmodSync12(VIEWERS_DIR2, 448);
|
|
516509
516544
|
} catch {}
|
|
516510
|
-
const filePath =
|
|
516545
|
+
const filePath = join123(VIEWERS_DIR2, `diff-${encodeURIComponent(worktreePath)}.html`);
|
|
516511
516546
|
writeFileSync53(filePath, html5);
|
|
516512
516547
|
chmodSync12(filePath, 384);
|
|
516513
516548
|
const skipOpen = shouldSkipOpen();
|
|
@@ -516577,7 +516612,7 @@ var init_generate_diff_viewer = __esm(() => {
|
|
|
516577
516612
|
init_settings_path();
|
|
516578
516613
|
init_diff_viewer_template();
|
|
516579
516614
|
execFile26 = promisify23(execFileCb7);
|
|
516580
|
-
VIEWERS_DIR2 =
|
|
516615
|
+
VIEWERS_DIR2 = join123(resolveGlobalConfigDir(), "viewers");
|
|
516581
516616
|
GIT_MAX_BUFFER = 50 * 1024 * 1024;
|
|
516582
516617
|
});
|
|
516583
516618
|
|
|
@@ -518540,7 +518575,7 @@ __export(exports_shell_aliases, {
|
|
|
518540
518575
|
});
|
|
518541
518576
|
import { existsSync as existsSync81, readFileSync as readFileSync59 } from "node:fs";
|
|
518542
518577
|
import { homedir as homedir37 } from "node:os";
|
|
518543
|
-
import { join as
|
|
518578
|
+
import { join as join124 } from "node:path";
|
|
518544
518579
|
function parseAliasesFromFile(filePath) {
|
|
518545
518580
|
const aliases = new Map;
|
|
518546
518581
|
if (!existsSync81(filePath)) {
|
|
@@ -518612,7 +518647,7 @@ function loadAliases(forceReload = false) {
|
|
|
518612
518647
|
const home = homedir37();
|
|
518613
518648
|
const allAliases = new Map;
|
|
518614
518649
|
for (const file of ALIAS_FILES) {
|
|
518615
|
-
const filePath =
|
|
518650
|
+
const filePath = join124(home, file);
|
|
518616
518651
|
const fileAliases = parseAliasesFromFile(filePath);
|
|
518617
518652
|
for (const [name, value] of fileAliases) {
|
|
518618
518653
|
allAliases.set(name, value);
|
|
@@ -519773,7 +519808,7 @@ var init_system_reminders2 = __esm(() => {
|
|
|
519773
519808
|
// src/cli/app/use-conversation-loop.ts
|
|
519774
519809
|
import { randomUUID as randomUUID71 } from "node:crypto";
|
|
519775
519810
|
function sleep12(ms) {
|
|
519776
|
-
return new Promise((
|
|
519811
|
+
return new Promise((resolve44) => setTimeout(resolve44, ms));
|
|
519777
519812
|
}
|
|
519778
519813
|
function makeExecutionPhaseHook(setExecutionPhase) {
|
|
519779
519814
|
return ({ chunk: chunk2 }) => {
|
|
@@ -520227,7 +520262,7 @@ function useConversationLoop(ctx) {
|
|
|
520227
520262
|
cancelled = true;
|
|
520228
520263
|
break;
|
|
520229
520264
|
}
|
|
520230
|
-
await new Promise((
|
|
520265
|
+
await new Promise((resolve44) => setTimeout(resolve44, 100));
|
|
520231
520266
|
}
|
|
520232
520267
|
if (!blockingRunId) {
|
|
520233
520268
|
buffersRef.current.byId.delete(statusId);
|
|
@@ -520274,7 +520309,7 @@ function useConversationLoop(ctx) {
|
|
|
520274
520309
|
cancelled = true;
|
|
520275
520310
|
break;
|
|
520276
520311
|
}
|
|
520277
|
-
await new Promise((
|
|
520312
|
+
await new Promise((resolve44) => setTimeout(resolve44, 100));
|
|
520278
520313
|
}
|
|
520279
520314
|
if (retryStatusId) {
|
|
520280
520315
|
buffersRef.current.byId.delete(retryStatusId);
|
|
@@ -521030,7 +521065,7 @@ ${feedback}
|
|
|
521030
521065
|
});
|
|
521031
521066
|
buffersRef.current.order.push(statusId);
|
|
521032
521067
|
refreshDerived();
|
|
521033
|
-
await new Promise((
|
|
521068
|
+
await new Promise((resolve44) => setTimeout(resolve44, delayMs));
|
|
521034
521069
|
buffersRef.current.byId.delete(statusId);
|
|
521035
521070
|
buffersRef.current.order = buffersRef.current.order.filter((id) => id !== statusId);
|
|
521036
521071
|
refreshDerived();
|
|
@@ -521070,7 +521105,7 @@ ${feedback}
|
|
|
521070
521105
|
cancelled = true;
|
|
521071
521106
|
break;
|
|
521072
521107
|
}
|
|
521073
|
-
await new Promise((
|
|
521108
|
+
await new Promise((resolve44) => setTimeout(resolve44, 100));
|
|
521074
521109
|
}
|
|
521075
521110
|
if (retryStatusId) {
|
|
521076
521111
|
buffersRef.current.byId.delete(retryStatusId);
|
|
@@ -523796,7 +523831,7 @@ async function writeHistoryArtifacts(params) {
|
|
|
523796
523831
|
}
|
|
523797
523832
|
async function defaultCommandRunner(command, args, options) {
|
|
523798
523833
|
const startedAt = Date.now();
|
|
523799
|
-
return new Promise((
|
|
523834
|
+
return new Promise((resolve44) => {
|
|
523800
523835
|
const child = spawn16(command, args, {
|
|
523801
523836
|
cwd: options.cwd,
|
|
523802
523837
|
env: options.env,
|
|
@@ -523823,7 +523858,7 @@ async function defaultCommandRunner(command, args, options) {
|
|
|
523823
523858
|
});
|
|
523824
523859
|
child.on("close", (exitCode) => {
|
|
523825
523860
|
clearTimeout(timeout);
|
|
523826
|
-
|
|
523861
|
+
resolve44({
|
|
523827
523862
|
args,
|
|
523828
523863
|
command,
|
|
523829
523864
|
cwd: options.cwd,
|
|
@@ -526848,7 +526883,7 @@ var init_conversation_switch_alert = __esm(() => {
|
|
|
526848
526883
|
import { randomUUID as randomUUID73 } from "node:crypto";
|
|
526849
526884
|
import { existsSync as existsSync82, readFileSync as readFileSync60, renameSync as renameSync14 } from "node:fs";
|
|
526850
526885
|
import { tmpdir as tmpdir17 } from "node:os";
|
|
526851
|
-
import { join as
|
|
526886
|
+
import { join as join125 } from "node:path";
|
|
526852
526887
|
async function findCustomCommandByName(commandName) {
|
|
526853
526888
|
const { findCustomCommand: findCustomCommand2 } = await Promise.resolve().then(() => (init_custom(), exports_custom));
|
|
526854
526889
|
return findCustomCommand2(commandName);
|
|
@@ -527456,8 +527491,8 @@ ${SYSTEM_REMINDER_CLOSE}`),
|
|
|
527456
527491
|
try {
|
|
527457
527492
|
const memoryRoot = getScopedMemoryFilesystemRoot(agentId);
|
|
527458
527493
|
const personaCandidates = [
|
|
527459
|
-
|
|
527460
|
-
|
|
527494
|
+
join125(memoryRoot, "system", "persona.md"),
|
|
527495
|
+
join125(memoryRoot, "memory", "system", "persona.md")
|
|
527461
527496
|
];
|
|
527462
527497
|
const personaPath = personaCandidates.find((candidate) => existsSync82(candidate));
|
|
527463
527498
|
if (personaPath) {
|
|
@@ -528305,7 +528340,7 @@ Path: ${memoryDir}`, true);
|
|
|
528305
528340
|
updateMemorySyncCommand(cmdId, "No local memory filesystem found to reset.", true, msg);
|
|
528306
528341
|
return { submitted: true };
|
|
528307
528342
|
}
|
|
528308
|
-
const backupDir =
|
|
528343
|
+
const backupDir = join125(tmpdir17(), `letta-memfs-reset-${agentId}-${Date.now()}`);
|
|
528309
528344
|
renameSync14(memoryDir, backupDir);
|
|
528310
528345
|
if (getBackend().capabilities.localMemfs) {
|
|
528311
528346
|
const { initializeLocalMemoryRepo: initializeLocalMemoryRepo2 } = await Promise.resolve().then(() => (init_memory_git(), exports_memory_git));
|
|
@@ -529214,7 +529249,7 @@ var init_use_submit_handler = __esm(async () => {
|
|
|
529214
529249
|
});
|
|
529215
529250
|
|
|
529216
529251
|
// src/cli/app/AppCoordinator.tsx
|
|
529217
|
-
import { join as
|
|
529252
|
+
import { join as join126 } from "node:path";
|
|
529218
529253
|
function buildStartupCommandHints(options) {
|
|
529219
529254
|
const {
|
|
529220
529255
|
isResumingConversation,
|
|
@@ -530495,7 +530530,7 @@ function App2({
|
|
|
530495
530530
|
agentId: a2.agentId ?? null
|
|
530496
530531
|
}))
|
|
530497
530532
|
});
|
|
530498
|
-
const agentModsDirectory = modContext.memfs.enabled && modContext.memfs.memoryDir ?
|
|
530533
|
+
const agentModsDirectory = modContext.memfs.enabled && modContext.memfs.memoryDir ? join126(modContext.memfs.memoryDir, "mods") : null;
|
|
530499
530534
|
const modAdapter = useLocalModAdapter(modContext, {
|
|
530500
530535
|
agentModsDirectory,
|
|
530501
530536
|
disabled: modsDisabled,
|
|
@@ -532836,12 +532871,12 @@ EXAMPLES
|
|
|
532836
532871
|
console.log(usage);
|
|
532837
532872
|
}
|
|
532838
532873
|
async function printInfo() {
|
|
532839
|
-
const { join:
|
|
532874
|
+
const { join: join127 } = await import("node:path");
|
|
532840
532875
|
const { getVersion: getVersion2 } = await Promise.resolve().then(() => (init_version(), exports_version));
|
|
532841
532876
|
const { SKILLS_DIR: SKILLS_DIR2 } = await Promise.resolve().then(() => (init_skills5(), exports_skills2));
|
|
532842
532877
|
const { exists: exists2 } = await Promise.resolve().then(() => (init_fs(), exports_fs));
|
|
532843
532878
|
const cwd2 = process.cwd();
|
|
532844
|
-
const skillsDir =
|
|
532879
|
+
const skillsDir = join127(cwd2, SKILLS_DIR2);
|
|
532845
532880
|
const skillsExist = exists2(skillsDir);
|
|
532846
532881
|
await settingsManager.loadLocalProjectSettings(cwd2);
|
|
532847
532882
|
const pinned = settingsManager.getPinnedAgents();
|
|
@@ -536703,4 +536738,4 @@ function registerBunOAuthFlows() {
|
|
|
536703
536738
|
registerBunOAuthFlows();
|
|
536704
536739
|
await init_src5().then(() => exports_src2);
|
|
536705
536740
|
|
|
536706
|
-
//# debugId=
|
|
536741
|
+
//# debugId=0AC80729B5970D2464756E2164756E21
|