@letta-ai/letta-code 0.34.73 → 0.34.74
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/dist/types/tools/impl/antigravity-acp.d.ts +37 -0
- package/dist/types/tools/impl/antigravity-acp.d.ts.map +1 -0
- package/dist/types/tools/impl/antigravity-session.d.ts.map +1 -1
- package/dist/types/tools/impl/send-agent-message.d.ts.map +1 -1
- package/letta.js +723 -458
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/skills/image-generation/SKILL.md +26 -9
package/letta.js
CHANGED
|
@@ -6156,7 +6156,7 @@ var package_default;
|
|
|
6156
6156
|
var init_package = __esm(() => {
|
|
6157
6157
|
package_default = {
|
|
6158
6158
|
name: "@letta-ai/letta-code",
|
|
6159
|
-
version: "0.34.
|
|
6159
|
+
version: "0.34.74",
|
|
6160
6160
|
lettaStartupLogProtocol: 1,
|
|
6161
6161
|
lettaConfigDirProtocol: 1,
|
|
6162
6162
|
description: "Letta Code is a CLI tool for interacting with stateful Letta agents from the terminal.",
|
|
@@ -212280,7 +212280,7 @@ var init_mcp_client = __esm(() => {
|
|
|
212280
212280
|
init_streamableHttp();
|
|
212281
212281
|
DEFAULT_CLIENT_INFO = {
|
|
212282
212282
|
name: "letta-code",
|
|
212283
|
-
version: "0.34.
|
|
212283
|
+
version: "0.34.74"
|
|
212284
212284
|
};
|
|
212285
212285
|
});
|
|
212286
212286
|
|
|
@@ -248754,13 +248754,222 @@ var init_subagent_process = __esm(() => {
|
|
|
248754
248754
|
init_package_manager_spawn();
|
|
248755
248755
|
});
|
|
248756
248756
|
|
|
248757
|
+
// src/tools/impl/antigravity-acp.ts
|
|
248758
|
+
import { mkdtemp as mkdtemp4, rm as rm8 } from "node:fs/promises";
|
|
248759
|
+
import { tmpdir as tmpdir13 } from "node:os";
|
|
248760
|
+
import { join as join68 } from "node:path";
|
|
248761
|
+
import { createInterface as createInterface8 } from "node:readline";
|
|
248762
|
+
async function withAcpTimeout(promise2, method2, timeout) {
|
|
248763
|
+
let timer;
|
|
248764
|
+
try {
|
|
248765
|
+
return await Promise.race([
|
|
248766
|
+
promise2,
|
|
248767
|
+
new Promise((_4, reject2) => {
|
|
248768
|
+
timer = setTimeout(() => reject2(new Error(`Antigravity ${method2} timed out`)), timeout);
|
|
248769
|
+
})
|
|
248770
|
+
]);
|
|
248771
|
+
} finally {
|
|
248772
|
+
clearTimeout(timer);
|
|
248773
|
+
}
|
|
248774
|
+
}
|
|
248775
|
+
async function withAntigravityAcp(cwd2, env6, run) {
|
|
248776
|
+
const temp = await mkdtemp4(join68(tmpdir13(), "letta-agy-acp-"));
|
|
248777
|
+
try {
|
|
248778
|
+
const client = new AntigravityAcp(cwd2, {
|
|
248779
|
+
...env6,
|
|
248780
|
+
TMPDIR: temp,
|
|
248781
|
+
...process.platform === "win32" && { TEMP: temp, TMP: temp }
|
|
248782
|
+
});
|
|
248783
|
+
try {
|
|
248784
|
+
return await run(client);
|
|
248785
|
+
} finally {
|
|
248786
|
+
await client.close();
|
|
248787
|
+
}
|
|
248788
|
+
} finally {
|
|
248789
|
+
await rm8(temp, { recursive: true, force: true });
|
|
248790
|
+
}
|
|
248791
|
+
}
|
|
248792
|
+
|
|
248793
|
+
class AntigravityAcp {
|
|
248794
|
+
controller = new AbortController;
|
|
248795
|
+
running;
|
|
248796
|
+
lines;
|
|
248797
|
+
pending = new Map;
|
|
248798
|
+
error;
|
|
248799
|
+
diagnostic = "";
|
|
248800
|
+
nextId = 0;
|
|
248801
|
+
onUpdate;
|
|
248802
|
+
onPermission;
|
|
248803
|
+
constructor(cwd2, env6) {
|
|
248804
|
+
this.running = spawnManagedWorkloadProcess("agy", ["acp"], {
|
|
248805
|
+
cwd: cwd2,
|
|
248806
|
+
env: env6,
|
|
248807
|
+
signal: this.controller.signal
|
|
248808
|
+
});
|
|
248809
|
+
const child = this.running.process;
|
|
248810
|
+
child.on("error", (error4) => {
|
|
248811
|
+
this.fail(error4.code === "ENOENT" ? new Error("Required executable 'agy' was not found on PATH") : error4);
|
|
248812
|
+
});
|
|
248813
|
+
child.stderr.on("data", (chunk2) => {
|
|
248814
|
+
this.diagnostic = (this.diagnostic + chunk2).slice(-2048);
|
|
248815
|
+
});
|
|
248816
|
+
child.stdin.on("error", (error4) => this.fail(error4));
|
|
248817
|
+
this.lines = createInterface8({ input: child.stdout });
|
|
248818
|
+
this.lines.on("line", (line) => {
|
|
248819
|
+
try {
|
|
248820
|
+
this.receive(line);
|
|
248821
|
+
} catch (error4) {
|
|
248822
|
+
this.fail(error4 instanceof Error ? error4 : new Error(String(error4)));
|
|
248823
|
+
}
|
|
248824
|
+
});
|
|
248825
|
+
this.running.completion.then(() => {
|
|
248826
|
+
this.fail(new Error(this.diagnostic.trim() || "Antigravity ACP exited"));
|
|
248827
|
+
});
|
|
248828
|
+
}
|
|
248829
|
+
fail(error4) {
|
|
248830
|
+
this.error ??= error4;
|
|
248831
|
+
for (const entry of this.pending.values())
|
|
248832
|
+
entry.reject(this.error);
|
|
248833
|
+
this.pending.clear();
|
|
248834
|
+
}
|
|
248835
|
+
write(message) {
|
|
248836
|
+
this.running.process.stdin.write(`${JSON.stringify({ jsonrpc: "2.0", ...message })}
|
|
248837
|
+
`);
|
|
248838
|
+
}
|
|
248839
|
+
receive(line) {
|
|
248840
|
+
if (!line.trim().startsWith("{"))
|
|
248841
|
+
return;
|
|
248842
|
+
const message = JSON.parse(line);
|
|
248843
|
+
if (!isRecord2(message) || message.jsonrpc !== "2.0")
|
|
248844
|
+
return;
|
|
248845
|
+
const { id, method: method2, params, result: result3, error: error4 } = message;
|
|
248846
|
+
if (typeof method2 === "string") {
|
|
248847
|
+
if (typeof id === "string" || typeof id === "number") {
|
|
248848
|
+
if (method2 === "session/request_permission") {
|
|
248849
|
+
const outcome = isRecord2(params) ? this.onPermission?.(params) : undefined;
|
|
248850
|
+
this.write({
|
|
248851
|
+
id,
|
|
248852
|
+
result: { outcome: outcome ?? { outcome: "cancelled" } }
|
|
248853
|
+
});
|
|
248854
|
+
} else {
|
|
248855
|
+
this.write({
|
|
248856
|
+
id,
|
|
248857
|
+
error: { code: -32601, message: "Method not supported" }
|
|
248858
|
+
});
|
|
248859
|
+
}
|
|
248860
|
+
} else if (method2 === "session/update" && isRecord2(params)) {
|
|
248861
|
+
this.onUpdate?.(params);
|
|
248862
|
+
}
|
|
248863
|
+
return;
|
|
248864
|
+
}
|
|
248865
|
+
if (typeof id !== "number")
|
|
248866
|
+
return;
|
|
248867
|
+
const entry = this.pending.get(id);
|
|
248868
|
+
this.pending.delete(id);
|
|
248869
|
+
if (isRecord2(error4))
|
|
248870
|
+
entry?.reject(new AntigravityRpcError(String(error4.message ?? "Antigravity ACP request failed"), error4.code));
|
|
248871
|
+
else
|
|
248872
|
+
entry?.resolve(isRecord2(result3) ? result3 : {});
|
|
248873
|
+
}
|
|
248874
|
+
async request(method2, params, timeout = 30000) {
|
|
248875
|
+
if (this.error)
|
|
248876
|
+
throw this.error;
|
|
248877
|
+
const id = ++this.nextId;
|
|
248878
|
+
const result3 = new Promise((resolve34, reject2) => {
|
|
248879
|
+
this.pending.set(id, { resolve: resolve34, reject: reject2 });
|
|
248880
|
+
this.write({ id, method: method2, params });
|
|
248881
|
+
});
|
|
248882
|
+
try {
|
|
248883
|
+
return await (timeout ? withAcpTimeout(result3, method2, timeout) : result3);
|
|
248884
|
+
} finally {
|
|
248885
|
+
this.pending.delete(id);
|
|
248886
|
+
}
|
|
248887
|
+
}
|
|
248888
|
+
notify(method2, params) {
|
|
248889
|
+
if (!this.error)
|
|
248890
|
+
this.write({ method: method2, params });
|
|
248891
|
+
}
|
|
248892
|
+
async close() {
|
|
248893
|
+
this.running.process.stdin.end();
|
|
248894
|
+
try {
|
|
248895
|
+
await withAcpTimeout(this.running.completion, "shutdown", 1000);
|
|
248896
|
+
} catch {
|
|
248897
|
+
this.controller.abort();
|
|
248898
|
+
await this.running.completion;
|
|
248899
|
+
} finally {
|
|
248900
|
+
this.lines.close();
|
|
248901
|
+
}
|
|
248902
|
+
}
|
|
248903
|
+
}
|
|
248904
|
+
async function openAntigravitySession(client, cwd2, apiKey, sessionId) {
|
|
248905
|
+
const init = await client.request("initialize", {
|
|
248906
|
+
protocolVersion: 1,
|
|
248907
|
+
clientInfo: { name: "letta-code", version: "1.0.0" },
|
|
248908
|
+
clientCapabilities: {}
|
|
248909
|
+
});
|
|
248910
|
+
try {
|
|
248911
|
+
await client.request("authenticate", {
|
|
248912
|
+
methodId: apiKey ? "gemini-api-key" : "oauth-personal"
|
|
248913
|
+
});
|
|
248914
|
+
} catch (error4) {
|
|
248915
|
+
if (!apiKey && error4 instanceof AntigravityRpcError)
|
|
248916
|
+
throw new Error("Antigravity is not signed in: run agy acp --login to authenticate");
|
|
248917
|
+
throw error4;
|
|
248918
|
+
}
|
|
248919
|
+
const params = { cwd: cwd2, mcpServers: [] };
|
|
248920
|
+
const capabilities = isRecord2(init.agentCapabilities) ? init.agentCapabilities.sessionCapabilities : undefined;
|
|
248921
|
+
const setup = sessionId ? await client.request(isRecord2(capabilities) && isRecord2(capabilities.resume) ? "session/resume" : "session/load", { ...params, sessionId }) : await client.request("session/new", params);
|
|
248922
|
+
const version3 = isRecord2(init.agentInfo) && typeof init.agentInfo.version === "string" ? /^(\d+)\.(\d+)\./.exec(init.agentInfo.version) : null;
|
|
248923
|
+
const liveSteering = !!version3 && (Number(version3[1]) > 1 || Number(version3[1]) === 1 && Number(version3[2]) >= 5);
|
|
248924
|
+
return {
|
|
248925
|
+
setup,
|
|
248926
|
+
liveSteering,
|
|
248927
|
+
canClose: isRecord2(capabilities) && isRecord2(capabilities.close)
|
|
248928
|
+
};
|
|
248929
|
+
}
|
|
248930
|
+
function antigravityConfig(setup, category2) {
|
|
248931
|
+
return Array.isArray(setup.configOptions) ? setup.configOptions.filter(isRecord2).find((option2) => option2.category === category2 && option2.type === "select") : undefined;
|
|
248932
|
+
}
|
|
248933
|
+
async function listAntigravityModels(cwd2, env6) {
|
|
248934
|
+
try {
|
|
248935
|
+
return await withAntigravityAcp(cwd2, env6, async (client) => {
|
|
248936
|
+
const { setup, canClose } = await openAntigravitySession(client, cwd2, !!env6.GEMINI_API_KEY);
|
|
248937
|
+
try {
|
|
248938
|
+
const model2 = antigravityConfig(setup, "model");
|
|
248939
|
+
const options = Array.isArray(model2?.options) ? model2.options.filter(isRecord2) : [];
|
|
248940
|
+
return options.flatMap((option2) => Array.isArray(option2.options) ? option2.options.filter(isRecord2) : [option2]).filter((option2) => typeof option2.value === "string" && typeof option2.name === "string").map((option2) => ({
|
|
248941
|
+
id: option2.value,
|
|
248942
|
+
displayName: option2.name,
|
|
248943
|
+
description: option2.description
|
|
248944
|
+
}));
|
|
248945
|
+
} finally {
|
|
248946
|
+
if (canClose && typeof setup.sessionId === "string")
|
|
248947
|
+
await client.request("session/close", { sessionId: setup.sessionId }, 1000).catch(() => {});
|
|
248948
|
+
}
|
|
248949
|
+
});
|
|
248950
|
+
} catch {
|
|
248951
|
+
return [];
|
|
248952
|
+
}
|
|
248953
|
+
}
|
|
248954
|
+
var AntigravityRpcError;
|
|
248955
|
+
var init_antigravity_acp = __esm(() => {
|
|
248956
|
+
init_subagent_process();
|
|
248957
|
+
AntigravityRpcError = class AntigravityRpcError extends Error {
|
|
248958
|
+
code;
|
|
248959
|
+
constructor(message, code) {
|
|
248960
|
+
super(message);
|
|
248961
|
+
this.code = code;
|
|
248962
|
+
}
|
|
248963
|
+
};
|
|
248964
|
+
});
|
|
248965
|
+
|
|
248757
248966
|
// src/tools/impl/native-session-owner.ts
|
|
248758
248967
|
import { createHash as createHash11 } from "node:crypto";
|
|
248759
248968
|
import { mkdirSync as mkdirSync38, readFileSync as readFileSync41, rmSync as rmSync16, writeFileSync as writeFileSync33 } from "node:fs";
|
|
248760
|
-
import { join as
|
|
248969
|
+
import { join as join69 } from "node:path";
|
|
248761
248970
|
function ownerPath(source, sessionId) {
|
|
248762
248971
|
const id = createHash11("sha256").update(`${source}:${sessionId}`).digest("hex");
|
|
248763
|
-
return
|
|
248972
|
+
return join69(resolveGlobalConfigDir(), "native-session-owners", `${id}.json`);
|
|
248764
248973
|
}
|
|
248765
248974
|
function readNativeSessionOwner(source, sessionId) {
|
|
248766
248975
|
try {
|
|
@@ -248776,7 +248985,7 @@ function readNativeSessionOwner(source, sessionId) {
|
|
|
248776
248985
|
}
|
|
248777
248986
|
function persistNativeSessionOwner(source, sessionId, scope) {
|
|
248778
248987
|
const path30 = ownerPath(source, sessionId);
|
|
248779
|
-
mkdirSync38(
|
|
248988
|
+
mkdirSync38(join69(path30, ".."), { recursive: true, mode: 448 });
|
|
248780
248989
|
try {
|
|
248781
248990
|
writeFileSync33(path30, JSON.stringify(scope), { flag: "wx", mode: 384 });
|
|
248782
248991
|
} catch (error4) {
|
|
@@ -248790,173 +248999,222 @@ var init_native_session_owner = __esm(() => {
|
|
|
248790
248999
|
});
|
|
248791
249000
|
|
|
248792
249001
|
// src/tools/impl/antigravity-session.ts
|
|
248793
|
-
|
|
249002
|
+
function requireOwner(id, agentId) {
|
|
249003
|
+
const owner = sessionPattern.test(id) ? readNativeSessionOwner("antigravity", id) : undefined;
|
|
249004
|
+
if (owner?.agentId !== agentId)
|
|
249005
|
+
throw new Error("Antigravity session does not belong to this agent");
|
|
249006
|
+
return owner;
|
|
249007
|
+
}
|
|
249008
|
+
function createTurnProgress(options, secrets2) {
|
|
249009
|
+
const text2 = createSecretStreamScrubber(secrets2);
|
|
249010
|
+
const scrub = (value) => scrubSecretsFromString(value, secrets2);
|
|
249011
|
+
const tools = new Map;
|
|
249012
|
+
const completedTools = new Set;
|
|
249013
|
+
let report = "";
|
|
249014
|
+
return {
|
|
249015
|
+
update(update2) {
|
|
249016
|
+
if (update2.sessionUpdate === "agent_message_chunk" && isRecord2(update2.content) && update2.content.type === "text" && typeof update2.content.text === "string") {
|
|
249017
|
+
report += update2.content.text;
|
|
249018
|
+
const delta = text2.push(update2.content.text);
|
|
249019
|
+
if (delta)
|
|
249020
|
+
emitProgress(options.onText, delta);
|
|
249021
|
+
}
|
|
249022
|
+
const id = update2.toolCallId;
|
|
249023
|
+
if (typeof id !== "string")
|
|
249024
|
+
return;
|
|
249025
|
+
if (update2.sessionUpdate === "tool_call" && !tools.has(id)) {
|
|
249026
|
+
const label = update2.name ?? update2.title;
|
|
249027
|
+
const name = typeof label === "string" ? scrub(label) : "Antigravity tool";
|
|
249028
|
+
tools.set(id, name);
|
|
249029
|
+
emitProgress(options.onToolCall, {
|
|
249030
|
+
id,
|
|
249031
|
+
name,
|
|
249032
|
+
args: scrub(formatExternalToolCallArgs(update2.rawInput))
|
|
249033
|
+
});
|
|
249034
|
+
}
|
|
249035
|
+
if ((update2.status === "completed" || update2.status === "failed") && !completedTools.has(id) && tools.has(id)) {
|
|
249036
|
+
completedTools.add(id);
|
|
249037
|
+
emitProgress(options.onToolResult, {
|
|
249038
|
+
id,
|
|
249039
|
+
name: tools.get(id),
|
|
249040
|
+
isError: update2.status === "failed" || isRecord2(update2.rawOutput) && typeof update2.rawOutput.exit_code === "number" && update2.rawOutput.exit_code !== 0,
|
|
249041
|
+
output: scrub(toolOutputText(update2.rawOutput ?? update2.content))
|
|
249042
|
+
});
|
|
249043
|
+
}
|
|
249044
|
+
},
|
|
249045
|
+
finish() {
|
|
249046
|
+
const tail2 = text2.flush();
|
|
249047
|
+
if (tail2)
|
|
249048
|
+
emitProgress(options.onText, tail2);
|
|
249049
|
+
return scrub(report);
|
|
249050
|
+
}
|
|
249051
|
+
};
|
|
249052
|
+
}
|
|
248794
249053
|
async function runAntigravityTurn(options, env6, secrets2) {
|
|
248795
249054
|
const start = Date.now();
|
|
248796
249055
|
if (env6.GEMINI_API_KEY)
|
|
248797
249056
|
secrets2 = { ...secrets2, GEMINI_API_KEY: env6.GEMINI_API_KEY };
|
|
248798
249057
|
let sessionId = options.resumeSessionId;
|
|
248799
249058
|
const state2 = { queue: [], closing: false };
|
|
248800
|
-
const
|
|
248801
|
-
const signal = options.signal ? AbortSignal.any([controller.signal, options.signal]) : controller.signal;
|
|
248802
|
-
const base2 = {
|
|
248803
|
-
model: options.model,
|
|
248804
|
-
report: "",
|
|
248805
|
-
agentId: options.parentAgentId
|
|
248806
|
-
};
|
|
249059
|
+
const { signal } = options;
|
|
248807
249060
|
try {
|
|
248808
|
-
signal
|
|
248809
|
-
const
|
|
248810
|
-
"--mode",
|
|
248811
|
-
"accept-edits",
|
|
248812
|
-
"--input-format",
|
|
248813
|
-
"stream-json",
|
|
248814
|
-
"--output-format",
|
|
248815
|
-
"stream-json",
|
|
248816
|
-
"--disable-slash-commands"
|
|
248817
|
-
];
|
|
248818
|
-
if (env6.GEMINI_API_KEY)
|
|
248819
|
-
args.push("--settings", '{"modelProvider":"gemini"}');
|
|
249061
|
+
signal?.throwIfAborted();
|
|
249062
|
+
const unrestricted = (getRuntimeContext()?.permissionMode ?? permissionMode.getMode()) === "unrestricted";
|
|
248820
249063
|
if (sessionId) {
|
|
248821
|
-
const owner =
|
|
248822
|
-
if (!sessionPattern.test(sessionId) || owner?.agentId !== options.parentAgentId)
|
|
248823
|
-
throw new Error("Antigravity session does not belong to this agent");
|
|
249064
|
+
const owner = requireOwner(sessionId, options.parentAgentId);
|
|
248824
249065
|
if (sessions.has(sessionId))
|
|
248825
249066
|
throw new Error("Antigravity session is already running");
|
|
248826
249067
|
sessions.set(sessionId, state2);
|
|
248827
|
-
args.push("--conversation", sessionId);
|
|
248828
249068
|
options = {
|
|
248829
249069
|
...options,
|
|
248830
249070
|
cwd: owner.cwd ?? options.cwd,
|
|
248831
249071
|
model: options.model ?? owner.model
|
|
248832
249072
|
};
|
|
248833
249073
|
}
|
|
248834
|
-
|
|
248835
|
-
|
|
248836
|
-
|
|
248837
|
-
|
|
248838
|
-
|
|
248839
|
-
|
|
248840
|
-
|
|
248841
|
-
|
|
248842
|
-
|
|
248843
|
-
|
|
248844
|
-
|
|
248845
|
-
|
|
248846
|
-
|
|
248847
|
-
|
|
248848
|
-
|
|
248849
|
-
|
|
248850
|
-
|
|
248851
|
-
|
|
248852
|
-
|
|
248853
|
-
|
|
248854
|
-
|
|
248855
|
-
|
|
248856
|
-
|
|
248857
|
-
|
|
248858
|
-
|
|
248859
|
-
|
|
248860
|
-
|
|
248861
|
-
|
|
248862
|
-
|
|
248863
|
-
|
|
248864
|
-
|
|
248865
|
-
|
|
248866
|
-
|
|
248867
|
-
|
|
248868
|
-
|
|
248869
|
-
|
|
248870
|
-
|
|
248871
|
-
|
|
248872
|
-
|
|
248873
|
-
|
|
248874
|
-
if (
|
|
248875
|
-
|
|
248876
|
-
|
|
248877
|
-
|
|
248878
|
-
cwd: options.cwd,
|
|
248879
|
-
model: options.model
|
|
249074
|
+
return await withAntigravityAcp(options.cwd, env6, async (client) => {
|
|
249075
|
+
const { setup, liveSteering, canClose } = await openAntigravitySession(client, options.cwd, !!env6.GEMINI_API_KEY, sessionId);
|
|
249076
|
+
const id = sessionId ?? setup.sessionId;
|
|
249077
|
+
if (typeof id !== "string" || !sessionPattern.test(id) || setup.sessionId !== undefined && id !== setup.sessionId || sessions.has(id) && sessions.get(id) !== state2)
|
|
249078
|
+
throw new Error("Invalid Antigravity conversation ID");
|
|
249079
|
+
sessionId = id;
|
|
249080
|
+
let cancelTimer;
|
|
249081
|
+
let rejectCancelled = () => {};
|
|
249082
|
+
const cancelled = new Promise((_4, reject2) => {
|
|
249083
|
+
rejectCancelled = reject2;
|
|
249084
|
+
});
|
|
249085
|
+
const cancel = () => {
|
|
249086
|
+
state2.closing = true;
|
|
249087
|
+
client.notify("session/cancel", { sessionId: id });
|
|
249088
|
+
cancelTimer = setTimeout(() => rejectCancelled(signal?.reason), 3000);
|
|
249089
|
+
};
|
|
249090
|
+
try {
|
|
249091
|
+
signal?.throwIfAborted();
|
|
249092
|
+
if (!options.resumeSessionId) {
|
|
249093
|
+
persistNativeSessionOwner("antigravity", id, {
|
|
249094
|
+
agentId: options.parentAgentId,
|
|
249095
|
+
conversationId: options.parentConversationId ?? "default",
|
|
249096
|
+
cwd: options.cwd,
|
|
249097
|
+
model: options.model
|
|
249098
|
+
});
|
|
249099
|
+
requireOwner(id, options.parentAgentId);
|
|
249100
|
+
}
|
|
249101
|
+
sessions.set(id, state2);
|
|
249102
|
+
const mode = antigravityConfig(setup, "mode");
|
|
249103
|
+
if (!unrestricted && Array.isArray(mode?.options) && mode.options.some((entry) => isRecord2(entry) && entry.value === "accept-edits")) {
|
|
249104
|
+
await client.request("session/set_config_option", {
|
|
249105
|
+
sessionId: id,
|
|
249106
|
+
configId: mode.id,
|
|
249107
|
+
value: "accept-edits"
|
|
249108
|
+
});
|
|
249109
|
+
}
|
|
249110
|
+
if (options.model) {
|
|
249111
|
+
const model2 = antigravityConfig(setup, "model");
|
|
249112
|
+
const legacyModels = isRecord2(setup.models) ? setup.models.availableModels : undefined;
|
|
249113
|
+
const useLegacy = !model2 || Array.isArray(legacyModels) && legacyModels.some((entry) => isRecord2(entry) && entry.modelId === options.model) && !(Array.isArray(model2.options) && model2.options.some((entry) => isRecord2(entry) && entry.value === options.model));
|
|
249114
|
+
if (useLegacy) {
|
|
249115
|
+
await client.request("session/set_model", {
|
|
249116
|
+
sessionId: id,
|
|
249117
|
+
modelId: options.model
|
|
248880
249118
|
});
|
|
248881
|
-
if (readNativeSessionOwner("antigravity", id)?.agentId !== options.parentAgentId)
|
|
248882
|
-
throw new Error("Antigravity session owner mismatch");
|
|
248883
|
-
sessions.set(id, state2);
|
|
248884
|
-
initialized = true;
|
|
248885
|
-
options.onStarted?.(`antigravity_${id}`);
|
|
248886
|
-
} else if (event.event === "step_update" && isRecord2(event.step_update)) {
|
|
248887
|
-
const step = event.step_update;
|
|
248888
|
-
if (!initialized || step.conversation_id !== sessionId)
|
|
248889
|
-
throw new Error("Unexpected Antigravity step conversation");
|
|
248890
|
-
if (step.step_type === "agent_response" && typeof step.text_delta === "string") {
|
|
248891
|
-
const delta = text2.push(step.text_delta);
|
|
248892
|
-
if (delta)
|
|
248893
|
-
emitProgress(options.onText, delta);
|
|
248894
|
-
}
|
|
248895
|
-
if (step.step_type === "tool" && typeof step.step_index === "number" && typeof step.tool_name === "string") {
|
|
248896
|
-
const info = isRecord2(step.tool_info) ? step.tool_info : {};
|
|
248897
|
-
const id = `step-${step.step_index}`;
|
|
248898
|
-
if (!tools.has(step.step_index)) {
|
|
248899
|
-
tools.add(step.step_index);
|
|
248900
|
-
emitProgress(options.onToolCall, {
|
|
248901
|
-
id,
|
|
248902
|
-
name: step.tool_name,
|
|
248903
|
-
args: formatExternalToolCallArgs(info.parameters)
|
|
248904
|
-
});
|
|
248905
|
-
}
|
|
248906
|
-
if (step.state === "DONE")
|
|
248907
|
-
emitProgress(options.onToolResult, {
|
|
248908
|
-
id,
|
|
248909
|
-
name: step.tool_name,
|
|
248910
|
-
isError: !!info.error,
|
|
248911
|
-
output: toolOutputText(info.error ?? info.output)
|
|
248912
|
-
});
|
|
248913
|
-
}
|
|
248914
|
-
} else if (event.event === "result" && isRecord2(event.result)) {
|
|
248915
|
-
const result3 = event.result;
|
|
248916
|
-
const tail2 = text2.flush();
|
|
248917
|
-
if (tail2)
|
|
248918
|
-
emitProgress(options.onText, tail2);
|
|
248919
|
-
if (result3.status !== "SUCCESS")
|
|
248920
|
-
error4 = typeof result3.error === "string" ? result3.error : "Antigravity turn failed";
|
|
248921
|
-
else if (!initialized || result3.conversation_id !== sessionId || typeof result3.response !== "string" || state2.closing)
|
|
248922
|
-
throw new Error("Invalid Antigravity result");
|
|
248923
|
-
const next = !error4 && state2.queue.shift();
|
|
248924
|
-
if (next) {
|
|
248925
|
-
tools.clear();
|
|
248926
|
-
send(next);
|
|
248927
249119
|
} else {
|
|
248928
|
-
|
|
248929
|
-
|
|
248930
|
-
|
|
249120
|
+
await client.request("session/set_config_option", {
|
|
249121
|
+
sessionId: id,
|
|
249122
|
+
configId: model2.id,
|
|
249123
|
+
value: options.model
|
|
249124
|
+
});
|
|
248931
249125
|
}
|
|
248932
249126
|
}
|
|
249127
|
+
signal?.throwIfAborted();
|
|
249128
|
+
let progress = createTurnProgress(options, secrets2);
|
|
249129
|
+
let denied = false;
|
|
249130
|
+
client.onUpdate = (params) => {
|
|
249131
|
+
if (params.sessionId === id && isRecord2(params.update))
|
|
249132
|
+
progress.update(params.update);
|
|
249133
|
+
};
|
|
249134
|
+
client.onPermission = (params) => {
|
|
249135
|
+
if (params.sessionId !== id || signal?.aborted)
|
|
249136
|
+
return { outcome: "cancelled" };
|
|
249137
|
+
if (isRecord2(params.toolCall) && typeof params.toolCall.toolCallId === "string" && params.toolCall.toolCallId.startsWith("interaction_"))
|
|
249138
|
+
return { outcome: "cancelled" };
|
|
249139
|
+
const choices = Array.isArray(params.options) ? params.options.filter(isRecord2) : [];
|
|
249140
|
+
const kind = unrestricted ? "allow_once" : "reject_once";
|
|
249141
|
+
const choice = choices.find((entry) => entry.kind === kind && typeof entry.optionId === "string");
|
|
249142
|
+
denied ||= !unrestricted || !choice;
|
|
249143
|
+
return choice ? { outcome: "selected", optionId: choice.optionId } : { outcome: "cancelled" };
|
|
249144
|
+
};
|
|
249145
|
+
const prompt = (value) => client.request("session/prompt", {
|
|
249146
|
+
sessionId: id,
|
|
249147
|
+
prompt: [{ type: "text", text: value }]
|
|
249148
|
+
}, 0);
|
|
249149
|
+
let next = [options.mcpReminder, options.prompt].filter(Boolean).join(`
|
|
249150
|
+
|
|
249151
|
+
`);
|
|
249152
|
+
let report = "";
|
|
249153
|
+
let supportsSteering = liveSteering;
|
|
249154
|
+
signal?.addEventListener("abort", cancel, { once: true });
|
|
249155
|
+
let started = false;
|
|
249156
|
+
while (true) {
|
|
249157
|
+
let steering;
|
|
249158
|
+
const turn = prompt(next);
|
|
249159
|
+
state2.steer = (value) => {
|
|
249160
|
+
if (!supportsSteering || steering || state2.queue.length)
|
|
249161
|
+
return false;
|
|
249162
|
+
steering = prompt(value).catch((error4) => {
|
|
249163
|
+
if (error4 instanceof AntigravityRpcError && (error4.code === -32601 || /already (running|in progress)|busy|waiting for a permission or question answer|steering.*not supported/i.test(error4.message))) {
|
|
249164
|
+
if (error4.code === -32601 || /steering.*not supported/i.test(error4.message))
|
|
249165
|
+
supportsSteering = false;
|
|
249166
|
+
state2.queue.unshift(value);
|
|
249167
|
+
return;
|
|
249168
|
+
}
|
|
249169
|
+
throw error4;
|
|
249170
|
+
});
|
|
249171
|
+
steering.catch(() => {});
|
|
249172
|
+
return true;
|
|
249173
|
+
};
|
|
249174
|
+
if (!started) {
|
|
249175
|
+
started = true;
|
|
249176
|
+
emitProgress(options.onStarted, `antigravity_${id}`);
|
|
249177
|
+
}
|
|
249178
|
+
const result3 = await Promise.race([turn, cancelled]);
|
|
249179
|
+
state2.steer = undefined;
|
|
249180
|
+
const steered = steering && await Promise.race([steering, cancelled]);
|
|
249181
|
+
signal?.throwIfAborted();
|
|
249182
|
+
if (result3.stopReason === "cancelled" && !steered || steered?.stopReason === "cancelled")
|
|
249183
|
+
throw new Error("Antigravity turn cancelled");
|
|
249184
|
+
report = progress.finish();
|
|
249185
|
+
if (!report.trim() && denied)
|
|
249186
|
+
throw new Error("Antigravity tool permission denied");
|
|
249187
|
+
const queued = state2.queue.shift();
|
|
249188
|
+
if (queued === undefined)
|
|
249189
|
+
break;
|
|
249190
|
+
next = queued;
|
|
249191
|
+
denied = false;
|
|
249192
|
+
progress = createTurnProgress(options, secrets2);
|
|
249193
|
+
}
|
|
249194
|
+
state2.closing = true;
|
|
249195
|
+
return {
|
|
249196
|
+
model: options.model,
|
|
249197
|
+
agentId: `antigravity_${id}`,
|
|
249198
|
+
runtimeSessionId: id,
|
|
249199
|
+
report,
|
|
249200
|
+
success: true,
|
|
249201
|
+
durationMs: Date.now() - start
|
|
249202
|
+
};
|
|
249203
|
+
} finally {
|
|
249204
|
+
state2.closing = true;
|
|
249205
|
+
signal?.removeEventListener("abort", cancel);
|
|
249206
|
+
clearTimeout(cancelTimer);
|
|
249207
|
+
client.onUpdate = undefined;
|
|
249208
|
+
client.onPermission = undefined;
|
|
249209
|
+
if (canClose)
|
|
249210
|
+
await client.request("session/close", { sessionId: id }, 1000).catch(() => {});
|
|
248933
249211
|
}
|
|
248934
|
-
|
|
248935
|
-
signal.throwIfAborted();
|
|
248936
|
-
if (spawnError?.code === "ENOENT")
|
|
248937
|
-
throw new Error("Required executable 'agy' was not found on PATH");
|
|
248938
|
-
if (!initialized && /authentication required|authentication failed/i.test(`${diagnostic}
|
|
248939
|
-
${error4}`))
|
|
248940
|
-
throw new Error("Antigravity is not signed in: run agy to authenticate");
|
|
248941
|
-
if (spawnError || error4 || exitCode !== 0 || report === undefined || !sessionId)
|
|
248942
|
-
throw spawnError ?? new Error(error4 || diagnostic.trim() || "Antigravity exited without a result");
|
|
248943
|
-
return {
|
|
248944
|
-
...base2,
|
|
248945
|
-
agentId: `antigravity_${sessionId}`,
|
|
248946
|
-
runtimeSessionId: sessionId,
|
|
248947
|
-
report: scrubSecretsFromString(report, secrets2),
|
|
248948
|
-
success: true,
|
|
248949
|
-
durationMs: Date.now() - start
|
|
248950
|
-
};
|
|
248951
|
-
} finally {
|
|
248952
|
-
lines.close();
|
|
248953
|
-
if (child.exitCode === null && child.signalCode === null)
|
|
248954
|
-
controller.abort();
|
|
248955
|
-
await running.completion;
|
|
248956
|
-
}
|
|
249212
|
+
});
|
|
248957
249213
|
} catch (error4) {
|
|
248958
249214
|
return {
|
|
248959
|
-
|
|
249215
|
+
model: options.model,
|
|
249216
|
+
report: "",
|
|
249217
|
+
agentId: options.parentAgentId,
|
|
248960
249218
|
success: false,
|
|
248961
249219
|
error: scrubSecretsFromString(error4 instanceof Error ? error4.message : String(error4), secrets2),
|
|
248962
249220
|
durationMs: Date.now() - start
|
|
@@ -248968,14 +249226,16 @@ ${error4}`))
|
|
|
248968
249226
|
}
|
|
248969
249227
|
function sendAntigravityMessage(options, env6, secrets2) {
|
|
248970
249228
|
const id = options.resumeSessionId;
|
|
248971
|
-
|
|
248972
|
-
throw new Error("Antigravity session does not belong to this agent");
|
|
249229
|
+
requireOwner(id, options.parentAgentId);
|
|
248973
249230
|
const active = sessions.get(id);
|
|
248974
249231
|
if (active) {
|
|
248975
249232
|
if (active.closing)
|
|
248976
249233
|
throw new Error("Antigravity session is finishing; retry after completion");
|
|
248977
|
-
|
|
248978
|
-
|
|
249234
|
+
options.signal?.throwIfAborted();
|
|
249235
|
+
const queued = !active.steer?.(options.prompt);
|
|
249236
|
+
if (queued)
|
|
249237
|
+
active.queue.push(options.prompt);
|
|
249238
|
+
return { mode: "steered", queued };
|
|
248979
249239
|
}
|
|
248980
249240
|
const controller = new AbortController;
|
|
248981
249241
|
const signal = options.signal ? AbortSignal.any([controller.signal, options.signal]) : controller.signal;
|
|
@@ -248991,8 +249251,10 @@ function sendAntigravityMessage(options, env6, secrets2) {
|
|
|
248991
249251
|
}
|
|
248992
249252
|
var sessions, sessionPattern;
|
|
248993
249253
|
var init_antigravity_session = __esm(() => {
|
|
248994
|
-
|
|
249254
|
+
init_mode();
|
|
249255
|
+
init_runtime_context();
|
|
248995
249256
|
init_secret_substitution();
|
|
249257
|
+
init_antigravity_acp();
|
|
248996
249258
|
init_native_session_owner();
|
|
248997
249259
|
sessions = new Map;
|
|
248998
249260
|
sessionPattern = /^[a-f\d]{8}(?:-[a-f\d]{4}){3}-[a-f\d]{12}$/i;
|
|
@@ -249015,11 +249277,11 @@ async function confirmProcessExit(exit, name) {
|
|
|
249015
249277
|
|
|
249016
249278
|
// src/utils/native-cli-env.ts
|
|
249017
249279
|
import { homedir as homedir19 } from "node:os";
|
|
249018
|
-
import { join as
|
|
249280
|
+
import { join as join70 } from "node:path";
|
|
249019
249281
|
function withNativeCliPath(env6, platform7 = process.platform) {
|
|
249020
249282
|
if (platform7 === "win32")
|
|
249021
249283
|
return { ...env6 };
|
|
249022
|
-
const nativeBin =
|
|
249284
|
+
const nativeBin = join70(env6.HOME || homedir19(), ".local", "bin");
|
|
249023
249285
|
const paths = (env6.PATH ?? "/usr/bin:/bin").split(":");
|
|
249024
249286
|
if (!paths.includes(nativeBin))
|
|
249025
249287
|
paths.push(nativeBin);
|
|
@@ -249028,20 +249290,20 @@ function withNativeCliPath(env6, platform7 = process.platform) {
|
|
|
249028
249290
|
var init_native_cli_env = () => {};
|
|
249029
249291
|
|
|
249030
249292
|
// src/tools/impl/claude-repository-skills.ts
|
|
249031
|
-
import { mkdir as mkdir11, mkdtemp as
|
|
249032
|
-
import { tmpdir as
|
|
249033
|
-
import { basename as basename22, join as
|
|
249293
|
+
import { mkdir as mkdir11, mkdtemp as mkdtemp5, rm as rm9, stat as stat10, symlink as symlink3 } from "node:fs/promises";
|
|
249294
|
+
import { tmpdir as tmpdir14 } from "node:os";
|
|
249295
|
+
import { basename as basename22, join as join71 } from "node:path";
|
|
249034
249296
|
async function stageClaudeRepositorySkills(repositoryRoots) {
|
|
249035
249297
|
const directories = [];
|
|
249036
249298
|
let stagingRoot;
|
|
249037
249299
|
const cleanup = async () => {
|
|
249038
249300
|
if (stagingRoot)
|
|
249039
|
-
await
|
|
249301
|
+
await rm9(stagingRoot, { recursive: true, force: true });
|
|
249040
249302
|
};
|
|
249041
249303
|
try {
|
|
249042
249304
|
for (const repo of repositoryRoots) {
|
|
249043
249305
|
for (const source of [".claude", ".agents"]) {
|
|
249044
|
-
const skills =
|
|
249306
|
+
const skills = join71(repo, source, "skills");
|
|
249045
249307
|
const info = await stat10(skills).catch((error4) => {
|
|
249046
249308
|
if (error4.code === "ENOENT" || error4.code === "ENOTDIR")
|
|
249047
249309
|
return;
|
|
@@ -249049,11 +249311,11 @@ async function stageClaudeRepositorySkills(repositoryRoots) {
|
|
|
249049
249311
|
});
|
|
249050
249312
|
if (!info?.isDirectory())
|
|
249051
249313
|
continue;
|
|
249052
|
-
stagingRoot ??= await
|
|
249053
|
-
const directory =
|
|
249054
|
-
const claudeDir =
|
|
249314
|
+
stagingRoot ??= await mkdtemp5(join71(tmpdir14(), "letta-claude-skills-"));
|
|
249315
|
+
const directory = join71(stagingRoot, source, basename22(repo));
|
|
249316
|
+
const claudeDir = join71(directory, ".claude");
|
|
249055
249317
|
await mkdir11(claudeDir, { recursive: true });
|
|
249056
|
-
await symlink3(skills,
|
|
249318
|
+
await symlink3(skills, join71(claudeDir, "skills"), "dir");
|
|
249057
249319
|
directories.push(directory);
|
|
249058
249320
|
}
|
|
249059
249321
|
}
|
|
@@ -250648,7 +250910,7 @@ var init_codex_steer_receipt = __esm(() => {
|
|
|
250648
250910
|
});
|
|
250649
250911
|
|
|
250650
250912
|
// src/tools/impl/codex-app-server.ts
|
|
250651
|
-
import { join as
|
|
250913
|
+
import { join as join72 } from "node:path";
|
|
250652
250914
|
import { createInterface as createInterface10 } from "node:readline";
|
|
250653
250915
|
import { setTimeout as sleep12 } from "node:timers/promises";
|
|
250654
250916
|
async function listCodexModels(cwd2, env6) {
|
|
@@ -250771,7 +251033,7 @@ class CodexAppServerClient {
|
|
|
250771
251033
|
await this.request("initialize", {
|
|
250772
251034
|
clientInfo: {
|
|
250773
251035
|
name: "letta-code",
|
|
250774
|
-
version: "0.34.
|
|
251036
|
+
version: "0.34.74"
|
|
250775
251037
|
},
|
|
250776
251038
|
capabilities: null
|
|
250777
251039
|
});
|
|
@@ -251049,7 +251311,7 @@ async function createSession(options, deps) {
|
|
|
251049
251311
|
});
|
|
251050
251312
|
if (options.cloudSkillRepositories?.length) {
|
|
251051
251313
|
await client.request("skills/extraRoots/set", {
|
|
251052
|
-
extraRoots: cloudRepositoryRoots(options.cloudSkillRepositories).map((root2) =>
|
|
251314
|
+
extraRoots: cloudRepositoryRoots(options.cloudSkillRepositories).map((root2) => join72(root2, PROJECT_SKILLS_DIR))
|
|
251053
251315
|
});
|
|
251054
251316
|
}
|
|
251055
251317
|
const method2 = options.resumeThreadId ? "thread/resume" : "thread/start";
|
|
@@ -251319,7 +251581,7 @@ var init_codex_app_server = __esm(() => {
|
|
|
251319
251581
|
// src/tools/impl/cursor-session.ts
|
|
251320
251582
|
import { randomUUID as randomUUID41 } from "node:crypto";
|
|
251321
251583
|
import { existsSync as existsSync47 } from "node:fs";
|
|
251322
|
-
import { join as
|
|
251584
|
+
import { join as join73 } from "node:path";
|
|
251323
251585
|
import { createInterface as createInterface11 } from "node:readline";
|
|
251324
251586
|
import { fileURLToPath as fileURLToPath7 } from "node:url";
|
|
251325
251587
|
function key2(options, id) {
|
|
@@ -251475,7 +251737,7 @@ async function runCursorTurn(options, env6 = process.env, secrets2 = {}) {
|
|
|
251475
251737
|
type: "start",
|
|
251476
251738
|
sessionId: id,
|
|
251477
251739
|
resume: !!options.resumeSessionId,
|
|
251478
|
-
stateDir:
|
|
251740
|
+
stateDir: join73(resolveGlobalConfigDir(), "cursor-sessions", sessionKey),
|
|
251479
251741
|
cwd: options.cwd,
|
|
251480
251742
|
model: options.model,
|
|
251481
251743
|
reminder: options.mcpReminder,
|
|
@@ -252578,14 +252840,14 @@ var init_engine = __esm(() => {
|
|
|
252578
252840
|
import { createHash as createHash12, randomUUID as randomUUID42 } from "node:crypto";
|
|
252579
252841
|
import { readdirSync as readdirSync18, rmSync as rmSync17 } from "node:fs";
|
|
252580
252842
|
import {
|
|
252581
|
-
mkdtemp as
|
|
252843
|
+
mkdtemp as mkdtemp6,
|
|
252582
252844
|
open as open4,
|
|
252583
252845
|
readdir as readdir8,
|
|
252584
|
-
rm as
|
|
252846
|
+
rm as rm10,
|
|
252585
252847
|
stat as stat11
|
|
252586
252848
|
} from "node:fs/promises";
|
|
252587
|
-
import { homedir as homedir20, tmpdir as
|
|
252588
|
-
import { join as
|
|
252849
|
+
import { homedir as homedir20, tmpdir as tmpdir15 } from "node:os";
|
|
252850
|
+
import { join as join74 } from "node:path";
|
|
252589
252851
|
async function hashNativeSessionPrefix(input, size2) {
|
|
252590
252852
|
const hash = createHash12("sha256");
|
|
252591
252853
|
const buffer = Buffer.allocUnsafe(NATIVE_SESSION_CAPTURE_CHUNK_BYTES);
|
|
@@ -252635,7 +252897,7 @@ function cleanupSpoolDirectorySync(directory) {
|
|
|
252635
252897
|
}
|
|
252636
252898
|
async function cleanupSpoolDirectory(directory) {
|
|
252637
252899
|
try {
|
|
252638
|
-
await
|
|
252900
|
+
await rm10(directory, { recursive: true, force: true });
|
|
252639
252901
|
spoolDirectories.delete(directory);
|
|
252640
252902
|
} catch (error4) {
|
|
252641
252903
|
debugWarn("native-session", "Failed to delete native capture spool directory", error4);
|
|
@@ -252647,7 +252909,7 @@ function scavengeStaleSpoolDirectories() {
|
|
|
252647
252909
|
staleSpoolsScavenged = true;
|
|
252648
252910
|
let entries;
|
|
252649
252911
|
try {
|
|
252650
|
-
entries = readdirSync18(
|
|
252912
|
+
entries = readdirSync18(tmpdir15(), { withFileTypes: true });
|
|
252651
252913
|
} catch {
|
|
252652
252914
|
return;
|
|
252653
252915
|
}
|
|
@@ -252670,7 +252932,7 @@ function scavengeStaleSpoolDirectories() {
|
|
|
252670
252932
|
}
|
|
252671
252933
|
}
|
|
252672
252934
|
if (!ownerIsAlive)
|
|
252673
|
-
cleanupSpoolDirectorySync(
|
|
252935
|
+
cleanupSpoolDirectorySync(join74(tmpdir15(), entry.name));
|
|
252674
252936
|
}
|
|
252675
252937
|
}
|
|
252676
252938
|
function key3(source, sessionId) {
|
|
@@ -252823,9 +253085,9 @@ async function findNativeSessionPath(source, sessionId, env6 = process.env) {
|
|
|
252823
253085
|
return;
|
|
252824
253086
|
const home = env6.HOME || homedir20();
|
|
252825
253087
|
if (source === "claude_code") {
|
|
252826
|
-
const projects =
|
|
253088
|
+
const projects = join74(env6.CLAUDE_CONFIG_DIR || join74(home, ".claude"), "projects");
|
|
252827
253089
|
for (const project of await entries(projects, true)) {
|
|
252828
|
-
const path30 =
|
|
253090
|
+
const path30 = join74(projects, project, `${sessionId}.jsonl`);
|
|
252829
253091
|
try {
|
|
252830
253092
|
if ((await stat11(path30)).isFile())
|
|
252831
253093
|
return path30;
|
|
@@ -252836,14 +253098,14 @@ async function findNativeSessionPath(source, sessionId, env6 = process.env) {
|
|
|
252836
253098
|
}
|
|
252837
253099
|
return;
|
|
252838
253100
|
}
|
|
252839
|
-
const root2 =
|
|
253101
|
+
const root2 = join74(env6.CODEX_HOME || join74(home, ".codex"), "sessions");
|
|
252840
253102
|
for (const year of (await entries(root2, true)).filter((name) => /^\d{4}$/.test(name)))
|
|
252841
|
-
for (const month of (await entries(
|
|
252842
|
-
for (const day of (await entries(
|
|
252843
|
-
const directory =
|
|
253103
|
+
for (const month of (await entries(join74(root2, year), true)).filter((name) => /^\d{2}$/.test(name)))
|
|
253104
|
+
for (const day of (await entries(join74(root2, year, month), true)).filter((name) => /^\d{2}$/.test(name))) {
|
|
253105
|
+
const directory = join74(root2, year, month, day);
|
|
252844
253106
|
for (const file of await entries(directory, false))
|
|
252845
253107
|
if (file.startsWith("rollout-") && file.endsWith(`-${sessionId}.jsonl`))
|
|
252846
|
-
return
|
|
253108
|
+
return join74(directory, file);
|
|
252847
253109
|
}
|
|
252848
253110
|
return;
|
|
252849
253111
|
}
|
|
@@ -252860,9 +253122,9 @@ async function seal(state2, source, sessionId, scope, env6, requestOptions) {
|
|
|
252860
253122
|
throw new Error("Native session file disappeared before EOF capture");
|
|
252861
253123
|
throw error4;
|
|
252862
253124
|
}
|
|
252863
|
-
const directory = await
|
|
253125
|
+
const directory = await mkdtemp6(join74(tmpdir15(), `letta-native-session-${process.pid}-${captureProcessInstanceId}-`));
|
|
252864
253126
|
spoolDirectories.add(directory);
|
|
252865
|
-
const spoolPath =
|
|
253127
|
+
const spoolPath = join74(directory, "segment");
|
|
252866
253128
|
let output;
|
|
252867
253129
|
let retained = false;
|
|
252868
253130
|
try {
|
|
@@ -252979,7 +253241,7 @@ async function drain(state2, source, sessionId) {
|
|
|
252979
253241
|
await spool.close();
|
|
252980
253242
|
}
|
|
252981
253243
|
state2.segments.shift();
|
|
252982
|
-
const directory =
|
|
253244
|
+
const directory = join74(segment.path, "..");
|
|
252983
253245
|
await cleanupSpoolDirectory(directory);
|
|
252984
253246
|
}
|
|
252985
253247
|
}
|
|
@@ -253011,7 +253273,7 @@ async function discardRejectedSegment(state2) {
|
|
|
253011
253273
|
const segment = state2.segments.shift();
|
|
253012
253274
|
if (!segment)
|
|
253013
253275
|
return;
|
|
253014
|
-
const directory =
|
|
253276
|
+
const directory = join74(segment.path, "..");
|
|
253015
253277
|
await cleanupSpoolDirectory(directory);
|
|
253016
253278
|
state2.ackedOffset = segment.end;
|
|
253017
253279
|
state2.retryDelayMs = INITIAL_DRAIN_RETRY_MS;
|
|
@@ -254411,7 +254673,7 @@ var init_fork_conversation = __esm(() => {
|
|
|
254411
254673
|
|
|
254412
254674
|
// src/agent/subagents/sandbox.ts
|
|
254413
254675
|
import { mkdirSync as mkdirSync39 } from "node:fs";
|
|
254414
|
-
import { join as
|
|
254676
|
+
import { join as join75 } from "node:path";
|
|
254415
254677
|
function wrapSubagentLauncher(input) {
|
|
254416
254678
|
const env6 = input.env ?? process.env;
|
|
254417
254679
|
if (!isFsSandboxEnabled(env6))
|
|
@@ -254454,7 +254716,7 @@ function wrapSubagentLauncher(input) {
|
|
|
254454
254716
|
if (!wrapped || wrapped.length === 0)
|
|
254455
254717
|
return null;
|
|
254456
254718
|
const [command, ...args] = wrapped;
|
|
254457
|
-
const scratchRoot =
|
|
254719
|
+
const scratchRoot = join75(getLettaHomeRoot(), "tmp");
|
|
254458
254720
|
mkdirSync39(scratchRoot, { recursive: true });
|
|
254459
254721
|
return {
|
|
254460
254722
|
command,
|
|
@@ -255570,8 +255832,8 @@ var FORK_PROMPT_CHARACTER_LIMIT = 2000;
|
|
|
255570
255832
|
// src/agent/memory-conflict-repair.ts
|
|
255571
255833
|
import { execFile as execFile15 } from "node:child_process";
|
|
255572
255834
|
import { randomUUID as randomUUID45 } from "node:crypto";
|
|
255573
|
-
import { readFile as readFile18, rm as
|
|
255574
|
-
import { join as
|
|
255835
|
+
import { readFile as readFile18, rm as rm11, writeFile as writeFile13 } from "node:fs/promises";
|
|
255836
|
+
import { join as join76 } from "node:path";
|
|
255575
255837
|
import { promisify as promisify15 } from "node:util";
|
|
255576
255838
|
async function readOptional(path30) {
|
|
255577
255839
|
try {
|
|
@@ -255592,7 +255854,7 @@ async function describeMemoryConflict(memoryDir, gitDir) {
|
|
|
255592
255854
|
]);
|
|
255593
255855
|
head4 = stdout.trim();
|
|
255594
255856
|
} catch {}
|
|
255595
|
-
const heads = await Promise.all(OPERATION_HEADS.map((name) => readOptional(
|
|
255857
|
+
const heads = await Promise.all(OPERATION_HEADS.map((name) => readOptional(join76(gitDir, name))));
|
|
255596
255858
|
return [head4, ...heads].join(`
|
|
255597
255859
|
`);
|
|
255598
255860
|
}
|
|
@@ -255612,7 +255874,7 @@ ${stdout.trim()}`;
|
|
|
255612
255874
|
}
|
|
255613
255875
|
}
|
|
255614
255876
|
async function attemptPath(memoryDir) {
|
|
255615
|
-
return
|
|
255877
|
+
return join76(await getMemoryGitDir(memoryDir), ATTEMPT_FILE);
|
|
255616
255878
|
}
|
|
255617
255879
|
async function readAttempt(path30) {
|
|
255618
255880
|
try {
|
|
@@ -255646,7 +255908,7 @@ async function claimMemoryConflictRepair(memoryDir, kind = "conflict") {
|
|
|
255646
255908
|
let signature;
|
|
255647
255909
|
try {
|
|
255648
255910
|
const gitDir = await getMemoryGitDir(memoryDir);
|
|
255649
|
-
path30 =
|
|
255911
|
+
path30 = join76(gitDir, ATTEMPT_FILE);
|
|
255650
255912
|
signature = kind === "invalid" ? await describeInvalidMemoryHistory(memoryDir) : await describeMemoryConflict(memoryDir, gitDir);
|
|
255651
255913
|
} catch {
|
|
255652
255914
|
return { status: "claimed", token: token2 };
|
|
@@ -255687,7 +255949,7 @@ async function completeMemoryConflictRepair(memoryDir, token2) {
|
|
|
255687
255949
|
async function clearMemoryConflictRepair(memoryDir, token2) {
|
|
255688
255950
|
await transition(memoryDir, async (path30, attempt2) => {
|
|
255689
255951
|
if (attempt2.token === token2)
|
|
255690
|
-
await
|
|
255952
|
+
await rm11(path30, { force: true });
|
|
255691
255953
|
});
|
|
255692
255954
|
}
|
|
255693
255955
|
var ATTEMPT_FILE = "letta-memory-repair.json", OPERATION_HEADS, MARKER_LOCK, CLAIM_TIMEOUT_MS = 5000;
|
|
@@ -255707,15 +255969,15 @@ var init_memory_conflict_repair = __esm(() => {
|
|
|
255707
255969
|
|
|
255708
255970
|
// src/agent/subagents/memory-handoff.ts
|
|
255709
255971
|
import { randomUUID as randomUUID46 } from "node:crypto";
|
|
255710
|
-
import { mkdir as mkdir12, rm as
|
|
255711
|
-
import { join as
|
|
255972
|
+
import { mkdir as mkdir12, rm as rm12, writeFile as writeFile14 } from "node:fs/promises";
|
|
255973
|
+
import { join as join77 } from "node:path";
|
|
255712
255974
|
async function withMemoryHandoff(params, run) {
|
|
255713
255975
|
const handoff = await prepareMemoryHandoff(params);
|
|
255714
255976
|
try {
|
|
255715
255977
|
return await run(handoff);
|
|
255716
255978
|
} finally {
|
|
255717
255979
|
if (handoff.transcriptPath)
|
|
255718
|
-
await
|
|
255980
|
+
await rm12(handoff.transcriptPath, { force: true });
|
|
255719
255981
|
}
|
|
255720
255982
|
}
|
|
255721
255983
|
async function prepareMemoryHandoff(params) {
|
|
@@ -255743,9 +256005,9 @@ async function prepareMemoryHandoff(params) {
|
|
|
255743
256005
|
break;
|
|
255744
256006
|
after2 = cursor;
|
|
255745
256007
|
}
|
|
255746
|
-
const directory =
|
|
256008
|
+
const directory = join77(getTranscriptRoot(), params.agentId, "memory-handoffs");
|
|
255747
256009
|
await mkdir12(directory, { recursive: true, mode: 448 });
|
|
255748
|
-
transcriptPath =
|
|
256010
|
+
transcriptPath = join77(directory, `${randomUUID46()}.json`);
|
|
255749
256011
|
await writeFile14(transcriptPath, JSON.stringify(messages, null, 2), {
|
|
255750
256012
|
mode: 292,
|
|
255751
256013
|
flag: "wx"
|
|
@@ -258279,7 +258541,7 @@ async function send_agent_message(args, deps = {}) {
|
|
|
258279
258541
|
content: JSON.stringify({
|
|
258280
258542
|
status: "accepted",
|
|
258281
258543
|
agent_id: args.agent_id,
|
|
258282
|
-
delivery: externalTarget.type === "antigravity" ? "queued" : externalTarget.type === "cursor" ? "run/steer" : "session/abort+prompt"
|
|
258544
|
+
delivery: externalTarget.type === "antigravity" ? "queued" in receipt3 && receipt3.queued ? "queued" : "session/prompt" : externalTarget.type === "cursor" ? "run/steer" : "session/abort+prompt"
|
|
258283
258545
|
}),
|
|
258284
258546
|
status: "success"
|
|
258285
258547
|
};
|
|
@@ -258692,7 +258954,7 @@ __export(exports_skill, {
|
|
|
258692
258954
|
});
|
|
258693
258955
|
import { existsSync as existsSync48, readdirSync as readdirSync19 } from "node:fs";
|
|
258694
258956
|
import { readFile as readFile19 } from "node:fs/promises";
|
|
258695
|
-
import { dirname as dirname31, join as
|
|
258957
|
+
import { dirname as dirname31, join as join78 } from "node:path";
|
|
258696
258958
|
async function readSkillFromRoot(skillsRoot, skillId) {
|
|
258697
258959
|
const discovery = await discoverSkills(skillsRoot, undefined, {
|
|
258698
258960
|
sources: ["project"],
|
|
@@ -258713,11 +258975,11 @@ function getMemorySkillsDirs2(agentId) {
|
|
|
258713
258975
|
const dirs = new Set;
|
|
258714
258976
|
const scopedMemoryDir = resolveScopedMemoryDir({ agentId });
|
|
258715
258977
|
if (scopedMemoryDir && scopedMemoryDir.trim().length > 0 && existsSync48(scopedMemoryDir)) {
|
|
258716
|
-
dirs.add(
|
|
258978
|
+
dirs.add(join78(scopedMemoryDir.trim(), "skills"));
|
|
258717
258979
|
} else {
|
|
258718
258980
|
const fallbackMemoryDir = (process.env.LETTA_MEMORY_DIR || process.env.MEMORY_DIR || "").trim();
|
|
258719
258981
|
if (fallbackMemoryDir) {
|
|
258720
|
-
dirs.add(
|
|
258982
|
+
dirs.add(join78(fallbackMemoryDir, "skills"));
|
|
258721
258983
|
}
|
|
258722
258984
|
}
|
|
258723
258985
|
return Array.from(dirs);
|
|
@@ -258743,7 +259005,7 @@ function listSkillResources(skillMdPath) {
|
|
|
258743
259005
|
return;
|
|
258744
259006
|
}
|
|
258745
259007
|
if (entry.isDirectory()) {
|
|
258746
|
-
walk3(
|
|
259008
|
+
walk3(join78(directory, entry.name), relativePath);
|
|
258747
259009
|
if (truncated2) {
|
|
258748
259010
|
return;
|
|
258749
259011
|
}
|
|
@@ -258757,7 +259019,7 @@ function listSkillResources(skillMdPath) {
|
|
|
258757
259019
|
}
|
|
258758
259020
|
async function readSkillContent(skillId, skillsDir, agentId, options = {}) {
|
|
258759
259021
|
const projectSkillsDirs = new Set([
|
|
258760
|
-
|
|
259022
|
+
join78(getCurrentWorkingDirectory(), PROJECT_SKILLS_DIR),
|
|
258761
259023
|
skillsDir,
|
|
258762
259024
|
...getSkillSources().includes("project") ? getCloudProjectSkillDirectories().reverse() : []
|
|
258763
259025
|
]);
|
|
@@ -258806,8 +259068,8 @@ async function readSkillContent(skillId, skillsDir, agentId, options = {}) {
|
|
|
258806
259068
|
} catch {}
|
|
258807
259069
|
}
|
|
258808
259070
|
try {
|
|
258809
|
-
const bundledSkillsDir =
|
|
258810
|
-
const bundledSkillPath =
|
|
259071
|
+
const bundledSkillsDir = join78(process.cwd(), "skills", "skills");
|
|
259072
|
+
const bundledSkillPath = join78(bundledSkillsDir, skillId, "SKILL.md");
|
|
258811
259073
|
const content = await readFile19(bundledSkillPath, "utf-8");
|
|
258812
259074
|
return { content, path: bundledSkillPath };
|
|
258813
259075
|
} catch {
|
|
@@ -258819,7 +259081,7 @@ async function getResolvedSkillsDir() {
|
|
|
258819
259081
|
if (skillsDir) {
|
|
258820
259082
|
return skillsDir;
|
|
258821
259083
|
}
|
|
258822
|
-
return
|
|
259084
|
+
return join78(getCurrentWorkingDirectory(), SKILLS_DIR);
|
|
258823
259085
|
}
|
|
258824
259086
|
function getResolvedAgentId(args) {
|
|
258825
259087
|
if (args.parentScope?.agentId) {
|
|
@@ -260511,7 +260773,7 @@ import {
|
|
|
260511
260773
|
rmSync as rmSync19,
|
|
260512
260774
|
writeFileSync as writeFileSync34
|
|
260513
260775
|
} from "node:fs";
|
|
260514
|
-
import { dirname as dirname32, join as
|
|
260776
|
+
import { dirname as dirname32, join as join79 } from "node:path";
|
|
260515
260777
|
import { setTimeout as delay7 } from "node:timers/promises";
|
|
260516
260778
|
function errorText(error4) {
|
|
260517
260779
|
const message2 = error4 instanceof Error ? error4.message : String(error4);
|
|
@@ -260629,7 +260891,7 @@ async function watch_pr(args, deps = {}) {
|
|
|
260629
260891
|
const scope = resolveNotificationScope(parentScope);
|
|
260630
260892
|
let snapshotPath;
|
|
260631
260893
|
try {
|
|
260632
|
-
snapshotPath = scope && !isRun ?
|
|
260894
|
+
snapshotPath = scope && !isRun ? join79(resolveGlobalConfigDir(), "cache", "watch-pr", `${createHash13("sha256").update(JSON.stringify([
|
|
260633
260895
|
scope.agentId,
|
|
260634
260896
|
scope.conversationId,
|
|
260635
260897
|
ref.owner.toLowerCase(),
|
|
@@ -260909,7 +261171,7 @@ var init_watch_pr = __esm(() => {
|
|
|
260909
261171
|
// src/tools/workflow/sdk-loader.ts
|
|
260910
261172
|
import { existsSync as existsSync49, readFileSync as readFileSync43 } from "node:fs";
|
|
260911
261173
|
import { createRequire as createRequire6 } from "node:module";
|
|
260912
|
-
import { dirname as dirname33, join as
|
|
261174
|
+
import { dirname as dirname33, join as join80 } from "node:path";
|
|
260913
261175
|
import { fileURLToPath as fileURLToPath8, pathToFileURL as pathToFileURL3 } from "node:url";
|
|
260914
261176
|
function supportsPublishedResume(version3) {
|
|
260915
261177
|
if (!version3 || !MIN_RESUME_SDK_VERSION)
|
|
@@ -260938,7 +261200,7 @@ function preferRunningCliForSubagents() {
|
|
|
260938
261200
|
function packageVersion(entry) {
|
|
260939
261201
|
for (let dir = dirname33(entry);; dir = dirname33(dir)) {
|
|
260940
261202
|
try {
|
|
260941
|
-
const manifest = JSON.parse(readFileSync43(
|
|
261203
|
+
const manifest = JSON.parse(readFileSync43(join80(dir, "package.json"), "utf8"));
|
|
260942
261204
|
if (manifest.name === SDK_PACKAGE)
|
|
260943
261205
|
return manifest.version;
|
|
260944
261206
|
} catch {}
|
|
@@ -260948,10 +261210,10 @@ function packageVersion(entry) {
|
|
|
260948
261210
|
}
|
|
260949
261211
|
function packageEntry(packageDir) {
|
|
260950
261212
|
try {
|
|
260951
|
-
const manifest = JSON.parse(readFileSync43(
|
|
261213
|
+
const manifest = JSON.parse(readFileSync43(join80(packageDir, "package.json"), "utf8"));
|
|
260952
261214
|
const root2 = manifest.exports?.["."];
|
|
260953
261215
|
const entry = typeof root2 === "string" ? root2 : root2?.import ?? root2?.default ?? manifest.main;
|
|
260954
|
-
return entry ?
|
|
261216
|
+
return entry ? join80(packageDir, entry) : null;
|
|
260955
261217
|
} catch {
|
|
260956
261218
|
return null;
|
|
260957
261219
|
}
|
|
@@ -260961,8 +261223,8 @@ function probeInstalledSdkDirs(startDirs) {
|
|
|
260961
261223
|
for (const start2 of startDirs) {
|
|
260962
261224
|
let dir = start2;
|
|
260963
261225
|
while (true) {
|
|
260964
|
-
const candidate =
|
|
260965
|
-
if (existsSync49(
|
|
261226
|
+
const candidate = join80(dir, "node_modules", ...SDK_PACKAGE.split("/"));
|
|
261227
|
+
if (existsSync49(join80(candidate, "package.json")) && !found.includes(candidate)) {
|
|
260966
261228
|
found.push(candidate);
|
|
260967
261229
|
}
|
|
260968
261230
|
const parent = dirname33(dir);
|
|
@@ -260980,7 +261242,7 @@ async function loadAgentSdk() {
|
|
|
260980
261242
|
const specifiers = [];
|
|
260981
261243
|
if (envPath) {
|
|
260982
261244
|
try {
|
|
260983
|
-
const require2 = createRequire6(
|
|
261245
|
+
const require2 = createRequire6(join80(envPath, "noop.js"));
|
|
260984
261246
|
specifiers.push(pathToFileURL3(require2.resolve(envPath)).href);
|
|
260985
261247
|
} catch {
|
|
260986
261248
|
specifiers.push(pathToFileURL3(envPath).href);
|
|
@@ -260991,7 +261253,7 @@ async function loadAgentSdk() {
|
|
|
260991
261253
|
specifiers.push(pathToFileURL3(require2.resolve(SDK_PACKAGE)).href);
|
|
260992
261254
|
} catch {}
|
|
260993
261255
|
try {
|
|
260994
|
-
const require2 = createRequire6(
|
|
261256
|
+
const require2 = createRequire6(join80(process.cwd(), "package.json"));
|
|
260995
261257
|
specifiers.push(pathToFileURL3(require2.resolve(SDK_PACKAGE)).href);
|
|
260996
261258
|
} catch {
|
|
260997
261259
|
specifiers.push(SDK_PACKAGE);
|
|
@@ -261541,7 +261803,7 @@ var init_sdk_spawner = __esm(() => {
|
|
|
261541
261803
|
|
|
261542
261804
|
// src/tools/impl/workflow.ts
|
|
261543
261805
|
import { readFileSync as readFileSync44 } from "node:fs";
|
|
261544
|
-
import { join as
|
|
261806
|
+
import { join as join81, resolve as resolve36 } from "node:path";
|
|
261545
261807
|
async function createSdkSpawnerHandle(args, setStage = () => {}) {
|
|
261546
261808
|
setStage("resolving parent agent");
|
|
261547
261809
|
const parentAgentId = await resolveScriptParentAgentId(args);
|
|
@@ -261693,7 +261955,7 @@ function formatCompletionResult(run, executionDir) {
|
|
|
261693
261955
|
return [
|
|
261694
261956
|
payload,
|
|
261695
261957
|
"",
|
|
261696
|
-
`Per-call results: ${
|
|
261958
|
+
`Per-call results: ${join81(executionDir, "journal.jsonl")} — one line per completed agent call with its full return value, plus one per decide() API attempt (retries included) with its model, cost, calibration, and tokens.`,
|
|
261697
261959
|
"If the result above is empty or unexpected, read that file BEFORE diagnosing — do not assume agents returned non-empty results."
|
|
261698
261960
|
].join(`
|
|
261699
261961
|
`);
|
|
@@ -263476,7 +263738,7 @@ var init_interrupted_turn_schema = __esm(() => {
|
|
|
263476
263738
|
// src/websocket/listener/interrupted-turn-storage.ts
|
|
263477
263739
|
import { createHash as createHash14 } from "node:crypto";
|
|
263478
263740
|
import { closeSync as closeSync10, fsyncSync as fsyncSync4, openSync as openSync10, writeFileSync as writeFileSync35 } from "node:fs";
|
|
263479
|
-
import { join as
|
|
263741
|
+
import { join as join82 } from "node:path";
|
|
263480
263742
|
function writeInterruptedTurnRecordFile(temporary, destination, directory, record5, syncDirectory) {
|
|
263481
263743
|
writeFileSync35(temporary, JSON.stringify(record5), {
|
|
263482
263744
|
mode: 384,
|
|
@@ -263502,7 +263764,7 @@ function defaultInterruptedTurnDirectory() {
|
|
|
263502
263764
|
} catch {
|
|
263503
263765
|
serverUrl = process.env.LETTA_BASE_URL ?? "uninitialized";
|
|
263504
263766
|
}
|
|
263505
|
-
return
|
|
263767
|
+
return join82(resolveGlobalConfigDir(), "listener-state", createHash14("sha256").update(serverUrl).digest("hex").slice(0, 24));
|
|
263506
263768
|
}
|
|
263507
263769
|
var init_interrupted_turn_storage = __esm(() => {
|
|
263508
263770
|
init_server_url();
|
|
@@ -263581,14 +263843,14 @@ import {
|
|
|
263581
263843
|
statSync as statSync21,
|
|
263582
263844
|
writeFileSync as writeFileSync36
|
|
263583
263845
|
} from "node:fs";
|
|
263584
|
-
import { join as
|
|
263846
|
+
import { join as join83 } from "node:path";
|
|
263585
263847
|
function createRecoveryLineageSidecarAccess(params) {
|
|
263586
263848
|
const canonicalSidecarName = /\.json\.recovery-[0-9a-f]{24}$/;
|
|
263587
263849
|
const temporarySidecarName = /^(.+\.json)\.recovery-[0-9a-f]{24}\.(\d+)\.([0-9a-f-]{36})\.[0-9a-f-]{36}\.tmp$/;
|
|
263588
263850
|
const legacyTemporarySidecarName = /^(.+\.json)\.recovery-[0-9a-f]{24}\.(\d+)\.[0-9a-f-]{36}\.tmp$/;
|
|
263589
263851
|
const staleTemporaryAgeMs = 60000;
|
|
263590
263852
|
const maximumTemporaryAgeMs = 24 * 60 * 60 * 1000;
|
|
263591
|
-
const path33 = (agentId, conversationId, lineageId) =>
|
|
263853
|
+
const path33 = (agentId, conversationId, lineageId) => join83(params.directory, `${encodeURIComponent(agentId)}_${encodeURIComponent(conversationId)}.json.recovery-${createHash15("sha256").update(lineageId).digest("hex").slice(0, 24)}`);
|
|
263592
263854
|
const isSidecar = (value) => {
|
|
263593
263855
|
if (!value || typeof value !== "object")
|
|
263594
263856
|
return false;
|
|
@@ -263867,10 +264129,10 @@ function createRecoveryLineageSidecarAccess(params) {
|
|
|
263867
264129
|
const removeMalformedOrphan = (file) => {
|
|
263868
264130
|
const separator = file.indexOf(".recovery-");
|
|
263869
264131
|
const mainFile = separator >= 0 ? file.slice(0, separator) : "";
|
|
263870
|
-
if (!mainFile || existsSync50(
|
|
264132
|
+
if (!mainFile || existsSync50(join83(params.directory, mainFile)))
|
|
263871
264133
|
return;
|
|
263872
264134
|
try {
|
|
263873
|
-
rmSync20(
|
|
264135
|
+
rmSync20(join83(params.directory, file), { force: true });
|
|
263874
264136
|
params.syncDirectory(params.directory);
|
|
263875
264137
|
} catch {}
|
|
263876
264138
|
};
|
|
@@ -263897,13 +264159,13 @@ function createRecoveryLineageSidecarAccess(params) {
|
|
|
263897
264159
|
ownerIsAlive = error4.code !== "ESRCH";
|
|
263898
264160
|
}
|
|
263899
264161
|
}
|
|
263900
|
-
const ageMs = Date.now() - statSync21(
|
|
264162
|
+
const ageMs = Date.now() - statSync21(join83(params.directory, file)).mtimeMs;
|
|
263901
264163
|
if (!ownerIsCurrentWriter && (!ownerIsAlive && ageMs >= staleTemporaryAgeMs || ageMs >= maximumTemporaryAgeMs)) {
|
|
263902
|
-
const release = acquireDurableFileLock(
|
|
264164
|
+
const release = acquireDurableFileLock(join83(params.directory, mainFile), { waitMs: params.lockWaitMs });
|
|
263903
264165
|
try {
|
|
263904
|
-
const currentAgeMs = Date.now() - statSync21(
|
|
264166
|
+
const currentAgeMs = Date.now() - statSync21(join83(params.directory, file)).mtimeMs;
|
|
263905
264167
|
if (!ownerIsCurrentWriter && (!ownerIsAlive && currentAgeMs >= staleTemporaryAgeMs || currentAgeMs >= maximumTemporaryAgeMs)) {
|
|
263906
|
-
rmSync20(
|
|
264168
|
+
rmSync20(join83(params.directory, file), { force: true });
|
|
263907
264169
|
params.syncDirectory(params.directory);
|
|
263908
264170
|
}
|
|
263909
264171
|
} finally {
|
|
@@ -263914,8 +264176,8 @@ function createRecoveryLineageSidecarAccess(params) {
|
|
|
263914
264176
|
}
|
|
263915
264177
|
return files.filter((file) => canonicalSidecarName.test(file)).flatMap((file) => {
|
|
263916
264178
|
try {
|
|
263917
|
-
const value = JSON.parse(readFileSync45(
|
|
263918
|
-
if (isSidecar(value) &&
|
|
264179
|
+
const value = JSON.parse(readFileSync45(join83(params.directory, file), "utf8"));
|
|
264180
|
+
if (isSidecar(value) && join83(params.directory, file) === path33(value.agentId, value.conversationId, value.lineageId)) {
|
|
263919
264181
|
return [value];
|
|
263920
264182
|
}
|
|
263921
264183
|
removeMalformedOrphan(file);
|
|
@@ -263965,7 +264227,7 @@ import {
|
|
|
263965
264227
|
unlinkSync as unlinkSync14,
|
|
263966
264228
|
writeFileSync as writeFileSync37
|
|
263967
264229
|
} from "node:fs";
|
|
263968
|
-
import { join as
|
|
264230
|
+
import { join as join84 } from "node:path";
|
|
263969
264231
|
function createInterruptedTurnStore(directory = defaultInterruptedTurnDirectory(), dependencies = {}) {
|
|
263970
264232
|
const sync = dependencies.fsyncDirectory ?? fsyncInterruptedTurnDirectory;
|
|
263971
264233
|
function persist(destination, record5) {
|
|
@@ -263977,7 +264239,7 @@ function createInterruptedTurnStore(directory = defaultInterruptedTurnDirectory(
|
|
|
263977
264239
|
}
|
|
263978
264240
|
}
|
|
263979
264241
|
function path33(agentId, conversationId) {
|
|
263980
|
-
return
|
|
264242
|
+
return join84(directory, `${encodeURIComponent(agentId)}_${encodeURIComponent(conversationId)}.json`);
|
|
263981
264243
|
}
|
|
263982
264244
|
function readRecordOrThrow(file) {
|
|
263983
264245
|
try {
|
|
@@ -266399,10 +266661,10 @@ var init_input_disposition_expiry = __esm(() => {
|
|
|
266399
266661
|
|
|
266400
266662
|
// src/websocket/listener/input-disposition-path.ts
|
|
266401
266663
|
import { createHash as createHash16 } from "node:crypto";
|
|
266402
|
-
import { join as
|
|
266664
|
+
import { join as join85 } from "node:path";
|
|
266403
266665
|
function inputDispositionPersistentPath(serverUrl) {
|
|
266404
266666
|
const namespace = createHash16("sha256").update(serverUrl).digest("hex").slice(0, 24);
|
|
266405
|
-
return
|
|
266667
|
+
return join85(resolveGlobalConfigDir(), "state", namespace, "input-dispositions-v2.json");
|
|
266406
266668
|
}
|
|
266407
266669
|
var init_input_disposition_path = __esm(() => {
|
|
266408
266670
|
init_settings_path();
|
|
@@ -267034,7 +267296,7 @@ import {
|
|
|
267034
267296
|
rmSync as rmSync22,
|
|
267035
267297
|
writeFileSync as writeFileSync39
|
|
267036
267298
|
} from "node:fs";
|
|
267037
|
-
import { join as
|
|
267299
|
+
import { join as join86 } from "node:path";
|
|
267038
267300
|
function terminalAuthorityStatus(runtime, terminal, terminals, interruptedStore = createInterruptedTurnStore()) {
|
|
267039
267301
|
const { owner } = terminal;
|
|
267040
267302
|
if (!owner.recoveryLineageId)
|
|
@@ -267091,7 +267353,7 @@ function defaultTurnFinishedDirectory() {
|
|
|
267091
267353
|
} catch {
|
|
267092
267354
|
serverUrl = process.env.LETTA_BASE_URL ?? "uninitialized";
|
|
267093
267355
|
}
|
|
267094
|
-
return
|
|
267356
|
+
return join86(resolveGlobalConfigDir(), "listener-terminal-state", Buffer.from(serverUrl).toString("base64url"));
|
|
267095
267357
|
}
|
|
267096
267358
|
function encodeTurnFinishedScope(agentId, conversationId) {
|
|
267097
267359
|
return Buffer.from(JSON.stringify([agentId, conversationId])).toString("base64url");
|
|
@@ -267119,7 +267381,7 @@ function fsyncDirectory2(directory) {
|
|
|
267119
267381
|
}
|
|
267120
267382
|
function createTurnFinishedStore(directory = defaultTurnFinishedDirectory(), options = {}) {
|
|
267121
267383
|
const claimantToken = randomUUID53();
|
|
267122
|
-
const path33 = (agentId, conversationId) =>
|
|
267384
|
+
const path33 = (agentId, conversationId) => join86(directory, `${encodeTurnFinishedScope(agentId, conversationId)}.json`);
|
|
267123
267385
|
const readRecord2 = (agentId, conversationId) => {
|
|
267124
267386
|
try {
|
|
267125
267387
|
const record5 = JSON.parse(readFileSync48(path33(agentId, conversationId), "utf8"));
|
|
@@ -277731,7 +277993,7 @@ import {
|
|
|
277731
277993
|
unlinkSync as unlinkSync16,
|
|
277732
277994
|
writeFileSync as writeFileSync40
|
|
277733
277995
|
} from "node:fs";
|
|
277734
|
-
import { join as
|
|
277996
|
+
import { join as join87 } from "node:path";
|
|
277735
277997
|
function truncateStr(value, maxLen) {
|
|
277736
277998
|
if (value === null || value === undefined)
|
|
277737
277999
|
return "";
|
|
@@ -277795,8 +278057,8 @@ class ChunkLog {
|
|
|
277795
278057
|
agentDir = null;
|
|
277796
278058
|
dirCreated = false;
|
|
277797
278059
|
init(agentId, sessionId) {
|
|
277798
|
-
this.agentDir =
|
|
277799
|
-
this.logPath =
|
|
278060
|
+
this.agentDir = join87(LOG_BASE_DIR, agentId);
|
|
278061
|
+
this.logPath = join87(this.agentDir, `${sessionId}.jsonl`);
|
|
277800
278062
|
this.buffer = [];
|
|
277801
278063
|
this.dirty = false;
|
|
277802
278064
|
this.dirCreated = false;
|
|
@@ -277857,7 +278119,7 @@ class ChunkLog {
|
|
|
277857
278119
|
const toDelete = files.slice(0, files.length - MAX_SESSION_FILES2 + 1);
|
|
277858
278120
|
for (const file of toDelete) {
|
|
277859
278121
|
try {
|
|
277860
|
-
unlinkSync16(
|
|
278122
|
+
unlinkSync16(join87(this.agentDir, file));
|
|
277861
278123
|
} catch (e2) {
|
|
277862
278124
|
debugWarn("chunkLog", `Failed to delete old session log ${file}: ${e2 instanceof Error ? e2.message : String(e2)}`);
|
|
277863
278125
|
}
|
|
@@ -277872,7 +278134,7 @@ var MAX_ENTRIES = 100, CONTENT_TRUNCATE_LEN = 200, MAX_SESSION_FILES2 = 5, LOG_B
|
|
|
277872
278134
|
var init_chunk_log = __esm(() => {
|
|
277873
278135
|
init_debug();
|
|
277874
278136
|
init_settings_path();
|
|
277875
|
-
LOG_BASE_DIR =
|
|
278137
|
+
LOG_BASE_DIR = join87(resolveGlobalConfigDir(), "logs", "chunk-logs");
|
|
277876
278138
|
chunkLog = new ChunkLog;
|
|
277877
278139
|
});
|
|
277878
278140
|
|
|
@@ -450587,8 +450849,8 @@ var init_mod_adapter = __esm(() => {
|
|
|
450587
450849
|
|
|
450588
450850
|
// src/websocket/listener/memfs-sync.ts
|
|
450589
450851
|
import { execFileSync as execFileSync11 } from "node:child_process";
|
|
450590
|
-
import { lstat as lstat2, realpath as realpath6, rm as
|
|
450591
|
-
import { isAbsolute as isAbsolute26, join as
|
|
450852
|
+
import { lstat as lstat2, realpath as realpath6, rm as rm13 } from "node:fs/promises";
|
|
450853
|
+
import { isAbsolute as isAbsolute26, join as join88, relative as relative7, resolve as resolve37, sep as sep8 } from "node:path";
|
|
450592
450854
|
async function removeRefusedCheckout(agentId, error4) {
|
|
450593
450855
|
const message2 = error4 instanceof Error ? error4.message : String(error4);
|
|
450594
450856
|
if (isLocalBackendEnvEnabled() || !/(?:returned error:|HTTP(?: status)?)[ :]*403\b/i.test(message2))
|
|
@@ -450599,14 +450861,14 @@ async function removeRefusedCheckout(agentId, error4) {
|
|
|
450599
450861
|
const configDir = await realpath6(resolveGlobalConfigDir());
|
|
450600
450862
|
if (!agentId || agentId === "." || agentId === ".." || /[/\\]/.test(agentId))
|
|
450601
450863
|
return;
|
|
450602
|
-
const expected =
|
|
450864
|
+
const expected = join88(configDir, "agents", agentId, "memory");
|
|
450603
450865
|
const checkout = resolve37(getScopedMemoryFilesystemRoot2(agentId));
|
|
450604
450866
|
if (await realpath6(checkout) !== expected || !(await lstat2(checkout)).isDirectory())
|
|
450605
450867
|
return;
|
|
450606
450868
|
const cwdRelative = relative7(expected, await realpath6(process.cwd()));
|
|
450607
450869
|
if (!cwdRelative || !cwdRelative.startsWith(`..${sep8}`) && cwdRelative !== ".." && !isAbsolute26(cwdRelative))
|
|
450608
450870
|
return;
|
|
450609
|
-
if (!(await lstat2(
|
|
450871
|
+
if (!(await lstat2(join88(checkout, ".git"))).isDirectory())
|
|
450610
450872
|
return;
|
|
450611
450873
|
const origin = execFileSync11("git", ["-C", checkout, "remote", "get-url", "origin"], {
|
|
450612
450874
|
encoding: "utf8",
|
|
@@ -450615,7 +450877,7 @@ async function removeRefusedCheckout(agentId, error4) {
|
|
|
450615
450877
|
}).trim();
|
|
450616
450878
|
if (!isMemfsRemoteUrlForAgent2(origin, agentId))
|
|
450617
450879
|
return;
|
|
450618
|
-
await
|
|
450880
|
+
await rm13(checkout, { recursive: true, force: true });
|
|
450619
450881
|
} catch {}
|
|
450620
450882
|
}
|
|
450621
450883
|
async function syncMemfsForAgent(agentId) {
|
|
@@ -450686,7 +450948,7 @@ var init_memfs_sync = __esm(() => {
|
|
|
450686
450948
|
|
|
450687
450949
|
// src/websocket/listener/mod-adapter.ts
|
|
450688
450950
|
import { createHash as createHash19 } from "node:crypto";
|
|
450689
|
-
import { join as
|
|
450951
|
+
import { join as join89 } from "node:path";
|
|
450690
450952
|
async function getUnavailableListenerClient() {
|
|
450691
450953
|
throw new Error("letta.client is not available in listener mods");
|
|
450692
450954
|
}
|
|
@@ -450762,14 +451024,14 @@ function ensureListenerModAdapter(runtime) {
|
|
|
450762
451024
|
}
|
|
450763
451025
|
function resolveListenerAgentModsDirectory(agentId) {
|
|
450764
451026
|
try {
|
|
450765
|
-
return settingsManager.isMemfsEnabled(agentId) ?
|
|
451027
|
+
return settingsManager.isMemfsEnabled(agentId) ? join89(getScopedMemoryFilesystemRoot(agentId), "mods") : null;
|
|
450766
451028
|
} catch {
|
|
450767
451029
|
return null;
|
|
450768
451030
|
}
|
|
450769
451031
|
}
|
|
450770
451032
|
function resolveListenerAgentModCacheDirectory(agentId) {
|
|
450771
451033
|
const cacheKey = createHash19("sha256").update(agentId).digest("hex");
|
|
450772
|
-
return
|
|
451034
|
+
return join89(getModCacheDirectory(), "listener-agents", cacheKey);
|
|
450773
451035
|
}
|
|
450774
451036
|
async function ensureListenerAgentModAdapter(runtime, agentId) {
|
|
450775
451037
|
runtime.agentModAdapters ??= new Map;
|
|
@@ -456100,7 +456362,7 @@ var init_turn_approval = __esm(() => {
|
|
|
456100
456362
|
|
|
456101
456363
|
// src/agent/attached-repository-git-sync.ts
|
|
456102
456364
|
import { existsSync as existsSync59 } from "node:fs";
|
|
456103
|
-
import { join as
|
|
456365
|
+
import { join as join90 } from "node:path";
|
|
456104
456366
|
async function getPendingCommitCount(path41) {
|
|
456105
456367
|
const divergence = await getMemoryAheadBehind(path41);
|
|
456106
456368
|
if (divergence) {
|
|
@@ -456130,7 +456392,7 @@ async function syncPendingAttachedRepositoryCommitsUnlocked(params) {
|
|
|
456130
456392
|
path: path41,
|
|
456131
456393
|
permissions: params.repository.permissions ?? "unknown"
|
|
456132
456394
|
};
|
|
456133
|
-
if (!existsSync59(
|
|
456395
|
+
if (!existsSync59(join90(path41, ".git"))) {
|
|
456134
456396
|
return {
|
|
456135
456397
|
...resultBase,
|
|
456136
456398
|
status: "skipped",
|
|
@@ -456302,7 +456564,7 @@ var init_attached_repository_git_sync = __esm(() => {
|
|
|
456302
456564
|
|
|
456303
456565
|
// src/reminders/memory-git-sync.ts
|
|
456304
456566
|
import { existsSync as existsSync60 } from "node:fs";
|
|
456305
|
-
import { join as
|
|
456567
|
+
import { join as join91 } from "node:path";
|
|
456306
456568
|
function formatMemoryRepairInProgressReminder(result3) {
|
|
456307
456569
|
return `${SYSTEM_REMINDER_OPEN}
|
|
456308
456570
|
MEMORY REPAIR RUNNING: A background worker is repairing the memory repository.
|
|
@@ -456412,7 +456674,7 @@ async function runPostTurnMemorySync(params, dependencies = {}) {
|
|
|
456412
456674
|
if (memorySyncEnabled) {
|
|
456413
456675
|
try {
|
|
456414
456676
|
const memoryDir = getScopedMemoryFilesystemRoot(params.agentId);
|
|
456415
|
-
const release = existsSync60(
|
|
456677
|
+
const release = existsSync60(join91(memoryDir, ".git")) ? await (dependencies.claimOperation ?? claimMemoryOperation)(memoryDir) : undefined;
|
|
456416
456678
|
if (release !== null) {
|
|
456417
456679
|
try {
|
|
456418
456680
|
const result3 = await syncMemory(params.agentId);
|
|
@@ -458647,7 +458909,7 @@ var init_core5 = __esm(() => {
|
|
|
458647
458909
|
import { spawn as spawn12 } from "node:child_process";
|
|
458648
458910
|
import { accessSync as accessSync3, constants as constants8 } from "node:fs";
|
|
458649
458911
|
import { homedir as homedir23 } from "node:os";
|
|
458650
|
-
import { join as
|
|
458912
|
+
import { join as join92 } from "node:path";
|
|
458651
458913
|
import { fileURLToPath as fileURLToPath9 } from "node:url";
|
|
458652
458914
|
async function normalizeCheckpoint(input) {
|
|
458653
458915
|
const { decoded, bounds, filters } = await decodeCheckpoint(input);
|
|
@@ -458671,7 +458933,7 @@ async function decodeCheckpoint(input) {
|
|
|
458671
458933
|
}
|
|
458672
458934
|
async function loadDeepAgentsCheckpoint(checkpoint) {
|
|
458673
458935
|
validateLocation(checkpoint);
|
|
458674
|
-
const path41 = checkpoint.path ??
|
|
458936
|
+
const path41 = checkpoint.path ?? join92(homedir23(), ".deepagents", "sessions.db");
|
|
458675
458937
|
const python = checkpoint.pythonExecutable ?? process.env.PYTHON ?? "python3";
|
|
458676
458938
|
const helper = resolveHelperPath();
|
|
458677
458939
|
return await new Promise((resolve38, reject2) => {
|
|
@@ -458891,7 +459153,7 @@ var init_deepagents = __esm(() => {
|
|
|
458891
459153
|
|
|
458892
459154
|
// node_modules/@letta-ai/trajectory/dist/adapters/listing-shared.js
|
|
458893
459155
|
import { readdirSync as readdirSync25, statSync as statSync24 } from "node:fs";
|
|
458894
|
-
import { join as
|
|
459156
|
+
import { join as join93 } from "node:path";
|
|
458895
459157
|
function sortListings(items) {
|
|
458896
459158
|
return items.sort((left, right) => {
|
|
458897
459159
|
const l3 = left.updatedAt ?? "";
|
|
@@ -458936,7 +459198,7 @@ function collectFiles(root2, extension, depth) {
|
|
|
458936
459198
|
return [];
|
|
458937
459199
|
const collected = [];
|
|
458938
459200
|
for (const entry of safeReadDir(root2)) {
|
|
458939
|
-
const full =
|
|
459201
|
+
const full = join93(root2, entry.name);
|
|
458940
459202
|
if (entry.isFile && entry.name.endsWith(extension)) {
|
|
458941
459203
|
collected.push(full);
|
|
458942
459204
|
} else if (entry.isDirectory) {
|
|
@@ -459021,18 +459283,18 @@ var init_listing_shared = __esm(() => {
|
|
|
459021
459283
|
|
|
459022
459284
|
// node_modules/@letta-ai/trajectory/dist/adapters/claude-code/list.js
|
|
459023
459285
|
import { homedir as homedir24 } from "node:os";
|
|
459024
|
-
import { basename as basename26, join as
|
|
459286
|
+
import { basename as basename26, join as join94 } from "node:path";
|
|
459025
459287
|
async function listClaudeCodeTrajectories(root2) {
|
|
459026
|
-
const base2 = root2 ??
|
|
459288
|
+
const base2 = root2 ?? join94(homedir24(), ".claude", "projects");
|
|
459027
459289
|
const items = [];
|
|
459028
459290
|
for (const project of safeReadDir(base2)) {
|
|
459029
459291
|
if (!project.isDirectory)
|
|
459030
459292
|
continue;
|
|
459031
|
-
const projectPath =
|
|
459293
|
+
const projectPath = join94(base2, project.name);
|
|
459032
459294
|
for (const entry of safeReadDir(projectPath)) {
|
|
459033
459295
|
if (!entry.isFile || !entry.name.endsWith(".jsonl"))
|
|
459034
459296
|
continue;
|
|
459035
|
-
const path41 =
|
|
459297
|
+
const path41 = join94(projectPath, entry.name);
|
|
459036
459298
|
const listing = listingFromFile(basename26(entry.name, ".jsonl"), path41);
|
|
459037
459299
|
if (listing)
|
|
459038
459300
|
items.push(listing);
|
|
@@ -459046,9 +459308,9 @@ var init_list = __esm(() => {
|
|
|
459046
459308
|
|
|
459047
459309
|
// node_modules/@letta-ai/trajectory/dist/adapters/codex/list.js
|
|
459048
459310
|
import { homedir as homedir25 } from "node:os";
|
|
459049
|
-
import { basename as basename27, join as
|
|
459311
|
+
import { basename as basename27, join as join95 } from "node:path";
|
|
459050
459312
|
async function listCodexTrajectories(root2) {
|
|
459051
|
-
const base2 = root2 ??
|
|
459313
|
+
const base2 = root2 ?? join95(homedir25(), ".codex", "sessions");
|
|
459052
459314
|
const items = [];
|
|
459053
459315
|
for (const path41 of collectFiles(base2, ".jsonl", 4)) {
|
|
459054
459316
|
const listing = listingFromFile(basename27(path41, ".jsonl"), path41);
|
|
@@ -459063,7 +459325,7 @@ var init_list2 = __esm(() => {
|
|
|
459063
459325
|
|
|
459064
459326
|
// node_modules/@letta-ai/trajectory/dist/adapters/deepagents/list.js
|
|
459065
459327
|
import { homedir as homedir26 } from "node:os";
|
|
459066
|
-
import { join as
|
|
459328
|
+
import { join as join96 } from "node:path";
|
|
459067
459329
|
async function listDeepAgentsTrajectories(root2) {
|
|
459068
459330
|
const path41 = resolveStorePath(root2);
|
|
459069
459331
|
if (!safeStat(path41))
|
|
@@ -459084,8 +459346,8 @@ async function listDeepAgentsTrajectories(root2) {
|
|
|
459084
459346
|
}
|
|
459085
459347
|
function resolveStorePath(root2) {
|
|
459086
459348
|
if (root2 === undefined)
|
|
459087
|
-
return
|
|
459088
|
-
return root2.endsWith(".db") ? root2 :
|
|
459349
|
+
return join96(homedir26(), ".deepagents", "sessions.db");
|
|
459350
|
+
return root2.endsWith(".db") ? root2 : join96(root2, "sessions.db");
|
|
459089
459351
|
}
|
|
459090
459352
|
var init_list3 = __esm(() => {
|
|
459091
459353
|
init_listing_shared();
|
|
@@ -459093,7 +459355,7 @@ var init_list3 = __esm(() => {
|
|
|
459093
459355
|
|
|
459094
459356
|
// node_modules/@letta-ai/trajectory/dist/adapters/hermes/list.js
|
|
459095
459357
|
import { homedir as homedir27 } from "node:os";
|
|
459096
|
-
import { join as
|
|
459358
|
+
import { join as join97 } from "node:path";
|
|
459097
459359
|
async function listHermesTrajectories(root2) {
|
|
459098
459360
|
const path41 = resolveStorePath2(root2);
|
|
459099
459361
|
if (!safeStat(path41))
|
|
@@ -459120,8 +459382,8 @@ async function listHermesTrajectories(root2) {
|
|
|
459120
459382
|
}
|
|
459121
459383
|
function resolveStorePath2(root2) {
|
|
459122
459384
|
if (root2 === undefined)
|
|
459123
|
-
return
|
|
459124
|
-
return root2.endsWith(".db") ? root2 :
|
|
459385
|
+
return join97(homedir27(), ".hermes", "state.db");
|
|
459386
|
+
return root2.endsWith(".db") ? root2 : join97(root2, "state.db");
|
|
459125
459387
|
}
|
|
459126
459388
|
function numeric2(value) {
|
|
459127
459389
|
return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : undefined;
|
|
@@ -459132,18 +459394,18 @@ var init_list4 = __esm(() => {
|
|
|
459132
459394
|
|
|
459133
459395
|
// node_modules/@letta-ai/trajectory/dist/adapters/letta-code/list.js
|
|
459134
459396
|
import { homedir as homedir28 } from "node:os";
|
|
459135
|
-
import { join as
|
|
459397
|
+
import { join as join98 } from "node:path";
|
|
459136
459398
|
async function listLettaCodeTrajectories(root2) {
|
|
459137
|
-
const base2 = root2 ??
|
|
459399
|
+
const base2 = root2 ?? join98(homedir28(), ".letta", "transcripts");
|
|
459138
459400
|
const items = [];
|
|
459139
459401
|
for (const agent of safeReadDir(base2)) {
|
|
459140
459402
|
if (!agent.isDirectory)
|
|
459141
459403
|
continue;
|
|
459142
|
-
const agentPath2 =
|
|
459404
|
+
const agentPath2 = join98(base2, agent.name);
|
|
459143
459405
|
for (const conversation of safeReadDir(agentPath2)) {
|
|
459144
459406
|
if (!conversation.isDirectory)
|
|
459145
459407
|
continue;
|
|
459146
|
-
const path41 =
|
|
459408
|
+
const path41 = join98(agentPath2, conversation.name, "transcript.jsonl");
|
|
459147
459409
|
const listing = listingFromFile(`${agent.name}/${conversation.name}`, path41);
|
|
459148
459410
|
if (listing && (listing.sizeBytes ?? 0) > 0)
|
|
459149
459411
|
items.push(listing);
|
|
@@ -459158,19 +459420,19 @@ var init_list5 = __esm(() => {
|
|
|
459158
459420
|
// node_modules/@letta-ai/trajectory/dist/adapters/openclaw/list.js
|
|
459159
459421
|
import { existsSync as existsSync61 } from "node:fs";
|
|
459160
459422
|
import { homedir as homedir29 } from "node:os";
|
|
459161
|
-
import { basename as basename28, join as
|
|
459423
|
+
import { basename as basename28, join as join99 } from "node:path";
|
|
459162
459424
|
async function listOpenClawTrajectories(root2) {
|
|
459163
459425
|
const base2 = root2 ?? defaultStateDir();
|
|
459164
459426
|
const items = [];
|
|
459165
|
-
const agentsPath =
|
|
459427
|
+
const agentsPath = join99(base2, "agents");
|
|
459166
459428
|
for (const agent of safeReadDir(agentsPath)) {
|
|
459167
459429
|
if (!agent.isDirectory)
|
|
459168
459430
|
continue;
|
|
459169
|
-
const sessionsPath =
|
|
459431
|
+
const sessionsPath = join99(agentsPath, agent.name, "sessions");
|
|
459170
459432
|
for (const entry of safeReadDir(sessionsPath)) {
|
|
459171
459433
|
if (!entry.isFile || !entry.name.endsWith(".jsonl"))
|
|
459172
459434
|
continue;
|
|
459173
|
-
const path41 =
|
|
459435
|
+
const path41 = join99(sessionsPath, entry.name);
|
|
459174
459436
|
const listing = listingFromFile(basename28(entry.name, ".jsonl"), path41);
|
|
459175
459437
|
if (listing)
|
|
459176
459438
|
items.push(listing);
|
|
@@ -459182,10 +459444,10 @@ function defaultStateDir() {
|
|
|
459182
459444
|
const override = process.env.OPENCLAW_STATE_DIR?.trim() || process.env.CLAWDBOT_STATE_DIR?.trim();
|
|
459183
459445
|
if (override)
|
|
459184
459446
|
return override;
|
|
459185
|
-
const current =
|
|
459447
|
+
const current = join99(homedir29(), ".openclaw");
|
|
459186
459448
|
if (existsSync61(current))
|
|
459187
459449
|
return current;
|
|
459188
|
-
return
|
|
459450
|
+
return join99(homedir29(), ".clawdbot");
|
|
459189
459451
|
}
|
|
459190
459452
|
var init_list6 = __esm(() => {
|
|
459191
459453
|
init_listing_shared();
|
|
@@ -459193,14 +459455,14 @@ var init_list6 = __esm(() => {
|
|
|
459193
459455
|
|
|
459194
459456
|
// node_modules/@letta-ai/trajectory/dist/adapters/openhands/list.js
|
|
459195
459457
|
import { homedir as homedir30 } from "node:os";
|
|
459196
|
-
import { join as
|
|
459458
|
+
import { join as join100 } from "node:path";
|
|
459197
459459
|
async function listOpenHandsTrajectories(root2) {
|
|
459198
|
-
const base2 = root2 ??
|
|
459460
|
+
const base2 = root2 ?? join100(homedir30(), ".openhands", "sessions");
|
|
459199
459461
|
const items = [];
|
|
459200
459462
|
for (const entry of safeReadDir(base2)) {
|
|
459201
459463
|
if (!entry.isDirectory)
|
|
459202
459464
|
continue;
|
|
459203
|
-
const path41 =
|
|
459465
|
+
const path41 = join100(base2, entry.name);
|
|
459204
459466
|
const facts = safeStat(path41);
|
|
459205
459467
|
items.push({
|
|
459206
459468
|
id: entry.name,
|
|
@@ -459374,7 +459636,7 @@ __export(exports_memory_scanner, {
|
|
|
459374
459636
|
getFileNodes: () => getFileNodes
|
|
459375
459637
|
});
|
|
459376
459638
|
import { readdirSync as readdirSync26, readFileSync as readFileSync52, statSync as statSync25 } from "node:fs";
|
|
459377
|
-
import { join as
|
|
459639
|
+
import { join as join101, relative as relative10 } from "node:path";
|
|
459378
459640
|
function scanMemoryFilesystem(memoryRoot) {
|
|
459379
459641
|
const nodes = [];
|
|
459380
459642
|
const scanDir = (dir, depth, parentIsLast) => {
|
|
@@ -459386,8 +459648,8 @@ function scanMemoryFilesystem(memoryRoot) {
|
|
|
459386
459648
|
}
|
|
459387
459649
|
const filtered = entries2.filter((name) => !name.startsWith("."));
|
|
459388
459650
|
const sorted = filtered.sort((a2, b3) => {
|
|
459389
|
-
const aPath =
|
|
459390
|
-
const bPath =
|
|
459651
|
+
const aPath = join101(dir, a2);
|
|
459652
|
+
const bPath = join101(dir, b3);
|
|
459391
459653
|
let aIsDir = false;
|
|
459392
459654
|
let bIsDir = false;
|
|
459393
459655
|
try {
|
|
@@ -459407,7 +459669,7 @@ function scanMemoryFilesystem(memoryRoot) {
|
|
|
459407
459669
|
return a2.localeCompare(b3);
|
|
459408
459670
|
});
|
|
459409
459671
|
sorted.forEach((name, index) => {
|
|
459410
|
-
const fullPath =
|
|
459672
|
+
const fullPath = join101(dir, name);
|
|
459411
459673
|
let isDir = false;
|
|
459412
459674
|
try {
|
|
459413
459675
|
isDir = statSync25(fullPath).isDirectory();
|
|
@@ -459525,7 +459787,7 @@ import {
|
|
|
459525
459787
|
stat as stat13,
|
|
459526
459788
|
writeFile as writeFile15
|
|
459527
459789
|
} from "node:fs/promises";
|
|
459528
|
-
import { join as
|
|
459790
|
+
import { join as join102 } from "node:path";
|
|
459529
459791
|
function buildReflectionSelectorPrompt(options) {
|
|
459530
459792
|
const lines = [
|
|
459531
459793
|
'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.',
|
|
@@ -459559,7 +459821,7 @@ async function collectParentMemoryFiles(memoryDir) {
|
|
|
459559
459821
|
return a2.name.localeCompare(b3.name);
|
|
459560
459822
|
});
|
|
459561
459823
|
for (const entry of sortedEntries) {
|
|
459562
|
-
const entryPath =
|
|
459824
|
+
const entryPath = join102(currentDir, entry.name);
|
|
459563
459825
|
const relativePath = relativeDir ? `${relativeDir}/${entry.name}` : entry.name;
|
|
459564
459826
|
if (entry.isDirectory()) {
|
|
459565
459827
|
await walk3(entryPath, relativePath);
|
|
@@ -459975,17 +460237,17 @@ async function writeState(paths, state2) {
|
|
|
459975
460237
|
}
|
|
459976
460238
|
function buildPayloadPath(rootDir, kind) {
|
|
459977
460239
|
const nonce = Math.random().toString(36).slice(2, 8);
|
|
459978
|
-
return
|
|
460240
|
+
return join102(rootDir, `payload-${kind}-${nonce}.json`);
|
|
459979
460241
|
}
|
|
459980
460242
|
function getAgentTranscriptRoot(agentId) {
|
|
459981
|
-
return
|
|
460243
|
+
return join102(getTranscriptRoot(), sanitizePathSegment2(agentId));
|
|
459982
460244
|
}
|
|
459983
460245
|
function getReflectionTranscriptPaths(agentId, conversationId) {
|
|
459984
|
-
const rootDir =
|
|
460246
|
+
const rootDir = join102(getTranscriptRoot(), sanitizePathSegment2(agentId), sanitizePathSegment2(conversationId));
|
|
459985
460247
|
return {
|
|
459986
460248
|
rootDir,
|
|
459987
|
-
transcriptPath:
|
|
459988
|
-
statePath:
|
|
460249
|
+
transcriptPath: join102(rootDir, "transcript.jsonl"),
|
|
460250
|
+
statePath: join102(rootDir, "state.json")
|
|
459989
460251
|
};
|
|
459990
460252
|
}
|
|
459991
460253
|
async function appendTranscriptDeltaJsonl(agentId, conversationId, lines) {
|
|
@@ -460075,7 +460337,7 @@ async function getTranscriptLastUpdatedAt(paths) {
|
|
|
460075
460337
|
}
|
|
460076
460338
|
}
|
|
460077
460339
|
async function ensureAgentPayloadRoot(agentId) {
|
|
460078
|
-
const root2 =
|
|
460340
|
+
const root2 = join102(getAgentTranscriptRoot(agentId), "multi-reflection-payloads");
|
|
460079
460341
|
await mkdir13(root2, { recursive: true });
|
|
460080
460342
|
return root2;
|
|
460081
460343
|
}
|
|
@@ -460639,7 +460901,7 @@ import { execFile as execFileCb3 } from "node:child_process";
|
|
|
460639
460901
|
import { randomUUID as randomUUID55 } from "node:crypto";
|
|
460640
460902
|
import { existsSync as existsSync62 } from "node:fs";
|
|
460641
460903
|
import { mkdir as mkdir14 } from "node:fs/promises";
|
|
460642
|
-
import { dirname as dirname37, isAbsolute as isAbsolute27, join as
|
|
460904
|
+
import { dirname as dirname37, isAbsolute as isAbsolute27, join as join103, resolve as resolve38 } from "node:path";
|
|
460643
460905
|
import { promisify as promisify18 } from "node:util";
|
|
460644
460906
|
async function runGit4(cwd2, args) {
|
|
460645
460907
|
try {
|
|
@@ -460699,9 +460961,9 @@ async function buildReflectionMergeMessage(parentMemoryDir, branchName) {
|
|
|
460699
460961
|
async function createReflectionMemoryWorktree(options) {
|
|
460700
460962
|
const parentMemoryDir = resolve38(options.parentMemoryDir);
|
|
460701
460963
|
const id = buildReflectionWorktreeId(options.now);
|
|
460702
|
-
const worktreeBaseDir =
|
|
460964
|
+
const worktreeBaseDir = join103(dirname37(parentMemoryDir), "memory-worktrees");
|
|
460703
460965
|
const label = options.label ?? "reflection";
|
|
460704
|
-
const worktreeDir =
|
|
460966
|
+
const worktreeDir = join103(worktreeBaseDir, `${label}-${id}`);
|
|
460705
460967
|
const branchName = `letta/${label}/${id}`;
|
|
460706
460968
|
await mkdir14(worktreeBaseDir, { recursive: true });
|
|
460707
460969
|
const { stdout: baseHeadOut } = await runGit4(parentMemoryDir, [
|
|
@@ -467852,9 +468114,9 @@ __export(exports_custom, {
|
|
|
467852
468114
|
});
|
|
467853
468115
|
import { existsSync as existsSync63 } from "node:fs";
|
|
467854
468116
|
import { readdir as readdir11, readFile as readFile27 } from "node:fs/promises";
|
|
467855
|
-
import { basename as basename30, dirname as dirname38, join as
|
|
468117
|
+
import { basename as basename30, dirname as dirname38, join as join104 } from "node:path";
|
|
467856
468118
|
function getGlobalCommandsDir() {
|
|
467857
|
-
return
|
|
468119
|
+
return join104(resolveGlobalConfigDir(), "commands");
|
|
467858
468120
|
}
|
|
467859
468121
|
async function getCustomCommands() {
|
|
467860
468122
|
if (cachedCommands !== null) {
|
|
@@ -467866,7 +468128,7 @@ async function getCustomCommands() {
|
|
|
467866
468128
|
function refreshCustomCommands() {
|
|
467867
468129
|
cachedCommands = null;
|
|
467868
468130
|
}
|
|
467869
|
-
async function discoverCustomCommands(projectPath =
|
|
468131
|
+
async function discoverCustomCommands(projectPath = join104(process.cwd(), COMMANDS_DIR)) {
|
|
467870
468132
|
const commandsById = new Map;
|
|
467871
468133
|
const userCommands = await discoverFromDirectory(getGlobalCommandsDir(), "user");
|
|
467872
468134
|
for (const cmd of userCommands) {
|
|
@@ -467898,7 +468160,7 @@ async function findCommandFiles(currentPath, rootPath, commands, source) {
|
|
|
467898
468160
|
try {
|
|
467899
468161
|
const entries2 = await readdir11(currentPath, { withFileTypes: true });
|
|
467900
468162
|
for (const entry of entries2) {
|
|
467901
|
-
const fullPath =
|
|
468163
|
+
const fullPath = join104(currentPath, entry.name);
|
|
467902
468164
|
if (entry.isDirectory()) {
|
|
467903
468165
|
await findCommandFiles(fullPath, rootPath, commands, source);
|
|
467904
468166
|
} else if (entry.isFile() && entry.name.endsWith(".md")) {
|
|
@@ -470639,9 +470901,9 @@ async function handleListMemoryCommand(parsed, socket, safeSocketSend, overrides
|
|
|
470639
470901
|
const { scanMemoryFilesystem: scanMemoryFilesystem2, getFileNodes: getFileNodes2, readFileContent: readFileContent2 } = await Promise.resolve().then(() => (init_memory_scanner(), exports_memory_scanner));
|
|
470640
470902
|
const { parseFrontmatter: parseFrontmatter2 } = await Promise.resolve().then(() => exports_frontmatter);
|
|
470641
470903
|
const { existsSync: existsSync64, statSync: statSync26 } = await import("node:fs");
|
|
470642
|
-
const { join:
|
|
470904
|
+
const { join: join105, posix: posix4 } = await import("node:path");
|
|
470643
470905
|
const memoryRoot = getMemoryFilesystemRoot2(parsed.agent_id);
|
|
470644
|
-
let memfsInitialized = existsSync64(
|
|
470906
|
+
let memfsInitialized = existsSync64(join105(memoryRoot, ".git"));
|
|
470645
470907
|
const memfsEnabled = memfsInitialized ? true : await isMemfsEnabledOnServer2(parsed.agent_id);
|
|
470646
470908
|
if (!memfsEnabled) {
|
|
470647
470909
|
safeSocketSend(socket, {
|
|
@@ -470659,7 +470921,7 @@ async function handleListMemoryCommand(parsed, socket, safeSocketSend, overrides
|
|
|
470659
470921
|
await ensureLocalMemfsCheckout2(parsed.agent_id, {
|
|
470660
470922
|
pullOnExistingRepo: true
|
|
470661
470923
|
});
|
|
470662
|
-
memfsInitialized = existsSync64(
|
|
470924
|
+
memfsInitialized = existsSync64(join105(memoryRoot, ".git"));
|
|
470663
470925
|
if (!memfsInitialized) {
|
|
470664
470926
|
throw new Error("MemFS is enabled, but the local memory checkout could not be initialized.");
|
|
470665
470927
|
}
|
|
@@ -470960,26 +471222,26 @@ function handleMemoryProtocolCommand(parsed, context3) {
|
|
|
470960
471222
|
} = await Promise.resolve().then(() => (init_memory_filesystem2(), exports_memory_filesystem));
|
|
470961
471223
|
const { readFile: readFile28 } = await import("node:fs/promises");
|
|
470962
471224
|
const { existsSync: existsSync64 } = await import("node:fs");
|
|
470963
|
-
const { isAbsolute: isAbsolute28, join:
|
|
471225
|
+
const { isAbsolute: isAbsolute28, join: join105, normalize: normalize5, relative: relative12, sep: sep9 } = await import("node:path");
|
|
470964
471226
|
if (isAbsolute28(parsed.path) || parsed.path.length === 0) {
|
|
470965
471227
|
sendFailure("path must be a non-empty relative path");
|
|
470966
471228
|
return;
|
|
470967
471229
|
}
|
|
470968
471230
|
const memoryRoot = getScopedMemoryFilesystemRoot2(parsed.agent_id);
|
|
470969
|
-
const absolutePath = normalize5(
|
|
471231
|
+
const absolutePath = normalize5(join105(memoryRoot, parsed.path));
|
|
470970
471232
|
const rel = relative12(memoryRoot, absolutePath);
|
|
470971
471233
|
if (rel.startsWith("..") || rel === "" || isAbsolute28(rel) || rel.split(sep9).includes("..")) {
|
|
470972
471234
|
sendFailure("path must resolve inside the memory root");
|
|
470973
471235
|
return;
|
|
470974
471236
|
}
|
|
470975
|
-
if (!existsSync64(
|
|
471237
|
+
if (!existsSync64(join105(memoryRoot, ".git"))) {
|
|
470976
471238
|
const enabled = await isMemfsEnabledOnServer2(parsed.agent_id);
|
|
470977
471239
|
if (!enabled) {
|
|
470978
471240
|
sendFailure("memfs is not enabled for this agent");
|
|
470979
471241
|
return;
|
|
470980
471242
|
}
|
|
470981
471243
|
await ensureLocalMemfsCheckout2(parsed.agent_id);
|
|
470982
|
-
if (!existsSync64(
|
|
471244
|
+
if (!existsSync64(join105(memoryRoot, ".git"))) {
|
|
470983
471245
|
sendFailure("failed to initialize local memory checkout");
|
|
470984
471246
|
return;
|
|
470985
471247
|
}
|
|
@@ -471026,26 +471288,26 @@ function handleMemoryProtocolCommand(parsed, context3) {
|
|
|
471026
471288
|
const { commitMemoryWrite: commitMemoryWrite2 } = await Promise.resolve().then(() => (init_memory_git(), exports_memory_git));
|
|
471027
471289
|
const { writeFile: writeFile17, mkdir: mkdir16 } = await import("node:fs/promises");
|
|
471028
471290
|
const { existsSync: existsSync64 } = await import("node:fs");
|
|
471029
|
-
const { dirname: dirname39, isAbsolute: isAbsolute28, join:
|
|
471291
|
+
const { dirname: dirname39, isAbsolute: isAbsolute28, join: join105, normalize: normalize5, relative: relative12, sep: sep9 } = await import("node:path");
|
|
471030
471292
|
if (isAbsolute28(parsed.path) || parsed.path.length === 0) {
|
|
471031
471293
|
sendFailure("write_memory_file: path must be a non-empty relative path");
|
|
471032
471294
|
return;
|
|
471033
471295
|
}
|
|
471034
471296
|
const memoryRoot = getScopedMemoryFilesystemRoot2(parsed.agent_id);
|
|
471035
|
-
const absolutePath = normalize5(
|
|
471297
|
+
const absolutePath = normalize5(join105(memoryRoot, parsed.path));
|
|
471036
471298
|
const rel = relative12(memoryRoot, absolutePath);
|
|
471037
471299
|
if (rel.startsWith("..") || rel === "" || isAbsolute28(rel) || rel.split(sep9).includes("..")) {
|
|
471038
471300
|
sendFailure("write_memory_file: path must resolve inside the memory root");
|
|
471039
471301
|
return;
|
|
471040
471302
|
}
|
|
471041
|
-
if (!existsSync64(
|
|
471303
|
+
if (!existsSync64(join105(memoryRoot, ".git"))) {
|
|
471042
471304
|
const enabled = await isMemfsEnabledOnServer2(parsed.agent_id);
|
|
471043
471305
|
if (!enabled) {
|
|
471044
471306
|
sendFailure("write_memory_file: memfs is not enabled for this agent");
|
|
471045
471307
|
return;
|
|
471046
471308
|
}
|
|
471047
471309
|
await ensureLocalMemfsCheckout2(parsed.agent_id);
|
|
471048
|
-
if (!existsSync64(
|
|
471310
|
+
if (!existsSync64(join105(memoryRoot, ".git"))) {
|
|
471049
471311
|
sendFailure("write_memory_file: failed to initialize local memory checkout");
|
|
471050
471312
|
return;
|
|
471051
471313
|
}
|
|
@@ -471124,26 +471386,26 @@ function handleMemoryProtocolCommand(parsed, context3) {
|
|
|
471124
471386
|
const { commitMemoryWrite: commitMemoryWrite2 } = await Promise.resolve().then(() => (init_memory_git(), exports_memory_git));
|
|
471125
471387
|
const { unlink: unlink3 } = await import("node:fs/promises");
|
|
471126
471388
|
const { existsSync: existsSync64 } = await import("node:fs");
|
|
471127
|
-
const { isAbsolute: isAbsolute28, join:
|
|
471389
|
+
const { isAbsolute: isAbsolute28, join: join105, normalize: normalize5, relative: relative12, sep: sep9 } = await import("node:path");
|
|
471128
471390
|
if (isAbsolute28(parsed.path) || parsed.path.length === 0) {
|
|
471129
471391
|
sendFailure("delete_memory_file: path must be a non-empty relative path");
|
|
471130
471392
|
return;
|
|
471131
471393
|
}
|
|
471132
471394
|
const memoryRoot = getScopedMemoryFilesystemRoot2(parsed.agent_id);
|
|
471133
|
-
const absolutePath = normalize5(
|
|
471395
|
+
const absolutePath = normalize5(join105(memoryRoot, parsed.path));
|
|
471134
471396
|
const rel = relative12(memoryRoot, absolutePath);
|
|
471135
471397
|
if (rel.startsWith("..") || rel === "" || isAbsolute28(rel) || rel.split(sep9).includes("..")) {
|
|
471136
471398
|
sendFailure("delete_memory_file: path must resolve inside the memory root");
|
|
471137
471399
|
return;
|
|
471138
471400
|
}
|
|
471139
|
-
if (!existsSync64(
|
|
471401
|
+
if (!existsSync64(join105(memoryRoot, ".git"))) {
|
|
471140
471402
|
const enabled = await isMemfsEnabledOnServer2(parsed.agent_id);
|
|
471141
471403
|
if (!enabled) {
|
|
471142
471404
|
sendFailure("delete_memory_file: memfs is not enabled for this agent");
|
|
471143
471405
|
return;
|
|
471144
471406
|
}
|
|
471145
471407
|
await ensureLocalMemfsCheckout2(parsed.agent_id);
|
|
471146
|
-
if (!existsSync64(
|
|
471408
|
+
if (!existsSync64(join105(memoryRoot, ".git"))) {
|
|
471147
471409
|
sendFailure("delete_memory_file: failed to initialize local memory checkout");
|
|
471148
471410
|
return;
|
|
471149
471411
|
}
|
|
@@ -471277,10 +471539,10 @@ __export(exports_remote_model_catalog, {
|
|
|
471277
471539
|
__testResetRemoteModelCatalog: () => __testResetRemoteModelCatalog
|
|
471278
471540
|
});
|
|
471279
471541
|
import { existsSync as existsSync64, mkdirSync as mkdirSync51, readFileSync as readFileSync53, writeFileSync as writeFileSync44 } from "node:fs";
|
|
471280
|
-
import { dirname as dirname39, join as
|
|
471542
|
+
import { dirname as dirname39, join as join105 } from "node:path";
|
|
471281
471543
|
function catalogCachePath() {
|
|
471282
|
-
const dir = process.env.LETTA_MODEL_CATALOG_CACHE_DIR ||
|
|
471283
|
-
return
|
|
471544
|
+
const dir = process.env.LETTA_MODEL_CATALOG_CACHE_DIR || join105(resolveGlobalConfigDir(), "cache");
|
|
471545
|
+
return join105(dir, "model-catalog.json");
|
|
471284
471546
|
}
|
|
471285
471547
|
function normalizeCatalogSource(source) {
|
|
471286
471548
|
try {
|
|
@@ -472700,7 +472962,7 @@ async function handleSkillCommand(parsed, socket, safeSocketSend) {
|
|
|
472700
472962
|
symlinkSync: symlinkSync2,
|
|
472701
472963
|
unlinkSync: unlinkSync19
|
|
472702
472964
|
} = await import("node:fs");
|
|
472703
|
-
const { basename: basename31, join:
|
|
472965
|
+
const { basename: basename31, join: join106 } = await import("node:path");
|
|
472704
472966
|
const globalSkillsDir = getGlobalSkillsDir();
|
|
472705
472967
|
if (parsed.type === "skill_enable") {
|
|
472706
472968
|
try {
|
|
@@ -472713,7 +472975,7 @@ async function handleSkillCommand(parsed, socket, safeSocketSend) {
|
|
|
472713
472975
|
}, "listener_skill_send_failed", "listener_skill_command");
|
|
472714
472976
|
return true;
|
|
472715
472977
|
}
|
|
472716
|
-
const skillMdPath =
|
|
472978
|
+
const skillMdPath = join106(parsed.skill_path, "SKILL.md");
|
|
472717
472979
|
if (!existsSync65(skillMdPath)) {
|
|
472718
472980
|
safeSocketSend(socket, {
|
|
472719
472981
|
type: "skill_enable_response",
|
|
@@ -472724,7 +472986,7 @@ async function handleSkillCommand(parsed, socket, safeSocketSend) {
|
|
|
472724
472986
|
return true;
|
|
472725
472987
|
}
|
|
472726
472988
|
const linkName = basename31(parsed.skill_path);
|
|
472727
|
-
const linkPath =
|
|
472989
|
+
const linkPath = join106(globalSkillsDir, linkName);
|
|
472728
472990
|
mkdirSync52(globalSkillsDir, { recursive: true });
|
|
472729
472991
|
if (existsSync65(linkPath)) {
|
|
472730
472992
|
const stat14 = lstatSync4(linkPath);
|
|
@@ -472767,7 +473029,7 @@ async function handleSkillCommand(parsed, socket, safeSocketSend) {
|
|
|
472767
473029
|
}
|
|
472768
473030
|
if (parsed.type === "skill_disable") {
|
|
472769
473031
|
try {
|
|
472770
|
-
const linkPath =
|
|
473032
|
+
const linkPath = join106(globalSkillsDir, parsed.name);
|
|
472771
473033
|
if (!existsSync65(linkPath)) {
|
|
472772
473034
|
safeSocketSend(socket, {
|
|
472773
473035
|
type: "skill_disable_response",
|
|
@@ -474794,7 +475056,7 @@ var init_message_router = __esm(() => {
|
|
|
474794
475056
|
});
|
|
474795
475057
|
|
|
474796
475058
|
// src/websocket/listener/process-services.ts
|
|
474797
|
-
import { join as
|
|
475059
|
+
import { join as join106 } from "node:path";
|
|
474798
475060
|
function installProcessEventRouting(params) {
|
|
474799
475061
|
const { runtime, processTransport, opts, processQueuedTurn } = params;
|
|
474800
475062
|
runtime._unsubscribeSubagentState?.();
|
|
@@ -474901,7 +475163,7 @@ function installProcessEventRouting(params) {
|
|
|
474901
475163
|
scheduleQueuePump(targetRuntime, processTransport, opts, processQueuedTurn);
|
|
474902
475164
|
});
|
|
474903
475165
|
runtime._stopDiskSpaceWatch?.();
|
|
474904
|
-
runtime._stopDiskSpaceWatch = watchSandboxDiskSpace(getCurrentWorkingDirectory, (text3) => deliverSandboxDiskAlert(runtime, text3), { reserveDirectory:
|
|
475166
|
+
runtime._stopDiskSpaceWatch = watchSandboxDiskSpace(getCurrentWorkingDirectory, (text3) => deliverSandboxDiskAlert(runtime, text3), { reserveDirectory: join106(resolveGlobalConfigDir(), "state") });
|
|
474905
475167
|
}
|
|
474906
475168
|
function deliverSandboxDiskAlert(runtime, text3) {
|
|
474907
475169
|
const target = getMostRecentlyActiveConversation(runtime);
|
|
@@ -478468,7 +478730,7 @@ import {
|
|
|
478468
478730
|
readdirSync as readdirSync27,
|
|
478469
478731
|
unlinkSync as unlinkSync19
|
|
478470
478732
|
} from "node:fs";
|
|
478471
|
-
import { join as
|
|
478733
|
+
import { join as join107 } from "node:path";
|
|
478472
478734
|
function formatTimestamp2() {
|
|
478473
478735
|
const now2 = new Date;
|
|
478474
478736
|
const h3 = String(now2.getHours()).padStart(2, "0");
|
|
@@ -478489,7 +478751,7 @@ function pruneOldLogs(dir, maxFiles) {
|
|
|
478489
478751
|
const toDelete = files.slice(0, files.length - maxFiles + 1);
|
|
478490
478752
|
for (const file of toDelete) {
|
|
478491
478753
|
try {
|
|
478492
|
-
unlinkSync19(
|
|
478754
|
+
unlinkSync19(join107(dir, file));
|
|
478493
478755
|
} catch {}
|
|
478494
478756
|
}
|
|
478495
478757
|
}
|
|
@@ -478528,7 +478790,7 @@ class RemoteSessionLog {
|
|
|
478528
478790
|
freshPath() {
|
|
478529
478791
|
const stamp = formatFileTimestamp(new Date);
|
|
478530
478792
|
const suffix = this.rotation > 0 ? `.${this.rotation}` : "";
|
|
478531
|
-
return
|
|
478793
|
+
return join107(this.dir, `${stamp}${suffix}.log`);
|
|
478532
478794
|
}
|
|
478533
478795
|
rotate() {
|
|
478534
478796
|
const previous = this.path;
|
|
@@ -478569,13 +478831,13 @@ var REMOTE_LOG_DIR, MAX_LOG_FILES = 10, MAX_LOG_BYTES2;
|
|
|
478569
478831
|
var init_listen_log = __esm(() => {
|
|
478570
478832
|
init_settings_path();
|
|
478571
478833
|
init_ws_event_redaction();
|
|
478572
|
-
REMOTE_LOG_DIR =
|
|
478834
|
+
REMOTE_LOG_DIR = join107(resolveGlobalConfigDir(), "logs", "remote");
|
|
478573
478835
|
MAX_LOG_BYTES2 = 10 * 1024 * 1024;
|
|
478574
478836
|
});
|
|
478575
478837
|
|
|
478576
478838
|
// src/websocket/listener/manual-instance-lock.ts
|
|
478577
478839
|
import { createHash as createHash22, randomUUID as randomUUID61 } from "node:crypto";
|
|
478578
|
-
import { link as link4, mkdir as mkdir16, readFile as readFile28, rm as
|
|
478840
|
+
import { link as link4, mkdir as mkdir16, readFile as readFile28, rm as rm14, unlink as unlink3, writeFile as writeFile17 } from "node:fs/promises";
|
|
478579
478841
|
import { uptime as uptime2 } from "node:os";
|
|
478580
478842
|
import path46 from "node:path";
|
|
478581
478843
|
function hasErrorCode3(error4, code) {
|
|
@@ -478649,7 +478911,7 @@ async function publishInitializedFile(targetPath, contents) {
|
|
|
478649
478911
|
} catch (error4) {
|
|
478650
478912
|
publicationError = error4;
|
|
478651
478913
|
}
|
|
478652
|
-
await
|
|
478914
|
+
await rm14(candidatePath, { force: true }).catch(() => {});
|
|
478653
478915
|
return publicationError;
|
|
478654
478916
|
}
|
|
478655
478917
|
function getRecoveryClaimPath2(lockPath, staleContents, depth) {
|
|
@@ -478658,7 +478920,7 @@ function getRecoveryClaimPath2(lockPath, staleContents, depth) {
|
|
|
478658
478920
|
}
|
|
478659
478921
|
async function cleanupRecoveryClaims2(lockPath, staleContents, deepestClaim) {
|
|
478660
478922
|
for (let depth = deepestClaim;depth >= 0; depth--) {
|
|
478661
|
-
await
|
|
478923
|
+
await rm14(getRecoveryClaimPath2(lockPath, staleContents, depth), {
|
|
478662
478924
|
force: true
|
|
478663
478925
|
}).catch(() => {});
|
|
478664
478926
|
}
|
|
@@ -480300,7 +480562,7 @@ import {
|
|
|
480300
480562
|
readFileSync as readFileSync54,
|
|
480301
480563
|
writeFileSync as writeFileSync45
|
|
480302
480564
|
} from "node:fs";
|
|
480303
|
-
import { join as
|
|
480565
|
+
import { join as join108 } from "node:path";
|
|
480304
480566
|
function readJsonl(path47) {
|
|
480305
480567
|
if (!existsSync66(path47))
|
|
480306
480568
|
return [];
|
|
@@ -480583,7 +480845,7 @@ function convertMessages4(messages, mode, nextId2) {
|
|
|
480583
480845
|
}
|
|
480584
480846
|
function migrateLocalBackendTranscripts(input) {
|
|
480585
480847
|
const storageDir = input.storageDir;
|
|
480586
|
-
const conversationsDir =
|
|
480848
|
+
const conversationsDir = join108(storageDir, "conversations");
|
|
480587
480849
|
const result3 = {
|
|
480588
480850
|
storageDir,
|
|
480589
480851
|
converted: [],
|
|
@@ -480593,9 +480855,9 @@ function migrateLocalBackendTranscripts(input) {
|
|
|
480593
480855
|
if (!existsSync66(conversationsDir))
|
|
480594
480856
|
return result3;
|
|
480595
480857
|
for (const name of readdirSync28(conversationsDir)) {
|
|
480596
|
-
const conversationDir =
|
|
480597
|
-
const messagesPath =
|
|
480598
|
-
const manifestPath =
|
|
480858
|
+
const conversationDir = join108(conversationsDir, name);
|
|
480859
|
+
const messagesPath = join108(conversationDir, "messages.jsonl");
|
|
480860
|
+
const manifestPath = join108(conversationDir, "manifest.json");
|
|
480599
480861
|
const hasManifest = existsSync66(manifestPath);
|
|
480600
480862
|
const existingManifest = hasManifest ? (() => {
|
|
480601
480863
|
try {
|
|
@@ -480638,7 +480900,7 @@ function migrateLocalBackendTranscripts(input) {
|
|
|
480638
480900
|
const backupPath = `${messagesPath}.pre-pi-backup-${timestampSuffix()}`;
|
|
480639
480901
|
if (!input.dryRun) {
|
|
480640
480902
|
copyFileSync3(messagesPath, backupPath);
|
|
480641
|
-
const conversationPath =
|
|
480903
|
+
const conversationPath = join108(conversationDir, "conversation.json");
|
|
480642
480904
|
let conversation;
|
|
480643
480905
|
if (existsSync66(conversationPath)) {
|
|
480644
480906
|
try {
|
|
@@ -480836,7 +481098,7 @@ var init_memory_tokens = __esm(() => {
|
|
|
480836
481098
|
// src/cli/subcommands/memory.ts
|
|
480837
481099
|
import { cpSync, existsSync as existsSync67, mkdirSync as mkdirSync54, rmSync as rmSync24, statSync as statSync26 } from "node:fs";
|
|
480838
481100
|
import { readdir as readdir12 } from "node:fs/promises";
|
|
480839
|
-
import { dirname as dirname40, join as
|
|
481101
|
+
import { dirname as dirname40, join as join109 } from "node:path";
|
|
480840
481102
|
import { parseArgs as parseArgs12 } from "node:util";
|
|
480841
481103
|
function printUsage8() {
|
|
480842
481104
|
console.log(`
|
|
@@ -480906,7 +481168,7 @@ async function listBackups(agentId) {
|
|
|
480906
481168
|
continue;
|
|
480907
481169
|
if (!entry.name.startsWith("memory-backup-"))
|
|
480908
481170
|
continue;
|
|
480909
|
-
const path47 =
|
|
481171
|
+
const path47 = join109(agentRoot, entry.name);
|
|
480910
481172
|
let createdAt = null;
|
|
480911
481173
|
try {
|
|
480912
481174
|
const stat14 = statSync26(path47);
|
|
@@ -480923,7 +481185,7 @@ function resolveBackupPath(agentId, from) {
|
|
|
480923
481185
|
if (from.startsWith("/") || /^[A-Za-z]:[/\\]/.test(from)) {
|
|
480924
481186
|
return from;
|
|
480925
481187
|
}
|
|
480926
|
-
return
|
|
481188
|
+
return join109(getAgentRoot(agentId), from);
|
|
480927
481189
|
}
|
|
480928
481190
|
async function runMemorySubcommand(argv, deps = {}) {
|
|
480929
481191
|
let parsed;
|
|
@@ -481007,7 +481269,7 @@ async function runMemorySubcommand(argv, deps = {}) {
|
|
|
481007
481269
|
}
|
|
481008
481270
|
const agentRoot = getAgentRoot(agentId);
|
|
481009
481271
|
const backupName = `memory-backup-${formatBackupTimestamp()}`;
|
|
481010
|
-
const backupPath =
|
|
481272
|
+
const backupPath = join109(agentRoot, backupName);
|
|
481011
481273
|
if (existsSync67(backupPath)) {
|
|
481012
481274
|
console.error(`Backup already exists at ${backupPath}`);
|
|
481013
481275
|
return 1;
|
|
@@ -481108,7 +481370,7 @@ var init_memory6 = __esm(() => {
|
|
|
481108
481370
|
|
|
481109
481371
|
// src/backend/local/transcript-search.ts
|
|
481110
481372
|
import { existsSync as existsSync68, readdirSync as readdirSync29, readFileSync as readFileSync55, statSync as statSync27 } from "node:fs";
|
|
481111
|
-
import { join as
|
|
481373
|
+
import { join as join110 } from "node:path";
|
|
481112
481374
|
function readJsonFile3(path47) {
|
|
481113
481375
|
if (!existsSync68(path47))
|
|
481114
481376
|
return;
|
|
@@ -481353,7 +481615,7 @@ function collectConversationMessages(input) {
|
|
|
481353
481615
|
return [];
|
|
481354
481616
|
if (input.conversationId && conversation.id !== input.conversationId)
|
|
481355
481617
|
return [];
|
|
481356
|
-
const manifest2 = readJsonFile3(
|
|
481618
|
+
const manifest2 = readJsonFile3(join110(conversationDir, "manifest.json"));
|
|
481357
481619
|
let format3 = transcriptFormatFromManifest(manifest2);
|
|
481358
481620
|
const records2 = [];
|
|
481359
481621
|
const echoToolCallIds = [];
|
|
@@ -481413,7 +481675,7 @@ function collectConversationMessages(input) {
|
|
|
481413
481675
|
}
|
|
481414
481676
|
addRow(row, rowIndex);
|
|
481415
481677
|
};
|
|
481416
|
-
const messagesPath =
|
|
481678
|
+
const messagesPath = join110(conversationDir, "messages.jsonl");
|
|
481417
481679
|
let rowError;
|
|
481418
481680
|
try {
|
|
481419
481681
|
forEachJsonlRow(messagesPath, (row) => {
|
|
@@ -481442,11 +481704,11 @@ function collectConversationMessages(input) {
|
|
|
481442
481704
|
return records2;
|
|
481443
481705
|
}
|
|
481444
481706
|
function conversationDirectories(storageDir) {
|
|
481445
|
-
const conversationsDir =
|
|
481707
|
+
const conversationsDir = join110(storageDir, "conversations");
|
|
481446
481708
|
if (!existsSync68(conversationsDir))
|
|
481447
481709
|
return [];
|
|
481448
481710
|
try {
|
|
481449
|
-
return readdirSync29(conversationsDir).map((entry) =>
|
|
481711
|
+
return readdirSync29(conversationsDir).map((entry) => join110(conversationsDir, entry)).filter((entryPath) => statSync27(entryPath).isDirectory());
|
|
481450
481712
|
} catch {
|
|
481451
481713
|
return [];
|
|
481452
481714
|
}
|
|
@@ -481473,7 +481735,7 @@ function searchLocalTranscriptMessages(storageDir, body3, options = {}) {
|
|
|
481473
481735
|
const endDate = typeof body3.end_date === "string" ? body3.end_date : undefined;
|
|
481474
481736
|
const includeHidden = body3.include_hidden === true;
|
|
481475
481737
|
const records2 = conversationDirectories(storageDir).flatMap((conversationDir) => {
|
|
481476
|
-
const conversation = conversationSearchRecord(readJsonFile3(
|
|
481738
|
+
const conversation = conversationSearchRecord(readJsonFile3(join110(conversationDir, "conversation.json")));
|
|
481477
481739
|
if (!conversation)
|
|
481478
481740
|
return [];
|
|
481479
481741
|
if (conversation.hidden && !includeHidden)
|
|
@@ -482035,11 +482297,13 @@ function listNativeModels(worker, cwd2, env6) {
|
|
|
482035
482297
|
return listCodexModels(cwd2, env6);
|
|
482036
482298
|
if (worker === "cursor")
|
|
482037
482299
|
return listCursorModels(cwd2, env6);
|
|
482300
|
+
if (worker === "antigravity")
|
|
482301
|
+
return listAntigravityModels(cwd2, env6);
|
|
482038
482302
|
return listClaudeModels(cwd2, env6);
|
|
482039
482303
|
}
|
|
482040
482304
|
async function listExternalWorkerModels(worker, deps = {}) {
|
|
482041
|
-
if (!["claude-code", "codex", "opencode", "cursor"].includes(worker))
|
|
482042
|
-
throw new Error("--worker must be claude-code, codex, opencode, or
|
|
482305
|
+
if (!["claude-code", "codex", "opencode", "cursor", "antigravity"].includes(worker))
|
|
482306
|
+
throw new Error("--worker must be claude-code, codex, opencode, cursor, or antigravity");
|
|
482043
482307
|
const baseEnv = deps.env ?? process.env;
|
|
482044
482308
|
const agentId = baseEnv.AGENT_ID ?? baseEnv.LETTA_AGENT_ID;
|
|
482045
482309
|
const secrets2 = agentId ? await resolveExternalCodingAgentSecretEnv(agentId) : {};
|
|
@@ -482067,7 +482331,7 @@ async function listExternalWorkerModels(worker, deps = {}) {
|
|
|
482067
482331
|
for (const model2 of catalog2) {
|
|
482068
482332
|
if (!isRecord2(model2))
|
|
482069
482333
|
throw new Error("Invalid native model catalog entry");
|
|
482070
|
-
const id = worker === "codex" ? model2.model : worker === "cursor" ? model2.id : model2.value;
|
|
482334
|
+
const id = worker === "codex" ? model2.model : worker === "cursor" || worker === "antigravity" ? model2.id : model2.value;
|
|
482071
482335
|
if (typeof id !== "string" || typeof model2.displayName !== "string")
|
|
482072
482336
|
throw new Error("Native model catalog entry is missing its ID or name");
|
|
482073
482337
|
const aliases = Array.isArray(model2.aliases) ? model2.aliases.filter((alias) => typeof alias === "string") : [];
|
|
@@ -482090,6 +482354,7 @@ var init_external_worker_models = __esm(() => {
|
|
|
482090
482354
|
init_subagent_process();
|
|
482091
482355
|
init_secret_substitution();
|
|
482092
482356
|
init_native_cli_env();
|
|
482357
|
+
init_antigravity_acp();
|
|
482093
482358
|
init_codex_app_server();
|
|
482094
482359
|
init_cursor_session();
|
|
482095
482360
|
init_external_coding_agent();
|
|
@@ -482102,7 +482367,7 @@ function printUsage10() {
|
|
|
482102
482367
|
console.log(`Usage:
|
|
482103
482368
|
letta model get [--default] [--agent <id> | --conversation <id>]
|
|
482104
482369
|
letta model list [--byok | --hosted] [--structured-outputs]
|
|
482105
|
-
letta model list --worker <claude-code|codex|opencode|cursor>
|
|
482370
|
+
letta model list --worker <claude-code|codex|opencode|cursor|antigravity>
|
|
482106
482371
|
letta model set [handle] [--reasoning <level>] [--model-settings <json>] [--default] [--agent <id> | --conversation <id>]
|
|
482107
482372
|
|
|
482108
482373
|
get Show the effective model, context limit, and full redacted model_settings.
|
|
@@ -482516,7 +482781,7 @@ import {
|
|
|
482516
482781
|
rmSync as rmSync25,
|
|
482517
482782
|
writeFileSync as writeFileSync46
|
|
482518
482783
|
} from "node:fs";
|
|
482519
|
-
import { tmpdir as
|
|
482784
|
+
import { tmpdir as tmpdir16 } from "node:os";
|
|
482520
482785
|
import path47 from "node:path";
|
|
482521
482786
|
function isRecord21(value) {
|
|
482522
482787
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -483230,7 +483495,7 @@ function installLocalManagedModPackage(params) {
|
|
|
483230
483495
|
}
|
|
483231
483496
|
async function installNpmManagedModPackage(params) {
|
|
483232
483497
|
const parsed = parseNpmManagedModPackageInstallSpecifier(params.specifier);
|
|
483233
|
-
const tempRoot = mkdtempSync5(path47.join(
|
|
483498
|
+
const tempRoot = mkdtempSync5(path47.join(tmpdir16(), "letta-mod-npm-"));
|
|
483234
483499
|
try {
|
|
483235
483500
|
writeNpmInstallManifest(tempRoot);
|
|
483236
483501
|
await runNpmInstall({
|
|
@@ -483254,7 +483519,7 @@ async function installGitManagedModPackage(params) {
|
|
|
483254
483519
|
if (!parsed) {
|
|
483255
483520
|
throw new Error(`Invalid git mod package specifier: ${params.specifier}`);
|
|
483256
483521
|
}
|
|
483257
|
-
const tempRoot = mkdtempSync5(path47.join(
|
|
483522
|
+
const tempRoot = mkdtempSync5(path47.join(tmpdir16(), "letta-mod-git-"));
|
|
483258
483523
|
try {
|
|
483259
483524
|
const packageDirectory = path47.join(tempRoot, "repo");
|
|
483260
483525
|
const revision = await checkoutGitPackage({
|
|
@@ -483287,7 +483552,7 @@ async function updateNpmManagedModPackage(params) {
|
|
|
483287
483552
|
modsRoot: params.modsRoot,
|
|
483288
483553
|
specifier: parsed.source
|
|
483289
483554
|
}).package;
|
|
483290
|
-
const tempRoot = mkdtempSync5(path47.join(
|
|
483555
|
+
const tempRoot = mkdtempSync5(path47.join(tmpdir16(), "letta-mod-npm-"));
|
|
483291
483556
|
try {
|
|
483292
483557
|
writeNpmInstallManifest(tempRoot);
|
|
483293
483558
|
await runNpmInstall({
|
|
@@ -483321,7 +483586,7 @@ async function updateGitManagedModPackage(params) {
|
|
|
483321
483586
|
modsRoot: params.modsRoot,
|
|
483322
483587
|
specifier: parsed.source
|
|
483323
483588
|
}).package;
|
|
483324
|
-
const tempRoot = mkdtempSync5(path47.join(
|
|
483589
|
+
const tempRoot = mkdtempSync5(path47.join(tmpdir16(), "letta-mod-git-"));
|
|
483325
483590
|
try {
|
|
483326
483591
|
const packageDirectory = path47.join(tempRoot, "repo");
|
|
483327
483592
|
const revision = await checkoutGitPackage({
|
|
@@ -483502,7 +483767,7 @@ var init_package_scaffolder = __esm(() => {
|
|
|
483502
483767
|
});
|
|
483503
483768
|
|
|
483504
483769
|
// src/cli/subcommands/mods.ts
|
|
483505
|
-
import { dirname as dirname41, join as
|
|
483770
|
+
import { dirname as dirname41, join as join111 } from "node:path";
|
|
483506
483771
|
import { parseArgs as parseArgs15 } from "node:util";
|
|
483507
483772
|
function printUsage11() {
|
|
483508
483773
|
console.log(`
|
|
@@ -483541,7 +483806,7 @@ function getExplicitAgentId(values4) {
|
|
|
483541
483806
|
return typeof explicitAgent === "string" && explicitAgent.trim() ? explicitAgent.trim() : null;
|
|
483542
483807
|
}
|
|
483543
483808
|
function getAgentModsDirectory(agentId) {
|
|
483544
|
-
return
|
|
483809
|
+
return join111(getScopedMemoryFilesystemRoot(agentId), "mods");
|
|
483545
483810
|
}
|
|
483546
483811
|
function directFilesForSource(source) {
|
|
483547
483812
|
return source.files.filter((file) => dirname41(file) === source.root);
|
|
@@ -485184,7 +485449,7 @@ var init_setup7 = __esm(async () => {
|
|
|
485184
485449
|
|
|
485185
485450
|
// src/cli/subcommands/shared-memory.ts
|
|
485186
485451
|
import { existsSync as existsSync71 } from "node:fs";
|
|
485187
|
-
import { join as
|
|
485452
|
+
import { join as join112 } from "node:path";
|
|
485188
485453
|
import { parseArgs as parseArgs20 } from "node:util";
|
|
485189
485454
|
function printUsage16() {
|
|
485190
485455
|
console.log(`
|
|
@@ -485391,7 +485656,7 @@ async function runSharedMemorySubcommand(argv, deps = {}) {
|
|
|
485391
485656
|
invalidateClientSkills(agentId);
|
|
485392
485657
|
const recompileError = await recompileAndReportFailure(recompileAgent, agentId);
|
|
485393
485658
|
const mountDir = getRepositoryMountDir(agentId, repository.name);
|
|
485394
|
-
const mounted = existsSync71(
|
|
485659
|
+
const mounted = existsSync71(join112(mountDir, ".git"));
|
|
485395
485660
|
console.log(JSON.stringify({
|
|
485396
485661
|
attached: true,
|
|
485397
485662
|
repository: { id: repository.id, name: repository.name },
|
|
@@ -486982,8 +487247,8 @@ import {
|
|
|
486982
487247
|
writeFileSync as writeFileSync48
|
|
486983
487248
|
} from "node:fs";
|
|
486984
487249
|
import { mkdir as mkdir17, readdir as readdir13 } from "node:fs/promises";
|
|
486985
|
-
import { tmpdir as
|
|
486986
|
-
import { basename as basename32, dirname as dirname42, join as
|
|
487250
|
+
import { tmpdir as tmpdir17 } from "node:os";
|
|
487251
|
+
import { basename as basename32, dirname as dirname42, join as join113, normalize as normalize5, resolve as resolve41, sep as sep9 } from "node:path";
|
|
486987
487252
|
import { parseArgs as parseArgs21, TextDecoder as TextDecoder2, TextEncoder as TextEncoder2 } from "node:util";
|
|
486988
487253
|
function printUsage17() {
|
|
486989
487254
|
console.log(`
|
|
@@ -487254,14 +487519,14 @@ async function resolveBranchAndSubdir(location) {
|
|
|
487254
487519
|
}
|
|
487255
487520
|
async function cloneSkillSource(location) {
|
|
487256
487521
|
const resolvedLocation = await resolveBranchAndSubdir(location);
|
|
487257
|
-
const tmpDir = mkdtempSync6(
|
|
487522
|
+
const tmpDir = mkdtempSync6(join113(tmpdir17(), "letta-skill-install-"));
|
|
487258
487523
|
const args = ["clone", "--depth", "1"];
|
|
487259
487524
|
if (resolvedLocation.branch) {
|
|
487260
487525
|
args.push("--branch", resolvedLocation.branch);
|
|
487261
487526
|
}
|
|
487262
487527
|
args.push(resolvedLocation.repoUrl, tmpDir);
|
|
487263
487528
|
await execFile22("git", args, { timeout: 120000 });
|
|
487264
|
-
const sourceDir = resolvedLocation.subdir ?
|
|
487529
|
+
const sourceDir = resolvedLocation.subdir ? join113(tmpDir, resolvedLocation.subdir) : tmpDir;
|
|
487265
487530
|
return { tmpDir, sourceDir };
|
|
487266
487531
|
}
|
|
487267
487532
|
function assertDirectSkillFileSize(receivedBytes, maxBytes) {
|
|
@@ -487316,11 +487581,11 @@ async function downloadDirectSkillFileSource(location, options = {}) {
|
|
|
487316
487581
|
throw new Error(`Direct skill file download failed for ${location.url}: ${response.status}`);
|
|
487317
487582
|
}
|
|
487318
487583
|
const skillText = await readResponseTextWithLimit(response, MAX_DIRECT_SKILL_FILE_BYTES);
|
|
487319
|
-
const tmpDir = mkdtempSync6(
|
|
487584
|
+
const tmpDir = mkdtempSync6(join113(tmpdir17(), "letta-direct-skill-"));
|
|
487320
487585
|
try {
|
|
487321
|
-
const sourceDir =
|
|
487586
|
+
const sourceDir = join113(tmpDir, "skill");
|
|
487322
487587
|
await mkdir17(sourceDir, { recursive: true });
|
|
487323
|
-
writeFileSync48(
|
|
487588
|
+
writeFileSync48(join113(sourceDir, "SKILL.md"), skillText, "utf8");
|
|
487324
487589
|
return { tmpDir, sourceDir };
|
|
487325
487590
|
} catch (error4) {
|
|
487326
487591
|
rmSync27(tmpDir, { recursive: true, force: true });
|
|
@@ -487361,9 +487626,9 @@ function assertSafeZipMember(name) {
|
|
|
487361
487626
|
}
|
|
487362
487627
|
async function downloadClawHubSkillSource(location) {
|
|
487363
487628
|
const version3 = await resolveClawHubVersion(location);
|
|
487364
|
-
const tmpDir = mkdtempSync6(
|
|
487365
|
-
const zipPath =
|
|
487366
|
-
const sourceDir =
|
|
487629
|
+
const tmpDir = mkdtempSync6(join113(tmpdir17(), "letta-clawhub-skill-"));
|
|
487630
|
+
const zipPath = join113(tmpDir, "skill.zip");
|
|
487631
|
+
const sourceDir = join113(tmpDir, "skill");
|
|
487367
487632
|
await mkdir17(sourceDir, { recursive: true });
|
|
487368
487633
|
const url2 = new URL(`${CLAWHUB_API_BASE_URL}/download`);
|
|
487369
487634
|
url2.searchParams.set("slug", location.slug);
|
|
@@ -487402,7 +487667,7 @@ function sanitizeSkillName(name) {
|
|
|
487402
487667
|
return trimmed;
|
|
487403
487668
|
}
|
|
487404
487669
|
function getSkillName(sourceDir) {
|
|
487405
|
-
const skillMd = readFileSync57(
|
|
487670
|
+
const skillMd = readFileSync57(join113(sourceDir, "SKILL.md"), "utf8");
|
|
487406
487671
|
const { frontmatter } = parseFrontmatter(skillMd);
|
|
487407
487672
|
const frontmatterName = frontmatter.name;
|
|
487408
487673
|
const name = typeof frontmatterName === "string" && frontmatterName.trim() ? frontmatterName : basename32(sourceDir);
|
|
@@ -487411,7 +487676,7 @@ function getSkillName(sourceDir) {
|
|
|
487411
487676
|
async function installSkillDirectory(params) {
|
|
487412
487677
|
const sourceDir = resolve41(params.sourceDir);
|
|
487413
487678
|
const memoryDir = resolve41(params.memoryDir);
|
|
487414
|
-
const skillMdPath =
|
|
487679
|
+
const skillMdPath = join113(sourceDir, "SKILL.md");
|
|
487415
487680
|
if (!existsSync72(skillMdPath)) {
|
|
487416
487681
|
throw new Error("No SKILL.md found in the skill directory.");
|
|
487417
487682
|
}
|
|
@@ -487419,8 +487684,8 @@ async function installSkillDirectory(params) {
|
|
|
487419
487684
|
throw new Error(`Skill source is not a directory: ${sourceDir}`);
|
|
487420
487685
|
}
|
|
487421
487686
|
const name = getSkillName(sourceDir);
|
|
487422
|
-
const skillsDir =
|
|
487423
|
-
const targetPath =
|
|
487687
|
+
const skillsDir = join113(memoryDir, "skills");
|
|
487688
|
+
const targetPath = join113(skillsDir, name);
|
|
487424
487689
|
assertInside(skillsDir, targetPath);
|
|
487425
487690
|
if (existsSync72(targetPath)) {
|
|
487426
487691
|
if (!params.force) {
|
|
@@ -487437,7 +487702,7 @@ async function installSkillDirectory(params) {
|
|
|
487437
487702
|
}
|
|
487438
487703
|
async function listSkillDirectories(params) {
|
|
487439
487704
|
const memoryDir = resolve41(params.memoryDir);
|
|
487440
|
-
const skillsDir =
|
|
487705
|
+
const skillsDir = join113(memoryDir, "skills");
|
|
487441
487706
|
if (!existsSync72(skillsDir))
|
|
487442
487707
|
return [];
|
|
487443
487708
|
const entries2 = await readdir13(skillsDir, { withFileTypes: true });
|
|
@@ -487445,8 +487710,8 @@ async function listSkillDirectories(params) {
|
|
|
487445
487710
|
for (const entry of entries2) {
|
|
487446
487711
|
if (!entry.isDirectory())
|
|
487447
487712
|
continue;
|
|
487448
|
-
const skillDir =
|
|
487449
|
-
const skillMdPath =
|
|
487713
|
+
const skillDir = join113(skillsDir, entry.name);
|
|
487714
|
+
const skillMdPath = join113(skillDir, "SKILL.md");
|
|
487450
487715
|
if (!existsSync72(skillMdPath))
|
|
487451
487716
|
continue;
|
|
487452
487717
|
let name = entry.name;
|
|
@@ -487467,9 +487732,9 @@ async function listSkillDirectories(params) {
|
|
|
487467
487732
|
}
|
|
487468
487733
|
async function deleteSkillDirectory(params) {
|
|
487469
487734
|
const memoryDir = resolve41(params.memoryDir);
|
|
487470
|
-
const skillsDir =
|
|
487735
|
+
const skillsDir = join113(memoryDir, "skills");
|
|
487471
487736
|
const name = sanitizeSkillName(params.name);
|
|
487472
|
-
const targetPath =
|
|
487737
|
+
const targetPath = join113(skillsDir, name);
|
|
487473
487738
|
assertInside(skillsDir, targetPath);
|
|
487474
487739
|
if (!existsSync72(targetPath)) {
|
|
487475
487740
|
throw new Error(`Skill "${name}" is not installed at ${targetPath}.`);
|
|
@@ -488055,7 +488320,7 @@ var init_teleport2 = __esm(() => {
|
|
|
488055
488320
|
|
|
488056
488321
|
// src/cli/subcommands/trajectories/readers.ts
|
|
488057
488322
|
import { readdir as readdir14, readFile as readFile30, stat as stat15 } from "node:fs/promises";
|
|
488058
|
-
import { join as
|
|
488323
|
+
import { join as join114 } from "node:path";
|
|
488059
488324
|
async function loadSessionTranscript(item) {
|
|
488060
488325
|
const stats = await stat15(item.path);
|
|
488061
488326
|
if (stats.isDirectory()) {
|
|
@@ -488067,13 +488332,13 @@ async function loadSessionTranscript(item) {
|
|
|
488067
488332
|
return readFile30(item.path, "utf-8");
|
|
488068
488333
|
}
|
|
488069
488334
|
async function assembleEventDirectory(sessionDir) {
|
|
488070
|
-
const eventsSubdir =
|
|
488335
|
+
const eventsSubdir = join114(sessionDir, "events");
|
|
488071
488336
|
const eventsDir = (await stat15(eventsSubdir).catch(() => null))?.isDirectory() ? eventsSubdir : sessionDir;
|
|
488072
488337
|
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));
|
|
488073
488338
|
if (names.length === 0) {
|
|
488074
488339
|
throw new Error(`No event files found in ${eventsDir}`);
|
|
488075
488340
|
}
|
|
488076
|
-
const events = await Promise.all(names.map(async (name) => JSON.parse(await readFile30(
|
|
488341
|
+
const events = await Promise.all(names.map(async (name) => JSON.parse(await readFile30(join114(eventsDir, name), "utf-8"))));
|
|
488077
488342
|
return JSON.stringify(events);
|
|
488078
488343
|
}
|
|
488079
488344
|
async function openReadOnlyDatabase(path49) {
|
|
@@ -488147,11 +488412,11 @@ import {
|
|
|
488147
488412
|
mkdir as mkdir18,
|
|
488148
488413
|
readdir as readdir15,
|
|
488149
488414
|
readFile as readFile31,
|
|
488150
|
-
rm as
|
|
488415
|
+
rm as rm15,
|
|
488151
488416
|
stat as stat16,
|
|
488152
488417
|
writeFile as writeFile20
|
|
488153
488418
|
} from "node:fs/promises";
|
|
488154
|
-
import { basename as basename33, join as
|
|
488419
|
+
import { basename as basename33, join as join115 } from "node:path";
|
|
488155
488420
|
function fileTimestamp(startedAt) {
|
|
488156
488421
|
if (!startedAt)
|
|
488157
488422
|
return "unknown-date";
|
|
@@ -488221,7 +488486,7 @@ async function prepareOutDir(outDir) {
|
|
|
488221
488486
|
throw new Error(`--out ${outDir} is not empty and has no ${MANIFEST_NAME}; refusing to overwrite a directory this tool did not create`);
|
|
488222
488487
|
}
|
|
488223
488488
|
for (const entry of entries2) {
|
|
488224
|
-
await
|
|
488489
|
+
await rm15(join115(outDir, entry), { recursive: true, force: true });
|
|
488225
488490
|
}
|
|
488226
488491
|
} catch (error4) {
|
|
488227
488492
|
if (error4.code !== "ENOENT")
|
|
@@ -488264,14 +488529,14 @@ async function runTrajectoryExport(options) {
|
|
|
488264
488529
|
}
|
|
488265
488530
|
const sessionId = sessionHash(source, id);
|
|
488266
488531
|
const base2 = `${fileTimestamp(stats.startedAt)}_${sessionId}`;
|
|
488267
|
-
let file =
|
|
488532
|
+
let file = join115(source, `${base2}.json`);
|
|
488268
488533
|
for (let suffix = 2;usedFiles.has(file); suffix += 1) {
|
|
488269
|
-
file =
|
|
488534
|
+
file = join115(source, `${base2}-${suffix}.json`);
|
|
488270
488535
|
}
|
|
488271
488536
|
usedFiles.add(file);
|
|
488272
488537
|
const body3 = JSON.stringify(records2);
|
|
488273
|
-
await mkdir18(
|
|
488274
|
-
await writeFile20(
|
|
488538
|
+
await mkdir18(join115(options.outDir, source), { recursive: true });
|
|
488539
|
+
await writeFile20(join115(options.outDir, file), body3, "utf-8");
|
|
488275
488540
|
counts.exported += 1;
|
|
488276
488541
|
manifest2.sessions.push({
|
|
488277
488542
|
source,
|
|
@@ -488325,7 +488590,7 @@ async function runTrajectoryExport(options) {
|
|
|
488325
488590
|
await exportCheckpoint(checkpoint, `${basename33(checkpoint.path)}-${checkpoint.threadId}`);
|
|
488326
488591
|
}
|
|
488327
488592
|
manifest2.sessions.sort((a2, b3) => (a2.startedAt ?? "").localeCompare(b3.startedAt ?? ""));
|
|
488328
|
-
await writeFile20(
|
|
488593
|
+
await writeFile20(join115(options.outDir, MANIFEST_NAME), JSON.stringify(manifest2, null, 2), "utf-8");
|
|
488329
488594
|
return manifest2;
|
|
488330
488595
|
}
|
|
488331
488596
|
var MANIFEST_NAME = "manifest.json", FIRST_PROMPT_MAX_CHARS = 200, LIST_PAGE_LIMIT = 1000;
|
|
@@ -488337,13 +488602,13 @@ var init_export = __esm(() => {
|
|
|
488337
488602
|
|
|
488338
488603
|
// src/cli/subcommands/trajectories/review.ts
|
|
488339
488604
|
import { readFile as readFile32 } from "node:fs/promises";
|
|
488340
|
-
import { isAbsolute as isAbsolute28, join as
|
|
488605
|
+
import { isAbsolute as isAbsolute28, join as join116 } from "node:path";
|
|
488341
488606
|
async function readManifest(dir) {
|
|
488342
488607
|
let raw2;
|
|
488343
488608
|
try {
|
|
488344
|
-
raw2 = await readFile32(
|
|
488609
|
+
raw2 = await readFile32(join116(dir, "manifest.json"), "utf-8");
|
|
488345
488610
|
} catch {
|
|
488346
|
-
throw new Error(`No manifest at ${
|
|
488611
|
+
throw new Error(`No manifest at ${join116(dir, "manifest.json")}. Run: letta trajectories export --out ${dir}`);
|
|
488347
488612
|
}
|
|
488348
488613
|
return JSON.parse(raw2);
|
|
488349
488614
|
}
|
|
@@ -488352,7 +488617,7 @@ function filterSessions(sessions6, filter3) {
|
|
|
488352
488617
|
}
|
|
488353
488618
|
async function resolveSessionFile(dir, target) {
|
|
488354
488619
|
if (target.endsWith(".json")) {
|
|
488355
|
-
const direct = isAbsolute28(target) ? target :
|
|
488620
|
+
const direct = isAbsolute28(target) ? target : join116(dir, target);
|
|
488356
488621
|
try {
|
|
488357
488622
|
await readFile32(direct, "utf-8");
|
|
488358
488623
|
return direct;
|
|
@@ -488363,7 +488628,7 @@ async function resolveSessionFile(dir, target) {
|
|
|
488363
488628
|
if (!entry) {
|
|
488364
488629
|
throw new Error(`No session "${target}" in ${dir} (pass a file path, a manifest-relative file, or a sessionId)`);
|
|
488365
488630
|
}
|
|
488366
|
-
return
|
|
488631
|
+
return join116(dir, entry.file);
|
|
488367
488632
|
}
|
|
488368
488633
|
function stamp(timestamp) {
|
|
488369
488634
|
return (timestamp ?? "").slice(0, 19);
|
|
@@ -488406,7 +488671,7 @@ async function searchSessions(dir, keyword, options = {}) {
|
|
|
488406
488671
|
for (const session3 of filterSessions(manifest2.sessions, options)) {
|
|
488407
488672
|
let records2;
|
|
488408
488673
|
try {
|
|
488409
|
-
records2 = JSON.parse(await readFile32(
|
|
488674
|
+
records2 = JSON.parse(await readFile32(join116(dir, session3.file), "utf-8"));
|
|
488410
488675
|
} catch {
|
|
488411
488676
|
continue;
|
|
488412
488677
|
}
|
|
@@ -494726,7 +494991,7 @@ function resolveHeadlessMemfsPolicy(options) {
|
|
|
494726
494991
|
var init_headless_memfs_policy = () => {};
|
|
494727
494992
|
|
|
494728
494993
|
// src/headless-mod-adapter.ts
|
|
494729
|
-
import { join as
|
|
494994
|
+
import { join as join117 } from "node:path";
|
|
494730
494995
|
function isHeadlessMemfsEnabled(agentId) {
|
|
494731
494996
|
try {
|
|
494732
494997
|
return settingsManager.isMemfsEnabled(agentId);
|
|
@@ -494797,7 +495062,7 @@ function createHeadlessModContext(options) {
|
|
|
494797
495062
|
};
|
|
494798
495063
|
}
|
|
494799
495064
|
function createHeadlessModAdapter(options) {
|
|
494800
|
-
const agentModsDirectory = isHeadlessMemfsEnabled(options.agent.id) ?
|
|
495065
|
+
const agentModsDirectory = isHeadlessMemfsEnabled(options.agent.id) ? join117(getScopedMemoryFilesystemRoot(options.agent.id), "mods") : undefined;
|
|
494801
495066
|
return createModAdapter({
|
|
494802
495067
|
...agentModsDirectory ? { agentModsDirectory } : {},
|
|
494803
495068
|
...options.cacheDirectory ? { cacheDirectory: options.cacheDirectory } : {},
|
|
@@ -499460,10 +499725,10 @@ import { execFile as execFileCb4 } from "node:child_process";
|
|
|
499460
499725
|
import { existsSync as existsSync75 } from "node:fs";
|
|
499461
499726
|
import { appendFile as appendFile3, chmod, mkdir as mkdir19, writeFile as writeFile21 } from "node:fs/promises";
|
|
499462
499727
|
import { homedir as homedir34 } from "node:os";
|
|
499463
|
-
import { join as
|
|
499728
|
+
import { join as join119 } from "node:path";
|
|
499464
499729
|
import { promisify as promisify20 } from "node:util";
|
|
499465
499730
|
function getReflectionArenaHfCacheRoot(env6 = process.env, fallbackHome = homedir34()) {
|
|
499466
|
-
return
|
|
499731
|
+
return join119(resolveGlobalConfigDir(env6, fallbackHome), "reflection-arena", "hf-upload");
|
|
499467
499732
|
}
|
|
499468
499733
|
function buildGitEnv(token2, askpassPath) {
|
|
499469
499734
|
return {
|
|
@@ -499499,7 +499764,7 @@ async function runGit6(cwd2, args, env6) {
|
|
|
499499
499764
|
}
|
|
499500
499765
|
}
|
|
499501
499766
|
async function writeGitAskpass(repoRoot) {
|
|
499502
|
-
const askpassPath =
|
|
499767
|
+
const askpassPath = join119(repoRoot, "hf-askpass.sh");
|
|
499503
499768
|
await writeFile21(askpassPath, [
|
|
499504
499769
|
"#!/bin/sh",
|
|
499505
499770
|
'case "$1" in',
|
|
@@ -499514,7 +499779,7 @@ async function writeGitAskpass(repoRoot) {
|
|
|
499514
499779
|
}
|
|
499515
499780
|
async function prepareHfRepo(env6) {
|
|
499516
499781
|
await mkdir19(HF_CACHE_ROOT, { recursive: true });
|
|
499517
|
-
if (!existsSync75(
|
|
499782
|
+
if (!existsSync75(join119(HF_REPO_DIR, ".git"))) {
|
|
499518
499783
|
await runGit6(HF_CACHE_ROOT, ["clone", "--depth", "1", HF_REPO_URL, HF_REPO_DIR], env6);
|
|
499519
499784
|
return HF_REPO_DIR;
|
|
499520
499785
|
}
|
|
@@ -499549,8 +499814,8 @@ async function maybeUploadReflectionArenaChoiceToHf(row) {
|
|
|
499549
499814
|
const env6 = buildGitEnv(token2, askpassPath);
|
|
499550
499815
|
try {
|
|
499551
499816
|
const repoDir = await prepareHfRepo(env6);
|
|
499552
|
-
await mkdir19(
|
|
499553
|
-
await appendFile3(
|
|
499817
|
+
await mkdir19(join119(repoDir, "data"), { recursive: true });
|
|
499818
|
+
await appendFile3(join119(repoDir, HF_DATASET_PATH), `${JSON.stringify(row)}
|
|
499554
499819
|
`, {
|
|
499555
499820
|
encoding: "utf-8"
|
|
499556
499821
|
});
|
|
@@ -499580,14 +499845,14 @@ var init_reflection_arena_hf_upload = __esm(() => {
|
|
|
499580
499845
|
execFile23 = promisify20(execFileCb4);
|
|
499581
499846
|
HF_REPO_URL = `https://huggingface.co/datasets/${HF_REPO_ID}`;
|
|
499582
499847
|
HF_CACHE_ROOT = getReflectionArenaHfCacheRoot();
|
|
499583
|
-
HF_REPO_DIR =
|
|
499848
|
+
HF_REPO_DIR = join119(HF_CACHE_ROOT, "repo");
|
|
499584
499849
|
});
|
|
499585
499850
|
|
|
499586
499851
|
// src/cli/helpers/reflection-arena.ts
|
|
499587
499852
|
import { execFile as execFileCb5 } from "node:child_process";
|
|
499588
499853
|
import { randomInt as randomInt2, randomUUID as randomUUID69 } from "node:crypto";
|
|
499589
499854
|
import { appendFile as appendFile4, mkdir as mkdir20, readFile as readFile34, writeFile as writeFile22 } from "node:fs/promises";
|
|
499590
|
-
import { join as
|
|
499855
|
+
import { join as join120 } from "node:path";
|
|
499591
499856
|
import { promisify as promisify21 } from "node:util";
|
|
499592
499857
|
function sampleReflectionArenaComparisonModel(excludedModels = []) {
|
|
499593
499858
|
const excluded = new Set(excludedModels);
|
|
@@ -499636,16 +499901,16 @@ function candidateIsConfirmedNoOp(candidate) {
|
|
|
499636
499901
|
return candidate.result?.success === true && candidate.result.memoryNoChanges === true && candidate.result.memoryHead === candidate.worktree.baseHead;
|
|
499637
499902
|
}
|
|
499638
499903
|
function getReflectionArenaRoot() {
|
|
499639
|
-
return
|
|
499904
|
+
return join120(resolveGlobalConfigDir(), "reflection-arena");
|
|
499640
499905
|
}
|
|
499641
499906
|
function getReflectionArenaRunsDir() {
|
|
499642
|
-
return
|
|
499907
|
+
return join120(getReflectionArenaRoot(), "runs");
|
|
499643
499908
|
}
|
|
499644
499909
|
function getReflectionArenaChoiceLogPath() {
|
|
499645
|
-
return
|
|
499910
|
+
return join120(getReflectionArenaRoot(), "choices.jsonl");
|
|
499646
499911
|
}
|
|
499647
499912
|
function getReflectionArenaRunPath(runId) {
|
|
499648
|
-
return
|
|
499913
|
+
return join120(getReflectionArenaRunsDir(), `${runId}.json`);
|
|
499649
499914
|
}
|
|
499650
499915
|
async function saveReflectionArenaRun(run) {
|
|
499651
499916
|
await mkdir20(getReflectionArenaRunsDir(), { recursive: true });
|
|
@@ -501186,7 +501451,7 @@ import {
|
|
|
501186
501451
|
writeFileSync as writeFileSync51
|
|
501187
501452
|
} from "node:fs";
|
|
501188
501453
|
import { homedir as homedir35, platform as platform10 } from "node:os";
|
|
501189
|
-
import { dirname as dirname43, join as
|
|
501454
|
+
import { dirname as dirname43, join as join121 } from "node:path";
|
|
501190
501455
|
function detectTerminalType() {
|
|
501191
501456
|
if (process.env.CURSOR_TRACE_ID || process.env.CURSOR_CHANNEL) {
|
|
501192
501457
|
return "cursor";
|
|
@@ -501218,16 +501483,16 @@ function getKeybindingsPath(terminal) {
|
|
|
501218
501483
|
}[terminal];
|
|
501219
501484
|
const os7 = platform10();
|
|
501220
501485
|
if (os7 === "darwin") {
|
|
501221
|
-
return
|
|
501486
|
+
return join121(homedir35(), "Library", "Application Support", appName, "User", "keybindings.json");
|
|
501222
501487
|
}
|
|
501223
501488
|
if (os7 === "win32") {
|
|
501224
501489
|
const appData = process.env.APPDATA;
|
|
501225
501490
|
if (!appData)
|
|
501226
501491
|
return null;
|
|
501227
|
-
return
|
|
501492
|
+
return join121(appData, appName, "User", "keybindings.json");
|
|
501228
501493
|
}
|
|
501229
501494
|
if (os7 === "linux") {
|
|
501230
|
-
return
|
|
501495
|
+
return join121(homedir35(), ".config", appName, "User", "keybindings.json");
|
|
501231
501496
|
}
|
|
501232
501497
|
return null;
|
|
501233
501498
|
}
|
|
@@ -501380,14 +501645,14 @@ function getWezTermConfigPath() {
|
|
|
501380
501645
|
}
|
|
501381
501646
|
const xdgConfig = process.env.XDG_CONFIG_HOME;
|
|
501382
501647
|
if (xdgConfig) {
|
|
501383
|
-
const xdgPath =
|
|
501648
|
+
const xdgPath = join121(xdgConfig, "wezterm", "wezterm.lua");
|
|
501384
501649
|
if (existsSync76(xdgPath))
|
|
501385
501650
|
return xdgPath;
|
|
501386
501651
|
}
|
|
501387
|
-
const configPath =
|
|
501652
|
+
const configPath = join121(homedir35(), ".config", "wezterm", "wezterm.lua");
|
|
501388
501653
|
if (existsSync76(configPath))
|
|
501389
501654
|
return configPath;
|
|
501390
|
-
return
|
|
501655
|
+
return join121(homedir35(), ".wezterm.lua");
|
|
501391
501656
|
}
|
|
501392
501657
|
function stripLuaCommentsFromLine(line, blockCommentEnd) {
|
|
501393
501658
|
let code = "";
|
|
@@ -501565,7 +501830,7 @@ __export(exports_settings, {
|
|
|
501565
501830
|
loadProjectSettings: () => loadProjectSettings,
|
|
501566
501831
|
getSetting: () => getSetting
|
|
501567
501832
|
});
|
|
501568
|
-
import { join as
|
|
501833
|
+
import { join as join122 } from "node:path";
|
|
501569
501834
|
function getSettingsPath() {
|
|
501570
501835
|
return resolveGlobalSettingsPath();
|
|
501571
501836
|
}
|
|
@@ -501607,7 +501872,7 @@ async function getSetting(key4) {
|
|
|
501607
501872
|
return settings[key4];
|
|
501608
501873
|
}
|
|
501609
501874
|
function getProjectSettingsPath() {
|
|
501610
|
-
return
|
|
501875
|
+
return join122(process.cwd(), ".letta", "settings.local.json");
|
|
501611
501876
|
}
|
|
501612
501877
|
async function loadProjectSettings() {
|
|
501613
501878
|
if (shouldIsolateHomeProjectConfig(process.cwd()))
|
|
@@ -501629,7 +501894,7 @@ async function saveProjectSettings(settings) {
|
|
|
501629
501894
|
if (shouldIsolateHomeProjectConfig(process.cwd()))
|
|
501630
501895
|
return;
|
|
501631
501896
|
const settingsPath = getProjectSettingsPath();
|
|
501632
|
-
const dirPath =
|
|
501897
|
+
const dirPath = join122(process.cwd(), ".letta");
|
|
501633
501898
|
try {
|
|
501634
501899
|
if (!exists(dirPath)) {
|
|
501635
501900
|
await mkdir(dirPath, { recursive: true });
|
|
@@ -512449,8 +512714,8 @@ import {
|
|
|
512449
512714
|
rmSync as rmSync29,
|
|
512450
512715
|
writeFileSync as writeFileSync52
|
|
512451
512716
|
} from "node:fs";
|
|
512452
|
-
import { tmpdir as
|
|
512453
|
-
import { dirname as dirname44, join as
|
|
512717
|
+
import { tmpdir as tmpdir18 } from "node:os";
|
|
512718
|
+
import { dirname as dirname44, join as join123 } from "node:path";
|
|
512454
512719
|
function runCommand(command, args, cwd2, input) {
|
|
512455
512720
|
try {
|
|
512456
512721
|
return execFileSync12(command, args, {
|
|
@@ -512671,8 +512936,8 @@ async function createLettaAgent(apiKey, name) {
|
|
|
512671
512936
|
return createMinimalAgent(apiKey, name);
|
|
512672
512937
|
}
|
|
512673
512938
|
function cloneRepoToTemp(repo) {
|
|
512674
|
-
const tempDir = mkdtempSync7(
|
|
512675
|
-
const repoDir =
|
|
512939
|
+
const tempDir = mkdtempSync7(join123(tmpdir18(), "letta-install-github-app-"));
|
|
512940
|
+
const repoDir = join123(tempDir, "repo");
|
|
512676
512941
|
runCommand("gh", ["repo", "clone", repo, repoDir, "--", "--depth=1"]);
|
|
512677
512942
|
return { tempDir, repoDir };
|
|
512678
512943
|
}
|
|
@@ -512683,7 +512948,7 @@ function runGit7(args, cwd2) {
|
|
|
512683
512948
|
return runCommand("git", args, cwd2);
|
|
512684
512949
|
}
|
|
512685
512950
|
function writeWorkflow(repoDir, workflowPath, content) {
|
|
512686
|
-
const absolutePath =
|
|
512951
|
+
const absolutePath = join123(repoDir, workflowPath);
|
|
512687
512952
|
if (!existsSync77(dirname44(absolutePath))) {
|
|
512688
512953
|
mkdirSync60(dirname44(absolutePath), { recursive: true });
|
|
512689
512954
|
}
|
|
@@ -516573,7 +516838,7 @@ __export(exports_generate_memory_viewer, {
|
|
|
516573
516838
|
});
|
|
516574
516839
|
import { execFile as execFileCb6 } from "node:child_process";
|
|
516575
516840
|
import { chmodSync as chmodSync11, existsSync as existsSync78, mkdirSync as mkdirSync61, writeFileSync as writeFileSync53 } from "node:fs";
|
|
516576
|
-
import { join as
|
|
516841
|
+
import { join as join124 } from "node:path";
|
|
516577
516842
|
import { promisify as promisify22 } from "node:util";
|
|
516578
516843
|
function messagesFromOverview(overview) {
|
|
516579
516844
|
return overview.messages?.map((message2) => ({
|
|
@@ -516883,7 +517148,7 @@ ${m4.body}` : m4.subject;
|
|
|
516883
517148
|
async function generateAndOpenMemoryViewer(agentId, options) {
|
|
516884
517149
|
const memoryRoot = getScopedMemoryFilesystemRoot(agentId);
|
|
516885
517150
|
const repoDir = memoryRoot;
|
|
516886
|
-
if (!existsSync78(
|
|
517151
|
+
if (!existsSync78(join124(repoDir, ".git"))) {
|
|
516887
517152
|
throw new Error("Memory viewer requires memfs. Run /memfs enable first.");
|
|
516888
517153
|
}
|
|
516889
517154
|
const data = await collectMemoryData(agentId, repoDir, memoryRoot, options?.conversationId);
|
|
@@ -516899,7 +517164,7 @@ async function generateAndOpenMemoryViewer(agentId, options) {
|
|
|
516899
517164
|
try {
|
|
516900
517165
|
chmodSync11(VIEWERS_DIR, 448);
|
|
516901
517166
|
} catch {}
|
|
516902
|
-
const filePath =
|
|
517167
|
+
const filePath = join124(VIEWERS_DIR, `memory-${encodeURIComponent(agentId)}.html`);
|
|
516903
517168
|
writeFileSync53(filePath, html5);
|
|
516904
517169
|
chmodSync11(filePath, 384);
|
|
516905
517170
|
const skipOpen = Boolean(process.env.TMUX) || Boolean(process.env.SSH_CONNECTION) || Boolean(process.env.SSH_TTY);
|
|
@@ -516927,13 +517192,13 @@ var init_generate_memory_viewer = __esm(() => {
|
|
|
516927
517192
|
init_local_memory_context();
|
|
516928
517193
|
init_memory_viewer_template();
|
|
516929
517194
|
execFile25 = promisify22(execFileCb6);
|
|
516930
|
-
VIEWERS_DIR =
|
|
517195
|
+
VIEWERS_DIR = join124(resolveGlobalConfigDir(), "viewers");
|
|
516931
517196
|
REFLECTION_PATTERN = /\(reflection\)|🔮|reflection:/i;
|
|
516932
517197
|
});
|
|
516933
517198
|
|
|
516934
517199
|
// src/cli/components/MemfsTreeViewer.tsx
|
|
516935
517200
|
import { existsSync as existsSync79 } from "node:fs";
|
|
516936
|
-
import { join as
|
|
517201
|
+
import { join as join125 } from "node:path";
|
|
516937
517202
|
function renderTreePrefix(node) {
|
|
516938
517203
|
let prefix = "";
|
|
516939
517204
|
for (let i4 = 0;i4 < node.depth; i4++) {
|
|
@@ -516962,7 +517227,7 @@ function MemfsTreeViewer({
|
|
|
516962
517227
|
const statusTimerRef = import_react88.useRef(null);
|
|
516963
517228
|
const memoryRoot = getScopedMemoryFilesystemRoot(agentId);
|
|
516964
517229
|
const memoryExists = existsSync79(memoryRoot);
|
|
516965
|
-
const hasGitRepo = import_react88.useMemo(() => existsSync79(
|
|
517230
|
+
const hasGitRepo = import_react88.useMemo(() => existsSync79(join125(memoryRoot, ".git")), [memoryRoot]);
|
|
516966
517231
|
function showStatus(msg, durationMs) {
|
|
516967
517232
|
if (statusTimerRef.current)
|
|
516968
517233
|
clearTimeout(statusTimerRef.current);
|
|
@@ -519694,10 +519959,10 @@ var init_use_chatgpt_rate_limit_state = __esm(() => {
|
|
|
519694
519959
|
// src/utils/aws-credentials.ts
|
|
519695
519960
|
import { readFile as readFile35 } from "node:fs/promises";
|
|
519696
519961
|
import { homedir as homedir36 } from "node:os";
|
|
519697
|
-
import { join as
|
|
519962
|
+
import { join as join126 } from "node:path";
|
|
519698
519963
|
async function parseAwsCredentials() {
|
|
519699
|
-
const credentialsPath =
|
|
519700
|
-
const configPath =
|
|
519964
|
+
const credentialsPath = join126(homedir36(), ".aws", "credentials");
|
|
519965
|
+
const configPath = join126(homedir36(), ".aws", "config");
|
|
519701
519966
|
const profiles = new Map;
|
|
519702
519967
|
try {
|
|
519703
519968
|
const content = await readFile35(credentialsPath, "utf-8");
|
|
@@ -521460,7 +521725,7 @@ var init_ReasoningMessageRich = __esm(async () => {
|
|
|
521460
521725
|
});
|
|
521461
521726
|
|
|
521462
521727
|
// src/cli/components/skills-dialog-paths.ts
|
|
521463
|
-
import { join as
|
|
521728
|
+
import { join as join127 } from "node:path";
|
|
521464
521729
|
function displayDirectory(path50) {
|
|
521465
521730
|
return `${path50.replace(/\\/g, "/").replace(/\/$/, "")}/`;
|
|
521466
521731
|
}
|
|
@@ -521470,7 +521735,7 @@ function getSkillsTabDescription(tab2, agentId, env6 = process.env) {
|
|
|
521470
521735
|
return ".agents/skills/";
|
|
521471
521736
|
case "agent": {
|
|
521472
521737
|
const memoryDir = resolveScopedMemoryDir({ agentId, env: env6 });
|
|
521473
|
-
return memoryDir ? displayDirectory(
|
|
521738
|
+
return memoryDir ? displayDirectory(join127(memoryDir, "skills")) : "$MEMORY_DIR/skills/";
|
|
521474
521739
|
}
|
|
521475
521740
|
case "global":
|
|
521476
521741
|
return displayDirectory(getGlobalSkillsDir(env6));
|
|
@@ -521498,8 +521763,8 @@ function SkillsDialog({ onClose, agentId }) {
|
|
|
521498
521763
|
try {
|
|
521499
521764
|
const { discoverSkills: discoverSkills2, SKILLS_DIR: SKILLS_DIR2 } = await Promise.resolve().then(() => (init_skills5(), exports_skills2));
|
|
521500
521765
|
const { getSkillsDirectory: getSkillsDirectory2, getSkillSources: getSkillSources2 } = await Promise.resolve().then(() => (init_context(), exports_context));
|
|
521501
|
-
const { join:
|
|
521502
|
-
const skillsDir = getSkillsDirectory2() ||
|
|
521766
|
+
const { join: join128 } = await import("node:path");
|
|
521767
|
+
const skillsDir = getSkillsDirectory2() || join128(process.cwd(), SKILLS_DIR2);
|
|
521503
521768
|
const result3 = await discoverSkills2(skillsDir, agentId, {
|
|
521504
521769
|
sources: getSkillSources2()
|
|
521505
521770
|
});
|
|
@@ -527605,7 +527870,7 @@ __export(exports_generate_diff_viewer, {
|
|
|
527605
527870
|
});
|
|
527606
527871
|
import { execFile as execFileCb7 } from "node:child_process";
|
|
527607
527872
|
import { chmodSync as chmodSync12, existsSync as existsSync80, mkdirSync as mkdirSync62, writeFileSync as writeFileSync54 } from "node:fs";
|
|
527608
|
-
import { isAbsolute as isAbsolute29, join as
|
|
527873
|
+
import { isAbsolute as isAbsolute29, join as join128, resolve as resolve43 } from "node:path";
|
|
527609
527874
|
import { promisify as promisify23 } from "node:util";
|
|
527610
527875
|
async function runGit8(cwd2, args) {
|
|
527611
527876
|
try {
|
|
@@ -527834,7 +528099,7 @@ async function generateAndOpenDiffViewer(targetPath) {
|
|
|
527834
528099
|
try {
|
|
527835
528100
|
chmodSync12(VIEWERS_DIR2, 448);
|
|
527836
528101
|
} catch {}
|
|
527837
|
-
const filePath =
|
|
528102
|
+
const filePath = join128(VIEWERS_DIR2, `diff-${encodeURIComponent(worktreePath)}.html`);
|
|
527838
528103
|
writeFileSync54(filePath, html5);
|
|
527839
528104
|
chmodSync12(filePath, 384);
|
|
527840
528105
|
const skipOpen = shouldSkipOpen();
|
|
@@ -527904,7 +528169,7 @@ var init_generate_diff_viewer = __esm(() => {
|
|
|
527904
528169
|
init_settings_path();
|
|
527905
528170
|
init_diff_viewer_template();
|
|
527906
528171
|
execFile26 = promisify23(execFileCb7);
|
|
527907
|
-
VIEWERS_DIR2 =
|
|
528172
|
+
VIEWERS_DIR2 = join128(resolveGlobalConfigDir(), "viewers");
|
|
527908
528173
|
GIT_MAX_BUFFER = 50 * 1024 * 1024;
|
|
527909
528174
|
});
|
|
527910
528175
|
|
|
@@ -529867,7 +530132,7 @@ __export(exports_shell_aliases, {
|
|
|
529867
530132
|
});
|
|
529868
530133
|
import { existsSync as existsSync81, readFileSync as readFileSync61 } from "node:fs";
|
|
529869
530134
|
import { homedir as homedir37 } from "node:os";
|
|
529870
|
-
import { join as
|
|
530135
|
+
import { join as join129 } from "node:path";
|
|
529871
530136
|
function parseAliasesFromFile(filePath) {
|
|
529872
530137
|
const aliases = new Map;
|
|
529873
530138
|
if (!existsSync81(filePath)) {
|
|
@@ -529939,7 +530204,7 @@ function loadAliases(forceReload = false) {
|
|
|
529939
530204
|
const home = homedir37();
|
|
529940
530205
|
const allAliases = new Map;
|
|
529941
530206
|
for (const file of ALIAS_FILES) {
|
|
529942
|
-
const filePath =
|
|
530207
|
+
const filePath = join129(home, file);
|
|
529943
530208
|
const fileAliases = parseAliasesFromFile(filePath);
|
|
529944
530209
|
for (const [name, value] of fileAliases) {
|
|
529945
530210
|
allAliases.set(name, value);
|
|
@@ -538157,8 +538422,8 @@ var init_conversation_switch_alert = __esm(() => {
|
|
|
538157
538422
|
// src/cli/app/use-submit-handler.ts
|
|
538158
538423
|
import { randomUUID as randomUUID75 } from "node:crypto";
|
|
538159
538424
|
import { existsSync as existsSync82, readFileSync as readFileSync62, renameSync as renameSync14 } from "node:fs";
|
|
538160
|
-
import { tmpdir as
|
|
538161
|
-
import { join as
|
|
538425
|
+
import { tmpdir as tmpdir19 } from "node:os";
|
|
538426
|
+
import { join as join130 } from "node:path";
|
|
538162
538427
|
async function findCustomCommandByName(commandName) {
|
|
538163
538428
|
const { findCustomCommand: findCustomCommand2 } = await Promise.resolve().then(() => (init_custom(), exports_custom));
|
|
538164
538429
|
return findCustomCommand2(commandName);
|
|
@@ -538766,8 +539031,8 @@ ${SYSTEM_REMINDER_CLOSE}`),
|
|
|
538766
539031
|
try {
|
|
538767
539032
|
const memoryRoot = getScopedMemoryFilesystemRoot(agentId);
|
|
538768
539033
|
const personaCandidates = [
|
|
538769
|
-
|
|
538770
|
-
|
|
539034
|
+
join130(memoryRoot, "system", "persona.md"),
|
|
539035
|
+
join130(memoryRoot, "memory", "system", "persona.md")
|
|
538771
539036
|
];
|
|
538772
539037
|
const personaPath = personaCandidates.find((candidate) => existsSync82(candidate));
|
|
538773
539038
|
if (personaPath) {
|
|
@@ -539615,7 +539880,7 @@ Path: ${memoryDir}`, true);
|
|
|
539615
539880
|
updateMemorySyncCommand(cmdId, "No local memory filesystem found to reset.", true, msg);
|
|
539616
539881
|
return { submitted: true };
|
|
539617
539882
|
}
|
|
539618
|
-
const backupDir =
|
|
539883
|
+
const backupDir = join130(tmpdir19(), `letta-memfs-reset-${agentId}-${Date.now()}`);
|
|
539619
539884
|
renameSync14(memoryDir, backupDir);
|
|
539620
539885
|
if (getBackend().capabilities.localMemfs) {
|
|
539621
539886
|
const { initializeLocalMemoryRepo: initializeLocalMemoryRepo2 } = await Promise.resolve().then(() => (init_memory_git(), exports_memory_git));
|
|
@@ -540524,7 +540789,7 @@ var init_use_submit_handler = __esm(async () => {
|
|
|
540524
540789
|
});
|
|
540525
540790
|
|
|
540526
540791
|
// src/cli/app/AppCoordinator.tsx
|
|
540527
|
-
import { join as
|
|
540792
|
+
import { join as join131 } from "node:path";
|
|
540528
540793
|
function buildStartupCommandHints(options) {
|
|
540529
540794
|
const {
|
|
540530
540795
|
isResumingConversation,
|
|
@@ -541805,7 +542070,7 @@ function App2({
|
|
|
541805
542070
|
agentId: a2.agentId ?? null
|
|
541806
542071
|
}))
|
|
541807
542072
|
});
|
|
541808
|
-
const agentModsDirectory = modContext.memfs.enabled && modContext.memfs.memoryDir ?
|
|
542073
|
+
const agentModsDirectory = modContext.memfs.enabled && modContext.memfs.memoryDir ? join131(modContext.memfs.memoryDir, "mods") : null;
|
|
541809
542074
|
const modAdapter = useLocalModAdapter(modContext, {
|
|
541810
542075
|
agentModsDirectory,
|
|
541811
542076
|
disabled: modsDisabled,
|
|
@@ -544146,12 +544411,12 @@ EXAMPLES
|
|
|
544146
544411
|
console.log(usage);
|
|
544147
544412
|
}
|
|
544148
544413
|
async function printInfo() {
|
|
544149
|
-
const { join:
|
|
544414
|
+
const { join: join132 } = await import("node:path");
|
|
544150
544415
|
const { getVersion: getVersion2 } = await Promise.resolve().then(() => (init_version(), exports_version));
|
|
544151
544416
|
const { SKILLS_DIR: SKILLS_DIR2 } = await Promise.resolve().then(() => (init_skills5(), exports_skills2));
|
|
544152
544417
|
const { exists: exists2 } = await Promise.resolve().then(() => (init_fs(), exports_fs));
|
|
544153
544418
|
const cwd2 = process.cwd();
|
|
544154
|
-
const skillsDir =
|
|
544419
|
+
const skillsDir = join132(cwd2, SKILLS_DIR2);
|
|
544155
544420
|
const skillsExist = exists2(skillsDir);
|
|
544156
544421
|
await settingsManager.loadLocalProjectSettings(cwd2);
|
|
544157
544422
|
const pinned = settingsManager.getPinnedAgents();
|
|
@@ -548016,4 +548281,4 @@ function registerBunOAuthFlows() {
|
|
|
548016
548281
|
registerBunOAuthFlows();
|
|
548017
548282
|
await init_src5().then(() => exports_src2);
|
|
548018
548283
|
|
|
548019
|
-
//# debugId=
|
|
548284
|
+
//# debugId=928B7A44932DBCE064756E2164756E21
|