@letta-ai/letta-code 0.34.73 → 0.34.75
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/cron/scheduler.d.ts.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/dist/types/websocket/listener/inbound-queue.d.ts.map +1 -1
- package/dist/types/websocket/listener/recorded-tool-results.d.ts.map +1 -1
- package/dist/types/websocket/listener/runtime.d.ts +3 -0
- package/dist/types/websocket/listener/runtime.d.ts.map +1 -1
- package/letta.js +873 -543
- 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.75",
|
|
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.75"
|
|
212284
212284
|
};
|
|
212285
212285
|
});
|
|
212286
212286
|
|
|
@@ -238756,9 +238756,13 @@ function enqueueInboundUserMessage(runtime, incoming, actingUserId, options = {}
|
|
|
238756
238756
|
if (!enqueuedItem) {
|
|
238757
238757
|
return false;
|
|
238758
238758
|
}
|
|
238759
|
+
markLocalTurnScope(runtime);
|
|
238759
238760
|
runtime.queuedMessagesByItemId.set(enqueuedItem.id, incoming);
|
|
238760
238761
|
return true;
|
|
238761
238762
|
}
|
|
238763
|
+
var init_inbound_queue = __esm(() => {
|
|
238764
|
+
init_runtime6();
|
|
238765
|
+
});
|
|
238762
238766
|
|
|
238763
238767
|
// src/websocket/listener/turn-correlation.ts
|
|
238764
238768
|
function takeDequeuedClientMessageIds(runtime, batchId) {
|
|
@@ -238827,6 +238831,7 @@ function createTurnCorrelation(runtime, message, batchId) {
|
|
|
238827
238831
|
}
|
|
238828
238832
|
var MAX_CLIENT_MESSAGE_IDS_PER_RUN = 32, MAX_RECENT_RUN_CORRELATIONS = 32, MAX_RECENT_CONVERSATIONS = 256;
|
|
238829
238833
|
var init_turn_correlation = __esm(() => {
|
|
238834
|
+
init_inbound_queue();
|
|
238830
238835
|
init_runtime6();
|
|
238831
238836
|
});
|
|
238832
238837
|
|
|
@@ -248754,13 +248759,222 @@ var init_subagent_process = __esm(() => {
|
|
|
248754
248759
|
init_package_manager_spawn();
|
|
248755
248760
|
});
|
|
248756
248761
|
|
|
248762
|
+
// src/tools/impl/antigravity-acp.ts
|
|
248763
|
+
import { mkdtemp as mkdtemp4, rm as rm8 } from "node:fs/promises";
|
|
248764
|
+
import { tmpdir as tmpdir13 } from "node:os";
|
|
248765
|
+
import { join as join68 } from "node:path";
|
|
248766
|
+
import { createInterface as createInterface8 } from "node:readline";
|
|
248767
|
+
async function withAcpTimeout(promise2, method2, timeout) {
|
|
248768
|
+
let timer;
|
|
248769
|
+
try {
|
|
248770
|
+
return await Promise.race([
|
|
248771
|
+
promise2,
|
|
248772
|
+
new Promise((_4, reject2) => {
|
|
248773
|
+
timer = setTimeout(() => reject2(new Error(`Antigravity ${method2} timed out`)), timeout);
|
|
248774
|
+
})
|
|
248775
|
+
]);
|
|
248776
|
+
} finally {
|
|
248777
|
+
clearTimeout(timer);
|
|
248778
|
+
}
|
|
248779
|
+
}
|
|
248780
|
+
async function withAntigravityAcp(cwd2, env6, run) {
|
|
248781
|
+
const temp = await mkdtemp4(join68(tmpdir13(), "letta-agy-acp-"));
|
|
248782
|
+
try {
|
|
248783
|
+
const client = new AntigravityAcp(cwd2, {
|
|
248784
|
+
...env6,
|
|
248785
|
+
TMPDIR: temp,
|
|
248786
|
+
...process.platform === "win32" && { TEMP: temp, TMP: temp }
|
|
248787
|
+
});
|
|
248788
|
+
try {
|
|
248789
|
+
return await run(client);
|
|
248790
|
+
} finally {
|
|
248791
|
+
await client.close();
|
|
248792
|
+
}
|
|
248793
|
+
} finally {
|
|
248794
|
+
await rm8(temp, { recursive: true, force: true });
|
|
248795
|
+
}
|
|
248796
|
+
}
|
|
248797
|
+
|
|
248798
|
+
class AntigravityAcp {
|
|
248799
|
+
controller = new AbortController;
|
|
248800
|
+
running;
|
|
248801
|
+
lines;
|
|
248802
|
+
pending = new Map;
|
|
248803
|
+
error;
|
|
248804
|
+
diagnostic = "";
|
|
248805
|
+
nextId = 0;
|
|
248806
|
+
onUpdate;
|
|
248807
|
+
onPermission;
|
|
248808
|
+
constructor(cwd2, env6) {
|
|
248809
|
+
this.running = spawnManagedWorkloadProcess("agy", ["acp"], {
|
|
248810
|
+
cwd: cwd2,
|
|
248811
|
+
env: env6,
|
|
248812
|
+
signal: this.controller.signal
|
|
248813
|
+
});
|
|
248814
|
+
const child = this.running.process;
|
|
248815
|
+
child.on("error", (error4) => {
|
|
248816
|
+
this.fail(error4.code === "ENOENT" ? new Error("Required executable 'agy' was not found on PATH") : error4);
|
|
248817
|
+
});
|
|
248818
|
+
child.stderr.on("data", (chunk2) => {
|
|
248819
|
+
this.diagnostic = (this.diagnostic + chunk2).slice(-2048);
|
|
248820
|
+
});
|
|
248821
|
+
child.stdin.on("error", (error4) => this.fail(error4));
|
|
248822
|
+
this.lines = createInterface8({ input: child.stdout });
|
|
248823
|
+
this.lines.on("line", (line) => {
|
|
248824
|
+
try {
|
|
248825
|
+
this.receive(line);
|
|
248826
|
+
} catch (error4) {
|
|
248827
|
+
this.fail(error4 instanceof Error ? error4 : new Error(String(error4)));
|
|
248828
|
+
}
|
|
248829
|
+
});
|
|
248830
|
+
this.running.completion.then(() => {
|
|
248831
|
+
this.fail(new Error(this.diagnostic.trim() || "Antigravity ACP exited"));
|
|
248832
|
+
});
|
|
248833
|
+
}
|
|
248834
|
+
fail(error4) {
|
|
248835
|
+
this.error ??= error4;
|
|
248836
|
+
for (const entry of this.pending.values())
|
|
248837
|
+
entry.reject(this.error);
|
|
248838
|
+
this.pending.clear();
|
|
248839
|
+
}
|
|
248840
|
+
write(message) {
|
|
248841
|
+
this.running.process.stdin.write(`${JSON.stringify({ jsonrpc: "2.0", ...message })}
|
|
248842
|
+
`);
|
|
248843
|
+
}
|
|
248844
|
+
receive(line) {
|
|
248845
|
+
if (!line.trim().startsWith("{"))
|
|
248846
|
+
return;
|
|
248847
|
+
const message = JSON.parse(line);
|
|
248848
|
+
if (!isRecord2(message) || message.jsonrpc !== "2.0")
|
|
248849
|
+
return;
|
|
248850
|
+
const { id, method: method2, params, result: result3, error: error4 } = message;
|
|
248851
|
+
if (typeof method2 === "string") {
|
|
248852
|
+
if (typeof id === "string" || typeof id === "number") {
|
|
248853
|
+
if (method2 === "session/request_permission") {
|
|
248854
|
+
const outcome = isRecord2(params) ? this.onPermission?.(params) : undefined;
|
|
248855
|
+
this.write({
|
|
248856
|
+
id,
|
|
248857
|
+
result: { outcome: outcome ?? { outcome: "cancelled" } }
|
|
248858
|
+
});
|
|
248859
|
+
} else {
|
|
248860
|
+
this.write({
|
|
248861
|
+
id,
|
|
248862
|
+
error: { code: -32601, message: "Method not supported" }
|
|
248863
|
+
});
|
|
248864
|
+
}
|
|
248865
|
+
} else if (method2 === "session/update" && isRecord2(params)) {
|
|
248866
|
+
this.onUpdate?.(params);
|
|
248867
|
+
}
|
|
248868
|
+
return;
|
|
248869
|
+
}
|
|
248870
|
+
if (typeof id !== "number")
|
|
248871
|
+
return;
|
|
248872
|
+
const entry = this.pending.get(id);
|
|
248873
|
+
this.pending.delete(id);
|
|
248874
|
+
if (isRecord2(error4))
|
|
248875
|
+
entry?.reject(new AntigravityRpcError(String(error4.message ?? "Antigravity ACP request failed"), error4.code));
|
|
248876
|
+
else
|
|
248877
|
+
entry?.resolve(isRecord2(result3) ? result3 : {});
|
|
248878
|
+
}
|
|
248879
|
+
async request(method2, params, timeout = 30000) {
|
|
248880
|
+
if (this.error)
|
|
248881
|
+
throw this.error;
|
|
248882
|
+
const id = ++this.nextId;
|
|
248883
|
+
const result3 = new Promise((resolve34, reject2) => {
|
|
248884
|
+
this.pending.set(id, { resolve: resolve34, reject: reject2 });
|
|
248885
|
+
this.write({ id, method: method2, params });
|
|
248886
|
+
});
|
|
248887
|
+
try {
|
|
248888
|
+
return await (timeout ? withAcpTimeout(result3, method2, timeout) : result3);
|
|
248889
|
+
} finally {
|
|
248890
|
+
this.pending.delete(id);
|
|
248891
|
+
}
|
|
248892
|
+
}
|
|
248893
|
+
notify(method2, params) {
|
|
248894
|
+
if (!this.error)
|
|
248895
|
+
this.write({ method: method2, params });
|
|
248896
|
+
}
|
|
248897
|
+
async close() {
|
|
248898
|
+
this.running.process.stdin.end();
|
|
248899
|
+
try {
|
|
248900
|
+
await withAcpTimeout(this.running.completion, "shutdown", 1000);
|
|
248901
|
+
} catch {
|
|
248902
|
+
this.controller.abort();
|
|
248903
|
+
await this.running.completion;
|
|
248904
|
+
} finally {
|
|
248905
|
+
this.lines.close();
|
|
248906
|
+
}
|
|
248907
|
+
}
|
|
248908
|
+
}
|
|
248909
|
+
async function openAntigravitySession(client, cwd2, apiKey, sessionId) {
|
|
248910
|
+
const init = await client.request("initialize", {
|
|
248911
|
+
protocolVersion: 1,
|
|
248912
|
+
clientInfo: { name: "letta-code", version: "1.0.0" },
|
|
248913
|
+
clientCapabilities: {}
|
|
248914
|
+
});
|
|
248915
|
+
try {
|
|
248916
|
+
await client.request("authenticate", {
|
|
248917
|
+
methodId: apiKey ? "gemini-api-key" : "oauth-personal"
|
|
248918
|
+
});
|
|
248919
|
+
} catch (error4) {
|
|
248920
|
+
if (!apiKey && error4 instanceof AntigravityRpcError)
|
|
248921
|
+
throw new Error("Antigravity is not signed in: run agy acp --login to authenticate");
|
|
248922
|
+
throw error4;
|
|
248923
|
+
}
|
|
248924
|
+
const params = { cwd: cwd2, mcpServers: [] };
|
|
248925
|
+
const capabilities = isRecord2(init.agentCapabilities) ? init.agentCapabilities.sessionCapabilities : undefined;
|
|
248926
|
+
const setup = sessionId ? await client.request(isRecord2(capabilities) && isRecord2(capabilities.resume) ? "session/resume" : "session/load", { ...params, sessionId }) : await client.request("session/new", params);
|
|
248927
|
+
const version3 = isRecord2(init.agentInfo) && typeof init.agentInfo.version === "string" ? /^(\d+)\.(\d+)\./.exec(init.agentInfo.version) : null;
|
|
248928
|
+
const liveSteering = !!version3 && (Number(version3[1]) > 1 || Number(version3[1]) === 1 && Number(version3[2]) >= 5);
|
|
248929
|
+
return {
|
|
248930
|
+
setup,
|
|
248931
|
+
liveSteering,
|
|
248932
|
+
canClose: isRecord2(capabilities) && isRecord2(capabilities.close)
|
|
248933
|
+
};
|
|
248934
|
+
}
|
|
248935
|
+
function antigravityConfig(setup, category2) {
|
|
248936
|
+
return Array.isArray(setup.configOptions) ? setup.configOptions.filter(isRecord2).find((option2) => option2.category === category2 && option2.type === "select") : undefined;
|
|
248937
|
+
}
|
|
248938
|
+
async function listAntigravityModels(cwd2, env6) {
|
|
248939
|
+
try {
|
|
248940
|
+
return await withAntigravityAcp(cwd2, env6, async (client) => {
|
|
248941
|
+
const { setup, canClose } = await openAntigravitySession(client, cwd2, !!env6.GEMINI_API_KEY);
|
|
248942
|
+
try {
|
|
248943
|
+
const model2 = antigravityConfig(setup, "model");
|
|
248944
|
+
const options = Array.isArray(model2?.options) ? model2.options.filter(isRecord2) : [];
|
|
248945
|
+
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) => ({
|
|
248946
|
+
id: option2.value,
|
|
248947
|
+
displayName: option2.name,
|
|
248948
|
+
description: option2.description
|
|
248949
|
+
}));
|
|
248950
|
+
} finally {
|
|
248951
|
+
if (canClose && typeof setup.sessionId === "string")
|
|
248952
|
+
await client.request("session/close", { sessionId: setup.sessionId }, 1000).catch(() => {});
|
|
248953
|
+
}
|
|
248954
|
+
});
|
|
248955
|
+
} catch {
|
|
248956
|
+
return [];
|
|
248957
|
+
}
|
|
248958
|
+
}
|
|
248959
|
+
var AntigravityRpcError;
|
|
248960
|
+
var init_antigravity_acp = __esm(() => {
|
|
248961
|
+
init_subagent_process();
|
|
248962
|
+
AntigravityRpcError = class AntigravityRpcError extends Error {
|
|
248963
|
+
code;
|
|
248964
|
+
constructor(message, code) {
|
|
248965
|
+
super(message);
|
|
248966
|
+
this.code = code;
|
|
248967
|
+
}
|
|
248968
|
+
};
|
|
248969
|
+
});
|
|
248970
|
+
|
|
248757
248971
|
// src/tools/impl/native-session-owner.ts
|
|
248758
248972
|
import { createHash as createHash11 } from "node:crypto";
|
|
248759
248973
|
import { mkdirSync as mkdirSync38, readFileSync as readFileSync41, rmSync as rmSync16, writeFileSync as writeFileSync33 } from "node:fs";
|
|
248760
|
-
import { join as
|
|
248974
|
+
import { join as join69 } from "node:path";
|
|
248761
248975
|
function ownerPath(source, sessionId) {
|
|
248762
248976
|
const id = createHash11("sha256").update(`${source}:${sessionId}`).digest("hex");
|
|
248763
|
-
return
|
|
248977
|
+
return join69(resolveGlobalConfigDir(), "native-session-owners", `${id}.json`);
|
|
248764
248978
|
}
|
|
248765
248979
|
function readNativeSessionOwner(source, sessionId) {
|
|
248766
248980
|
try {
|
|
@@ -248776,7 +248990,7 @@ function readNativeSessionOwner(source, sessionId) {
|
|
|
248776
248990
|
}
|
|
248777
248991
|
function persistNativeSessionOwner(source, sessionId, scope) {
|
|
248778
248992
|
const path30 = ownerPath(source, sessionId);
|
|
248779
|
-
mkdirSync38(
|
|
248993
|
+
mkdirSync38(join69(path30, ".."), { recursive: true, mode: 448 });
|
|
248780
248994
|
try {
|
|
248781
248995
|
writeFileSync33(path30, JSON.stringify(scope), { flag: "wx", mode: 384 });
|
|
248782
248996
|
} catch (error4) {
|
|
@@ -248790,173 +249004,222 @@ var init_native_session_owner = __esm(() => {
|
|
|
248790
249004
|
});
|
|
248791
249005
|
|
|
248792
249006
|
// src/tools/impl/antigravity-session.ts
|
|
248793
|
-
|
|
249007
|
+
function requireOwner(id, agentId) {
|
|
249008
|
+
const owner = sessionPattern.test(id) ? readNativeSessionOwner("antigravity", id) : undefined;
|
|
249009
|
+
if (owner?.agentId !== agentId)
|
|
249010
|
+
throw new Error("Antigravity session does not belong to this agent");
|
|
249011
|
+
return owner;
|
|
249012
|
+
}
|
|
249013
|
+
function createTurnProgress(options, secrets2) {
|
|
249014
|
+
const text2 = createSecretStreamScrubber(secrets2);
|
|
249015
|
+
const scrub = (value) => scrubSecretsFromString(value, secrets2);
|
|
249016
|
+
const tools = new Map;
|
|
249017
|
+
const completedTools = new Set;
|
|
249018
|
+
let report = "";
|
|
249019
|
+
return {
|
|
249020
|
+
update(update2) {
|
|
249021
|
+
if (update2.sessionUpdate === "agent_message_chunk" && isRecord2(update2.content) && update2.content.type === "text" && typeof update2.content.text === "string") {
|
|
249022
|
+
report += update2.content.text;
|
|
249023
|
+
const delta = text2.push(update2.content.text);
|
|
249024
|
+
if (delta)
|
|
249025
|
+
emitProgress(options.onText, delta);
|
|
249026
|
+
}
|
|
249027
|
+
const id = update2.toolCallId;
|
|
249028
|
+
if (typeof id !== "string")
|
|
249029
|
+
return;
|
|
249030
|
+
if (update2.sessionUpdate === "tool_call" && !tools.has(id)) {
|
|
249031
|
+
const label = update2.name ?? update2.title;
|
|
249032
|
+
const name = typeof label === "string" ? scrub(label) : "Antigravity tool";
|
|
249033
|
+
tools.set(id, name);
|
|
249034
|
+
emitProgress(options.onToolCall, {
|
|
249035
|
+
id,
|
|
249036
|
+
name,
|
|
249037
|
+
args: scrub(formatExternalToolCallArgs(update2.rawInput))
|
|
249038
|
+
});
|
|
249039
|
+
}
|
|
249040
|
+
if ((update2.status === "completed" || update2.status === "failed") && !completedTools.has(id) && tools.has(id)) {
|
|
249041
|
+
completedTools.add(id);
|
|
249042
|
+
emitProgress(options.onToolResult, {
|
|
249043
|
+
id,
|
|
249044
|
+
name: tools.get(id),
|
|
249045
|
+
isError: update2.status === "failed" || isRecord2(update2.rawOutput) && typeof update2.rawOutput.exit_code === "number" && update2.rawOutput.exit_code !== 0,
|
|
249046
|
+
output: scrub(toolOutputText(update2.rawOutput ?? update2.content))
|
|
249047
|
+
});
|
|
249048
|
+
}
|
|
249049
|
+
},
|
|
249050
|
+
finish() {
|
|
249051
|
+
const tail2 = text2.flush();
|
|
249052
|
+
if (tail2)
|
|
249053
|
+
emitProgress(options.onText, tail2);
|
|
249054
|
+
return scrub(report);
|
|
249055
|
+
}
|
|
249056
|
+
};
|
|
249057
|
+
}
|
|
248794
249058
|
async function runAntigravityTurn(options, env6, secrets2) {
|
|
248795
249059
|
const start = Date.now();
|
|
248796
249060
|
if (env6.GEMINI_API_KEY)
|
|
248797
249061
|
secrets2 = { ...secrets2, GEMINI_API_KEY: env6.GEMINI_API_KEY };
|
|
248798
249062
|
let sessionId = options.resumeSessionId;
|
|
248799
249063
|
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
|
-
};
|
|
249064
|
+
const { signal } = options;
|
|
248807
249065
|
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"}');
|
|
249066
|
+
signal?.throwIfAborted();
|
|
249067
|
+
const unrestricted = (getRuntimeContext()?.permissionMode ?? permissionMode.getMode()) === "unrestricted";
|
|
248820
249068
|
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");
|
|
249069
|
+
const owner = requireOwner(sessionId, options.parentAgentId);
|
|
248824
249070
|
if (sessions.has(sessionId))
|
|
248825
249071
|
throw new Error("Antigravity session is already running");
|
|
248826
249072
|
sessions.set(sessionId, state2);
|
|
248827
|
-
args.push("--conversation", sessionId);
|
|
248828
249073
|
options = {
|
|
248829
249074
|
...options,
|
|
248830
249075
|
cwd: owner.cwd ?? options.cwd,
|
|
248831
249076
|
model: options.model ?? owner.model
|
|
248832
249077
|
};
|
|
248833
249078
|
}
|
|
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
|
|
249079
|
+
return await withAntigravityAcp(options.cwd, env6, async (client) => {
|
|
249080
|
+
const { setup, liveSteering, canClose } = await openAntigravitySession(client, options.cwd, !!env6.GEMINI_API_KEY, sessionId);
|
|
249081
|
+
const id = sessionId ?? setup.sessionId;
|
|
249082
|
+
if (typeof id !== "string" || !sessionPattern.test(id) || setup.sessionId !== undefined && id !== setup.sessionId || sessions.has(id) && sessions.get(id) !== state2)
|
|
249083
|
+
throw new Error("Invalid Antigravity conversation ID");
|
|
249084
|
+
sessionId = id;
|
|
249085
|
+
let cancelTimer;
|
|
249086
|
+
let rejectCancelled = () => {};
|
|
249087
|
+
const cancelled = new Promise((_4, reject2) => {
|
|
249088
|
+
rejectCancelled = reject2;
|
|
249089
|
+
});
|
|
249090
|
+
const cancel = () => {
|
|
249091
|
+
state2.closing = true;
|
|
249092
|
+
client.notify("session/cancel", { sessionId: id });
|
|
249093
|
+
cancelTimer = setTimeout(() => rejectCancelled(signal?.reason), 3000);
|
|
249094
|
+
};
|
|
249095
|
+
try {
|
|
249096
|
+
signal?.throwIfAborted();
|
|
249097
|
+
if (!options.resumeSessionId) {
|
|
249098
|
+
persistNativeSessionOwner("antigravity", id, {
|
|
249099
|
+
agentId: options.parentAgentId,
|
|
249100
|
+
conversationId: options.parentConversationId ?? "default",
|
|
249101
|
+
cwd: options.cwd,
|
|
249102
|
+
model: options.model
|
|
249103
|
+
});
|
|
249104
|
+
requireOwner(id, options.parentAgentId);
|
|
249105
|
+
}
|
|
249106
|
+
sessions.set(id, state2);
|
|
249107
|
+
const mode = antigravityConfig(setup, "mode");
|
|
249108
|
+
if (!unrestricted && Array.isArray(mode?.options) && mode.options.some((entry) => isRecord2(entry) && entry.value === "accept-edits")) {
|
|
249109
|
+
await client.request("session/set_config_option", {
|
|
249110
|
+
sessionId: id,
|
|
249111
|
+
configId: mode.id,
|
|
249112
|
+
value: "accept-edits"
|
|
249113
|
+
});
|
|
249114
|
+
}
|
|
249115
|
+
if (options.model) {
|
|
249116
|
+
const model2 = antigravityConfig(setup, "model");
|
|
249117
|
+
const legacyModels = isRecord2(setup.models) ? setup.models.availableModels : undefined;
|
|
249118
|
+
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));
|
|
249119
|
+
if (useLegacy) {
|
|
249120
|
+
await client.request("session/set_model", {
|
|
249121
|
+
sessionId: id,
|
|
249122
|
+
modelId: options.model
|
|
248880
249123
|
});
|
|
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
249124
|
} else {
|
|
248928
|
-
|
|
248929
|
-
|
|
248930
|
-
|
|
249125
|
+
await client.request("session/set_config_option", {
|
|
249126
|
+
sessionId: id,
|
|
249127
|
+
configId: model2.id,
|
|
249128
|
+
value: options.model
|
|
249129
|
+
});
|
|
248931
249130
|
}
|
|
248932
249131
|
}
|
|
249132
|
+
signal?.throwIfAborted();
|
|
249133
|
+
let progress = createTurnProgress(options, secrets2);
|
|
249134
|
+
let denied = false;
|
|
249135
|
+
client.onUpdate = (params) => {
|
|
249136
|
+
if (params.sessionId === id && isRecord2(params.update))
|
|
249137
|
+
progress.update(params.update);
|
|
249138
|
+
};
|
|
249139
|
+
client.onPermission = (params) => {
|
|
249140
|
+
if (params.sessionId !== id || signal?.aborted)
|
|
249141
|
+
return { outcome: "cancelled" };
|
|
249142
|
+
if (isRecord2(params.toolCall) && typeof params.toolCall.toolCallId === "string" && params.toolCall.toolCallId.startsWith("interaction_"))
|
|
249143
|
+
return { outcome: "cancelled" };
|
|
249144
|
+
const choices = Array.isArray(params.options) ? params.options.filter(isRecord2) : [];
|
|
249145
|
+
const kind = unrestricted ? "allow_once" : "reject_once";
|
|
249146
|
+
const choice = choices.find((entry) => entry.kind === kind && typeof entry.optionId === "string");
|
|
249147
|
+
denied ||= !unrestricted || !choice;
|
|
249148
|
+
return choice ? { outcome: "selected", optionId: choice.optionId } : { outcome: "cancelled" };
|
|
249149
|
+
};
|
|
249150
|
+
const prompt = (value) => client.request("session/prompt", {
|
|
249151
|
+
sessionId: id,
|
|
249152
|
+
prompt: [{ type: "text", text: value }]
|
|
249153
|
+
}, 0);
|
|
249154
|
+
let next = [options.mcpReminder, options.prompt].filter(Boolean).join(`
|
|
249155
|
+
|
|
249156
|
+
`);
|
|
249157
|
+
let report = "";
|
|
249158
|
+
let supportsSteering = liveSteering;
|
|
249159
|
+
signal?.addEventListener("abort", cancel, { once: true });
|
|
249160
|
+
let started = false;
|
|
249161
|
+
while (true) {
|
|
249162
|
+
let steering;
|
|
249163
|
+
const turn = prompt(next);
|
|
249164
|
+
state2.steer = (value) => {
|
|
249165
|
+
if (!supportsSteering || steering || state2.queue.length)
|
|
249166
|
+
return false;
|
|
249167
|
+
steering = prompt(value).catch((error4) => {
|
|
249168
|
+
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))) {
|
|
249169
|
+
if (error4.code === -32601 || /steering.*not supported/i.test(error4.message))
|
|
249170
|
+
supportsSteering = false;
|
|
249171
|
+
state2.queue.unshift(value);
|
|
249172
|
+
return;
|
|
249173
|
+
}
|
|
249174
|
+
throw error4;
|
|
249175
|
+
});
|
|
249176
|
+
steering.catch(() => {});
|
|
249177
|
+
return true;
|
|
249178
|
+
};
|
|
249179
|
+
if (!started) {
|
|
249180
|
+
started = true;
|
|
249181
|
+
emitProgress(options.onStarted, `antigravity_${id}`);
|
|
249182
|
+
}
|
|
249183
|
+
const result3 = await Promise.race([turn, cancelled]);
|
|
249184
|
+
state2.steer = undefined;
|
|
249185
|
+
const steered = steering && await Promise.race([steering, cancelled]);
|
|
249186
|
+
signal?.throwIfAborted();
|
|
249187
|
+
if (result3.stopReason === "cancelled" && !steered || steered?.stopReason === "cancelled")
|
|
249188
|
+
throw new Error("Antigravity turn cancelled");
|
|
249189
|
+
report = progress.finish();
|
|
249190
|
+
if (!report.trim() && denied)
|
|
249191
|
+
throw new Error("Antigravity tool permission denied");
|
|
249192
|
+
const queued = state2.queue.shift();
|
|
249193
|
+
if (queued === undefined)
|
|
249194
|
+
break;
|
|
249195
|
+
next = queued;
|
|
249196
|
+
denied = false;
|
|
249197
|
+
progress = createTurnProgress(options, secrets2);
|
|
249198
|
+
}
|
|
249199
|
+
state2.closing = true;
|
|
249200
|
+
return {
|
|
249201
|
+
model: options.model,
|
|
249202
|
+
agentId: `antigravity_${id}`,
|
|
249203
|
+
runtimeSessionId: id,
|
|
249204
|
+
report,
|
|
249205
|
+
success: true,
|
|
249206
|
+
durationMs: Date.now() - start
|
|
249207
|
+
};
|
|
249208
|
+
} finally {
|
|
249209
|
+
state2.closing = true;
|
|
249210
|
+
signal?.removeEventListener("abort", cancel);
|
|
249211
|
+
clearTimeout(cancelTimer);
|
|
249212
|
+
client.onUpdate = undefined;
|
|
249213
|
+
client.onPermission = undefined;
|
|
249214
|
+
if (canClose)
|
|
249215
|
+
await client.request("session/close", { sessionId: id }, 1000).catch(() => {});
|
|
248933
249216
|
}
|
|
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
|
-
}
|
|
249217
|
+
});
|
|
248957
249218
|
} catch (error4) {
|
|
248958
249219
|
return {
|
|
248959
|
-
|
|
249220
|
+
model: options.model,
|
|
249221
|
+
report: "",
|
|
249222
|
+
agentId: options.parentAgentId,
|
|
248960
249223
|
success: false,
|
|
248961
249224
|
error: scrubSecretsFromString(error4 instanceof Error ? error4.message : String(error4), secrets2),
|
|
248962
249225
|
durationMs: Date.now() - start
|
|
@@ -248968,14 +249231,16 @@ ${error4}`))
|
|
|
248968
249231
|
}
|
|
248969
249232
|
function sendAntigravityMessage(options, env6, secrets2) {
|
|
248970
249233
|
const id = options.resumeSessionId;
|
|
248971
|
-
|
|
248972
|
-
throw new Error("Antigravity session does not belong to this agent");
|
|
249234
|
+
requireOwner(id, options.parentAgentId);
|
|
248973
249235
|
const active = sessions.get(id);
|
|
248974
249236
|
if (active) {
|
|
248975
249237
|
if (active.closing)
|
|
248976
249238
|
throw new Error("Antigravity session is finishing; retry after completion");
|
|
248977
|
-
|
|
248978
|
-
|
|
249239
|
+
options.signal?.throwIfAborted();
|
|
249240
|
+
const queued = !active.steer?.(options.prompt);
|
|
249241
|
+
if (queued)
|
|
249242
|
+
active.queue.push(options.prompt);
|
|
249243
|
+
return { mode: "steered", queued };
|
|
248979
249244
|
}
|
|
248980
249245
|
const controller = new AbortController;
|
|
248981
249246
|
const signal = options.signal ? AbortSignal.any([controller.signal, options.signal]) : controller.signal;
|
|
@@ -248991,8 +249256,10 @@ function sendAntigravityMessage(options, env6, secrets2) {
|
|
|
248991
249256
|
}
|
|
248992
249257
|
var sessions, sessionPattern;
|
|
248993
249258
|
var init_antigravity_session = __esm(() => {
|
|
248994
|
-
|
|
249259
|
+
init_mode();
|
|
249260
|
+
init_runtime_context();
|
|
248995
249261
|
init_secret_substitution();
|
|
249262
|
+
init_antigravity_acp();
|
|
248996
249263
|
init_native_session_owner();
|
|
248997
249264
|
sessions = new Map;
|
|
248998
249265
|
sessionPattern = /^[a-f\d]{8}(?:-[a-f\d]{4}){3}-[a-f\d]{12}$/i;
|
|
@@ -249015,11 +249282,11 @@ async function confirmProcessExit(exit, name) {
|
|
|
249015
249282
|
|
|
249016
249283
|
// src/utils/native-cli-env.ts
|
|
249017
249284
|
import { homedir as homedir19 } from "node:os";
|
|
249018
|
-
import { join as
|
|
249285
|
+
import { join as join70 } from "node:path";
|
|
249019
249286
|
function withNativeCliPath(env6, platform7 = process.platform) {
|
|
249020
249287
|
if (platform7 === "win32")
|
|
249021
249288
|
return { ...env6 };
|
|
249022
|
-
const nativeBin =
|
|
249289
|
+
const nativeBin = join70(env6.HOME || homedir19(), ".local", "bin");
|
|
249023
249290
|
const paths = (env6.PATH ?? "/usr/bin:/bin").split(":");
|
|
249024
249291
|
if (!paths.includes(nativeBin))
|
|
249025
249292
|
paths.push(nativeBin);
|
|
@@ -249028,20 +249295,20 @@ function withNativeCliPath(env6, platform7 = process.platform) {
|
|
|
249028
249295
|
var init_native_cli_env = () => {};
|
|
249029
249296
|
|
|
249030
249297
|
// 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
|
|
249298
|
+
import { mkdir as mkdir11, mkdtemp as mkdtemp5, rm as rm9, stat as stat10, symlink as symlink3 } from "node:fs/promises";
|
|
249299
|
+
import { tmpdir as tmpdir14 } from "node:os";
|
|
249300
|
+
import { basename as basename22, join as join71 } from "node:path";
|
|
249034
249301
|
async function stageClaudeRepositorySkills(repositoryRoots) {
|
|
249035
249302
|
const directories = [];
|
|
249036
249303
|
let stagingRoot;
|
|
249037
249304
|
const cleanup = async () => {
|
|
249038
249305
|
if (stagingRoot)
|
|
249039
|
-
await
|
|
249306
|
+
await rm9(stagingRoot, { recursive: true, force: true });
|
|
249040
249307
|
};
|
|
249041
249308
|
try {
|
|
249042
249309
|
for (const repo of repositoryRoots) {
|
|
249043
249310
|
for (const source of [".claude", ".agents"]) {
|
|
249044
|
-
const skills =
|
|
249311
|
+
const skills = join71(repo, source, "skills");
|
|
249045
249312
|
const info = await stat10(skills).catch((error4) => {
|
|
249046
249313
|
if (error4.code === "ENOENT" || error4.code === "ENOTDIR")
|
|
249047
249314
|
return;
|
|
@@ -249049,11 +249316,11 @@ async function stageClaudeRepositorySkills(repositoryRoots) {
|
|
|
249049
249316
|
});
|
|
249050
249317
|
if (!info?.isDirectory())
|
|
249051
249318
|
continue;
|
|
249052
|
-
stagingRoot ??= await
|
|
249053
|
-
const directory =
|
|
249054
|
-
const claudeDir =
|
|
249319
|
+
stagingRoot ??= await mkdtemp5(join71(tmpdir14(), "letta-claude-skills-"));
|
|
249320
|
+
const directory = join71(stagingRoot, source, basename22(repo));
|
|
249321
|
+
const claudeDir = join71(directory, ".claude");
|
|
249055
249322
|
await mkdir11(claudeDir, { recursive: true });
|
|
249056
|
-
await symlink3(skills,
|
|
249323
|
+
await symlink3(skills, join71(claudeDir, "skills"), "dir");
|
|
249057
249324
|
directories.push(directory);
|
|
249058
249325
|
}
|
|
249059
249326
|
}
|
|
@@ -250648,7 +250915,7 @@ var init_codex_steer_receipt = __esm(() => {
|
|
|
250648
250915
|
});
|
|
250649
250916
|
|
|
250650
250917
|
// src/tools/impl/codex-app-server.ts
|
|
250651
|
-
import { join as
|
|
250918
|
+
import { join as join72 } from "node:path";
|
|
250652
250919
|
import { createInterface as createInterface10 } from "node:readline";
|
|
250653
250920
|
import { setTimeout as sleep12 } from "node:timers/promises";
|
|
250654
250921
|
async function listCodexModels(cwd2, env6) {
|
|
@@ -250771,7 +251038,7 @@ class CodexAppServerClient {
|
|
|
250771
251038
|
await this.request("initialize", {
|
|
250772
251039
|
clientInfo: {
|
|
250773
251040
|
name: "letta-code",
|
|
250774
|
-
version: "0.34.
|
|
251041
|
+
version: "0.34.75"
|
|
250775
251042
|
},
|
|
250776
251043
|
capabilities: null
|
|
250777
251044
|
});
|
|
@@ -251049,7 +251316,7 @@ async function createSession(options, deps) {
|
|
|
251049
251316
|
});
|
|
251050
251317
|
if (options.cloudSkillRepositories?.length) {
|
|
251051
251318
|
await client.request("skills/extraRoots/set", {
|
|
251052
|
-
extraRoots: cloudRepositoryRoots(options.cloudSkillRepositories).map((root2) =>
|
|
251319
|
+
extraRoots: cloudRepositoryRoots(options.cloudSkillRepositories).map((root2) => join72(root2, PROJECT_SKILLS_DIR))
|
|
251053
251320
|
});
|
|
251054
251321
|
}
|
|
251055
251322
|
const method2 = options.resumeThreadId ? "thread/resume" : "thread/start";
|
|
@@ -251319,7 +251586,7 @@ var init_codex_app_server = __esm(() => {
|
|
|
251319
251586
|
// src/tools/impl/cursor-session.ts
|
|
251320
251587
|
import { randomUUID as randomUUID41 } from "node:crypto";
|
|
251321
251588
|
import { existsSync as existsSync47 } from "node:fs";
|
|
251322
|
-
import { join as
|
|
251589
|
+
import { join as join73 } from "node:path";
|
|
251323
251590
|
import { createInterface as createInterface11 } from "node:readline";
|
|
251324
251591
|
import { fileURLToPath as fileURLToPath7 } from "node:url";
|
|
251325
251592
|
function key2(options, id) {
|
|
@@ -251475,7 +251742,7 @@ async function runCursorTurn(options, env6 = process.env, secrets2 = {}) {
|
|
|
251475
251742
|
type: "start",
|
|
251476
251743
|
sessionId: id,
|
|
251477
251744
|
resume: !!options.resumeSessionId,
|
|
251478
|
-
stateDir:
|
|
251745
|
+
stateDir: join73(resolveGlobalConfigDir(), "cursor-sessions", sessionKey),
|
|
251479
251746
|
cwd: options.cwd,
|
|
251480
251747
|
model: options.model,
|
|
251481
251748
|
reminder: options.mcpReminder,
|
|
@@ -252578,14 +252845,14 @@ var init_engine = __esm(() => {
|
|
|
252578
252845
|
import { createHash as createHash12, randomUUID as randomUUID42 } from "node:crypto";
|
|
252579
252846
|
import { readdirSync as readdirSync18, rmSync as rmSync17 } from "node:fs";
|
|
252580
252847
|
import {
|
|
252581
|
-
mkdtemp as
|
|
252848
|
+
mkdtemp as mkdtemp6,
|
|
252582
252849
|
open as open4,
|
|
252583
252850
|
readdir as readdir8,
|
|
252584
|
-
rm as
|
|
252851
|
+
rm as rm10,
|
|
252585
252852
|
stat as stat11
|
|
252586
252853
|
} from "node:fs/promises";
|
|
252587
|
-
import { homedir as homedir20, tmpdir as
|
|
252588
|
-
import { join as
|
|
252854
|
+
import { homedir as homedir20, tmpdir as tmpdir15 } from "node:os";
|
|
252855
|
+
import { join as join74 } from "node:path";
|
|
252589
252856
|
async function hashNativeSessionPrefix(input, size2) {
|
|
252590
252857
|
const hash = createHash12("sha256");
|
|
252591
252858
|
const buffer = Buffer.allocUnsafe(NATIVE_SESSION_CAPTURE_CHUNK_BYTES);
|
|
@@ -252635,7 +252902,7 @@ function cleanupSpoolDirectorySync(directory) {
|
|
|
252635
252902
|
}
|
|
252636
252903
|
async function cleanupSpoolDirectory(directory) {
|
|
252637
252904
|
try {
|
|
252638
|
-
await
|
|
252905
|
+
await rm10(directory, { recursive: true, force: true });
|
|
252639
252906
|
spoolDirectories.delete(directory);
|
|
252640
252907
|
} catch (error4) {
|
|
252641
252908
|
debugWarn("native-session", "Failed to delete native capture spool directory", error4);
|
|
@@ -252647,7 +252914,7 @@ function scavengeStaleSpoolDirectories() {
|
|
|
252647
252914
|
staleSpoolsScavenged = true;
|
|
252648
252915
|
let entries;
|
|
252649
252916
|
try {
|
|
252650
|
-
entries = readdirSync18(
|
|
252917
|
+
entries = readdirSync18(tmpdir15(), { withFileTypes: true });
|
|
252651
252918
|
} catch {
|
|
252652
252919
|
return;
|
|
252653
252920
|
}
|
|
@@ -252670,7 +252937,7 @@ function scavengeStaleSpoolDirectories() {
|
|
|
252670
252937
|
}
|
|
252671
252938
|
}
|
|
252672
252939
|
if (!ownerIsAlive)
|
|
252673
|
-
cleanupSpoolDirectorySync(
|
|
252940
|
+
cleanupSpoolDirectorySync(join74(tmpdir15(), entry.name));
|
|
252674
252941
|
}
|
|
252675
252942
|
}
|
|
252676
252943
|
function key3(source, sessionId) {
|
|
@@ -252823,9 +253090,9 @@ async function findNativeSessionPath(source, sessionId, env6 = process.env) {
|
|
|
252823
253090
|
return;
|
|
252824
253091
|
const home = env6.HOME || homedir20();
|
|
252825
253092
|
if (source === "claude_code") {
|
|
252826
|
-
const projects =
|
|
253093
|
+
const projects = join74(env6.CLAUDE_CONFIG_DIR || join74(home, ".claude"), "projects");
|
|
252827
253094
|
for (const project of await entries(projects, true)) {
|
|
252828
|
-
const path30 =
|
|
253095
|
+
const path30 = join74(projects, project, `${sessionId}.jsonl`);
|
|
252829
253096
|
try {
|
|
252830
253097
|
if ((await stat11(path30)).isFile())
|
|
252831
253098
|
return path30;
|
|
@@ -252836,14 +253103,14 @@ async function findNativeSessionPath(source, sessionId, env6 = process.env) {
|
|
|
252836
253103
|
}
|
|
252837
253104
|
return;
|
|
252838
253105
|
}
|
|
252839
|
-
const root2 =
|
|
253106
|
+
const root2 = join74(env6.CODEX_HOME || join74(home, ".codex"), "sessions");
|
|
252840
253107
|
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 =
|
|
253108
|
+
for (const month of (await entries(join74(root2, year), true)).filter((name) => /^\d{2}$/.test(name)))
|
|
253109
|
+
for (const day of (await entries(join74(root2, year, month), true)).filter((name) => /^\d{2}$/.test(name))) {
|
|
253110
|
+
const directory = join74(root2, year, month, day);
|
|
252844
253111
|
for (const file of await entries(directory, false))
|
|
252845
253112
|
if (file.startsWith("rollout-") && file.endsWith(`-${sessionId}.jsonl`))
|
|
252846
|
-
return
|
|
253113
|
+
return join74(directory, file);
|
|
252847
253114
|
}
|
|
252848
253115
|
return;
|
|
252849
253116
|
}
|
|
@@ -252860,9 +253127,9 @@ async function seal(state2, source, sessionId, scope, env6, requestOptions) {
|
|
|
252860
253127
|
throw new Error("Native session file disappeared before EOF capture");
|
|
252861
253128
|
throw error4;
|
|
252862
253129
|
}
|
|
252863
|
-
const directory = await
|
|
253130
|
+
const directory = await mkdtemp6(join74(tmpdir15(), `letta-native-session-${process.pid}-${captureProcessInstanceId}-`));
|
|
252864
253131
|
spoolDirectories.add(directory);
|
|
252865
|
-
const spoolPath =
|
|
253132
|
+
const spoolPath = join74(directory, "segment");
|
|
252866
253133
|
let output;
|
|
252867
253134
|
let retained = false;
|
|
252868
253135
|
try {
|
|
@@ -252979,7 +253246,7 @@ async function drain(state2, source, sessionId) {
|
|
|
252979
253246
|
await spool.close();
|
|
252980
253247
|
}
|
|
252981
253248
|
state2.segments.shift();
|
|
252982
|
-
const directory =
|
|
253249
|
+
const directory = join74(segment.path, "..");
|
|
252983
253250
|
await cleanupSpoolDirectory(directory);
|
|
252984
253251
|
}
|
|
252985
253252
|
}
|
|
@@ -253011,7 +253278,7 @@ async function discardRejectedSegment(state2) {
|
|
|
253011
253278
|
const segment = state2.segments.shift();
|
|
253012
253279
|
if (!segment)
|
|
253013
253280
|
return;
|
|
253014
|
-
const directory =
|
|
253281
|
+
const directory = join74(segment.path, "..");
|
|
253015
253282
|
await cleanupSpoolDirectory(directory);
|
|
253016
253283
|
state2.ackedOffset = segment.end;
|
|
253017
253284
|
state2.retryDelayMs = INITIAL_DRAIN_RETRY_MS;
|
|
@@ -254411,7 +254678,7 @@ var init_fork_conversation = __esm(() => {
|
|
|
254411
254678
|
|
|
254412
254679
|
// src/agent/subagents/sandbox.ts
|
|
254413
254680
|
import { mkdirSync as mkdirSync39 } from "node:fs";
|
|
254414
|
-
import { join as
|
|
254681
|
+
import { join as join75 } from "node:path";
|
|
254415
254682
|
function wrapSubagentLauncher(input) {
|
|
254416
254683
|
const env6 = input.env ?? process.env;
|
|
254417
254684
|
if (!isFsSandboxEnabled(env6))
|
|
@@ -254454,7 +254721,7 @@ function wrapSubagentLauncher(input) {
|
|
|
254454
254721
|
if (!wrapped || wrapped.length === 0)
|
|
254455
254722
|
return null;
|
|
254456
254723
|
const [command, ...args] = wrapped;
|
|
254457
|
-
const scratchRoot =
|
|
254724
|
+
const scratchRoot = join75(getLettaHomeRoot(), "tmp");
|
|
254458
254725
|
mkdirSync39(scratchRoot, { recursive: true });
|
|
254459
254726
|
return {
|
|
254460
254727
|
command,
|
|
@@ -255299,7 +255566,7 @@ async function fetchParentConversationMessages(params) {
|
|
|
255299
255566
|
}
|
|
255300
255567
|
return messages.reverse();
|
|
255301
255568
|
}
|
|
255302
|
-
function
|
|
255569
|
+
function contentText2(content) {
|
|
255303
255570
|
if (typeof content === "string")
|
|
255304
255571
|
return content;
|
|
255305
255572
|
if (!Array.isArray(content))
|
|
@@ -255325,7 +255592,7 @@ function renderToolCall(call) {
|
|
|
255325
255592
|
}
|
|
255326
255593
|
function renderToolResult(result3) {
|
|
255327
255594
|
const raw2 = result3.tool_return ?? result3.func_response;
|
|
255328
|
-
const text2 = typeof raw2 === "string" ? raw2 :
|
|
255595
|
+
const text2 = typeof raw2 === "string" ? raw2 : contentText2(raw2) || (raw2 == null ? "" : JSON.stringify(raw2));
|
|
255329
255596
|
return {
|
|
255330
255597
|
type: "tool_result",
|
|
255331
255598
|
call_id: result3.tool_call_id ?? undefined,
|
|
@@ -255361,11 +255628,11 @@ function userEvents(text2, speaker) {
|
|
|
255361
255628
|
function renderMessage(message2) {
|
|
255362
255629
|
switch (message2.message_type) {
|
|
255363
255630
|
case "user_message": {
|
|
255364
|
-
const text2 = stripNonScheduledSystemReminders(
|
|
255631
|
+
const text2 = stripNonScheduledSystemReminders(contentText2(message2.content)).trim();
|
|
255365
255632
|
return userEvents(text2, message2.name ?? undefined);
|
|
255366
255633
|
}
|
|
255367
255634
|
case "assistant_message": {
|
|
255368
|
-
const text2 =
|
|
255635
|
+
const text2 = contentText2(message2.content).trim();
|
|
255369
255636
|
return text2 ? [
|
|
255370
255637
|
{
|
|
255371
255638
|
type: "message",
|
|
@@ -255570,8 +255837,8 @@ var FORK_PROMPT_CHARACTER_LIMIT = 2000;
|
|
|
255570
255837
|
// src/agent/memory-conflict-repair.ts
|
|
255571
255838
|
import { execFile as execFile15 } from "node:child_process";
|
|
255572
255839
|
import { randomUUID as randomUUID45 } from "node:crypto";
|
|
255573
|
-
import { readFile as readFile18, rm as
|
|
255574
|
-
import { join as
|
|
255840
|
+
import { readFile as readFile18, rm as rm11, writeFile as writeFile13 } from "node:fs/promises";
|
|
255841
|
+
import { join as join76 } from "node:path";
|
|
255575
255842
|
import { promisify as promisify15 } from "node:util";
|
|
255576
255843
|
async function readOptional(path30) {
|
|
255577
255844
|
try {
|
|
@@ -255592,7 +255859,7 @@ async function describeMemoryConflict(memoryDir, gitDir) {
|
|
|
255592
255859
|
]);
|
|
255593
255860
|
head4 = stdout.trim();
|
|
255594
255861
|
} catch {}
|
|
255595
|
-
const heads = await Promise.all(OPERATION_HEADS.map((name) => readOptional(
|
|
255862
|
+
const heads = await Promise.all(OPERATION_HEADS.map((name) => readOptional(join76(gitDir, name))));
|
|
255596
255863
|
return [head4, ...heads].join(`
|
|
255597
255864
|
`);
|
|
255598
255865
|
}
|
|
@@ -255612,7 +255879,7 @@ ${stdout.trim()}`;
|
|
|
255612
255879
|
}
|
|
255613
255880
|
}
|
|
255614
255881
|
async function attemptPath(memoryDir) {
|
|
255615
|
-
return
|
|
255882
|
+
return join76(await getMemoryGitDir(memoryDir), ATTEMPT_FILE);
|
|
255616
255883
|
}
|
|
255617
255884
|
async function readAttempt(path30) {
|
|
255618
255885
|
try {
|
|
@@ -255646,7 +255913,7 @@ async function claimMemoryConflictRepair(memoryDir, kind = "conflict") {
|
|
|
255646
255913
|
let signature;
|
|
255647
255914
|
try {
|
|
255648
255915
|
const gitDir = await getMemoryGitDir(memoryDir);
|
|
255649
|
-
path30 =
|
|
255916
|
+
path30 = join76(gitDir, ATTEMPT_FILE);
|
|
255650
255917
|
signature = kind === "invalid" ? await describeInvalidMemoryHistory(memoryDir) : await describeMemoryConflict(memoryDir, gitDir);
|
|
255651
255918
|
} catch {
|
|
255652
255919
|
return { status: "claimed", token: token2 };
|
|
@@ -255687,7 +255954,7 @@ async function completeMemoryConflictRepair(memoryDir, token2) {
|
|
|
255687
255954
|
async function clearMemoryConflictRepair(memoryDir, token2) {
|
|
255688
255955
|
await transition(memoryDir, async (path30, attempt2) => {
|
|
255689
255956
|
if (attempt2.token === token2)
|
|
255690
|
-
await
|
|
255957
|
+
await rm11(path30, { force: true });
|
|
255691
255958
|
});
|
|
255692
255959
|
}
|
|
255693
255960
|
var ATTEMPT_FILE = "letta-memory-repair.json", OPERATION_HEADS, MARKER_LOCK, CLAIM_TIMEOUT_MS = 5000;
|
|
@@ -255707,15 +255974,15 @@ var init_memory_conflict_repair = __esm(() => {
|
|
|
255707
255974
|
|
|
255708
255975
|
// src/agent/subagents/memory-handoff.ts
|
|
255709
255976
|
import { randomUUID as randomUUID46 } from "node:crypto";
|
|
255710
|
-
import { mkdir as mkdir12, rm as
|
|
255711
|
-
import { join as
|
|
255977
|
+
import { mkdir as mkdir12, rm as rm12, writeFile as writeFile14 } from "node:fs/promises";
|
|
255978
|
+
import { join as join77 } from "node:path";
|
|
255712
255979
|
async function withMemoryHandoff(params, run) {
|
|
255713
255980
|
const handoff = await prepareMemoryHandoff(params);
|
|
255714
255981
|
try {
|
|
255715
255982
|
return await run(handoff);
|
|
255716
255983
|
} finally {
|
|
255717
255984
|
if (handoff.transcriptPath)
|
|
255718
|
-
await
|
|
255985
|
+
await rm12(handoff.transcriptPath, { force: true });
|
|
255719
255986
|
}
|
|
255720
255987
|
}
|
|
255721
255988
|
async function prepareMemoryHandoff(params) {
|
|
@@ -255743,9 +256010,9 @@ async function prepareMemoryHandoff(params) {
|
|
|
255743
256010
|
break;
|
|
255744
256011
|
after2 = cursor;
|
|
255745
256012
|
}
|
|
255746
|
-
const directory =
|
|
256013
|
+
const directory = join77(getTranscriptRoot(), params.agentId, "memory-handoffs");
|
|
255747
256014
|
await mkdir12(directory, { recursive: true, mode: 448 });
|
|
255748
|
-
transcriptPath =
|
|
256015
|
+
transcriptPath = join77(directory, `${randomUUID46()}.json`);
|
|
255749
256016
|
await writeFile14(transcriptPath, JSON.stringify(messages, null, 2), {
|
|
255750
256017
|
mode: 292,
|
|
255751
256018
|
flag: "wx"
|
|
@@ -258279,7 +258546,7 @@ async function send_agent_message(args, deps = {}) {
|
|
|
258279
258546
|
content: JSON.stringify({
|
|
258280
258547
|
status: "accepted",
|
|
258281
258548
|
agent_id: args.agent_id,
|
|
258282
|
-
delivery: externalTarget.type === "antigravity" ? "queued" : externalTarget.type === "cursor" ? "run/steer" : "session/abort+prompt"
|
|
258549
|
+
delivery: externalTarget.type === "antigravity" ? "queued" in receipt3 && receipt3.queued ? "queued" : "session/prompt" : externalTarget.type === "cursor" ? "run/steer" : "session/abort+prompt"
|
|
258283
258550
|
}),
|
|
258284
258551
|
status: "success"
|
|
258285
258552
|
};
|
|
@@ -258692,7 +258959,7 @@ __export(exports_skill, {
|
|
|
258692
258959
|
});
|
|
258693
258960
|
import { existsSync as existsSync48, readdirSync as readdirSync19 } from "node:fs";
|
|
258694
258961
|
import { readFile as readFile19 } from "node:fs/promises";
|
|
258695
|
-
import { dirname as dirname31, join as
|
|
258962
|
+
import { dirname as dirname31, join as join78 } from "node:path";
|
|
258696
258963
|
async function readSkillFromRoot(skillsRoot, skillId) {
|
|
258697
258964
|
const discovery = await discoverSkills(skillsRoot, undefined, {
|
|
258698
258965
|
sources: ["project"],
|
|
@@ -258713,11 +258980,11 @@ function getMemorySkillsDirs2(agentId) {
|
|
|
258713
258980
|
const dirs = new Set;
|
|
258714
258981
|
const scopedMemoryDir = resolveScopedMemoryDir({ agentId });
|
|
258715
258982
|
if (scopedMemoryDir && scopedMemoryDir.trim().length > 0 && existsSync48(scopedMemoryDir)) {
|
|
258716
|
-
dirs.add(
|
|
258983
|
+
dirs.add(join78(scopedMemoryDir.trim(), "skills"));
|
|
258717
258984
|
} else {
|
|
258718
258985
|
const fallbackMemoryDir = (process.env.LETTA_MEMORY_DIR || process.env.MEMORY_DIR || "").trim();
|
|
258719
258986
|
if (fallbackMemoryDir) {
|
|
258720
|
-
dirs.add(
|
|
258987
|
+
dirs.add(join78(fallbackMemoryDir, "skills"));
|
|
258721
258988
|
}
|
|
258722
258989
|
}
|
|
258723
258990
|
return Array.from(dirs);
|
|
@@ -258743,7 +259010,7 @@ function listSkillResources(skillMdPath) {
|
|
|
258743
259010
|
return;
|
|
258744
259011
|
}
|
|
258745
259012
|
if (entry.isDirectory()) {
|
|
258746
|
-
walk3(
|
|
259013
|
+
walk3(join78(directory, entry.name), relativePath);
|
|
258747
259014
|
if (truncated2) {
|
|
258748
259015
|
return;
|
|
258749
259016
|
}
|
|
@@ -258757,7 +259024,7 @@ function listSkillResources(skillMdPath) {
|
|
|
258757
259024
|
}
|
|
258758
259025
|
async function readSkillContent(skillId, skillsDir, agentId, options = {}) {
|
|
258759
259026
|
const projectSkillsDirs = new Set([
|
|
258760
|
-
|
|
259027
|
+
join78(getCurrentWorkingDirectory(), PROJECT_SKILLS_DIR),
|
|
258761
259028
|
skillsDir,
|
|
258762
259029
|
...getSkillSources().includes("project") ? getCloudProjectSkillDirectories().reverse() : []
|
|
258763
259030
|
]);
|
|
@@ -258806,8 +259073,8 @@ async function readSkillContent(skillId, skillsDir, agentId, options = {}) {
|
|
|
258806
259073
|
} catch {}
|
|
258807
259074
|
}
|
|
258808
259075
|
try {
|
|
258809
|
-
const bundledSkillsDir =
|
|
258810
|
-
const bundledSkillPath =
|
|
259076
|
+
const bundledSkillsDir = join78(process.cwd(), "skills", "skills");
|
|
259077
|
+
const bundledSkillPath = join78(bundledSkillsDir, skillId, "SKILL.md");
|
|
258811
259078
|
const content = await readFile19(bundledSkillPath, "utf-8");
|
|
258812
259079
|
return { content, path: bundledSkillPath };
|
|
258813
259080
|
} catch {
|
|
@@ -258819,7 +259086,7 @@ async function getResolvedSkillsDir() {
|
|
|
258819
259086
|
if (skillsDir) {
|
|
258820
259087
|
return skillsDir;
|
|
258821
259088
|
}
|
|
258822
|
-
return
|
|
259089
|
+
return join78(getCurrentWorkingDirectory(), SKILLS_DIR);
|
|
258823
259090
|
}
|
|
258824
259091
|
function getResolvedAgentId(args) {
|
|
258825
259092
|
if (args.parentScope?.agentId) {
|
|
@@ -260511,7 +260778,7 @@ import {
|
|
|
260511
260778
|
rmSync as rmSync19,
|
|
260512
260779
|
writeFileSync as writeFileSync34
|
|
260513
260780
|
} from "node:fs";
|
|
260514
|
-
import { dirname as dirname32, join as
|
|
260781
|
+
import { dirname as dirname32, join as join79 } from "node:path";
|
|
260515
260782
|
import { setTimeout as delay7 } from "node:timers/promises";
|
|
260516
260783
|
function errorText(error4) {
|
|
260517
260784
|
const message2 = error4 instanceof Error ? error4.message : String(error4);
|
|
@@ -260629,7 +260896,7 @@ async function watch_pr(args, deps = {}) {
|
|
|
260629
260896
|
const scope = resolveNotificationScope(parentScope);
|
|
260630
260897
|
let snapshotPath;
|
|
260631
260898
|
try {
|
|
260632
|
-
snapshotPath = scope && !isRun ?
|
|
260899
|
+
snapshotPath = scope && !isRun ? join79(resolveGlobalConfigDir(), "cache", "watch-pr", `${createHash13("sha256").update(JSON.stringify([
|
|
260633
260900
|
scope.agentId,
|
|
260634
260901
|
scope.conversationId,
|
|
260635
260902
|
ref.owner.toLowerCase(),
|
|
@@ -260909,7 +261176,7 @@ var init_watch_pr = __esm(() => {
|
|
|
260909
261176
|
// src/tools/workflow/sdk-loader.ts
|
|
260910
261177
|
import { existsSync as existsSync49, readFileSync as readFileSync43 } from "node:fs";
|
|
260911
261178
|
import { createRequire as createRequire6 } from "node:module";
|
|
260912
|
-
import { dirname as dirname33, join as
|
|
261179
|
+
import { dirname as dirname33, join as join80 } from "node:path";
|
|
260913
261180
|
import { fileURLToPath as fileURLToPath8, pathToFileURL as pathToFileURL3 } from "node:url";
|
|
260914
261181
|
function supportsPublishedResume(version3) {
|
|
260915
261182
|
if (!version3 || !MIN_RESUME_SDK_VERSION)
|
|
@@ -260938,7 +261205,7 @@ function preferRunningCliForSubagents() {
|
|
|
260938
261205
|
function packageVersion(entry) {
|
|
260939
261206
|
for (let dir = dirname33(entry);; dir = dirname33(dir)) {
|
|
260940
261207
|
try {
|
|
260941
|
-
const manifest = JSON.parse(readFileSync43(
|
|
261208
|
+
const manifest = JSON.parse(readFileSync43(join80(dir, "package.json"), "utf8"));
|
|
260942
261209
|
if (manifest.name === SDK_PACKAGE)
|
|
260943
261210
|
return manifest.version;
|
|
260944
261211
|
} catch {}
|
|
@@ -260948,10 +261215,10 @@ function packageVersion(entry) {
|
|
|
260948
261215
|
}
|
|
260949
261216
|
function packageEntry(packageDir) {
|
|
260950
261217
|
try {
|
|
260951
|
-
const manifest = JSON.parse(readFileSync43(
|
|
261218
|
+
const manifest = JSON.parse(readFileSync43(join80(packageDir, "package.json"), "utf8"));
|
|
260952
261219
|
const root2 = manifest.exports?.["."];
|
|
260953
261220
|
const entry = typeof root2 === "string" ? root2 : root2?.import ?? root2?.default ?? manifest.main;
|
|
260954
|
-
return entry ?
|
|
261221
|
+
return entry ? join80(packageDir, entry) : null;
|
|
260955
261222
|
} catch {
|
|
260956
261223
|
return null;
|
|
260957
261224
|
}
|
|
@@ -260961,8 +261228,8 @@ function probeInstalledSdkDirs(startDirs) {
|
|
|
260961
261228
|
for (const start2 of startDirs) {
|
|
260962
261229
|
let dir = start2;
|
|
260963
261230
|
while (true) {
|
|
260964
|
-
const candidate =
|
|
260965
|
-
if (existsSync49(
|
|
261231
|
+
const candidate = join80(dir, "node_modules", ...SDK_PACKAGE.split("/"));
|
|
261232
|
+
if (existsSync49(join80(candidate, "package.json")) && !found.includes(candidate)) {
|
|
260966
261233
|
found.push(candidate);
|
|
260967
261234
|
}
|
|
260968
261235
|
const parent = dirname33(dir);
|
|
@@ -260980,7 +261247,7 @@ async function loadAgentSdk() {
|
|
|
260980
261247
|
const specifiers = [];
|
|
260981
261248
|
if (envPath) {
|
|
260982
261249
|
try {
|
|
260983
|
-
const require2 = createRequire6(
|
|
261250
|
+
const require2 = createRequire6(join80(envPath, "noop.js"));
|
|
260984
261251
|
specifiers.push(pathToFileURL3(require2.resolve(envPath)).href);
|
|
260985
261252
|
} catch {
|
|
260986
261253
|
specifiers.push(pathToFileURL3(envPath).href);
|
|
@@ -260991,7 +261258,7 @@ async function loadAgentSdk() {
|
|
|
260991
261258
|
specifiers.push(pathToFileURL3(require2.resolve(SDK_PACKAGE)).href);
|
|
260992
261259
|
} catch {}
|
|
260993
261260
|
try {
|
|
260994
|
-
const require2 = createRequire6(
|
|
261261
|
+
const require2 = createRequire6(join80(process.cwd(), "package.json"));
|
|
260995
261262
|
specifiers.push(pathToFileURL3(require2.resolve(SDK_PACKAGE)).href);
|
|
260996
261263
|
} catch {
|
|
260997
261264
|
specifiers.push(SDK_PACKAGE);
|
|
@@ -261541,7 +261808,7 @@ var init_sdk_spawner = __esm(() => {
|
|
|
261541
261808
|
|
|
261542
261809
|
// src/tools/impl/workflow.ts
|
|
261543
261810
|
import { readFileSync as readFileSync44 } from "node:fs";
|
|
261544
|
-
import { join as
|
|
261811
|
+
import { join as join81, resolve as resolve36 } from "node:path";
|
|
261545
261812
|
async function createSdkSpawnerHandle(args, setStage = () => {}) {
|
|
261546
261813
|
setStage("resolving parent agent");
|
|
261547
261814
|
const parentAgentId = await resolveScriptParentAgentId(args);
|
|
@@ -261693,7 +261960,7 @@ function formatCompletionResult(run, executionDir) {
|
|
|
261693
261960
|
return [
|
|
261694
261961
|
payload,
|
|
261695
261962
|
"",
|
|
261696
|
-
`Per-call results: ${
|
|
261963
|
+
`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
261964
|
"If the result above is empty or unexpected, read that file BEFORE diagnosing — do not assume agents returned non-empty results."
|
|
261698
261965
|
].join(`
|
|
261699
261966
|
`);
|
|
@@ -263476,7 +263743,7 @@ var init_interrupted_turn_schema = __esm(() => {
|
|
|
263476
263743
|
// src/websocket/listener/interrupted-turn-storage.ts
|
|
263477
263744
|
import { createHash as createHash14 } from "node:crypto";
|
|
263478
263745
|
import { closeSync as closeSync10, fsyncSync as fsyncSync4, openSync as openSync10, writeFileSync as writeFileSync35 } from "node:fs";
|
|
263479
|
-
import { join as
|
|
263746
|
+
import { join as join82 } from "node:path";
|
|
263480
263747
|
function writeInterruptedTurnRecordFile(temporary, destination, directory, record5, syncDirectory) {
|
|
263481
263748
|
writeFileSync35(temporary, JSON.stringify(record5), {
|
|
263482
263749
|
mode: 384,
|
|
@@ -263502,7 +263769,7 @@ function defaultInterruptedTurnDirectory() {
|
|
|
263502
263769
|
} catch {
|
|
263503
263770
|
serverUrl = process.env.LETTA_BASE_URL ?? "uninitialized";
|
|
263504
263771
|
}
|
|
263505
|
-
return
|
|
263772
|
+
return join82(resolveGlobalConfigDir(), "listener-state", createHash14("sha256").update(serverUrl).digest("hex").slice(0, 24));
|
|
263506
263773
|
}
|
|
263507
263774
|
var init_interrupted_turn_storage = __esm(() => {
|
|
263508
263775
|
init_server_url();
|
|
@@ -263524,7 +263791,7 @@ function recordedToolResults(record5, pendingToolCallIds) {
|
|
|
263524
263791
|
type: "approval",
|
|
263525
263792
|
tool_call_id: id,
|
|
263526
263793
|
approve: false,
|
|
263527
|
-
reason: STALE_APPROVAL_RECOVERY_DENIAL_REASON
|
|
263794
|
+
reason: record5.toolCallIds.includes(id) && record5.unstartedToolCallIds?.includes(id) === false ? STARTED_TOOL_CALL_RECOVERY_DENIAL_REASON : STALE_APPROVAL_RECOVERY_DENIAL_REASON
|
|
263528
263795
|
});
|
|
263529
263796
|
}
|
|
263530
263797
|
var init_recorded_tool_results = __esm(() => {
|
|
@@ -263581,14 +263848,14 @@ import {
|
|
|
263581
263848
|
statSync as statSync21,
|
|
263582
263849
|
writeFileSync as writeFileSync36
|
|
263583
263850
|
} from "node:fs";
|
|
263584
|
-
import { join as
|
|
263851
|
+
import { join as join83 } from "node:path";
|
|
263585
263852
|
function createRecoveryLineageSidecarAccess(params) {
|
|
263586
263853
|
const canonicalSidecarName = /\.json\.recovery-[0-9a-f]{24}$/;
|
|
263587
263854
|
const temporarySidecarName = /^(.+\.json)\.recovery-[0-9a-f]{24}\.(\d+)\.([0-9a-f-]{36})\.[0-9a-f-]{36}\.tmp$/;
|
|
263588
263855
|
const legacyTemporarySidecarName = /^(.+\.json)\.recovery-[0-9a-f]{24}\.(\d+)\.[0-9a-f-]{36}\.tmp$/;
|
|
263589
263856
|
const staleTemporaryAgeMs = 60000;
|
|
263590
263857
|
const maximumTemporaryAgeMs = 24 * 60 * 60 * 1000;
|
|
263591
|
-
const path33 = (agentId, conversationId, lineageId) =>
|
|
263858
|
+
const path33 = (agentId, conversationId, lineageId) => join83(params.directory, `${encodeURIComponent(agentId)}_${encodeURIComponent(conversationId)}.json.recovery-${createHash15("sha256").update(lineageId).digest("hex").slice(0, 24)}`);
|
|
263592
263859
|
const isSidecar = (value) => {
|
|
263593
263860
|
if (!value || typeof value !== "object")
|
|
263594
263861
|
return false;
|
|
@@ -263867,10 +264134,10 @@ function createRecoveryLineageSidecarAccess(params) {
|
|
|
263867
264134
|
const removeMalformedOrphan = (file) => {
|
|
263868
264135
|
const separator = file.indexOf(".recovery-");
|
|
263869
264136
|
const mainFile = separator >= 0 ? file.slice(0, separator) : "";
|
|
263870
|
-
if (!mainFile || existsSync50(
|
|
264137
|
+
if (!mainFile || existsSync50(join83(params.directory, mainFile)))
|
|
263871
264138
|
return;
|
|
263872
264139
|
try {
|
|
263873
|
-
rmSync20(
|
|
264140
|
+
rmSync20(join83(params.directory, file), { force: true });
|
|
263874
264141
|
params.syncDirectory(params.directory);
|
|
263875
264142
|
} catch {}
|
|
263876
264143
|
};
|
|
@@ -263897,13 +264164,13 @@ function createRecoveryLineageSidecarAccess(params) {
|
|
|
263897
264164
|
ownerIsAlive = error4.code !== "ESRCH";
|
|
263898
264165
|
}
|
|
263899
264166
|
}
|
|
263900
|
-
const ageMs = Date.now() - statSync21(
|
|
264167
|
+
const ageMs = Date.now() - statSync21(join83(params.directory, file)).mtimeMs;
|
|
263901
264168
|
if (!ownerIsCurrentWriter && (!ownerIsAlive && ageMs >= staleTemporaryAgeMs || ageMs >= maximumTemporaryAgeMs)) {
|
|
263902
|
-
const release = acquireDurableFileLock(
|
|
264169
|
+
const release = acquireDurableFileLock(join83(params.directory, mainFile), { waitMs: params.lockWaitMs });
|
|
263903
264170
|
try {
|
|
263904
|
-
const currentAgeMs = Date.now() - statSync21(
|
|
264171
|
+
const currentAgeMs = Date.now() - statSync21(join83(params.directory, file)).mtimeMs;
|
|
263905
264172
|
if (!ownerIsCurrentWriter && (!ownerIsAlive && currentAgeMs >= staleTemporaryAgeMs || currentAgeMs >= maximumTemporaryAgeMs)) {
|
|
263906
|
-
rmSync20(
|
|
264173
|
+
rmSync20(join83(params.directory, file), { force: true });
|
|
263907
264174
|
params.syncDirectory(params.directory);
|
|
263908
264175
|
}
|
|
263909
264176
|
} finally {
|
|
@@ -263914,8 +264181,8 @@ function createRecoveryLineageSidecarAccess(params) {
|
|
|
263914
264181
|
}
|
|
263915
264182
|
return files.filter((file) => canonicalSidecarName.test(file)).flatMap((file) => {
|
|
263916
264183
|
try {
|
|
263917
|
-
const value = JSON.parse(readFileSync45(
|
|
263918
|
-
if (isSidecar(value) &&
|
|
264184
|
+
const value = JSON.parse(readFileSync45(join83(params.directory, file), "utf8"));
|
|
264185
|
+
if (isSidecar(value) && join83(params.directory, file) === path33(value.agentId, value.conversationId, value.lineageId)) {
|
|
263919
264186
|
return [value];
|
|
263920
264187
|
}
|
|
263921
264188
|
removeMalformedOrphan(file);
|
|
@@ -263965,7 +264232,7 @@ import {
|
|
|
263965
264232
|
unlinkSync as unlinkSync14,
|
|
263966
264233
|
writeFileSync as writeFileSync37
|
|
263967
264234
|
} from "node:fs";
|
|
263968
|
-
import { join as
|
|
264235
|
+
import { join as join84 } from "node:path";
|
|
263969
264236
|
function createInterruptedTurnStore(directory = defaultInterruptedTurnDirectory(), dependencies = {}) {
|
|
263970
264237
|
const sync = dependencies.fsyncDirectory ?? fsyncInterruptedTurnDirectory;
|
|
263971
264238
|
function persist(destination, record5) {
|
|
@@ -263977,7 +264244,7 @@ function createInterruptedTurnStore(directory = defaultInterruptedTurnDirectory(
|
|
|
263977
264244
|
}
|
|
263978
264245
|
}
|
|
263979
264246
|
function path33(agentId, conversationId) {
|
|
263980
|
-
return
|
|
264247
|
+
return join84(directory, `${encodeURIComponent(agentId)}_${encodeURIComponent(conversationId)}.json`);
|
|
263981
264248
|
}
|
|
263982
264249
|
function readRecordOrThrow(file) {
|
|
263983
264250
|
try {
|
|
@@ -264990,6 +265257,9 @@ __export(exports_runtime, {
|
|
|
264990
265257
|
setActiveRuntime: () => setActiveRuntime,
|
|
264991
265258
|
safeEmitWsEvent: () => safeEmitWsEvent,
|
|
264992
265259
|
nextEventSeq: () => nextEventSeq,
|
|
265260
|
+
markSidebandOnlyScope: () => markSidebandOnlyScope,
|
|
265261
|
+
markLocalTurnScope: () => markLocalTurnScope,
|
|
265262
|
+
isSidebandOnlyScope: () => isSidebandOnlyScope,
|
|
264993
265263
|
invalidateExternalToolNotifications: () => invalidateExternalToolNotifications,
|
|
264994
265264
|
hasInterruptedCacheForScope: () => hasInterruptedCacheForScope,
|
|
264995
265265
|
getRuntimeAuthorityEpoch: () => getRuntimeAuthorityEpoch,
|
|
@@ -265147,6 +265417,20 @@ function getConversationRuntimeKey(agentId, conversationId) {
|
|
|
265147
265417
|
const normalizedAgentId = normalizeCwdAgentId(agentId);
|
|
265148
265418
|
return `agent:${normalizedAgentId ?? "__unknown__"}::conversation:${normalizedConversationId}`;
|
|
265149
265419
|
}
|
|
265420
|
+
function isSidebandOnlyScope(listener, key4) {
|
|
265421
|
+
return sidebandScopesByListener.get(listener)?.has(key4) ?? false;
|
|
265422
|
+
}
|
|
265423
|
+
function markSidebandOnlyScope(listener, key4) {
|
|
265424
|
+
let scopes = sidebandScopesByListener.get(listener);
|
|
265425
|
+
if (!scopes) {
|
|
265426
|
+
scopes = new Set;
|
|
265427
|
+
sidebandScopesByListener.set(listener, scopes);
|
|
265428
|
+
}
|
|
265429
|
+
scopes.add(key4);
|
|
265430
|
+
}
|
|
265431
|
+
function markLocalTurnScope(runtime) {
|
|
265432
|
+
sidebandScopesByListener.get(runtime.listener)?.delete(runtime.key);
|
|
265433
|
+
}
|
|
265150
265434
|
function createConversationRuntime(listener, agentId, conversationId) {
|
|
265151
265435
|
const normalizedAgentId = normalizeCwdAgentId(agentId);
|
|
265152
265436
|
const normalizedConversationId = normalizeConversationId(conversationId);
|
|
@@ -265329,7 +265613,7 @@ function hasInterruptedCacheForScope(runtime, params) {
|
|
|
265329
265613
|
function getPendingControlRequestCount(runtime, params) {
|
|
265330
265614
|
return getPendingControlRequests(runtime, params).length;
|
|
265331
265615
|
}
|
|
265332
|
-
var activeRuntime = null, activeRuntimeAuthorityEpoch = 0, authorityEpochByRuntime, WORKTREE_WATCHER_IDLE_STOP_MS, watcherIdleStopsByListener, __watcherIdleStopTestUtils;
|
|
265616
|
+
var activeRuntime = null, activeRuntimeAuthorityEpoch = 0, authorityEpochByRuntime, WORKTREE_WATCHER_IDLE_STOP_MS, watcherIdleStopsByListener, __watcherIdleStopTestUtils, sidebandScopesByListener;
|
|
265333
265617
|
var init_runtime6 = __esm(() => {
|
|
265334
265618
|
init_ws_event_redaction();
|
|
265335
265619
|
init_background_process_snapshot();
|
|
@@ -265354,6 +265638,7 @@ var init_runtime6 = __esm(() => {
|
|
|
265354
265638
|
return watcherIdleStopsByListener.get(listener)?.has(scopeKey2) ?? false;
|
|
265355
265639
|
}
|
|
265356
265640
|
};
|
|
265641
|
+
sidebandScopesByListener = new WeakMap;
|
|
265357
265642
|
});
|
|
265358
265643
|
|
|
265359
265644
|
// src/websocket/listener/startup-frame-buffer.ts
|
|
@@ -266399,10 +266684,10 @@ var init_input_disposition_expiry = __esm(() => {
|
|
|
266399
266684
|
|
|
266400
266685
|
// src/websocket/listener/input-disposition-path.ts
|
|
266401
266686
|
import { createHash as createHash16 } from "node:crypto";
|
|
266402
|
-
import { join as
|
|
266687
|
+
import { join as join85 } from "node:path";
|
|
266403
266688
|
function inputDispositionPersistentPath(serverUrl) {
|
|
266404
266689
|
const namespace = createHash16("sha256").update(serverUrl).digest("hex").slice(0, 24);
|
|
266405
|
-
return
|
|
266690
|
+
return join85(resolveGlobalConfigDir(), "state", namespace, "input-dispositions-v2.json");
|
|
266406
266691
|
}
|
|
266407
266692
|
var init_input_disposition_path = __esm(() => {
|
|
266408
266693
|
init_settings_path();
|
|
@@ -267034,7 +267319,7 @@ import {
|
|
|
267034
267319
|
rmSync as rmSync22,
|
|
267035
267320
|
writeFileSync as writeFileSync39
|
|
267036
267321
|
} from "node:fs";
|
|
267037
|
-
import { join as
|
|
267322
|
+
import { join as join86 } from "node:path";
|
|
267038
267323
|
function terminalAuthorityStatus(runtime, terminal, terminals, interruptedStore = createInterruptedTurnStore()) {
|
|
267039
267324
|
const { owner } = terminal;
|
|
267040
267325
|
if (!owner.recoveryLineageId)
|
|
@@ -267091,7 +267376,7 @@ function defaultTurnFinishedDirectory() {
|
|
|
267091
267376
|
} catch {
|
|
267092
267377
|
serverUrl = process.env.LETTA_BASE_URL ?? "uninitialized";
|
|
267093
267378
|
}
|
|
267094
|
-
return
|
|
267379
|
+
return join86(resolveGlobalConfigDir(), "listener-terminal-state", Buffer.from(serverUrl).toString("base64url"));
|
|
267095
267380
|
}
|
|
267096
267381
|
function encodeTurnFinishedScope(agentId, conversationId) {
|
|
267097
267382
|
return Buffer.from(JSON.stringify([agentId, conversationId])).toString("base64url");
|
|
@@ -267119,7 +267404,7 @@ function fsyncDirectory2(directory) {
|
|
|
267119
267404
|
}
|
|
267120
267405
|
function createTurnFinishedStore(directory = defaultTurnFinishedDirectory(), options = {}) {
|
|
267121
267406
|
const claimantToken = randomUUID53();
|
|
267122
|
-
const path33 = (agentId, conversationId) =>
|
|
267407
|
+
const path33 = (agentId, conversationId) => join86(directory, `${encodeTurnFinishedScope(agentId, conversationId)}.json`);
|
|
267123
267408
|
const readRecord2 = (agentId, conversationId) => {
|
|
267124
267409
|
try {
|
|
267125
267410
|
const record5 = JSON.parse(readFileSync48(path33(agentId, conversationId), "utf8"));
|
|
@@ -268569,6 +268854,7 @@ var init_queue = __esm(() => {
|
|
|
268569
268854
|
init_debug();
|
|
268570
268855
|
init_connection();
|
|
268571
268856
|
init_image_policy();
|
|
268857
|
+
init_inbound_queue();
|
|
268572
268858
|
init_protocol_outbound();
|
|
268573
268859
|
init_runtime6();
|
|
268574
268860
|
init_transport2();
|
|
@@ -269158,6 +269444,7 @@ var discardQueuedItem = (runtime, item) => {
|
|
|
269158
269444
|
var init_conversation_runtime = __esm(() => {
|
|
269159
269445
|
init_queue_runtime();
|
|
269160
269446
|
init_debug();
|
|
269447
|
+
init_inbound_queue();
|
|
269161
269448
|
init_input_disposition();
|
|
269162
269449
|
init_input_disposition_retention();
|
|
269163
269450
|
init_input_terminal_journal();
|
|
@@ -269372,24 +269659,24 @@ async function fireCronTask(task2, timing2, socket, opts, processQueuedTurn, tri
|
|
|
269372
269659
|
});
|
|
269373
269660
|
return false;
|
|
269374
269661
|
}
|
|
269375
|
-
|
|
269376
|
-
if (!rawRuntime) {
|
|
269662
|
+
if (isSidebandOnlyScope(listener, getConversationRuntimeKey(task2.agent_id, targetConversationId))) {
|
|
269377
269663
|
setLastRunOutcome(task2.id, {
|
|
269378
269664
|
outcome: "failed",
|
|
269379
269665
|
reason: "runtime_unavailable",
|
|
269380
269666
|
runAt: timing2.schedulerNow,
|
|
269381
|
-
error: "Conversation
|
|
269667
|
+
error: "Conversation is only held for remote worker control"
|
|
269382
269668
|
});
|
|
269383
269669
|
safeAppendCronRunLogForTask(task2, {
|
|
269384
269670
|
status: "error",
|
|
269385
269671
|
outcome: "failed",
|
|
269386
269672
|
reason: "runtime_unavailable",
|
|
269387
|
-
error: "Conversation
|
|
269673
|
+
error: "Conversation is only held for remote worker control",
|
|
269388
269674
|
runAtMs: timing2.schedulerNow.getTime(),
|
|
269389
269675
|
scheduledFor: task2.scheduled_for
|
|
269390
269676
|
});
|
|
269391
269677
|
return false;
|
|
269392
269678
|
}
|
|
269679
|
+
const rawRuntime = getOrCreateConversationRuntime(listener, task2.agent_id, targetConversationId);
|
|
269393
269680
|
const conversationRuntime = ensureConversationQueueRuntime(listener, rawRuntime);
|
|
269394
269681
|
if (trigger === "automatic" && getTask(task2.id)?.status !== "active") {
|
|
269395
269682
|
return false;
|
|
@@ -273744,6 +274031,48 @@ var init_approval = __esm(() => {
|
|
|
273744
274031
|
init_turn_status();
|
|
273745
274032
|
});
|
|
273746
274033
|
|
|
274034
|
+
// src/tools/interactive-policy.ts
|
|
274035
|
+
var INTERACTIVE_USER_INPUT_TOOL_NAMES;
|
|
274036
|
+
var init_interactive_policy = __esm(() => {
|
|
274037
|
+
INTERACTIVE_USER_INPUT_TOOL_NAMES = [
|
|
274038
|
+
"AskUserQuestionAsync"
|
|
274039
|
+
];
|
|
274040
|
+
});
|
|
274041
|
+
|
|
274042
|
+
// src/tools/tool-policy.ts
|
|
274043
|
+
function intersectToolAllowlists(ceiling, narrower) {
|
|
274044
|
+
return narrower.filter((name) => ceiling.some((allowed) => getInternalToolName(allowed) === getInternalToolName(name)));
|
|
274045
|
+
}
|
|
274046
|
+
function resolveTurnToolSelection(turn, policy) {
|
|
274047
|
+
const base2 = turn.clientToolset?.base ?? policy?.toolset?.base;
|
|
274048
|
+
const include = turn.clientToolset?.include ?? policy?.toolset?.include;
|
|
274049
|
+
const clientToolset = base2 === undefined && include === undefined ? undefined : {
|
|
274050
|
+
...base2 !== undefined ? { base: base2 } : {},
|
|
274051
|
+
...include !== undefined ? { include: [...include] } : {}
|
|
274052
|
+
};
|
|
274053
|
+
const policyAllowlist = policy?.allowlist;
|
|
274054
|
+
const clientToolAllowlist = policyAllowlist === undefined ? turn.clientToolAllowlist : turn.clientToolAllowlist === undefined ? [...policyAllowlist] : intersectToolAllowlists(policyAllowlist, turn.clientToolAllowlist);
|
|
274055
|
+
const excludeInteractiveTools = turn.excludeInteractiveTools ?? policy?.exclude_interactive;
|
|
274056
|
+
return {
|
|
274057
|
+
...clientToolset ? { clientToolset } : {},
|
|
274058
|
+
...clientToolAllowlist !== undefined ? { clientToolAllowlist } : {},
|
|
274059
|
+
...excludeInteractiveTools !== undefined ? { excludeInteractiveTools } : {}
|
|
274060
|
+
};
|
|
274061
|
+
}
|
|
274062
|
+
function mergeClientToolsetFields(primary, fallback) {
|
|
274063
|
+
const base2 = primary?.base ?? fallback?.base;
|
|
274064
|
+
const include = primary?.include ?? fallback?.include;
|
|
274065
|
+
if (base2 === undefined && include === undefined)
|
|
274066
|
+
return;
|
|
274067
|
+
return {
|
|
274068
|
+
...base2 !== undefined ? { base: base2 } : {},
|
|
274069
|
+
...include !== undefined ? { include } : {}
|
|
274070
|
+
};
|
|
274071
|
+
}
|
|
274072
|
+
var init_tool_policy = __esm(() => {
|
|
274073
|
+
init_tool_name_mapping();
|
|
274074
|
+
});
|
|
274075
|
+
|
|
273747
274076
|
// src/websocket/listener/external-tools.ts
|
|
273748
274077
|
function createExternalToolNotificationState() {
|
|
273749
274078
|
return {
|
|
@@ -274026,6 +274355,17 @@ function resolveRuntimeToolOwner(runtime, runtimeScope, submittingConnectionId)
|
|
|
274026
274355
|
...owner.toolPolicy ? { toolPolicy: owner.toolPolicy } : {}
|
|
274027
274356
|
};
|
|
274028
274357
|
}
|
|
274358
|
+
function resolveRuntimeToolContextOptions(runtime, scope, connectionId, overrides = {}) {
|
|
274359
|
+
const owner = resolveRuntimeToolOwner(runtime, scope, connectionId);
|
|
274360
|
+
const selection = resolveTurnToolSelection(overrides, owner.toolPolicy);
|
|
274361
|
+
return {
|
|
274362
|
+
externalToolOwnerConnectionId: owner.connectionId,
|
|
274363
|
+
clientToolset: selection.clientToolset,
|
|
274364
|
+
clientToolAllowlist: selection.clientToolAllowlist,
|
|
274365
|
+
...selection.excludeInteractiveTools ? { exclude: [...INTERACTIVE_USER_INPUT_TOOL_NAMES] } : {},
|
|
274366
|
+
foregroundYieldMs: owner.toolPolicy?.foreground_yield_ms
|
|
274367
|
+
};
|
|
274368
|
+
}
|
|
274029
274369
|
function updateRuntimeExternalTools(runtime, connectionId, updates) {
|
|
274030
274370
|
for (const update2 of updates) {
|
|
274031
274371
|
for (const runtimeScope of update2.runtimes) {
|
|
@@ -274125,7 +274465,9 @@ var EXTERNAL_TOOL_CALL_TIMEOUT_MS, registeredToolsByRuntime, lastSubmittingConne
|
|
|
274125
274465
|
var init_external_tools = __esm(() => {
|
|
274126
274466
|
init_external_tool_background_eligibility();
|
|
274127
274467
|
init_foreground_yield();
|
|
274468
|
+
init_interactive_policy();
|
|
274128
274469
|
init_manager2();
|
|
274470
|
+
init_tool_policy();
|
|
274129
274471
|
init_debug();
|
|
274130
274472
|
init_connection();
|
|
274131
274473
|
init_runtime6();
|
|
@@ -277731,7 +278073,7 @@ import {
|
|
|
277731
278073
|
unlinkSync as unlinkSync16,
|
|
277732
278074
|
writeFileSync as writeFileSync40
|
|
277733
278075
|
} from "node:fs";
|
|
277734
|
-
import { join as
|
|
278076
|
+
import { join as join87 } from "node:path";
|
|
277735
278077
|
function truncateStr(value, maxLen) {
|
|
277736
278078
|
if (value === null || value === undefined)
|
|
277737
278079
|
return "";
|
|
@@ -277795,8 +278137,8 @@ class ChunkLog {
|
|
|
277795
278137
|
agentDir = null;
|
|
277796
278138
|
dirCreated = false;
|
|
277797
278139
|
init(agentId, sessionId) {
|
|
277798
|
-
this.agentDir =
|
|
277799
|
-
this.logPath =
|
|
278140
|
+
this.agentDir = join87(LOG_BASE_DIR, agentId);
|
|
278141
|
+
this.logPath = join87(this.agentDir, `${sessionId}.jsonl`);
|
|
277800
278142
|
this.buffer = [];
|
|
277801
278143
|
this.dirty = false;
|
|
277802
278144
|
this.dirCreated = false;
|
|
@@ -277857,7 +278199,7 @@ class ChunkLog {
|
|
|
277857
278199
|
const toDelete = files.slice(0, files.length - MAX_SESSION_FILES2 + 1);
|
|
277858
278200
|
for (const file of toDelete) {
|
|
277859
278201
|
try {
|
|
277860
|
-
unlinkSync16(
|
|
278202
|
+
unlinkSync16(join87(this.agentDir, file));
|
|
277861
278203
|
} catch (e2) {
|
|
277862
278204
|
debugWarn("chunkLog", `Failed to delete old session log ${file}: ${e2 instanceof Error ? e2.message : String(e2)}`);
|
|
277863
278205
|
}
|
|
@@ -277872,7 +278214,7 @@ var MAX_ENTRIES = 100, CONTENT_TRUNCATE_LEN = 200, MAX_SESSION_FILES2 = 5, LOG_B
|
|
|
277872
278214
|
var init_chunk_log = __esm(() => {
|
|
277873
278215
|
init_debug();
|
|
277874
278216
|
init_settings_path();
|
|
277875
|
-
LOG_BASE_DIR =
|
|
278217
|
+
LOG_BASE_DIR = join87(resolveGlobalConfigDir(), "logs", "chunk-logs");
|
|
277876
278218
|
chunkLog = new ChunkLog;
|
|
277877
278219
|
});
|
|
277878
278220
|
|
|
@@ -278801,40 +279143,6 @@ var init_stream2 = __esm(() => {
|
|
|
278801
279143
|
init_stream_terminal_eof_guard();
|
|
278802
279144
|
});
|
|
278803
279145
|
|
|
278804
|
-
// src/tools/tool-policy.ts
|
|
278805
|
-
function intersectToolAllowlists(ceiling, narrower) {
|
|
278806
|
-
return narrower.filter((name) => ceiling.some((allowed) => getInternalToolName(allowed) === getInternalToolName(name)));
|
|
278807
|
-
}
|
|
278808
|
-
function resolveTurnToolSelection(turn, policy) {
|
|
278809
|
-
const base2 = turn.clientToolset?.base ?? policy?.toolset?.base;
|
|
278810
|
-
const include = turn.clientToolset?.include ?? policy?.toolset?.include;
|
|
278811
|
-
const clientToolset = base2 === undefined && include === undefined ? undefined : {
|
|
278812
|
-
...base2 !== undefined ? { base: base2 } : {},
|
|
278813
|
-
...include !== undefined ? { include: [...include] } : {}
|
|
278814
|
-
};
|
|
278815
|
-
const policyAllowlist = policy?.allowlist;
|
|
278816
|
-
const clientToolAllowlist = policyAllowlist === undefined ? turn.clientToolAllowlist : turn.clientToolAllowlist === undefined ? [...policyAllowlist] : intersectToolAllowlists(policyAllowlist, turn.clientToolAllowlist);
|
|
278817
|
-
const excludeInteractiveTools = turn.excludeInteractiveTools ?? policy?.exclude_interactive;
|
|
278818
|
-
return {
|
|
278819
|
-
...clientToolset ? { clientToolset } : {},
|
|
278820
|
-
...clientToolAllowlist !== undefined ? { clientToolAllowlist } : {},
|
|
278821
|
-
...excludeInteractiveTools !== undefined ? { excludeInteractiveTools } : {}
|
|
278822
|
-
};
|
|
278823
|
-
}
|
|
278824
|
-
function mergeClientToolsetFields(primary, fallback) {
|
|
278825
|
-
const base2 = primary?.base ?? fallback?.base;
|
|
278826
|
-
const include = primary?.include ?? fallback?.include;
|
|
278827
|
-
if (base2 === undefined && include === undefined)
|
|
278828
|
-
return;
|
|
278829
|
-
return {
|
|
278830
|
-
...base2 !== undefined ? { base: base2 } : {},
|
|
278831
|
-
...include !== undefined ? { include } : {}
|
|
278832
|
-
};
|
|
278833
|
-
}
|
|
278834
|
-
var init_tool_policy = __esm(() => {
|
|
278835
|
-
init_tool_name_mapping();
|
|
278836
|
-
});
|
|
278837
|
-
|
|
278838
279146
|
// src/tools/toolset.ts
|
|
278839
279147
|
var exports_toolset = {};
|
|
278840
279148
|
__export(exports_toolset, {
|
|
@@ -450587,8 +450895,8 @@ var init_mod_adapter = __esm(() => {
|
|
|
450587
450895
|
|
|
450588
450896
|
// src/websocket/listener/memfs-sync.ts
|
|
450589
450897
|
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
|
|
450898
|
+
import { lstat as lstat2, realpath as realpath6, rm as rm13 } from "node:fs/promises";
|
|
450899
|
+
import { isAbsolute as isAbsolute26, join as join88, relative as relative7, resolve as resolve37, sep as sep8 } from "node:path";
|
|
450592
450900
|
async function removeRefusedCheckout(agentId, error4) {
|
|
450593
450901
|
const message2 = error4 instanceof Error ? error4.message : String(error4);
|
|
450594
450902
|
if (isLocalBackendEnvEnabled() || !/(?:returned error:|HTTP(?: status)?)[ :]*403\b/i.test(message2))
|
|
@@ -450599,14 +450907,14 @@ async function removeRefusedCheckout(agentId, error4) {
|
|
|
450599
450907
|
const configDir = await realpath6(resolveGlobalConfigDir());
|
|
450600
450908
|
if (!agentId || agentId === "." || agentId === ".." || /[/\\]/.test(agentId))
|
|
450601
450909
|
return;
|
|
450602
|
-
const expected =
|
|
450910
|
+
const expected = join88(configDir, "agents", agentId, "memory");
|
|
450603
450911
|
const checkout = resolve37(getScopedMemoryFilesystemRoot2(agentId));
|
|
450604
450912
|
if (await realpath6(checkout) !== expected || !(await lstat2(checkout)).isDirectory())
|
|
450605
450913
|
return;
|
|
450606
450914
|
const cwdRelative = relative7(expected, await realpath6(process.cwd()));
|
|
450607
450915
|
if (!cwdRelative || !cwdRelative.startsWith(`..${sep8}`) && cwdRelative !== ".." && !isAbsolute26(cwdRelative))
|
|
450608
450916
|
return;
|
|
450609
|
-
if (!(await lstat2(
|
|
450917
|
+
if (!(await lstat2(join88(checkout, ".git"))).isDirectory())
|
|
450610
450918
|
return;
|
|
450611
450919
|
const origin = execFileSync11("git", ["-C", checkout, "remote", "get-url", "origin"], {
|
|
450612
450920
|
encoding: "utf8",
|
|
@@ -450615,7 +450923,7 @@ async function removeRefusedCheckout(agentId, error4) {
|
|
|
450615
450923
|
}).trim();
|
|
450616
450924
|
if (!isMemfsRemoteUrlForAgent2(origin, agentId))
|
|
450617
450925
|
return;
|
|
450618
|
-
await
|
|
450926
|
+
await rm13(checkout, { recursive: true, force: true });
|
|
450619
450927
|
} catch {}
|
|
450620
450928
|
}
|
|
450621
450929
|
async function syncMemfsForAgent(agentId) {
|
|
@@ -450686,7 +450994,7 @@ var init_memfs_sync = __esm(() => {
|
|
|
450686
450994
|
|
|
450687
450995
|
// src/websocket/listener/mod-adapter.ts
|
|
450688
450996
|
import { createHash as createHash19 } from "node:crypto";
|
|
450689
|
-
import { join as
|
|
450997
|
+
import { join as join89 } from "node:path";
|
|
450690
450998
|
async function getUnavailableListenerClient() {
|
|
450691
450999
|
throw new Error("letta.client is not available in listener mods");
|
|
450692
451000
|
}
|
|
@@ -450762,14 +451070,14 @@ function ensureListenerModAdapter(runtime) {
|
|
|
450762
451070
|
}
|
|
450763
451071
|
function resolveListenerAgentModsDirectory(agentId) {
|
|
450764
451072
|
try {
|
|
450765
|
-
return settingsManager.isMemfsEnabled(agentId) ?
|
|
451073
|
+
return settingsManager.isMemfsEnabled(agentId) ? join89(getScopedMemoryFilesystemRoot(agentId), "mods") : null;
|
|
450766
451074
|
} catch {
|
|
450767
451075
|
return null;
|
|
450768
451076
|
}
|
|
450769
451077
|
}
|
|
450770
451078
|
function resolveListenerAgentModCacheDirectory(agentId) {
|
|
450771
451079
|
const cacheKey = createHash19("sha256").update(agentId).digest("hex");
|
|
450772
|
-
return
|
|
451080
|
+
return join89(getModCacheDirectory(), "listener-agents", cacheKey);
|
|
450773
451081
|
}
|
|
450774
451082
|
async function ensureListenerAgentModAdapter(runtime, agentId) {
|
|
450775
451083
|
runtime.agentModAdapters ??= new Map;
|
|
@@ -452179,6 +452487,7 @@ async function executeRecoveredApprovalContinuation(params) {
|
|
|
452179
452487
|
return;
|
|
452180
452488
|
}
|
|
452181
452489
|
const preparedToolContext = await prepareToolExecutionContext({
|
|
452490
|
+
...resolveRuntimeToolContextOptions(runtime.listener, scope, selectedDeliveryOwnerId ?? opts?.connectionId),
|
|
452182
452491
|
connectionId: resolveTurnExecutionConnectionId(runtime.listener, scope, opts?.connectionId),
|
|
452183
452492
|
agentId: recovered.agentId,
|
|
452184
452493
|
conversationId: recovered.conversationId,
|
|
@@ -452737,9 +453046,12 @@ async function resolveStaleApprovals(runtime, socket, turnLease, deps = {}) {
|
|
|
452737
453046
|
agent_id: runtime.agentId,
|
|
452738
453047
|
conversation_id: recoveryConversationId
|
|
452739
453048
|
};
|
|
453049
|
+
if (await getRecoveryEligibility(runtime) !== "owned")
|
|
453050
|
+
return null;
|
|
452740
453051
|
const modAdapters = runtime.agentId ? await ensureListenerModAdaptersForAgent(runtime.listener, runtime.agentId) : [];
|
|
452741
453052
|
const preparedToolContext = await prepareToolExecutionContext({
|
|
452742
453053
|
connectionId: resolveTurnExecutionConnectionId(runtime.listener, scope, runtime.activeConnectionId ?? undefined),
|
|
453054
|
+
...resolveRuntimeToolContextOptions(runtime.listener, scope),
|
|
452743
453055
|
agentId: runtime.agentId,
|
|
452744
453056
|
conversationId: recoveryConversationId,
|
|
452745
453057
|
workingDirectory: recoveryWorkingDirectory,
|
|
@@ -452757,6 +453069,8 @@ async function resolveStaleApprovals(runtime, socket, turnLease, deps = {}) {
|
|
|
452757
453069
|
const recoveryActingUserId = recoveryRecord?.actingUserId;
|
|
452758
453070
|
pendingApprovals = await filterStillPending(pendingApprovals);
|
|
452759
453071
|
while (pendingApprovals.length > 0) {
|
|
453072
|
+
if (await getRecoveryEligibility(runtime) !== "owned")
|
|
453073
|
+
return null;
|
|
452760
453074
|
assertCurrentTurnLease();
|
|
452761
453075
|
const recoveryBatchId = resolveRecoveryBatchId(runtime, pendingApprovals);
|
|
452762
453076
|
if (!recoveryBatchId) {
|
|
@@ -453167,6 +453481,7 @@ var init_send = __esm(() => {
|
|
|
453167
453481
|
init_protocol_outbound();
|
|
453168
453482
|
init_recorded_tool_results();
|
|
453169
453483
|
init_recovery();
|
|
453484
|
+
init_recovery_ownership();
|
|
453170
453485
|
init_recovery_read();
|
|
453171
453486
|
init_skill_injection();
|
|
453172
453487
|
init_turn_input_state();
|
|
@@ -456100,7 +456415,7 @@ var init_turn_approval = __esm(() => {
|
|
|
456100
456415
|
|
|
456101
456416
|
// src/agent/attached-repository-git-sync.ts
|
|
456102
456417
|
import { existsSync as existsSync59 } from "node:fs";
|
|
456103
|
-
import { join as
|
|
456418
|
+
import { join as join90 } from "node:path";
|
|
456104
456419
|
async function getPendingCommitCount(path41) {
|
|
456105
456420
|
const divergence = await getMemoryAheadBehind(path41);
|
|
456106
456421
|
if (divergence) {
|
|
@@ -456130,7 +456445,7 @@ async function syncPendingAttachedRepositoryCommitsUnlocked(params) {
|
|
|
456130
456445
|
path: path41,
|
|
456131
456446
|
permissions: params.repository.permissions ?? "unknown"
|
|
456132
456447
|
};
|
|
456133
|
-
if (!existsSync59(
|
|
456448
|
+
if (!existsSync59(join90(path41, ".git"))) {
|
|
456134
456449
|
return {
|
|
456135
456450
|
...resultBase,
|
|
456136
456451
|
status: "skipped",
|
|
@@ -456302,7 +456617,7 @@ var init_attached_repository_git_sync = __esm(() => {
|
|
|
456302
456617
|
|
|
456303
456618
|
// src/reminders/memory-git-sync.ts
|
|
456304
456619
|
import { existsSync as existsSync60 } from "node:fs";
|
|
456305
|
-
import { join as
|
|
456620
|
+
import { join as join91 } from "node:path";
|
|
456306
456621
|
function formatMemoryRepairInProgressReminder(result3) {
|
|
456307
456622
|
return `${SYSTEM_REMINDER_OPEN}
|
|
456308
456623
|
MEMORY REPAIR RUNNING: A background worker is repairing the memory repository.
|
|
@@ -456412,7 +456727,7 @@ async function runPostTurnMemorySync(params, dependencies = {}) {
|
|
|
456412
456727
|
if (memorySyncEnabled) {
|
|
456413
456728
|
try {
|
|
456414
456729
|
const memoryDir = getScopedMemoryFilesystemRoot(params.agentId);
|
|
456415
|
-
const release = existsSync60(
|
|
456730
|
+
const release = existsSync60(join91(memoryDir, ".git")) ? await (dependencies.claimOperation ?? claimMemoryOperation)(memoryDir) : undefined;
|
|
456416
456731
|
if (release !== null) {
|
|
456417
456732
|
try {
|
|
456418
456733
|
const result3 = await syncMemory(params.agentId);
|
|
@@ -457245,12 +457560,12 @@ function rowToolCalls(row, index, diagnostics2) {
|
|
|
457245
457560
|
}
|
|
457246
457561
|
return calls;
|
|
457247
457562
|
}
|
|
457248
|
-
function
|
|
457563
|
+
function contentText3(content) {
|
|
457249
457564
|
if (typeof content === "string") {
|
|
457250
457565
|
if (content.startsWith(CONTENT_JSON_PREFIX)) {
|
|
457251
457566
|
const encoded = content.slice(CONTENT_JSON_PREFIX.length);
|
|
457252
457567
|
try {
|
|
457253
|
-
return
|
|
457568
|
+
return contentText3(JSON.parse(encoded));
|
|
457254
457569
|
} catch {
|
|
457255
457570
|
return encoded;
|
|
457256
457571
|
}
|
|
@@ -457336,7 +457651,7 @@ var init_hermes = __esm(() => {
|
|
|
457336
457651
|
});
|
|
457337
457652
|
};
|
|
457338
457653
|
if (row.role === "user") {
|
|
457339
|
-
const content =
|
|
457654
|
+
const content = contentText3(row.content);
|
|
457340
457655
|
if (content) {
|
|
457341
457656
|
emit({
|
|
457342
457657
|
type: "message",
|
|
@@ -457356,7 +457671,7 @@ var init_hermes = __esm(() => {
|
|
|
457356
457671
|
...timestamp ? { timestamp } : {}
|
|
457357
457672
|
});
|
|
457358
457673
|
}
|
|
457359
|
-
const content =
|
|
457674
|
+
const content = contentText3(row.content);
|
|
457360
457675
|
if (content) {
|
|
457361
457676
|
emit({
|
|
457362
457677
|
type: "message",
|
|
@@ -457379,7 +457694,7 @@ var init_hermes = __esm(() => {
|
|
|
457379
457694
|
if (row.role === "tool") {
|
|
457380
457695
|
emit({
|
|
457381
457696
|
type: "tool_result",
|
|
457382
|
-
content:
|
|
457697
|
+
content: contentText3(row.content),
|
|
457383
457698
|
...typeof row.tool_call_id === "string" && row.tool_call_id ? { callId: row.tool_call_id } : {},
|
|
457384
457699
|
...timestamp ? { timestamp } : {}
|
|
457385
457700
|
});
|
|
@@ -458647,7 +458962,7 @@ var init_core5 = __esm(() => {
|
|
|
458647
458962
|
import { spawn as spawn12 } from "node:child_process";
|
|
458648
458963
|
import { accessSync as accessSync3, constants as constants8 } from "node:fs";
|
|
458649
458964
|
import { homedir as homedir23 } from "node:os";
|
|
458650
|
-
import { join as
|
|
458965
|
+
import { join as join92 } from "node:path";
|
|
458651
458966
|
import { fileURLToPath as fileURLToPath9 } from "node:url";
|
|
458652
458967
|
async function normalizeCheckpoint(input) {
|
|
458653
458968
|
const { decoded, bounds, filters } = await decodeCheckpoint(input);
|
|
@@ -458671,7 +458986,7 @@ async function decodeCheckpoint(input) {
|
|
|
458671
458986
|
}
|
|
458672
458987
|
async function loadDeepAgentsCheckpoint(checkpoint) {
|
|
458673
458988
|
validateLocation(checkpoint);
|
|
458674
|
-
const path41 = checkpoint.path ??
|
|
458989
|
+
const path41 = checkpoint.path ?? join92(homedir23(), ".deepagents", "sessions.db");
|
|
458675
458990
|
const python = checkpoint.pythonExecutable ?? process.env.PYTHON ?? "python3";
|
|
458676
458991
|
const helper = resolveHelperPath();
|
|
458677
458992
|
return await new Promise((resolve38, reject2) => {
|
|
@@ -458891,7 +459206,7 @@ var init_deepagents = __esm(() => {
|
|
|
458891
459206
|
|
|
458892
459207
|
// node_modules/@letta-ai/trajectory/dist/adapters/listing-shared.js
|
|
458893
459208
|
import { readdirSync as readdirSync25, statSync as statSync24 } from "node:fs";
|
|
458894
|
-
import { join as
|
|
459209
|
+
import { join as join93 } from "node:path";
|
|
458895
459210
|
function sortListings(items) {
|
|
458896
459211
|
return items.sort((left, right) => {
|
|
458897
459212
|
const l3 = left.updatedAt ?? "";
|
|
@@ -458936,7 +459251,7 @@ function collectFiles(root2, extension, depth) {
|
|
|
458936
459251
|
return [];
|
|
458937
459252
|
const collected = [];
|
|
458938
459253
|
for (const entry of safeReadDir(root2)) {
|
|
458939
|
-
const full =
|
|
459254
|
+
const full = join93(root2, entry.name);
|
|
458940
459255
|
if (entry.isFile && entry.name.endsWith(extension)) {
|
|
458941
459256
|
collected.push(full);
|
|
458942
459257
|
} else if (entry.isDirectory) {
|
|
@@ -459021,18 +459336,18 @@ var init_listing_shared = __esm(() => {
|
|
|
459021
459336
|
|
|
459022
459337
|
// node_modules/@letta-ai/trajectory/dist/adapters/claude-code/list.js
|
|
459023
459338
|
import { homedir as homedir24 } from "node:os";
|
|
459024
|
-
import { basename as basename26, join as
|
|
459339
|
+
import { basename as basename26, join as join94 } from "node:path";
|
|
459025
459340
|
async function listClaudeCodeTrajectories(root2) {
|
|
459026
|
-
const base2 = root2 ??
|
|
459341
|
+
const base2 = root2 ?? join94(homedir24(), ".claude", "projects");
|
|
459027
459342
|
const items = [];
|
|
459028
459343
|
for (const project of safeReadDir(base2)) {
|
|
459029
459344
|
if (!project.isDirectory)
|
|
459030
459345
|
continue;
|
|
459031
|
-
const projectPath =
|
|
459346
|
+
const projectPath = join94(base2, project.name);
|
|
459032
459347
|
for (const entry of safeReadDir(projectPath)) {
|
|
459033
459348
|
if (!entry.isFile || !entry.name.endsWith(".jsonl"))
|
|
459034
459349
|
continue;
|
|
459035
|
-
const path41 =
|
|
459350
|
+
const path41 = join94(projectPath, entry.name);
|
|
459036
459351
|
const listing = listingFromFile(basename26(entry.name, ".jsonl"), path41);
|
|
459037
459352
|
if (listing)
|
|
459038
459353
|
items.push(listing);
|
|
@@ -459046,9 +459361,9 @@ var init_list = __esm(() => {
|
|
|
459046
459361
|
|
|
459047
459362
|
// node_modules/@letta-ai/trajectory/dist/adapters/codex/list.js
|
|
459048
459363
|
import { homedir as homedir25 } from "node:os";
|
|
459049
|
-
import { basename as basename27, join as
|
|
459364
|
+
import { basename as basename27, join as join95 } from "node:path";
|
|
459050
459365
|
async function listCodexTrajectories(root2) {
|
|
459051
|
-
const base2 = root2 ??
|
|
459366
|
+
const base2 = root2 ?? join95(homedir25(), ".codex", "sessions");
|
|
459052
459367
|
const items = [];
|
|
459053
459368
|
for (const path41 of collectFiles(base2, ".jsonl", 4)) {
|
|
459054
459369
|
const listing = listingFromFile(basename27(path41, ".jsonl"), path41);
|
|
@@ -459063,7 +459378,7 @@ var init_list2 = __esm(() => {
|
|
|
459063
459378
|
|
|
459064
459379
|
// node_modules/@letta-ai/trajectory/dist/adapters/deepagents/list.js
|
|
459065
459380
|
import { homedir as homedir26 } from "node:os";
|
|
459066
|
-
import { join as
|
|
459381
|
+
import { join as join96 } from "node:path";
|
|
459067
459382
|
async function listDeepAgentsTrajectories(root2) {
|
|
459068
459383
|
const path41 = resolveStorePath(root2);
|
|
459069
459384
|
if (!safeStat(path41))
|
|
@@ -459084,8 +459399,8 @@ async function listDeepAgentsTrajectories(root2) {
|
|
|
459084
459399
|
}
|
|
459085
459400
|
function resolveStorePath(root2) {
|
|
459086
459401
|
if (root2 === undefined)
|
|
459087
|
-
return
|
|
459088
|
-
return root2.endsWith(".db") ? root2 :
|
|
459402
|
+
return join96(homedir26(), ".deepagents", "sessions.db");
|
|
459403
|
+
return root2.endsWith(".db") ? root2 : join96(root2, "sessions.db");
|
|
459089
459404
|
}
|
|
459090
459405
|
var init_list3 = __esm(() => {
|
|
459091
459406
|
init_listing_shared();
|
|
@@ -459093,7 +459408,7 @@ var init_list3 = __esm(() => {
|
|
|
459093
459408
|
|
|
459094
459409
|
// node_modules/@letta-ai/trajectory/dist/adapters/hermes/list.js
|
|
459095
459410
|
import { homedir as homedir27 } from "node:os";
|
|
459096
|
-
import { join as
|
|
459411
|
+
import { join as join97 } from "node:path";
|
|
459097
459412
|
async function listHermesTrajectories(root2) {
|
|
459098
459413
|
const path41 = resolveStorePath2(root2);
|
|
459099
459414
|
if (!safeStat(path41))
|
|
@@ -459120,8 +459435,8 @@ async function listHermesTrajectories(root2) {
|
|
|
459120
459435
|
}
|
|
459121
459436
|
function resolveStorePath2(root2) {
|
|
459122
459437
|
if (root2 === undefined)
|
|
459123
|
-
return
|
|
459124
|
-
return root2.endsWith(".db") ? root2 :
|
|
459438
|
+
return join97(homedir27(), ".hermes", "state.db");
|
|
459439
|
+
return root2.endsWith(".db") ? root2 : join97(root2, "state.db");
|
|
459125
459440
|
}
|
|
459126
459441
|
function numeric2(value) {
|
|
459127
459442
|
return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : undefined;
|
|
@@ -459132,18 +459447,18 @@ var init_list4 = __esm(() => {
|
|
|
459132
459447
|
|
|
459133
459448
|
// node_modules/@letta-ai/trajectory/dist/adapters/letta-code/list.js
|
|
459134
459449
|
import { homedir as homedir28 } from "node:os";
|
|
459135
|
-
import { join as
|
|
459450
|
+
import { join as join98 } from "node:path";
|
|
459136
459451
|
async function listLettaCodeTrajectories(root2) {
|
|
459137
|
-
const base2 = root2 ??
|
|
459452
|
+
const base2 = root2 ?? join98(homedir28(), ".letta", "transcripts");
|
|
459138
459453
|
const items = [];
|
|
459139
459454
|
for (const agent of safeReadDir(base2)) {
|
|
459140
459455
|
if (!agent.isDirectory)
|
|
459141
459456
|
continue;
|
|
459142
|
-
const agentPath2 =
|
|
459457
|
+
const agentPath2 = join98(base2, agent.name);
|
|
459143
459458
|
for (const conversation of safeReadDir(agentPath2)) {
|
|
459144
459459
|
if (!conversation.isDirectory)
|
|
459145
459460
|
continue;
|
|
459146
|
-
const path41 =
|
|
459461
|
+
const path41 = join98(agentPath2, conversation.name, "transcript.jsonl");
|
|
459147
459462
|
const listing = listingFromFile(`${agent.name}/${conversation.name}`, path41);
|
|
459148
459463
|
if (listing && (listing.sizeBytes ?? 0) > 0)
|
|
459149
459464
|
items.push(listing);
|
|
@@ -459158,19 +459473,19 @@ var init_list5 = __esm(() => {
|
|
|
459158
459473
|
// node_modules/@letta-ai/trajectory/dist/adapters/openclaw/list.js
|
|
459159
459474
|
import { existsSync as existsSync61 } from "node:fs";
|
|
459160
459475
|
import { homedir as homedir29 } from "node:os";
|
|
459161
|
-
import { basename as basename28, join as
|
|
459476
|
+
import { basename as basename28, join as join99 } from "node:path";
|
|
459162
459477
|
async function listOpenClawTrajectories(root2) {
|
|
459163
459478
|
const base2 = root2 ?? defaultStateDir();
|
|
459164
459479
|
const items = [];
|
|
459165
|
-
const agentsPath =
|
|
459480
|
+
const agentsPath = join99(base2, "agents");
|
|
459166
459481
|
for (const agent of safeReadDir(agentsPath)) {
|
|
459167
459482
|
if (!agent.isDirectory)
|
|
459168
459483
|
continue;
|
|
459169
|
-
const sessionsPath =
|
|
459484
|
+
const sessionsPath = join99(agentsPath, agent.name, "sessions");
|
|
459170
459485
|
for (const entry of safeReadDir(sessionsPath)) {
|
|
459171
459486
|
if (!entry.isFile || !entry.name.endsWith(".jsonl"))
|
|
459172
459487
|
continue;
|
|
459173
|
-
const path41 =
|
|
459488
|
+
const path41 = join99(sessionsPath, entry.name);
|
|
459174
459489
|
const listing = listingFromFile(basename28(entry.name, ".jsonl"), path41);
|
|
459175
459490
|
if (listing)
|
|
459176
459491
|
items.push(listing);
|
|
@@ -459182,10 +459497,10 @@ function defaultStateDir() {
|
|
|
459182
459497
|
const override = process.env.OPENCLAW_STATE_DIR?.trim() || process.env.CLAWDBOT_STATE_DIR?.trim();
|
|
459183
459498
|
if (override)
|
|
459184
459499
|
return override;
|
|
459185
|
-
const current =
|
|
459500
|
+
const current = join99(homedir29(), ".openclaw");
|
|
459186
459501
|
if (existsSync61(current))
|
|
459187
459502
|
return current;
|
|
459188
|
-
return
|
|
459503
|
+
return join99(homedir29(), ".clawdbot");
|
|
459189
459504
|
}
|
|
459190
459505
|
var init_list6 = __esm(() => {
|
|
459191
459506
|
init_listing_shared();
|
|
@@ -459193,14 +459508,14 @@ var init_list6 = __esm(() => {
|
|
|
459193
459508
|
|
|
459194
459509
|
// node_modules/@letta-ai/trajectory/dist/adapters/openhands/list.js
|
|
459195
459510
|
import { homedir as homedir30 } from "node:os";
|
|
459196
|
-
import { join as
|
|
459511
|
+
import { join as join100 } from "node:path";
|
|
459197
459512
|
async function listOpenHandsTrajectories(root2) {
|
|
459198
|
-
const base2 = root2 ??
|
|
459513
|
+
const base2 = root2 ?? join100(homedir30(), ".openhands", "sessions");
|
|
459199
459514
|
const items = [];
|
|
459200
459515
|
for (const entry of safeReadDir(base2)) {
|
|
459201
459516
|
if (!entry.isDirectory)
|
|
459202
459517
|
continue;
|
|
459203
|
-
const path41 =
|
|
459518
|
+
const path41 = join100(base2, entry.name);
|
|
459204
459519
|
const facts = safeStat(path41);
|
|
459205
459520
|
items.push({
|
|
459206
459521
|
id: entry.name,
|
|
@@ -459374,7 +459689,7 @@ __export(exports_memory_scanner, {
|
|
|
459374
459689
|
getFileNodes: () => getFileNodes
|
|
459375
459690
|
});
|
|
459376
459691
|
import { readdirSync as readdirSync26, readFileSync as readFileSync52, statSync as statSync25 } from "node:fs";
|
|
459377
|
-
import { join as
|
|
459692
|
+
import { join as join101, relative as relative10 } from "node:path";
|
|
459378
459693
|
function scanMemoryFilesystem(memoryRoot) {
|
|
459379
459694
|
const nodes = [];
|
|
459380
459695
|
const scanDir = (dir, depth, parentIsLast) => {
|
|
@@ -459386,8 +459701,8 @@ function scanMemoryFilesystem(memoryRoot) {
|
|
|
459386
459701
|
}
|
|
459387
459702
|
const filtered = entries2.filter((name) => !name.startsWith("."));
|
|
459388
459703
|
const sorted = filtered.sort((a2, b3) => {
|
|
459389
|
-
const aPath =
|
|
459390
|
-
const bPath =
|
|
459704
|
+
const aPath = join101(dir, a2);
|
|
459705
|
+
const bPath = join101(dir, b3);
|
|
459391
459706
|
let aIsDir = false;
|
|
459392
459707
|
let bIsDir = false;
|
|
459393
459708
|
try {
|
|
@@ -459407,7 +459722,7 @@ function scanMemoryFilesystem(memoryRoot) {
|
|
|
459407
459722
|
return a2.localeCompare(b3);
|
|
459408
459723
|
});
|
|
459409
459724
|
sorted.forEach((name, index) => {
|
|
459410
|
-
const fullPath =
|
|
459725
|
+
const fullPath = join101(dir, name);
|
|
459411
459726
|
let isDir = false;
|
|
459412
459727
|
try {
|
|
459413
459728
|
isDir = statSync25(fullPath).isDirectory();
|
|
@@ -459525,7 +459840,7 @@ import {
|
|
|
459525
459840
|
stat as stat13,
|
|
459526
459841
|
writeFile as writeFile15
|
|
459527
459842
|
} from "node:fs/promises";
|
|
459528
|
-
import { join as
|
|
459843
|
+
import { join as join102 } from "node:path";
|
|
459529
459844
|
function buildReflectionSelectorPrompt(options) {
|
|
459530
459845
|
const lines = [
|
|
459531
459846
|
'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 +459874,7 @@ async function collectParentMemoryFiles(memoryDir) {
|
|
|
459559
459874
|
return a2.name.localeCompare(b3.name);
|
|
459560
459875
|
});
|
|
459561
459876
|
for (const entry of sortedEntries) {
|
|
459562
|
-
const entryPath =
|
|
459877
|
+
const entryPath = join102(currentDir, entry.name);
|
|
459563
459878
|
const relativePath = relativeDir ? `${relativeDir}/${entry.name}` : entry.name;
|
|
459564
459879
|
if (entry.isDirectory()) {
|
|
459565
459880
|
await walk3(entryPath, relativePath);
|
|
@@ -459975,17 +460290,17 @@ async function writeState(paths, state2) {
|
|
|
459975
460290
|
}
|
|
459976
460291
|
function buildPayloadPath(rootDir, kind) {
|
|
459977
460292
|
const nonce = Math.random().toString(36).slice(2, 8);
|
|
459978
|
-
return
|
|
460293
|
+
return join102(rootDir, `payload-${kind}-${nonce}.json`);
|
|
459979
460294
|
}
|
|
459980
460295
|
function getAgentTranscriptRoot(agentId) {
|
|
459981
|
-
return
|
|
460296
|
+
return join102(getTranscriptRoot(), sanitizePathSegment2(agentId));
|
|
459982
460297
|
}
|
|
459983
460298
|
function getReflectionTranscriptPaths(agentId, conversationId) {
|
|
459984
|
-
const rootDir =
|
|
460299
|
+
const rootDir = join102(getTranscriptRoot(), sanitizePathSegment2(agentId), sanitizePathSegment2(conversationId));
|
|
459985
460300
|
return {
|
|
459986
460301
|
rootDir,
|
|
459987
|
-
transcriptPath:
|
|
459988
|
-
statePath:
|
|
460302
|
+
transcriptPath: join102(rootDir, "transcript.jsonl"),
|
|
460303
|
+
statePath: join102(rootDir, "state.json")
|
|
459989
460304
|
};
|
|
459990
460305
|
}
|
|
459991
460306
|
async function appendTranscriptDeltaJsonl(agentId, conversationId, lines) {
|
|
@@ -460075,7 +460390,7 @@ async function getTranscriptLastUpdatedAt(paths) {
|
|
|
460075
460390
|
}
|
|
460076
460391
|
}
|
|
460077
460392
|
async function ensureAgentPayloadRoot(agentId) {
|
|
460078
|
-
const root2 =
|
|
460393
|
+
const root2 = join102(getAgentTranscriptRoot(agentId), "multi-reflection-payloads");
|
|
460079
460394
|
await mkdir13(root2, { recursive: true });
|
|
460080
460395
|
return root2;
|
|
460081
460396
|
}
|
|
@@ -460639,7 +460954,7 @@ import { execFile as execFileCb3 } from "node:child_process";
|
|
|
460639
460954
|
import { randomUUID as randomUUID55 } from "node:crypto";
|
|
460640
460955
|
import { existsSync as existsSync62 } from "node:fs";
|
|
460641
460956
|
import { mkdir as mkdir14 } from "node:fs/promises";
|
|
460642
|
-
import { dirname as dirname37, isAbsolute as isAbsolute27, join as
|
|
460957
|
+
import { dirname as dirname37, isAbsolute as isAbsolute27, join as join103, resolve as resolve38 } from "node:path";
|
|
460643
460958
|
import { promisify as promisify18 } from "node:util";
|
|
460644
460959
|
async function runGit4(cwd2, args) {
|
|
460645
460960
|
try {
|
|
@@ -460699,9 +461014,9 @@ async function buildReflectionMergeMessage(parentMemoryDir, branchName) {
|
|
|
460699
461014
|
async function createReflectionMemoryWorktree(options) {
|
|
460700
461015
|
const parentMemoryDir = resolve38(options.parentMemoryDir);
|
|
460701
461016
|
const id = buildReflectionWorktreeId(options.now);
|
|
460702
|
-
const worktreeBaseDir =
|
|
461017
|
+
const worktreeBaseDir = join103(dirname37(parentMemoryDir), "memory-worktrees");
|
|
460703
461018
|
const label = options.label ?? "reflection";
|
|
460704
|
-
const worktreeDir =
|
|
461019
|
+
const worktreeDir = join103(worktreeBaseDir, `${label}-${id}`);
|
|
460705
461020
|
const branchName = `letta/${label}/${id}`;
|
|
460706
461021
|
await mkdir14(worktreeBaseDir, { recursive: true });
|
|
460707
461022
|
const { stdout: baseHeadOut } = await runGit4(parentMemoryDir, [
|
|
@@ -462387,6 +462702,16 @@ async function startTurnInput(params) {
|
|
|
462387
462702
|
stream: sender.accept(result3)
|
|
462388
462703
|
};
|
|
462389
462704
|
}
|
|
462705
|
+
function getPostStopErrorDetails(latestErrorInfo, runErrorInfo2, fallbackError) {
|
|
462706
|
+
const errorDetail3 = getApprovalToolCallDesyncErrorText(latestErrorInfo ?? {}) || latestErrorInfo?.detail || latestErrorInfo?.message || runErrorInfo2?.detail || runErrorInfo2?.message || fallbackError || null;
|
|
462707
|
+
const retryErrorDetail = [
|
|
462708
|
+
latestErrorInfo?.detail,
|
|
462709
|
+
latestErrorInfo?.message,
|
|
462710
|
+
runErrorInfo2?.detail,
|
|
462711
|
+
runErrorInfo2?.message
|
|
462712
|
+
].find(isProviderStreamTimeoutDetail) ?? errorDetail3;
|
|
462713
|
+
return { errorDetail: errorDetail3, retryErrorDetail };
|
|
462714
|
+
}
|
|
462390
462715
|
function getProviderRetryLimit(errorDetail3) {
|
|
462391
462716
|
return isProviderStreamTimeoutDetail(errorDetail3) ? 1 : LLM_API_ERROR_MAX_RETRIES;
|
|
462392
462717
|
}
|
|
@@ -462482,6 +462807,7 @@ var init_turn_send = __esm(() => {
|
|
|
462482
462807
|
init_queue();
|
|
462483
462808
|
init_recoverable_notices();
|
|
462484
462809
|
init_recovery();
|
|
462810
|
+
init_recovery_error_policy();
|
|
462485
462811
|
init_send();
|
|
462486
462812
|
init_skill_injection();
|
|
462487
462813
|
init_turn_input_state();
|
|
@@ -462509,14 +462835,6 @@ function buildListenReminderContext(params) {
|
|
|
462509
462835
|
};
|
|
462510
462836
|
}
|
|
462511
462837
|
|
|
462512
|
-
// src/tools/interactive-policy.ts
|
|
462513
|
-
var INTERACTIVE_USER_INPUT_TOOL_NAMES;
|
|
462514
|
-
var init_interactive_policy = __esm(() => {
|
|
462515
|
-
INTERACTIVE_USER_INPUT_TOOL_NAMES = [
|
|
462516
|
-
"AskUserQuestionAsync"
|
|
462517
|
-
];
|
|
462518
|
-
});
|
|
462519
|
-
|
|
462520
462838
|
// src/telemetry/input.ts
|
|
462521
462839
|
function extractTelemetryInputText(content) {
|
|
462522
462840
|
if (typeof content === "string") {
|
|
@@ -462678,6 +462996,7 @@ async function prepareListenerTurn(params) {
|
|
|
462678
462996
|
if (isInterrupted()) {
|
|
462679
462997
|
return { kind: "interrupted" };
|
|
462680
462998
|
}
|
|
462999
|
+
markLocalTurnScope(runtime);
|
|
462681
463000
|
setCurrentAgentId(agentId);
|
|
462682
463001
|
setCurrentAgentName(listenAgentMetadata?.name ?? null);
|
|
462683
463002
|
setConversationId(conversationId);
|
|
@@ -462839,12 +463158,6 @@ async function prepareListenerTurn(params) {
|
|
|
462839
463158
|
if (connectionId) {
|
|
462840
463159
|
recordRuntimeSubmittingConnection(runtime.listener, toolRuntimeScope, connectionId);
|
|
462841
463160
|
}
|
|
462842
|
-
const toolOwner = resolveRuntimeToolOwner(runtime.listener, toolRuntimeScope, connectionId);
|
|
462843
|
-
const toolSelection = resolveTurnToolSelection({
|
|
462844
|
-
clientToolset: msg.clientToolset,
|
|
462845
|
-
clientToolAllowlist: msg.clientToolAllowlist,
|
|
462846
|
-
excludeInteractiveTools: msg.excludeInteractiveTools
|
|
462847
|
-
}, toolOwner.toolPolicy);
|
|
462848
463161
|
const preparedToolContext = await prepareToolExecutionContextForScope({
|
|
462849
463162
|
readScopeState: (read2) => retryApprovalRecoveryRead(read2, () => {
|
|
462850
463163
|
if (isInterrupted())
|
|
@@ -462859,10 +463172,7 @@ async function prepareListenerTurn(params) {
|
|
|
462859
463172
|
mcpOriginatorSuperRunId: getEffectiveMcpOriginatorId(msg),
|
|
462860
463173
|
resolveClientMessageIds,
|
|
462861
463174
|
turnStartedAt: msg.receivedAt,
|
|
462862
|
-
|
|
462863
|
-
clientToolset: toolSelection.clientToolset,
|
|
462864
|
-
clientToolAllowlist: toolSelection.clientToolAllowlist,
|
|
462865
|
-
...toolSelection.excludeInteractiveTools ? { exclude: [...INTERACTIVE_USER_INPUT_TOOL_NAMES] } : {},
|
|
463175
|
+
...resolveRuntimeToolContextOptions(runtime.listener, toolRuntimeScope, connectionId, msg),
|
|
462866
463176
|
workingDirectory,
|
|
462867
463177
|
permissionModeState,
|
|
462868
463178
|
skillsDirectory: listenerOptions?.skillsDirectory,
|
|
@@ -462870,7 +463180,6 @@ async function prepareListenerTurn(params) {
|
|
|
462870
463180
|
bundledSkills: runtime.bundledSkills,
|
|
462871
463181
|
workspaceSandbox: runtime.workspaceSandbox,
|
|
462872
463182
|
executionSettings: runtime.executionSettings,
|
|
462873
|
-
foregroundYieldMs: toolOwner.toolPolicy?.foreground_yield_ms,
|
|
462874
463183
|
cachedAgent,
|
|
462875
463184
|
...agentId ? { modContext: createListenerAgentModContext(agentId) } : {},
|
|
462876
463185
|
modAdapters,
|
|
@@ -462941,8 +463250,6 @@ var init_turn_setup = __esm(() => {
|
|
|
462941
463250
|
init_runtime_context();
|
|
462942
463251
|
init_error_reporting();
|
|
462943
463252
|
init_client_preferences();
|
|
462944
|
-
init_interactive_policy();
|
|
462945
|
-
init_tool_policy();
|
|
462946
463253
|
init_toolset();
|
|
462947
463254
|
init_debug();
|
|
462948
463255
|
init_shell_context();
|
|
@@ -463322,23 +463629,22 @@ async function handleIncomingMessageInner(msg, socket, runtime, onStatusChange,
|
|
|
463322
463629
|
break;
|
|
463323
463630
|
}
|
|
463324
463631
|
const latestErrorInfo = result3.errorInfo;
|
|
463325
|
-
const
|
|
463326
|
-
const retryErrorDetail = [
|
|
463327
|
-
latestErrorInfo?.detail,
|
|
463328
|
-
latestErrorInfo?.message,
|
|
463329
|
-
runErrorInfo2?.detail,
|
|
463330
|
-
runErrorInfo2?.message
|
|
463331
|
-
].find(isProviderStreamTimeoutDetail) ?? errorDetail3;
|
|
463632
|
+
const { errorDetail: errorDetail3, retryErrorDetail } = getPostStopErrorDetails(latestErrorInfo, runErrorInfo2, fallbackError);
|
|
463332
463633
|
const quotaError = latestErrorInfo ?? runErrorInfo2 ?? errorDetail3;
|
|
463333
463634
|
const deploymentInterrupted = isCloudApiDeploymentInterrupted(latestErrorInfo) || isCloudApiDeploymentInterrupted(runErrorInfo2);
|
|
463334
|
-
|
|
463635
|
+
const shouldRecoverApproval = !deploymentInterrupted && shouldAttemptPostStopApprovalRecovery({
|
|
463335
463636
|
stopReason,
|
|
463336
463637
|
runIdsSeen: msgRunIds.length,
|
|
463337
463638
|
retries: postStopApprovalRecoveryRetries,
|
|
463338
463639
|
runErrorDetail: errorDetail3,
|
|
463339
463640
|
latestErrorText: latestErrorInfo?.detail ?? latestErrorInfo?.message ?? null,
|
|
463340
463641
|
fallbackError
|
|
463341
|
-
})
|
|
463642
|
+
});
|
|
463643
|
+
const ownsApprovalRecovery = shouldRecoverApproval && await getRecoveryEligibility(runtime) === "owned";
|
|
463644
|
+
if (shouldRecoverApproval && finishIfInterrupted(lastRunId || runtime.activeRunId)) {
|
|
463645
|
+
break;
|
|
463646
|
+
}
|
|
463647
|
+
if (ownsApprovalRecovery) {
|
|
463342
463648
|
postStopApprovalRecoveryRetries += 1;
|
|
463343
463649
|
emitRecoverableStatusNotice(socket, runtime, {
|
|
463344
463650
|
kind: "stale_approval_conflict_recovery",
|
|
@@ -463786,6 +464092,7 @@ var init_turn = __esm(() => {
|
|
|
463786
464092
|
init_protocol_outbound();
|
|
463787
464093
|
init_recoverable_notices();
|
|
463788
464094
|
init_recovery();
|
|
464095
|
+
init_recovery_ownership();
|
|
463789
464096
|
init_runtime6();
|
|
463790
464097
|
init_send();
|
|
463791
464098
|
init_skill_injection();
|
|
@@ -464200,6 +464507,7 @@ var init_inbound_dispatch = __esm(() => {
|
|
|
464200
464507
|
init_mcp_originator_tokens();
|
|
464201
464508
|
init_debug();
|
|
464202
464509
|
init_connection();
|
|
464510
|
+
init_inbound_queue();
|
|
464203
464511
|
init_input_disposition();
|
|
464204
464512
|
init_input_disposition_ownership();
|
|
464205
464513
|
init_input_disposition_rollback();
|
|
@@ -467852,9 +468160,9 @@ __export(exports_custom, {
|
|
|
467852
468160
|
});
|
|
467853
468161
|
import { existsSync as existsSync63 } from "node:fs";
|
|
467854
468162
|
import { readdir as readdir11, readFile as readFile27 } from "node:fs/promises";
|
|
467855
|
-
import { basename as basename30, dirname as dirname38, join as
|
|
468163
|
+
import { basename as basename30, dirname as dirname38, join as join104 } from "node:path";
|
|
467856
468164
|
function getGlobalCommandsDir() {
|
|
467857
|
-
return
|
|
468165
|
+
return join104(resolveGlobalConfigDir(), "commands");
|
|
467858
468166
|
}
|
|
467859
468167
|
async function getCustomCommands() {
|
|
467860
468168
|
if (cachedCommands !== null) {
|
|
@@ -467866,7 +468174,7 @@ async function getCustomCommands() {
|
|
|
467866
468174
|
function refreshCustomCommands() {
|
|
467867
468175
|
cachedCommands = null;
|
|
467868
468176
|
}
|
|
467869
|
-
async function discoverCustomCommands(projectPath =
|
|
468177
|
+
async function discoverCustomCommands(projectPath = join104(process.cwd(), COMMANDS_DIR)) {
|
|
467870
468178
|
const commandsById = new Map;
|
|
467871
468179
|
const userCommands = await discoverFromDirectory(getGlobalCommandsDir(), "user");
|
|
467872
468180
|
for (const cmd of userCommands) {
|
|
@@ -467898,7 +468206,7 @@ async function findCommandFiles(currentPath, rootPath, commands, source) {
|
|
|
467898
468206
|
try {
|
|
467899
468207
|
const entries2 = await readdir11(currentPath, { withFileTypes: true });
|
|
467900
468208
|
for (const entry of entries2) {
|
|
467901
|
-
const fullPath =
|
|
468209
|
+
const fullPath = join104(currentPath, entry.name);
|
|
467902
468210
|
if (entry.isDirectory()) {
|
|
467903
468211
|
await findCommandFiles(fullPath, rootPath, commands, source);
|
|
467904
468212
|
} else if (entry.isFile() && entry.name.endsWith(".md")) {
|
|
@@ -470639,9 +470947,9 @@ async function handleListMemoryCommand(parsed, socket, safeSocketSend, overrides
|
|
|
470639
470947
|
const { scanMemoryFilesystem: scanMemoryFilesystem2, getFileNodes: getFileNodes2, readFileContent: readFileContent2 } = await Promise.resolve().then(() => (init_memory_scanner(), exports_memory_scanner));
|
|
470640
470948
|
const { parseFrontmatter: parseFrontmatter2 } = await Promise.resolve().then(() => exports_frontmatter);
|
|
470641
470949
|
const { existsSync: existsSync64, statSync: statSync26 } = await import("node:fs");
|
|
470642
|
-
const { join:
|
|
470950
|
+
const { join: join105, posix: posix4 } = await import("node:path");
|
|
470643
470951
|
const memoryRoot = getMemoryFilesystemRoot2(parsed.agent_id);
|
|
470644
|
-
let memfsInitialized = existsSync64(
|
|
470952
|
+
let memfsInitialized = existsSync64(join105(memoryRoot, ".git"));
|
|
470645
470953
|
const memfsEnabled = memfsInitialized ? true : await isMemfsEnabledOnServer2(parsed.agent_id);
|
|
470646
470954
|
if (!memfsEnabled) {
|
|
470647
470955
|
safeSocketSend(socket, {
|
|
@@ -470659,7 +470967,7 @@ async function handleListMemoryCommand(parsed, socket, safeSocketSend, overrides
|
|
|
470659
470967
|
await ensureLocalMemfsCheckout2(parsed.agent_id, {
|
|
470660
470968
|
pullOnExistingRepo: true
|
|
470661
470969
|
});
|
|
470662
|
-
memfsInitialized = existsSync64(
|
|
470970
|
+
memfsInitialized = existsSync64(join105(memoryRoot, ".git"));
|
|
470663
470971
|
if (!memfsInitialized) {
|
|
470664
470972
|
throw new Error("MemFS is enabled, but the local memory checkout could not be initialized.");
|
|
470665
470973
|
}
|
|
@@ -470960,26 +471268,26 @@ function handleMemoryProtocolCommand(parsed, context3) {
|
|
|
470960
471268
|
} = await Promise.resolve().then(() => (init_memory_filesystem2(), exports_memory_filesystem));
|
|
470961
471269
|
const { readFile: readFile28 } = await import("node:fs/promises");
|
|
470962
471270
|
const { existsSync: existsSync64 } = await import("node:fs");
|
|
470963
|
-
const { isAbsolute: isAbsolute28, join:
|
|
471271
|
+
const { isAbsolute: isAbsolute28, join: join105, normalize: normalize5, relative: relative12, sep: sep9 } = await import("node:path");
|
|
470964
471272
|
if (isAbsolute28(parsed.path) || parsed.path.length === 0) {
|
|
470965
471273
|
sendFailure("path must be a non-empty relative path");
|
|
470966
471274
|
return;
|
|
470967
471275
|
}
|
|
470968
471276
|
const memoryRoot = getScopedMemoryFilesystemRoot2(parsed.agent_id);
|
|
470969
|
-
const absolutePath = normalize5(
|
|
471277
|
+
const absolutePath = normalize5(join105(memoryRoot, parsed.path));
|
|
470970
471278
|
const rel = relative12(memoryRoot, absolutePath);
|
|
470971
471279
|
if (rel.startsWith("..") || rel === "" || isAbsolute28(rel) || rel.split(sep9).includes("..")) {
|
|
470972
471280
|
sendFailure("path must resolve inside the memory root");
|
|
470973
471281
|
return;
|
|
470974
471282
|
}
|
|
470975
|
-
if (!existsSync64(
|
|
471283
|
+
if (!existsSync64(join105(memoryRoot, ".git"))) {
|
|
470976
471284
|
const enabled = await isMemfsEnabledOnServer2(parsed.agent_id);
|
|
470977
471285
|
if (!enabled) {
|
|
470978
471286
|
sendFailure("memfs is not enabled for this agent");
|
|
470979
471287
|
return;
|
|
470980
471288
|
}
|
|
470981
471289
|
await ensureLocalMemfsCheckout2(parsed.agent_id);
|
|
470982
|
-
if (!existsSync64(
|
|
471290
|
+
if (!existsSync64(join105(memoryRoot, ".git"))) {
|
|
470983
471291
|
sendFailure("failed to initialize local memory checkout");
|
|
470984
471292
|
return;
|
|
470985
471293
|
}
|
|
@@ -471026,26 +471334,26 @@ function handleMemoryProtocolCommand(parsed, context3) {
|
|
|
471026
471334
|
const { commitMemoryWrite: commitMemoryWrite2 } = await Promise.resolve().then(() => (init_memory_git(), exports_memory_git));
|
|
471027
471335
|
const { writeFile: writeFile17, mkdir: mkdir16 } = await import("node:fs/promises");
|
|
471028
471336
|
const { existsSync: existsSync64 } = await import("node:fs");
|
|
471029
|
-
const { dirname: dirname39, isAbsolute: isAbsolute28, join:
|
|
471337
|
+
const { dirname: dirname39, isAbsolute: isAbsolute28, join: join105, normalize: normalize5, relative: relative12, sep: sep9 } = await import("node:path");
|
|
471030
471338
|
if (isAbsolute28(parsed.path) || parsed.path.length === 0) {
|
|
471031
471339
|
sendFailure("write_memory_file: path must be a non-empty relative path");
|
|
471032
471340
|
return;
|
|
471033
471341
|
}
|
|
471034
471342
|
const memoryRoot = getScopedMemoryFilesystemRoot2(parsed.agent_id);
|
|
471035
|
-
const absolutePath = normalize5(
|
|
471343
|
+
const absolutePath = normalize5(join105(memoryRoot, parsed.path));
|
|
471036
471344
|
const rel = relative12(memoryRoot, absolutePath);
|
|
471037
471345
|
if (rel.startsWith("..") || rel === "" || isAbsolute28(rel) || rel.split(sep9).includes("..")) {
|
|
471038
471346
|
sendFailure("write_memory_file: path must resolve inside the memory root");
|
|
471039
471347
|
return;
|
|
471040
471348
|
}
|
|
471041
|
-
if (!existsSync64(
|
|
471349
|
+
if (!existsSync64(join105(memoryRoot, ".git"))) {
|
|
471042
471350
|
const enabled = await isMemfsEnabledOnServer2(parsed.agent_id);
|
|
471043
471351
|
if (!enabled) {
|
|
471044
471352
|
sendFailure("write_memory_file: memfs is not enabled for this agent");
|
|
471045
471353
|
return;
|
|
471046
471354
|
}
|
|
471047
471355
|
await ensureLocalMemfsCheckout2(parsed.agent_id);
|
|
471048
|
-
if (!existsSync64(
|
|
471356
|
+
if (!existsSync64(join105(memoryRoot, ".git"))) {
|
|
471049
471357
|
sendFailure("write_memory_file: failed to initialize local memory checkout");
|
|
471050
471358
|
return;
|
|
471051
471359
|
}
|
|
@@ -471124,26 +471432,26 @@ function handleMemoryProtocolCommand(parsed, context3) {
|
|
|
471124
471432
|
const { commitMemoryWrite: commitMemoryWrite2 } = await Promise.resolve().then(() => (init_memory_git(), exports_memory_git));
|
|
471125
471433
|
const { unlink: unlink3 } = await import("node:fs/promises");
|
|
471126
471434
|
const { existsSync: existsSync64 } = await import("node:fs");
|
|
471127
|
-
const { isAbsolute: isAbsolute28, join:
|
|
471435
|
+
const { isAbsolute: isAbsolute28, join: join105, normalize: normalize5, relative: relative12, sep: sep9 } = await import("node:path");
|
|
471128
471436
|
if (isAbsolute28(parsed.path) || parsed.path.length === 0) {
|
|
471129
471437
|
sendFailure("delete_memory_file: path must be a non-empty relative path");
|
|
471130
471438
|
return;
|
|
471131
471439
|
}
|
|
471132
471440
|
const memoryRoot = getScopedMemoryFilesystemRoot2(parsed.agent_id);
|
|
471133
|
-
const absolutePath = normalize5(
|
|
471441
|
+
const absolutePath = normalize5(join105(memoryRoot, parsed.path));
|
|
471134
471442
|
const rel = relative12(memoryRoot, absolutePath);
|
|
471135
471443
|
if (rel.startsWith("..") || rel === "" || isAbsolute28(rel) || rel.split(sep9).includes("..")) {
|
|
471136
471444
|
sendFailure("delete_memory_file: path must resolve inside the memory root");
|
|
471137
471445
|
return;
|
|
471138
471446
|
}
|
|
471139
|
-
if (!existsSync64(
|
|
471447
|
+
if (!existsSync64(join105(memoryRoot, ".git"))) {
|
|
471140
471448
|
const enabled = await isMemfsEnabledOnServer2(parsed.agent_id);
|
|
471141
471449
|
if (!enabled) {
|
|
471142
471450
|
sendFailure("delete_memory_file: memfs is not enabled for this agent");
|
|
471143
471451
|
return;
|
|
471144
471452
|
}
|
|
471145
471453
|
await ensureLocalMemfsCheckout2(parsed.agent_id);
|
|
471146
|
-
if (!existsSync64(
|
|
471454
|
+
if (!existsSync64(join105(memoryRoot, ".git"))) {
|
|
471147
471455
|
sendFailure("delete_memory_file: failed to initialize local memory checkout");
|
|
471148
471456
|
return;
|
|
471149
471457
|
}
|
|
@@ -471277,10 +471585,10 @@ __export(exports_remote_model_catalog, {
|
|
|
471277
471585
|
__testResetRemoteModelCatalog: () => __testResetRemoteModelCatalog
|
|
471278
471586
|
});
|
|
471279
471587
|
import { existsSync as existsSync64, mkdirSync as mkdirSync51, readFileSync as readFileSync53, writeFileSync as writeFileSync44 } from "node:fs";
|
|
471280
|
-
import { dirname as dirname39, join as
|
|
471588
|
+
import { dirname as dirname39, join as join105 } from "node:path";
|
|
471281
471589
|
function catalogCachePath() {
|
|
471282
|
-
const dir = process.env.LETTA_MODEL_CATALOG_CACHE_DIR ||
|
|
471283
|
-
return
|
|
471590
|
+
const dir = process.env.LETTA_MODEL_CATALOG_CACHE_DIR || join105(resolveGlobalConfigDir(), "cache");
|
|
471591
|
+
return join105(dir, "model-catalog.json");
|
|
471284
471592
|
}
|
|
471285
471593
|
function normalizeCatalogSource(source) {
|
|
471286
471594
|
try {
|
|
@@ -472465,6 +472773,7 @@ async function handleRuntimeStartCommand(parsed, context3) {
|
|
|
472465
472773
|
expectInboundTeleport(scopedRuntime, parsed.teleport_id);
|
|
472466
472774
|
}
|
|
472467
472775
|
assertConnectionOpen();
|
|
472776
|
+
markLocalTurnScope(scopedRuntime);
|
|
472468
472777
|
subscribeListenerConnection(context3.runtime, connectionId, runtimeScope);
|
|
472469
472778
|
registerRuntimeExternalTools(context3.runtime, connectionId, runtimeScope, parsed.external_tools ?? [], parsed.tool_policy);
|
|
472470
472779
|
if (parsed.wait_for_replay) {
|
|
@@ -472530,6 +472839,7 @@ var init_runtime_start = __esm(() => {
|
|
|
472530
472839
|
init_external_tools();
|
|
472531
472840
|
init_permission_mode();
|
|
472532
472841
|
init_queue();
|
|
472842
|
+
init_runtime6();
|
|
472533
472843
|
init_runtime_start_validation();
|
|
472534
472844
|
init_teleport();
|
|
472535
472845
|
LEGACY_SUMMARY_PREFIX_BY_SOURCE_TAG = {
|
|
@@ -472700,7 +473010,7 @@ async function handleSkillCommand(parsed, socket, safeSocketSend) {
|
|
|
472700
473010
|
symlinkSync: symlinkSync2,
|
|
472701
473011
|
unlinkSync: unlinkSync19
|
|
472702
473012
|
} = await import("node:fs");
|
|
472703
|
-
const { basename: basename31, join:
|
|
473013
|
+
const { basename: basename31, join: join106 } = await import("node:path");
|
|
472704
473014
|
const globalSkillsDir = getGlobalSkillsDir();
|
|
472705
473015
|
if (parsed.type === "skill_enable") {
|
|
472706
473016
|
try {
|
|
@@ -472713,7 +473023,7 @@ async function handleSkillCommand(parsed, socket, safeSocketSend) {
|
|
|
472713
473023
|
}, "listener_skill_send_failed", "listener_skill_command");
|
|
472714
473024
|
return true;
|
|
472715
473025
|
}
|
|
472716
|
-
const skillMdPath =
|
|
473026
|
+
const skillMdPath = join106(parsed.skill_path, "SKILL.md");
|
|
472717
473027
|
if (!existsSync65(skillMdPath)) {
|
|
472718
473028
|
safeSocketSend(socket, {
|
|
472719
473029
|
type: "skill_enable_response",
|
|
@@ -472724,7 +473034,7 @@ async function handleSkillCommand(parsed, socket, safeSocketSend) {
|
|
|
472724
473034
|
return true;
|
|
472725
473035
|
}
|
|
472726
473036
|
const linkName = basename31(parsed.skill_path);
|
|
472727
|
-
const linkPath =
|
|
473037
|
+
const linkPath = join106(globalSkillsDir, linkName);
|
|
472728
473038
|
mkdirSync52(globalSkillsDir, { recursive: true });
|
|
472729
473039
|
if (existsSync65(linkPath)) {
|
|
472730
473040
|
const stat14 = lstatSync4(linkPath);
|
|
@@ -472767,7 +473077,7 @@ async function handleSkillCommand(parsed, socket, safeSocketSend) {
|
|
|
472767
473077
|
}
|
|
472768
473078
|
if (parsed.type === "skill_disable") {
|
|
472769
473079
|
try {
|
|
472770
|
-
const linkPath =
|
|
473080
|
+
const linkPath = join106(globalSkillsDir, parsed.name);
|
|
472771
473081
|
if (!existsSync65(linkPath)) {
|
|
472772
473082
|
safeSocketSend(socket, {
|
|
472773
473083
|
type: "skill_disable_response",
|
|
@@ -473455,6 +473765,7 @@ async function routeInputFrame(deps) {
|
|
|
473455
473765
|
var init_input_frame_router = __esm(() => {
|
|
473456
473766
|
init_mcp_originator_tokens();
|
|
473457
473767
|
init_inbound_dispatch();
|
|
473768
|
+
init_inbound_queue();
|
|
473458
473769
|
init_input_ack();
|
|
473459
473770
|
init_input_disposition();
|
|
473460
473771
|
init_input_disposition_rollback();
|
|
@@ -474249,7 +474560,14 @@ async function handleTaskControlCommand(command, context3) {
|
|
|
474249
474560
|
safeSocketSend(socket, response2, response2.type, command.type);
|
|
474250
474561
|
return;
|
|
474251
474562
|
}
|
|
474252
|
-
const
|
|
474563
|
+
const { agent_id, conversation_id } = command.runtime;
|
|
474564
|
+
const sidebandOnly = command.type !== "launch_subagent" || command.notify === "caller";
|
|
474565
|
+
if (sidebandOnly && !getConversationRuntime(runtime, agent_id, conversation_id)) {
|
|
474566
|
+
markSidebandOnlyScope(runtime, getConversationRuntimeKey(agent_id, conversation_id));
|
|
474567
|
+
}
|
|
474568
|
+
const parent = getOrCreateScopedRuntime2(runtime, agent_id, conversation_id);
|
|
474569
|
+
if (!sidebandOnly)
|
|
474570
|
+
markLocalTurnScope(parent);
|
|
474253
474571
|
const response = command.type === "launch_subagent" ? await handleLaunchSubagentCommand(command, parent, connectionId) : command.type === "subagent_message" ? await handleSubagentMessageCommand(command, parent) : await handleSubagentStopCommand(command, parent);
|
|
474254
474572
|
sendReply(response);
|
|
474255
474573
|
};
|
|
@@ -474260,6 +474578,7 @@ async function handleTaskControlCommand(command, context3) {
|
|
|
474260
474578
|
}
|
|
474261
474579
|
}
|
|
474262
474580
|
var init_task_control = __esm(() => {
|
|
474581
|
+
init_runtime6();
|
|
474263
474582
|
init_monitors2();
|
|
474264
474583
|
init_stop_conversation();
|
|
474265
474584
|
init_subagent_control();
|
|
@@ -474794,7 +475113,7 @@ var init_message_router = __esm(() => {
|
|
|
474794
475113
|
});
|
|
474795
475114
|
|
|
474796
475115
|
// src/websocket/listener/process-services.ts
|
|
474797
|
-
import { join as
|
|
475116
|
+
import { join as join106 } from "node:path";
|
|
474798
475117
|
function installProcessEventRouting(params) {
|
|
474799
475118
|
const { runtime, processTransport, opts, processQueuedTurn } = params;
|
|
474800
475119
|
runtime._unsubscribeSubagentState?.();
|
|
@@ -474883,7 +475202,8 @@ function installProcessEventRouting(params) {
|
|
|
474883
475202
|
setMessageQueueAdder((queuedMessage) => {
|
|
474884
475203
|
if (!queuedMessage.agentId || !queuedMessage.conversationId)
|
|
474885
475204
|
return;
|
|
474886
|
-
|
|
475205
|
+
const key4 = getConversationRuntimeKey(queuedMessage.agentId, queuedMessage.conversationId);
|
|
475206
|
+
if (isSidebandOnlyScope(runtime, key4) || isRuntimeTeleportPending(runtime, queuedMessage.agentId, queuedMessage.conversationId))
|
|
474887
475207
|
return;
|
|
474888
475208
|
const targetRuntime = getOrCreateScopedRuntime(runtime, queuedMessage.agentId, queuedMessage.conversationId);
|
|
474889
475209
|
if (!targetRuntime?.queueRuntime)
|
|
@@ -474901,7 +475221,7 @@ function installProcessEventRouting(params) {
|
|
|
474901
475221
|
scheduleQueuePump(targetRuntime, processTransport, opts, processQueuedTurn);
|
|
474902
475222
|
});
|
|
474903
475223
|
runtime._stopDiskSpaceWatch?.();
|
|
474904
|
-
runtime._stopDiskSpaceWatch = watchSandboxDiskSpace(getCurrentWorkingDirectory, (text3) => deliverSandboxDiskAlert(runtime, text3), { reserveDirectory:
|
|
475224
|
+
runtime._stopDiskSpaceWatch = watchSandboxDiskSpace(getCurrentWorkingDirectory, (text3) => deliverSandboxDiskAlert(runtime, text3), { reserveDirectory: join106(resolveGlobalConfigDir(), "state") });
|
|
474905
475225
|
}
|
|
474906
475226
|
function deliverSandboxDiskAlert(runtime, text3) {
|
|
474907
475227
|
const target = getMostRecentlyActiveConversation(runtime);
|
|
@@ -474911,7 +475231,7 @@ function getMostRecentlyActiveConversation(runtime) {
|
|
|
474911
475231
|
let latest = null;
|
|
474912
475232
|
let latestAt = -1;
|
|
474913
475233
|
for (const conversationRuntime of runtime.conversationRuntimes.values()) {
|
|
474914
|
-
if (!conversationRuntime.agentId)
|
|
475234
|
+
if (!conversationRuntime.agentId || isSidebandOnlyScope(runtime, conversationRuntime.key))
|
|
474915
475235
|
continue;
|
|
474916
475236
|
const activeAt = conversationRuntime.isProcessing ? Number.POSITIVE_INFINITY : conversationRuntime.contextTracker.contextTokensHistory.at(-1)?.timestamp ?? 0;
|
|
474917
475237
|
if (activeAt > latestAt) {
|
|
@@ -475947,7 +476267,12 @@ async function recoverApprovalStateForSync(runtime, scope, deps = {}, opts = {})
|
|
|
475947
476267
|
clearRecoveredApprovalState(runtime);
|
|
475948
476268
|
return "deferred";
|
|
475949
476269
|
}
|
|
475950
|
-
runtime.pendingInterruptedResults =
|
|
476270
|
+
runtime.pendingInterruptedResults = staleDenialDecisions.filter((decision) => decision.type === "deny").map(({ approval, reason }) => ({
|
|
476271
|
+
type: "approval",
|
|
476272
|
+
tool_call_id: approval.toolCallId,
|
|
476273
|
+
approve: false,
|
|
476274
|
+
reason
|
|
476275
|
+
}));
|
|
475951
476276
|
runtime.pendingInterruptedContext = {
|
|
475952
476277
|
agentId: scope.agent_id,
|
|
475953
476278
|
conversationId: scope.conversation_id,
|
|
@@ -475988,7 +476313,8 @@ var init_recovery_sync = __esm(() => {
|
|
|
475988
476313
|
async function replaySyncStateForRuntime(listenerRuntime, socket, scope, opts) {
|
|
475989
476314
|
const syncScopedRuntime = getOrCreateScopedRuntime(listenerRuntime, scope.agent_id, scope.conversation_id);
|
|
475990
476315
|
const recoverFn = opts?.recoverApprovalStateForSync ?? recoverApprovalStateForSync;
|
|
475991
|
-
|
|
476316
|
+
const canRecover = !isSidebandOnlyScope(listenerRuntime, syncScopedRuntime.key);
|
|
476317
|
+
if (canRecover && (opts?.recoverApprovals ?? true)) {
|
|
475992
476318
|
try {
|
|
475993
476319
|
await recoverFn(syncScopedRuntime, scope, undefined, {
|
|
475994
476320
|
resumeInterruptedTurn: opts?.resumeInterruptedTurn === true
|
|
@@ -476004,7 +476330,7 @@ async function replaySyncStateForRuntime(listenerRuntime, socket, scope, opts) {
|
|
|
476004
476330
|
}
|
|
476005
476331
|
}
|
|
476006
476332
|
}
|
|
476007
|
-
if (syncScopedRuntime.recoveredApprovalState && (syncScopedRuntime.recoveredApprovalState.autoDecisions?.length ?? 0) > 0) {
|
|
476333
|
+
if (canRecover && syncScopedRuntime.recoveredApprovalState && (syncScopedRuntime.recoveredApprovalState.autoDecisions?.length ?? 0) > 0) {
|
|
476008
476334
|
let signalLeaseReady;
|
|
476009
476335
|
let releaseLeaseBarrier;
|
|
476010
476336
|
const leaseReady = new Promise((resolve39) => {
|
|
@@ -476053,6 +476379,7 @@ var init_sync_replay = __esm(() => {
|
|
|
476053
476379
|
init_conversation_runtime();
|
|
476054
476380
|
init_recovery();
|
|
476055
476381
|
init_recovery_sync();
|
|
476382
|
+
init_runtime6();
|
|
476056
476383
|
init_turn();
|
|
476057
476384
|
init_warmup();
|
|
476058
476385
|
});
|
|
@@ -478468,7 +478795,7 @@ import {
|
|
|
478468
478795
|
readdirSync as readdirSync27,
|
|
478469
478796
|
unlinkSync as unlinkSync19
|
|
478470
478797
|
} from "node:fs";
|
|
478471
|
-
import { join as
|
|
478798
|
+
import { join as join107 } from "node:path";
|
|
478472
478799
|
function formatTimestamp2() {
|
|
478473
478800
|
const now2 = new Date;
|
|
478474
478801
|
const h3 = String(now2.getHours()).padStart(2, "0");
|
|
@@ -478489,7 +478816,7 @@ function pruneOldLogs(dir, maxFiles) {
|
|
|
478489
478816
|
const toDelete = files.slice(0, files.length - maxFiles + 1);
|
|
478490
478817
|
for (const file of toDelete) {
|
|
478491
478818
|
try {
|
|
478492
|
-
unlinkSync19(
|
|
478819
|
+
unlinkSync19(join107(dir, file));
|
|
478493
478820
|
} catch {}
|
|
478494
478821
|
}
|
|
478495
478822
|
}
|
|
@@ -478528,7 +478855,7 @@ class RemoteSessionLog {
|
|
|
478528
478855
|
freshPath() {
|
|
478529
478856
|
const stamp = formatFileTimestamp(new Date);
|
|
478530
478857
|
const suffix = this.rotation > 0 ? `.${this.rotation}` : "";
|
|
478531
|
-
return
|
|
478858
|
+
return join107(this.dir, `${stamp}${suffix}.log`);
|
|
478532
478859
|
}
|
|
478533
478860
|
rotate() {
|
|
478534
478861
|
const previous = this.path;
|
|
@@ -478569,13 +478896,13 @@ var REMOTE_LOG_DIR, MAX_LOG_FILES = 10, MAX_LOG_BYTES2;
|
|
|
478569
478896
|
var init_listen_log = __esm(() => {
|
|
478570
478897
|
init_settings_path();
|
|
478571
478898
|
init_ws_event_redaction();
|
|
478572
|
-
REMOTE_LOG_DIR =
|
|
478899
|
+
REMOTE_LOG_DIR = join107(resolveGlobalConfigDir(), "logs", "remote");
|
|
478573
478900
|
MAX_LOG_BYTES2 = 10 * 1024 * 1024;
|
|
478574
478901
|
});
|
|
478575
478902
|
|
|
478576
478903
|
// src/websocket/listener/manual-instance-lock.ts
|
|
478577
478904
|
import { createHash as createHash22, randomUUID as randomUUID61 } from "node:crypto";
|
|
478578
|
-
import { link as link4, mkdir as mkdir16, readFile as readFile28, rm as
|
|
478905
|
+
import { link as link4, mkdir as mkdir16, readFile as readFile28, rm as rm14, unlink as unlink3, writeFile as writeFile17 } from "node:fs/promises";
|
|
478579
478906
|
import { uptime as uptime2 } from "node:os";
|
|
478580
478907
|
import path46 from "node:path";
|
|
478581
478908
|
function hasErrorCode3(error4, code) {
|
|
@@ -478649,7 +478976,7 @@ async function publishInitializedFile(targetPath, contents) {
|
|
|
478649
478976
|
} catch (error4) {
|
|
478650
478977
|
publicationError = error4;
|
|
478651
478978
|
}
|
|
478652
|
-
await
|
|
478979
|
+
await rm14(candidatePath, { force: true }).catch(() => {});
|
|
478653
478980
|
return publicationError;
|
|
478654
478981
|
}
|
|
478655
478982
|
function getRecoveryClaimPath2(lockPath, staleContents, depth) {
|
|
@@ -478658,7 +478985,7 @@ function getRecoveryClaimPath2(lockPath, staleContents, depth) {
|
|
|
478658
478985
|
}
|
|
478659
478986
|
async function cleanupRecoveryClaims2(lockPath, staleContents, deepestClaim) {
|
|
478660
478987
|
for (let depth = deepestClaim;depth >= 0; depth--) {
|
|
478661
|
-
await
|
|
478988
|
+
await rm14(getRecoveryClaimPath2(lockPath, staleContents, depth), {
|
|
478662
478989
|
force: true
|
|
478663
478990
|
}).catch(() => {});
|
|
478664
478991
|
}
|
|
@@ -480300,7 +480627,7 @@ import {
|
|
|
480300
480627
|
readFileSync as readFileSync54,
|
|
480301
480628
|
writeFileSync as writeFileSync45
|
|
480302
480629
|
} from "node:fs";
|
|
480303
|
-
import { join as
|
|
480630
|
+
import { join as join108 } from "node:path";
|
|
480304
480631
|
function readJsonl(path47) {
|
|
480305
480632
|
if (!existsSync66(path47))
|
|
480306
480633
|
return [];
|
|
@@ -480583,7 +480910,7 @@ function convertMessages4(messages, mode, nextId2) {
|
|
|
480583
480910
|
}
|
|
480584
480911
|
function migrateLocalBackendTranscripts(input) {
|
|
480585
480912
|
const storageDir = input.storageDir;
|
|
480586
|
-
const conversationsDir =
|
|
480913
|
+
const conversationsDir = join108(storageDir, "conversations");
|
|
480587
480914
|
const result3 = {
|
|
480588
480915
|
storageDir,
|
|
480589
480916
|
converted: [],
|
|
@@ -480593,9 +480920,9 @@ function migrateLocalBackendTranscripts(input) {
|
|
|
480593
480920
|
if (!existsSync66(conversationsDir))
|
|
480594
480921
|
return result3;
|
|
480595
480922
|
for (const name of readdirSync28(conversationsDir)) {
|
|
480596
|
-
const conversationDir =
|
|
480597
|
-
const messagesPath =
|
|
480598
|
-
const manifestPath =
|
|
480923
|
+
const conversationDir = join108(conversationsDir, name);
|
|
480924
|
+
const messagesPath = join108(conversationDir, "messages.jsonl");
|
|
480925
|
+
const manifestPath = join108(conversationDir, "manifest.json");
|
|
480599
480926
|
const hasManifest = existsSync66(manifestPath);
|
|
480600
480927
|
const existingManifest = hasManifest ? (() => {
|
|
480601
480928
|
try {
|
|
@@ -480638,7 +480965,7 @@ function migrateLocalBackendTranscripts(input) {
|
|
|
480638
480965
|
const backupPath = `${messagesPath}.pre-pi-backup-${timestampSuffix()}`;
|
|
480639
480966
|
if (!input.dryRun) {
|
|
480640
480967
|
copyFileSync3(messagesPath, backupPath);
|
|
480641
|
-
const conversationPath =
|
|
480968
|
+
const conversationPath = join108(conversationDir, "conversation.json");
|
|
480642
480969
|
let conversation;
|
|
480643
480970
|
if (existsSync66(conversationPath)) {
|
|
480644
480971
|
try {
|
|
@@ -480836,7 +481163,7 @@ var init_memory_tokens = __esm(() => {
|
|
|
480836
481163
|
// src/cli/subcommands/memory.ts
|
|
480837
481164
|
import { cpSync, existsSync as existsSync67, mkdirSync as mkdirSync54, rmSync as rmSync24, statSync as statSync26 } from "node:fs";
|
|
480838
481165
|
import { readdir as readdir12 } from "node:fs/promises";
|
|
480839
|
-
import { dirname as dirname40, join as
|
|
481166
|
+
import { dirname as dirname40, join as join109 } from "node:path";
|
|
480840
481167
|
import { parseArgs as parseArgs12 } from "node:util";
|
|
480841
481168
|
function printUsage8() {
|
|
480842
481169
|
console.log(`
|
|
@@ -480906,7 +481233,7 @@ async function listBackups(agentId) {
|
|
|
480906
481233
|
continue;
|
|
480907
481234
|
if (!entry.name.startsWith("memory-backup-"))
|
|
480908
481235
|
continue;
|
|
480909
|
-
const path47 =
|
|
481236
|
+
const path47 = join109(agentRoot, entry.name);
|
|
480910
481237
|
let createdAt = null;
|
|
480911
481238
|
try {
|
|
480912
481239
|
const stat14 = statSync26(path47);
|
|
@@ -480923,7 +481250,7 @@ function resolveBackupPath(agentId, from) {
|
|
|
480923
481250
|
if (from.startsWith("/") || /^[A-Za-z]:[/\\]/.test(from)) {
|
|
480924
481251
|
return from;
|
|
480925
481252
|
}
|
|
480926
|
-
return
|
|
481253
|
+
return join109(getAgentRoot(agentId), from);
|
|
480927
481254
|
}
|
|
480928
481255
|
async function runMemorySubcommand(argv, deps = {}) {
|
|
480929
481256
|
let parsed;
|
|
@@ -481007,7 +481334,7 @@ async function runMemorySubcommand(argv, deps = {}) {
|
|
|
481007
481334
|
}
|
|
481008
481335
|
const agentRoot = getAgentRoot(agentId);
|
|
481009
481336
|
const backupName = `memory-backup-${formatBackupTimestamp()}`;
|
|
481010
|
-
const backupPath =
|
|
481337
|
+
const backupPath = join109(agentRoot, backupName);
|
|
481011
481338
|
if (existsSync67(backupPath)) {
|
|
481012
481339
|
console.error(`Backup already exists at ${backupPath}`);
|
|
481013
481340
|
return 1;
|
|
@@ -481108,7 +481435,7 @@ var init_memory6 = __esm(() => {
|
|
|
481108
481435
|
|
|
481109
481436
|
// src/backend/local/transcript-search.ts
|
|
481110
481437
|
import { existsSync as existsSync68, readdirSync as readdirSync29, readFileSync as readFileSync55, statSync as statSync27 } from "node:fs";
|
|
481111
|
-
import { join as
|
|
481438
|
+
import { join as join110 } from "node:path";
|
|
481112
481439
|
function readJsonFile3(path47) {
|
|
481113
481440
|
if (!existsSync68(path47))
|
|
481114
481441
|
return;
|
|
@@ -481353,7 +481680,7 @@ function collectConversationMessages(input) {
|
|
|
481353
481680
|
return [];
|
|
481354
481681
|
if (input.conversationId && conversation.id !== input.conversationId)
|
|
481355
481682
|
return [];
|
|
481356
|
-
const manifest2 = readJsonFile3(
|
|
481683
|
+
const manifest2 = readJsonFile3(join110(conversationDir, "manifest.json"));
|
|
481357
481684
|
let format3 = transcriptFormatFromManifest(manifest2);
|
|
481358
481685
|
const records2 = [];
|
|
481359
481686
|
const echoToolCallIds = [];
|
|
@@ -481413,7 +481740,7 @@ function collectConversationMessages(input) {
|
|
|
481413
481740
|
}
|
|
481414
481741
|
addRow(row, rowIndex);
|
|
481415
481742
|
};
|
|
481416
|
-
const messagesPath =
|
|
481743
|
+
const messagesPath = join110(conversationDir, "messages.jsonl");
|
|
481417
481744
|
let rowError;
|
|
481418
481745
|
try {
|
|
481419
481746
|
forEachJsonlRow(messagesPath, (row) => {
|
|
@@ -481442,11 +481769,11 @@ function collectConversationMessages(input) {
|
|
|
481442
481769
|
return records2;
|
|
481443
481770
|
}
|
|
481444
481771
|
function conversationDirectories(storageDir) {
|
|
481445
|
-
const conversationsDir =
|
|
481772
|
+
const conversationsDir = join110(storageDir, "conversations");
|
|
481446
481773
|
if (!existsSync68(conversationsDir))
|
|
481447
481774
|
return [];
|
|
481448
481775
|
try {
|
|
481449
|
-
return readdirSync29(conversationsDir).map((entry) =>
|
|
481776
|
+
return readdirSync29(conversationsDir).map((entry) => join110(conversationsDir, entry)).filter((entryPath) => statSync27(entryPath).isDirectory());
|
|
481450
481777
|
} catch {
|
|
481451
481778
|
return [];
|
|
481452
481779
|
}
|
|
@@ -481473,7 +481800,7 @@ function searchLocalTranscriptMessages(storageDir, body3, options = {}) {
|
|
|
481473
481800
|
const endDate = typeof body3.end_date === "string" ? body3.end_date : undefined;
|
|
481474
481801
|
const includeHidden = body3.include_hidden === true;
|
|
481475
481802
|
const records2 = conversationDirectories(storageDir).flatMap((conversationDir) => {
|
|
481476
|
-
const conversation = conversationSearchRecord(readJsonFile3(
|
|
481803
|
+
const conversation = conversationSearchRecord(readJsonFile3(join110(conversationDir, "conversation.json")));
|
|
481477
481804
|
if (!conversation)
|
|
481478
481805
|
return [];
|
|
481479
481806
|
if (conversation.hidden && !includeHidden)
|
|
@@ -482035,11 +482362,13 @@ function listNativeModels(worker, cwd2, env6) {
|
|
|
482035
482362
|
return listCodexModels(cwd2, env6);
|
|
482036
482363
|
if (worker === "cursor")
|
|
482037
482364
|
return listCursorModels(cwd2, env6);
|
|
482365
|
+
if (worker === "antigravity")
|
|
482366
|
+
return listAntigravityModels(cwd2, env6);
|
|
482038
482367
|
return listClaudeModels(cwd2, env6);
|
|
482039
482368
|
}
|
|
482040
482369
|
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
|
|
482370
|
+
if (!["claude-code", "codex", "opencode", "cursor", "antigravity"].includes(worker))
|
|
482371
|
+
throw new Error("--worker must be claude-code, codex, opencode, cursor, or antigravity");
|
|
482043
482372
|
const baseEnv = deps.env ?? process.env;
|
|
482044
482373
|
const agentId = baseEnv.AGENT_ID ?? baseEnv.LETTA_AGENT_ID;
|
|
482045
482374
|
const secrets2 = agentId ? await resolveExternalCodingAgentSecretEnv(agentId) : {};
|
|
@@ -482067,7 +482396,7 @@ async function listExternalWorkerModels(worker, deps = {}) {
|
|
|
482067
482396
|
for (const model2 of catalog2) {
|
|
482068
482397
|
if (!isRecord2(model2))
|
|
482069
482398
|
throw new Error("Invalid native model catalog entry");
|
|
482070
|
-
const id = worker === "codex" ? model2.model : worker === "cursor" ? model2.id : model2.value;
|
|
482399
|
+
const id = worker === "codex" ? model2.model : worker === "cursor" || worker === "antigravity" ? model2.id : model2.value;
|
|
482071
482400
|
if (typeof id !== "string" || typeof model2.displayName !== "string")
|
|
482072
482401
|
throw new Error("Native model catalog entry is missing its ID or name");
|
|
482073
482402
|
const aliases = Array.isArray(model2.aliases) ? model2.aliases.filter((alias) => typeof alias === "string") : [];
|
|
@@ -482090,6 +482419,7 @@ var init_external_worker_models = __esm(() => {
|
|
|
482090
482419
|
init_subagent_process();
|
|
482091
482420
|
init_secret_substitution();
|
|
482092
482421
|
init_native_cli_env();
|
|
482422
|
+
init_antigravity_acp();
|
|
482093
482423
|
init_codex_app_server();
|
|
482094
482424
|
init_cursor_session();
|
|
482095
482425
|
init_external_coding_agent();
|
|
@@ -482102,7 +482432,7 @@ function printUsage10() {
|
|
|
482102
482432
|
console.log(`Usage:
|
|
482103
482433
|
letta model get [--default] [--agent <id> | --conversation <id>]
|
|
482104
482434
|
letta model list [--byok | --hosted] [--structured-outputs]
|
|
482105
|
-
letta model list --worker <claude-code|codex|opencode|cursor>
|
|
482435
|
+
letta model list --worker <claude-code|codex|opencode|cursor|antigravity>
|
|
482106
482436
|
letta model set [handle] [--reasoning <level>] [--model-settings <json>] [--default] [--agent <id> | --conversation <id>]
|
|
482107
482437
|
|
|
482108
482438
|
get Show the effective model, context limit, and full redacted model_settings.
|
|
@@ -482516,7 +482846,7 @@ import {
|
|
|
482516
482846
|
rmSync as rmSync25,
|
|
482517
482847
|
writeFileSync as writeFileSync46
|
|
482518
482848
|
} from "node:fs";
|
|
482519
|
-
import { tmpdir as
|
|
482849
|
+
import { tmpdir as tmpdir16 } from "node:os";
|
|
482520
482850
|
import path47 from "node:path";
|
|
482521
482851
|
function isRecord21(value) {
|
|
482522
482852
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -483230,7 +483560,7 @@ function installLocalManagedModPackage(params) {
|
|
|
483230
483560
|
}
|
|
483231
483561
|
async function installNpmManagedModPackage(params) {
|
|
483232
483562
|
const parsed = parseNpmManagedModPackageInstallSpecifier(params.specifier);
|
|
483233
|
-
const tempRoot = mkdtempSync5(path47.join(
|
|
483563
|
+
const tempRoot = mkdtempSync5(path47.join(tmpdir16(), "letta-mod-npm-"));
|
|
483234
483564
|
try {
|
|
483235
483565
|
writeNpmInstallManifest(tempRoot);
|
|
483236
483566
|
await runNpmInstall({
|
|
@@ -483254,7 +483584,7 @@ async function installGitManagedModPackage(params) {
|
|
|
483254
483584
|
if (!parsed) {
|
|
483255
483585
|
throw new Error(`Invalid git mod package specifier: ${params.specifier}`);
|
|
483256
483586
|
}
|
|
483257
|
-
const tempRoot = mkdtempSync5(path47.join(
|
|
483587
|
+
const tempRoot = mkdtempSync5(path47.join(tmpdir16(), "letta-mod-git-"));
|
|
483258
483588
|
try {
|
|
483259
483589
|
const packageDirectory = path47.join(tempRoot, "repo");
|
|
483260
483590
|
const revision = await checkoutGitPackage({
|
|
@@ -483287,7 +483617,7 @@ async function updateNpmManagedModPackage(params) {
|
|
|
483287
483617
|
modsRoot: params.modsRoot,
|
|
483288
483618
|
specifier: parsed.source
|
|
483289
483619
|
}).package;
|
|
483290
|
-
const tempRoot = mkdtempSync5(path47.join(
|
|
483620
|
+
const tempRoot = mkdtempSync5(path47.join(tmpdir16(), "letta-mod-npm-"));
|
|
483291
483621
|
try {
|
|
483292
483622
|
writeNpmInstallManifest(tempRoot);
|
|
483293
483623
|
await runNpmInstall({
|
|
@@ -483321,7 +483651,7 @@ async function updateGitManagedModPackage(params) {
|
|
|
483321
483651
|
modsRoot: params.modsRoot,
|
|
483322
483652
|
specifier: parsed.source
|
|
483323
483653
|
}).package;
|
|
483324
|
-
const tempRoot = mkdtempSync5(path47.join(
|
|
483654
|
+
const tempRoot = mkdtempSync5(path47.join(tmpdir16(), "letta-mod-git-"));
|
|
483325
483655
|
try {
|
|
483326
483656
|
const packageDirectory = path47.join(tempRoot, "repo");
|
|
483327
483657
|
const revision = await checkoutGitPackage({
|
|
@@ -483502,7 +483832,7 @@ var init_package_scaffolder = __esm(() => {
|
|
|
483502
483832
|
});
|
|
483503
483833
|
|
|
483504
483834
|
// src/cli/subcommands/mods.ts
|
|
483505
|
-
import { dirname as dirname41, join as
|
|
483835
|
+
import { dirname as dirname41, join as join111 } from "node:path";
|
|
483506
483836
|
import { parseArgs as parseArgs15 } from "node:util";
|
|
483507
483837
|
function printUsage11() {
|
|
483508
483838
|
console.log(`
|
|
@@ -483541,7 +483871,7 @@ function getExplicitAgentId(values4) {
|
|
|
483541
483871
|
return typeof explicitAgent === "string" && explicitAgent.trim() ? explicitAgent.trim() : null;
|
|
483542
483872
|
}
|
|
483543
483873
|
function getAgentModsDirectory(agentId) {
|
|
483544
|
-
return
|
|
483874
|
+
return join111(getScopedMemoryFilesystemRoot(agentId), "mods");
|
|
483545
483875
|
}
|
|
483546
483876
|
function directFilesForSource(source) {
|
|
483547
483877
|
return source.files.filter((file) => dirname41(file) === source.root);
|
|
@@ -485184,7 +485514,7 @@ var init_setup7 = __esm(async () => {
|
|
|
485184
485514
|
|
|
485185
485515
|
// src/cli/subcommands/shared-memory.ts
|
|
485186
485516
|
import { existsSync as existsSync71 } from "node:fs";
|
|
485187
|
-
import { join as
|
|
485517
|
+
import { join as join112 } from "node:path";
|
|
485188
485518
|
import { parseArgs as parseArgs20 } from "node:util";
|
|
485189
485519
|
function printUsage16() {
|
|
485190
485520
|
console.log(`
|
|
@@ -485391,7 +485721,7 @@ async function runSharedMemorySubcommand(argv, deps = {}) {
|
|
|
485391
485721
|
invalidateClientSkills(agentId);
|
|
485392
485722
|
const recompileError = await recompileAndReportFailure(recompileAgent, agentId);
|
|
485393
485723
|
const mountDir = getRepositoryMountDir(agentId, repository.name);
|
|
485394
|
-
const mounted = existsSync71(
|
|
485724
|
+
const mounted = existsSync71(join112(mountDir, ".git"));
|
|
485395
485725
|
console.log(JSON.stringify({
|
|
485396
485726
|
attached: true,
|
|
485397
485727
|
repository: { id: repository.id, name: repository.name },
|
|
@@ -486982,8 +487312,8 @@ import {
|
|
|
486982
487312
|
writeFileSync as writeFileSync48
|
|
486983
487313
|
} from "node:fs";
|
|
486984
487314
|
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
|
|
487315
|
+
import { tmpdir as tmpdir17 } from "node:os";
|
|
487316
|
+
import { basename as basename32, dirname as dirname42, join as join113, normalize as normalize5, resolve as resolve41, sep as sep9 } from "node:path";
|
|
486987
487317
|
import { parseArgs as parseArgs21, TextDecoder as TextDecoder2, TextEncoder as TextEncoder2 } from "node:util";
|
|
486988
487318
|
function printUsage17() {
|
|
486989
487319
|
console.log(`
|
|
@@ -487254,14 +487584,14 @@ async function resolveBranchAndSubdir(location) {
|
|
|
487254
487584
|
}
|
|
487255
487585
|
async function cloneSkillSource(location) {
|
|
487256
487586
|
const resolvedLocation = await resolveBranchAndSubdir(location);
|
|
487257
|
-
const tmpDir = mkdtempSync6(
|
|
487587
|
+
const tmpDir = mkdtempSync6(join113(tmpdir17(), "letta-skill-install-"));
|
|
487258
487588
|
const args = ["clone", "--depth", "1"];
|
|
487259
487589
|
if (resolvedLocation.branch) {
|
|
487260
487590
|
args.push("--branch", resolvedLocation.branch);
|
|
487261
487591
|
}
|
|
487262
487592
|
args.push(resolvedLocation.repoUrl, tmpDir);
|
|
487263
487593
|
await execFile22("git", args, { timeout: 120000 });
|
|
487264
|
-
const sourceDir = resolvedLocation.subdir ?
|
|
487594
|
+
const sourceDir = resolvedLocation.subdir ? join113(tmpDir, resolvedLocation.subdir) : tmpDir;
|
|
487265
487595
|
return { tmpDir, sourceDir };
|
|
487266
487596
|
}
|
|
487267
487597
|
function assertDirectSkillFileSize(receivedBytes, maxBytes) {
|
|
@@ -487316,11 +487646,11 @@ async function downloadDirectSkillFileSource(location, options = {}) {
|
|
|
487316
487646
|
throw new Error(`Direct skill file download failed for ${location.url}: ${response.status}`);
|
|
487317
487647
|
}
|
|
487318
487648
|
const skillText = await readResponseTextWithLimit(response, MAX_DIRECT_SKILL_FILE_BYTES);
|
|
487319
|
-
const tmpDir = mkdtempSync6(
|
|
487649
|
+
const tmpDir = mkdtempSync6(join113(tmpdir17(), "letta-direct-skill-"));
|
|
487320
487650
|
try {
|
|
487321
|
-
const sourceDir =
|
|
487651
|
+
const sourceDir = join113(tmpDir, "skill");
|
|
487322
487652
|
await mkdir17(sourceDir, { recursive: true });
|
|
487323
|
-
writeFileSync48(
|
|
487653
|
+
writeFileSync48(join113(sourceDir, "SKILL.md"), skillText, "utf8");
|
|
487324
487654
|
return { tmpDir, sourceDir };
|
|
487325
487655
|
} catch (error4) {
|
|
487326
487656
|
rmSync27(tmpDir, { recursive: true, force: true });
|
|
@@ -487361,9 +487691,9 @@ function assertSafeZipMember(name) {
|
|
|
487361
487691
|
}
|
|
487362
487692
|
async function downloadClawHubSkillSource(location) {
|
|
487363
487693
|
const version3 = await resolveClawHubVersion(location);
|
|
487364
|
-
const tmpDir = mkdtempSync6(
|
|
487365
|
-
const zipPath =
|
|
487366
|
-
const sourceDir =
|
|
487694
|
+
const tmpDir = mkdtempSync6(join113(tmpdir17(), "letta-clawhub-skill-"));
|
|
487695
|
+
const zipPath = join113(tmpDir, "skill.zip");
|
|
487696
|
+
const sourceDir = join113(tmpDir, "skill");
|
|
487367
487697
|
await mkdir17(sourceDir, { recursive: true });
|
|
487368
487698
|
const url2 = new URL(`${CLAWHUB_API_BASE_URL}/download`);
|
|
487369
487699
|
url2.searchParams.set("slug", location.slug);
|
|
@@ -487402,7 +487732,7 @@ function sanitizeSkillName(name) {
|
|
|
487402
487732
|
return trimmed;
|
|
487403
487733
|
}
|
|
487404
487734
|
function getSkillName(sourceDir) {
|
|
487405
|
-
const skillMd = readFileSync57(
|
|
487735
|
+
const skillMd = readFileSync57(join113(sourceDir, "SKILL.md"), "utf8");
|
|
487406
487736
|
const { frontmatter } = parseFrontmatter(skillMd);
|
|
487407
487737
|
const frontmatterName = frontmatter.name;
|
|
487408
487738
|
const name = typeof frontmatterName === "string" && frontmatterName.trim() ? frontmatterName : basename32(sourceDir);
|
|
@@ -487411,7 +487741,7 @@ function getSkillName(sourceDir) {
|
|
|
487411
487741
|
async function installSkillDirectory(params) {
|
|
487412
487742
|
const sourceDir = resolve41(params.sourceDir);
|
|
487413
487743
|
const memoryDir = resolve41(params.memoryDir);
|
|
487414
|
-
const skillMdPath =
|
|
487744
|
+
const skillMdPath = join113(sourceDir, "SKILL.md");
|
|
487415
487745
|
if (!existsSync72(skillMdPath)) {
|
|
487416
487746
|
throw new Error("No SKILL.md found in the skill directory.");
|
|
487417
487747
|
}
|
|
@@ -487419,8 +487749,8 @@ async function installSkillDirectory(params) {
|
|
|
487419
487749
|
throw new Error(`Skill source is not a directory: ${sourceDir}`);
|
|
487420
487750
|
}
|
|
487421
487751
|
const name = getSkillName(sourceDir);
|
|
487422
|
-
const skillsDir =
|
|
487423
|
-
const targetPath =
|
|
487752
|
+
const skillsDir = join113(memoryDir, "skills");
|
|
487753
|
+
const targetPath = join113(skillsDir, name);
|
|
487424
487754
|
assertInside(skillsDir, targetPath);
|
|
487425
487755
|
if (existsSync72(targetPath)) {
|
|
487426
487756
|
if (!params.force) {
|
|
@@ -487437,7 +487767,7 @@ async function installSkillDirectory(params) {
|
|
|
487437
487767
|
}
|
|
487438
487768
|
async function listSkillDirectories(params) {
|
|
487439
487769
|
const memoryDir = resolve41(params.memoryDir);
|
|
487440
|
-
const skillsDir =
|
|
487770
|
+
const skillsDir = join113(memoryDir, "skills");
|
|
487441
487771
|
if (!existsSync72(skillsDir))
|
|
487442
487772
|
return [];
|
|
487443
487773
|
const entries2 = await readdir13(skillsDir, { withFileTypes: true });
|
|
@@ -487445,8 +487775,8 @@ async function listSkillDirectories(params) {
|
|
|
487445
487775
|
for (const entry of entries2) {
|
|
487446
487776
|
if (!entry.isDirectory())
|
|
487447
487777
|
continue;
|
|
487448
|
-
const skillDir =
|
|
487449
|
-
const skillMdPath =
|
|
487778
|
+
const skillDir = join113(skillsDir, entry.name);
|
|
487779
|
+
const skillMdPath = join113(skillDir, "SKILL.md");
|
|
487450
487780
|
if (!existsSync72(skillMdPath))
|
|
487451
487781
|
continue;
|
|
487452
487782
|
let name = entry.name;
|
|
@@ -487467,9 +487797,9 @@ async function listSkillDirectories(params) {
|
|
|
487467
487797
|
}
|
|
487468
487798
|
async function deleteSkillDirectory(params) {
|
|
487469
487799
|
const memoryDir = resolve41(params.memoryDir);
|
|
487470
|
-
const skillsDir =
|
|
487800
|
+
const skillsDir = join113(memoryDir, "skills");
|
|
487471
487801
|
const name = sanitizeSkillName(params.name);
|
|
487472
|
-
const targetPath =
|
|
487802
|
+
const targetPath = join113(skillsDir, name);
|
|
487473
487803
|
assertInside(skillsDir, targetPath);
|
|
487474
487804
|
if (!existsSync72(targetPath)) {
|
|
487475
487805
|
throw new Error(`Skill "${name}" is not installed at ${targetPath}.`);
|
|
@@ -488055,7 +488385,7 @@ var init_teleport2 = __esm(() => {
|
|
|
488055
488385
|
|
|
488056
488386
|
// src/cli/subcommands/trajectories/readers.ts
|
|
488057
488387
|
import { readdir as readdir14, readFile as readFile30, stat as stat15 } from "node:fs/promises";
|
|
488058
|
-
import { join as
|
|
488388
|
+
import { join as join114 } from "node:path";
|
|
488059
488389
|
async function loadSessionTranscript(item) {
|
|
488060
488390
|
const stats = await stat15(item.path);
|
|
488061
488391
|
if (stats.isDirectory()) {
|
|
@@ -488067,13 +488397,13 @@ async function loadSessionTranscript(item) {
|
|
|
488067
488397
|
return readFile30(item.path, "utf-8");
|
|
488068
488398
|
}
|
|
488069
488399
|
async function assembleEventDirectory(sessionDir) {
|
|
488070
|
-
const eventsSubdir =
|
|
488400
|
+
const eventsSubdir = join114(sessionDir, "events");
|
|
488071
488401
|
const eventsDir = (await stat15(eventsSubdir).catch(() => null))?.isDirectory() ? eventsSubdir : sessionDir;
|
|
488072
488402
|
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
488403
|
if (names.length === 0) {
|
|
488074
488404
|
throw new Error(`No event files found in ${eventsDir}`);
|
|
488075
488405
|
}
|
|
488076
|
-
const events = await Promise.all(names.map(async (name) => JSON.parse(await readFile30(
|
|
488406
|
+
const events = await Promise.all(names.map(async (name) => JSON.parse(await readFile30(join114(eventsDir, name), "utf-8"))));
|
|
488077
488407
|
return JSON.stringify(events);
|
|
488078
488408
|
}
|
|
488079
488409
|
async function openReadOnlyDatabase(path49) {
|
|
@@ -488147,11 +488477,11 @@ import {
|
|
|
488147
488477
|
mkdir as mkdir18,
|
|
488148
488478
|
readdir as readdir15,
|
|
488149
488479
|
readFile as readFile31,
|
|
488150
|
-
rm as
|
|
488480
|
+
rm as rm15,
|
|
488151
488481
|
stat as stat16,
|
|
488152
488482
|
writeFile as writeFile20
|
|
488153
488483
|
} from "node:fs/promises";
|
|
488154
|
-
import { basename as basename33, join as
|
|
488484
|
+
import { basename as basename33, join as join115 } from "node:path";
|
|
488155
488485
|
function fileTimestamp(startedAt) {
|
|
488156
488486
|
if (!startedAt)
|
|
488157
488487
|
return "unknown-date";
|
|
@@ -488221,7 +488551,7 @@ async function prepareOutDir(outDir) {
|
|
|
488221
488551
|
throw new Error(`--out ${outDir} is not empty and has no ${MANIFEST_NAME}; refusing to overwrite a directory this tool did not create`);
|
|
488222
488552
|
}
|
|
488223
488553
|
for (const entry of entries2) {
|
|
488224
|
-
await
|
|
488554
|
+
await rm15(join115(outDir, entry), { recursive: true, force: true });
|
|
488225
488555
|
}
|
|
488226
488556
|
} catch (error4) {
|
|
488227
488557
|
if (error4.code !== "ENOENT")
|
|
@@ -488264,14 +488594,14 @@ async function runTrajectoryExport(options) {
|
|
|
488264
488594
|
}
|
|
488265
488595
|
const sessionId = sessionHash(source, id);
|
|
488266
488596
|
const base2 = `${fileTimestamp(stats.startedAt)}_${sessionId}`;
|
|
488267
|
-
let file =
|
|
488597
|
+
let file = join115(source, `${base2}.json`);
|
|
488268
488598
|
for (let suffix = 2;usedFiles.has(file); suffix += 1) {
|
|
488269
|
-
file =
|
|
488599
|
+
file = join115(source, `${base2}-${suffix}.json`);
|
|
488270
488600
|
}
|
|
488271
488601
|
usedFiles.add(file);
|
|
488272
488602
|
const body3 = JSON.stringify(records2);
|
|
488273
|
-
await mkdir18(
|
|
488274
|
-
await writeFile20(
|
|
488603
|
+
await mkdir18(join115(options.outDir, source), { recursive: true });
|
|
488604
|
+
await writeFile20(join115(options.outDir, file), body3, "utf-8");
|
|
488275
488605
|
counts.exported += 1;
|
|
488276
488606
|
manifest2.sessions.push({
|
|
488277
488607
|
source,
|
|
@@ -488325,7 +488655,7 @@ async function runTrajectoryExport(options) {
|
|
|
488325
488655
|
await exportCheckpoint(checkpoint, `${basename33(checkpoint.path)}-${checkpoint.threadId}`);
|
|
488326
488656
|
}
|
|
488327
488657
|
manifest2.sessions.sort((a2, b3) => (a2.startedAt ?? "").localeCompare(b3.startedAt ?? ""));
|
|
488328
|
-
await writeFile20(
|
|
488658
|
+
await writeFile20(join115(options.outDir, MANIFEST_NAME), JSON.stringify(manifest2, null, 2), "utf-8");
|
|
488329
488659
|
return manifest2;
|
|
488330
488660
|
}
|
|
488331
488661
|
var MANIFEST_NAME = "manifest.json", FIRST_PROMPT_MAX_CHARS = 200, LIST_PAGE_LIMIT = 1000;
|
|
@@ -488337,13 +488667,13 @@ var init_export = __esm(() => {
|
|
|
488337
488667
|
|
|
488338
488668
|
// src/cli/subcommands/trajectories/review.ts
|
|
488339
488669
|
import { readFile as readFile32 } from "node:fs/promises";
|
|
488340
|
-
import { isAbsolute as isAbsolute28, join as
|
|
488670
|
+
import { isAbsolute as isAbsolute28, join as join116 } from "node:path";
|
|
488341
488671
|
async function readManifest(dir) {
|
|
488342
488672
|
let raw2;
|
|
488343
488673
|
try {
|
|
488344
|
-
raw2 = await readFile32(
|
|
488674
|
+
raw2 = await readFile32(join116(dir, "manifest.json"), "utf-8");
|
|
488345
488675
|
} catch {
|
|
488346
|
-
throw new Error(`No manifest at ${
|
|
488676
|
+
throw new Error(`No manifest at ${join116(dir, "manifest.json")}. Run: letta trajectories export --out ${dir}`);
|
|
488347
488677
|
}
|
|
488348
488678
|
return JSON.parse(raw2);
|
|
488349
488679
|
}
|
|
@@ -488352,7 +488682,7 @@ function filterSessions(sessions6, filter3) {
|
|
|
488352
488682
|
}
|
|
488353
488683
|
async function resolveSessionFile(dir, target) {
|
|
488354
488684
|
if (target.endsWith(".json")) {
|
|
488355
|
-
const direct = isAbsolute28(target) ? target :
|
|
488685
|
+
const direct = isAbsolute28(target) ? target : join116(dir, target);
|
|
488356
488686
|
try {
|
|
488357
488687
|
await readFile32(direct, "utf-8");
|
|
488358
488688
|
return direct;
|
|
@@ -488363,7 +488693,7 @@ async function resolveSessionFile(dir, target) {
|
|
|
488363
488693
|
if (!entry) {
|
|
488364
488694
|
throw new Error(`No session "${target}" in ${dir} (pass a file path, a manifest-relative file, or a sessionId)`);
|
|
488365
488695
|
}
|
|
488366
|
-
return
|
|
488696
|
+
return join116(dir, entry.file);
|
|
488367
488697
|
}
|
|
488368
488698
|
function stamp(timestamp) {
|
|
488369
488699
|
return (timestamp ?? "").slice(0, 19);
|
|
@@ -488406,7 +488736,7 @@ async function searchSessions(dir, keyword, options = {}) {
|
|
|
488406
488736
|
for (const session3 of filterSessions(manifest2.sessions, options)) {
|
|
488407
488737
|
let records2;
|
|
488408
488738
|
try {
|
|
488409
|
-
records2 = JSON.parse(await readFile32(
|
|
488739
|
+
records2 = JSON.parse(await readFile32(join116(dir, session3.file), "utf-8"));
|
|
488410
488740
|
} catch {
|
|
488411
488741
|
continue;
|
|
488412
488742
|
}
|
|
@@ -494726,7 +495056,7 @@ function resolveHeadlessMemfsPolicy(options) {
|
|
|
494726
495056
|
var init_headless_memfs_policy = () => {};
|
|
494727
495057
|
|
|
494728
495058
|
// src/headless-mod-adapter.ts
|
|
494729
|
-
import { join as
|
|
495059
|
+
import { join as join117 } from "node:path";
|
|
494730
495060
|
function isHeadlessMemfsEnabled(agentId) {
|
|
494731
495061
|
try {
|
|
494732
495062
|
return settingsManager.isMemfsEnabled(agentId);
|
|
@@ -494797,7 +495127,7 @@ function createHeadlessModContext(options) {
|
|
|
494797
495127
|
};
|
|
494798
495128
|
}
|
|
494799
495129
|
function createHeadlessModAdapter(options) {
|
|
494800
|
-
const agentModsDirectory = isHeadlessMemfsEnabled(options.agent.id) ?
|
|
495130
|
+
const agentModsDirectory = isHeadlessMemfsEnabled(options.agent.id) ? join117(getScopedMemoryFilesystemRoot(options.agent.id), "mods") : undefined;
|
|
494801
495131
|
return createModAdapter({
|
|
494802
495132
|
...agentModsDirectory ? { agentModsDirectory } : {},
|
|
494803
495133
|
...options.cacheDirectory ? { cacheDirectory: options.cacheDirectory } : {},
|
|
@@ -499460,10 +499790,10 @@ import { execFile as execFileCb4 } from "node:child_process";
|
|
|
499460
499790
|
import { existsSync as existsSync75 } from "node:fs";
|
|
499461
499791
|
import { appendFile as appendFile3, chmod, mkdir as mkdir19, writeFile as writeFile21 } from "node:fs/promises";
|
|
499462
499792
|
import { homedir as homedir34 } from "node:os";
|
|
499463
|
-
import { join as
|
|
499793
|
+
import { join as join119 } from "node:path";
|
|
499464
499794
|
import { promisify as promisify20 } from "node:util";
|
|
499465
499795
|
function getReflectionArenaHfCacheRoot(env6 = process.env, fallbackHome = homedir34()) {
|
|
499466
|
-
return
|
|
499796
|
+
return join119(resolveGlobalConfigDir(env6, fallbackHome), "reflection-arena", "hf-upload");
|
|
499467
499797
|
}
|
|
499468
499798
|
function buildGitEnv(token2, askpassPath) {
|
|
499469
499799
|
return {
|
|
@@ -499499,7 +499829,7 @@ async function runGit6(cwd2, args, env6) {
|
|
|
499499
499829
|
}
|
|
499500
499830
|
}
|
|
499501
499831
|
async function writeGitAskpass(repoRoot) {
|
|
499502
|
-
const askpassPath =
|
|
499832
|
+
const askpassPath = join119(repoRoot, "hf-askpass.sh");
|
|
499503
499833
|
await writeFile21(askpassPath, [
|
|
499504
499834
|
"#!/bin/sh",
|
|
499505
499835
|
'case "$1" in',
|
|
@@ -499514,7 +499844,7 @@ async function writeGitAskpass(repoRoot) {
|
|
|
499514
499844
|
}
|
|
499515
499845
|
async function prepareHfRepo(env6) {
|
|
499516
499846
|
await mkdir19(HF_CACHE_ROOT, { recursive: true });
|
|
499517
|
-
if (!existsSync75(
|
|
499847
|
+
if (!existsSync75(join119(HF_REPO_DIR, ".git"))) {
|
|
499518
499848
|
await runGit6(HF_CACHE_ROOT, ["clone", "--depth", "1", HF_REPO_URL, HF_REPO_DIR], env6);
|
|
499519
499849
|
return HF_REPO_DIR;
|
|
499520
499850
|
}
|
|
@@ -499549,8 +499879,8 @@ async function maybeUploadReflectionArenaChoiceToHf(row) {
|
|
|
499549
499879
|
const env6 = buildGitEnv(token2, askpassPath);
|
|
499550
499880
|
try {
|
|
499551
499881
|
const repoDir = await prepareHfRepo(env6);
|
|
499552
|
-
await mkdir19(
|
|
499553
|
-
await appendFile3(
|
|
499882
|
+
await mkdir19(join119(repoDir, "data"), { recursive: true });
|
|
499883
|
+
await appendFile3(join119(repoDir, HF_DATASET_PATH), `${JSON.stringify(row)}
|
|
499554
499884
|
`, {
|
|
499555
499885
|
encoding: "utf-8"
|
|
499556
499886
|
});
|
|
@@ -499580,14 +499910,14 @@ var init_reflection_arena_hf_upload = __esm(() => {
|
|
|
499580
499910
|
execFile23 = promisify20(execFileCb4);
|
|
499581
499911
|
HF_REPO_URL = `https://huggingface.co/datasets/${HF_REPO_ID}`;
|
|
499582
499912
|
HF_CACHE_ROOT = getReflectionArenaHfCacheRoot();
|
|
499583
|
-
HF_REPO_DIR =
|
|
499913
|
+
HF_REPO_DIR = join119(HF_CACHE_ROOT, "repo");
|
|
499584
499914
|
});
|
|
499585
499915
|
|
|
499586
499916
|
// src/cli/helpers/reflection-arena.ts
|
|
499587
499917
|
import { execFile as execFileCb5 } from "node:child_process";
|
|
499588
499918
|
import { randomInt as randomInt2, randomUUID as randomUUID69 } from "node:crypto";
|
|
499589
499919
|
import { appendFile as appendFile4, mkdir as mkdir20, readFile as readFile34, writeFile as writeFile22 } from "node:fs/promises";
|
|
499590
|
-
import { join as
|
|
499920
|
+
import { join as join120 } from "node:path";
|
|
499591
499921
|
import { promisify as promisify21 } from "node:util";
|
|
499592
499922
|
function sampleReflectionArenaComparisonModel(excludedModels = []) {
|
|
499593
499923
|
const excluded = new Set(excludedModels);
|
|
@@ -499636,16 +499966,16 @@ function candidateIsConfirmedNoOp(candidate) {
|
|
|
499636
499966
|
return candidate.result?.success === true && candidate.result.memoryNoChanges === true && candidate.result.memoryHead === candidate.worktree.baseHead;
|
|
499637
499967
|
}
|
|
499638
499968
|
function getReflectionArenaRoot() {
|
|
499639
|
-
return
|
|
499969
|
+
return join120(resolveGlobalConfigDir(), "reflection-arena");
|
|
499640
499970
|
}
|
|
499641
499971
|
function getReflectionArenaRunsDir() {
|
|
499642
|
-
return
|
|
499972
|
+
return join120(getReflectionArenaRoot(), "runs");
|
|
499643
499973
|
}
|
|
499644
499974
|
function getReflectionArenaChoiceLogPath() {
|
|
499645
|
-
return
|
|
499975
|
+
return join120(getReflectionArenaRoot(), "choices.jsonl");
|
|
499646
499976
|
}
|
|
499647
499977
|
function getReflectionArenaRunPath(runId) {
|
|
499648
|
-
return
|
|
499978
|
+
return join120(getReflectionArenaRunsDir(), `${runId}.json`);
|
|
499649
499979
|
}
|
|
499650
499980
|
async function saveReflectionArenaRun(run) {
|
|
499651
499981
|
await mkdir20(getReflectionArenaRunsDir(), { recursive: true });
|
|
@@ -501186,7 +501516,7 @@ import {
|
|
|
501186
501516
|
writeFileSync as writeFileSync51
|
|
501187
501517
|
} from "node:fs";
|
|
501188
501518
|
import { homedir as homedir35, platform as platform10 } from "node:os";
|
|
501189
|
-
import { dirname as dirname43, join as
|
|
501519
|
+
import { dirname as dirname43, join as join121 } from "node:path";
|
|
501190
501520
|
function detectTerminalType() {
|
|
501191
501521
|
if (process.env.CURSOR_TRACE_ID || process.env.CURSOR_CHANNEL) {
|
|
501192
501522
|
return "cursor";
|
|
@@ -501218,16 +501548,16 @@ function getKeybindingsPath(terminal) {
|
|
|
501218
501548
|
}[terminal];
|
|
501219
501549
|
const os7 = platform10();
|
|
501220
501550
|
if (os7 === "darwin") {
|
|
501221
|
-
return
|
|
501551
|
+
return join121(homedir35(), "Library", "Application Support", appName, "User", "keybindings.json");
|
|
501222
501552
|
}
|
|
501223
501553
|
if (os7 === "win32") {
|
|
501224
501554
|
const appData = process.env.APPDATA;
|
|
501225
501555
|
if (!appData)
|
|
501226
501556
|
return null;
|
|
501227
|
-
return
|
|
501557
|
+
return join121(appData, appName, "User", "keybindings.json");
|
|
501228
501558
|
}
|
|
501229
501559
|
if (os7 === "linux") {
|
|
501230
|
-
return
|
|
501560
|
+
return join121(homedir35(), ".config", appName, "User", "keybindings.json");
|
|
501231
501561
|
}
|
|
501232
501562
|
return null;
|
|
501233
501563
|
}
|
|
@@ -501380,14 +501710,14 @@ function getWezTermConfigPath() {
|
|
|
501380
501710
|
}
|
|
501381
501711
|
const xdgConfig = process.env.XDG_CONFIG_HOME;
|
|
501382
501712
|
if (xdgConfig) {
|
|
501383
|
-
const xdgPath =
|
|
501713
|
+
const xdgPath = join121(xdgConfig, "wezterm", "wezterm.lua");
|
|
501384
501714
|
if (existsSync76(xdgPath))
|
|
501385
501715
|
return xdgPath;
|
|
501386
501716
|
}
|
|
501387
|
-
const configPath =
|
|
501717
|
+
const configPath = join121(homedir35(), ".config", "wezterm", "wezterm.lua");
|
|
501388
501718
|
if (existsSync76(configPath))
|
|
501389
501719
|
return configPath;
|
|
501390
|
-
return
|
|
501720
|
+
return join121(homedir35(), ".wezterm.lua");
|
|
501391
501721
|
}
|
|
501392
501722
|
function stripLuaCommentsFromLine(line, blockCommentEnd) {
|
|
501393
501723
|
let code = "";
|
|
@@ -501565,7 +501895,7 @@ __export(exports_settings, {
|
|
|
501565
501895
|
loadProjectSettings: () => loadProjectSettings,
|
|
501566
501896
|
getSetting: () => getSetting
|
|
501567
501897
|
});
|
|
501568
|
-
import { join as
|
|
501898
|
+
import { join as join122 } from "node:path";
|
|
501569
501899
|
function getSettingsPath() {
|
|
501570
501900
|
return resolveGlobalSettingsPath();
|
|
501571
501901
|
}
|
|
@@ -501607,7 +501937,7 @@ async function getSetting(key4) {
|
|
|
501607
501937
|
return settings[key4];
|
|
501608
501938
|
}
|
|
501609
501939
|
function getProjectSettingsPath() {
|
|
501610
|
-
return
|
|
501940
|
+
return join122(process.cwd(), ".letta", "settings.local.json");
|
|
501611
501941
|
}
|
|
501612
501942
|
async function loadProjectSettings() {
|
|
501613
501943
|
if (shouldIsolateHomeProjectConfig(process.cwd()))
|
|
@@ -501629,7 +501959,7 @@ async function saveProjectSettings(settings) {
|
|
|
501629
501959
|
if (shouldIsolateHomeProjectConfig(process.cwd()))
|
|
501630
501960
|
return;
|
|
501631
501961
|
const settingsPath = getProjectSettingsPath();
|
|
501632
|
-
const dirPath =
|
|
501962
|
+
const dirPath = join122(process.cwd(), ".letta");
|
|
501633
501963
|
try {
|
|
501634
501964
|
if (!exists(dirPath)) {
|
|
501635
501965
|
await mkdir(dirPath, { recursive: true });
|
|
@@ -512449,8 +512779,8 @@ import {
|
|
|
512449
512779
|
rmSync as rmSync29,
|
|
512450
512780
|
writeFileSync as writeFileSync52
|
|
512451
512781
|
} from "node:fs";
|
|
512452
|
-
import { tmpdir as
|
|
512453
|
-
import { dirname as dirname44, join as
|
|
512782
|
+
import { tmpdir as tmpdir18 } from "node:os";
|
|
512783
|
+
import { dirname as dirname44, join as join123 } from "node:path";
|
|
512454
512784
|
function runCommand(command, args, cwd2, input) {
|
|
512455
512785
|
try {
|
|
512456
512786
|
return execFileSync12(command, args, {
|
|
@@ -512671,8 +513001,8 @@ async function createLettaAgent(apiKey, name) {
|
|
|
512671
513001
|
return createMinimalAgent(apiKey, name);
|
|
512672
513002
|
}
|
|
512673
513003
|
function cloneRepoToTemp(repo) {
|
|
512674
|
-
const tempDir = mkdtempSync7(
|
|
512675
|
-
const repoDir =
|
|
513004
|
+
const tempDir = mkdtempSync7(join123(tmpdir18(), "letta-install-github-app-"));
|
|
513005
|
+
const repoDir = join123(tempDir, "repo");
|
|
512676
513006
|
runCommand("gh", ["repo", "clone", repo, repoDir, "--", "--depth=1"]);
|
|
512677
513007
|
return { tempDir, repoDir };
|
|
512678
513008
|
}
|
|
@@ -512683,7 +513013,7 @@ function runGit7(args, cwd2) {
|
|
|
512683
513013
|
return runCommand("git", args, cwd2);
|
|
512684
513014
|
}
|
|
512685
513015
|
function writeWorkflow(repoDir, workflowPath, content) {
|
|
512686
|
-
const absolutePath =
|
|
513016
|
+
const absolutePath = join123(repoDir, workflowPath);
|
|
512687
513017
|
if (!existsSync77(dirname44(absolutePath))) {
|
|
512688
513018
|
mkdirSync60(dirname44(absolutePath), { recursive: true });
|
|
512689
513019
|
}
|
|
@@ -516573,7 +516903,7 @@ __export(exports_generate_memory_viewer, {
|
|
|
516573
516903
|
});
|
|
516574
516904
|
import { execFile as execFileCb6 } from "node:child_process";
|
|
516575
516905
|
import { chmodSync as chmodSync11, existsSync as existsSync78, mkdirSync as mkdirSync61, writeFileSync as writeFileSync53 } from "node:fs";
|
|
516576
|
-
import { join as
|
|
516906
|
+
import { join as join124 } from "node:path";
|
|
516577
516907
|
import { promisify as promisify22 } from "node:util";
|
|
516578
516908
|
function messagesFromOverview(overview) {
|
|
516579
516909
|
return overview.messages?.map((message2) => ({
|
|
@@ -516883,7 +517213,7 @@ ${m4.body}` : m4.subject;
|
|
|
516883
517213
|
async function generateAndOpenMemoryViewer(agentId, options) {
|
|
516884
517214
|
const memoryRoot = getScopedMemoryFilesystemRoot(agentId);
|
|
516885
517215
|
const repoDir = memoryRoot;
|
|
516886
|
-
if (!existsSync78(
|
|
517216
|
+
if (!existsSync78(join124(repoDir, ".git"))) {
|
|
516887
517217
|
throw new Error("Memory viewer requires memfs. Run /memfs enable first.");
|
|
516888
517218
|
}
|
|
516889
517219
|
const data = await collectMemoryData(agentId, repoDir, memoryRoot, options?.conversationId);
|
|
@@ -516899,7 +517229,7 @@ async function generateAndOpenMemoryViewer(agentId, options) {
|
|
|
516899
517229
|
try {
|
|
516900
517230
|
chmodSync11(VIEWERS_DIR, 448);
|
|
516901
517231
|
} catch {}
|
|
516902
|
-
const filePath =
|
|
517232
|
+
const filePath = join124(VIEWERS_DIR, `memory-${encodeURIComponent(agentId)}.html`);
|
|
516903
517233
|
writeFileSync53(filePath, html5);
|
|
516904
517234
|
chmodSync11(filePath, 384);
|
|
516905
517235
|
const skipOpen = Boolean(process.env.TMUX) || Boolean(process.env.SSH_CONNECTION) || Boolean(process.env.SSH_TTY);
|
|
@@ -516927,13 +517257,13 @@ var init_generate_memory_viewer = __esm(() => {
|
|
|
516927
517257
|
init_local_memory_context();
|
|
516928
517258
|
init_memory_viewer_template();
|
|
516929
517259
|
execFile25 = promisify22(execFileCb6);
|
|
516930
|
-
VIEWERS_DIR =
|
|
517260
|
+
VIEWERS_DIR = join124(resolveGlobalConfigDir(), "viewers");
|
|
516931
517261
|
REFLECTION_PATTERN = /\(reflection\)|🔮|reflection:/i;
|
|
516932
517262
|
});
|
|
516933
517263
|
|
|
516934
517264
|
// src/cli/components/MemfsTreeViewer.tsx
|
|
516935
517265
|
import { existsSync as existsSync79 } from "node:fs";
|
|
516936
|
-
import { join as
|
|
517266
|
+
import { join as join125 } from "node:path";
|
|
516937
517267
|
function renderTreePrefix(node) {
|
|
516938
517268
|
let prefix = "";
|
|
516939
517269
|
for (let i4 = 0;i4 < node.depth; i4++) {
|
|
@@ -516962,7 +517292,7 @@ function MemfsTreeViewer({
|
|
|
516962
517292
|
const statusTimerRef = import_react88.useRef(null);
|
|
516963
517293
|
const memoryRoot = getScopedMemoryFilesystemRoot(agentId);
|
|
516964
517294
|
const memoryExists = existsSync79(memoryRoot);
|
|
516965
|
-
const hasGitRepo = import_react88.useMemo(() => existsSync79(
|
|
517295
|
+
const hasGitRepo = import_react88.useMemo(() => existsSync79(join125(memoryRoot, ".git")), [memoryRoot]);
|
|
516966
517296
|
function showStatus(msg, durationMs) {
|
|
516967
517297
|
if (statusTimerRef.current)
|
|
516968
517298
|
clearTimeout(statusTimerRef.current);
|
|
@@ -519694,10 +520024,10 @@ var init_use_chatgpt_rate_limit_state = __esm(() => {
|
|
|
519694
520024
|
// src/utils/aws-credentials.ts
|
|
519695
520025
|
import { readFile as readFile35 } from "node:fs/promises";
|
|
519696
520026
|
import { homedir as homedir36 } from "node:os";
|
|
519697
|
-
import { join as
|
|
520027
|
+
import { join as join126 } from "node:path";
|
|
519698
520028
|
async function parseAwsCredentials() {
|
|
519699
|
-
const credentialsPath =
|
|
519700
|
-
const configPath =
|
|
520029
|
+
const credentialsPath = join126(homedir36(), ".aws", "credentials");
|
|
520030
|
+
const configPath = join126(homedir36(), ".aws", "config");
|
|
519701
520031
|
const profiles = new Map;
|
|
519702
520032
|
try {
|
|
519703
520033
|
const content = await readFile35(credentialsPath, "utf-8");
|
|
@@ -521460,7 +521790,7 @@ var init_ReasoningMessageRich = __esm(async () => {
|
|
|
521460
521790
|
});
|
|
521461
521791
|
|
|
521462
521792
|
// src/cli/components/skills-dialog-paths.ts
|
|
521463
|
-
import { join as
|
|
521793
|
+
import { join as join127 } from "node:path";
|
|
521464
521794
|
function displayDirectory(path50) {
|
|
521465
521795
|
return `${path50.replace(/\\/g, "/").replace(/\/$/, "")}/`;
|
|
521466
521796
|
}
|
|
@@ -521470,7 +521800,7 @@ function getSkillsTabDescription(tab2, agentId, env6 = process.env) {
|
|
|
521470
521800
|
return ".agents/skills/";
|
|
521471
521801
|
case "agent": {
|
|
521472
521802
|
const memoryDir = resolveScopedMemoryDir({ agentId, env: env6 });
|
|
521473
|
-
return memoryDir ? displayDirectory(
|
|
521803
|
+
return memoryDir ? displayDirectory(join127(memoryDir, "skills")) : "$MEMORY_DIR/skills/";
|
|
521474
521804
|
}
|
|
521475
521805
|
case "global":
|
|
521476
521806
|
return displayDirectory(getGlobalSkillsDir(env6));
|
|
@@ -521498,8 +521828,8 @@ function SkillsDialog({ onClose, agentId }) {
|
|
|
521498
521828
|
try {
|
|
521499
521829
|
const { discoverSkills: discoverSkills2, SKILLS_DIR: SKILLS_DIR2 } = await Promise.resolve().then(() => (init_skills5(), exports_skills2));
|
|
521500
521830
|
const { getSkillsDirectory: getSkillsDirectory2, getSkillSources: getSkillSources2 } = await Promise.resolve().then(() => (init_context(), exports_context));
|
|
521501
|
-
const { join:
|
|
521502
|
-
const skillsDir = getSkillsDirectory2() ||
|
|
521831
|
+
const { join: join128 } = await import("node:path");
|
|
521832
|
+
const skillsDir = getSkillsDirectory2() || join128(process.cwd(), SKILLS_DIR2);
|
|
521503
521833
|
const result3 = await discoverSkills2(skillsDir, agentId, {
|
|
521504
521834
|
sources: getSkillSources2()
|
|
521505
521835
|
});
|
|
@@ -527605,7 +527935,7 @@ __export(exports_generate_diff_viewer, {
|
|
|
527605
527935
|
});
|
|
527606
527936
|
import { execFile as execFileCb7 } from "node:child_process";
|
|
527607
527937
|
import { chmodSync as chmodSync12, existsSync as existsSync80, mkdirSync as mkdirSync62, writeFileSync as writeFileSync54 } from "node:fs";
|
|
527608
|
-
import { isAbsolute as isAbsolute29, join as
|
|
527938
|
+
import { isAbsolute as isAbsolute29, join as join128, resolve as resolve43 } from "node:path";
|
|
527609
527939
|
import { promisify as promisify23 } from "node:util";
|
|
527610
527940
|
async function runGit8(cwd2, args) {
|
|
527611
527941
|
try {
|
|
@@ -527834,7 +528164,7 @@ async function generateAndOpenDiffViewer(targetPath) {
|
|
|
527834
528164
|
try {
|
|
527835
528165
|
chmodSync12(VIEWERS_DIR2, 448);
|
|
527836
528166
|
} catch {}
|
|
527837
|
-
const filePath =
|
|
528167
|
+
const filePath = join128(VIEWERS_DIR2, `diff-${encodeURIComponent(worktreePath)}.html`);
|
|
527838
528168
|
writeFileSync54(filePath, html5);
|
|
527839
528169
|
chmodSync12(filePath, 384);
|
|
527840
528170
|
const skipOpen = shouldSkipOpen();
|
|
@@ -527904,7 +528234,7 @@ var init_generate_diff_viewer = __esm(() => {
|
|
|
527904
528234
|
init_settings_path();
|
|
527905
528235
|
init_diff_viewer_template();
|
|
527906
528236
|
execFile26 = promisify23(execFileCb7);
|
|
527907
|
-
VIEWERS_DIR2 =
|
|
528237
|
+
VIEWERS_DIR2 = join128(resolveGlobalConfigDir(), "viewers");
|
|
527908
528238
|
GIT_MAX_BUFFER = 50 * 1024 * 1024;
|
|
527909
528239
|
});
|
|
527910
528240
|
|
|
@@ -529867,7 +530197,7 @@ __export(exports_shell_aliases, {
|
|
|
529867
530197
|
});
|
|
529868
530198
|
import { existsSync as existsSync81, readFileSync as readFileSync61 } from "node:fs";
|
|
529869
530199
|
import { homedir as homedir37 } from "node:os";
|
|
529870
|
-
import { join as
|
|
530200
|
+
import { join as join129 } from "node:path";
|
|
529871
530201
|
function parseAliasesFromFile(filePath) {
|
|
529872
530202
|
const aliases = new Map;
|
|
529873
530203
|
if (!existsSync81(filePath)) {
|
|
@@ -529939,7 +530269,7 @@ function loadAliases(forceReload = false) {
|
|
|
529939
530269
|
const home = homedir37();
|
|
529940
530270
|
const allAliases = new Map;
|
|
529941
530271
|
for (const file of ALIAS_FILES) {
|
|
529942
|
-
const filePath =
|
|
530272
|
+
const filePath = join129(home, file);
|
|
529943
530273
|
const fileAliases = parseAliasesFromFile(filePath);
|
|
529944
530274
|
for (const [name, value] of fileAliases) {
|
|
529945
530275
|
allAliases.set(name, value);
|
|
@@ -538157,8 +538487,8 @@ var init_conversation_switch_alert = __esm(() => {
|
|
|
538157
538487
|
// src/cli/app/use-submit-handler.ts
|
|
538158
538488
|
import { randomUUID as randomUUID75 } from "node:crypto";
|
|
538159
538489
|
import { existsSync as existsSync82, readFileSync as readFileSync62, renameSync as renameSync14 } from "node:fs";
|
|
538160
|
-
import { tmpdir as
|
|
538161
|
-
import { join as
|
|
538490
|
+
import { tmpdir as tmpdir19 } from "node:os";
|
|
538491
|
+
import { join as join130 } from "node:path";
|
|
538162
538492
|
async function findCustomCommandByName(commandName) {
|
|
538163
538493
|
const { findCustomCommand: findCustomCommand2 } = await Promise.resolve().then(() => (init_custom(), exports_custom));
|
|
538164
538494
|
return findCustomCommand2(commandName);
|
|
@@ -538766,8 +539096,8 @@ ${SYSTEM_REMINDER_CLOSE}`),
|
|
|
538766
539096
|
try {
|
|
538767
539097
|
const memoryRoot = getScopedMemoryFilesystemRoot(agentId);
|
|
538768
539098
|
const personaCandidates = [
|
|
538769
|
-
|
|
538770
|
-
|
|
539099
|
+
join130(memoryRoot, "system", "persona.md"),
|
|
539100
|
+
join130(memoryRoot, "memory", "system", "persona.md")
|
|
538771
539101
|
];
|
|
538772
539102
|
const personaPath = personaCandidates.find((candidate) => existsSync82(candidate));
|
|
538773
539103
|
if (personaPath) {
|
|
@@ -539615,7 +539945,7 @@ Path: ${memoryDir}`, true);
|
|
|
539615
539945
|
updateMemorySyncCommand(cmdId, "No local memory filesystem found to reset.", true, msg);
|
|
539616
539946
|
return { submitted: true };
|
|
539617
539947
|
}
|
|
539618
|
-
const backupDir =
|
|
539948
|
+
const backupDir = join130(tmpdir19(), `letta-memfs-reset-${agentId}-${Date.now()}`);
|
|
539619
539949
|
renameSync14(memoryDir, backupDir);
|
|
539620
539950
|
if (getBackend().capabilities.localMemfs) {
|
|
539621
539951
|
const { initializeLocalMemoryRepo: initializeLocalMemoryRepo2 } = await Promise.resolve().then(() => (init_memory_git(), exports_memory_git));
|
|
@@ -540524,7 +540854,7 @@ var init_use_submit_handler = __esm(async () => {
|
|
|
540524
540854
|
});
|
|
540525
540855
|
|
|
540526
540856
|
// src/cli/app/AppCoordinator.tsx
|
|
540527
|
-
import { join as
|
|
540857
|
+
import { join as join131 } from "node:path";
|
|
540528
540858
|
function buildStartupCommandHints(options) {
|
|
540529
540859
|
const {
|
|
540530
540860
|
isResumingConversation,
|
|
@@ -541805,7 +542135,7 @@ function App2({
|
|
|
541805
542135
|
agentId: a2.agentId ?? null
|
|
541806
542136
|
}))
|
|
541807
542137
|
});
|
|
541808
|
-
const agentModsDirectory = modContext.memfs.enabled && modContext.memfs.memoryDir ?
|
|
542138
|
+
const agentModsDirectory = modContext.memfs.enabled && modContext.memfs.memoryDir ? join131(modContext.memfs.memoryDir, "mods") : null;
|
|
541809
542139
|
const modAdapter = useLocalModAdapter(modContext, {
|
|
541810
542140
|
agentModsDirectory,
|
|
541811
542141
|
disabled: modsDisabled,
|
|
@@ -544146,12 +544476,12 @@ EXAMPLES
|
|
|
544146
544476
|
console.log(usage);
|
|
544147
544477
|
}
|
|
544148
544478
|
async function printInfo() {
|
|
544149
|
-
const { join:
|
|
544479
|
+
const { join: join132 } = await import("node:path");
|
|
544150
544480
|
const { getVersion: getVersion2 } = await Promise.resolve().then(() => (init_version(), exports_version));
|
|
544151
544481
|
const { SKILLS_DIR: SKILLS_DIR2 } = await Promise.resolve().then(() => (init_skills5(), exports_skills2));
|
|
544152
544482
|
const { exists: exists2 } = await Promise.resolve().then(() => (init_fs(), exports_fs));
|
|
544153
544483
|
const cwd2 = process.cwd();
|
|
544154
|
-
const skillsDir =
|
|
544484
|
+
const skillsDir = join132(cwd2, SKILLS_DIR2);
|
|
544155
544485
|
const skillsExist = exists2(skillsDir);
|
|
544156
544486
|
await settingsManager.loadLocalProjectSettings(cwd2);
|
|
544157
544487
|
const pinned = settingsManager.getPinnedAgents();
|
|
@@ -548016,4 +548346,4 @@ function registerBunOAuthFlows() {
|
|
|
548016
548346
|
registerBunOAuthFlows();
|
|
548017
548347
|
await init_src5().then(() => exports_src2);
|
|
548018
548348
|
|
|
548019
|
-
//# debugId=
|
|
548349
|
+
//# debugId=1A69A6302AC3853F64756E2164756E21
|