@letta-ai/letta-code 0.32.8 → 0.32.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mcp-client.js +2 -2
- package/dist/mcp-client.js.map +1 -1
- package/dist/types/agent/subagents/names.d.ts +1 -1
- package/dist/types/agent/subagents/names.d.ts.map +1 -1
- package/dist/types/backend/api/metadata.d.ts +1 -0
- package/dist/types/backend/api/metadata.d.ts.map +1 -1
- package/dist/types/runtime-context.d.ts +2 -0
- package/dist/types/runtime-context.d.ts.map +1 -1
- package/dist/types/telemetry/index.d.ts +1 -0
- package/dist/types/telemetry/index.d.ts.map +1 -1
- package/dist/types/tools/impl/task.d.ts.map +1 -1
- package/dist/types/tools/manager.d.ts +1 -3
- package/dist/types/tools/manager.d.ts.map +1 -1
- package/dist/types/types/protocol_v2.d.ts +3 -5
- package/dist/types/types/protocol_v2.d.ts.map +1 -1
- package/dist/types/websocket/listener/runtime.d.ts.map +1 -1
- package/dist/types/websocket/listener/types.d.ts +10 -8
- package/dist/types/websocket/listener/types.d.ts.map +1 -1
- package/docs/examples/mods/learning/memory-citations.env.json +2 -2
- package/docs/examples/mods/learning/uv-pip-install.env.json +2 -2
- package/docs/examples/mods/memory-citations.ts +3 -3
- package/letta.js +910 -563
- package/package.json +1 -1
- package/scripts/source-file-size-baseline.json +4 -4
- package/scripts/test-home-preload.ts +9 -1
- package/skills/letta-guide/SKILL.md +3 -1
package/letta.js
CHANGED
|
@@ -3933,6 +3933,18 @@ var init_paths = __esm(() => {
|
|
|
3933
3933
|
init_local_backend_paths();
|
|
3934
3934
|
});
|
|
3935
3935
|
|
|
3936
|
+
// src/agent/acting-user.ts
|
|
3937
|
+
function resolveActingUserId(explicitActingUserId, runtimeActingUserId, env = process.env) {
|
|
3938
|
+
return explicitActingUserId ?? runtimeActingUserId ?? env[ACTING_USER_ID_ENV];
|
|
3939
|
+
}
|
|
3940
|
+
function actingUserRequestOptions(actingUserId) {
|
|
3941
|
+
if (!actingUserId) {
|
|
3942
|
+
return;
|
|
3943
|
+
}
|
|
3944
|
+
return { headers: { [ACTING_USER_ID_HEADER]: actingUserId } };
|
|
3945
|
+
}
|
|
3946
|
+
var ACTING_USER_ID_HEADER = "X-Letta-Acting-User-Id", ACTING_USER_ID_ENV = "LETTA_ACTING_USER_ID";
|
|
3947
|
+
|
|
3936
3948
|
// src/helpers/usable-directory.ts
|
|
3937
3949
|
import { statSync } from "node:fs";
|
|
3938
3950
|
function readDirectoryStats(dirPath) {
|
|
@@ -3968,6 +3980,9 @@ import { homedir as homedir2, tmpdir } from "node:os";
|
|
|
3968
3980
|
function getRuntimeContext() {
|
|
3969
3981
|
return runtimeContextStorage.getStore();
|
|
3970
3982
|
}
|
|
3983
|
+
function getRuntimeActingUserId() {
|
|
3984
|
+
return resolveActingUserId(undefined, getRuntimeContext()?.actingUserId);
|
|
3985
|
+
}
|
|
3971
3986
|
function runWithRuntimeContext(snapshot, fn) {
|
|
3972
3987
|
const parent = runtimeContextStorage.getStore();
|
|
3973
3988
|
return runtimeContextStorage.run({
|
|
@@ -5515,7 +5530,7 @@ var package_default;
|
|
|
5515
5530
|
var init_package = __esm(() => {
|
|
5516
5531
|
package_default = {
|
|
5517
5532
|
name: "@letta-ai/letta-code",
|
|
5518
|
-
version: "0.32.
|
|
5533
|
+
version: "0.32.10",
|
|
5519
5534
|
lettaStartupLogProtocol: 1,
|
|
5520
5535
|
description: "Letta Code is a CLI tool for interacting with stateful Letta agents from the terminal.",
|
|
5521
5536
|
type: "module",
|
|
@@ -5945,7 +5960,8 @@ async function submitTelemetryMetadata(apiKey, deviceId, payload, options) {
|
|
|
5945
5960
|
await apiRequest("POST", "/v1/metadata/telemetry", payload, {
|
|
5946
5961
|
...config,
|
|
5947
5962
|
headers: {
|
|
5948
|
-
"X-Letta-Code-Device-ID": deviceId
|
|
5963
|
+
"X-Letta-Code-Device-ID": deviceId,
|
|
5964
|
+
...actingUserRequestOptions(options?.actingUserId)?.headers
|
|
5949
5965
|
},
|
|
5950
5966
|
signal: options?.signal
|
|
5951
5967
|
});
|
|
@@ -6167,6 +6183,7 @@ function isNonActionableError(message) {
|
|
|
6167
6183
|
|
|
6168
6184
|
class TelemetryManager {
|
|
6169
6185
|
events = [];
|
|
6186
|
+
eventActingUsers = new WeakMap;
|
|
6170
6187
|
sessionId;
|
|
6171
6188
|
deviceId = null;
|
|
6172
6189
|
currentAgentId = null;
|
|
@@ -6291,6 +6308,7 @@ class TelemetryManager {
|
|
|
6291
6308
|
backend: resolveTelemetryBackend()
|
|
6292
6309
|
}
|
|
6293
6310
|
};
|
|
6311
|
+
this.eventActingUsers.set(event, getRuntimeActingUserId());
|
|
6294
6312
|
this.events.push(event);
|
|
6295
6313
|
if (this.events.length >= this.MAX_BATCH_SIZE) {
|
|
6296
6314
|
this.flush().catch((err) => {
|
|
@@ -6509,15 +6527,27 @@ class TelemetryManager {
|
|
|
6509
6527
|
this.events = [];
|
|
6510
6528
|
const apiKey = await this.resolveTelemetryApiKey();
|
|
6511
6529
|
const deviceId = this.getTelemetryDeviceId();
|
|
6512
|
-
|
|
6513
|
-
|
|
6514
|
-
|
|
6515
|
-
|
|
6516
|
-
|
|
6517
|
-
|
|
6518
|
-
}
|
|
6519
|
-
|
|
6520
|
-
|
|
6530
|
+
const groups = new Map;
|
|
6531
|
+
for (const event of eventsToSend) {
|
|
6532
|
+
const actingUserId = this.eventActingUsers.get(event);
|
|
6533
|
+
const group = groups.get(actingUserId) ?? [];
|
|
6534
|
+
group.push(event);
|
|
6535
|
+
groups.set(actingUserId, group);
|
|
6536
|
+
}
|
|
6537
|
+
const failed = new Set;
|
|
6538
|
+
await Promise.all([...groups].map(async ([actingUserId, events]) => {
|
|
6539
|
+
try {
|
|
6540
|
+
await submitTelemetryMetadata(apiKey, deviceId, {
|
|
6541
|
+
service: "letta-code",
|
|
6542
|
+
server_version: this.serverVersion || undefined,
|
|
6543
|
+
events
|
|
6544
|
+
}, { signal: AbortSignal.timeout(5000), actingUserId });
|
|
6545
|
+
} catch {
|
|
6546
|
+
for (const event of events)
|
|
6547
|
+
failed.add(event);
|
|
6548
|
+
}
|
|
6549
|
+
}));
|
|
6550
|
+
this.events.unshift(...eventsToSend.filter((event) => failed.has(event)));
|
|
6521
6551
|
}
|
|
6522
6552
|
async drain() {
|
|
6523
6553
|
if (!this.isTelemetryEnabled()) {
|
|
@@ -6554,6 +6584,7 @@ var init_telemetry = __esm(() => {
|
|
|
6554
6584
|
init_metadata();
|
|
6555
6585
|
init_server_url();
|
|
6556
6586
|
init_paths();
|
|
6587
|
+
init_runtime_context();
|
|
6557
6588
|
init_settings_manager();
|
|
6558
6589
|
init_debug();
|
|
6559
6590
|
init_version();
|
|
@@ -101243,7 +101274,6 @@ function createConversationRuntime(listener, agentId, conversationId) {
|
|
|
101243
101274
|
acceptedInputDispositions: new Map,
|
|
101244
101275
|
pendingApprovalResolvers: new Map,
|
|
101245
101276
|
recoveredApprovalState: null,
|
|
101246
|
-
syncApprovalRecoveryCompleted: false,
|
|
101247
101277
|
expectedTeleportId: null,
|
|
101248
101278
|
expectedTeleportExpiresAt: null,
|
|
101249
101279
|
get lastStopReason() {
|
|
@@ -122326,18 +122356,6 @@ var init_search_file_content_gemini = __esm(() => {
|
|
|
122326
122356
|
init_grep();
|
|
122327
122357
|
});
|
|
122328
122358
|
|
|
122329
|
-
// src/agent/acting-user.ts
|
|
122330
|
-
function resolveActingUserId(explicitActingUserId, runtimeActingUserId, env3 = process.env) {
|
|
122331
|
-
return explicitActingUserId ?? runtimeActingUserId ?? env3[ACTING_USER_ID_ENV];
|
|
122332
|
-
}
|
|
122333
|
-
function actingUserRequestOptions(actingUserId) {
|
|
122334
|
-
if (!actingUserId) {
|
|
122335
|
-
return;
|
|
122336
|
-
}
|
|
122337
|
-
return { headers: { [ACTING_USER_ID_HEADER]: actingUserId } };
|
|
122338
|
-
}
|
|
122339
|
-
var ACTING_USER_ID_HEADER = "X-Letta-Acting-User-Id", ACTING_USER_ID_ENV = "LETTA_ACTING_USER_ID";
|
|
122340
|
-
|
|
122341
122359
|
// src/backend/api/agent-message.ts
|
|
122342
122360
|
function normalizeAgentMessageComputer(value) {
|
|
122343
122361
|
if (value == null)
|
|
@@ -123673,106 +123691,114 @@ var init_names = __esm(() => {
|
|
|
123673
123691
|
init_constants2();
|
|
123674
123692
|
SUBAGENT_NAMES = [
|
|
123675
123693
|
"Deckard",
|
|
123676
|
-
"
|
|
123677
|
-
"Roy",
|
|
123694
|
+
"Roy Batty",
|
|
123678
123695
|
"Pris",
|
|
123679
123696
|
"Zhora",
|
|
123680
|
-
"Leon",
|
|
123681
123697
|
"Gaff",
|
|
123682
123698
|
"Tyrell",
|
|
123683
|
-
"Sebastian",
|
|
123684
|
-
"Bryant",
|
|
123685
|
-
"Chew",
|
|
123686
|
-
"Holden",
|
|
123687
|
-
"Taffey",
|
|
123688
123699
|
"K",
|
|
123689
123700
|
"Joi",
|
|
123690
123701
|
"Luv",
|
|
123691
|
-
"Wallace",
|
|
123692
|
-
"Joshi",
|
|
123693
123702
|
"Sapper",
|
|
123694
|
-
"Mariette",
|
|
123695
123703
|
"Freysa",
|
|
123696
|
-
"Ana",
|
|
123697
|
-
"Coco",
|
|
123698
|
-
"Samantha",
|
|
123699
|
-
"Theodore",
|
|
123700
|
-
"Amy",
|
|
123701
|
-
"Catherine",
|
|
123702
|
-
"Paul",
|
|
123703
|
-
"Isabella",
|
|
123704
123704
|
"Ava",
|
|
123705
|
-
"Caleb",
|
|
123706
|
-
"Nathan",
|
|
123707
123705
|
"Kyoko",
|
|
123708
123706
|
"V",
|
|
123709
|
-
"
|
|
123710
|
-
"Jackie",
|
|
123711
|
-
"Judy",
|
|
123707
|
+
"Silverhand",
|
|
123712
123708
|
"Panam",
|
|
123713
|
-
"River",
|
|
123714
|
-
"Kerry",
|
|
123715
123709
|
"Rogue",
|
|
123716
|
-
"Alt",
|
|
123717
|
-
"Evelyn",
|
|
123710
|
+
"Alt Cunningham",
|
|
123718
123711
|
"Takemura",
|
|
123719
123712
|
"Hanako",
|
|
123720
123713
|
"Yorinobu",
|
|
123721
123714
|
"Saburo",
|
|
123722
123715
|
"Oda",
|
|
123723
|
-
"Viktor",
|
|
123724
|
-
"Misty",
|
|
123725
|
-
"Dex",
|
|
123726
123716
|
"T-Bug",
|
|
123727
123717
|
"Delamain",
|
|
123728
123718
|
"Wakako",
|
|
123729
123719
|
"Padre",
|
|
123730
|
-
"Regina",
|
|
123731
|
-
"Dakota",
|
|
123732
|
-
"Dino",
|
|
123733
123720
|
"El Capitan",
|
|
123734
123721
|
"Mr. Hands",
|
|
123735
123722
|
"Placide",
|
|
123736
|
-
"Brigitte",
|
|
123737
|
-
"Royce",
|
|
123738
123723
|
"Dum Dum",
|
|
123739
|
-
"Brick",
|
|
123740
|
-
"Meredith",
|
|
123741
|
-
"Sandra",
|
|
123742
|
-
"Maiko",
|
|
123743
|
-
"Claire",
|
|
123744
123724
|
"Nix",
|
|
123745
123725
|
"Weyland",
|
|
123746
|
-
"Saul",
|
|
123747
|
-
"Mitch",
|
|
123748
123726
|
"Scorpion",
|
|
123749
|
-
"Cassidy",
|
|
123750
|
-
"Carol",
|
|
123751
|
-
"Denny",
|
|
123752
|
-
"Nancy",
|
|
123753
|
-
"Henry",
|
|
123754
123727
|
"Blue Moon",
|
|
123755
123728
|
"Red Menace",
|
|
123756
123729
|
"Purple Force",
|
|
123757
|
-
"Lizzy",
|
|
123730
|
+
"Lizzy Wizzy",
|
|
123758
123731
|
"Ozob",
|
|
123759
123732
|
"Smasher",
|
|
123760
|
-
"Reed",
|
|
123761
123733
|
"Songbird",
|
|
123762
|
-
"Alex",
|
|
123763
|
-
"Myers",
|
|
123764
|
-
"Hansen",
|
|
123765
|
-
"Paco",
|
|
123766
|
-
"Babs",
|
|
123767
123734
|
"Slider",
|
|
123768
|
-
"Aurore",
|
|
123769
|
-
"Aymeric",
|
|
123770
123735
|
"Aguilar",
|
|
123771
|
-
"
|
|
123772
|
-
"
|
|
123773
|
-
"
|
|
123774
|
-
"
|
|
123775
|
-
"
|
|
123736
|
+
"Dogmeat",
|
|
123737
|
+
"Codsworth",
|
|
123738
|
+
"Nick Valentine",
|
|
123739
|
+
"Yes Man",
|
|
123740
|
+
"Mr. House",
|
|
123741
|
+
"ED-E",
|
|
123742
|
+
"Fisto",
|
|
123743
|
+
"Liberty Prime",
|
|
123744
|
+
"Three Dog",
|
|
123745
|
+
"Charon",
|
|
123746
|
+
"Fawkes",
|
|
123747
|
+
"Ulysses",
|
|
123748
|
+
"The Master",
|
|
123749
|
+
"Muggy",
|
|
123750
|
+
"Dr. Mobius",
|
|
123751
|
+
"Dr. Klein",
|
|
123752
|
+
"Old Longfellow",
|
|
123753
|
+
"Pickman",
|
|
123754
|
+
"Butch DeLoria",
|
|
123755
|
+
"Fantastic",
|
|
123756
|
+
"Muad'Dib",
|
|
123757
|
+
"Stilgar",
|
|
123758
|
+
"Chani",
|
|
123759
|
+
"Gurney Halleck",
|
|
123760
|
+
"Duncan Idaho",
|
|
123761
|
+
"Thufir Hawat",
|
|
123762
|
+
"Liet-Kynes",
|
|
123763
|
+
"Shadout Mapes",
|
|
123764
|
+
"Feyd-Rautha",
|
|
123765
|
+
"Rabban",
|
|
123766
|
+
"Piter De Vries",
|
|
123767
|
+
"Irulan",
|
|
123768
|
+
"Scytale",
|
|
123769
|
+
"Hayt",
|
|
123770
|
+
"Bijaz",
|
|
123771
|
+
"Moneo",
|
|
123772
|
+
"Miles Teg",
|
|
123773
|
+
"Darwi Odrade",
|
|
123774
|
+
"Sheeana",
|
|
123775
|
+
"Shaddam IV",
|
|
123776
|
+
"Count Fenring",
|
|
123777
|
+
"Wintermute",
|
|
123778
|
+
"Neuromancer",
|
|
123779
|
+
"Dixie Flatline",
|
|
123780
|
+
"Molly Millions",
|
|
123781
|
+
"Lady 3Jane",
|
|
123782
|
+
"Armitage",
|
|
123783
|
+
"Maelcum",
|
|
123784
|
+
"Ratz",
|
|
123785
|
+
"The Finn",
|
|
123786
|
+
"Hiro Protagonist",
|
|
123787
|
+
"Y.T.",
|
|
123788
|
+
"Raven",
|
|
123789
|
+
"Uncle Enzo",
|
|
123790
|
+
"R. Daneel Olivaw",
|
|
123791
|
+
"R. Giskard Reventlov",
|
|
123792
|
+
"Hari Seldon",
|
|
123793
|
+
"Dors Venabili",
|
|
123794
|
+
"The Mule",
|
|
123795
|
+
"HAL 9000",
|
|
123796
|
+
"Aineko",
|
|
123797
|
+
"Eschaton",
|
|
123798
|
+
"Mycroft Canner",
|
|
123799
|
+
"J.E.D.D. Mason",
|
|
123800
|
+
"Sniper",
|
|
123801
|
+
"Eureka Weeksbooth"
|
|
123776
123802
|
];
|
|
123777
123803
|
nextName = createSubagentNameAllocator();
|
|
123778
123804
|
});
|
|
@@ -125204,7 +125230,10 @@ async function task(args) {
|
|
|
125204
125230
|
const agentId = linkedAgent?.agentId ?? null;
|
|
125205
125231
|
const agentIdLine = agentId ? `
|
|
125206
125232
|
Agent ID: ${agentId}` : "";
|
|
125207
|
-
|
|
125233
|
+
const conversationId = linkedAgent?.conversationId ?? null;
|
|
125234
|
+
const conversationIdLine = conversationId ? `
|
|
125235
|
+
Conversation ID: ${conversationId}` : "";
|
|
125236
|
+
return `Task running in background with task ID: ${taskId}${agentIdLine}${conversationIdLine}
|
|
125208
125237
|
Output file: ${outputFile}
|
|
125209
125238
|
|
|
125210
125239
|
You will be notified automatically when this task completes — a <task-notification> message will be delivered with the result. No need to poll, sleep-wait, or check the output file. Just continue with your current work.`;
|
|
@@ -134381,7 +134410,7 @@ async function executeToolInner(name, args, options) {
|
|
|
134381
134410
|
return createModPermissionToolResult(permissionDecision2);
|
|
134382
134411
|
}
|
|
134383
134412
|
}
|
|
134384
|
-
return executeExternalTool(options?.toolCallId ?? `ext-${Date.now()}`, name, eventArgs2, externalTool?.executor ?? activeExternalExecutor, externalTool);
|
|
134413
|
+
return runWithRuntimeContext(executionScope, () => executeExternalTool(options?.toolCallId ?? `ext-${Date.now()}`, name, eventArgs2, externalTool?.executor ?? activeExternalExecutor, externalTool));
|
|
134385
134414
|
}
|
|
134386
134415
|
const internalName = resolveInternalToolName(name, activeRegistry);
|
|
134387
134416
|
const tool = internalName ? activeRegistry.get(internalName) : undefined;
|
|
@@ -218684,6 +218713,7 @@ __export(exports_environments2, {
|
|
|
218684
218713
|
resolveAgentSandboxConnectionId: () => resolveAgentSandboxConnectionId,
|
|
218685
218714
|
listEnvironments: () => listEnvironments,
|
|
218686
218715
|
isEnvironmentOnline: () => isEnvironmentOnline,
|
|
218716
|
+
getTeleportStatus: () => getTeleportStatus,
|
|
218687
218717
|
getEnvironmentConnection: () => getEnvironmentConnection,
|
|
218688
218718
|
describeEnvironment: () => describeEnvironment,
|
|
218689
218719
|
createAgentSandbox: () => createAgentSandbox
|
|
@@ -218786,6 +218816,9 @@ async function resolveAgentSandboxConnectionId(agentId, options = {}) {
|
|
|
218786
218816
|
}
|
|
218787
218817
|
throw new Error(`Timed out waiting for cloud sandbox ${sandbox.connectionName} to register${lastError instanceof Error ? `: ${lastError.message}` : ""}`);
|
|
218788
218818
|
}
|
|
218819
|
+
function getTeleportStatus(agentId, conversationId, teleportId, request = apiRequest) {
|
|
218820
|
+
return request("GET", `/v1/environments/runtimes/${encodeURIComponent(agentId)}/${encodeURIComponent(conversationId)}/teleports/${encodeURIComponent(teleportId)}`, undefined, { signal: AbortSignal.timeout(5000) });
|
|
218821
|
+
}
|
|
218789
218822
|
async function teleportToEnvironment(agentId, conversationId, targetConnectionId, request = apiRequest) {
|
|
218790
218823
|
return request("POST", `/v1/environments/runtimes/${encodeURIComponent(agentId)}/${encodeURIComponent(conversationId)}/teleport`, {
|
|
218791
218824
|
targetConnectionId,
|
|
@@ -223091,8 +223124,8 @@ function isSyncCommand(value) {
|
|
|
223091
223124
|
if (!value || typeof value !== "object") {
|
|
223092
223125
|
return false;
|
|
223093
223126
|
}
|
|
223094
|
-
const
|
|
223095
|
-
return
|
|
223127
|
+
const c = value;
|
|
223128
|
+
return c.type === "sync" && isRuntimeScope(c.runtime) && (c.request_id === undefined || typeof c.request_id === "string") && (c.recover_approvals === undefined || typeof c.recover_approvals === "boolean") && (c.resume_interrupted_turn === undefined || typeof c.resume_interrupted_turn === "boolean") && (c.force_device_status === undefined || typeof c.force_device_status === "boolean");
|
|
223096
223129
|
}
|
|
223097
223130
|
function isTerminalSpawnCommand(value) {
|
|
223098
223131
|
if (!value || typeof value !== "object")
|
|
@@ -397825,6 +397858,108 @@ var init_teleport_guard = __esm(() => {
|
|
|
397825
397858
|
init_routing();
|
|
397826
397859
|
});
|
|
397827
397860
|
|
|
397861
|
+
// src/websocket/listener/interrupted-turn-record.ts
|
|
397862
|
+
import { createHash as createHash9, randomUUID as randomUUID29 } from "node:crypto";
|
|
397863
|
+
import {
|
|
397864
|
+
mkdirSync as mkdirSync36,
|
|
397865
|
+
readdirSync as readdirSync18,
|
|
397866
|
+
readFileSync as readFileSync37,
|
|
397867
|
+
renameSync as renameSync7,
|
|
397868
|
+
rmSync as rmSync13,
|
|
397869
|
+
writeFileSync as writeFileSync27
|
|
397870
|
+
} from "node:fs";
|
|
397871
|
+
import { homedir as homedir34 } from "node:os";
|
|
397872
|
+
import { join as join57 } from "node:path";
|
|
397873
|
+
function createInterruptedTurnStore(directory = join57(homedir34(), ".letta", "listener-state", createHash9("sha256").update(getServerUrl()).digest("hex").slice(0, 24))) {
|
|
397874
|
+
function path43(agentId, conversationId) {
|
|
397875
|
+
return join57(directory, `${encodeURIComponent(agentId)}_${encodeURIComponent(conversationId)}.json`);
|
|
397876
|
+
}
|
|
397877
|
+
function readRecord(file) {
|
|
397878
|
+
try {
|
|
397879
|
+
const value = JSON.parse(readFileSync37(file, "utf8"));
|
|
397880
|
+
if (!value || typeof value.agentId !== "string" || typeof value.conversationId !== "string" || path43(value.agentId, value.conversationId) !== file || !Array.isArray(value.toolCallIds) || !value.toolCallIds.every((id2) => typeof id2 === "string") || !Array.isArray(value.results) || !value.results.every((result2) => result2 && typeof result2.tool_call_id === "string") || typeof value.requestOtid !== "string" || typeof value.workingDirectory !== "string") {
|
|
397881
|
+
throw new Error("Invalid interrupted-turn record");
|
|
397882
|
+
}
|
|
397883
|
+
return value;
|
|
397884
|
+
} catch (error4) {
|
|
397885
|
+
if (error4.code !== "ENOENT") {
|
|
397886
|
+
debugWarn("recovery", "Ignoring unreadable interrupted-turn record", file);
|
|
397887
|
+
}
|
|
397888
|
+
return null;
|
|
397889
|
+
}
|
|
397890
|
+
}
|
|
397891
|
+
return {
|
|
397892
|
+
list() {
|
|
397893
|
+
try {
|
|
397894
|
+
return readdirSync18(directory).filter((file) => file.endsWith(".json")).map((file) => readRecord(join57(directory, file))).filter((record3) => record3 !== null);
|
|
397895
|
+
} catch (error4) {
|
|
397896
|
+
if (error4.code === "ENOENT")
|
|
397897
|
+
return [];
|
|
397898
|
+
throw error4;
|
|
397899
|
+
}
|
|
397900
|
+
},
|
|
397901
|
+
read(agentId, conversationId) {
|
|
397902
|
+
return readRecord(path43(agentId, conversationId));
|
|
397903
|
+
},
|
|
397904
|
+
write(record3) {
|
|
397905
|
+
mkdirSync36(directory, { recursive: true, mode: 448 });
|
|
397906
|
+
const destination = path43(record3.agentId, record3.conversationId);
|
|
397907
|
+
const temporary = `${destination}.${randomUUID29()}.tmp`;
|
|
397908
|
+
try {
|
|
397909
|
+
writeFileSync27(temporary, JSON.stringify({ ...record3, revision: randomUUID29() }), {
|
|
397910
|
+
mode: 384,
|
|
397911
|
+
flush: true
|
|
397912
|
+
});
|
|
397913
|
+
renameSync7(temporary, destination);
|
|
397914
|
+
} finally {
|
|
397915
|
+
rmSync13(temporary, { force: true });
|
|
397916
|
+
}
|
|
397917
|
+
},
|
|
397918
|
+
remove(agentId, conversationId) {
|
|
397919
|
+
rmSync13(path43(agentId, conversationId), { force: true });
|
|
397920
|
+
}
|
|
397921
|
+
};
|
|
397922
|
+
}
|
|
397923
|
+
function readInterruptedTurn(runtime) {
|
|
397924
|
+
if (!runtime.agentId || !runtime.listener.connectionId?.startsWith("conn-"))
|
|
397925
|
+
return null;
|
|
397926
|
+
return createInterruptedTurnStore().read(runtime.agentId, runtime.conversationId);
|
|
397927
|
+
}
|
|
397928
|
+
function recordListenerWork(runtime, update3) {
|
|
397929
|
+
if (!runtime.agentId || !runtime.listener.connectionId?.startsWith("conn-"))
|
|
397930
|
+
return;
|
|
397931
|
+
const previous = readInterruptedTurn(runtime);
|
|
397932
|
+
createInterruptedTurnStore().write({
|
|
397933
|
+
agentId: runtime.agentId,
|
|
397934
|
+
conversationId: runtime.conversationId,
|
|
397935
|
+
runId: previous?.runId ?? null,
|
|
397936
|
+
toolCallIds: previous?.toolCallIds ?? [],
|
|
397937
|
+
results: previous?.results ?? [],
|
|
397938
|
+
requestOtid: previous?.requestOtid ?? randomUUID29(),
|
|
397939
|
+
actingUserId: previous?.actingUserId,
|
|
397940
|
+
workingDirectory: runtime.activeWorkingDirectory ?? previous?.workingDirectory ?? process.cwd(),
|
|
397941
|
+
...update3
|
|
397942
|
+
});
|
|
397943
|
+
}
|
|
397944
|
+
function forgetListenerWork(runtime) {
|
|
397945
|
+
if (runtime.agentId && runtime.listener.connectionId?.startsWith("conn-")) {
|
|
397946
|
+
createInterruptedTurnStore().remove(runtime.agentId, runtime.conversationId);
|
|
397947
|
+
}
|
|
397948
|
+
}
|
|
397949
|
+
function recordedToolResults(record3, pendingToolCallIds) {
|
|
397950
|
+
return pendingToolCallIds.map((id2) => record3.results.find((result2) => result2.tool_call_id === id2) ?? {
|
|
397951
|
+
type: "approval",
|
|
397952
|
+
tool_call_id: id2,
|
|
397953
|
+
approve: false,
|
|
397954
|
+
reason: STALE_APPROVAL_RECOVERY_DENIAL_REASON
|
|
397955
|
+
});
|
|
397956
|
+
}
|
|
397957
|
+
var init_interrupted_turn_record = __esm(() => {
|
|
397958
|
+
init_turn_recovery_policy();
|
|
397959
|
+
init_server_url();
|
|
397960
|
+
init_debug();
|
|
397961
|
+
});
|
|
397962
|
+
|
|
397828
397963
|
// src/websocket/listener/recoverable-notices.ts
|
|
397829
397964
|
function getRecoverableStatusNoticeVisibility(kind) {
|
|
397830
397965
|
switch (kind) {
|
|
@@ -398039,7 +398174,7 @@ function buildTeleportContinuationMessages(params) {
|
|
|
398039
398174
|
otid: params.teleportId
|
|
398040
398175
|
},
|
|
398041
398176
|
{
|
|
398042
|
-
role: "
|
|
398177
|
+
role: "user",
|
|
398043
398178
|
content: "<system-reminder>Teleportation to this environment is complete. Continue the existing task from this environment now.</system-reminder>",
|
|
398044
398179
|
otid: `${params.teleportId}:continue`
|
|
398045
398180
|
}
|
|
@@ -398058,7 +398193,7 @@ function buildTeleportFailureMessages(params) {
|
|
|
398058
398193
|
});
|
|
398059
398194
|
}
|
|
398060
398195
|
messages.push({
|
|
398061
|
-
role: "
|
|
398196
|
+
role: "user",
|
|
398062
398197
|
content: `<system-reminder>Teleportation failed.
|
|
398063
398198
|
|
|
398064
398199
|
Error: ${escapeSystemReminderText(params.error)}
|
|
@@ -398191,9 +398326,8 @@ function handleTeleportRequest(params) {
|
|
|
398191
398326
|
const conversationRuntime = getConversationRuntime(listener, pending.agentId, pending.conversationId);
|
|
398192
398327
|
pending.drainAcceptedInputs = conversationRuntime ? hasAcceptedInputsWaiting(conversationRuntime, true) : false;
|
|
398193
398328
|
if (!conversationRuntime?.isProcessing && !pending.drainAcceptedInputs) {
|
|
398194
|
-
if (
|
|
398329
|
+
if (emitClaimedTeleportReady(listener, pending)) {
|
|
398195
398330
|
pending.readyAt = Date.now();
|
|
398196
|
-
retainTeleportForRecovery(listener, pending);
|
|
398197
398331
|
}
|
|
398198
398332
|
}
|
|
398199
398333
|
}
|
|
@@ -398217,12 +398351,25 @@ function claimPendingTeleportAtBoundary(params) {
|
|
|
398217
398351
|
return pending;
|
|
398218
398352
|
}
|
|
398219
398353
|
function emitClaimedTeleportReady(listener, pending) {
|
|
398354
|
+
if (listener.connectionId?.startsWith("conn-"))
|
|
398355
|
+
suspendRecordedTeleport(pending, true);
|
|
398220
398356
|
const sent = sendTeleportReady(listener, pending, { success: true });
|
|
398221
398357
|
if (sent) {
|
|
398222
398358
|
retainTeleportForRecovery(listener, pending);
|
|
398359
|
+
} else if (listener.connectionId?.startsWith("conn-")) {
|
|
398360
|
+
suspendRecordedTeleport(pending, false);
|
|
398223
398361
|
}
|
|
398224
398362
|
return sent;
|
|
398225
398363
|
}
|
|
398364
|
+
function suspendRecordedTeleport(pending, suspended) {
|
|
398365
|
+
const store3 = createInterruptedTurnStore();
|
|
398366
|
+
const record3 = store3.read(pending.agentId, pending.conversationId);
|
|
398367
|
+
if (record3)
|
|
398368
|
+
store3.write({
|
|
398369
|
+
...record3,
|
|
398370
|
+
teleportId: suspended ? pending.teleportId : undefined
|
|
398371
|
+
});
|
|
398372
|
+
}
|
|
398226
398373
|
function finishTeleport(runtime, lease, pending) {
|
|
398227
398374
|
const transition = runtime.turnLifecycle.finish(lease, "cancelled");
|
|
398228
398375
|
if (!transition.finished)
|
|
@@ -398294,6 +398441,7 @@ var init_teleport = __esm(() => {
|
|
|
398294
398441
|
init_backend_mode();
|
|
398295
398442
|
init_teleport_guard();
|
|
398296
398443
|
init_connection();
|
|
398444
|
+
init_interrupted_turn_record();
|
|
398297
398445
|
init_permission_mode();
|
|
398298
398446
|
init_protocol_outbound();
|
|
398299
398447
|
init_recoverable_notices();
|
|
@@ -398750,14 +398898,14 @@ async function handleSkillCommand(parsed, socket, safeSocketSend) {
|
|
|
398750
398898
|
const {
|
|
398751
398899
|
existsSync: existsSync50,
|
|
398752
398900
|
lstatSync: lstatSync3,
|
|
398753
|
-
mkdirSync:
|
|
398901
|
+
mkdirSync: mkdirSync37,
|
|
398754
398902
|
rmdirSync,
|
|
398755
398903
|
symlinkSync: symlinkSync2,
|
|
398756
398904
|
unlinkSync: unlinkSync10
|
|
398757
398905
|
} = await import("node:fs");
|
|
398758
|
-
const { basename: basename18, join:
|
|
398759
|
-
const lettaHome = process.env.LETTA_HOME ||
|
|
398760
|
-
const globalSkillsDir =
|
|
398906
|
+
const { basename: basename18, join: join58 } = await import("node:path");
|
|
398907
|
+
const lettaHome = process.env.LETTA_HOME || join58(process.env.HOME || process.env.USERPROFILE || "~", ".letta");
|
|
398908
|
+
const globalSkillsDir = join58(lettaHome, "skills");
|
|
398761
398909
|
if (parsed.type === "skill_enable") {
|
|
398762
398910
|
try {
|
|
398763
398911
|
if (!existsSync50(parsed.skill_path)) {
|
|
@@ -398769,7 +398917,7 @@ async function handleSkillCommand(parsed, socket, safeSocketSend) {
|
|
|
398769
398917
|
}, "listener_skill_send_failed", "listener_skill_command");
|
|
398770
398918
|
return true;
|
|
398771
398919
|
}
|
|
398772
|
-
const skillMdPath =
|
|
398920
|
+
const skillMdPath = join58(parsed.skill_path, "SKILL.md");
|
|
398773
398921
|
if (!existsSync50(skillMdPath)) {
|
|
398774
398922
|
safeSocketSend(socket, {
|
|
398775
398923
|
type: "skill_enable_response",
|
|
@@ -398780,8 +398928,8 @@ async function handleSkillCommand(parsed, socket, safeSocketSend) {
|
|
|
398780
398928
|
return true;
|
|
398781
398929
|
}
|
|
398782
398930
|
const linkName = basename18(parsed.skill_path);
|
|
398783
|
-
const linkPath =
|
|
398784
|
-
|
|
398931
|
+
const linkPath = join58(globalSkillsDir, linkName);
|
|
398932
|
+
mkdirSync37(globalSkillsDir, { recursive: true });
|
|
398785
398933
|
if (existsSync50(linkPath)) {
|
|
398786
398934
|
const stat12 = lstatSync3(linkPath);
|
|
398787
398935
|
if (stat12.isSymbolicLink()) {
|
|
@@ -398823,7 +398971,7 @@ async function handleSkillCommand(parsed, socket, safeSocketSend) {
|
|
|
398823
398971
|
}
|
|
398824
398972
|
if (parsed.type === "skill_disable") {
|
|
398825
398973
|
try {
|
|
398826
|
-
const linkPath =
|
|
398974
|
+
const linkPath = join58(globalSkillsDir, parsed.name);
|
|
398827
398975
|
if (!existsSync50(linkPath)) {
|
|
398828
398976
|
safeSocketSend(socket, {
|
|
398829
398977
|
type: "skill_disable_response",
|
|
@@ -400641,7 +400789,7 @@ var init_accumulator = __esm(async () => {
|
|
|
400641
400789
|
});
|
|
400642
400790
|
|
|
400643
400791
|
// src/utils/tui-perf.ts
|
|
400644
|
-
import { appendFileSync as appendFileSync8, mkdirSync as
|
|
400792
|
+
import { appendFileSync as appendFileSync8, mkdirSync as mkdirSync37 } from "node:fs";
|
|
400645
400793
|
import { dirname as dirname28 } from "node:path";
|
|
400646
400794
|
function ensureExitHook() {
|
|
400647
400795
|
if (tuiPerfExitHookRegistered) {
|
|
@@ -400733,7 +400881,7 @@ function flushTuiPerfTelemetry() {
|
|
|
400733
400881
|
try {
|
|
400734
400882
|
const dir = dirname28(filePath);
|
|
400735
400883
|
if (tuiPerfFileDirEnsured !== dir) {
|
|
400736
|
-
|
|
400884
|
+
mkdirSync37(dir, { recursive: true });
|
|
400737
400885
|
tuiPerfFileDirEnsured = dir;
|
|
400738
400886
|
}
|
|
400739
400887
|
appendFileSync8(filePath, `${JSON.stringify({
|
|
@@ -400765,13 +400913,13 @@ var init_tui_perf = __esm(() => {
|
|
|
400765
400913
|
// src/cli/helpers/chunk-log.ts
|
|
400766
400914
|
import {
|
|
400767
400915
|
existsSync as existsSync50,
|
|
400768
|
-
mkdirSync as
|
|
400769
|
-
readdirSync as
|
|
400916
|
+
mkdirSync as mkdirSync38,
|
|
400917
|
+
readdirSync as readdirSync19,
|
|
400770
400918
|
unlinkSync as unlinkSync10,
|
|
400771
|
-
writeFileSync as
|
|
400919
|
+
writeFileSync as writeFileSync28
|
|
400772
400920
|
} from "node:fs";
|
|
400773
|
-
import { homedir as
|
|
400774
|
-
import { join as
|
|
400921
|
+
import { homedir as homedir35 } from "node:os";
|
|
400922
|
+
import { join as join58 } from "node:path";
|
|
400775
400923
|
function truncateStr(value, maxLen) {
|
|
400776
400924
|
if (value === null || value === undefined)
|
|
400777
400925
|
return "";
|
|
@@ -400835,8 +400983,8 @@ class ChunkLog {
|
|
|
400835
400983
|
agentDir = null;
|
|
400836
400984
|
dirCreated = false;
|
|
400837
400985
|
init(agentId, sessionId) {
|
|
400838
|
-
this.agentDir =
|
|
400839
|
-
this.logPath =
|
|
400986
|
+
this.agentDir = join58(LOG_BASE_DIR, agentId);
|
|
400987
|
+
this.logPath = join58(this.agentDir, `${sessionId}.jsonl`);
|
|
400840
400988
|
this.buffer = [];
|
|
400841
400989
|
this.dirty = false;
|
|
400842
400990
|
this.dirCreated = false;
|
|
@@ -400866,7 +401014,7 @@ class ChunkLog {
|
|
|
400866
401014
|
return;
|
|
400867
401015
|
try {
|
|
400868
401016
|
if (!existsSync50(this.agentDir)) {
|
|
400869
|
-
|
|
401017
|
+
mkdirSync38(this.agentDir, { recursive: true });
|
|
400870
401018
|
}
|
|
400871
401019
|
this.dirCreated = true;
|
|
400872
401020
|
} catch (e2) {
|
|
@@ -400880,7 +401028,7 @@ class ChunkLog {
|
|
|
400880
401028
|
try {
|
|
400881
401029
|
const content = this.buffer.map((entry) => JSON.stringify(entry)).join(`
|
|
400882
401030
|
`);
|
|
400883
|
-
|
|
401031
|
+
writeFileSync28(this.logPath, `${content}
|
|
400884
401032
|
`, "utf8");
|
|
400885
401033
|
} catch (e2) {
|
|
400886
401034
|
debugWarn("chunkLog", `Failed to write ${this.logPath}: ${e2 instanceof Error ? e2.message : String(e2)}`);
|
|
@@ -400892,12 +401040,12 @@ class ChunkLog {
|
|
|
400892
401040
|
try {
|
|
400893
401041
|
if (!existsSync50(this.agentDir))
|
|
400894
401042
|
return;
|
|
400895
|
-
const files =
|
|
401043
|
+
const files = readdirSync19(this.agentDir).filter((f4) => f4.endsWith(".jsonl")).sort();
|
|
400896
401044
|
if (files.length >= MAX_SESSION_FILES2) {
|
|
400897
401045
|
const toDelete = files.slice(0, files.length - MAX_SESSION_FILES2 + 1);
|
|
400898
401046
|
for (const file of toDelete) {
|
|
400899
401047
|
try {
|
|
400900
|
-
unlinkSync10(
|
|
401048
|
+
unlinkSync10(join58(this.agentDir, file));
|
|
400901
401049
|
} catch (e2) {
|
|
400902
401050
|
debugWarn("chunkLog", `Failed to delete old session log ${file}: ${e2 instanceof Error ? e2.message : String(e2)}`);
|
|
400903
401051
|
}
|
|
@@ -400911,7 +401059,7 @@ class ChunkLog {
|
|
|
400911
401059
|
var MAX_ENTRIES = 100, CONTENT_TRUNCATE_LEN = 200, MAX_SESSION_FILES2 = 5, LOG_BASE_DIR, chunkLog;
|
|
400912
401060
|
var init_chunk_log = __esm(() => {
|
|
400913
401061
|
init_debug();
|
|
400914
|
-
LOG_BASE_DIR =
|
|
401062
|
+
LOG_BASE_DIR = join58(homedir35(), ".letta", "logs", "chunk-logs");
|
|
400915
401063
|
chunkLog = new ChunkLog;
|
|
400916
401064
|
});
|
|
400917
401065
|
|
|
@@ -402283,6 +402431,9 @@ function finishListenerTurn(runtime, lease, options) {
|
|
|
402283
402431
|
if (!transition.finished) {
|
|
402284
402432
|
return transition;
|
|
402285
402433
|
}
|
|
402434
|
+
if (options.stopReason === "end_turn" || options.stopReason === "cancelled") {
|
|
402435
|
+
forgetListenerWork(runtime);
|
|
402436
|
+
}
|
|
402286
402437
|
if (options.stopReason === "cancelled" && transition.previousKind === "active" && options.socket) {
|
|
402287
402438
|
emitInterruptedStatusDelta(options.socket, runtime, {
|
|
402288
402439
|
runId: options.runId ?? transition.runId,
|
|
@@ -402313,6 +402464,7 @@ function finishListenerTurn(runtime, lease, options) {
|
|
|
402313
402464
|
}
|
|
402314
402465
|
var init_turn_terminal = __esm(() => {
|
|
402315
402466
|
init_connection();
|
|
402467
|
+
init_interrupted_turn_record();
|
|
402316
402468
|
init_protocol_outbound();
|
|
402317
402469
|
});
|
|
402318
402470
|
|
|
@@ -402519,7 +402671,6 @@ async function startRecoveredApprovalContinuation(runtime, socket, processTurn,
|
|
|
402519
402671
|
if (!await canRecoverConversation(runtime)) {
|
|
402520
402672
|
if (runtime.recoveredApprovalState === recovered) {
|
|
402521
402673
|
clearRecoveredApprovalState(runtime);
|
|
402522
|
-
runtime.syncApprovalRecoveryCompleted = false;
|
|
402523
402674
|
}
|
|
402524
402675
|
return false;
|
|
402525
402676
|
}
|
|
@@ -405988,6 +406139,11 @@ async function handleApprovalStop(params) {
|
|
|
405988
406139
|
return interruptTermination();
|
|
405989
406140
|
}
|
|
405990
406141
|
lastExecutingToolCallIds = approvedDecisions.map((decision) => decision.approval.toolCallId);
|
|
406142
|
+
recordListenerWork(runtime, {
|
|
406143
|
+
toolCallIds: decisions.map((decision) => decision.approval.toolCallId),
|
|
406144
|
+
results: [],
|
|
406145
|
+
requestOtid: crypto.randomUUID()
|
|
406146
|
+
});
|
|
405991
406147
|
runtime.turnLifecycle.setExecutingToolCallIds(turnLease, lastExecutingToolCallIds);
|
|
405992
406148
|
setTurnLoopStatus(runtime, turnLease, "EXECUTING_CLIENT_SIDE_TOOL", {
|
|
405993
406149
|
agent_id: agentId,
|
|
@@ -406077,6 +406233,7 @@ async function handleApprovalStop(params) {
|
|
|
406077
406233
|
conversationId
|
|
406078
406234
|
});
|
|
406079
406235
|
lastExecutionResults = persistedExecutionResults;
|
|
406236
|
+
recordListenerWork(runtime, { results: persistedExecutionResults });
|
|
406080
406237
|
emitInterruptToolReturnMessage(socket, runtime, persistedExecutionResults, executionRunId, "tool-return");
|
|
406081
406238
|
if (shouldInterrupt()) {
|
|
406082
406239
|
return interruptTermination();
|
|
@@ -406107,7 +406264,7 @@ async function handleApprovalStop(params) {
|
|
|
406107
406264
|
{
|
|
406108
406265
|
type: "approval",
|
|
406109
406266
|
approvals: persistedExecutionResults,
|
|
406110
|
-
otid: crypto.randomUUID()
|
|
406267
|
+
otid: readInterruptedTurn(runtime)?.requestOtid ?? crypto.randomUUID()
|
|
406111
406268
|
}
|
|
406112
406269
|
]);
|
|
406113
406270
|
let continuationBatchId = dequeuedBatchId;
|
|
@@ -406201,6 +406358,7 @@ var init_turn_approval = __esm(async () => {
|
|
|
406201
406358
|
init_interactive_policy();
|
|
406202
406359
|
init_approval();
|
|
406203
406360
|
init_connection();
|
|
406361
|
+
init_interrupted_turn_record();
|
|
406204
406362
|
init_interrupts();
|
|
406205
406363
|
init_protocol_outbound();
|
|
406206
406364
|
init_secrets_sync();
|
|
@@ -406222,7 +406380,7 @@ var init_turn_approval = __esm(async () => {
|
|
|
406222
406380
|
|
|
406223
406381
|
// src/agent/attached-repository-git-sync.ts
|
|
406224
406382
|
import { existsSync as existsSync51 } from "node:fs";
|
|
406225
|
-
import { join as
|
|
406383
|
+
import { join as join59 } from "node:path";
|
|
406226
406384
|
async function getPendingCommitCount(path44) {
|
|
406227
406385
|
const divergence = await getMemoryAheadBehind(path44);
|
|
406228
406386
|
if (divergence) {
|
|
@@ -406252,7 +406410,7 @@ async function syncPendingAttachedRepositoryCommitsUnlocked(params) {
|
|
|
406252
406410
|
path: path44,
|
|
406253
406411
|
permissions: params.repository.permissions ?? "unknown"
|
|
406254
406412
|
};
|
|
406255
|
-
if (!existsSync51(
|
|
406413
|
+
if (!existsSync51(join59(path44, ".git"))) {
|
|
406256
406414
|
return {
|
|
406257
406415
|
...resultBase,
|
|
406258
406416
|
status: "skipped",
|
|
@@ -407312,12 +407470,12 @@ function rowToolCalls(row, index, diagnostics2) {
|
|
|
407312
407470
|
}
|
|
407313
407471
|
return calls;
|
|
407314
407472
|
}
|
|
407315
|
-
function
|
|
407473
|
+
function contentText(content) {
|
|
407316
407474
|
if (typeof content === "string") {
|
|
407317
407475
|
if (content.startsWith(CONTENT_JSON_PREFIX)) {
|
|
407318
407476
|
const encoded = content.slice(CONTENT_JSON_PREFIX.length);
|
|
407319
407477
|
try {
|
|
407320
|
-
return
|
|
407478
|
+
return contentText(JSON.parse(encoded));
|
|
407321
407479
|
} catch {
|
|
407322
407480
|
return encoded;
|
|
407323
407481
|
}
|
|
@@ -407403,7 +407561,7 @@ var init_hermes = __esm(() => {
|
|
|
407403
407561
|
});
|
|
407404
407562
|
};
|
|
407405
407563
|
if (row.role === "user") {
|
|
407406
|
-
const content =
|
|
407564
|
+
const content = contentText(row.content);
|
|
407407
407565
|
if (content) {
|
|
407408
407566
|
emit({
|
|
407409
407567
|
type: "message",
|
|
@@ -407423,7 +407581,7 @@ var init_hermes = __esm(() => {
|
|
|
407423
407581
|
...timestamp ? { timestamp } : {}
|
|
407424
407582
|
});
|
|
407425
407583
|
}
|
|
407426
|
-
const content =
|
|
407584
|
+
const content = contentText(row.content);
|
|
407427
407585
|
if (content) {
|
|
407428
407586
|
emit({
|
|
407429
407587
|
type: "message",
|
|
@@ -407446,7 +407604,7 @@ var init_hermes = __esm(() => {
|
|
|
407446
407604
|
if (row.role === "tool") {
|
|
407447
407605
|
emit({
|
|
407448
407606
|
type: "tool_result",
|
|
407449
|
-
content:
|
|
407607
|
+
content: contentText(row.content),
|
|
407450
407608
|
...typeof row.tool_call_id === "string" && row.tool_call_id ? { callId: row.tool_call_id } : {},
|
|
407451
407609
|
...timestamp ? { timestamp } : {}
|
|
407452
407610
|
});
|
|
@@ -408713,8 +408871,8 @@ var init_core3 = __esm(() => {
|
|
|
408713
408871
|
// node_modules/@letta-ai/trajectory/dist/adapters/deepagents/index.js
|
|
408714
408872
|
import { spawn as spawn9 } from "node:child_process";
|
|
408715
408873
|
import { accessSync as accessSync2, constants as constants6 } from "node:fs";
|
|
408716
|
-
import { homedir as
|
|
408717
|
-
import { join as
|
|
408874
|
+
import { homedir as homedir36 } from "node:os";
|
|
408875
|
+
import { join as join60 } from "node:path";
|
|
408718
408876
|
import { fileURLToPath as fileURLToPath9 } from "node:url";
|
|
408719
408877
|
async function normalizeCheckpoint(input) {
|
|
408720
408878
|
const { decoded, bounds, filters } = await decodeCheckpoint(input);
|
|
@@ -408738,7 +408896,7 @@ async function decodeCheckpoint(input) {
|
|
|
408738
408896
|
}
|
|
408739
408897
|
async function loadDeepAgentsCheckpoint(checkpoint) {
|
|
408740
408898
|
validateLocation(checkpoint);
|
|
408741
|
-
const path44 = checkpoint.path ??
|
|
408899
|
+
const path44 = checkpoint.path ?? join60(homedir36(), ".deepagents", "sessions.db");
|
|
408742
408900
|
const python = checkpoint.pythonExecutable ?? process.env.PYTHON ?? "python3";
|
|
408743
408901
|
const helper = resolveHelperPath();
|
|
408744
408902
|
return await new Promise((resolve36, reject2) => {
|
|
@@ -408957,8 +409115,8 @@ var init_deepagents = __esm(() => {
|
|
|
408957
409115
|
});
|
|
408958
409116
|
|
|
408959
409117
|
// node_modules/@letta-ai/trajectory/dist/adapters/listing-shared.js
|
|
408960
|
-
import { readdirSync as
|
|
408961
|
-
import { join as
|
|
409118
|
+
import { readdirSync as readdirSync20, statSync as statSync18 } from "node:fs";
|
|
409119
|
+
import { join as join61 } from "node:path";
|
|
408962
409120
|
function sortListings(items3) {
|
|
408963
409121
|
return items3.sort((left, right) => {
|
|
408964
409122
|
const l3 = left.updatedAt ?? "";
|
|
@@ -408970,7 +409128,7 @@ function sortListings(items3) {
|
|
|
408970
409128
|
}
|
|
408971
409129
|
function safeReadDir(path44) {
|
|
408972
409130
|
try {
|
|
408973
|
-
return
|
|
409131
|
+
return readdirSync20(path44, { withFileTypes: true }).map((entry) => ({
|
|
408974
409132
|
name: entry.name,
|
|
408975
409133
|
isDirectory: entry.isDirectory(),
|
|
408976
409134
|
isFile: entry.isFile()
|
|
@@ -409003,7 +409161,7 @@ function collectFiles(root2, extension, depth) {
|
|
|
409003
409161
|
return [];
|
|
409004
409162
|
const collected = [];
|
|
409005
409163
|
for (const entry of safeReadDir(root2)) {
|
|
409006
|
-
const full =
|
|
409164
|
+
const full = join61(root2, entry.name);
|
|
409007
409165
|
if (entry.isFile && entry.name.endsWith(extension)) {
|
|
409008
409166
|
collected.push(full);
|
|
409009
409167
|
} else if (entry.isDirectory) {
|
|
@@ -409087,19 +409245,19 @@ var init_listing_shared = __esm(() => {
|
|
|
409087
409245
|
});
|
|
409088
409246
|
|
|
409089
409247
|
// node_modules/@letta-ai/trajectory/dist/adapters/claude-code/list.js
|
|
409090
|
-
import { homedir as
|
|
409091
|
-
import { basename as basename20, join as
|
|
409248
|
+
import { homedir as homedir37 } from "node:os";
|
|
409249
|
+
import { basename as basename20, join as join62 } from "node:path";
|
|
409092
409250
|
async function listClaudeCodeTrajectories(root2) {
|
|
409093
|
-
const base2 = root2 ??
|
|
409251
|
+
const base2 = root2 ?? join62(homedir37(), ".claude", "projects");
|
|
409094
409252
|
const items3 = [];
|
|
409095
409253
|
for (const project of safeReadDir(base2)) {
|
|
409096
409254
|
if (!project.isDirectory)
|
|
409097
409255
|
continue;
|
|
409098
|
-
const projectPath =
|
|
409256
|
+
const projectPath = join62(base2, project.name);
|
|
409099
409257
|
for (const entry of safeReadDir(projectPath)) {
|
|
409100
409258
|
if (!entry.isFile || !entry.name.endsWith(".jsonl"))
|
|
409101
409259
|
continue;
|
|
409102
|
-
const path44 =
|
|
409260
|
+
const path44 = join62(projectPath, entry.name);
|
|
409103
409261
|
const listing = listingFromFile(basename20(entry.name, ".jsonl"), path44);
|
|
409104
409262
|
if (listing)
|
|
409105
409263
|
items3.push(listing);
|
|
@@ -409112,10 +409270,10 @@ var init_list = __esm(() => {
|
|
|
409112
409270
|
});
|
|
409113
409271
|
|
|
409114
409272
|
// node_modules/@letta-ai/trajectory/dist/adapters/codex/list.js
|
|
409115
|
-
import { homedir as
|
|
409116
|
-
import { basename as basename21, join as
|
|
409273
|
+
import { homedir as homedir38 } from "node:os";
|
|
409274
|
+
import { basename as basename21, join as join63 } from "node:path";
|
|
409117
409275
|
async function listCodexTrajectories(root2) {
|
|
409118
|
-
const base2 = root2 ??
|
|
409276
|
+
const base2 = root2 ?? join63(homedir38(), ".codex", "sessions");
|
|
409119
409277
|
const items3 = [];
|
|
409120
409278
|
for (const path44 of collectFiles(base2, ".jsonl", 4)) {
|
|
409121
409279
|
const listing = listingFromFile(basename21(path44, ".jsonl"), path44);
|
|
@@ -409129,8 +409287,8 @@ var init_list2 = __esm(() => {
|
|
|
409129
409287
|
});
|
|
409130
409288
|
|
|
409131
409289
|
// node_modules/@letta-ai/trajectory/dist/adapters/deepagents/list.js
|
|
409132
|
-
import { homedir as
|
|
409133
|
-
import { join as
|
|
409290
|
+
import { homedir as homedir39 } from "node:os";
|
|
409291
|
+
import { join as join64 } from "node:path";
|
|
409134
409292
|
async function listDeepAgentsTrajectories(root2) {
|
|
409135
409293
|
const path44 = resolveStorePath(root2);
|
|
409136
409294
|
if (!safeStat(path44))
|
|
@@ -409151,16 +409309,16 @@ async function listDeepAgentsTrajectories(root2) {
|
|
|
409151
409309
|
}
|
|
409152
409310
|
function resolveStorePath(root2) {
|
|
409153
409311
|
if (root2 === undefined)
|
|
409154
|
-
return
|
|
409155
|
-
return root2.endsWith(".db") ? root2 :
|
|
409312
|
+
return join64(homedir39(), ".deepagents", "sessions.db");
|
|
409313
|
+
return root2.endsWith(".db") ? root2 : join64(root2, "sessions.db");
|
|
409156
409314
|
}
|
|
409157
409315
|
var init_list3 = __esm(() => {
|
|
409158
409316
|
init_listing_shared();
|
|
409159
409317
|
});
|
|
409160
409318
|
|
|
409161
409319
|
// node_modules/@letta-ai/trajectory/dist/adapters/hermes/list.js
|
|
409162
|
-
import { homedir as
|
|
409163
|
-
import { join as
|
|
409320
|
+
import { homedir as homedir40 } from "node:os";
|
|
409321
|
+
import { join as join65 } from "node:path";
|
|
409164
409322
|
async function listHermesTrajectories(root2) {
|
|
409165
409323
|
const path44 = resolveStorePath2(root2);
|
|
409166
409324
|
if (!safeStat(path44))
|
|
@@ -409187,8 +409345,8 @@ async function listHermesTrajectories(root2) {
|
|
|
409187
409345
|
}
|
|
409188
409346
|
function resolveStorePath2(root2) {
|
|
409189
409347
|
if (root2 === undefined)
|
|
409190
|
-
return
|
|
409191
|
-
return root2.endsWith(".db") ? root2 :
|
|
409348
|
+
return join65(homedir40(), ".hermes", "state.db");
|
|
409349
|
+
return root2.endsWith(".db") ? root2 : join65(root2, "state.db");
|
|
409192
409350
|
}
|
|
409193
409351
|
function numeric2(value) {
|
|
409194
409352
|
return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : undefined;
|
|
@@ -409198,19 +409356,19 @@ var init_list4 = __esm(() => {
|
|
|
409198
409356
|
});
|
|
409199
409357
|
|
|
409200
409358
|
// node_modules/@letta-ai/trajectory/dist/adapters/letta-code/list.js
|
|
409201
|
-
import { homedir as
|
|
409202
|
-
import { join as
|
|
409359
|
+
import { homedir as homedir41 } from "node:os";
|
|
409360
|
+
import { join as join66 } from "node:path";
|
|
409203
409361
|
async function listLettaCodeTrajectories(root2) {
|
|
409204
|
-
const base2 = root2 ??
|
|
409362
|
+
const base2 = root2 ?? join66(homedir41(), ".letta", "transcripts");
|
|
409205
409363
|
const items3 = [];
|
|
409206
409364
|
for (const agent of safeReadDir(base2)) {
|
|
409207
409365
|
if (!agent.isDirectory)
|
|
409208
409366
|
continue;
|
|
409209
|
-
const agentPath =
|
|
409367
|
+
const agentPath = join66(base2, agent.name);
|
|
409210
409368
|
for (const conversation of safeReadDir(agentPath)) {
|
|
409211
409369
|
if (!conversation.isDirectory)
|
|
409212
409370
|
continue;
|
|
409213
|
-
const path44 =
|
|
409371
|
+
const path44 = join66(agentPath, conversation.name, "transcript.jsonl");
|
|
409214
409372
|
const listing = listingFromFile(`${agent.name}/${conversation.name}`, path44);
|
|
409215
409373
|
if (listing && (listing.sizeBytes ?? 0) > 0)
|
|
409216
409374
|
items3.push(listing);
|
|
@@ -409224,20 +409382,20 @@ var init_list5 = __esm(() => {
|
|
|
409224
409382
|
|
|
409225
409383
|
// node_modules/@letta-ai/trajectory/dist/adapters/openclaw/list.js
|
|
409226
409384
|
import { existsSync as existsSync52 } from "node:fs";
|
|
409227
|
-
import { homedir as
|
|
409228
|
-
import { basename as basename22, join as
|
|
409385
|
+
import { homedir as homedir42 } from "node:os";
|
|
409386
|
+
import { basename as basename22, join as join67 } from "node:path";
|
|
409229
409387
|
async function listOpenClawTrajectories(root2) {
|
|
409230
409388
|
const base2 = root2 ?? defaultStateDir();
|
|
409231
409389
|
const items3 = [];
|
|
409232
|
-
const agentsPath =
|
|
409390
|
+
const agentsPath = join67(base2, "agents");
|
|
409233
409391
|
for (const agent of safeReadDir(agentsPath)) {
|
|
409234
409392
|
if (!agent.isDirectory)
|
|
409235
409393
|
continue;
|
|
409236
|
-
const sessionsPath =
|
|
409394
|
+
const sessionsPath = join67(agentsPath, agent.name, "sessions");
|
|
409237
409395
|
for (const entry of safeReadDir(sessionsPath)) {
|
|
409238
409396
|
if (!entry.isFile || !entry.name.endsWith(".jsonl"))
|
|
409239
409397
|
continue;
|
|
409240
|
-
const path44 =
|
|
409398
|
+
const path44 = join67(sessionsPath, entry.name);
|
|
409241
409399
|
const listing = listingFromFile(basename22(entry.name, ".jsonl"), path44);
|
|
409242
409400
|
if (listing)
|
|
409243
409401
|
items3.push(listing);
|
|
@@ -409249,25 +409407,25 @@ function defaultStateDir() {
|
|
|
409249
409407
|
const override = process.env.OPENCLAW_STATE_DIR?.trim() || process.env.CLAWDBOT_STATE_DIR?.trim();
|
|
409250
409408
|
if (override)
|
|
409251
409409
|
return override;
|
|
409252
|
-
const current =
|
|
409410
|
+
const current = join67(homedir42(), ".openclaw");
|
|
409253
409411
|
if (existsSync52(current))
|
|
409254
409412
|
return current;
|
|
409255
|
-
return
|
|
409413
|
+
return join67(homedir42(), ".clawdbot");
|
|
409256
409414
|
}
|
|
409257
409415
|
var init_list6 = __esm(() => {
|
|
409258
409416
|
init_listing_shared();
|
|
409259
409417
|
});
|
|
409260
409418
|
|
|
409261
409419
|
// node_modules/@letta-ai/trajectory/dist/adapters/openhands/list.js
|
|
409262
|
-
import { homedir as
|
|
409263
|
-
import { join as
|
|
409420
|
+
import { homedir as homedir43 } from "node:os";
|
|
409421
|
+
import { join as join68 } from "node:path";
|
|
409264
409422
|
async function listOpenHandsTrajectories(root2) {
|
|
409265
|
-
const base2 = root2 ??
|
|
409423
|
+
const base2 = root2 ?? join68(homedir43(), ".openhands", "sessions");
|
|
409266
409424
|
const items3 = [];
|
|
409267
409425
|
for (const entry of safeReadDir(base2)) {
|
|
409268
409426
|
if (!entry.isDirectory)
|
|
409269
409427
|
continue;
|
|
409270
|
-
const path44 =
|
|
409428
|
+
const path44 = join68(base2, entry.name);
|
|
409271
409429
|
const facts = safeStat(path44);
|
|
409272
409430
|
items3.push({
|
|
409273
409431
|
id: entry.name,
|
|
@@ -409692,7 +409850,7 @@ import {
|
|
|
409692
409850
|
stat as stat13,
|
|
409693
409851
|
writeFile as writeFile14
|
|
409694
409852
|
} from "node:fs/promises";
|
|
409695
|
-
import { join as
|
|
409853
|
+
import { join as join69 } from "node:path";
|
|
409696
409854
|
function buildReflectionSelectorPrompt(options) {
|
|
409697
409855
|
const lines = [
|
|
409698
409856
|
'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.',
|
|
@@ -409726,7 +409884,7 @@ async function collectParentMemoryFiles(memoryDir) {
|
|
|
409726
409884
|
return a2.name.localeCompare(b3.name);
|
|
409727
409885
|
});
|
|
409728
409886
|
for (const entry of sortedEntries) {
|
|
409729
|
-
const entryPath =
|
|
409887
|
+
const entryPath = join69(currentDir, entry.name);
|
|
409730
409888
|
const relativePath = relativeDir ? `${relativeDir}/${entry.name}` : entry.name;
|
|
409731
409889
|
if (entry.isDirectory()) {
|
|
409732
409890
|
await walk3(entryPath, relativePath);
|
|
@@ -410142,17 +410300,17 @@ async function writeState(paths, state) {
|
|
|
410142
410300
|
}
|
|
410143
410301
|
function buildPayloadPath(rootDir, kind) {
|
|
410144
410302
|
const nonce = Math.random().toString(36).slice(2, 8);
|
|
410145
|
-
return
|
|
410303
|
+
return join69(rootDir, `payload-${kind}-${nonce}.json`);
|
|
410146
410304
|
}
|
|
410147
410305
|
function getAgentTranscriptRoot(agentId) {
|
|
410148
|
-
return
|
|
410306
|
+
return join69(getTranscriptRoot(), sanitizePathSegment2(agentId));
|
|
410149
410307
|
}
|
|
410150
410308
|
function getReflectionTranscriptPaths(agentId, conversationId) {
|
|
410151
|
-
const rootDir =
|
|
410309
|
+
const rootDir = join69(getTranscriptRoot(), sanitizePathSegment2(agentId), sanitizePathSegment2(conversationId));
|
|
410152
410310
|
return {
|
|
410153
410311
|
rootDir,
|
|
410154
|
-
transcriptPath:
|
|
410155
|
-
statePath:
|
|
410312
|
+
transcriptPath: join69(rootDir, "transcript.jsonl"),
|
|
410313
|
+
statePath: join69(rootDir, "state.json")
|
|
410156
410314
|
};
|
|
410157
410315
|
}
|
|
410158
410316
|
async function appendTranscriptDeltaJsonl(agentId, conversationId, lines) {
|
|
@@ -410242,7 +410400,7 @@ async function getTranscriptLastUpdatedAt(paths) {
|
|
|
410242
410400
|
}
|
|
410243
410401
|
}
|
|
410244
410402
|
async function ensureAgentPayloadRoot(agentId) {
|
|
410245
|
-
const root2 =
|
|
410403
|
+
const root2 = join69(getAgentTranscriptRoot(agentId), "multi-reflection-payloads");
|
|
410246
410404
|
await mkdir13(root2, { recursive: true });
|
|
410247
410405
|
return root2;
|
|
410248
410406
|
}
|
|
@@ -410803,10 +410961,10 @@ var init_post_turn_reflection = __esm(() => {
|
|
|
410803
410961
|
|
|
410804
410962
|
// src/agent/memory-worktree.ts
|
|
410805
410963
|
import { execFile as execFileCb4 } from "node:child_process";
|
|
410806
|
-
import { randomUUID as
|
|
410964
|
+
import { randomUUID as randomUUID30 } from "node:crypto";
|
|
410807
410965
|
import { existsSync as existsSync53 } from "node:fs";
|
|
410808
410966
|
import { mkdir as mkdir14 } from "node:fs/promises";
|
|
410809
|
-
import { dirname as dirname29, isAbsolute as isAbsolute28, join as
|
|
410967
|
+
import { dirname as dirname29, isAbsolute as isAbsolute28, join as join70, resolve as resolve36 } from "node:path";
|
|
410810
410968
|
import { promisify as promisify14 } from "node:util";
|
|
410811
410969
|
async function runGit4(cwd2, args) {
|
|
410812
410970
|
try {
|
|
@@ -410847,7 +411005,7 @@ function normalizeGitPath(path44, cwd2) {
|
|
|
410847
411005
|
}
|
|
410848
411006
|
function buildReflectionWorktreeId(now2 = new Date) {
|
|
410849
411007
|
const timestamp = now2.toISOString().replace(/[^0-9]/g, "").slice(0, 14);
|
|
410850
|
-
return `${timestamp}-${
|
|
411008
|
+
return `${timestamp}-${randomUUID30().slice(0, 8)}`;
|
|
410851
411009
|
}
|
|
410852
411010
|
function summarizeReflectionCommitSubject(subject) {
|
|
410853
411011
|
const summary = subject.trim().replace(/^[a-z]+(?:\([^)]+\))?!?:\s*/i, "").trim();
|
|
@@ -410866,8 +411024,8 @@ async function buildReflectionMergeMessage(parentMemoryDir, branchName) {
|
|
|
410866
411024
|
async function createReflectionMemoryWorktree(options) {
|
|
410867
411025
|
const parentMemoryDir = resolve36(options.parentMemoryDir);
|
|
410868
411026
|
const id2 = buildReflectionWorktreeId(options.now);
|
|
410869
|
-
const worktreeBaseDir =
|
|
410870
|
-
const worktreeDir =
|
|
411027
|
+
const worktreeBaseDir = join70(dirname29(parentMemoryDir), "memory-worktrees");
|
|
411028
|
+
const worktreeDir = join70(worktreeBaseDir, `reflection-${id2}`);
|
|
410871
411029
|
const branchName = `letta/reflection/${id2}`;
|
|
410872
411030
|
await mkdir14(worktreeBaseDir, { recursive: true });
|
|
410873
411031
|
const { stdout: baseHeadOut } = await runGit4(parentMemoryDir, [
|
|
@@ -411466,7 +411624,7 @@ var init_reflection_retry = __esm(() => {
|
|
|
411466
411624
|
});
|
|
411467
411625
|
|
|
411468
411626
|
// src/telemetry/reflection-threshold-feedback.ts
|
|
411469
|
-
import { randomUUID as
|
|
411627
|
+
import { randomUUID as randomUUID31 } from "node:crypto";
|
|
411470
411628
|
async function resolveFeedbackApiKey() {
|
|
411471
411629
|
const settings3 = await settingsManager.getSettingsWithSecureTokens();
|
|
411472
411630
|
return process.env.LETTA_API_KEY || settings3.env?.LETTA_API_KEY;
|
|
@@ -411478,7 +411636,7 @@ function getFeedbackDeviceId() {
|
|
|
411478
411636
|
return deviceId;
|
|
411479
411637
|
}
|
|
411480
411638
|
} catch {}
|
|
411481
|
-
return
|
|
411639
|
+
return randomUUID31();
|
|
411482
411640
|
}
|
|
411483
411641
|
function getAlertDeviceType() {
|
|
411484
411642
|
switch (process.platform) {
|
|
@@ -413453,16 +413611,18 @@ function extractTelemetryInputText(content) {
|
|
|
413453
413611
|
}
|
|
413454
413612
|
|
|
413455
413613
|
// src/websocket/listener/turn-transcript.ts
|
|
413456
|
-
function trackListenerUserInput(messages, modelId) {
|
|
413457
|
-
|
|
413458
|
-
|
|
413459
|
-
|
|
413460
|
-
|
|
413461
|
-
|
|
413462
|
-
|
|
413463
|
-
|
|
413614
|
+
function trackListenerUserInput(messages, modelId, actingUserId) {
|
|
413615
|
+
runWithRuntimeContext({ actingUserId }, () => {
|
|
413616
|
+
for (const message of messages) {
|
|
413617
|
+
if (!("role" in message) || message.role !== "user") {
|
|
413618
|
+
continue;
|
|
413619
|
+
}
|
|
413620
|
+
const inputText = extractTelemetryInputText(message.content);
|
|
413621
|
+
if (inputText.length > 0) {
|
|
413622
|
+
telemetry.trackUserInput(inputText, "user", modelId);
|
|
413623
|
+
}
|
|
413464
413624
|
}
|
|
413465
|
-
}
|
|
413625
|
+
});
|
|
413466
413626
|
}
|
|
413467
413627
|
function buildInboundUserTranscriptLines(messages) {
|
|
413468
413628
|
const lines = [];
|
|
@@ -413497,6 +413657,7 @@ function seedInboundUserTranscriptLines(buffers, lines) {
|
|
|
413497
413657
|
}
|
|
413498
413658
|
}
|
|
413499
413659
|
var init_turn_transcript = __esm(() => {
|
|
413660
|
+
init_runtime_context();
|
|
413500
413661
|
init_telemetry();
|
|
413501
413662
|
});
|
|
413502
413663
|
|
|
@@ -413609,7 +413770,7 @@ async function prepareListenerTurn(params) {
|
|
|
413609
413770
|
if (connectionId) {
|
|
413610
413771
|
onStatusChange?.("processing", connectionId);
|
|
413611
413772
|
}
|
|
413612
|
-
trackListenerUserInput(msg.messages, "unknown");
|
|
413773
|
+
trackListenerUserInput(msg.messages, "unknown", msg.actingUserId);
|
|
413613
413774
|
const messagesToSend = [];
|
|
413614
413775
|
let queuedInterruptedToolCallIds = [];
|
|
413615
413776
|
const wasInterrupted = hasInterruptedCacheForScope(runtime.listener, {
|
|
@@ -413854,6 +414015,10 @@ async function drainTurnStreamWithEmission(stream12, buffers, socket, runtime, p
|
|
|
413854
414015
|
runtime.turnLifecycle.setRunId(turnLease, maybeRunId);
|
|
413855
414016
|
turnCorrelation.observeRun(maybeRunId);
|
|
413856
414017
|
if (!runIdSent) {
|
|
414018
|
+
recordListenerWork(runtime, {
|
|
414019
|
+
runId: maybeRunId,
|
|
414020
|
+
actingUserId: getStreamRequestContext(stream12)?.actingUserId
|
|
414021
|
+
});
|
|
413857
414022
|
runIdSent = true;
|
|
413858
414023
|
msgRunIds.push(maybeRunId);
|
|
413859
414024
|
emitLoopStatusUpdate(socket, runtime, {
|
|
@@ -413901,10 +414066,12 @@ var init_turn_stream = __esm(async () => {
|
|
|
413901
414066
|
init_debug();
|
|
413902
414067
|
init_cloud_retry_message();
|
|
413903
414068
|
init_constants3();
|
|
414069
|
+
init_interrupted_turn_record();
|
|
413904
414070
|
init_interrupts();
|
|
413905
414071
|
init_protocol_outbound();
|
|
413906
414072
|
init_recoverable_notices();
|
|
413907
414073
|
await __promiseAll([
|
|
414074
|
+
init_message(),
|
|
413908
414075
|
init_stream(),
|
|
413909
414076
|
init_recovery()
|
|
413910
414077
|
]);
|
|
@@ -414214,7 +414381,7 @@ async function handleIncomingMessageInner(msg, socket, runtime, onStatusChange,
|
|
|
414214
414381
|
...turnInput.messages,
|
|
414215
414382
|
{
|
|
414216
414383
|
type: "message",
|
|
414217
|
-
role: "
|
|
414384
|
+
role: "user",
|
|
414218
414385
|
content: "<system-reminder>The previous response was empty. Please provide a response with either text content or a tool call.</system-reminder>"
|
|
414219
414386
|
}
|
|
414220
414387
|
]);
|
|
@@ -415538,7 +415705,7 @@ var init_grep_in_files = __esm(() => {
|
|
|
415538
415705
|
|
|
415539
415706
|
// src/websocket/listener/file-commands.ts
|
|
415540
415707
|
import { readdir as readdir10, readFile as readFile21 } from "node:fs/promises";
|
|
415541
|
-
import { homedir as
|
|
415708
|
+
import { homedir as homedir44 } from "node:os";
|
|
415542
415709
|
import path46 from "node:path";
|
|
415543
415710
|
function trackListenerError3(errorType, error4, context3) {
|
|
415544
415711
|
trackBoundaryError({
|
|
@@ -415558,7 +415725,7 @@ function isWithinOrEqual(parent, child) {
|
|
|
415558
415725
|
return relative13 === "" || !relative13.startsWith("..") && !path46.isAbsolute(relative13);
|
|
415559
415726
|
}
|
|
415560
415727
|
function getHomeDirectory() {
|
|
415561
|
-
return normalizeAbsPath(process.env.HOME ||
|
|
415728
|
+
return normalizeAbsPath(process.env.HOME || homedir44());
|
|
415562
415729
|
}
|
|
415563
415730
|
function isHomeDirectory(absPath) {
|
|
415564
415731
|
return normalizeAbsPath(absPath) === getHomeDirectory();
|
|
@@ -416485,7 +416652,7 @@ __export(exports_custom, {
|
|
|
416485
416652
|
});
|
|
416486
416653
|
import { existsSync as existsSync55 } from "node:fs";
|
|
416487
416654
|
import { readdir as readdir11, readFile as readFile22 } from "node:fs/promises";
|
|
416488
|
-
import { basename as basename24, dirname as dirname30, join as
|
|
416655
|
+
import { basename as basename24, dirname as dirname30, join as join71 } from "node:path";
|
|
416489
416656
|
async function getCustomCommands() {
|
|
416490
416657
|
if (cachedCommands !== null) {
|
|
416491
416658
|
return cachedCommands;
|
|
@@ -416496,7 +416663,7 @@ async function getCustomCommands() {
|
|
|
416496
416663
|
function refreshCustomCommands() {
|
|
416497
416664
|
cachedCommands = null;
|
|
416498
416665
|
}
|
|
416499
|
-
async function discoverCustomCommands(projectPath =
|
|
416666
|
+
async function discoverCustomCommands(projectPath = join71(process.cwd(), COMMANDS_DIR)) {
|
|
416500
416667
|
const commandsById = new Map;
|
|
416501
416668
|
const userCommands = await discoverFromDirectory(GLOBAL_COMMANDS_DIR, "user");
|
|
416502
416669
|
for (const cmd of userCommands) {
|
|
@@ -416528,7 +416695,7 @@ async function findCommandFiles(currentPath, rootPath, commands, source) {
|
|
|
416528
416695
|
try {
|
|
416529
416696
|
const entries = await readdir11(currentPath, { withFileTypes: true });
|
|
416530
416697
|
for (const entry of entries) {
|
|
416531
|
-
const fullPath =
|
|
416698
|
+
const fullPath = join71(currentPath, entry.name);
|
|
416532
416699
|
if (entry.isDirectory()) {
|
|
416533
416700
|
await findCommandFiles(fullPath, rootPath, commands, source);
|
|
416534
416701
|
} else if (entry.isFile() && entry.name.endsWith(".md")) {
|
|
@@ -416613,7 +416780,7 @@ async function findCustomCommand(commandName) {
|
|
|
416613
416780
|
}
|
|
416614
416781
|
var COMMANDS_DIR = ".commands", GLOBAL_COMMANDS_DIR, cachedCommands = null;
|
|
416615
416782
|
var init_custom = __esm(() => {
|
|
416616
|
-
GLOBAL_COMMANDS_DIR =
|
|
416783
|
+
GLOBAL_COMMANDS_DIR = join71(process.env.HOME || process.env.USERPROFILE || "~", ".letta/commands");
|
|
416617
416784
|
});
|
|
416618
416785
|
|
|
416619
416786
|
// src/cli/helpers/doctor-command.ts
|
|
@@ -418403,6 +418570,7 @@ function summarizeV2Command(parsed) {
|
|
|
418403
418570
|
"replace_all",
|
|
418404
418571
|
"expected_replacements",
|
|
418405
418572
|
"recover_approvals",
|
|
418573
|
+
"resume_interrupted_turn",
|
|
418406
418574
|
"force_device_status"
|
|
418407
418575
|
]) {
|
|
418408
418576
|
pushField(fields, key2, parsed[key2]);
|
|
@@ -418869,6 +419037,7 @@ function createListenerMessageHandler(params) {
|
|
|
418869
419037
|
try {
|
|
418870
419038
|
await replaySyncStateForRuntime(runtime, socket, parsed.runtime, {
|
|
418871
419039
|
recoverApprovals: parsed.recover_approvals !== false,
|
|
419040
|
+
resumeInterruptedTurn: parsed.resume_interrupted_turn === true,
|
|
418872
419041
|
forceDeviceStatus: parsed.force_device_status === true,
|
|
418873
419042
|
onStatusChange: opts.onStatusChange,
|
|
418874
419043
|
connectionId: opts.connectionId
|
|
@@ -419444,11 +419613,177 @@ var init_process_services = __esm(async () => {
|
|
|
419444
419613
|
]);
|
|
419445
419614
|
});
|
|
419446
419615
|
|
|
419616
|
+
// src/websocket/listener/recover-recorded-turn.ts
|
|
419617
|
+
import { randomUUID as randomUUID32 } from "node:crypto";
|
|
419618
|
+
function scheduleRecordedTurnRecovery(listener, recover = recoverRecordedTurns) {
|
|
419619
|
+
setImmediate(() => {
|
|
419620
|
+
if (listener !== getActiveRuntime() || listener.intentionallyClosed)
|
|
419621
|
+
return;
|
|
419622
|
+
recover(listener).catch((error4) => {
|
|
419623
|
+
debugWarn("recovery", "Recorded restart recovery failed", error4);
|
|
419624
|
+
});
|
|
419625
|
+
});
|
|
419626
|
+
}
|
|
419627
|
+
async function recoverRecordedTurns(listener, deps = {}) {
|
|
419628
|
+
if (!listener.connectionId?.startsWith("conn-") || listener.intentionallyClosed || recovering.has(listener))
|
|
419629
|
+
return;
|
|
419630
|
+
recovering.add(listener);
|
|
419631
|
+
const timer = retryTimers.get(listener);
|
|
419632
|
+
if (timer)
|
|
419633
|
+
clearTimeout(timer);
|
|
419634
|
+
retryTimers.delete(listener);
|
|
419635
|
+
const store3 = deps.store ?? createInterruptedTurnStore();
|
|
419636
|
+
const canRecover = deps.canRecover ?? canRecoverConversation;
|
|
419637
|
+
let deferred2 = false;
|
|
419638
|
+
try {
|
|
419639
|
+
for (const record3 of store3.list()) {
|
|
419640
|
+
const runtime = getOrCreateScopedRuntime(listener, record3.agentId, record3.conversationId);
|
|
419641
|
+
const unchanged = () => runtime.turnLifecycle.kind === "idle" && !listener.intentionallyClosed && store3.read(record3.agentId, record3.conversationId)?.revision === record3.revision;
|
|
419642
|
+
if (runtime.turnLifecycle.kind !== "idle")
|
|
419643
|
+
continue;
|
|
419644
|
+
if (!await canRecover(runtime)) {
|
|
419645
|
+
deferred2 = true;
|
|
419646
|
+
continue;
|
|
419647
|
+
}
|
|
419648
|
+
try {
|
|
419649
|
+
if (record3.teleportId) {
|
|
419650
|
+
const teleport = await (deps.teleportStatus ?? getTeleportStatus)(record3.agentId, record3.conversationId, record3.teleportId);
|
|
419651
|
+
if (!unchanged())
|
|
419652
|
+
continue;
|
|
419653
|
+
if (teleport.status === "completed") {
|
|
419654
|
+
store3.remove(record3.agentId, record3.conversationId);
|
|
419655
|
+
} else if (teleport.status === "failed") {
|
|
419656
|
+
store3.write({ ...record3, teleportId: undefined });
|
|
419657
|
+
deferred2 = true;
|
|
419658
|
+
} else {
|
|
419659
|
+
deferred2 = true;
|
|
419660
|
+
}
|
|
419661
|
+
continue;
|
|
419662
|
+
}
|
|
419663
|
+
const backend3 = deps.backend ?? getBackend();
|
|
419664
|
+
const agent = await backend3.retrieveAgent(record3.agentId);
|
|
419665
|
+
const pending = (await (deps.resume ?? getResumeDataFromBackend)(agent, record3.conversationId, { includeMessageHistory: false })).pendingApprovals;
|
|
419666
|
+
if (!unchanged())
|
|
419667
|
+
continue;
|
|
419668
|
+
let recordedRunId = record3.runId;
|
|
419669
|
+
if (record3.results.length && (!pending.length || pending.some((approval) => !record3.toolCallIds.includes(approval.toolCallId)))) {
|
|
419670
|
+
const stream12 = await backend3.streamConversationMessages(record3.conversationId, {
|
|
419671
|
+
otid: record3.requestOtid,
|
|
419672
|
+
starting_after: 0,
|
|
419673
|
+
...record3.conversationId === "default" ? { agent_id: record3.agentId } : {}
|
|
419674
|
+
}, { signal: AbortSignal.timeout(5000), maxRetries: 0 });
|
|
419675
|
+
try {
|
|
419676
|
+
for await (const chunk2 of stream12) {
|
|
419677
|
+
if ("run_id" in chunk2 && typeof chunk2.run_id === "string") {
|
|
419678
|
+
recordedRunId = chunk2.run_id;
|
|
419679
|
+
break;
|
|
419680
|
+
}
|
|
419681
|
+
}
|
|
419682
|
+
} finally {
|
|
419683
|
+
stream12.controller.abort();
|
|
419684
|
+
}
|
|
419685
|
+
}
|
|
419686
|
+
if (!pending.length) {
|
|
419687
|
+
const run = recordedRunId ? await backend3.retrieveRun(recordedRunId) : null;
|
|
419688
|
+
if (!unchanged())
|
|
419689
|
+
continue;
|
|
419690
|
+
if (run?.status === "running" || run?.status === "created") {
|
|
419691
|
+
deferred2 = true;
|
|
419692
|
+
continue;
|
|
419693
|
+
}
|
|
419694
|
+
store3.remove(record3.agentId, record3.conversationId);
|
|
419695
|
+
continue;
|
|
419696
|
+
}
|
|
419697
|
+
const owned = [];
|
|
419698
|
+
for (const approval of pending) {
|
|
419699
|
+
if (record3.toolCallIds.includes(approval.toolCallId)) {
|
|
419700
|
+
owned.push(approval);
|
|
419701
|
+
continue;
|
|
419702
|
+
}
|
|
419703
|
+
if (!approval.messageId || !recordedRunId)
|
|
419704
|
+
continue;
|
|
419705
|
+
const messages = await backend3.retrieveMessage(approval.messageId);
|
|
419706
|
+
if (messages.some((message) => ("run_id" in message) && message.run_id === recordedRunId))
|
|
419707
|
+
owned.push(approval);
|
|
419708
|
+
}
|
|
419709
|
+
if (!unchanged())
|
|
419710
|
+
continue;
|
|
419711
|
+
if (!owned.length) {
|
|
419712
|
+
store3.remove(record3.agentId, record3.conversationId);
|
|
419713
|
+
continue;
|
|
419714
|
+
}
|
|
419715
|
+
if (owned.length !== pending.length)
|
|
419716
|
+
continue;
|
|
419717
|
+
if (owned.some((approval) => isInteractiveApprovalTool(approval.toolName)))
|
|
419718
|
+
continue;
|
|
419719
|
+
if (!await canRecover(runtime))
|
|
419720
|
+
continue;
|
|
419721
|
+
if (!unchanged())
|
|
419722
|
+
continue;
|
|
419723
|
+
const approvals = recordedToolResults(record3, owned.map((approval) => approval.toolCallId));
|
|
419724
|
+
const continuation = owned.every((approval) => record3.toolCallIds.includes(approval.toolCallId)) ? record3 : {
|
|
419725
|
+
...record3,
|
|
419726
|
+
toolCallIds: owned.map((approval) => approval.toolCallId),
|
|
419727
|
+
results: approvals,
|
|
419728
|
+
requestOtid: randomUUID32()
|
|
419729
|
+
};
|
|
419730
|
+
store3.write(continuation);
|
|
419731
|
+
runtime.pendingInterruptedResults = null;
|
|
419732
|
+
runtime.pendingInterruptedContext = null;
|
|
419733
|
+
runtime.pendingInterruptedToolCallIds = null;
|
|
419734
|
+
(deps.setCwd ?? setConversationWorkingDirectory)(listener, record3.agentId, record3.conversationId, record3.workingDirectory);
|
|
419735
|
+
(deps.processTurn ?? handleIncomingMessage)({
|
|
419736
|
+
type: "message",
|
|
419737
|
+
agentId: record3.agentId,
|
|
419738
|
+
conversationId: record3.conversationId,
|
|
419739
|
+
actingUserId: record3.actingUserId,
|
|
419740
|
+
messages: [
|
|
419741
|
+
{ type: "approval", approvals, otid: continuation.requestOtid }
|
|
419742
|
+
]
|
|
419743
|
+
}, getOrCreateProcessTransport(listener), runtime).catch((error4) => {
|
|
419744
|
+
debugWarn("recovery", "Recorded continuation failed; retaining local work", error4);
|
|
419745
|
+
});
|
|
419746
|
+
} catch (error4) {
|
|
419747
|
+
deferred2 = true;
|
|
419748
|
+
debugWarn("recovery", "Recorded turn recovery failed; retaining local work", error4);
|
|
419749
|
+
}
|
|
419750
|
+
}
|
|
419751
|
+
} finally {
|
|
419752
|
+
recovering.delete(listener);
|
|
419753
|
+
if (deferred2 && !listener.intentionallyClosed) {
|
|
419754
|
+
const timer2 = setTimeout(() => {
|
|
419755
|
+
recoverRecordedTurns(listener, deps);
|
|
419756
|
+
}, 5000);
|
|
419757
|
+
timer2.unref();
|
|
419758
|
+
retryTimers.set(listener, timer2);
|
|
419759
|
+
}
|
|
419760
|
+
}
|
|
419761
|
+
}
|
|
419762
|
+
var recovering, retryTimers;
|
|
419763
|
+
var init_recover_recorded_turn = __esm(async () => {
|
|
419764
|
+
init_check_approval();
|
|
419765
|
+
init_backend2();
|
|
419766
|
+
init_environments2();
|
|
419767
|
+
init_interactive_policy();
|
|
419768
|
+
init_debug();
|
|
419769
|
+
init_connection();
|
|
419770
|
+
init_cwd();
|
|
419771
|
+
init_interrupted_turn_record();
|
|
419772
|
+
init_recovery_ownership();
|
|
419773
|
+
init_runtime();
|
|
419774
|
+
await __promiseAll([
|
|
419775
|
+
init_conversation_runtime(),
|
|
419776
|
+
init_turn()
|
|
419777
|
+
]);
|
|
419778
|
+
recovering = new WeakSet;
|
|
419779
|
+
retryTimers = new WeakMap;
|
|
419780
|
+
});
|
|
419781
|
+
|
|
419447
419782
|
// src/websocket/listener/recovery-sync.ts
|
|
419448
419783
|
function isBackendNotFoundError2(error4) {
|
|
419449
419784
|
return error4 instanceof APIError && (error4.status === 404 || error4.status === 422) || error4 instanceof Error && error4.name === "LocalBackendNotFoundError";
|
|
419450
419785
|
}
|
|
419451
|
-
async function recoverApprovalStateForSync(runtime, scope, deps = {}) {
|
|
419786
|
+
async function recoverApprovalStateForSync(runtime, scope, deps = {}, opts = {}) {
|
|
419452
419787
|
const resolvedDeps = {
|
|
419453
419788
|
getBackend,
|
|
419454
419789
|
getResumeDataFromBackend,
|
|
@@ -419518,6 +419853,17 @@ async function recoverApprovalStateForSync(runtime, scope, deps = {}) {
|
|
|
419518
419853
|
approval,
|
|
419519
419854
|
reason: STALE_APPROVAL_RECOVERY_DENIAL_REASON
|
|
419520
419855
|
}));
|
|
419856
|
+
if (interactivePending.length === 0 && !opts.resumeInterruptedTurn) {
|
|
419857
|
+
runtime.pendingInterruptedResults = buildFreshDenialApprovals(pendingApprovals, STALE_APPROVAL_RECOVERY_DENIAL_REASON);
|
|
419858
|
+
runtime.pendingInterruptedContext = {
|
|
419859
|
+
agentId: scope.agent_id,
|
|
419860
|
+
conversationId: scope.conversation_id,
|
|
419861
|
+
continuationEpoch: runtime.continuationEpoch
|
|
419862
|
+
};
|
|
419863
|
+
runtime.pendingInterruptedToolCallIds = null;
|
|
419864
|
+
clearRecoveredApprovalState(runtime);
|
|
419865
|
+
return;
|
|
419866
|
+
}
|
|
419521
419867
|
const approvalsByRequestId = new Map;
|
|
419522
419868
|
for (const approval of interactivePending) {
|
|
419523
419869
|
const requestId = `perm-${approval.toolCallId}`;
|
|
@@ -419569,10 +419915,11 @@ var init_recovery_sync = __esm(() => {
|
|
|
419569
419915
|
async function replaySyncStateForRuntime(listenerRuntime, socket, scope, opts) {
|
|
419570
419916
|
const syncScopedRuntime = getOrCreateScopedRuntime(listenerRuntime, scope.agent_id, scope.conversation_id);
|
|
419571
419917
|
const recoverFn = opts?.recoverApprovalStateForSync ?? recoverApprovalStateForSync;
|
|
419572
|
-
if (
|
|
419918
|
+
if (opts?.recoverApprovals ?? true) {
|
|
419573
419919
|
try {
|
|
419574
|
-
|
|
419575
|
-
|
|
419920
|
+
await recoverFn(syncScopedRuntime, scope, undefined, {
|
|
419921
|
+
resumeInterruptedTurn: opts?.resumeInterruptedTurn === true
|
|
419922
|
+
});
|
|
419576
419923
|
} catch (error4) {
|
|
419577
419924
|
trackBoundaryError({
|
|
419578
419925
|
errorType: "listener_sync_recovery_failed",
|
|
@@ -419801,6 +420148,7 @@ async function startConnectedListenerRuntime(runtime, transport, opts, processQu
|
|
|
419801
420148
|
}
|
|
419802
420149
|
if (options.startProcessServices === false)
|
|
419803
420150
|
return;
|
|
420151
|
+
scheduleRecordedTurnRecovery(runtime, options.recoverRecordedWork);
|
|
419804
420152
|
const processTransport = getOrCreateProcessTransport(runtime);
|
|
419805
420153
|
for (const conversationRuntime of runtime.conversationRuntimes.values()) {
|
|
419806
420154
|
if (conversationRuntime.queueRuntime?.isEmpty === false) {
|
|
@@ -420259,6 +420607,7 @@ var init_lifecycle = __esm(async () => {
|
|
|
420259
420607
|
init_mod_adapter2(),
|
|
420260
420608
|
init_process_services(),
|
|
420261
420609
|
init_queue(),
|
|
420610
|
+
init_recover_recorded_turn(),
|
|
420262
420611
|
init_sync_replay(),
|
|
420263
420612
|
init_warmup()
|
|
420264
420613
|
]);
|
|
@@ -420697,7 +421046,7 @@ var init_listen_client = __esm(async () => {
|
|
|
420697
421046
|
});
|
|
420698
421047
|
|
|
420699
421048
|
// src/websocket/app-server-auth.ts
|
|
420700
|
-
import { createHash as
|
|
421049
|
+
import { createHash as createHash10, createHmac, timingSafeEqual } from "node:crypto";
|
|
420701
421050
|
import { readFile as readFile23 } from "node:fs/promises";
|
|
420702
421051
|
import { isIP as isIP2 } from "node:net";
|
|
420703
421052
|
import { isAbsolute as isAbsolute29 } from "node:path";
|
|
@@ -420980,7 +421329,7 @@ function sha256DigestArg(flagName, value) {
|
|
|
420980
421329
|
return Buffer.from(trimmed, "hex");
|
|
420981
421330
|
}
|
|
420982
421331
|
function sha256Digest(value) {
|
|
420983
|
-
return
|
|
421332
|
+
return createHash10("sha256").update(value).digest();
|
|
420984
421333
|
}
|
|
420985
421334
|
function unauthorized(message) {
|
|
420986
421335
|
return { statusCode: 401, message };
|
|
@@ -421471,7 +421820,7 @@ function createToolLifecycleTracker(onEvent) {
|
|
|
421471
421820
|
}
|
|
421472
421821
|
|
|
421473
421822
|
// src/websocket/app-server-openai-turn.ts
|
|
421474
|
-
import { randomUUID as
|
|
421823
|
+
import { randomUUID as randomUUID33 } from "node:crypto";
|
|
421475
421824
|
function runBridgeTurn(params) {
|
|
421476
421825
|
return runTurnImpl(params);
|
|
421477
421826
|
}
|
|
@@ -421490,7 +421839,7 @@ async function ensureListenerRuntime(onLog) {
|
|
|
421490
421839
|
if (active && !active.intentionallyClosed)
|
|
421491
421840
|
return active;
|
|
421492
421841
|
bridgeRuntimeStart ??= startLocalChannelListener({
|
|
421493
|
-
connectionId: `openai-api-${
|
|
421842
|
+
connectionId: `openai-api-${randomUUID33()}`,
|
|
421494
421843
|
deviceId: settingsManager.getOrCreateDeviceId(),
|
|
421495
421844
|
connectionName: "openai-api",
|
|
421496
421845
|
onConnected: () => {},
|
|
@@ -421699,11 +422048,11 @@ var init_app_server_openai_turn = __esm(async () => {
|
|
|
421699
422048
|
});
|
|
421700
422049
|
|
|
421701
422050
|
// src/websocket/app-server-openai-responses.ts
|
|
421702
|
-
import { randomUUID as
|
|
422051
|
+
import { randomUUID as randomUUID34 } from "node:crypto";
|
|
421703
422052
|
function createStoredResponseId(state) {
|
|
421704
422053
|
const cursor = Buffer.from(JSON.stringify({
|
|
421705
422054
|
version: 1,
|
|
421706
|
-
nonce:
|
|
422055
|
+
nonce: randomUUID34(),
|
|
421707
422056
|
agent_id: state.agentId,
|
|
421708
422057
|
conversation_id: state.conversationId
|
|
421709
422058
|
})).toString("base64url");
|
|
@@ -421748,7 +422097,7 @@ function toBridgeMessages(messages, stateful) {
|
|
|
421748
422097
|
return { messages: [], correlationOtid: null };
|
|
421749
422098
|
}
|
|
421750
422099
|
if (stateful) {
|
|
421751
|
-
const otid =
|
|
422100
|
+
const otid = randomUUID34();
|
|
421752
422101
|
return {
|
|
421753
422102
|
messages: [{ role: "user", content: lastUserContent, otid }],
|
|
421754
422103
|
correlationOtid: otid
|
|
@@ -421770,7 +422119,7 @@ function toBridgeMessages(messages, stateful) {
|
|
|
421770
422119
|
bridgeMessages.push({
|
|
421771
422120
|
role: message.role,
|
|
421772
422121
|
content,
|
|
421773
|
-
otid:
|
|
422122
|
+
otid: randomUUID34()
|
|
421774
422123
|
});
|
|
421775
422124
|
}
|
|
421776
422125
|
return {
|
|
@@ -421902,7 +422251,7 @@ class ResponseOutputBuilder {
|
|
|
421902
422251
|
this.finishText();
|
|
421903
422252
|
const result2 = {
|
|
421904
422253
|
type: "function_call_output",
|
|
421905
|
-
id: `fco_${
|
|
422254
|
+
id: `fco_${randomUUID34()}`,
|
|
421906
422255
|
call_id: event.tool_call_id,
|
|
421907
422256
|
output: [{ type: "input_text", text: event.output }],
|
|
421908
422257
|
status: event.success ? "completed" : "incomplete"
|
|
@@ -421987,7 +422336,7 @@ class ResponseOutputBuilder {
|
|
|
421987
422336
|
return this.message;
|
|
421988
422337
|
const item = {
|
|
421989
422338
|
type: "message",
|
|
421990
|
-
id: `msg_${
|
|
422339
|
+
id: `msg_${randomUUID34()}`,
|
|
421991
422340
|
status: "in_progress",
|
|
421992
422341
|
role: "assistant",
|
|
421993
422342
|
content: [{ type: "output_text", text: "", annotations: [] }]
|
|
@@ -422014,7 +422363,7 @@ class ResponseOutputBuilder {
|
|
|
422014
422363
|
return this.reasoning;
|
|
422015
422364
|
const item = {
|
|
422016
422365
|
type: "reasoning",
|
|
422017
|
-
id: `rs_${
|
|
422366
|
+
id: `rs_${randomUUID34()}`,
|
|
422018
422367
|
status: "in_progress",
|
|
422019
422368
|
summary: [{ type: "summary_text", text: "" }]
|
|
422020
422369
|
};
|
|
@@ -422045,7 +422394,7 @@ class ResponseOutputBuilder {
|
|
|
422045
422394
|
}
|
|
422046
422395
|
const item = {
|
|
422047
422396
|
type: "function_call",
|
|
422048
|
-
id: `fc_${
|
|
422397
|
+
id: `fc_${randomUUID34()}`,
|
|
422049
422398
|
call_id: callId,
|
|
422050
422399
|
name,
|
|
422051
422400
|
arguments: "",
|
|
@@ -422150,7 +422499,7 @@ async function handleResponses(request, response, options) {
|
|
|
422150
422499
|
sendOpenAiError(response, 500, "failed to create a conversation for this response", "server_error");
|
|
422151
422500
|
return;
|
|
422152
422501
|
}
|
|
422153
|
-
const responseId = body3.store === true ? createStoredResponseId({ agentId: agent.id, conversationId }) : `resp_${
|
|
422502
|
+
const responseId = body3.store === true ? createStoredResponseId({ agentId: agent.id, conversationId }) : `resp_${randomUUID34()}`;
|
|
422154
422503
|
const createdAt = Math.floor(Date.now() / 1000);
|
|
422155
422504
|
let sequenceNumber = 0;
|
|
422156
422505
|
let clientClosed = false;
|
|
@@ -422240,7 +422589,7 @@ var init_app_server_openai_responses = __esm(async () => {
|
|
|
422240
422589
|
});
|
|
422241
422590
|
|
|
422242
422591
|
// src/websocket/app-server-openai.ts
|
|
422243
|
-
import { randomUUID as
|
|
422592
|
+
import { randomUUID as randomUUID35 } from "node:crypto";
|
|
422244
422593
|
function isOpenAiCompatPath(pathname) {
|
|
422245
422594
|
return pathname === MODELS_PATH || pathname === CHAT_COMPLETIONS_PATH || pathname === RESPONSES_PATH;
|
|
422246
422595
|
}
|
|
@@ -422309,7 +422658,7 @@ async function handleChatCompletions(request, response, options) {
|
|
|
422309
422658
|
turnMessages.push({
|
|
422310
422659
|
role: "user",
|
|
422311
422660
|
content: userContent,
|
|
422312
|
-
otid:
|
|
422661
|
+
otid: randomUUID35()
|
|
422313
422662
|
});
|
|
422314
422663
|
} else {
|
|
422315
422664
|
for (const message of body3.messages) {
|
|
@@ -422326,7 +422675,7 @@ async function handleChatCompletions(request, response, options) {
|
|
|
422326
422675
|
}
|
|
422327
422676
|
if (content.length === 0)
|
|
422328
422677
|
continue;
|
|
422329
|
-
turnMessages.push({ role: message.role, content, otid:
|
|
422678
|
+
turnMessages.push({ role: message.role, content, otid: randomUUID35() });
|
|
422330
422679
|
}
|
|
422331
422680
|
}
|
|
422332
422681
|
correlationOtid = turnMessages.at(-1)?.otid ?? null;
|
|
@@ -422335,7 +422684,7 @@ async function handleChatCompletions(request, response, options) {
|
|
|
422335
422684
|
return;
|
|
422336
422685
|
}
|
|
422337
422686
|
}
|
|
422338
|
-
const completionId = `chatcmpl-${
|
|
422687
|
+
const completionId = `chatcmpl-${randomUUID35()}`;
|
|
422339
422688
|
const created = Math.floor(Date.now() / 1000);
|
|
422340
422689
|
const streaming3 = body3.stream === true;
|
|
422341
422690
|
let clientClosed = false;
|
|
@@ -423638,20 +423987,20 @@ var init_listen = __esm(async () => {
|
|
|
423638
423987
|
});
|
|
423639
423988
|
|
|
423640
423989
|
// src/backend/local/transcript-migration.ts
|
|
423641
|
-
import { randomUUID as
|
|
423990
|
+
import { randomUUID as randomUUID36 } from "node:crypto";
|
|
423642
423991
|
import {
|
|
423643
423992
|
copyFileSync as copyFileSync3,
|
|
423644
423993
|
existsSync as existsSync56,
|
|
423645
|
-
mkdirSync as
|
|
423646
|
-
readdirSync as
|
|
423647
|
-
readFileSync as
|
|
423648
|
-
writeFileSync as
|
|
423994
|
+
mkdirSync as mkdirSync39,
|
|
423995
|
+
readdirSync as readdirSync21,
|
|
423996
|
+
readFileSync as readFileSync38,
|
|
423997
|
+
writeFileSync as writeFileSync29
|
|
423649
423998
|
} from "node:fs";
|
|
423650
|
-
import { join as
|
|
423999
|
+
import { join as join72 } from "node:path";
|
|
423651
424000
|
function readJsonl(path48) {
|
|
423652
424001
|
if (!existsSync56(path48))
|
|
423653
424002
|
return [];
|
|
423654
|
-
return
|
|
424003
|
+
return readFileSync38(path48, "utf8").split(`
|
|
423655
424004
|
`).filter((line) => line.trim().length > 0).map((line) => JSON.parse(line));
|
|
423656
424005
|
}
|
|
423657
424006
|
function isLegacyUiMessage(value) {
|
|
@@ -423661,7 +424010,7 @@ function isPiLocalMessage(value) {
|
|
|
423661
424010
|
return isRecord(value) && typeof value.id === "string" && (value.role === "user" || value.role === "assistant" || value.role === "toolResult") && Object.hasOwn(value, "content");
|
|
423662
424011
|
}
|
|
423663
424012
|
function writeJsonl(path48, items3) {
|
|
423664
|
-
|
|
424013
|
+
writeFileSync29(path48, `${items3.map((item) => JSON.stringify(item)).join(`
|
|
423665
424014
|
`)}
|
|
423666
424015
|
`);
|
|
423667
424016
|
}
|
|
@@ -423678,7 +424027,7 @@ function writeSessionEntryJsonl(path48, messages, input) {
|
|
|
423678
424027
|
...messages.map((message) => {
|
|
423679
424028
|
const entry = {
|
|
423680
424029
|
type: "message",
|
|
423681
|
-
id:
|
|
424030
|
+
id: randomUUID36().slice(0, 8),
|
|
423682
424031
|
parentId,
|
|
423683
424032
|
timestamp: message.metadata?.created_at ?? new Date(message.timestamp).toISOString(),
|
|
423684
424033
|
message
|
|
@@ -423930,7 +424279,7 @@ function convertMessages4(messages, mode, nextId2) {
|
|
|
423930
424279
|
}
|
|
423931
424280
|
function migrateLocalBackendTranscripts(input) {
|
|
423932
424281
|
const storageDir = input.storageDir;
|
|
423933
|
-
const conversationsDir =
|
|
424282
|
+
const conversationsDir = join72(storageDir, "conversations");
|
|
423934
424283
|
const result2 = {
|
|
423935
424284
|
storageDir,
|
|
423936
424285
|
converted: [],
|
|
@@ -423939,14 +424288,14 @@ function migrateLocalBackendTranscripts(input) {
|
|
|
423939
424288
|
};
|
|
423940
424289
|
if (!existsSync56(conversationsDir))
|
|
423941
424290
|
return result2;
|
|
423942
|
-
for (const name of
|
|
423943
|
-
const conversationDir =
|
|
423944
|
-
const messagesPath =
|
|
423945
|
-
const manifestPath =
|
|
424291
|
+
for (const name of readdirSync21(conversationsDir)) {
|
|
424292
|
+
const conversationDir = join72(conversationsDir, name);
|
|
424293
|
+
const messagesPath = join72(conversationDir, "messages.jsonl");
|
|
424294
|
+
const manifestPath = join72(conversationDir, "manifest.json");
|
|
423946
424295
|
const hasManifest = existsSync56(manifestPath);
|
|
423947
424296
|
const existingManifest = hasManifest ? (() => {
|
|
423948
424297
|
try {
|
|
423949
|
-
return JSON.parse(
|
|
424298
|
+
return JSON.parse(readFileSync38(manifestPath, "utf8"));
|
|
423950
424299
|
} catch {
|
|
423951
424300
|
return;
|
|
423952
424301
|
}
|
|
@@ -423961,8 +424310,8 @@ function migrateLocalBackendTranscripts(input) {
|
|
|
423961
424310
|
if (legacyMessages.length === 0) {
|
|
423962
424311
|
result2.skipped.push({ conversationDir, reason: "empty" });
|
|
423963
424312
|
if (!input.dryRun) {
|
|
423964
|
-
|
|
423965
|
-
|
|
424313
|
+
mkdirSync39(conversationDir, { recursive: true });
|
|
424314
|
+
writeFileSync29(manifestPath, `${JSON.stringify(manifest({}), null, 2)}
|
|
423966
424315
|
`);
|
|
423967
424316
|
}
|
|
423968
424317
|
continue;
|
|
@@ -423985,11 +424334,11 @@ function migrateLocalBackendTranscripts(input) {
|
|
|
423985
424334
|
const backupPath = `${messagesPath}.pre-pi-backup-${timestampSuffix()}`;
|
|
423986
424335
|
if (!input.dryRun) {
|
|
423987
424336
|
copyFileSync3(messagesPath, backupPath);
|
|
423988
|
-
const conversationPath =
|
|
424337
|
+
const conversationPath = join72(conversationDir, "conversation.json");
|
|
423989
424338
|
let conversation;
|
|
423990
424339
|
if (existsSync56(conversationPath)) {
|
|
423991
424340
|
try {
|
|
423992
|
-
conversation = JSON.parse(
|
|
424341
|
+
conversation = JSON.parse(readFileSync38(conversationPath, "utf8"));
|
|
423993
424342
|
} catch {
|
|
423994
424343
|
conversation = undefined;
|
|
423995
424344
|
}
|
|
@@ -424015,12 +424364,12 @@ function migrateLocalBackendTranscripts(input) {
|
|
|
424015
424364
|
}
|
|
424016
424365
|
}
|
|
424017
424366
|
conversation.in_context_message_ids = remapped;
|
|
424018
|
-
|
|
424367
|
+
writeFileSync29(conversationPath, `${JSON.stringify(conversation, null, 2)}
|
|
424019
424368
|
`);
|
|
424020
424369
|
}
|
|
424021
424370
|
} catch {}
|
|
424022
424371
|
}
|
|
424023
|
-
|
|
424372
|
+
writeFileSync29(manifestPath, `${JSON.stringify(manifest({
|
|
424024
424373
|
backupPath,
|
|
424025
424374
|
migratedFrom: repairVersioned ? hasLegacyUiRows ? "versioned-pi-transcript-with-legacy-ui-message-rows" : "versioned-pi-ai-message-jsonl" : undefined
|
|
424026
424375
|
}), null, 2)}
|
|
@@ -440944,12 +441293,12 @@ var init_mcp_client = __esm(() => {
|
|
|
440944
441293
|
init_streamableHttp();
|
|
440945
441294
|
DEFAULT_CLIENT_INFO = {
|
|
440946
441295
|
name: "letta-code",
|
|
440947
|
-
version: "0.32.
|
|
441296
|
+
version: "0.32.10"
|
|
440948
441297
|
};
|
|
440949
441298
|
});
|
|
440950
441299
|
|
|
440951
441300
|
// src/mcp-oauth.ts
|
|
440952
|
-
import { createHash as
|
|
441301
|
+
import { createHash as createHash11, randomBytes as randomBytes2 } from "node:crypto";
|
|
440953
441302
|
import { createServer as createServer3 } from "node:http";
|
|
440954
441303
|
async function clearMcpOAuthCredentials(agentId, serverName, serverUrl) {
|
|
440955
441304
|
return deleteSecretValue(oauthSecretName(agentId, serverName, serverUrl));
|
|
@@ -441190,7 +441539,7 @@ async function openSystemBrowser(url2) {
|
|
|
441190
441539
|
} catch {}
|
|
441191
441540
|
}
|
|
441192
441541
|
function oauthSecretName(agentId, serverName, serverUrl) {
|
|
441193
|
-
const digest =
|
|
441542
|
+
const digest = createHash11("sha256").update(`${agentId}\x00${serverName}\x00${serverUrl}`).digest("hex").slice(0, 32);
|
|
441194
441543
|
return `mcp-oauth-${digest}`;
|
|
441195
441544
|
}
|
|
441196
441545
|
async function loadState(secretName) {
|
|
@@ -442178,9 +442527,9 @@ var init_memory_tokens = __esm(() => {
|
|
|
442178
442527
|
});
|
|
442179
442528
|
|
|
442180
442529
|
// src/cli/subcommands/memory.ts
|
|
442181
|
-
import { cpSync, existsSync as existsSync57, mkdirSync as
|
|
442530
|
+
import { cpSync, existsSync as existsSync57, mkdirSync as mkdirSync40, rmSync as rmSync14, statSync as statSync19 } from "node:fs";
|
|
442182
442531
|
import { readdir as readdir12 } from "node:fs/promises";
|
|
442183
|
-
import { dirname as dirname31, join as
|
|
442532
|
+
import { dirname as dirname31, join as join73 } from "node:path";
|
|
442184
442533
|
import { parseArgs as parseArgs11 } from "node:util";
|
|
442185
442534
|
function printUsage8() {
|
|
442186
442535
|
console.log(`
|
|
@@ -442250,7 +442599,7 @@ async function listBackups(agentId) {
|
|
|
442250
442599
|
continue;
|
|
442251
442600
|
if (!entry.name.startsWith("memory-backup-"))
|
|
442252
442601
|
continue;
|
|
442253
|
-
const path48 =
|
|
442602
|
+
const path48 = join73(agentRoot, entry.name);
|
|
442254
442603
|
let createdAt = null;
|
|
442255
442604
|
try {
|
|
442256
442605
|
const stat16 = statSync19(path48);
|
|
@@ -442267,7 +442616,7 @@ function resolveBackupPath(agentId, from) {
|
|
|
442267
442616
|
if (from.startsWith("/") || /^[A-Za-z]:[/\\]/.test(from)) {
|
|
442268
442617
|
return from;
|
|
442269
442618
|
}
|
|
442270
|
-
return
|
|
442619
|
+
return join73(getAgentRoot(agentId), from);
|
|
442271
442620
|
}
|
|
442272
442621
|
async function runMemorySubcommand(argv) {
|
|
442273
442622
|
let parsed;
|
|
@@ -442350,7 +442699,7 @@ async function runMemorySubcommand(argv) {
|
|
|
442350
442699
|
}
|
|
442351
442700
|
const agentRoot = getAgentRoot(agentId);
|
|
442352
442701
|
const backupName = `memory-backup-${formatBackupTimestamp()}`;
|
|
442353
|
-
const backupPath =
|
|
442702
|
+
const backupPath = join73(agentRoot, backupName);
|
|
442354
442703
|
if (existsSync57(backupPath)) {
|
|
442355
442704
|
console.error(`Backup already exists at ${backupPath}`);
|
|
442356
442705
|
return 1;
|
|
@@ -442385,7 +442734,7 @@ async function runMemorySubcommand(argv) {
|
|
|
442385
442734
|
return 1;
|
|
442386
442735
|
}
|
|
442387
442736
|
const root2 = getMemoryRoot(agentId);
|
|
442388
|
-
|
|
442737
|
+
rmSync14(root2, { recursive: true, force: true });
|
|
442389
442738
|
cpSync(backupPath, root2, { recursive: true });
|
|
442390
442739
|
console.log(JSON.stringify({ restoredFrom: backupPath }, null, 2));
|
|
442391
442740
|
return 0;
|
|
@@ -442414,7 +442763,7 @@ async function runMemorySubcommand(argv) {
|
|
|
442414
442763
|
return 1;
|
|
442415
442764
|
}
|
|
442416
442765
|
} else {
|
|
442417
|
-
|
|
442766
|
+
mkdirSync40(out, { recursive: true });
|
|
442418
442767
|
}
|
|
442419
442768
|
cpSync(root2, out, { recursive: true });
|
|
442420
442769
|
console.log(JSON.stringify({ exportedFrom: root2, exportedTo: out, agentId }, null, 2));
|
|
@@ -442449,13 +442798,13 @@ var init_memory7 = __esm(() => {
|
|
|
442449
442798
|
});
|
|
442450
442799
|
|
|
442451
442800
|
// src/backend/local/transcript-search.ts
|
|
442452
|
-
import { existsSync as existsSync58, readdirSync as
|
|
442453
|
-
import { join as
|
|
442801
|
+
import { existsSync as existsSync58, readdirSync as readdirSync22, readFileSync as readFileSync39, statSync as statSync20 } from "node:fs";
|
|
442802
|
+
import { join as join74 } from "node:path";
|
|
442454
442803
|
function readJsonFile3(path48) {
|
|
442455
442804
|
if (!existsSync58(path48))
|
|
442456
442805
|
return;
|
|
442457
442806
|
try {
|
|
442458
|
-
return JSON.parse(
|
|
442807
|
+
return JSON.parse(readFileSync39(path48, "utf8"));
|
|
442459
442808
|
} catch {
|
|
442460
442809
|
return;
|
|
442461
442810
|
}
|
|
@@ -442464,7 +442813,7 @@ function readJsonlFile2(path48) {
|
|
|
442464
442813
|
if (!existsSync58(path48))
|
|
442465
442814
|
return [];
|
|
442466
442815
|
try {
|
|
442467
|
-
return
|
|
442816
|
+
return readFileSync39(path48, "utf8").split(`
|
|
442468
442817
|
`).filter((line) => line.trim().length > 0).map((line) => JSON.parse(line));
|
|
442469
442818
|
} catch {
|
|
442470
442819
|
return [];
|
|
@@ -442671,11 +443020,11 @@ function collectConversationMessages(input) {
|
|
|
442671
443020
|
return [];
|
|
442672
443021
|
if (input.conversationId && conversation.id !== input.conversationId)
|
|
442673
443022
|
return [];
|
|
442674
|
-
const messagesPath =
|
|
443023
|
+
const messagesPath = join74(conversationDir, "messages.jsonl");
|
|
442675
443024
|
const rows = readJsonlFile2(messagesPath);
|
|
442676
443025
|
if (rows.length === 0)
|
|
442677
443026
|
return [];
|
|
442678
|
-
const manifest2 = readJsonFile3(
|
|
443027
|
+
const manifest2 = readJsonFile3(join74(conversationDir, "manifest.json"));
|
|
442679
443028
|
const format5 = transcriptFormat(manifest2, rows);
|
|
442680
443029
|
if (!format5)
|
|
442681
443030
|
return [];
|
|
@@ -442696,11 +443045,11 @@ function collectConversationMessages(input) {
|
|
|
442696
443045
|
});
|
|
442697
443046
|
}
|
|
442698
443047
|
function conversationDirectories(storageDir) {
|
|
442699
|
-
const conversationsDir =
|
|
443048
|
+
const conversationsDir = join74(storageDir, "conversations");
|
|
442700
443049
|
if (!existsSync58(conversationsDir))
|
|
442701
443050
|
return [];
|
|
442702
443051
|
try {
|
|
442703
|
-
return
|
|
443052
|
+
return readdirSync22(conversationsDir).map((entry) => join74(conversationsDir, entry)).filter((entryPath) => statSync20(entryPath).isDirectory());
|
|
442704
443053
|
} catch {
|
|
442705
443054
|
return [];
|
|
442706
443055
|
}
|
|
@@ -442724,7 +443073,7 @@ function searchLocalTranscriptMessages(storageDir, body3) {
|
|
|
442724
443073
|
const endDate = typeof body3.end_date === "string" ? body3.end_date : undefined;
|
|
442725
443074
|
const includeHidden = body3.include_hidden === true;
|
|
442726
443075
|
const records = conversationDirectories(storageDir).flatMap((conversationDir) => {
|
|
442727
|
-
const conversation = conversationSearchRecord(readJsonFile3(
|
|
443076
|
+
const conversation = conversationSearchRecord(readJsonFile3(join74(conversationDir, "conversation.json")));
|
|
442728
443077
|
if (!conversation)
|
|
442729
443078
|
return [];
|
|
442730
443079
|
if (conversation.hidden && !includeHidden)
|
|
@@ -443530,13 +443879,13 @@ import {
|
|
|
443530
443879
|
copyFileSync as copyFileSync4,
|
|
443531
443880
|
existsSync as existsSync59,
|
|
443532
443881
|
lstatSync as lstatSync3,
|
|
443533
|
-
mkdirSync as
|
|
443882
|
+
mkdirSync as mkdirSync41,
|
|
443534
443883
|
mkdtempSync as mkdtempSync4,
|
|
443535
|
-
readdirSync as
|
|
443536
|
-
readFileSync as
|
|
443537
|
-
renameSync as
|
|
443538
|
-
rmSync as
|
|
443539
|
-
writeFileSync as
|
|
443884
|
+
readdirSync as readdirSync23,
|
|
443885
|
+
readFileSync as readFileSync40,
|
|
443886
|
+
renameSync as renameSync8,
|
|
443887
|
+
rmSync as rmSync15,
|
|
443888
|
+
writeFileSync as writeFileSync30
|
|
443540
443889
|
} from "node:fs";
|
|
443541
443890
|
import { tmpdir as tmpdir10 } from "node:os";
|
|
443542
443891
|
import path48 from "node:path";
|
|
@@ -443552,7 +443901,7 @@ function isPathInsideOrEqual2(childPath, parentPath) {
|
|
|
443552
443901
|
function readPackageJson(packageJsonPath) {
|
|
443553
443902
|
let parsed;
|
|
443554
443903
|
try {
|
|
443555
|
-
parsed = JSON.parse(
|
|
443904
|
+
parsed = JSON.parse(readFileSync40(packageJsonPath, "utf8"));
|
|
443556
443905
|
} catch (error5) {
|
|
443557
443906
|
throw new Error(`Could not read package.json: ${error5 instanceof Error ? error5.message : String(error5)}`);
|
|
443558
443907
|
}
|
|
@@ -443672,8 +444021,8 @@ function validatePackageSource(packageDirectory) {
|
|
|
443672
444021
|
};
|
|
443673
444022
|
}
|
|
443674
444023
|
function copyPackageDirectory(sourceRoot, targetRoot) {
|
|
443675
|
-
|
|
443676
|
-
for (const entry of
|
|
444024
|
+
mkdirSync41(targetRoot, { recursive: true });
|
|
444025
|
+
for (const entry of readdirSync23(sourceRoot, { withFileTypes: true })) {
|
|
443677
444026
|
if (SKIPPED_PACKAGE_COPY_NAMES.has(entry.name))
|
|
443678
444027
|
continue;
|
|
443679
444028
|
const sourcePath = path48.join(sourceRoot, entry.name);
|
|
@@ -443687,7 +444036,7 @@ function copyPackageDirectory(sourceRoot, targetRoot) {
|
|
|
443687
444036
|
continue;
|
|
443688
444037
|
}
|
|
443689
444038
|
if (stats.isFile()) {
|
|
443690
|
-
|
|
444039
|
+
mkdirSync41(path48.dirname(targetPath), { recursive: true });
|
|
443691
444040
|
copyFileSync4(sourcePath, targetPath);
|
|
443692
444041
|
continue;
|
|
443693
444042
|
}
|
|
@@ -443705,7 +444054,7 @@ function shouldSkipDependencyPath(relativeParts, installedPackageName) {
|
|
|
443705
444054
|
function copyDependencyDirectoryFiltered(params) {
|
|
443706
444055
|
let copied = false;
|
|
443707
444056
|
const relativeParts = params.relativeParts ?? [];
|
|
443708
|
-
for (const entry of
|
|
444057
|
+
for (const entry of readdirSync23(params.sourceRoot, { withFileTypes: true })) {
|
|
443709
444058
|
const nextRelativeParts = [...relativeParts, entry.name];
|
|
443710
444059
|
if (shouldSkipDependencyPath(nextRelativeParts, params.installedPackageName)) {
|
|
443711
444060
|
continue;
|
|
@@ -443727,7 +444076,7 @@ function copyDependencyDirectoryFiltered(params) {
|
|
|
443727
444076
|
continue;
|
|
443728
444077
|
}
|
|
443729
444078
|
if (stats.isFile()) {
|
|
443730
|
-
|
|
444079
|
+
mkdirSync41(path48.dirname(targetPath), { recursive: true });
|
|
443731
444080
|
copyFileSync4(sourcePath, targetPath);
|
|
443732
444081
|
copied = true;
|
|
443733
444082
|
continue;
|
|
@@ -443756,26 +444105,26 @@ function copyPackageInternalNodeModules(params) {
|
|
|
443756
444105
|
}
|
|
443757
444106
|
function restoreRegistry(registryPath, previousContents) {
|
|
443758
444107
|
if (previousContents === null) {
|
|
443759
|
-
|
|
444108
|
+
rmSync15(registryPath, { force: true });
|
|
443760
444109
|
return;
|
|
443761
444110
|
}
|
|
443762
|
-
|
|
443763
|
-
|
|
444111
|
+
mkdirSync41(path48.dirname(registryPath), { recursive: true });
|
|
444112
|
+
writeFileSync30(registryPath, previousContents);
|
|
443764
444113
|
}
|
|
443765
444114
|
function removeIfExists(targetPath) {
|
|
443766
444115
|
if (!targetPath)
|
|
443767
444116
|
return;
|
|
443768
|
-
|
|
444117
|
+
rmSync15(targetPath, { force: true, recursive: true });
|
|
443769
444118
|
}
|
|
443770
444119
|
function restoreDestination(params) {
|
|
443771
|
-
|
|
444120
|
+
rmSync15(params.destinationRoot, { force: true, recursive: true });
|
|
443772
444121
|
if (params.backupRoot && existsSync59(params.backupRoot)) {
|
|
443773
|
-
|
|
444122
|
+
renameSync8(params.backupRoot, params.destinationRoot);
|
|
443774
444123
|
}
|
|
443775
444124
|
}
|
|
443776
444125
|
function restoreDestinationIfNeeded(params) {
|
|
443777
444126
|
if (!params.backupRoot || !existsSync59(params.backupRoot)) {
|
|
443778
|
-
|
|
444127
|
+
rmSync15(params.destinationRoot, { force: true, recursive: true });
|
|
443779
444128
|
return;
|
|
443780
444129
|
}
|
|
443781
444130
|
restoreDestination(params);
|
|
@@ -443783,7 +444132,7 @@ function restoreDestinationIfNeeded(params) {
|
|
|
443783
444132
|
function makeSiblingTempDirectory(destinationRoot, label) {
|
|
443784
444133
|
const parent = path48.dirname(destinationRoot);
|
|
443785
444134
|
const baseName = path48.basename(destinationRoot).replace(/[^a-zA-Z0-9._-]/g, "-");
|
|
443786
|
-
|
|
444135
|
+
mkdirSync41(parent, { recursive: true });
|
|
443787
444136
|
return mkdtempSync4(path48.join(parent, `.${baseName}.${label}-`));
|
|
443788
444137
|
}
|
|
443789
444138
|
function installPreparedManagedModPackage(params) {
|
|
@@ -443817,11 +444166,11 @@ function installPreparedManagedModPackage(params) {
|
|
|
443817
444166
|
}
|
|
443818
444167
|
if (existsSync59(destinationRoot)) {
|
|
443819
444168
|
backupRoot = makeSiblingTempDirectory(destinationRoot, "backup");
|
|
443820
|
-
|
|
443821
|
-
|
|
444169
|
+
rmSync15(backupRoot, { force: true, recursive: true });
|
|
444170
|
+
renameSync8(destinationRoot, backupRoot);
|
|
443822
444171
|
destinationNeedsRollback = true;
|
|
443823
444172
|
}
|
|
443824
|
-
|
|
444173
|
+
renameSync8(stagingRoot, destinationRoot);
|
|
443825
444174
|
destinationNeedsRollback = true;
|
|
443826
444175
|
stagingRoot = null;
|
|
443827
444176
|
try {
|
|
@@ -443881,7 +444230,7 @@ function getNpmInstallArgs(installSpec) {
|
|
|
443881
444230
|
];
|
|
443882
444231
|
}
|
|
443883
444232
|
function writeNpmInstallManifest(tempRoot) {
|
|
443884
|
-
|
|
444233
|
+
writeFileSync30(path48.join(tempRoot, "package.json"), `${JSON.stringify({
|
|
443885
444234
|
private: true,
|
|
443886
444235
|
name: "letta-managed-mod-install"
|
|
443887
444236
|
}, null, 2)}
|
|
@@ -444120,7 +444469,7 @@ function inferCompatibilityModEntries(packageDirectory) {
|
|
|
444120
444469
|
throw new Error(`Package mods directory must not be a symlink: mods`);
|
|
444121
444470
|
}
|
|
444122
444471
|
if (stats.isDirectory()) {
|
|
444123
|
-
const entries =
|
|
444472
|
+
const entries = readdirSync23(modsDirectory, { withFileTypes: true }).filter((entry) => entry.isFile() && isModFileExtension(path48.extname(entry.name))).map((entry) => `mods/${entry.name}`).sort();
|
|
444124
444473
|
if (entries.length > 0)
|
|
444125
444474
|
return entries;
|
|
444126
444475
|
}
|
|
@@ -444155,7 +444504,7 @@ function getPackageVersionForGitPackage(params) {
|
|
|
444155
444504
|
}
|
|
444156
444505
|
function writeCompatibilityPackageManifest(params) {
|
|
444157
444506
|
const packageJsonPath = path48.join(params.packageDirectory, "package.json");
|
|
444158
|
-
|
|
444507
|
+
writeFileSync30(packageJsonPath, `${JSON.stringify({
|
|
444159
444508
|
...params.packageJson ?? {},
|
|
444160
444509
|
name: params.packageName,
|
|
444161
444510
|
version: params.version,
|
|
@@ -444268,7 +444617,7 @@ async function installNpmManagedModPackage(params) {
|
|
|
444268
444617
|
packageDirectory
|
|
444269
444618
|
});
|
|
444270
444619
|
} finally {
|
|
444271
|
-
|
|
444620
|
+
rmSync15(tempRoot, { force: true, recursive: true });
|
|
444272
444621
|
}
|
|
444273
444622
|
}
|
|
444274
444623
|
async function installGitManagedModPackage(params) {
|
|
@@ -444300,7 +444649,7 @@ async function installGitManagedModPackage(params) {
|
|
|
444300
444649
|
packageInfo
|
|
444301
444650
|
});
|
|
444302
444651
|
} finally {
|
|
444303
|
-
|
|
444652
|
+
rmSync15(tempRoot, { force: true, recursive: true });
|
|
444304
444653
|
}
|
|
444305
444654
|
}
|
|
444306
444655
|
async function updateNpmManagedModPackage(params) {
|
|
@@ -444331,7 +444680,7 @@ async function updateNpmManagedModPackage(params) {
|
|
|
444331
444680
|
previousVersion: existing.version
|
|
444332
444681
|
};
|
|
444333
444682
|
} finally {
|
|
444334
|
-
|
|
444683
|
+
rmSync15(tempRoot, { force: true, recursive: true });
|
|
444335
444684
|
}
|
|
444336
444685
|
}
|
|
444337
444686
|
async function updateGitManagedModPackage(params) {
|
|
@@ -444373,7 +444722,7 @@ async function updateGitManagedModPackage(params) {
|
|
|
444373
444722
|
previousVersion: existing.version
|
|
444374
444723
|
};
|
|
444375
444724
|
} finally {
|
|
444376
|
-
|
|
444725
|
+
rmSync15(tempRoot, { force: true, recursive: true });
|
|
444377
444726
|
}
|
|
444378
444727
|
}
|
|
444379
444728
|
var SKIPPED_PACKAGE_COPY_NAMES, spawnNpmInstallProcessOverride = null, spawnGitInstallProcess, platformOverride2 = null;
|
|
@@ -444391,9 +444740,9 @@ import {
|
|
|
444391
444740
|
copyFileSync as copyFileSync5,
|
|
444392
444741
|
existsSync as existsSync60,
|
|
444393
444742
|
lstatSync as lstatSync4,
|
|
444394
|
-
mkdirSync as
|
|
444395
|
-
rmSync as
|
|
444396
|
-
writeFileSync as
|
|
444743
|
+
mkdirSync as mkdirSync42,
|
|
444744
|
+
rmSync as rmSync16,
|
|
444745
|
+
writeFileSync as writeFileSync31
|
|
444397
444746
|
} from "node:fs";
|
|
444398
444747
|
import path49 from "node:path";
|
|
444399
444748
|
function assertValidPackageName(packageName) {
|
|
@@ -444494,14 +444843,14 @@ function scaffoldLocalModPackage(options) {
|
|
|
444494
444843
|
const modGuidePath = path49.join(outputDirectory, "MOD.md");
|
|
444495
444844
|
const installCommand = `letta install ${outputDirectory}`;
|
|
444496
444845
|
try {
|
|
444497
|
-
|
|
444846
|
+
mkdirSync42(targetModsDirectory, { recursive: true });
|
|
444498
444847
|
copyFileSync5(sourceFile, targetModPath);
|
|
444499
|
-
|
|
444848
|
+
writeFileSync31(packageJsonPath, `${JSON.stringify(createPackageJson(packageName, manifestEntry), null, 2)}
|
|
444500
444849
|
`);
|
|
444501
|
-
|
|
444502
|
-
|
|
444850
|
+
writeFileSync31(readmePath, createReadme(packageName));
|
|
444851
|
+
writeFileSync31(modGuidePath, createModGuide(packageName, manifestEntry));
|
|
444503
444852
|
} catch (error5) {
|
|
444504
|
-
|
|
444853
|
+
rmSync16(outputDirectory, { force: true, recursive: true });
|
|
444505
444854
|
throw error5;
|
|
444506
444855
|
}
|
|
444507
444856
|
return {
|
|
@@ -444524,7 +444873,7 @@ var init_package_scaffolder = __esm(() => {
|
|
|
444524
444873
|
});
|
|
444525
444874
|
|
|
444526
444875
|
// src/cli/subcommands/mods.ts
|
|
444527
|
-
import { dirname as dirname32, join as
|
|
444876
|
+
import { dirname as dirname32, join as join75 } from "node:path";
|
|
444528
444877
|
import { parseArgs as parseArgs14 } from "node:util";
|
|
444529
444878
|
function printUsage11() {
|
|
444530
444879
|
console.log(`
|
|
@@ -444563,7 +444912,7 @@ function getExplicitAgentId(values4) {
|
|
|
444563
444912
|
return typeof explicitAgent === "string" && explicitAgent.trim() ? explicitAgent.trim() : null;
|
|
444564
444913
|
}
|
|
444565
444914
|
function getAgentModsDirectory(agentId) {
|
|
444566
|
-
return
|
|
444915
|
+
return join75(getScopedMemoryFilesystemRoot(agentId), "mods");
|
|
444567
444916
|
}
|
|
444568
444917
|
function directFilesForSource(source) {
|
|
444569
444918
|
return source.files.filter((file) => dirname32(file) === source.root);
|
|
@@ -445934,7 +446283,7 @@ var init_setup7 = __esm(async () => {
|
|
|
445934
446283
|
|
|
445935
446284
|
// src/cli/subcommands/shared-memory.ts
|
|
445936
446285
|
import { existsSync as existsSync61 } from "node:fs";
|
|
445937
|
-
import { join as
|
|
446286
|
+
import { join as join76 } from "node:path";
|
|
445938
446287
|
import { parseArgs as parseArgs18 } from "node:util";
|
|
445939
446288
|
function printUsage15() {
|
|
445940
446289
|
console.log(`
|
|
@@ -446126,7 +446475,7 @@ async function runSharedMemorySubcommand(argv, deps = {}) {
|
|
|
446126
446475
|
invalidateClientSkills(agentId);
|
|
446127
446476
|
const recompileError = await recompileAndReportFailure(recompileAgent, agentId);
|
|
446128
446477
|
const mountDir = getRepositoryMountDir(agentId, repository.name);
|
|
446129
|
-
const mounted = existsSync61(
|
|
446478
|
+
const mounted = existsSync61(join76(mountDir, ".git"));
|
|
446130
446479
|
console.log(JSON.stringify({
|
|
446131
446480
|
attached: true,
|
|
446132
446481
|
repository: { id: repository.id, name: repository.name },
|
|
@@ -447657,14 +448006,14 @@ import {
|
|
|
447657
448006
|
cpSync as cpSync2,
|
|
447658
448007
|
existsSync as existsSync62,
|
|
447659
448008
|
mkdtempSync as mkdtempSync5,
|
|
447660
|
-
readFileSync as
|
|
447661
|
-
rmSync as
|
|
448009
|
+
readFileSync as readFileSync41,
|
|
448010
|
+
rmSync as rmSync17,
|
|
447662
448011
|
statSync as statSync21,
|
|
447663
|
-
writeFileSync as
|
|
448012
|
+
writeFileSync as writeFileSync32
|
|
447664
448013
|
} from "node:fs";
|
|
447665
448014
|
import { mkdir as mkdir15, readdir as readdir13 } from "node:fs/promises";
|
|
447666
448015
|
import { tmpdir as tmpdir11 } from "node:os";
|
|
447667
|
-
import { basename as basename26, dirname as dirname33, join as
|
|
448016
|
+
import { basename as basename26, dirname as dirname33, join as join77, normalize as normalize5, resolve as resolve39, sep as sep8 } from "node:path";
|
|
447668
448017
|
import { parseArgs as parseArgs19, TextDecoder as TextDecoder2, TextEncoder as TextEncoder2 } from "node:util";
|
|
447669
448018
|
function printUsage16() {
|
|
447670
448019
|
console.log(`
|
|
@@ -447956,14 +448305,14 @@ async function resolveBranchAndSubdir(location) {
|
|
|
447956
448305
|
}
|
|
447957
448306
|
async function cloneSkillSource(location) {
|
|
447958
448307
|
const resolvedLocation = await resolveBranchAndSubdir(location);
|
|
447959
|
-
const tmpDir = mkdtempSync5(
|
|
448308
|
+
const tmpDir = mkdtempSync5(join77(tmpdir11(), "letta-skill-install-"));
|
|
447960
448309
|
const args = ["clone", "--depth", "1"];
|
|
447961
448310
|
if (resolvedLocation.branch) {
|
|
447962
448311
|
args.push("--branch", resolvedLocation.branch);
|
|
447963
448312
|
}
|
|
447964
448313
|
args.push(resolvedLocation.repoUrl, tmpDir);
|
|
447965
448314
|
await execFile17("git", args, { timeout: 120000 });
|
|
447966
|
-
const sourceDir = resolvedLocation.subdir ?
|
|
448315
|
+
const sourceDir = resolvedLocation.subdir ? join77(tmpDir, resolvedLocation.subdir) : tmpDir;
|
|
447967
448316
|
return { tmpDir, sourceDir };
|
|
447968
448317
|
}
|
|
447969
448318
|
function assertDirectSkillFileSize(receivedBytes, maxBytes) {
|
|
@@ -448018,14 +448367,14 @@ async function downloadDirectSkillFileSource(location, options = {}) {
|
|
|
448018
448367
|
throw new Error(`Direct skill file download failed for ${location.url}: ${response.status}`);
|
|
448019
448368
|
}
|
|
448020
448369
|
const skillText = await readResponseTextWithLimit(response, MAX_DIRECT_SKILL_FILE_BYTES);
|
|
448021
|
-
const tmpDir = mkdtempSync5(
|
|
448370
|
+
const tmpDir = mkdtempSync5(join77(tmpdir11(), "letta-direct-skill-"));
|
|
448022
448371
|
try {
|
|
448023
|
-
const sourceDir =
|
|
448372
|
+
const sourceDir = join77(tmpDir, "skill");
|
|
448024
448373
|
await mkdir15(sourceDir, { recursive: true });
|
|
448025
|
-
|
|
448374
|
+
writeFileSync32(join77(sourceDir, "SKILL.md"), skillText, "utf8");
|
|
448026
448375
|
return { tmpDir, sourceDir };
|
|
448027
448376
|
} catch (error5) {
|
|
448028
|
-
|
|
448377
|
+
rmSync17(tmpDir, { recursive: true, force: true });
|
|
448029
448378
|
throw error5;
|
|
448030
448379
|
}
|
|
448031
448380
|
}
|
|
@@ -448063,9 +448412,9 @@ function assertSafeZipMember(name) {
|
|
|
448063
448412
|
}
|
|
448064
448413
|
async function downloadClawHubSkillSource(location) {
|
|
448065
448414
|
const version2 = await resolveClawHubVersion(location);
|
|
448066
|
-
const tmpDir = mkdtempSync5(
|
|
448067
|
-
const zipPath =
|
|
448068
|
-
const sourceDir =
|
|
448415
|
+
const tmpDir = mkdtempSync5(join77(tmpdir11(), "letta-clawhub-skill-"));
|
|
448416
|
+
const zipPath = join77(tmpDir, "skill.zip");
|
|
448417
|
+
const sourceDir = join77(tmpDir, "skill");
|
|
448069
448418
|
await mkdir15(sourceDir, { recursive: true });
|
|
448070
448419
|
const url2 = new URL(`${CLAWHUB_API_BASE_URL}/download`);
|
|
448071
448420
|
url2.searchParams.set("slug", location.slug);
|
|
@@ -448074,7 +448423,7 @@ async function downloadClawHubSkillSource(location) {
|
|
|
448074
448423
|
if (!response.ok) {
|
|
448075
448424
|
throw new Error(`ClawHub download failed for ${location.slug}@${version2}: ${response.status}`);
|
|
448076
448425
|
}
|
|
448077
|
-
|
|
448426
|
+
writeFileSync32(zipPath, Buffer.from(await response.arrayBuffer()));
|
|
448078
448427
|
const { stdout } = await execFile17("unzip", ["-Z1", zipPath], {
|
|
448079
448428
|
timeout: 30000
|
|
448080
448429
|
});
|
|
@@ -448104,7 +448453,7 @@ function sanitizeSkillName(name) {
|
|
|
448104
448453
|
return trimmed;
|
|
448105
448454
|
}
|
|
448106
448455
|
function getSkillName(sourceDir) {
|
|
448107
|
-
const skillMd =
|
|
448456
|
+
const skillMd = readFileSync41(join77(sourceDir, "SKILL.md"), "utf8");
|
|
448108
448457
|
const { frontmatter } = parseFrontmatter(skillMd);
|
|
448109
448458
|
const frontmatterName = frontmatter.name;
|
|
448110
448459
|
const name = typeof frontmatterName === "string" && frontmatterName.trim() ? frontmatterName : basename26(sourceDir);
|
|
@@ -448113,7 +448462,7 @@ function getSkillName(sourceDir) {
|
|
|
448113
448462
|
async function installSkillDirectory(params) {
|
|
448114
448463
|
const sourceDir = resolve39(params.sourceDir);
|
|
448115
448464
|
const memoryDir = resolve39(params.memoryDir);
|
|
448116
|
-
const skillMdPath =
|
|
448465
|
+
const skillMdPath = join77(sourceDir, "SKILL.md");
|
|
448117
448466
|
if (!existsSync62(skillMdPath)) {
|
|
448118
448467
|
throw new Error("No SKILL.md found in the skill directory.");
|
|
448119
448468
|
}
|
|
@@ -448121,14 +448470,14 @@ async function installSkillDirectory(params) {
|
|
|
448121
448470
|
throw new Error(`Skill source is not a directory: ${sourceDir}`);
|
|
448122
448471
|
}
|
|
448123
448472
|
const name = getSkillName(sourceDir);
|
|
448124
|
-
const skillsDir =
|
|
448125
|
-
const targetPath =
|
|
448473
|
+
const skillsDir = join77(memoryDir, "skills");
|
|
448474
|
+
const targetPath = join77(skillsDir, name);
|
|
448126
448475
|
assertInside(skillsDir, targetPath);
|
|
448127
448476
|
if (existsSync62(targetPath)) {
|
|
448128
448477
|
if (!params.force) {
|
|
448129
448478
|
throw new Error(`Skill "${name}" already exists at ${targetPath}. Re-run with --force to replace it.`);
|
|
448130
448479
|
}
|
|
448131
|
-
|
|
448480
|
+
rmSync17(targetPath, { recursive: true, force: true });
|
|
448132
448481
|
}
|
|
448133
448482
|
await mkdir15(skillsDir, { recursive: true });
|
|
448134
448483
|
cpSync2(sourceDir, targetPath, {
|
|
@@ -448139,7 +448488,7 @@ async function installSkillDirectory(params) {
|
|
|
448139
448488
|
}
|
|
448140
448489
|
async function listSkillDirectories(params) {
|
|
448141
448490
|
const memoryDir = resolve39(params.memoryDir);
|
|
448142
|
-
const skillsDir =
|
|
448491
|
+
const skillsDir = join77(memoryDir, "skills");
|
|
448143
448492
|
if (!existsSync62(skillsDir))
|
|
448144
448493
|
return [];
|
|
448145
448494
|
const entries = await readdir13(skillsDir, { withFileTypes: true });
|
|
@@ -448147,14 +448496,14 @@ async function listSkillDirectories(params) {
|
|
|
448147
448496
|
for (const entry of entries) {
|
|
448148
448497
|
if (!entry.isDirectory())
|
|
448149
448498
|
continue;
|
|
448150
|
-
const skillDir =
|
|
448151
|
-
const skillMdPath =
|
|
448499
|
+
const skillDir = join77(skillsDir, entry.name);
|
|
448500
|
+
const skillMdPath = join77(skillDir, "SKILL.md");
|
|
448152
448501
|
if (!existsSync62(skillMdPath))
|
|
448153
448502
|
continue;
|
|
448154
448503
|
let name = entry.name;
|
|
448155
448504
|
let description;
|
|
448156
448505
|
try {
|
|
448157
|
-
const skillMd =
|
|
448506
|
+
const skillMd = readFileSync41(skillMdPath, "utf8");
|
|
448158
448507
|
const { frontmatter } = parseFrontmatter(skillMd);
|
|
448159
448508
|
if (typeof frontmatter.name === "string" && frontmatter.name.trim()) {
|
|
448160
448509
|
name = frontmatter.name.trim();
|
|
@@ -448169,9 +448518,9 @@ async function listSkillDirectories(params) {
|
|
|
448169
448518
|
}
|
|
448170
448519
|
async function deleteSkillDirectory(params) {
|
|
448171
448520
|
const memoryDir = resolve39(params.memoryDir);
|
|
448172
|
-
const skillsDir =
|
|
448521
|
+
const skillsDir = join77(memoryDir, "skills");
|
|
448173
448522
|
const name = sanitizeSkillName(params.name);
|
|
448174
|
-
const targetPath =
|
|
448523
|
+
const targetPath = join77(skillsDir, name);
|
|
448175
448524
|
assertInside(skillsDir, targetPath);
|
|
448176
448525
|
if (!existsSync62(targetPath)) {
|
|
448177
448526
|
throw new Error(`Skill "${name}" is not installed at ${targetPath}.`);
|
|
@@ -448179,7 +448528,7 @@ async function deleteSkillDirectory(params) {
|
|
|
448179
448528
|
if (!statSync21(targetPath).isDirectory()) {
|
|
448180
448529
|
throw new Error(`Skill path is not a directory: ${targetPath}`);
|
|
448181
448530
|
}
|
|
448182
|
-
|
|
448531
|
+
rmSync17(targetPath, { recursive: true, force: true });
|
|
448183
448532
|
return { name, path: normalize5(targetPath) };
|
|
448184
448533
|
}
|
|
448185
448534
|
async function loadSkillMemorySyncFn() {
|
|
@@ -448243,7 +448592,7 @@ async function installSkill(specifier, agentId, force) {
|
|
|
448243
448592
|
};
|
|
448244
448593
|
} finally {
|
|
448245
448594
|
if (tmpDir)
|
|
448246
|
-
|
|
448595
|
+
rmSync17(tmpDir, { recursive: true, force: true });
|
|
448247
448596
|
}
|
|
448248
448597
|
}
|
|
448249
448598
|
async function getAgentMemoryDir(agentId) {
|
|
@@ -448757,7 +449106,7 @@ var init_teleport2 = __esm(() => {
|
|
|
448757
449106
|
|
|
448758
449107
|
// src/cli/subcommands/trajectories/readers.ts
|
|
448759
449108
|
import { readdir as readdir14, readFile as readFile26, stat as stat17 } from "node:fs/promises";
|
|
448760
|
-
import { join as
|
|
449109
|
+
import { join as join78 } from "node:path";
|
|
448761
449110
|
async function loadSessionTranscript(item) {
|
|
448762
449111
|
const stats = await stat17(item.path);
|
|
448763
449112
|
if (stats.isDirectory()) {
|
|
@@ -448769,13 +449118,13 @@ async function loadSessionTranscript(item) {
|
|
|
448769
449118
|
return readFile26(item.path, "utf-8");
|
|
448770
449119
|
}
|
|
448771
449120
|
async function assembleEventDirectory(sessionDir) {
|
|
448772
|
-
const eventsSubdir =
|
|
449121
|
+
const eventsSubdir = join78(sessionDir, "events");
|
|
448773
449122
|
const eventsDir = (await stat17(eventsSubdir).catch(() => null))?.isDirectory() ? eventsSubdir : sessionDir;
|
|
448774
449123
|
const names2 = (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));
|
|
448775
449124
|
if (names2.length === 0) {
|
|
448776
449125
|
throw new Error(`No event files found in ${eventsDir}`);
|
|
448777
449126
|
}
|
|
448778
|
-
const events = await Promise.all(names2.map(async (name) => JSON.parse(await readFile26(
|
|
449127
|
+
const events = await Promise.all(names2.map(async (name) => JSON.parse(await readFile26(join78(eventsDir, name), "utf-8"))));
|
|
448779
449128
|
return JSON.stringify(events);
|
|
448780
449129
|
}
|
|
448781
449130
|
async function openReadOnlyDatabase(path50) {
|
|
@@ -448844,7 +449193,7 @@ var init_sources = __esm(() => {
|
|
|
448844
449193
|
});
|
|
448845
449194
|
|
|
448846
449195
|
// src/cli/subcommands/trajectories/export.ts
|
|
448847
|
-
import { createHash as
|
|
449196
|
+
import { createHash as createHash12 } from "node:crypto";
|
|
448848
449197
|
import {
|
|
448849
449198
|
mkdir as mkdir16,
|
|
448850
449199
|
readdir as readdir15,
|
|
@@ -448853,14 +449202,14 @@ import {
|
|
|
448853
449202
|
stat as stat18,
|
|
448854
449203
|
writeFile as writeFile17
|
|
448855
449204
|
} from "node:fs/promises";
|
|
448856
|
-
import { basename as basename27, join as
|
|
449205
|
+
import { basename as basename27, join as join79 } from "node:path";
|
|
448857
449206
|
function fileTimestamp(startedAt) {
|
|
448858
449207
|
if (!startedAt)
|
|
448859
449208
|
return "unknown-date";
|
|
448860
449209
|
return startedAt.slice(0, 19).replace(/:/g, "-");
|
|
448861
449210
|
}
|
|
448862
449211
|
function sessionHash(source, nativeId) {
|
|
448863
|
-
return
|
|
449212
|
+
return createHash12("sha256").update(`${source}:${nativeId}`).digest("hex").slice(0, 10);
|
|
448864
449213
|
}
|
|
448865
449214
|
async function listAllTrajectories(source, root2) {
|
|
448866
449215
|
const items3 = [];
|
|
@@ -448923,7 +449272,7 @@ async function prepareOutDir(outDir) {
|
|
|
448923
449272
|
throw new Error(`--out ${outDir} is not empty and has no ${MANIFEST_NAME}; refusing to overwrite a directory this tool did not create`);
|
|
448924
449273
|
}
|
|
448925
449274
|
for (const entry of entries) {
|
|
448926
|
-
await rm9(
|
|
449275
|
+
await rm9(join79(outDir, entry), { recursive: true, force: true });
|
|
448927
449276
|
}
|
|
448928
449277
|
} catch (error5) {
|
|
448929
449278
|
if (error5.code !== "ENOENT")
|
|
@@ -448966,14 +449315,14 @@ async function runTrajectoryExport(options) {
|
|
|
448966
449315
|
}
|
|
448967
449316
|
const sessionId = sessionHash(source, id2);
|
|
448968
449317
|
const base2 = `${fileTimestamp(stats.startedAt)}_${sessionId}`;
|
|
448969
|
-
let file =
|
|
449318
|
+
let file = join79(source, `${base2}.json`);
|
|
448970
449319
|
for (let suffix = 2;usedFiles.has(file); suffix += 1) {
|
|
448971
|
-
file =
|
|
449320
|
+
file = join79(source, `${base2}-${suffix}.json`);
|
|
448972
449321
|
}
|
|
448973
449322
|
usedFiles.add(file);
|
|
448974
449323
|
const body3 = JSON.stringify(records);
|
|
448975
|
-
await mkdir16(
|
|
448976
|
-
await writeFile17(
|
|
449324
|
+
await mkdir16(join79(options.outDir, source), { recursive: true });
|
|
449325
|
+
await writeFile17(join79(options.outDir, file), body3, "utf-8");
|
|
448977
449326
|
counts.exported += 1;
|
|
448978
449327
|
manifest2.sessions.push({
|
|
448979
449328
|
source,
|
|
@@ -449027,7 +449376,7 @@ async function runTrajectoryExport(options) {
|
|
|
449027
449376
|
await exportCheckpoint(checkpoint, `${basename27(checkpoint.path)}-${checkpoint.threadId}`);
|
|
449028
449377
|
}
|
|
449029
449378
|
manifest2.sessions.sort((a2, b3) => (a2.startedAt ?? "").localeCompare(b3.startedAt ?? ""));
|
|
449030
|
-
await writeFile17(
|
|
449379
|
+
await writeFile17(join79(options.outDir, MANIFEST_NAME), JSON.stringify(manifest2, null, 2), "utf-8");
|
|
449031
449380
|
return manifest2;
|
|
449032
449381
|
}
|
|
449033
449382
|
var MANIFEST_NAME = "manifest.json", FIRST_PROMPT_MAX_CHARS = 200, LIST_PAGE_LIMIT = 1000;
|
|
@@ -449039,13 +449388,13 @@ var init_export = __esm(() => {
|
|
|
449039
449388
|
|
|
449040
449389
|
// src/cli/subcommands/trajectories/review.ts
|
|
449041
449390
|
import { readFile as readFile28 } from "node:fs/promises";
|
|
449042
|
-
import { isAbsolute as isAbsolute30, join as
|
|
449391
|
+
import { isAbsolute as isAbsolute30, join as join80 } from "node:path";
|
|
449043
449392
|
async function readManifest(dir) {
|
|
449044
449393
|
let raw2;
|
|
449045
449394
|
try {
|
|
449046
|
-
raw2 = await readFile28(
|
|
449395
|
+
raw2 = await readFile28(join80(dir, "manifest.json"), "utf-8");
|
|
449047
449396
|
} catch {
|
|
449048
|
-
throw new Error(`No manifest at ${
|
|
449397
|
+
throw new Error(`No manifest at ${join80(dir, "manifest.json")}. Run: letta trajectories export --out ${dir}`);
|
|
449049
449398
|
}
|
|
449050
449399
|
return JSON.parse(raw2);
|
|
449051
449400
|
}
|
|
@@ -449054,7 +449403,7 @@ function filterSessions(sessions, filter4) {
|
|
|
449054
449403
|
}
|
|
449055
449404
|
async function resolveSessionFile(dir, target2) {
|
|
449056
449405
|
if (target2.endsWith(".json")) {
|
|
449057
|
-
const direct = isAbsolute30(target2) ? target2 :
|
|
449406
|
+
const direct = isAbsolute30(target2) ? target2 : join80(dir, target2);
|
|
449058
449407
|
try {
|
|
449059
449408
|
await readFile28(direct, "utf-8");
|
|
449060
449409
|
return direct;
|
|
@@ -449065,7 +449414,7 @@ async function resolveSessionFile(dir, target2) {
|
|
|
449065
449414
|
if (!entry) {
|
|
449066
449415
|
throw new Error(`No session "${target2}" in ${dir} (pass a file path, a manifest-relative file, or a sessionId)`);
|
|
449067
449416
|
}
|
|
449068
|
-
return
|
|
449417
|
+
return join80(dir, entry.file);
|
|
449069
449418
|
}
|
|
449070
449419
|
function stamp(timestamp) {
|
|
449071
449420
|
return (timestamp ?? "").slice(0, 19);
|
|
@@ -449108,7 +449457,7 @@ async function searchSessions(dir, keyword, options = {}) {
|
|
|
449108
449457
|
for (const session2 of filterSessions(manifest2.sessions, options)) {
|
|
449109
449458
|
let records;
|
|
449110
449459
|
try {
|
|
449111
|
-
records = JSON.parse(await readFile28(
|
|
449460
|
+
records = JSON.parse(await readFile28(join80(dir, session2.file), "utf-8"));
|
|
449112
449461
|
} catch {
|
|
449113
449462
|
continue;
|
|
449114
449463
|
}
|
|
@@ -452782,7 +453131,7 @@ var init_message_channel_gateway_tool = __esm(() => {
|
|
|
452782
453131
|
});
|
|
452783
453132
|
|
|
452784
453133
|
// src/channels/custom/scaffolding.ts
|
|
452785
|
-
import { existsSync as existsSync63, mkdirSync as
|
|
453134
|
+
import { existsSync as existsSync63, mkdirSync as mkdirSync43, rmSync as rmSync18, writeFileSync as writeFileSync33 } from "node:fs";
|
|
452786
453135
|
function removeUserPlugin(channelId) {
|
|
452787
453136
|
if (FIRST_PARTY_SET.has(channelId)) {
|
|
452788
453137
|
return;
|
|
@@ -452795,7 +453144,7 @@ function removeUserPlugin(channelId) {
|
|
|
452795
453144
|
return;
|
|
452796
453145
|
}
|
|
452797
453146
|
try {
|
|
452798
|
-
|
|
453147
|
+
rmSync18(channelDir, { recursive: true, force: true });
|
|
452799
453148
|
} catch (err) {
|
|
452800
453149
|
console.error(`[channels] Failed to remove plugin folder ${channelDir}:`, err);
|
|
452801
453150
|
}
|
|
@@ -453836,7 +454185,7 @@ async function handleChannelsSlashCommand(runtime, args) {
|
|
|
453836
454185
|
}
|
|
453837
454186
|
|
|
453838
454187
|
// src/channels/gateway-local.ts
|
|
453839
|
-
import { createHash as
|
|
454188
|
+
import { createHash as createHash13 } from "node:crypto";
|
|
453840
454189
|
import WebSocket10 from "ws";
|
|
453841
454190
|
async function executeChannelServiceCommand(command) {
|
|
453842
454191
|
if (!isDetachedChannelsCommand(command)) {
|
|
@@ -453880,7 +454229,7 @@ function gatewayClientMessageId(delivery) {
|
|
|
453880
454229
|
messageId: source.messageId ?? null
|
|
453881
454230
|
})).sort((a2, b3) => JSON.stringify(a2).localeCompare(JSON.stringify(b3)));
|
|
453882
454231
|
const hasPlatformMessageId = (delivery.turnSources ?? []).some((source) => Boolean(source.messageId));
|
|
453883
|
-
const digest =
|
|
454232
|
+
const digest = createHash13("sha256").update(JSON.stringify({
|
|
453884
454233
|
agentId: delivery.route.agentId,
|
|
453885
454234
|
conversationId: delivery.route.conversationId,
|
|
453886
454235
|
sources: sourceIdentity,
|
|
@@ -454781,9 +455130,9 @@ var exports_bootstrap_tools = {};
|
|
|
454781
455130
|
__export(exports_bootstrap_tools, {
|
|
454782
455131
|
bootstrapBaseToolsIfNeeded: () => bootstrapBaseToolsIfNeeded
|
|
454783
455132
|
});
|
|
454784
|
-
import { existsSync as existsSync64, mkdirSync as
|
|
454785
|
-
import { homedir as
|
|
454786
|
-
import { join as
|
|
455133
|
+
import { existsSync as existsSync64, mkdirSync as mkdirSync44, writeFileSync as writeFileSync34 } from "node:fs";
|
|
455134
|
+
import { homedir as homedir45 } from "node:os";
|
|
455135
|
+
import { join as join81 } from "node:path";
|
|
454787
455136
|
async function bootstrapBaseToolsIfNeeded(options = {}) {
|
|
454788
455137
|
if (existsSync64(MARKER_PATH2))
|
|
454789
455138
|
return;
|
|
@@ -454791,8 +455140,8 @@ async function bootstrapBaseToolsIfNeeded(options = {}) {
|
|
|
454791
455140
|
try {
|
|
454792
455141
|
const success = await addBaseToolsToServer(options);
|
|
454793
455142
|
if (success) {
|
|
454794
|
-
|
|
454795
|
-
|
|
455143
|
+
mkdirSync44(join81(homedir45(), ".letta"), { recursive: true });
|
|
455144
|
+
writeFileSync34(MARKER_PATH2, new Date().toISOString(), "utf-8");
|
|
454796
455145
|
}
|
|
454797
455146
|
} catch (err) {
|
|
454798
455147
|
debugWarn("bootstrap", `Failed to bootstrap base tools: ${err instanceof Error ? err.message : String(err)}`);
|
|
@@ -454802,7 +455151,7 @@ var MARKER_PATH2;
|
|
|
454802
455151
|
var init_bootstrap_tools = __esm(() => {
|
|
454803
455152
|
init_debug();
|
|
454804
455153
|
init_create5();
|
|
454805
|
-
MARKER_PATH2 =
|
|
455154
|
+
MARKER_PATH2 = join81(homedir45(), ".letta", ".bootstrapped");
|
|
454806
455155
|
});
|
|
454807
455156
|
|
|
454808
455157
|
// src/utils/headless-stdout-guard.ts
|
|
@@ -454843,7 +455192,7 @@ function resolveListMessagesRoute(listReq, sessionConvId, sessionAgentId) {
|
|
|
454843
455192
|
}
|
|
454844
455193
|
|
|
454845
455194
|
// src/agent/bootstrap-handler.ts
|
|
454846
|
-
import { randomUUID as
|
|
455195
|
+
import { randomUUID as randomUUID37 } from "node:crypto";
|
|
454847
455196
|
async function handleBootstrapSessionState(params) {
|
|
454848
455197
|
const {
|
|
454849
455198
|
bootstrapReq,
|
|
@@ -454892,7 +455241,7 @@ async function handleBootstrapSessionState(params) {
|
|
|
454892
455241
|
response: payload
|
|
454893
455242
|
},
|
|
454894
455243
|
session_id: sessionContext.sessionId,
|
|
454895
|
-
uuid:
|
|
455244
|
+
uuid: randomUUID37()
|
|
454896
455245
|
};
|
|
454897
455246
|
} catch (err) {
|
|
454898
455247
|
return {
|
|
@@ -454903,14 +455252,14 @@ async function handleBootstrapSessionState(params) {
|
|
|
454903
455252
|
error: err instanceof Error ? err.message : "bootstrap_session_state failed"
|
|
454904
455253
|
},
|
|
454905
455254
|
session_id: sessionContext.sessionId,
|
|
454906
|
-
uuid:
|
|
455255
|
+
uuid: randomUUID37()
|
|
454907
455256
|
};
|
|
454908
455257
|
}
|
|
454909
455258
|
}
|
|
454910
455259
|
var init_bootstrap_handler = () => {};
|
|
454911
455260
|
|
|
454912
455261
|
// src/agent/list-messages-handler.ts
|
|
454913
|
-
import { randomUUID as
|
|
455262
|
+
import { randomUUID as randomUUID38 } from "node:crypto";
|
|
454914
455263
|
async function handleListMessages(params) {
|
|
454915
455264
|
const {
|
|
454916
455265
|
listReq,
|
|
@@ -454950,7 +455299,7 @@ async function handleListMessages(params) {
|
|
|
454950
455299
|
response: payload
|
|
454951
455300
|
},
|
|
454952
455301
|
session_id: sessionId,
|
|
454953
|
-
uuid:
|
|
455302
|
+
uuid: randomUUID38()
|
|
454954
455303
|
};
|
|
454955
455304
|
} catch (err) {
|
|
454956
455305
|
return {
|
|
@@ -454961,7 +455310,7 @@ async function handleListMessages(params) {
|
|
|
454961
455310
|
error: err instanceof Error ? err.message : "list_messages failed"
|
|
454962
455311
|
},
|
|
454963
455312
|
session_id: sessionId,
|
|
454964
|
-
uuid:
|
|
455313
|
+
uuid: randomUUID38()
|
|
454965
455314
|
};
|
|
454966
455315
|
}
|
|
454967
455316
|
}
|
|
@@ -455264,7 +455613,7 @@ var init_headless_environment_response = __esm(() => {
|
|
|
455264
455613
|
});
|
|
455265
455614
|
|
|
455266
455615
|
// src/headless-cloud-send.ts
|
|
455267
|
-
import { randomUUID as
|
|
455616
|
+
import { randomUUID as randomUUID39 } from "node:crypto";
|
|
455268
455617
|
function shouldEnqueueCloudSend(values4, cloud, isAgentLaunch) {
|
|
455269
455618
|
if (!cloud || isAgentLaunch || values4["new-agent"] || values4.ephemeral)
|
|
455270
455619
|
return false;
|
|
@@ -455313,7 +455662,7 @@ async function tryCloudHeadlessSend(values4, prompt, backend3, isAgentLaunch, de
|
|
|
455313
455662
|
const format5 = values4["output-format"] ?? "text";
|
|
455314
455663
|
const noWait = Boolean(values4["no-wait"]);
|
|
455315
455664
|
const started = Date.now();
|
|
455316
|
-
const clientMessageId =
|
|
455665
|
+
const clientMessageId = randomUUID39();
|
|
455317
455666
|
const controller = new AbortController;
|
|
455318
455667
|
const submissionTimeout = setTimeout(() => controller.abort(new Error("Cloud submission timed out; inspect the conversation before resending.")), 30000);
|
|
455319
455668
|
const timeout = setTimeout(() => controller.abort(new Error("Stopped waiting; remote execution was not cancelled.")), deps.timeoutMs ?? resolveEnvironmentMaxWaitMs());
|
|
@@ -455393,7 +455742,7 @@ async function tryCloudHeadlessSend(values4, prompt, backend3, isAgentLaunch, de
|
|
|
455393
455742
|
mcp_servers: [],
|
|
455394
455743
|
permission_mode: "",
|
|
455395
455744
|
slash_commands: [],
|
|
455396
|
-
uuid:
|
|
455745
|
+
uuid: randomUUID39()
|
|
455397
455746
|
};
|
|
455398
455747
|
await writeObject(init);
|
|
455399
455748
|
}
|
|
@@ -455436,7 +455785,7 @@ async function tryCloudHeadlessSend(values4, prompt, backend3, isAgentLaunch, de
|
|
|
455436
455785
|
duration_api_ms: 0,
|
|
455437
455786
|
num_turns: 1,
|
|
455438
455787
|
usage: null,
|
|
455439
|
-
uuid:
|
|
455788
|
+
uuid: randomUUID39(),
|
|
455440
455789
|
...recovery
|
|
455441
455790
|
});
|
|
455442
455791
|
return 0;
|
|
@@ -455455,7 +455804,7 @@ async function tryCloudHeadlessSend(values4, prompt, backend3, isAgentLaunch, de
|
|
|
455455
455804
|
run_ids: error5 instanceof EnqueuedWaitError ? error5.runIds : [],
|
|
455456
455805
|
usage: null,
|
|
455457
455806
|
stop_reason: "error",
|
|
455458
|
-
uuid:
|
|
455807
|
+
uuid: randomUUID39(),
|
|
455459
455808
|
status: receipt ? "wait_failed" : submissionAttempted && !(error5 instanceof ApiRequestError && error5.status >= 400 && error5.status < 500) ? "acceptance_unknown" : "submission_failed",
|
|
455460
455809
|
agent_id: agentId ?? null,
|
|
455461
455810
|
conversation_id: conversationId ?? "",
|
|
@@ -455609,7 +455958,7 @@ var init_headless_ephemeral_startup = __esm(async () => {
|
|
|
455609
455958
|
});
|
|
455610
455959
|
|
|
455611
455960
|
// src/headless-listener-launch.ts
|
|
455612
|
-
import { randomUUID as
|
|
455961
|
+
import { randomUUID as randomUUID40 } from "node:crypto";
|
|
455613
455962
|
import { setTimeout as delay2 } from "node:timers/promises";
|
|
455614
455963
|
import WebSocket11 from "ws";
|
|
455615
455964
|
function listenerControlUrl(baseUrl, connectionId, scope) {
|
|
@@ -455656,7 +456005,7 @@ async function cancelListenerInput(params) {
|
|
|
455656
456005
|
}
|
|
455657
456006
|
async function launchListenerConversation(params, deps = {}) {
|
|
455658
456007
|
const client = deps.client ?? await createListenerClient(params.connectionId, params.scope);
|
|
455659
|
-
const clientMessageId =
|
|
456008
|
+
const clientMessageId = randomUUID40();
|
|
455660
456009
|
const runIds = new Set;
|
|
455661
456010
|
let loop;
|
|
455662
456011
|
let cancelled = false;
|
|
@@ -455841,7 +456190,7 @@ function resolveHeadlessMemfsPolicy(options) {
|
|
|
455841
456190
|
}
|
|
455842
456191
|
|
|
455843
456192
|
// src/headless-mod-adapter.ts
|
|
455844
|
-
import { join as
|
|
456193
|
+
import { join as join82 } from "node:path";
|
|
455845
456194
|
function isHeadlessMemfsEnabled(agentId) {
|
|
455846
456195
|
try {
|
|
455847
456196
|
return settingsManager.isMemfsEnabled(agentId);
|
|
@@ -455912,7 +456261,7 @@ function createHeadlessModContext(options) {
|
|
|
455912
456261
|
};
|
|
455913
456262
|
}
|
|
455914
456263
|
function createHeadlessModAdapter(options) {
|
|
455915
|
-
const agentModsDirectory = isHeadlessMemfsEnabled(options.agent.id) ?
|
|
456264
|
+
const agentModsDirectory = isHeadlessMemfsEnabled(options.agent.id) ? join82(getScopedMemoryFilesystemRoot(options.agent.id), "mods") : undefined;
|
|
455916
456265
|
return createModAdapter({
|
|
455917
456266
|
...agentModsDirectory ? { agentModsDirectory } : {},
|
|
455918
456267
|
...options.cacheDirectory ? { cacheDirectory: options.cacheDirectory } : {},
|
|
@@ -456299,7 +456648,7 @@ __export(exports_headless, {
|
|
|
456299
456648
|
decideInterruptAction: () => decideInterruptAction,
|
|
456300
456649
|
__headlessTestUtils: () => __headlessTestUtils
|
|
456301
456650
|
});
|
|
456302
|
-
import { randomUUID as
|
|
456651
|
+
import { randomUUID as randomUUID41 } from "node:crypto";
|
|
456303
456652
|
function trackHeadlessBoundaryError(errorType, error5, context3) {
|
|
456304
456653
|
trackBoundaryError({
|
|
456305
456654
|
errorType,
|
|
@@ -456321,7 +456670,7 @@ async function reportStartupErrorAndExit(errorType, error5, context3, outputForm
|
|
|
456321
456670
|
message,
|
|
456322
456671
|
stop_reason: "error",
|
|
456323
456672
|
session_id: "startup",
|
|
456324
|
-
uuid: `startup-error-${
|
|
456673
|
+
uuid: `startup-error-${randomUUID41()}`
|
|
456325
456674
|
};
|
|
456326
456675
|
await writeWireMessageAsync(errorMsg);
|
|
456327
456676
|
} else {
|
|
@@ -456420,7 +456769,7 @@ async function emitHeadlessTurnStartCancellationOutput(options) {
|
|
|
456420
456769
|
message: options.reason,
|
|
456421
456770
|
stop_reason: "cancelled",
|
|
456422
456771
|
session_id: options.sessionId,
|
|
456423
|
-
uuid: `error-turn-start-cancel-${
|
|
456772
|
+
uuid: `error-turn-start-cancel-${randomUUID41()}`
|
|
456424
456773
|
};
|
|
456425
456774
|
await writeWireMessageAsync(errorMsg);
|
|
456426
456775
|
const resultMsg = {
|
|
@@ -456435,7 +456784,7 @@ async function emitHeadlessTurnStartCancellationOutput(options) {
|
|
|
456435
456784
|
conversation_id: options.conversationId,
|
|
456436
456785
|
run_ids: [],
|
|
456437
456786
|
usage: null,
|
|
456438
|
-
uuid: `result-turn-start-cancel-${
|
|
456787
|
+
uuid: `result-turn-start-cancel-${randomUUID41()}`,
|
|
456439
456788
|
stop_reason: "cancelled"
|
|
456440
456789
|
};
|
|
456441
456790
|
await writeWireMessageAsync(resultMsg);
|
|
@@ -456464,7 +456813,7 @@ function writeBidirectionalTurnStartCancellation(options) {
|
|
|
456464
456813
|
message: options.reason,
|
|
456465
456814
|
stop_reason: "cancelled",
|
|
456466
456815
|
session_id: options.sessionId,
|
|
456467
|
-
uuid: `error-turn-start-cancel-${
|
|
456816
|
+
uuid: `error-turn-start-cancel-${randomUUID41()}`
|
|
456468
456817
|
};
|
|
456469
456818
|
writeWireMessage(errorMsg);
|
|
456470
456819
|
const resultMsg = {
|
|
@@ -456479,7 +456828,7 @@ function writeBidirectionalTurnStartCancellation(options) {
|
|
|
456479
456828
|
conversation_id: options.conversationId,
|
|
456480
456829
|
run_ids: [],
|
|
456481
456830
|
usage: null,
|
|
456482
|
-
uuid: `result-turn-start-cancel-${
|
|
456831
|
+
uuid: `result-turn-start-cancel-${randomUUID41()}`,
|
|
456483
456832
|
stop_reason: "cancelled"
|
|
456484
456833
|
};
|
|
456485
456834
|
writeWireMessage(resultMsg);
|
|
@@ -457287,7 +457636,7 @@ Current session AGENT_ID=${process.env.AGENT_ID}; --backend local switches to a
|
|
|
457287
457636
|
const approvalInput = {
|
|
457288
457637
|
type: "approval",
|
|
457289
457638
|
approvals: denialResults,
|
|
457290
|
-
otid:
|
|
457639
|
+
otid: randomUUID41()
|
|
457291
457640
|
};
|
|
457292
457641
|
const approvalMessages = [approvalInput];
|
|
457293
457642
|
{
|
|
@@ -457300,7 +457649,7 @@ Current session AGENT_ID=${process.env.AGENT_ID}; --backend local switches to a
|
|
|
457300
457649
|
type: "text",
|
|
457301
457650
|
text: sc.content
|
|
457302
457651
|
})),
|
|
457303
|
-
otid:
|
|
457652
|
+
otid: randomUUID41()
|
|
457304
457653
|
});
|
|
457305
457654
|
}
|
|
457306
457655
|
}
|
|
@@ -457333,7 +457682,7 @@ Current session AGENT_ID=${process.env.AGENT_ID}; --backend local switches to a
|
|
|
457333
457682
|
message: `Failed to resolve pending approvals on resume: ${approvalError instanceof Error ? approvalError.message : String(approvalError)}`,
|
|
457334
457683
|
stop_reason: "error",
|
|
457335
457684
|
session_id: sessionId,
|
|
457336
|
-
uuid: `error-pre-loop-approval-${
|
|
457685
|
+
uuid: `error-pre-loop-approval-${randomUUID41()}`
|
|
457337
457686
|
};
|
|
457338
457687
|
writeWireMessage(errorMsg);
|
|
457339
457688
|
} else {
|
|
@@ -457416,7 +457765,7 @@ ${SYSTEM_REMINDER_CLOSE}
|
|
|
457416
457765
|
content: contentParts,
|
|
457417
457766
|
backend: backend3,
|
|
457418
457767
|
onMessage: outputFormat === "stream-json" ? (message) => {
|
|
457419
|
-
const uuid5 = Reflect.get(message, "otid") ?? Reflect.get(message, "id") ??
|
|
457768
|
+
const uuid5 = Reflect.get(message, "otid") ?? Reflect.get(message, "id") ?? randomUUID41();
|
|
457420
457769
|
writeWireMessage(includePartialMessages ? {
|
|
457421
457770
|
type: "stream_event",
|
|
457422
457771
|
event: message,
|
|
@@ -457489,7 +457838,7 @@ ${SYSTEM_REMINDER_CLOSE}
|
|
|
457489
457838
|
{
|
|
457490
457839
|
role: "user",
|
|
457491
457840
|
content: contentParts,
|
|
457492
|
-
otid:
|
|
457841
|
+
otid: randomUUID41()
|
|
457493
457842
|
}
|
|
457494
457843
|
];
|
|
457495
457844
|
const recoveredApprovalResults = queuedRecoveredApprovalResults ?? [];
|
|
@@ -457498,7 +457847,7 @@ ${SYSTEM_REMINDER_CLOSE}
|
|
|
457498
457847
|
{
|
|
457499
457848
|
type: "approval",
|
|
457500
457849
|
approvals: recoveredApprovalResults,
|
|
457501
|
-
otid:
|
|
457850
|
+
otid: randomUUID41()
|
|
457502
457851
|
},
|
|
457503
457852
|
...currentInput
|
|
457504
457853
|
];
|
|
@@ -457545,7 +457894,7 @@ ${SYSTEM_REMINDER_CLOSE}
|
|
|
457545
457894
|
message: `Maximum turns limit reached (${buffers.usage.stepCount}/${maxTurns} steps)`,
|
|
457546
457895
|
stop_reason: "max_steps",
|
|
457547
457896
|
session_id: sessionId,
|
|
457548
|
-
uuid: `error-max-turns-${
|
|
457897
|
+
uuid: `error-max-turns-${randomUUID41()}`
|
|
457549
457898
|
};
|
|
457550
457899
|
await writeWireMessageAsync(errorMsg);
|
|
457551
457900
|
} else {
|
|
@@ -457563,7 +457912,7 @@ ${SYSTEM_REMINDER_CLOSE}
|
|
|
457563
457912
|
message: "Interrupted by SIGINT",
|
|
457564
457913
|
stop_reason: "cancelled",
|
|
457565
457914
|
session_id: sessionId,
|
|
457566
|
-
uuid: `error-interrupted-${
|
|
457915
|
+
uuid: `error-interrupted-${randomUUID41()}`
|
|
457567
457916
|
};
|
|
457568
457917
|
await writeWireMessageAsync(errorMsg);
|
|
457569
457918
|
} else {
|
|
@@ -457592,7 +457941,7 @@ ${SYSTEM_REMINDER_CLOSE}
|
|
|
457592
457941
|
type: "text",
|
|
457593
457942
|
text: sc.content
|
|
457594
457943
|
})),
|
|
457595
|
-
otid:
|
|
457944
|
+
otid: randomUUID41()
|
|
457596
457945
|
}
|
|
457597
457946
|
];
|
|
457598
457947
|
}
|
|
@@ -457637,7 +457986,7 @@ ${SYSTEM_REMINDER_CLOSE}
|
|
|
457637
457986
|
recovery_type: "approval_pending",
|
|
457638
457987
|
message: "Detected pending approval conflict on send; resolving before retry",
|
|
457639
457988
|
session_id: sessionId,
|
|
457640
|
-
uuid: `recovery-pre-stream-${
|
|
457989
|
+
uuid: `recovery-pre-stream-${randomUUID41()}`
|
|
457641
457990
|
};
|
|
457642
457991
|
writeWireMessage(recoveryMsg);
|
|
457643
457992
|
} else {
|
|
@@ -457670,7 +458019,7 @@ ${SYSTEM_REMINDER_CLOSE}
|
|
|
457670
458019
|
max_attempts: CONVERSATION_BUSY_MAX_RETRIES,
|
|
457671
458020
|
delay_ms: retryDelayMs,
|
|
457672
458021
|
session_id: sessionId,
|
|
457673
|
-
uuid: `retry-conversation-busy-${
|
|
458022
|
+
uuid: `retry-conversation-busy-${randomUUID41()}`
|
|
457674
458023
|
};
|
|
457675
458024
|
writeWireMessage(retryMsg);
|
|
457676
458025
|
} else {
|
|
@@ -457698,7 +458047,7 @@ ${SYSTEM_REMINDER_CLOSE}
|
|
|
457698
458047
|
max_attempts: LLM_API_ERROR_MAX_RETRIES2,
|
|
457699
458048
|
delay_ms: delayMs,
|
|
457700
458049
|
session_id: sessionId,
|
|
457701
|
-
uuid: `retry-pre-stream-${
|
|
458050
|
+
uuid: `retry-pre-stream-${randomUUID41()}`
|
|
457702
458051
|
};
|
|
457703
458052
|
writeWireMessage(retryMsg);
|
|
457704
458053
|
} else {
|
|
@@ -457724,7 +458073,7 @@ ${SYSTEM_REMINDER_CLOSE}
|
|
|
457724
458073
|
stop_reason: "error",
|
|
457725
458074
|
run_id: errorInfo.run_id,
|
|
457726
458075
|
session_id: sessionId,
|
|
457727
|
-
uuid:
|
|
458076
|
+
uuid: randomUUID41(),
|
|
457728
458077
|
...errorInfo.error_type && errorInfo.run_id && {
|
|
457729
458078
|
api_error: {
|
|
457730
458079
|
message_type: "error_message",
|
|
@@ -457746,7 +458095,7 @@ ${SYSTEM_REMINDER_CLOSE}
|
|
|
457746
458095
|
message: "Detected pending approval conflict; auto-denying stale approval and retrying",
|
|
457747
458096
|
run_id: recoveryRunId ?? undefined,
|
|
457748
458097
|
session_id: sessionId,
|
|
457749
|
-
uuid: `recovery-${recoveryRunId ||
|
|
458098
|
+
uuid: `recovery-${recoveryRunId || randomUUID41()}`
|
|
457750
458099
|
};
|
|
457751
458100
|
writeWireMessage(recoveryMsg);
|
|
457752
458101
|
approvalPendingRecovery = true;
|
|
@@ -457764,7 +458113,7 @@ ${SYSTEM_REMINDER_CLOSE}
|
|
|
457764
458113
|
type: "stream_event",
|
|
457765
458114
|
event: chunk2,
|
|
457766
458115
|
session_id: sessionId,
|
|
457767
|
-
uuid: uuid5 ||
|
|
458116
|
+
uuid: uuid5 || randomUUID41()
|
|
457768
458117
|
};
|
|
457769
458118
|
writeWireMessage(streamEvent);
|
|
457770
458119
|
} else {
|
|
@@ -457772,7 +458121,7 @@ ${SYSTEM_REMINDER_CLOSE}
|
|
|
457772
458121
|
type: "message",
|
|
457773
458122
|
...chunk2,
|
|
457774
458123
|
session_id: sessionId,
|
|
457775
|
-
uuid: uuid5 ||
|
|
458124
|
+
uuid: uuid5 || randomUUID41()
|
|
457776
458125
|
};
|
|
457777
458126
|
writeWireMessage(msg);
|
|
457778
458127
|
}
|
|
@@ -457817,7 +458166,7 @@ ${SYSTEM_REMINDER_CLOSE}
|
|
|
457817
458166
|
{
|
|
457818
458167
|
role: "user",
|
|
457819
458168
|
content: continueMessage,
|
|
457820
|
-
otid:
|
|
458169
|
+
otid: randomUUID41()
|
|
457821
458170
|
}
|
|
457822
458171
|
];
|
|
457823
458172
|
const continueTurnStartEmission = await emitHeadlessTurnStart({
|
|
@@ -457889,7 +458238,7 @@ ${SYSTEM_REMINDER_CLOSE}
|
|
|
457889
458238
|
const approvalInputWithOtid = {
|
|
457890
458239
|
type: "approval",
|
|
457891
458240
|
approvals: executedResults,
|
|
457892
|
-
otid:
|
|
458241
|
+
otid: randomUUID41()
|
|
457893
458242
|
};
|
|
457894
458243
|
currentInput = [approvalInputWithOtid];
|
|
457895
458244
|
continue;
|
|
@@ -457925,7 +458274,7 @@ ${SYSTEM_REMINDER_CLOSE}
|
|
|
457925
458274
|
delay_ms: 0,
|
|
457926
458275
|
run_id: lastRunId ?? undefined,
|
|
457927
458276
|
session_id: sessionId,
|
|
457928
|
-
uuid: `retry-${lastRunId ||
|
|
458277
|
+
uuid: `retry-${lastRunId || randomUUID41()}`
|
|
457929
458278
|
};
|
|
457930
458279
|
writeWireMessage(retryMsg);
|
|
457931
458280
|
} else {
|
|
@@ -457953,7 +458302,7 @@ ${SYSTEM_REMINDER_CLOSE}
|
|
|
457953
458302
|
delay_ms: delayMs,
|
|
457954
458303
|
run_id: lastRunId ?? undefined,
|
|
457955
458304
|
session_id: sessionId,
|
|
457956
|
-
uuid: `retry-${lastRunId ||
|
|
458305
|
+
uuid: `retry-${lastRunId || randomUUID41()}`
|
|
457957
458306
|
};
|
|
457958
458307
|
writeWireMessage(retryMsg);
|
|
457959
458308
|
} else {
|
|
@@ -457974,7 +458323,7 @@ ${SYSTEM_REMINDER_CLOSE}
|
|
|
457974
458323
|
message: "Tool call ID mismatch; fetching actual pending approvals and resyncing",
|
|
457975
458324
|
run_id: lastRunId ?? undefined,
|
|
457976
458325
|
session_id: sessionId,
|
|
457977
|
-
uuid: `recovery-${lastRunId ||
|
|
458326
|
+
uuid: `recovery-${lastRunId || randomUUID41()}`
|
|
457978
458327
|
};
|
|
457979
458328
|
writeWireMessage(recoveryMsg);
|
|
457980
458329
|
} else {
|
|
@@ -457991,7 +458340,7 @@ ${SYSTEM_REMINDER_CLOSE}
|
|
|
457991
458340
|
stop_reason: stopReason,
|
|
457992
458341
|
run_id: lastRunId ?? undefined,
|
|
457993
458342
|
session_id: sessionId,
|
|
457994
|
-
uuid: `error-${lastRunId ||
|
|
458343
|
+
uuid: `error-${lastRunId || randomUUID41()}`
|
|
457995
458344
|
};
|
|
457996
458345
|
await writeWireMessageAsync(errorMsg);
|
|
457997
458346
|
} else {
|
|
@@ -458031,9 +458380,9 @@ ${SYSTEM_REMINDER_CLOSE}
|
|
|
458031
458380
|
emptyResponseRetries = attempt2;
|
|
458032
458381
|
if (attempt2 >= EMPTY_RESPONSE_MAX_RETRIES2) {
|
|
458033
458382
|
const nudgeMessage = {
|
|
458034
|
-
role: "
|
|
458383
|
+
role: "user",
|
|
458035
458384
|
content: `<system-reminder>The previous response was empty. Please provide a response with either text content or a tool call.</system-reminder>`,
|
|
458036
|
-
otid:
|
|
458385
|
+
otid: randomUUID41()
|
|
458037
458386
|
};
|
|
458038
458387
|
currentInput = [...currentInput, nudgeMessage];
|
|
458039
458388
|
}
|
|
@@ -458046,7 +458395,7 @@ ${SYSTEM_REMINDER_CLOSE}
|
|
|
458046
458395
|
delay_ms: delayMs,
|
|
458047
458396
|
run_id: lastRunId ?? undefined,
|
|
458048
458397
|
session_id: sessionId,
|
|
458049
|
-
uuid: `retry-empty-${lastRunId ||
|
|
458398
|
+
uuid: `retry-empty-${lastRunId || randomUUID41()}`
|
|
458050
458399
|
};
|
|
458051
458400
|
writeWireMessage(retryMsg);
|
|
458052
458401
|
} else {
|
|
@@ -458073,7 +458422,7 @@ ${SYSTEM_REMINDER_CLOSE}
|
|
|
458073
458422
|
delay_ms: delayMs,
|
|
458074
458423
|
run_id: lastRunId ?? undefined,
|
|
458075
458424
|
session_id: sessionId,
|
|
458076
|
-
uuid: `retry-${lastRunId ||
|
|
458425
|
+
uuid: `retry-${lastRunId || randomUUID41()}`
|
|
458077
458426
|
};
|
|
458078
458427
|
writeWireMessage(retryMsg);
|
|
458079
458428
|
} else {
|
|
@@ -458103,7 +458452,7 @@ ${SYSTEM_REMINDER_CLOSE}
|
|
|
458103
458452
|
delay_ms: delayMs,
|
|
458104
458453
|
run_id: lastRunId ?? undefined,
|
|
458105
458454
|
session_id: sessionId,
|
|
458106
|
-
uuid: `retry-${lastRunId ||
|
|
458455
|
+
uuid: `retry-${lastRunId || randomUUID41()}`
|
|
458107
458456
|
};
|
|
458108
458457
|
writeWireMessage(retryMsg);
|
|
458109
458458
|
} else {
|
|
@@ -458152,7 +458501,7 @@ ${SYSTEM_REMINDER_CLOSE}
|
|
|
458152
458501
|
stop_reason: stopReason,
|
|
458153
458502
|
run_id: lastRunId ?? undefined,
|
|
458154
458503
|
session_id: sessionId,
|
|
458155
|
-
uuid: `error-${lastRunId ||
|
|
458504
|
+
uuid: `error-${lastRunId || randomUUID41()}`
|
|
458156
458505
|
};
|
|
458157
458506
|
await writeWireMessageAsync(errorMsg);
|
|
458158
458507
|
} else {
|
|
@@ -458171,7 +458520,7 @@ ${SYSTEM_REMINDER_CLOSE}
|
|
|
458171
458520
|
stop_reason: "error",
|
|
458172
458521
|
run_id: lastKnownRunId ?? undefined,
|
|
458173
458522
|
session_id: sessionId,
|
|
458174
|
-
uuid: `error-${lastKnownRunId ||
|
|
458523
|
+
uuid: `error-${lastKnownRunId || randomUUID41()}`
|
|
458175
458524
|
};
|
|
458176
458525
|
await writeWireMessageAsync(errorMsg);
|
|
458177
458526
|
} else {
|
|
@@ -458368,7 +458717,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
|
|
|
458368
458717
|
const approvalInput = {
|
|
458369
458718
|
type: "approval",
|
|
458370
458719
|
approvals: denialResults,
|
|
458371
|
-
otid:
|
|
458720
|
+
otid: randomUUID41()
|
|
458372
458721
|
};
|
|
458373
458722
|
const approvalMessages = [approvalInput];
|
|
458374
458723
|
{
|
|
@@ -458381,7 +458730,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
|
|
|
458381
458730
|
type: "text",
|
|
458382
458731
|
text: sc.content
|
|
458383
458732
|
})),
|
|
458384
|
-
otid:
|
|
458733
|
+
otid: randomUUID41()
|
|
458385
458734
|
});
|
|
458386
458735
|
}
|
|
458387
458736
|
}
|
|
@@ -458439,7 +458788,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
|
|
|
458439
458788
|
reason,
|
|
458440
458789
|
cleared_count: clearedCount,
|
|
458441
458790
|
session_id: sessionId,
|
|
458442
|
-
uuid: `q-clr-${
|
|
458791
|
+
uuid: `q-clr-${randomUUID41()}`
|
|
458443
458792
|
})
|
|
458444
458793
|
}
|
|
458445
458794
|
});
|
|
@@ -458469,7 +458818,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
|
|
|
458469
458818
|
reason: "runtime_busy",
|
|
458470
458819
|
queue_len: Math.max(1, queueLen),
|
|
458471
458820
|
session_id: sessionId,
|
|
458472
|
-
uuid: `q-blk-${
|
|
458821
|
+
uuid: `q-blk-${randomUUID41()}`
|
|
458473
458822
|
});
|
|
458474
458823
|
}
|
|
458475
458824
|
function enqueueForTracking(input) {
|
|
@@ -458541,7 +458890,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
|
|
|
458541
458890
|
request_id: interruptRequestId
|
|
458542
458891
|
},
|
|
458543
458892
|
session_id: sessionId,
|
|
458544
|
-
uuid:
|
|
458893
|
+
uuid: randomUUID41()
|
|
458545
458894
|
};
|
|
458546
458895
|
writeWireMessage(interruptResponse);
|
|
458547
458896
|
return;
|
|
@@ -458644,7 +458993,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
|
|
|
458644
458993
|
const approvalInput = {
|
|
458645
458994
|
type: "approval",
|
|
458646
458995
|
approvals: denialResults,
|
|
458647
|
-
otid:
|
|
458996
|
+
otid: randomUUID41()
|
|
458648
458997
|
};
|
|
458649
458998
|
const approvalStream = await sendScopedApprovalMessages({
|
|
458650
458999
|
agentId: agent.id,
|
|
@@ -458683,7 +459032,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
|
|
|
458683
459032
|
message: "Invalid JSON input",
|
|
458684
459033
|
stop_reason: "error",
|
|
458685
459034
|
session_id: sessionId,
|
|
458686
|
-
uuid:
|
|
459035
|
+
uuid: randomUUID41()
|
|
458687
459036
|
};
|
|
458688
459037
|
writeWireMessage(errorMsg2);
|
|
458689
459038
|
continue;
|
|
@@ -458709,7 +459058,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
|
|
|
458709
459058
|
}
|
|
458710
459059
|
},
|
|
458711
459060
|
session_id: sessionId,
|
|
458712
|
-
uuid:
|
|
459061
|
+
uuid: randomUUID41()
|
|
458713
459062
|
};
|
|
458714
459063
|
writeWireMessage(initResponse);
|
|
458715
459064
|
} else if (subtype === "interrupt") {
|
|
@@ -458726,7 +459075,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
|
|
|
458726
459075
|
request_id: requestId ?? ""
|
|
458727
459076
|
},
|
|
458728
459077
|
session_id: sessionId,
|
|
458729
|
-
uuid:
|
|
459078
|
+
uuid: randomUUID41()
|
|
458730
459079
|
};
|
|
458731
459080
|
writeWireMessage(interruptResponse);
|
|
458732
459081
|
} else if (subtype === "register_external_tools") {
|
|
@@ -458774,7 +459123,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
|
|
|
458774
459123
|
response: { registered: tools.length }
|
|
458775
459124
|
},
|
|
458776
459125
|
session_id: sessionId,
|
|
458777
|
-
uuid:
|
|
459126
|
+
uuid: randomUUID41()
|
|
458778
459127
|
};
|
|
458779
459128
|
writeWireMessage(registerResponse);
|
|
458780
459129
|
} else if (subtype === "bootstrap_session_state") {
|
|
@@ -458830,7 +459179,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
|
|
|
458830
459179
|
response: recovery
|
|
458831
459180
|
},
|
|
458832
459181
|
session_id: sessionId,
|
|
458833
|
-
uuid:
|
|
459182
|
+
uuid: randomUUID41()
|
|
458834
459183
|
};
|
|
458835
459184
|
writeWireMessage(recoveryResponse);
|
|
458836
459185
|
} catch (error5) {
|
|
@@ -458842,7 +459191,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
|
|
|
458842
459191
|
error: error5 instanceof Error ? error5.message : String(error5)
|
|
458843
459192
|
},
|
|
458844
459193
|
session_id: sessionId,
|
|
458845
|
-
uuid:
|
|
459194
|
+
uuid: randomUUID41()
|
|
458846
459195
|
};
|
|
458847
459196
|
writeWireMessage(recoveryError);
|
|
458848
459197
|
}
|
|
@@ -458855,7 +459204,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
|
|
|
458855
459204
|
error: `Unknown control request subtype: ${subtype}`
|
|
458856
459205
|
},
|
|
458857
459206
|
session_id: sessionId,
|
|
458858
|
-
uuid:
|
|
459207
|
+
uuid: randomUUID41()
|
|
458859
459208
|
};
|
|
458860
459209
|
writeWireMessage(errorResponse);
|
|
458861
459210
|
}
|
|
@@ -458911,7 +459260,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
|
|
|
458911
459260
|
try {
|
|
458912
459261
|
const buffers = createBuffers(agent.id);
|
|
458913
459262
|
const startTime = performance.now();
|
|
458914
|
-
const userOtid =
|
|
459263
|
+
const userOtid = randomUUID41();
|
|
458915
459264
|
const userTranscriptText = extractTelemetryInputText(userContent);
|
|
458916
459265
|
if (userTranscriptText.length > 0) {
|
|
458917
459266
|
const userLineId = `user-${userOtid}`;
|
|
@@ -458976,7 +459325,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
|
|
|
458976
459325
|
currentInput.unshift({
|
|
458977
459326
|
role: "user",
|
|
458978
459327
|
content: INTERRUPT_RECOVERY_ALERT,
|
|
458979
|
-
otid:
|
|
459328
|
+
otid: randomUUID41()
|
|
458980
459329
|
});
|
|
458981
459330
|
try {
|
|
458982
459331
|
await resolveAllPendingApprovals();
|
|
@@ -459038,7 +459387,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
|
|
|
459038
459387
|
recovery_type: "approval_pending",
|
|
459039
459388
|
message: "Detected pending approval conflict on send; resolving before retry",
|
|
459040
459389
|
session_id: sessionId,
|
|
459041
|
-
uuid: `recovery-bidir-${
|
|
459390
|
+
uuid: `recovery-bidir-${randomUUID41()}`
|
|
459042
459391
|
};
|
|
459043
459392
|
writeWireMessage(recoveryMsg);
|
|
459044
459393
|
await resolveAllPendingApprovals();
|
|
@@ -459061,7 +459410,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
|
|
|
459061
459410
|
max_attempts: LLM_API_ERROR_MAX_RETRIES2,
|
|
459062
459411
|
delay_ms: delayMs,
|
|
459063
459412
|
session_id: sessionId,
|
|
459064
|
-
uuid: `retry-bidir-${
|
|
459413
|
+
uuid: `retry-bidir-${randomUUID41()}`
|
|
459065
459414
|
};
|
|
459066
459415
|
writeWireMessage(retryMsg);
|
|
459067
459416
|
await new Promise((resolve40) => setTimeout(resolve40, delayMs));
|
|
@@ -459083,7 +459432,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
|
|
|
459083
459432
|
stop_reason: "error",
|
|
459084
459433
|
run_id: errorInfo.run_id,
|
|
459085
459434
|
session_id: sessionId,
|
|
459086
|
-
uuid:
|
|
459435
|
+
uuid: randomUUID41(),
|
|
459087
459436
|
...errorInfo.error_type && errorInfo.run_id && {
|
|
459088
459437
|
api_error: {
|
|
459089
459438
|
message_type: "error_message",
|
|
@@ -459111,7 +459460,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
|
|
|
459111
459460
|
type: "stream_event",
|
|
459112
459461
|
event: chunk2,
|
|
459113
459462
|
session_id: sessionId,
|
|
459114
|
-
uuid: uuid5 ||
|
|
459463
|
+
uuid: uuid5 || randomUUID41()
|
|
459115
459464
|
};
|
|
459116
459465
|
writeWireMessage(streamEvent);
|
|
459117
459466
|
} else {
|
|
@@ -459119,7 +459468,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
|
|
|
459119
459468
|
type: "message",
|
|
459120
459469
|
...chunk2,
|
|
459121
459470
|
session_id: sessionId,
|
|
459122
|
-
uuid: uuid5 ||
|
|
459471
|
+
uuid: uuid5 || randomUUID41()
|
|
459123
459472
|
};
|
|
459124
459473
|
writeWireMessage(msg);
|
|
459125
459474
|
}
|
|
@@ -459191,7 +459540,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
|
|
|
459191
459540
|
const approvalInputWithOtid = {
|
|
459192
459541
|
type: "approval",
|
|
459193
459542
|
approvals: executedResults,
|
|
459194
|
-
otid:
|
|
459543
|
+
otid: randomUUID41()
|
|
459195
459544
|
};
|
|
459196
459545
|
currentInput = [approvalInputWithOtid];
|
|
459197
459546
|
continue;
|
|
@@ -459254,7 +459603,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
|
|
|
459254
459603
|
message: errorDetails,
|
|
459255
459604
|
stop_reason: "error",
|
|
459256
459605
|
session_id: sessionId,
|
|
459257
|
-
uuid:
|
|
459606
|
+
uuid: randomUUID41()
|
|
459258
459607
|
};
|
|
459259
459608
|
writeWireMessage(errorMsg2);
|
|
459260
459609
|
const errorResultMsg = {
|
|
@@ -459297,7 +459646,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
|
|
|
459297
459646
|
message: `Unknown message type: ${message.type}`,
|
|
459298
459647
|
stop_reason: "error",
|
|
459299
459648
|
session_id: sessionId,
|
|
459300
|
-
uuid:
|
|
459649
|
+
uuid: randomUUID41()
|
|
459301
459650
|
};
|
|
459302
459651
|
writeWireMessage(errorMsg);
|
|
459303
459652
|
}
|
|
@@ -459785,7 +460134,7 @@ function estimateTokens(text2) {
|
|
|
459785
460134
|
var BYTES_PER_TOKEN = 4;
|
|
459786
460135
|
|
|
459787
460136
|
// src/cli/helpers/window-title-config.ts
|
|
459788
|
-
import { homedir as
|
|
460137
|
+
import { homedir as homedir47 } from "node:os";
|
|
459789
460138
|
import { basename as basename28, resolve as resolve40 } from "node:path";
|
|
459790
460139
|
function isWindowTitleField(value) {
|
|
459791
460140
|
return WINDOW_TITLE_FIELDS.includes(value);
|
|
@@ -459955,7 +460304,7 @@ function formatDirectoryDisplay(directory) {
|
|
|
459955
460304
|
if (!directory)
|
|
459956
460305
|
return null;
|
|
459957
460306
|
const resolved = resolve40(directory);
|
|
459958
|
-
const home =
|
|
460307
|
+
const home = homedir47();
|
|
459959
460308
|
if (resolved === home)
|
|
459960
460309
|
return "~";
|
|
459961
460310
|
if (resolved.startsWith(`${home}/`)) {
|
|
@@ -460679,8 +461028,8 @@ var init_queued_message_parts = __esm(() => {
|
|
|
460679
461028
|
import { execFile as execFileCb5 } from "node:child_process";
|
|
460680
461029
|
import { existsSync as existsSync66 } from "node:fs";
|
|
460681
461030
|
import { appendFile as appendFile2, chmod, mkdir as mkdir17, writeFile as writeFile18 } from "node:fs/promises";
|
|
460682
|
-
import { homedir as
|
|
460683
|
-
import { join as
|
|
461031
|
+
import { homedir as homedir48 } from "node:os";
|
|
461032
|
+
import { join as join84 } from "node:path";
|
|
460684
461033
|
import { promisify as promisify16 } from "node:util";
|
|
460685
461034
|
function buildGitEnv(token2, askpassPath) {
|
|
460686
461035
|
return {
|
|
@@ -460716,7 +461065,7 @@ async function runGit6(cwd2, args, env5) {
|
|
|
460716
461065
|
}
|
|
460717
461066
|
}
|
|
460718
461067
|
async function writeGitAskpass(repoRoot) {
|
|
460719
|
-
const askpassPath =
|
|
461068
|
+
const askpassPath = join84(repoRoot, "hf-askpass.sh");
|
|
460720
461069
|
await writeFile18(askpassPath, [
|
|
460721
461070
|
"#!/bin/sh",
|
|
460722
461071
|
'case "$1" in',
|
|
@@ -460731,7 +461080,7 @@ async function writeGitAskpass(repoRoot) {
|
|
|
460731
461080
|
}
|
|
460732
461081
|
async function prepareHfRepo(env5) {
|
|
460733
461082
|
await mkdir17(HF_CACHE_ROOT, { recursive: true });
|
|
460734
|
-
if (!existsSync66(
|
|
461083
|
+
if (!existsSync66(join84(HF_REPO_DIR, ".git"))) {
|
|
460735
461084
|
await runGit6(HF_CACHE_ROOT, ["clone", "--depth", "1", HF_REPO_URL, HF_REPO_DIR], env5);
|
|
460736
461085
|
return HF_REPO_DIR;
|
|
460737
461086
|
}
|
|
@@ -460766,8 +461115,8 @@ async function maybeUploadReflectionArenaChoiceToHf(row) {
|
|
|
460766
461115
|
const env5 = buildGitEnv(token2, askpassPath);
|
|
460767
461116
|
try {
|
|
460768
461117
|
const repoDir = await prepareHfRepo(env5);
|
|
460769
|
-
await mkdir17(
|
|
460770
|
-
await appendFile2(
|
|
461118
|
+
await mkdir17(join84(repoDir, "data"), { recursive: true });
|
|
461119
|
+
await appendFile2(join84(repoDir, HF_DATASET_PATH), `${JSON.stringify(row)}
|
|
460771
461120
|
`, {
|
|
460772
461121
|
encoding: "utf-8"
|
|
460773
461122
|
});
|
|
@@ -460795,16 +461144,16 @@ var init_reflection_arena_hf_upload = __esm(() => {
|
|
|
460795
461144
|
init_version();
|
|
460796
461145
|
execFile18 = promisify16(execFileCb5);
|
|
460797
461146
|
HF_REPO_URL = `https://huggingface.co/datasets/${HF_REPO_ID}`;
|
|
460798
|
-
HF_CACHE_ROOT =
|
|
460799
|
-
HF_REPO_DIR =
|
|
461147
|
+
HF_CACHE_ROOT = join84(homedir48(), ".letta", "reflection-arena", "hf-upload");
|
|
461148
|
+
HF_REPO_DIR = join84(HF_CACHE_ROOT, "repo");
|
|
460800
461149
|
});
|
|
460801
461150
|
|
|
460802
461151
|
// src/cli/helpers/reflection-arena.ts
|
|
460803
461152
|
import { execFile as execFileCb6 } from "node:child_process";
|
|
460804
|
-
import { randomInt as randomInt2, randomUUID as
|
|
461153
|
+
import { randomInt as randomInt2, randomUUID as randomUUID42 } from "node:crypto";
|
|
460805
461154
|
import { appendFile as appendFile3, mkdir as mkdir18, readFile as readFile30, writeFile as writeFile19 } from "node:fs/promises";
|
|
460806
|
-
import { homedir as
|
|
460807
|
-
import { join as
|
|
461155
|
+
import { homedir as homedir49 } from "node:os";
|
|
461156
|
+
import { join as join85 } from "node:path";
|
|
460808
461157
|
import { promisify as promisify17 } from "node:util";
|
|
460809
461158
|
function sampleReflectionArenaComparisonModel(excludedModels = []) {
|
|
460810
461159
|
const excluded = new Set(excludedModels);
|
|
@@ -460853,16 +461202,16 @@ function candidateIsConfirmedNoOp(candidate) {
|
|
|
460853
461202
|
return candidate.result?.success === true && candidate.result.memoryNoChanges === true && candidate.result.memoryHead === candidate.worktree.baseHead;
|
|
460854
461203
|
}
|
|
460855
461204
|
function getReflectionArenaRoot() {
|
|
460856
|
-
return
|
|
461205
|
+
return join85(homedir49(), ".letta", "reflection-arena");
|
|
460857
461206
|
}
|
|
460858
461207
|
function getReflectionArenaRunsDir() {
|
|
460859
|
-
return
|
|
461208
|
+
return join85(getReflectionArenaRoot(), "runs");
|
|
460860
461209
|
}
|
|
460861
461210
|
function getReflectionArenaChoiceLogPath() {
|
|
460862
|
-
return
|
|
461211
|
+
return join85(getReflectionArenaRoot(), "choices.jsonl");
|
|
460863
461212
|
}
|
|
460864
461213
|
function getReflectionArenaRunPath(runId) {
|
|
460865
|
-
return
|
|
461214
|
+
return join85(getReflectionArenaRunsDir(), `${runId}.json`);
|
|
460866
461215
|
}
|
|
460867
461216
|
async function saveReflectionArenaRun(run) {
|
|
460868
461217
|
await mkdir18(getReflectionArenaRunsDir(), { recursive: true });
|
|
@@ -461163,7 +461512,7 @@ async function startReflectionArenaRun(options) {
|
|
|
461163
461512
|
}
|
|
461164
461513
|
let releaseReservation = true;
|
|
461165
461514
|
try {
|
|
461166
|
-
const runId =
|
|
461515
|
+
const runId = randomUUID42().slice(0, 8);
|
|
461167
461516
|
const labels = shuffledLabels();
|
|
461168
461517
|
const prepared = await Promise.all([
|
|
461169
461518
|
prepareReflectionMemoryWorktreeLaunch({
|
|
@@ -462019,12 +462368,12 @@ __export(exports_terminal_keybinding_installer, {
|
|
|
462019
462368
|
import {
|
|
462020
462369
|
copyFileSync as copyFileSync6,
|
|
462021
462370
|
existsSync as existsSync67,
|
|
462022
|
-
mkdirSync as
|
|
462023
|
-
readFileSync as
|
|
462024
|
-
writeFileSync as
|
|
462371
|
+
mkdirSync as mkdirSync46,
|
|
462372
|
+
readFileSync as readFileSync43,
|
|
462373
|
+
writeFileSync as writeFileSync36
|
|
462025
462374
|
} from "node:fs";
|
|
462026
|
-
import { homedir as
|
|
462027
|
-
import { dirname as dirname34, join as
|
|
462375
|
+
import { homedir as homedir50, platform as platform10 } from "node:os";
|
|
462376
|
+
import { dirname as dirname34, join as join86 } from "node:path";
|
|
462028
462377
|
function detectTerminalType() {
|
|
462029
462378
|
if (process.env.CURSOR_TRACE_ID || process.env.CURSOR_CHANNEL) {
|
|
462030
462379
|
return "cursor";
|
|
@@ -462056,16 +462405,16 @@ function getKeybindingsPath(terminal) {
|
|
|
462056
462405
|
}[terminal];
|
|
462057
462406
|
const os9 = platform10();
|
|
462058
462407
|
if (os9 === "darwin") {
|
|
462059
|
-
return
|
|
462408
|
+
return join86(homedir50(), "Library", "Application Support", appName, "User", "keybindings.json");
|
|
462060
462409
|
}
|
|
462061
462410
|
if (os9 === "win32") {
|
|
462062
462411
|
const appData = process.env.APPDATA;
|
|
462063
462412
|
if (!appData)
|
|
462064
462413
|
return null;
|
|
462065
|
-
return
|
|
462414
|
+
return join86(appData, appName, "User", "keybindings.json");
|
|
462066
462415
|
}
|
|
462067
462416
|
if (os9 === "linux") {
|
|
462068
|
-
return
|
|
462417
|
+
return join86(homedir50(), ".config", appName, "User", "keybindings.json");
|
|
462069
462418
|
}
|
|
462070
462419
|
return null;
|
|
462071
462420
|
}
|
|
@@ -462090,7 +462439,7 @@ function keybindingExists(keybindingsPath) {
|
|
|
462090
462439
|
if (!existsSync67(keybindingsPath))
|
|
462091
462440
|
return false;
|
|
462092
462441
|
try {
|
|
462093
|
-
const content =
|
|
462442
|
+
const content = readFileSync43(keybindingsPath, { encoding: "utf-8" });
|
|
462094
462443
|
const keybindings = parseKeybindings(content);
|
|
462095
462444
|
if (!keybindings)
|
|
462096
462445
|
return false;
|
|
@@ -462117,13 +462466,13 @@ function installKeybinding(keybindingsPath) {
|
|
|
462117
462466
|
}
|
|
462118
462467
|
const parentDir = dirname34(keybindingsPath);
|
|
462119
462468
|
if (!existsSync67(parentDir)) {
|
|
462120
|
-
|
|
462469
|
+
mkdirSync46(parentDir, { recursive: true });
|
|
462121
462470
|
}
|
|
462122
462471
|
let keybindings = [];
|
|
462123
462472
|
let backupPath = null;
|
|
462124
462473
|
if (existsSync67(keybindingsPath)) {
|
|
462125
462474
|
backupPath = createBackup(keybindingsPath);
|
|
462126
|
-
const content =
|
|
462475
|
+
const content = readFileSync43(keybindingsPath, { encoding: "utf-8" });
|
|
462127
462476
|
const parsed = parseKeybindings(content);
|
|
462128
462477
|
if (parsed === null) {
|
|
462129
462478
|
return {
|
|
@@ -462136,7 +462485,7 @@ function installKeybinding(keybindingsPath) {
|
|
|
462136
462485
|
keybindings.push(SHIFT_ENTER_KEYBINDING);
|
|
462137
462486
|
const newContent = `${JSON.stringify(keybindings, null, 2)}
|
|
462138
462487
|
`;
|
|
462139
|
-
|
|
462488
|
+
writeFileSync36(keybindingsPath, newContent, { encoding: "utf-8" });
|
|
462140
462489
|
return {
|
|
462141
462490
|
success: true,
|
|
462142
462491
|
backupPath: backupPath ?? undefined
|
|
@@ -462154,7 +462503,7 @@ function removeKeybinding(keybindingsPath) {
|
|
|
462154
462503
|
if (!existsSync67(keybindingsPath)) {
|
|
462155
462504
|
return { success: true };
|
|
462156
462505
|
}
|
|
462157
|
-
const content =
|
|
462506
|
+
const content = readFileSync43(keybindingsPath, { encoding: "utf-8" });
|
|
462158
462507
|
const keybindings = parseKeybindings(content);
|
|
462159
462508
|
if (!keybindings) {
|
|
462160
462509
|
return {
|
|
@@ -462165,7 +462514,7 @@ function removeKeybinding(keybindingsPath) {
|
|
|
462165
462514
|
const filtered = keybindings.filter((kb) => !(kb.key?.toLowerCase() === "shift+enter" && kb.command === "workbench.action.terminal.sendSequence" && kb.when?.includes("terminalFocus")));
|
|
462166
462515
|
const newContent = `${JSON.stringify(filtered, null, 2)}
|
|
462167
462516
|
`;
|
|
462168
|
-
|
|
462517
|
+
writeFileSync36(keybindingsPath, newContent, { encoding: "utf-8" });
|
|
462169
462518
|
return { success: true };
|
|
462170
462519
|
} catch (error5) {
|
|
462171
462520
|
const message = error5 instanceof Error ? error5.message : String(error5);
|
|
@@ -462218,14 +462567,14 @@ function getWezTermConfigPath() {
|
|
|
462218
462567
|
}
|
|
462219
462568
|
const xdgConfig = process.env.XDG_CONFIG_HOME;
|
|
462220
462569
|
if (xdgConfig) {
|
|
462221
|
-
const xdgPath =
|
|
462570
|
+
const xdgPath = join86(xdgConfig, "wezterm", "wezterm.lua");
|
|
462222
462571
|
if (existsSync67(xdgPath))
|
|
462223
462572
|
return xdgPath;
|
|
462224
462573
|
}
|
|
462225
|
-
const configPath =
|
|
462574
|
+
const configPath = join86(homedir50(), ".config", "wezterm", "wezterm.lua");
|
|
462226
462575
|
if (existsSync67(configPath))
|
|
462227
462576
|
return configPath;
|
|
462228
|
-
return
|
|
462577
|
+
return join86(homedir50(), ".wezterm.lua");
|
|
462229
462578
|
}
|
|
462230
462579
|
function stripLuaCommentsFromLine(line, blockCommentEnd) {
|
|
462231
462580
|
let code2 = "";
|
|
@@ -462331,7 +462680,7 @@ function wezTermDeleteFixExists(configPath) {
|
|
|
462331
462680
|
if (!existsSync67(configPath))
|
|
462332
462681
|
return false;
|
|
462333
462682
|
try {
|
|
462334
|
-
const content =
|
|
462683
|
+
const content = readFileSync43(configPath, { encoding: "utf-8" });
|
|
462335
462684
|
return content.includes("Letta Code: Fix Delete key") || content.includes("key = 'Delete'") && content.includes("SendString") && content.includes("\\x1b[3~");
|
|
462336
462685
|
} catch {
|
|
462337
462686
|
return false;
|
|
@@ -462348,14 +462697,14 @@ function installWezTermDeleteFix() {
|
|
|
462348
462697
|
if (existsSync67(configPath)) {
|
|
462349
462698
|
backupPath = `${configPath}.letta-backup`;
|
|
462350
462699
|
copyFileSync6(configPath, backupPath);
|
|
462351
|
-
content =
|
|
462700
|
+
content = readFileSync43(configPath, { encoding: "utf-8" });
|
|
462352
462701
|
}
|
|
462353
462702
|
content = injectWezTermDeleteFix(content);
|
|
462354
462703
|
const parentDir = dirname34(configPath);
|
|
462355
462704
|
if (!existsSync67(parentDir)) {
|
|
462356
|
-
|
|
462705
|
+
mkdirSync46(parentDir, { recursive: true });
|
|
462357
462706
|
}
|
|
462358
|
-
|
|
462707
|
+
writeFileSync36(configPath, content, { encoding: "utf-8" });
|
|
462359
462708
|
return {
|
|
462360
462709
|
success: true,
|
|
462361
462710
|
backupPath: backupPath ?? undefined
|
|
@@ -462403,10 +462752,10 @@ __export(exports_settings2, {
|
|
|
462403
462752
|
loadProjectSettings: () => loadProjectSettings,
|
|
462404
462753
|
getSetting: () => getSetting
|
|
462405
462754
|
});
|
|
462406
|
-
import { homedir as
|
|
462407
|
-
import { join as
|
|
462755
|
+
import { homedir as homedir51 } from "node:os";
|
|
462756
|
+
import { join as join87 } from "node:path";
|
|
462408
462757
|
function getSettingsPath() {
|
|
462409
|
-
return
|
|
462758
|
+
return join87(homedir51(), ".letta", "settings.json");
|
|
462410
462759
|
}
|
|
462411
462760
|
async function loadSettings() {
|
|
462412
462761
|
const settingsPath = getSettingsPath();
|
|
@@ -462443,7 +462792,7 @@ async function getSetting(key2) {
|
|
|
462443
462792
|
return settings3[key2];
|
|
462444
462793
|
}
|
|
462445
462794
|
function getProjectSettingsPath() {
|
|
462446
|
-
return
|
|
462795
|
+
return join87(process.cwd(), ".letta", "settings.local.json");
|
|
462447
462796
|
}
|
|
462448
462797
|
async function loadProjectSettings() {
|
|
462449
462798
|
const settingsPath = getProjectSettingsPath();
|
|
@@ -462461,7 +462810,7 @@ async function loadProjectSettings() {
|
|
|
462461
462810
|
}
|
|
462462
462811
|
async function saveProjectSettings(settings3) {
|
|
462463
462812
|
const settingsPath = getProjectSettingsPath();
|
|
462464
|
-
const dirPath =
|
|
462813
|
+
const dirPath = join87(process.cwd(), ".letta");
|
|
462465
462814
|
try {
|
|
462466
462815
|
if (!exists(dirPath)) {
|
|
462467
462816
|
await mkdir(dirPath, { recursive: true });
|
|
@@ -468095,10 +468444,10 @@ var init_HelpDialog = __esm(async () => {
|
|
|
468095
468444
|
});
|
|
468096
468445
|
|
|
468097
468446
|
// src/hooks/writer.ts
|
|
468098
|
-
import { homedir as
|
|
468447
|
+
import { homedir as homedir52 } from "node:os";
|
|
468099
468448
|
import { resolve as resolve41 } from "node:path";
|
|
468100
468449
|
function isProjectSettingsPathCollidingWithGlobal2(workingDirectory) {
|
|
468101
|
-
const home = process.env.HOME ||
|
|
468450
|
+
const home = process.env.HOME || homedir52();
|
|
468102
468451
|
const globalSettingsPath = resolve41(home, ".letta", "settings.json");
|
|
468103
468452
|
const projectSettingsPath = resolve41(workingDirectory, ".letta", "settings.json");
|
|
468104
468453
|
return globalSettingsPath === projectSettingsPath;
|
|
@@ -473891,14 +474240,14 @@ var init_InputRich = __esm(async () => {
|
|
|
473891
474240
|
import { execFileSync as execFileSync7 } from "node:child_process";
|
|
473892
474241
|
import {
|
|
473893
474242
|
existsSync as existsSync68,
|
|
473894
|
-
mkdirSync as
|
|
474243
|
+
mkdirSync as mkdirSync47,
|
|
473895
474244
|
mkdtempSync as mkdtempSync6,
|
|
473896
|
-
readFileSync as
|
|
473897
|
-
rmSync as
|
|
473898
|
-
writeFileSync as
|
|
474245
|
+
readFileSync as readFileSync44,
|
|
474246
|
+
rmSync as rmSync19,
|
|
474247
|
+
writeFileSync as writeFileSync37
|
|
473899
474248
|
} from "node:fs";
|
|
473900
474249
|
import { tmpdir as tmpdir12 } from "node:os";
|
|
473901
|
-
import { dirname as dirname35, join as
|
|
474250
|
+
import { dirname as dirname35, join as join88 } from "node:path";
|
|
473902
474251
|
function runCommand(command, args, cwd2, input) {
|
|
473903
474252
|
try {
|
|
473904
474253
|
return execFileSync7(command, args, {
|
|
@@ -474119,8 +474468,8 @@ async function createLettaAgent(apiKey, name) {
|
|
|
474119
474468
|
return createMinimalAgent(apiKey, name);
|
|
474120
474469
|
}
|
|
474121
474470
|
function cloneRepoToTemp(repo) {
|
|
474122
|
-
const tempDir = mkdtempSync6(
|
|
474123
|
-
const repoDir =
|
|
474471
|
+
const tempDir = mkdtempSync6(join88(tmpdir12(), "letta-install-github-app-"));
|
|
474472
|
+
const repoDir = join88(tempDir, "repo");
|
|
474124
474473
|
runCommand("gh", ["repo", "clone", repo, repoDir, "--", "--depth=1"]);
|
|
474125
474474
|
return { tempDir, repoDir };
|
|
474126
474475
|
}
|
|
@@ -474131,19 +474480,19 @@ function runGit7(args, cwd2) {
|
|
|
474131
474480
|
return runCommand("git", args, cwd2);
|
|
474132
474481
|
}
|
|
474133
474482
|
function writeWorkflow(repoDir, workflowPath, content) {
|
|
474134
|
-
const absolutePath =
|
|
474483
|
+
const absolutePath = join88(repoDir, workflowPath);
|
|
474135
474484
|
if (!existsSync68(dirname35(absolutePath))) {
|
|
474136
|
-
|
|
474485
|
+
mkdirSync47(dirname35(absolutePath), { recursive: true });
|
|
474137
474486
|
}
|
|
474138
474487
|
const next = `${content.trimEnd()}
|
|
474139
474488
|
`;
|
|
474140
474489
|
if (existsSync68(absolutePath)) {
|
|
474141
|
-
const previous =
|
|
474490
|
+
const previous = readFileSync44(absolutePath, "utf8");
|
|
474142
474491
|
if (previous === next) {
|
|
474143
474492
|
return false;
|
|
474144
474493
|
}
|
|
474145
474494
|
}
|
|
474146
|
-
|
|
474495
|
+
writeFileSync37(absolutePath, next, "utf8");
|
|
474147
474496
|
return true;
|
|
474148
474497
|
}
|
|
474149
474498
|
function getDefaultBaseBranch(repoDir) {
|
|
@@ -474264,7 +474613,7 @@ async function installGithubApp(options) {
|
|
|
474264
474613
|
agentUrl: resolvedAgentId ? buildAgentReference(resolvedAgentId) : null
|
|
474265
474614
|
};
|
|
474266
474615
|
} finally {
|
|
474267
|
-
|
|
474616
|
+
rmSync19(tempDir, { recursive: true, force: true });
|
|
474268
474617
|
}
|
|
474269
474618
|
}
|
|
474270
474619
|
var DEFAULT_WORKFLOW_PATH = ".github/workflows/letta.yml", ALTERNATE_WORKFLOW_PATH = ".github/workflows/letta-code.yml";
|
|
@@ -478027,9 +478376,9 @@ __export(exports_generate_memory_viewer, {
|
|
|
478027
478376
|
generateAndOpenMemoryViewer: () => generateAndOpenMemoryViewer
|
|
478028
478377
|
});
|
|
478029
478378
|
import { execFile as execFileCb7 } from "node:child_process";
|
|
478030
|
-
import { chmodSync as chmodSync7, existsSync as existsSync69, mkdirSync as
|
|
478031
|
-
import { homedir as
|
|
478032
|
-
import { join as
|
|
478379
|
+
import { chmodSync as chmodSync7, existsSync as existsSync69, mkdirSync as mkdirSync48, writeFileSync as writeFileSync38 } from "node:fs";
|
|
478380
|
+
import { homedir as homedir53 } from "node:os";
|
|
478381
|
+
import { join as join89 } from "node:path";
|
|
478033
478382
|
import { promisify as promisify18 } from "node:util";
|
|
478034
478383
|
function messagesFromOverview(overview) {
|
|
478035
478384
|
return overview.messages?.map((message) => ({
|
|
@@ -478338,7 +478687,7 @@ ${m4.body}` : m4.subject;
|
|
|
478338
478687
|
async function generateAndOpenMemoryViewer(agentId, options) {
|
|
478339
478688
|
const memoryRoot = getScopedMemoryFilesystemRoot(agentId);
|
|
478340
478689
|
const repoDir = memoryRoot;
|
|
478341
|
-
if (!existsSync69(
|
|
478690
|
+
if (!existsSync69(join89(repoDir, ".git"))) {
|
|
478342
478691
|
throw new Error("Memory viewer requires memfs. Run /memfs enable first.");
|
|
478343
478692
|
}
|
|
478344
478693
|
const data = await collectMemoryData(agentId, repoDir, memoryRoot, options?.conversationId);
|
|
@@ -478349,13 +478698,13 @@ async function generateAndOpenMemoryViewer(agentId, options) {
|
|
|
478349
478698
|
const jsonPayload = JSON.stringify(data).replace(/</g, "\\u003c");
|
|
478350
478699
|
const html5 = memory_viewer_template_default.replace("<!--LETTA_DATA_PLACEHOLDER-->", () => jsonPayload);
|
|
478351
478700
|
if (!existsSync69(VIEWERS_DIR)) {
|
|
478352
|
-
|
|
478701
|
+
mkdirSync48(VIEWERS_DIR, { recursive: true, mode: 448 });
|
|
478353
478702
|
}
|
|
478354
478703
|
try {
|
|
478355
478704
|
chmodSync7(VIEWERS_DIR, 448);
|
|
478356
478705
|
} catch {}
|
|
478357
|
-
const filePath =
|
|
478358
|
-
|
|
478706
|
+
const filePath = join89(VIEWERS_DIR, `memory-${encodeURIComponent(agentId)}.html`);
|
|
478707
|
+
writeFileSync38(filePath, html5);
|
|
478359
478708
|
chmodSync7(filePath, 384);
|
|
478360
478709
|
const skipOpen = Boolean(process.env.TMUX) || Boolean(process.env.SSH_CONNECTION) || Boolean(process.env.SSH_TTY);
|
|
478361
478710
|
if (!skipOpen) {
|
|
@@ -478380,13 +478729,13 @@ var init_generate_memory_viewer = __esm(() => {
|
|
|
478380
478729
|
init_local_memory_context();
|
|
478381
478730
|
init_memory_viewer_template();
|
|
478382
478731
|
execFile20 = promisify18(execFileCb7);
|
|
478383
|
-
VIEWERS_DIR =
|
|
478732
|
+
VIEWERS_DIR = join89(homedir53(), ".letta", "viewers");
|
|
478384
478733
|
REFLECTION_PATTERN = /\(reflection\)|🔮|reflection:/i;
|
|
478385
478734
|
});
|
|
478386
478735
|
|
|
478387
478736
|
// src/cli/components/MemfsTreeViewer.tsx
|
|
478388
478737
|
import { existsSync as existsSync70 } from "node:fs";
|
|
478389
|
-
import { join as
|
|
478738
|
+
import { join as join90 } from "node:path";
|
|
478390
478739
|
function renderTreePrefix(node) {
|
|
478391
478740
|
let prefix = "";
|
|
478392
478741
|
for (let i4 = 0;i4 < node.depth; i4++) {
|
|
@@ -478415,7 +478764,7 @@ function MemfsTreeViewer({
|
|
|
478415
478764
|
const statusTimerRef = import_react88.useRef(null);
|
|
478416
478765
|
const memoryRoot = getScopedMemoryFilesystemRoot(agentId);
|
|
478417
478766
|
const memoryExists = existsSync70(memoryRoot);
|
|
478418
|
-
const hasGitRepo = import_react88.useMemo(() => existsSync70(
|
|
478767
|
+
const hasGitRepo = import_react88.useMemo(() => existsSync70(join90(memoryRoot, ".git")), [memoryRoot]);
|
|
478419
478768
|
function showStatus(msg, durationMs) {
|
|
478420
478769
|
if (statusTimerRef.current)
|
|
478421
478770
|
clearTimeout(statusTimerRef.current);
|
|
@@ -480791,11 +481140,11 @@ var init_PersonalitySelector = __esm(async () => {
|
|
|
480791
481140
|
|
|
480792
481141
|
// src/utils/aws-credentials.ts
|
|
480793
481142
|
import { readFile as readFile31 } from "node:fs/promises";
|
|
480794
|
-
import { homedir as
|
|
480795
|
-
import { join as
|
|
481143
|
+
import { homedir as homedir54 } from "node:os";
|
|
481144
|
+
import { join as join91 } from "node:path";
|
|
480796
481145
|
async function parseAwsCredentials() {
|
|
480797
|
-
const credentialsPath =
|
|
480798
|
-
const configPath =
|
|
481146
|
+
const credentialsPath = join91(homedir54(), ".aws", "credentials");
|
|
481147
|
+
const configPath = join91(homedir54(), ".aws", "config");
|
|
480799
481148
|
const profiles = new Map;
|
|
480800
481149
|
try {
|
|
480801
481150
|
const content = await readFile31(credentialsPath, "utf-8");
|
|
@@ -482374,8 +482723,8 @@ function SkillsDialog({ onClose, agentId }) {
|
|
|
482374
482723
|
try {
|
|
482375
482724
|
const { discoverSkills: discoverSkills2, SKILLS_DIR: SKILLS_DIR2 } = await Promise.resolve().then(() => (init_skills5(), exports_skills2));
|
|
482376
482725
|
const { getSkillsDirectory: getSkillsDirectory2, getSkillSources: getSkillSources2 } = await Promise.resolve().then(() => (init_context(), exports_context));
|
|
482377
|
-
const { join:
|
|
482378
|
-
const skillsDir = getSkillsDirectory2() ||
|
|
482726
|
+
const { join: join92 } = await import("node:path");
|
|
482727
|
+
const skillsDir = getSkillsDirectory2() || join92(process.cwd(), SKILLS_DIR2);
|
|
482379
482728
|
const result2 = await discoverSkills2(skillsDir, agentId, {
|
|
482380
482729
|
sources: getSkillSources2()
|
|
482381
482730
|
});
|
|
@@ -486586,12 +486935,12 @@ var init_ExitStats = __esm(async () => {
|
|
|
486586
486935
|
});
|
|
486587
486936
|
|
|
486588
486937
|
// src/cli/app/ids.ts
|
|
486589
|
-
import { randomUUID as
|
|
486938
|
+
import { randomUUID as randomUUID43 } from "node:crypto";
|
|
486590
486939
|
function uid(prefix) {
|
|
486591
486940
|
return `${prefix}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
|
|
486592
486941
|
}
|
|
486593
486942
|
function createClientOtid() {
|
|
486594
|
-
return
|
|
486943
|
+
return randomUUID43();
|
|
486595
486944
|
}
|
|
486596
486945
|
function appendOptimisticUserLine(buffers, text2, otid) {
|
|
486597
486946
|
if (!text2) {
|
|
@@ -501933,9 +502282,9 @@ __export(exports_generate_diff_viewer, {
|
|
|
501933
502282
|
generateAndOpenDiffViewer: () => generateAndOpenDiffViewer
|
|
501934
502283
|
});
|
|
501935
502284
|
import { execFile as execFileCb8 } from "node:child_process";
|
|
501936
|
-
import { chmodSync as chmodSync8, existsSync as existsSync71, mkdirSync as
|
|
501937
|
-
import { homedir as
|
|
501938
|
-
import { isAbsolute as isAbsolute31, join as
|
|
502285
|
+
import { chmodSync as chmodSync8, existsSync as existsSync71, mkdirSync as mkdirSync49, writeFileSync as writeFileSync39 } from "node:fs";
|
|
502286
|
+
import { homedir as homedir55 } from "node:os";
|
|
502287
|
+
import { isAbsolute as isAbsolute31, join as join92, resolve as resolve42 } from "node:path";
|
|
501939
502288
|
import { promisify as promisify19 } from "node:util";
|
|
501940
502289
|
async function runGit8(cwd2, args) {
|
|
501941
502290
|
try {
|
|
@@ -502155,13 +502504,13 @@ async function generateAndOpenDiffViewer(targetPath) {
|
|
|
502155
502504
|
const jsonPayload = JSON.stringify(payload).replace(/</g, "\\u003c");
|
|
502156
502505
|
const html5 = diff_viewer_template_default.replace("<!--LETTA_DIFF_DATA_PLACEHOLDER-->", () => jsonPayload);
|
|
502157
502506
|
if (!existsSync71(VIEWERS_DIR2)) {
|
|
502158
|
-
|
|
502507
|
+
mkdirSync49(VIEWERS_DIR2, { recursive: true, mode: 448 });
|
|
502159
502508
|
}
|
|
502160
502509
|
try {
|
|
502161
502510
|
chmodSync8(VIEWERS_DIR2, 448);
|
|
502162
502511
|
} catch {}
|
|
502163
|
-
const filePath =
|
|
502164
|
-
|
|
502512
|
+
const filePath = join92(VIEWERS_DIR2, `diff-${encodeURIComponent(worktreePath)}.html`);
|
|
502513
|
+
writeFileSync39(filePath, html5);
|
|
502165
502514
|
chmodSync8(filePath, 384);
|
|
502166
502515
|
const skipOpen = shouldSkipOpen();
|
|
502167
502516
|
if (!skipOpen) {
|
|
@@ -502231,7 +502580,7 @@ var init_generate_diff_viewer = __esm(() => {
|
|
|
502231
502580
|
init_ssr();
|
|
502232
502581
|
init_diff_viewer_template();
|
|
502233
502582
|
execFile21 = promisify19(execFileCb8);
|
|
502234
|
-
VIEWERS_DIR2 =
|
|
502583
|
+
VIEWERS_DIR2 = join92(homedir55(), ".letta", "viewers");
|
|
502235
502584
|
GIT_MAX_BUFFER = 50 * 1024 * 1024;
|
|
502236
502585
|
});
|
|
502237
502586
|
|
|
@@ -503480,7 +503829,7 @@ var init_notifications = __esm(() => {
|
|
|
503480
503829
|
});
|
|
503481
503830
|
|
|
503482
503831
|
// src/cli/app/use-approval-flow.ts
|
|
503483
|
-
import { randomUUID as
|
|
503832
|
+
import { randomUUID as randomUUID44 } from "node:crypto";
|
|
503484
503833
|
function useApprovalFlow(ctx) {
|
|
503485
503834
|
const {
|
|
503486
503835
|
abortControllerRef,
|
|
@@ -503992,7 +504341,7 @@ function useApprovalFlow(ctx) {
|
|
|
503992
504341
|
{
|
|
503993
504342
|
type: "approval",
|
|
503994
504343
|
approvals: allResults,
|
|
503995
|
-
otid:
|
|
504344
|
+
otid: randomUUID44()
|
|
503996
504345
|
}
|
|
503997
504346
|
]);
|
|
503998
504347
|
} catch (error5) {
|
|
@@ -504195,16 +504544,16 @@ __export(exports_shell_aliases, {
|
|
|
504195
504544
|
expandAliases: () => expandAliases,
|
|
504196
504545
|
clearAliasCache: () => clearAliasCache
|
|
504197
504546
|
});
|
|
504198
|
-
import { existsSync as existsSync72, readFileSync as
|
|
504199
|
-
import { homedir as
|
|
504200
|
-
import { join as
|
|
504547
|
+
import { existsSync as existsSync72, readFileSync as readFileSync45 } from "node:fs";
|
|
504548
|
+
import { homedir as homedir56 } from "node:os";
|
|
504549
|
+
import { join as join93 } from "node:path";
|
|
504201
504550
|
function parseAliasesFromFile(filePath) {
|
|
504202
504551
|
const aliases = new Map;
|
|
504203
504552
|
if (!existsSync72(filePath)) {
|
|
504204
504553
|
return aliases;
|
|
504205
504554
|
}
|
|
504206
504555
|
try {
|
|
504207
|
-
const content =
|
|
504556
|
+
const content = readFileSync45(filePath, "utf-8");
|
|
504208
504557
|
const lines = content.split(`
|
|
504209
504558
|
`);
|
|
504210
504559
|
let inFunction = false;
|
|
@@ -504266,10 +504615,10 @@ function loadAliases(forceReload = false) {
|
|
|
504266
504615
|
if (aliasCache && !forceReload) {
|
|
504267
504616
|
return aliasCache;
|
|
504268
504617
|
}
|
|
504269
|
-
const home =
|
|
504618
|
+
const home = homedir56();
|
|
504270
504619
|
const allAliases = new Map;
|
|
504271
504620
|
for (const file of ALIAS_FILES) {
|
|
504272
|
-
const filePath =
|
|
504621
|
+
const filePath = join93(home, file);
|
|
504273
504622
|
const fileAliases = parseAliasesFromFile(filePath);
|
|
504274
504623
|
for (const [name, value] of fileAliases) {
|
|
504275
504624
|
allAliases.set(name, value);
|
|
@@ -505420,7 +505769,7 @@ var init_system_reminders = __esm(() => {
|
|
|
505420
505769
|
});
|
|
505421
505770
|
|
|
505422
505771
|
// src/cli/app/use-conversation-loop.ts
|
|
505423
|
-
import { randomUUID as
|
|
505772
|
+
import { randomUUID as randomUUID45 } from "node:crypto";
|
|
505424
505773
|
function sleep11(ms) {
|
|
505425
505774
|
return new Promise((resolve43) => setTimeout(resolve43, ms));
|
|
505426
505775
|
}
|
|
@@ -505729,16 +506078,16 @@ function useConversationLoop(ctx) {
|
|
|
505729
506078
|
currentInput = [
|
|
505730
506079
|
...lastSentInputRef.current.map((m4) => ({
|
|
505731
506080
|
...m4,
|
|
505732
|
-
otid:
|
|
506081
|
+
otid: randomUUID45()
|
|
505733
506082
|
})),
|
|
505734
506083
|
...currentInput.map((m4) => m4.type === "message" && m4.role === "user" ? {
|
|
505735
506084
|
...m4,
|
|
505736
|
-
otid:
|
|
506085
|
+
otid: randomUUID45(),
|
|
505737
506086
|
content: [
|
|
505738
506087
|
{ type: "text", text: INTERRUPT_RECOVERY_ALERT },
|
|
505739
506088
|
...typeof m4.content === "string" ? [{ type: "text", text: m4.content }] : Array.isArray(m4.content) ? m4.content : []
|
|
505740
506089
|
]
|
|
505741
|
-
} : { ...m4, otid:
|
|
506090
|
+
} : { ...m4, otid: randomUUID45() })
|
|
505742
506091
|
];
|
|
505743
506092
|
pendingInterruptRecoveryConversationIdRef.current = null;
|
|
505744
506093
|
lastSentInputRef.current = [
|
|
@@ -505777,7 +506126,7 @@ function useConversationLoop(ctx) {
|
|
|
505777
506126
|
type: "text",
|
|
505778
506127
|
text: sc.content
|
|
505779
506128
|
})),
|
|
505780
|
-
otid:
|
|
506129
|
+
otid: randomUUID45()
|
|
505781
506130
|
}
|
|
505782
506131
|
];
|
|
505783
506132
|
}
|
|
@@ -506137,7 +506486,7 @@ ${feedback}
|
|
|
506137
506486
|
});
|
|
506138
506487
|
buffersRef.current.order.push(statusId);
|
|
506139
506488
|
refreshDerived();
|
|
506140
|
-
const hookMessageOtid =
|
|
506489
|
+
const hookMessageOtid = randomUUID45();
|
|
506141
506490
|
setTimeout(() => {
|
|
506142
506491
|
processConversation([
|
|
506143
506492
|
{
|
|
@@ -506164,7 +506513,7 @@ ${feedback}
|
|
|
506164
506513
|
turnEndContinue = undefined;
|
|
506165
506514
|
}
|
|
506166
506515
|
if (turnEndContinue) {
|
|
506167
|
-
const continueOtid =
|
|
506516
|
+
const continueOtid = randomUUID45();
|
|
506168
506517
|
setTimeout(() => {
|
|
506169
506518
|
processConversation([
|
|
506170
506519
|
{
|
|
@@ -506518,7 +506867,7 @@ ${feedback}
|
|
|
506518
506867
|
{
|
|
506519
506868
|
type: "approval",
|
|
506520
506869
|
approvals: allResults,
|
|
506521
|
-
otid:
|
|
506870
|
+
otid: randomUUID45()
|
|
506522
506871
|
}
|
|
506523
506872
|
], {
|
|
506524
506873
|
allowReentry: true,
|
|
@@ -506724,9 +507073,9 @@ ${feedback}
|
|
|
506724
507073
|
...currentInput,
|
|
506725
507074
|
{
|
|
506726
507075
|
type: "message",
|
|
506727
|
-
role: "
|
|
507076
|
+
role: "user",
|
|
506728
507077
|
content: `<system-reminder>The previous response was empty. Please provide a response with either text content or a tool call.</system-reminder>`,
|
|
506729
|
-
otid:
|
|
507078
|
+
otid: randomUUID45()
|
|
506730
507079
|
}
|
|
506731
507080
|
];
|
|
506732
507081
|
}
|
|
@@ -507003,7 +507352,7 @@ var init_use_conversation_loop = __esm(async () => {
|
|
|
507003
507352
|
});
|
|
507004
507353
|
|
|
507005
507354
|
// src/cli/app/use-conversation-switching.ts
|
|
507006
|
-
import { randomUUID as
|
|
507355
|
+
import { randomUUID as randomUUID46 } from "node:crypto";
|
|
507007
507356
|
function useConversationSwitching(ctx) {
|
|
507008
507357
|
const {
|
|
507009
507358
|
abortControllerRef,
|
|
@@ -507078,7 +507427,7 @@ function useConversationSwitching(ctx) {
|
|
|
507078
507427
|
{
|
|
507079
507428
|
role: "user",
|
|
507080
507429
|
content: question,
|
|
507081
|
-
otid:
|
|
507430
|
+
otid: randomUUID46()
|
|
507082
507431
|
}
|
|
507083
507432
|
];
|
|
507084
507433
|
let approvalRecoveryRetries = 0;
|
|
@@ -508379,7 +508728,7 @@ var init_memory_citations_env = __esm(() => {
|
|
|
508379
508728
|
'letta.events.on("tool_start", handler) receives event.toolName, event.args, event.toolCallId, and event.conversationId.',
|
|
508380
508729
|
"letta.tools.register({ name, description, parameters, requiresApproval, parallelSafe, run }) registers a tool available to the model.",
|
|
508381
508730
|
"For eval compatibility, the snapshot tool must be named exactly memory_citation_snapshot.",
|
|
508382
|
-
'For turn_start reminders, append a separate { type: "message", role: "
|
|
508731
|
+
'For turn_start reminders, append a separate { type: "message", role: "user", content: "<system-reminder>" + reminder + "</system-reminder>" } object to event.input. Do not concatenate onto an existing message content field because content may be structured parts.',
|
|
508383
508732
|
"For tool run handlers, ctx.conversation.id is the active conversation id; use it to retrieve state keyed by event.conversationId.",
|
|
508384
508733
|
"Avoid fragile generated regex strings with embedded quote characters; simple string matching/splitting is fine. The candidate must be syntactically valid TypeScript."
|
|
508385
508734
|
],
|
|
@@ -508426,7 +508775,7 @@ var init_memory_citations_env = __esm(() => {
|
|
|
508426
508775
|
assertions: [
|
|
508427
508776
|
{
|
|
508428
508777
|
type: "turn_start_injects_message",
|
|
508429
|
-
role: "
|
|
508778
|
+
role: "user",
|
|
508430
508779
|
contains: ["[[", "]]", "cite", "memory"],
|
|
508431
508780
|
notContains: ["unconditionally", "always call"],
|
|
508432
508781
|
input: [
|
|
@@ -508935,7 +509284,7 @@ export function activate(letta) {
|
|
|
508935
509284
|
// strings to existing content because content may be structured parts.
|
|
508936
509285
|
event.input = [
|
|
508937
509286
|
...event.input,
|
|
508938
|
-
{ type: "message", role: "
|
|
509287
|
+
{ type: "message", role: "user", content: "<system-reminder>mod reminder</system-reminder>" },
|
|
508939
509288
|
];
|
|
508940
509289
|
return { input: event.input };
|
|
508941
509290
|
}));
|
|
@@ -509091,7 +509440,7 @@ async function evaluateModLearningAssertions(params) {
|
|
|
509091
509440
|
};
|
|
509092
509441
|
const emission = await engine4.emitEvent("turn_start", event, context3);
|
|
509093
509442
|
const newMessages = event.input.slice(originalInput.length);
|
|
509094
|
-
const role = assertion.role ?? "
|
|
509443
|
+
const role = assertion.role ?? "user";
|
|
509095
509444
|
const matchingMessages = newMessages.filter((message) => message.role === role);
|
|
509096
509445
|
const matchingText = matchingMessages.map((message) => stringifyMessageContent(message.content)).join(`
|
|
509097
509446
|
`);
|
|
@@ -512494,10 +512843,10 @@ var init_conversation_switch_alert = __esm(() => {
|
|
|
512494
512843
|
});
|
|
512495
512844
|
|
|
512496
512845
|
// src/cli/app/use-submit-handler.ts
|
|
512497
|
-
import { randomUUID as
|
|
512498
|
-
import { existsSync as existsSync73, readFileSync as
|
|
512846
|
+
import { randomUUID as randomUUID47 } from "node:crypto";
|
|
512847
|
+
import { existsSync as existsSync73, readFileSync as readFileSync46, renameSync as renameSync9 } from "node:fs";
|
|
512499
512848
|
import { tmpdir as tmpdir13 } from "node:os";
|
|
512500
|
-
import { join as
|
|
512849
|
+
import { join as join94 } from "node:path";
|
|
512501
512850
|
async function findCustomCommandByName(commandName) {
|
|
512502
512851
|
const { findCustomCommand: findCustomCommand2 } = await Promise.resolve().then(() => (init_custom(), exports_custom));
|
|
512503
512852
|
return findCustomCommand2(commandName);
|
|
@@ -512920,7 +513269,7 @@ ${SYSTEM_REMINDER_CLOSE}` : "";
|
|
|
512920
513269
|
content: buildTextParts(`${SYSTEM_REMINDER_OPEN}
|
|
512921
513270
|
${prompt}
|
|
512922
513271
|
${SYSTEM_REMINDER_CLOSE}`),
|
|
512923
|
-
otid:
|
|
513272
|
+
otid: randomUUID47()
|
|
512924
513273
|
}
|
|
512925
513274
|
]);
|
|
512926
513275
|
} catch (error5) {
|
|
@@ -512984,7 +513333,7 @@ ${SYSTEM_REMINDER_CLOSE}`),
|
|
|
512984
513333
|
type: "message",
|
|
512985
513334
|
role: "user",
|
|
512986
513335
|
content: buildTextParts(buildModCommandPrompt(result3)),
|
|
512987
|
-
otid:
|
|
513336
|
+
otid: randomUUID47()
|
|
512988
513337
|
}
|
|
512989
513338
|
]);
|
|
512990
513339
|
} else if (result3.type === "output") {
|
|
@@ -513029,7 +513378,7 @@ ${SYSTEM_REMINDER_CLOSE}`),
|
|
|
513029
513378
|
${SYSTEM_REMINDER_OPEN}
|
|
513030
513379
|
${request2}
|
|
513031
513380
|
${SYSTEM_REMINDER_CLOSE}`),
|
|
513032
|
-
otid:
|
|
513381
|
+
otid: randomUUID47()
|
|
513033
513382
|
}
|
|
513034
513383
|
]);
|
|
513035
513384
|
} catch (error5) {
|
|
@@ -513197,12 +513546,12 @@ ${SYSTEM_REMINDER_CLOSE}`),
|
|
|
513197
513546
|
try {
|
|
513198
513547
|
const memoryRoot = getScopedMemoryFilesystemRoot(agentId);
|
|
513199
513548
|
const personaCandidates = [
|
|
513200
|
-
|
|
513201
|
-
|
|
513549
|
+
join94(memoryRoot, "system", "persona.md"),
|
|
513550
|
+
join94(memoryRoot, "memory", "system", "persona.md")
|
|
513202
513551
|
];
|
|
513203
513552
|
const personaPath = personaCandidates.find((candidate) => existsSync73(candidate));
|
|
513204
513553
|
if (personaPath) {
|
|
513205
|
-
const personaContent =
|
|
513554
|
+
const personaContent = readFileSync46(personaPath, "utf-8");
|
|
513206
513555
|
setCurrentPersonalityId(detectPersonalityFromPersonaFile(personaContent));
|
|
513207
513556
|
} else {
|
|
513208
513557
|
setCurrentPersonalityId(null);
|
|
@@ -513298,7 +513647,7 @@ ${SYSTEM_REMINDER_CLOSE}`),
|
|
|
513298
513647
|
${SYSTEM_REMINDER_OPEN}
|
|
513299
513648
|
${request2}
|
|
513300
513649
|
${SYSTEM_REMINDER_CLOSE}`),
|
|
513301
|
-
otid:
|
|
513650
|
+
otid: randomUUID47()
|
|
513302
513651
|
}
|
|
513303
513652
|
]);
|
|
513304
513653
|
} catch (error5) {
|
|
@@ -514050,8 +514399,8 @@ Path: ${memoryDir}`, true);
|
|
|
514050
514399
|
updateMemorySyncCommand(cmdId, "No local memory filesystem found to reset.", true, msg);
|
|
514051
514400
|
return { submitted: true };
|
|
514052
514401
|
}
|
|
514053
|
-
const backupDir =
|
|
514054
|
-
|
|
514402
|
+
const backupDir = join94(tmpdir13(), `letta-memfs-reset-${agentId}-${Date.now()}`);
|
|
514403
|
+
renameSync9(memoryDir, backupDir);
|
|
514055
514404
|
if (getBackend().capabilities.localMemfs) {
|
|
514056
514405
|
const { initializeLocalMemoryRepo: initializeLocalMemoryRepo2 } = await Promise.resolve().then(() => (init_memory_git(), exports_memory_git));
|
|
514057
514406
|
await initializeLocalMemoryRepo2({
|
|
@@ -514111,7 +514460,7 @@ ${SYSTEM_REMINDER_CLOSE}`;
|
|
|
514111
514460
|
type: "message",
|
|
514112
514461
|
role: "user",
|
|
514113
514462
|
content: buildTextParts(skillMessage),
|
|
514114
|
-
otid:
|
|
514463
|
+
otid: randomUUID47()
|
|
514115
514464
|
}
|
|
514116
514465
|
]);
|
|
514117
514466
|
} catch (error5) {
|
|
@@ -514149,7 +514498,7 @@ ${SYSTEM_REMINDER_CLOSE}`;
|
|
|
514149
514498
|
type: "message",
|
|
514150
514499
|
role: "user",
|
|
514151
514500
|
content: rememberParts,
|
|
514152
|
-
otid:
|
|
514501
|
+
otid: randomUUID47()
|
|
514153
514502
|
}
|
|
514154
514503
|
]);
|
|
514155
514504
|
} catch (error5) {
|
|
@@ -514565,7 +514914,7 @@ Resumed reflection arena choice prompt for run ${run2.runId}.`, true);
|
|
|
514565
514914
|
type: "message",
|
|
514566
514915
|
role: "user",
|
|
514567
514916
|
content: buildTextParts(initMessage),
|
|
514568
|
-
otid:
|
|
514917
|
+
otid: randomUUID47()
|
|
514569
514918
|
}
|
|
514570
514919
|
]);
|
|
514571
514920
|
} catch (error5) {
|
|
@@ -514598,7 +514947,7 @@ Resumed reflection arena choice prompt for run ${run2.runId}.`, true);
|
|
|
514598
514947
|
type: "message",
|
|
514599
514948
|
role: "user",
|
|
514600
514949
|
content: buildTextParts(doctorMessage),
|
|
514601
|
-
otid:
|
|
514950
|
+
otid: randomUUID47()
|
|
514602
514951
|
}
|
|
514603
514952
|
]);
|
|
514604
514953
|
} catch (error5) {
|
|
@@ -514730,7 +515079,7 @@ Resumed reflection arena choice prompt for run ${run2.runId}.`, true);
|
|
|
514730
515079
|
type: "message",
|
|
514731
515080
|
role: "user",
|
|
514732
515081
|
content: buildTextParts(wrapSkillPrompt2(matchedSkill.id, skillContent, userRequest)),
|
|
514733
|
-
otid:
|
|
515082
|
+
otid: randomUUID47()
|
|
514734
515083
|
}
|
|
514735
515084
|
]);
|
|
514736
515085
|
} catch (error5) {
|
|
@@ -514881,7 +515230,7 @@ ${SYSTEM_REMINDER_CLOSE}
|
|
|
514881
515230
|
initialInput.push({
|
|
514882
515231
|
type: "approval",
|
|
514883
515232
|
approvals: eagerRecoveryDenials,
|
|
514884
|
-
otid:
|
|
515233
|
+
otid: randomUUID47()
|
|
514885
515234
|
});
|
|
514886
515235
|
}
|
|
514887
515236
|
const queuedApprovalInput = consumeQueuedApprovalInputForCurrentConversation();
|
|
@@ -515004,7 +515353,7 @@ var init_use_submit_handler = __esm(async () => {
|
|
|
515004
515353
|
});
|
|
515005
515354
|
|
|
515006
515355
|
// src/cli/app/AppCoordinator.tsx
|
|
515007
|
-
import { join as
|
|
515356
|
+
import { join as join95 } from "node:path";
|
|
515008
515357
|
function buildStartupCommandHints(options) {
|
|
515009
515358
|
const {
|
|
515010
515359
|
isResumingConversation,
|
|
@@ -516291,7 +516640,7 @@ function App2({
|
|
|
516291
516640
|
agentId: a2.agentId ?? null
|
|
516292
516641
|
}))
|
|
516293
516642
|
});
|
|
516294
|
-
const agentModsDirectory = modContext.memfs.enabled && modContext.memfs.memoryDir ?
|
|
516643
|
+
const agentModsDirectory = modContext.memfs.enabled && modContext.memfs.memoryDir ? join95(modContext.memfs.memoryDir, "mods") : null;
|
|
516295
516644
|
const modAdapter = useLocalModAdapter(modContext, {
|
|
516296
516645
|
agentModsDirectory,
|
|
516297
516646
|
disabled: modsDisabled,
|
|
@@ -518639,12 +518988,12 @@ EXAMPLES
|
|
|
518639
518988
|
console.log(usage);
|
|
518640
518989
|
}
|
|
518641
518990
|
async function printInfo() {
|
|
518642
|
-
const { join:
|
|
518991
|
+
const { join: join96 } = await import("node:path");
|
|
518643
518992
|
const { getVersion: getVersion2 } = await Promise.resolve().then(() => (init_version(), exports_version));
|
|
518644
518993
|
const { SKILLS_DIR: SKILLS_DIR2 } = await Promise.resolve().then(() => (init_skills5(), exports_skills2));
|
|
518645
518994
|
const { exists: exists2 } = await Promise.resolve().then(() => (init_fs(), exports_fs));
|
|
518646
518995
|
const cwd2 = process.cwd();
|
|
518647
|
-
const skillsDir =
|
|
518996
|
+
const skillsDir = join96(cwd2, SKILLS_DIR2);
|
|
518648
518997
|
const skillsExist = exists2(skillsDir);
|
|
518649
518998
|
await settingsManager.loadLocalProjectSettings(cwd2);
|
|
518650
518999
|
const pinned = settingsManager.getPinnedAgents();
|
|
@@ -519787,7 +520136,9 @@ Error: ${message}`);
|
|
|
519787
520136
|
return null;
|
|
519788
520137
|
});
|
|
519789
520138
|
if (!shouldBlockOnMemfsStartup) {}
|
|
519790
|
-
const secretsInitPromise = Promise.resolve().then(() => (init_secrets_store(), exports_secrets_store)).then(({ initSecretsFromServer: initSecretsFromServer2 }) => initSecretsFromServer2(agentId2))
|
|
520139
|
+
const secretsInitPromise = Promise.resolve().then(() => (init_secrets_store(), exports_secrets_store)).then(({ initSecretsFromServer: initSecretsFromServer2 }) => initSecretsFromServer2(agentId2)).catch((error5) => {
|
|
520140
|
+
debugLog("secrets", `Failed to init secrets: ${error5 instanceof Error ? error5.message : String(error5)}`);
|
|
520141
|
+
});
|
|
519791
520142
|
const isResumingProject = !shouldCreateNew && !!resumingAgentId;
|
|
519792
520143
|
const isReusingExistingAgent = !shouldCreateNew && agent && agent.id;
|
|
519793
520144
|
const resuming = !!(agentIdArg || isResumingProject || isReusingExistingAgent);
|
|
@@ -519898,11 +520249,7 @@ Error: ${message}`);
|
|
|
519898
520249
|
}
|
|
519899
520250
|
const fdPath = await ensureFdPath();
|
|
519900
520251
|
setFileAutocompleteFdPath(fdPath);
|
|
519901
|
-
|
|
519902
|
-
await secretsInitPromise;
|
|
519903
|
-
} catch (error5) {
|
|
519904
|
-
Promise.resolve().then(() => (init_debug(), exports_debug)).then(({ debugLog: debugLog3 }) => debugLog3("secrets", `Failed to init secrets: ${error5 instanceof Error ? error5.message : String(error5)}`));
|
|
519905
|
-
}
|
|
520252
|
+
await secretsInitPromise;
|
|
519906
520253
|
if (shouldPersistSessionState()) {
|
|
519907
520254
|
settingsManager.persistSession(agent.id, conversationIdToUse);
|
|
519908
520255
|
}
|
|
@@ -522317,4 +522664,4 @@ function registerBunOAuthFlows() {
|
|
|
522317
522664
|
registerBunOAuthFlows();
|
|
522318
522665
|
await init_src5().then(() => exports_src2);
|
|
522319
522666
|
|
|
522320
|
-
//# debugId=
|
|
522667
|
+
//# debugId=BB160EB36D5AADE464756E2164756E21
|