@letta-ai/letta-code 0.34.63 → 0.34.64
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mcp-client.js +2 -2
- package/dist/mcp-client.js.map +1 -1
- package/dist/mcp-oauth.js +2 -2
- package/dist/mcp-oauth.js.map +1 -1
- package/dist/types/backend/api/agent-message.d.ts +2 -0
- package/dist/types/backend/api/agent-message.d.ts.map +1 -1
- package/dist/types/backend/api/metadata.d.ts +0 -12
- package/dist/types/backend/api/metadata.d.ts.map +1 -1
- package/dist/types/backend/api/unified-mcp.d.ts.map +1 -1
- package/dist/types/backend/local/local-backend.d.ts.map +1 -1
- package/dist/types/backend/local/local-message-list-options.d.ts +7 -0
- package/dist/types/backend/local/local-message-list-options.d.ts.map +1 -0
- package/dist/types/backend/local/local-store.d.ts +2 -0
- package/dist/types/backend/local/local-store.d.ts.map +1 -1
- package/dist/types/backend/local/local-transcript-history.d.ts +8 -0
- package/dist/types/backend/local/local-transcript-history.d.ts.map +1 -1
- package/dist/types/backend/local/local-transcript.d.ts +1 -0
- package/dist/types/backend/local/local-transcript.d.ts.map +1 -1
- package/dist/types/backend/local/system-prompt-compilation.d.ts +2 -1
- package/dist/types/backend/local/system-prompt-compilation.d.ts.map +1 -1
- package/dist/types/reminders/engine.d.ts +3 -3
- package/dist/types/reminders/engine.d.ts.map +1 -1
- package/dist/types/tools/impl/claude-steer-timeouts.d.ts +5 -0
- package/dist/types/tools/impl/claude-steer-timeouts.d.ts.map +1 -1
- package/dist/types/tools/impl/external-coding-agent.d.ts +1 -1
- package/dist/types/tools/impl/external-coding-agent.d.ts.map +1 -1
- package/dist/types/tools/impl/external-fork-context.d.ts +6 -0
- package/dist/types/tools/impl/external-fork-context.d.ts.map +1 -1
- package/dist/types/tools/impl/monitor-script.d.ts +1 -0
- package/dist/types/tools/impl/monitor-script.d.ts.map +1 -1
- package/dist/types/tools/impl/monitor.d.ts +1 -0
- package/dist/types/tools/impl/monitor.d.ts.map +1 -1
- package/dist/types/tools/impl/remote-connect-retry.d.ts +4 -0
- package/dist/types/tools/impl/remote-connect-retry.d.ts.map +1 -0
- package/dist/types/tools/impl/remote-external-coding-agent.d.ts.map +1 -1
- package/dist/types/tools/impl/remote-follow-up-retry.d.ts +9 -0
- package/dist/types/tools/impl/remote-follow-up-retry.d.ts.map +1 -0
- package/dist/types/tools/impl/watch-pr.d.ts.map +1 -1
- package/dist/types/utils/task-notifications.d.ts +1 -0
- package/dist/types/utils/task-notifications.d.ts.map +1 -1
- package/letta.js +261 -165
- package/npm-shrinkwrap.json +18 -14
- package/package.json +2 -2
- package/scripts/source-file-size-baseline.json +1 -1
- package/skills/image-generation/SKILL.md +2 -0
- package/skills/self-configuration/SKILL.md +7 -5
package/letta.js
CHANGED
|
@@ -3472,7 +3472,7 @@ function trackEndTurnNoAssistant(params) {
|
|
|
3472
3472
|
});
|
|
3473
3473
|
}
|
|
3474
3474
|
function extractHttpStatus(message) {
|
|
3475
|
-
const match = /(?:^|:\s*)([45]\d{2})\b/.exec(message);
|
|
3475
|
+
const match = /(?:^|:\s*)(?:HTTP\s+)?([45]\d{2})\b/.exec(message);
|
|
3476
3476
|
return match ? Number(match[1]) : undefined;
|
|
3477
3477
|
}
|
|
3478
3478
|
function reportExternalWorkerLaunchFailure(options) {
|
|
@@ -6139,7 +6139,7 @@ var package_default;
|
|
|
6139
6139
|
var init_package = __esm(() => {
|
|
6140
6140
|
package_default = {
|
|
6141
6141
|
name: "@letta-ai/letta-code",
|
|
6142
|
-
version: "0.34.
|
|
6142
|
+
version: "0.34.64",
|
|
6143
6143
|
lettaStartupLogProtocol: 1,
|
|
6144
6144
|
lettaConfigDirProtocol: 1,
|
|
6145
6145
|
description: "Letta Code is a CLI tool for interacting with stateful Letta agents from the terminal.",
|
|
@@ -6426,7 +6426,7 @@ var init_package = __esm(() => {
|
|
|
6426
6426
|
},
|
|
6427
6427
|
lettaLifecycleProtocol: 1,
|
|
6428
6428
|
lettaRuntimeGraphProtocol: 1,
|
|
6429
|
-
lettaRuntimeGraphSha512: "sha512-
|
|
6429
|
+
lettaRuntimeGraphSha512: "sha512-YBw5454QIS1lIoAD6ih1iX/HMCzk64xnt+DSnT2DImzzMMJXgHXqXap7e1O2wPQbkVfm5HI9Q+5a9KskU8GYRw==",
|
|
6430
6430
|
patchedDependencies: {
|
|
6431
6431
|
"@earendil-works/pi-ai@1.5.2": "patches/@earendil-works%2Fpi-ai@1.5.2.patch"
|
|
6432
6432
|
}
|
|
@@ -6587,9 +6587,6 @@ function getFeedbackClientType(env = process.env) {
|
|
|
6587
6587
|
async function getBalanceMetadata(options = {}) {
|
|
6588
6588
|
return apiRequest("GET", "/v1/metadata/balance", undefined, options.signal ? { signal: options.signal } : {});
|
|
6589
6589
|
}
|
|
6590
|
-
async function getModelQuotaMetadata() {
|
|
6591
|
-
return apiRequest("GET", "/v1/organizations/self/quotas");
|
|
6592
|
-
}
|
|
6593
6590
|
async function getBillingTier() {
|
|
6594
6591
|
try {
|
|
6595
6592
|
const balance = await getBalanceMetadata();
|
|
@@ -101815,6 +101812,27 @@ function emptyLocalUsage() {
|
|
|
101815
101812
|
};
|
|
101816
101813
|
}
|
|
101817
101814
|
|
|
101815
|
+
// src/backend/local/local-message-list-options.ts
|
|
101816
|
+
function getListLimit(body) {
|
|
101817
|
+
const limit4 = body?.limit;
|
|
101818
|
+
return typeof limit4 === "number" && limit4 > 0 ? limit4 : undefined;
|
|
101819
|
+
}
|
|
101820
|
+
function getListOrder(body) {
|
|
101821
|
+
const order = body?.order;
|
|
101822
|
+
return order === "asc" ? "asc" : "desc";
|
|
101823
|
+
}
|
|
101824
|
+
function getCursor(body, key) {
|
|
101825
|
+
const value = body?.[key];
|
|
101826
|
+
return typeof value === "string" && value.length > 0 ? value : undefined;
|
|
101827
|
+
}
|
|
101828
|
+
function getIncludedMessageTypes(body) {
|
|
101829
|
+
const value = body?.include_return_message_types;
|
|
101830
|
+
if (!Array.isArray(value))
|
|
101831
|
+
return;
|
|
101832
|
+
const messageTypes = value.filter((item) => typeof item === "string" && item.length > 0);
|
|
101833
|
+
return messageTypes.length > 0 ? new Set(messageTypes) : undefined;
|
|
101834
|
+
}
|
|
101835
|
+
|
|
101818
101836
|
// src/backend/local/local-stream-chunks.ts
|
|
101819
101837
|
function toStoredOutputFields(chunk) {
|
|
101820
101838
|
const {
|
|
@@ -101919,6 +101937,19 @@ function readLocalTranscriptRowsForHistory(path8, inContextMessageIds) {
|
|
|
101919
101937
|
});
|
|
101920
101938
|
return rows;
|
|
101921
101939
|
}
|
|
101940
|
+
function countLocalTranscriptMessagesOutsideContext(path8, messageFormat, inContextMessageIds) {
|
|
101941
|
+
if (inContextMessageIds.length === 0)
|
|
101942
|
+
return 0;
|
|
101943
|
+
const inContextIds = new Set(inContextMessageIds);
|
|
101944
|
+
const outsideContextIds = new Set;
|
|
101945
|
+
forEachJsonlRow(path8, (row) => {
|
|
101946
|
+
const message = messageFormat === LOCAL_TRANSCRIPT_LEGACY_MESSAGE_FORMAT ? row : isLocalTranscriptAppendEntry(row) ? row.message : undefined;
|
|
101947
|
+
if (isRecord2(message) && typeof message.id === "string" && !inContextIds.has(message.id)) {
|
|
101948
|
+
outsideContextIds.add(message.id);
|
|
101949
|
+
}
|
|
101950
|
+
});
|
|
101951
|
+
return outsideContextIds.size;
|
|
101952
|
+
}
|
|
101922
101953
|
var LOCAL_OMITTED_IMAGE_PLACEHOLDER = "[image omitted: not in context]";
|
|
101923
101954
|
var init_local_transcript_history = __esm(() => {
|
|
101924
101955
|
init_local_transcript();
|
|
@@ -101991,25 +102022,6 @@ function parseToolInput(input) {
|
|
|
101991
102022
|
return input;
|
|
101992
102023
|
}
|
|
101993
102024
|
}
|
|
101994
|
-
function getListLimit(body) {
|
|
101995
|
-
const limit4 = body?.limit;
|
|
101996
|
-
return typeof limit4 === "number" && limit4 > 0 ? limit4 : undefined;
|
|
101997
|
-
}
|
|
101998
|
-
function getListOrder(body) {
|
|
101999
|
-
const order = body?.order;
|
|
102000
|
-
return order === "asc" ? "asc" : "desc";
|
|
102001
|
-
}
|
|
102002
|
-
function getCursor(body, key) {
|
|
102003
|
-
const value = body?.[key];
|
|
102004
|
-
return typeof value === "string" && value.length > 0 ? value : undefined;
|
|
102005
|
-
}
|
|
102006
|
-
function getIncludedMessageTypes(body) {
|
|
102007
|
-
const value = body?.include_return_message_types;
|
|
102008
|
-
if (!Array.isArray(value))
|
|
102009
|
-
return;
|
|
102010
|
-
const messageTypes = value.filter((item) => typeof item === "string" && item.length > 0);
|
|
102011
|
-
return messageTypes.length > 0 ? new Set(messageTypes) : undefined;
|
|
102012
|
-
}
|
|
102013
102025
|
function encodePathSegment(value) {
|
|
102014
102026
|
return Buffer.from(value).toString("base64url");
|
|
102015
102027
|
}
|
|
@@ -102457,6 +102469,14 @@ class LocalStore {
|
|
|
102457
102469
|
this.ensureConversation(conversationId, resolvedAgentId);
|
|
102458
102470
|
return this.localMessagesForConversation(conversationId, resolvedAgentId).map(cloneLocalMessage);
|
|
102459
102471
|
}
|
|
102472
|
+
countMessagesOutsideContext(conversationId, agentId) {
|
|
102473
|
+
const conversation = this.findConversation(conversationId, agentId);
|
|
102474
|
+
if (!conversation)
|
|
102475
|
+
return 0;
|
|
102476
|
+
const key = this.conversationKey(conversation.id, agentId);
|
|
102477
|
+
const metadata = this.validateTranscriptMetadata(key);
|
|
102478
|
+
return metadata ? countLocalTranscriptMessagesOutsideContext(metadata.messagesPath, metadata.messageFormat, conversation.in_context_message_ids) : 0;
|
|
102479
|
+
}
|
|
102460
102480
|
settleInterruptedToolCalls(conversationIdOrAgentId, options = {}) {
|
|
102461
102481
|
const targets = this.toolSettlementTargets(conversationIdOrAgentId, options.agentId);
|
|
102462
102482
|
let settledCount = 0;
|
|
@@ -110134,7 +110154,7 @@ function compileLocalSystemPrompt(options) {
|
|
|
110134
110154
|
agentId: options.agent.id,
|
|
110135
110155
|
conversationId: options.conversationId,
|
|
110136
110156
|
compiledAt,
|
|
110137
|
-
previousMessageCount: options.previousMessageCount ?? 0
|
|
110157
|
+
previousMessageCount: typeof options.previousMessageCount === "function" ? options.previousMessageCount() : options.previousMessageCount ?? 0
|
|
110138
110158
|
});
|
|
110139
110159
|
const coreMemory = [memfs.content, metadata].filter((part) => part.trim().length > 0).join(`
|
|
110140
110160
|
|
|
@@ -110355,7 +110375,7 @@ var init_local_backend = __esm(() => {
|
|
|
110355
110375
|
systemPrompt: appendAvailableSkillsBlock(input.agent.system, clientSkills2)
|
|
110356
110376
|
};
|
|
110357
110377
|
}
|
|
110358
|
-
const persisted = await this.getOrCompileSystemPrompt(input.conversationId, input.agentId, input.agent
|
|
110378
|
+
const persisted = await this.getOrCompileSystemPrompt(input.conversationId, input.agentId, input.agent);
|
|
110359
110379
|
const clientSkills = Array.isArray(input.body.client_skills) ? input.body.client_skills : [];
|
|
110360
110380
|
return {
|
|
110361
110381
|
systemPrompt: appendAvailableSkillsBlock(persisted.content, clientSkills),
|
|
@@ -110542,7 +110562,7 @@ var init_local_backend = __esm(() => {
|
|
|
110542
110562
|
const compiled = await this.getOrCompileSystemPrompt(conversationId, agentId);
|
|
110543
110563
|
return { systemPrompt: compiled.content };
|
|
110544
110564
|
}
|
|
110545
|
-
async getOrCompileSystemPrompt(conversationId, agentId, agent = this.store.retrieveAgentRecord(agentId)
|
|
110565
|
+
async getOrCompileSystemPrompt(conversationId, agentId, agent = this.store.retrieveAgentRecord(agentId)) {
|
|
110546
110566
|
const existing = this.store.getCompiledSystemPrompt(conversationId, agentId);
|
|
110547
110567
|
const rawSystemHash = hashRawSystemPrompt(agent.system);
|
|
110548
110568
|
const memfsRevision = this.isMemfsEnabledForAgent(agentId) ? getCommittedMemfsRevision(this.memoryDirForAgent(agentId)) : undefined;
|
|
@@ -110550,10 +110570,7 @@ var init_local_backend = __esm(() => {
|
|
|
110550
110570
|
return existing;
|
|
110551
110571
|
}
|
|
110552
110572
|
if (existing?.rawSystemHash === rawSystemHash && existing.memfsRevision !== memfsRevision) {
|
|
110553
|
-
const compiled = await this.compileAndMaybePersistSystemPrompt(conversationId, agentId, {
|
|
110554
|
-
dryRun: true,
|
|
110555
|
-
previousMessageCount
|
|
110556
|
-
});
|
|
110573
|
+
const compiled = await this.compileAndMaybePersistSystemPrompt(conversationId, agentId, { dryRun: true });
|
|
110557
110574
|
if (compiled.memfsRevision !== existing.memfsRevision) {
|
|
110558
110575
|
const midConversationSystemPrompt = formatMidConversationMemoryUpdate(compiled);
|
|
110559
110576
|
this.store.setCompiledSystemPrompt(conversationId, agentId, {
|
|
@@ -110567,8 +110584,7 @@ var init_local_backend = __esm(() => {
|
|
|
110567
110584
|
return existing;
|
|
110568
110585
|
}
|
|
110569
110586
|
return this.compileAndMaybePersistSystemPrompt(conversationId, agentId, {
|
|
110570
|
-
dryRun: false
|
|
110571
|
-
previousMessageCount
|
|
110587
|
+
dryRun: false
|
|
110572
110588
|
});
|
|
110573
110589
|
}
|
|
110574
110590
|
async compileAndMaybePersistSystemPrompt(conversationId, agentId, options) {
|
|
@@ -110577,14 +110593,10 @@ var init_local_backend = __esm(() => {
|
|
|
110577
110593
|
if (memfsEnabled) {
|
|
110578
110594
|
await this.ensureLocalMemoryRepo(agentId, [], agent.name);
|
|
110579
110595
|
}
|
|
110580
|
-
const previousMessageCount = options.previousMessageCount ?? this.store.listConversationMessages(conversationId, {
|
|
110581
|
-
agent_id: agentId,
|
|
110582
|
-
order: "asc"
|
|
110583
|
-
}).length;
|
|
110584
110596
|
const compiled = compileLocalSystemPrompt({
|
|
110585
110597
|
agent,
|
|
110586
110598
|
conversationId,
|
|
110587
|
-
previousMessageCount,
|
|
110599
|
+
previousMessageCount: () => this.store.countMessagesOutsideContext(conversationId, agentId),
|
|
110588
110600
|
memoryDir: memfsEnabled ? this.memoryDirForAgent(agentId) : undefined,
|
|
110589
110601
|
includeMemfs: memfsEnabled
|
|
110590
110602
|
});
|
|
@@ -164907,7 +164919,7 @@ function taskNotificationMessage(text2) {
|
|
|
164907
164919
|
function formatMonitorEventNotification(notification) {
|
|
164908
164920
|
return `<task-notification>
|
|
164909
164921
|
<task-id>${escapeXml(notification.taskId)}</task-id>
|
|
164910
|
-
<summary>${escapeXml(`Monitor
|
|
164922
|
+
<summary>${escapeXml(notification.description?.trim() ? `Monitor: ${notification.description}` : "Monitor event")}</summary>
|
|
164911
164923
|
<result>
|
|
164912
164924
|
<event>${escapeXml(notification.event)}</event>
|
|
164913
164925
|
</result>
|
|
@@ -203357,7 +203369,7 @@ var init_mcp_client = __esm(() => {
|
|
|
203357
203369
|
init_streamableHttp();
|
|
203358
203370
|
DEFAULT_CLIENT_INFO = {
|
|
203359
203371
|
name: "letta-code",
|
|
203360
|
-
version: "0.34.
|
|
203372
|
+
version: "0.34.64"
|
|
203361
203373
|
};
|
|
203362
203374
|
});
|
|
203363
203375
|
|
|
@@ -226104,13 +226116,13 @@ function parseSearchResult(value) {
|
|
|
226104
226116
|
}
|
|
226105
226117
|
return { toolId, jsonSchema, score };
|
|
226106
226118
|
}
|
|
226107
|
-
async function withTimeout2(promise2, timeoutMs, operation) {
|
|
226119
|
+
async function withTimeout2(promise2, timeoutMs, operation, timeoutMessage) {
|
|
226108
226120
|
let timer;
|
|
226109
226121
|
try {
|
|
226110
226122
|
return await Promise.race([
|
|
226111
226123
|
promise2,
|
|
226112
226124
|
new Promise((_resolve, reject2) => {
|
|
226113
|
-
timer = setTimeout(() => reject2(new Error(`${operation} timed out after ${timeoutMs}ms`)), timeoutMs);
|
|
226125
|
+
timer = setTimeout(() => reject2(new Error(timeoutMessage ?? `${operation} timed out after ${timeoutMs}ms`)), timeoutMs);
|
|
226114
226126
|
})
|
|
226115
226127
|
]);
|
|
226116
226128
|
} finally {
|
|
@@ -226176,7 +226188,7 @@ async function runUnifiedMcpTool(params) {
|
|
|
226176
226188
|
[MCP_ORIGINATOR_ISOLATION_HEADER3]: "1"
|
|
226177
226189
|
}
|
|
226178
226190
|
} : {}
|
|
226179
|
-
}), params.timeoutMs ?? 60000, "Running agent MCP tool");
|
|
226191
|
+
}), params.timeoutMs ?? 60000, "Running agent MCP tool", `MCP tool call hit the cloud server's ${(params.timeoutMs ?? 60000) / 1000}-second limit; the MCP server may still be processing the request. Retry with a smaller or more selective request, or set the tool's own timeout argument below ${(params.timeoutMs ?? 60000) / 1000} seconds if it has one.`);
|
|
226180
226192
|
return parseRunResult(value);
|
|
226181
226193
|
}
|
|
226182
226194
|
var MCP_ORIGINATOR_TOKEN_HEADER3 = "x-letta-mcp-originator-token", MCP_ORIGINATOR_ISOLATION_HEADER3 = "x-letta-mcp-originator-isolation";
|
|
@@ -234737,7 +234749,14 @@ async function startScriptMonitor(args, hooks) {
|
|
|
234737
234749
|
};
|
|
234738
234750
|
const events = createMonitorEventStream({
|
|
234739
234751
|
emit(event) {
|
|
234740
|
-
hooks.queueEvent({
|
|
234752
|
+
hooks.queueEvent({
|
|
234753
|
+
taskId,
|
|
234754
|
+
description: args.description,
|
|
234755
|
+
event,
|
|
234756
|
+
scope,
|
|
234757
|
+
actingUserId,
|
|
234758
|
+
secrets: secrets2
|
|
234759
|
+
});
|
|
234741
234760
|
},
|
|
234742
234761
|
stopSource() {
|
|
234743
234762
|
stop2("output rate too high", `
|
|
@@ -234850,6 +234869,7 @@ async function startScriptMonitor(args, hooks) {
|
|
|
234850
234869
|
events.finish();
|
|
234851
234870
|
hooks.queueEvent({
|
|
234852
234871
|
taskId,
|
|
234872
|
+
description: args.description,
|
|
234853
234873
|
event: hooks.timeoutEvent(args.timeout_ms),
|
|
234854
234874
|
scope,
|
|
234855
234875
|
actingUserId,
|
|
@@ -234995,7 +235015,7 @@ function applyMonitorMaxTimeout(text2, timeoutMs = getMonitorMaxTimeoutMs()) {
|
|
|
234995
235015
|
return text2.replaceAll("{{MONITOR_MAX_TIMEOUT}}", formatMonitorMaxTimeout(timeoutMs));
|
|
234996
235016
|
}
|
|
234997
235017
|
function getMonitorTimeoutEvent(timeoutMs, tool = "Monitor") {
|
|
234998
|
-
return isManagedCloudRuntime() && timeoutMs === getMonitorMaxTimeoutMs() ? `${tool} stopped at the ${timeoutMs / 3600000}-hour Cloud sandbox limit. If you still need to watch,
|
|
235018
|
+
return isManagedCloudRuntime() && timeoutMs === getMonitorMaxTimeoutMs() ? `${tool} stopped at the ${timeoutMs / 3600000}-hour Cloud sandbox limit. If you still need to watch, re-arm it by calling ${tool} again.` : "[Monitor timed out — re-arm if needed.]";
|
|
234999
235019
|
}
|
|
235000
235020
|
var HOUR_MS = 3600000, DAY_MS, DEFAULT_MAX_TIMEOUT_MS, SEVEN_DAYS_MS;
|
|
235001
235021
|
var init_monitor_timeout = __esm(() => {
|
|
@@ -235376,7 +235396,8 @@ function queueMonitorEvent(params) {
|
|
|
235376
235396
|
kind: "task_notification",
|
|
235377
235397
|
text: formatMonitorEventNotification({
|
|
235378
235398
|
taskId,
|
|
235379
|
-
event: sanitizedEvent
|
|
235399
|
+
event: sanitizedEvent,
|
|
235400
|
+
description: sanitizeMonitorText(params.description ?? "", secrets2)
|
|
235380
235401
|
}),
|
|
235381
235402
|
...scope,
|
|
235382
235403
|
...actingUserId !== undefined ? { actingUserId } : {}
|
|
@@ -235455,6 +235476,7 @@ function startCommandMonitor(args) {
|
|
|
235455
235476
|
emit(event) {
|
|
235456
235477
|
queueMonitorEvent({
|
|
235457
235478
|
taskId,
|
|
235479
|
+
description: args.description,
|
|
235458
235480
|
event,
|
|
235459
235481
|
scope,
|
|
235460
235482
|
actingUserId,
|
|
@@ -235578,6 +235600,7 @@ function startCommandMonitor(args) {
|
|
|
235578
235600
|
`);
|
|
235579
235601
|
queueMonitorEvent({
|
|
235580
235602
|
taskId,
|
|
235603
|
+
description: args.description,
|
|
235581
235604
|
event: getMonitorTimeoutEvent(args.timeout_ms),
|
|
235582
235605
|
scope,
|
|
235583
235606
|
actingUserId,
|
|
@@ -235633,6 +235656,7 @@ function startWebSocketMonitor(args) {
|
|
|
235633
235656
|
emit(event) {
|
|
235634
235657
|
queueMonitorEvent({
|
|
235635
235658
|
taskId,
|
|
235659
|
+
description: args.description,
|
|
235636
235660
|
event,
|
|
235637
235661
|
scope,
|
|
235638
235662
|
actingUserId,
|
|
@@ -235686,6 +235710,7 @@ function startWebSocketMonitor(args) {
|
|
|
235686
235710
|
`);
|
|
235687
235711
|
queueMonitorEvent({
|
|
235688
235712
|
taskId,
|
|
235713
|
+
description: args.description,
|
|
235689
235714
|
event,
|
|
235690
235715
|
scope,
|
|
235691
235716
|
actingUserId,
|
|
@@ -235719,6 +235744,7 @@ function startWebSocketMonitor(args) {
|
|
|
235719
235744
|
`);
|
|
235720
235745
|
queueMonitorEvent({
|
|
235721
235746
|
taskId,
|
|
235747
|
+
description: args.description,
|
|
235722
235748
|
event,
|
|
235723
235749
|
scope,
|
|
235724
235750
|
actingUserId,
|
|
@@ -235744,6 +235770,7 @@ function startWebSocketMonitor(args) {
|
|
|
235744
235770
|
`);
|
|
235745
235771
|
queueMonitorEvent({
|
|
235746
235772
|
taskId,
|
|
235773
|
+
description: args.description,
|
|
235747
235774
|
event,
|
|
235748
235775
|
scope,
|
|
235749
235776
|
actingUserId,
|
|
@@ -235760,6 +235787,7 @@ function startWebSocketMonitor(args) {
|
|
|
235760
235787
|
return;
|
|
235761
235788
|
queueMonitorEvent({
|
|
235762
235789
|
taskId,
|
|
235790
|
+
description: args.description,
|
|
235763
235791
|
event: getMonitorTimeoutEvent(args.timeout_ms),
|
|
235764
235792
|
scope,
|
|
235765
235793
|
actingUserId,
|
|
@@ -238906,12 +238934,15 @@ function buildAgentSendContent(sender, noWait, message) {
|
|
|
238906
238934
|
{ type: "text", text: message }
|
|
238907
238935
|
];
|
|
238908
238936
|
}
|
|
238937
|
+
function buildAgentSendCliTarget(agentId, conversationId) {
|
|
238938
|
+
return conversationId === "default" ? `--agent ${agentId} --conversation default` : `--conversation ${conversationId}`;
|
|
238939
|
+
}
|
|
238909
238940
|
function buildAgentSendReminder(sender, noWait) {
|
|
238910
238941
|
if (!sender.agentId)
|
|
238911
238942
|
return "";
|
|
238912
238943
|
const address = sender.conversationId ? `, conversation ${sender.conversationId}` : "";
|
|
238913
238944
|
const isDefault = sender.conversationId === "default";
|
|
238914
|
-
const cliTarget =
|
|
238945
|
+
const cliTarget = buildAgentSendCliTarget(sender.agentId, sender.conversationId ?? "");
|
|
238915
238946
|
const toolTarget = isDefault ? `agent_id ${sender.agentId} and conversation_id default` : `conversation_id ${sender.conversationId}`;
|
|
238916
238947
|
const instruction = !noWait ? "The sender will only see the final message you generate (not tool calls or reasoning). Include your answer in your final response." : sender.conversationId ? `To reply, call SendAgentMessage with ${toolTarget}. Only if that tool is unavailable, run letta -p ${cliTarget} --no-wait "your reply". Ordinary assistant output is not forwarded to the sender.` : "Ordinary assistant output is not forwarded to the sender. No return conversation was supplied.";
|
|
238917
238948
|
return `<system-reminder>
|
|
@@ -239112,9 +239143,10 @@ function withNativeCliPath(env6, platform7 = process.platform) {
|
|
|
239112
239143
|
var init_native_cli_env = () => {};
|
|
239113
239144
|
|
|
239114
239145
|
// src/tools/impl/claude-steer-timeouts.ts
|
|
239115
|
-
var CLAUDE_TURN_START_TIMEOUT_MS = 60000, CLAUDE_CONTROL_RESPONSE_TIMEOUT_MS = 30000, REMOTE_SUBAGENT_MESSAGE_TIMEOUT_MS, CLAUDE_TURN_START_TIMEOUT_ERROR = "Claude turn did not become interruptible", CLAUDE_INTERRUPT_ACK_TIMEOUT_ERROR = "Claude interrupt acknowledgement timed out";
|
|
239146
|
+
var CLAUDE_TURN_START_TIMEOUT_MS = 60000, CLAUDE_CONTROL_RESPONSE_TIMEOUT_MS = 30000, REMOTE_SUBAGENT_MESSAGE_TIMEOUT_MS, REMOTE_SUBAGENT_MESSAGE_DEDUPE_PENDING_TTL_MS, CLAUDE_TURN_START_TIMEOUT_ERROR = "Claude turn did not become interruptible", CLAUDE_INTERRUPT_ACK_TIMEOUT_ERROR = "Claude interrupt acknowledgement timed out";
|
|
239116
239147
|
var init_claude_steer_timeouts = __esm(() => {
|
|
239117
239148
|
REMOTE_SUBAGENT_MESSAGE_TIMEOUT_MS = CLAUDE_TURN_START_TIMEOUT_MS + CLAUDE_CONTROL_RESPONSE_TIMEOUT_MS + 30000;
|
|
239149
|
+
REMOTE_SUBAGENT_MESSAGE_DEDUPE_PENDING_TTL_MS = 5 * REMOTE_SUBAGENT_MESSAGE_TIMEOUT_MS;
|
|
239118
239150
|
});
|
|
239119
239151
|
|
|
239120
239152
|
// src/tools/impl/external-llm-trace-payload.ts
|
|
@@ -240584,7 +240616,7 @@ class CodexAppServerClient {
|
|
|
240584
240616
|
await this.request("initialize", {
|
|
240585
240617
|
clientInfo: {
|
|
240586
240618
|
name: "letta-code",
|
|
240587
|
-
version: "0.34.
|
|
240619
|
+
version: "0.34.64"
|
|
240588
240620
|
},
|
|
240589
240621
|
capabilities: null
|
|
240590
240622
|
});
|
|
@@ -242079,7 +242111,7 @@ ${SYSTEM_REMINDER_CLOSE}`;
|
|
|
242079
242111
|
return null;
|
|
242080
242112
|
}
|
|
242081
242113
|
}
|
|
242082
|
-
async function defaultListServerSideServers(agentId) {
|
|
242114
|
+
async function defaultListServerSideServers(agentId, timeoutMs = 3000) {
|
|
242083
242115
|
let serverSideAvailable = false;
|
|
242084
242116
|
try {
|
|
242085
242117
|
const { getBackend: getBackend2 } = await Promise.resolve().then(() => (init_backend2(), exports_backend));
|
|
@@ -242095,7 +242127,7 @@ async function defaultListServerSideServers(agentId) {
|
|
|
242095
242127
|
const { LETTA_CLOUD_API_URL: LETTA_CLOUD_API_URL2 } = await Promise.resolve().then(() => (init_oauth(), exports_oauth));
|
|
242096
242128
|
const { listUnifiedMcpServers: listUnifiedMcpServers2 } = await Promise.resolve().then(() => (init_unified_mcp(), exports_unified_mcp));
|
|
242097
242129
|
const client = await getClient2();
|
|
242098
|
-
const allServers = await listUnifiedMcpServers2(client, agentId,
|
|
242130
|
+
const allServers = await listUnifiedMcpServers2(client, agentId, timeoutMs);
|
|
242099
242131
|
const servers = getServerUrl2() === LETTA_CLOUD_API_URL2 ? allServers.filter((server2) => server2.serverType !== "stdio") : allServers;
|
|
242100
242132
|
return servers.map((server2) => ({
|
|
242101
242133
|
name: server2.serverName,
|
|
@@ -242109,26 +242141,20 @@ function formatMcpServerEntry(entry) {
|
|
|
242109
242141
|
return `${entry.name} (${entry.toolCount} ${entry.toolCount === 1 ? "tool" : "tools"})`;
|
|
242110
242142
|
}
|
|
242111
242143
|
function buildMcpServersReminderText(entries) {
|
|
242112
|
-
|
|
242113
|
-
return `${SYSTEM_REMINDER_OPEN}
|
|
242114
|
-
MCP servers with available tools: None
|
|
242115
|
-
Do not automatically store results of principal-restricted operations in shared memory.
|
|
242116
|
-
${SYSTEM_REMINDER_CLOSE}`;
|
|
242117
|
-
}
|
|
242118
|
-
const rendered = entries.map(formatMcpServerEntry).join(", ");
|
|
242144
|
+
const inventory = entries === null ? 'MCP server list could not be loaded. Run `letta mcp search "<what you want to do>"` to find tools.' : `MCP servers with available tools: ${entries.length ? entries.map(formatMcpServerEntry).join(", ") : "None"}`;
|
|
242119
242145
|
return `${SYSTEM_REMINDER_OPEN}
|
|
242120
|
-
|
|
242121
|
-
|
|
242122
|
-
|
|
242123
|
-
${SYSTEM_REMINDER_CLOSE}`;
|
|
242146
|
+
${inventory}
|
|
242147
|
+
${MCP_MEMORY_GUIDANCE}
|
|
242148
|
+
${entries?.length === 0 ? "" : `${MCP_TOOL_USAGE}
|
|
242149
|
+
`}${SYSTEM_REMINDER_CLOSE}`;
|
|
242124
242150
|
}
|
|
242125
|
-
async function listMcpServersForAgent(agentId, _state, deps = {}) {
|
|
242151
|
+
async function listMcpServersForAgent(agentId, _state, deps = {}, timeoutMs = 3000) {
|
|
242126
242152
|
const localNames = (deps.getLocalServerNames ?? ((id) => settingsManager.getMcpServers(id).map((server2) => server2.name)))(agentId);
|
|
242127
242153
|
const entries = localNames.map((name) => ({
|
|
242128
242154
|
name,
|
|
242129
242155
|
toolCount: null
|
|
242130
242156
|
}));
|
|
242131
|
-
const serverSideEntries = await (deps.listServerSideServers ?? defaultListServerSideServers)(agentId);
|
|
242157
|
+
const serverSideEntries = await (deps.listServerSideServers ?? defaultListServerSideServers)(agentId, timeoutMs);
|
|
242132
242158
|
if (serverSideEntries)
|
|
242133
242159
|
entries.push(...serverSideEntries);
|
|
242134
242160
|
return [...new Map(entries.map((entry) => [entry.name, entry])).values()];
|
|
@@ -242346,7 +242372,7 @@ function prependReminderPartsToContent(content, reminderParts) {
|
|
|
242346
242372
|
}
|
|
242347
242373
|
return [...reminderParts, { type: "text", text: text2 }];
|
|
242348
242374
|
}
|
|
242349
|
-
var PERMISSION_MODE_DESCRIPTIONS, MAX_COMMAND_REMINDERS_PER_TURN = 10, MAX_TOOLSET_REMINDERS_PER_TURN = 5, MAX_COMMAND_INPUT_CHARS = 2000, MAX_COMMAND_OUTPUT_CHARS = 4000, MAX_TOOL_LIST_CHARS = 3000, sharedReminderProviders;
|
|
242375
|
+
var MCP_MEMORY_GUIDANCE = "Do not automatically store results of principal-restricted operations in shared memory.", MCP_TOOL_USAGE = `Find tools (with schemas) with \`letta mcp search "<what you want to do>"\`, list one server's tools with \`letta mcp tools <server>\` (\`--full\` includes schemas, \`letta mcp schema <tool-name>\` fetches one), and invoke one with \`letta mcp call <tool-name> --args '{"key":"value"}'\`. For large or quote-heavy arguments, use \`--args-file <path>\` (\`-\` for stdin) instead of \`--args\`. Exit code 2 means the tool returned an error result: read its \`content\`, fix the arguments, and retry (exit 1 is a CLI/usage error).`, PERMISSION_MODE_DESCRIPTIONS, MAX_COMMAND_REMINDERS_PER_TURN = 10, MAX_TOOLSET_REMINDERS_PER_TURN = 5, MAX_COMMAND_INPUT_CHARS = 2000, MAX_COMMAND_OUTPUT_CHARS = 4000, MAX_TOOL_LIST_CHARS = 3000, sharedReminderProviders;
|
|
242350
242376
|
var init_engine = __esm(() => {
|
|
242351
242377
|
init_agent_info();
|
|
242352
242378
|
init_conversation_bootstrap();
|
|
@@ -243502,7 +243528,14 @@ function buildExternalCodingAgentMcpReminder(entries2) {
|
|
|
243502
243528
|
async function resolveExternalCodingAgentMcpReminder(parentAgentId, mcp, deps = {}) {
|
|
243503
243529
|
if (mcp?.inherit === false)
|
|
243504
243530
|
return;
|
|
243505
|
-
const
|
|
243531
|
+
const scopeAgentId = await getMcpScopeAgentId(parentAgentId, undefined, deps.lookupParentAgent);
|
|
243532
|
+
let inventory;
|
|
243533
|
+
try {
|
|
243534
|
+
inventory = await listMcpServersForAgent(scopeAgentId, createSharedReminderState(), deps, 5000);
|
|
243535
|
+
} catch (error4) {
|
|
243536
|
+
debugLog("mcp", "Failed to load worker MCP inventory: %s", error4);
|
|
243537
|
+
return buildMcpServersReminderText(null);
|
|
243538
|
+
}
|
|
243506
243539
|
return buildExternalCodingAgentMcpReminder(selectExternalCodingAgentMcpEntries(inventory, mcp?.servers));
|
|
243507
243540
|
}
|
|
243508
243541
|
function buildExternalCodingAgentCommand(options) {
|
|
@@ -243906,6 +243939,7 @@ var init_external_coding_agent = __esm(() => {
|
|
|
243906
243939
|
init_engine();
|
|
243907
243940
|
init_runtime_context();
|
|
243908
243941
|
init_secret_substitution();
|
|
243942
|
+
init_debug();
|
|
243909
243943
|
init_native_cli_env();
|
|
243910
243944
|
init_claude_stream_session();
|
|
243911
243945
|
init_codex_app_server();
|
|
@@ -245115,7 +245149,7 @@ async function fetchParentConversationMessages(params) {
|
|
|
245115
245149
|
}
|
|
245116
245150
|
return messages.reverse();
|
|
245117
245151
|
}
|
|
245118
|
-
function
|
|
245152
|
+
function contentText2(content) {
|
|
245119
245153
|
if (typeof content === "string")
|
|
245120
245154
|
return content;
|
|
245121
245155
|
if (!Array.isArray(content))
|
|
@@ -245141,7 +245175,7 @@ function renderToolCall(call) {
|
|
|
245141
245175
|
}
|
|
245142
245176
|
function renderToolResult(result3) {
|
|
245143
245177
|
const raw2 = result3.tool_return ?? result3.func_response;
|
|
245144
|
-
const text2 = typeof raw2 === "string" ? raw2 :
|
|
245178
|
+
const text2 = typeof raw2 === "string" ? raw2 : contentText2(raw2) || (raw2 == null ? "" : JSON.stringify(raw2));
|
|
245145
245179
|
return {
|
|
245146
245180
|
type: "tool_result",
|
|
245147
245181
|
call_id: result3.tool_call_id ?? undefined,
|
|
@@ -245177,11 +245211,11 @@ function userEvents(text2, speaker) {
|
|
|
245177
245211
|
function renderMessage(message2) {
|
|
245178
245212
|
switch (message2.message_type) {
|
|
245179
245213
|
case "user_message": {
|
|
245180
|
-
const text2 =
|
|
245214
|
+
const text2 = contentText2(message2.content).replace(SYSTEM_REMINDER_PATTERN, "").trim();
|
|
245181
245215
|
return userEvents(text2, message2.name ?? undefined);
|
|
245182
245216
|
}
|
|
245183
245217
|
case "assistant_message": {
|
|
245184
|
-
const text2 =
|
|
245218
|
+
const text2 = contentText2(message2.content).trim();
|
|
245185
245219
|
return text2 ? [
|
|
245186
245220
|
{
|
|
245187
245221
|
type: "message",
|
|
@@ -245327,7 +245361,7 @@ async function prependParentContext(params) {
|
|
|
245327
245361
|
prompt: [
|
|
245328
245362
|
"The following JSONL is a read-only record of the parent's conversation. The task after the history block tells you what to do now; use the history as the source for everything else. If the task conflicts with what people said in the history, follow what people said in the history. Do not resume unrelated work from the history.",
|
|
245329
245363
|
"Records marked injected came from the harness, not the human. Tool calls and results are linked by call_id. Records marked truncated have omitted content; use the commands below to read further.",
|
|
245330
|
-
`This shows the parent's current context: the latest compaction summary when available, followed by its most recent in-context messages, up to 50,000 characters (an oversized summary is kept whole). If context lookup failed, it shows a recent-history fallback instead. For earlier or omitted history, search with \`letta messages search --query "<words>" --agent ${params.parentAgentId} --conversation ${params.parentConversationId}\`, or page back with \`letta messages list --agent ${params.parentAgentId} --conversation ${params.parentConversationId}
|
|
245364
|
+
`This shows the parent's current context: the latest compaction summary when available, followed by its most recent in-context messages, up to 50,000 characters (an oversized summary is kept whole). If context lookup failed, it shows a recent-history fallback instead. For earlier or omitted history, search with \`letta messages search --query "<words>" --agent ${params.parentAgentId} --conversation ${params.parentConversationId}\`, or page back with \`letta messages list --agent ${params.parentAgentId} --conversation ${params.parentConversationId}\`.`,
|
|
245331
245365
|
"<parent_history>",
|
|
245332
245366
|
serializeHistoryRecord({
|
|
245333
245367
|
type: "metadata",
|
|
@@ -245344,13 +245378,25 @@ async function prependParentContext(params) {
|
|
|
245344
245378
|
`)
|
|
245345
245379
|
};
|
|
245346
245380
|
}
|
|
245381
|
+
function withReportBackInstruction(prompt, parentAgentId, parentConversationId) {
|
|
245382
|
+
if (!parentConversationId)
|
|
245383
|
+
return prompt;
|
|
245384
|
+
return [
|
|
245385
|
+
prompt,
|
|
245386
|
+
"",
|
|
245387
|
+
`When you open a pull request (draft or ready) or hit a blocker you can't get past, tell the parent right away, then keep working: run \`letta -p ${buildAgentSendCliTarget(parentAgentId, parentConversationId)} --no-wait "<what happened, with the link>. Tell the person who asked now; a draft is a result."\` (for a blocker, end with "Tell the person who asked now."). Use the same command to ask the parent something mid-task.`
|
|
245388
|
+
].join(`
|
|
245389
|
+
`);
|
|
245390
|
+
}
|
|
245347
245391
|
async function prepareExternalWorkerPrompt(params) {
|
|
245348
|
-
|
|
245349
|
-
|
|
245392
|
+
const parentConversationId = params.parentConversationId ?? getConversationId() ?? (params.forkContext ? "default" : undefined);
|
|
245393
|
+
const prompt = withReportBackInstruction(params.prompt, params.parentAgentId, parentConversationId);
|
|
245394
|
+
if (!params.forkContext || !parentConversationId)
|
|
245395
|
+
return { prompt };
|
|
245350
245396
|
return prependParentContext({
|
|
245351
|
-
prompt
|
|
245397
|
+
prompt,
|
|
245352
245398
|
parentAgentId: params.parentAgentId,
|
|
245353
|
-
parentConversationId
|
|
245399
|
+
parentConversationId,
|
|
245354
245400
|
signal: params.signal
|
|
245355
245401
|
});
|
|
245356
245402
|
}
|
|
@@ -245359,6 +245405,7 @@ var init_external_fork_context = __esm(() => {
|
|
|
245359
245405
|
init_context();
|
|
245360
245406
|
init_parent_transcript();
|
|
245361
245407
|
init_backend2();
|
|
245408
|
+
init_agent_message();
|
|
245362
245409
|
});
|
|
245363
245410
|
|
|
245364
245411
|
// src/tools/impl/fork-prompt.ts
|
|
@@ -245856,6 +245903,64 @@ function isVersionBelow(version3, minimum) {
|
|
|
245856
245903
|
return result3 === -1;
|
|
245857
245904
|
}
|
|
245858
245905
|
|
|
245906
|
+
// src/tools/impl/remote-connect-retry.ts
|
|
245907
|
+
import { setTimeout as delay5 } from "node:timers/promises";
|
|
245908
|
+
async function connectRemoteWorkerWithRetry(connect, signal) {
|
|
245909
|
+
const backoffs = [1000, 3000];
|
|
245910
|
+
for (let attempt2 = 0;; attempt2++) {
|
|
245911
|
+
signal?.throwIfAborted();
|
|
245912
|
+
try {
|
|
245913
|
+
return await connect();
|
|
245914
|
+
} catch (error4) {
|
|
245915
|
+
signal?.throwIfAborted();
|
|
245916
|
+
const message2 = error4 instanceof Error ? error4.message : String(error4);
|
|
245917
|
+
const status = extractHttpStatus(message2);
|
|
245918
|
+
const transient = status !== undefined ? status >= 500 : /ECONNRESET|ETIMEDOUT|ECONNREFUSED|EPIPE|EAI_AGAIN|ENETUNREACH|EHOSTUNREACH|socket closed|connection reset|timed out|closed before opening/i.test(message2);
|
|
245919
|
+
const backoff3 = backoffs[attempt2];
|
|
245920
|
+
if (!transient || backoff3 === undefined)
|
|
245921
|
+
throw error4;
|
|
245922
|
+
await delay5(backoff3, undefined, { signal });
|
|
245923
|
+
}
|
|
245924
|
+
}
|
|
245925
|
+
}
|
|
245926
|
+
var init_remote_connect_retry = __esm(() => {
|
|
245927
|
+
init_error_reporting();
|
|
245928
|
+
});
|
|
245929
|
+
|
|
245930
|
+
// src/tools/impl/remote-follow-up-retry.ts
|
|
245931
|
+
async function sendRemoteFollowUpWithReconnect(client, command, connect, attach, computer) {
|
|
245932
|
+
try {
|
|
245933
|
+
try {
|
|
245934
|
+
return await client.sendSubagentMessage(command, {
|
|
245935
|
+
timeoutMs: REMOTE_SUBAGENT_MESSAGE_TIMEOUT_MS
|
|
245936
|
+
});
|
|
245937
|
+
} catch (error4) {
|
|
245938
|
+
if (!(error4 instanceof Error) || error4.message !== "App-server socket closed")
|
|
245939
|
+
throw error4;
|
|
245940
|
+
client.close();
|
|
245941
|
+
const reconnected = await connect();
|
|
245942
|
+
attach(reconnected);
|
|
245943
|
+
return await reconnected.sendSubagentMessage(command, {
|
|
245944
|
+
timeoutMs: REMOTE_SUBAGENT_MESSAGE_TIMEOUT_MS
|
|
245945
|
+
});
|
|
245946
|
+
}
|
|
245947
|
+
} catch (error4) {
|
|
245948
|
+
if (error4 instanceof Error && error4.message === "App-server socket closed")
|
|
245949
|
+
throw new RemoteFollowUpSocketClosedError(`The connection to ${computer} dropped before it confirmed the follow-up, even after one retry. The message may not have been delivered; check the worker's output, or send it again.`);
|
|
245950
|
+
if (error4 instanceof Error && error4.message === `Timed out waiting for ${command.request_id}`)
|
|
245951
|
+
throw new RemoteFollowUpTimeoutError(`${computer} didn't confirm the follow-up within ${Math.round(REMOTE_SUBAGENT_MESSAGE_TIMEOUT_MS / 1000)}s. The message may not have been delivered; check the worker's output, or send it again.`);
|
|
245952
|
+
throw error4;
|
|
245953
|
+
}
|
|
245954
|
+
}
|
|
245955
|
+
var RemoteFollowUpTimeoutError, RemoteFollowUpSocketClosedError;
|
|
245956
|
+
var init_remote_follow_up_retry = __esm(() => {
|
|
245957
|
+
init_claude_steer_timeouts();
|
|
245958
|
+
RemoteFollowUpTimeoutError = class RemoteFollowUpTimeoutError extends Error {
|
|
245959
|
+
};
|
|
245960
|
+
RemoteFollowUpSocketClosedError = class RemoteFollowUpSocketClosedError extends Error {
|
|
245961
|
+
};
|
|
245962
|
+
});
|
|
245963
|
+
|
|
245859
245964
|
// src/tools/impl/remote-subagent-events.ts
|
|
245860
245965
|
function followRemoteSubagentEvents(subagentId, read2) {
|
|
245861
245966
|
let cursor = 0;
|
|
@@ -246000,7 +246105,11 @@ function classifyRemoteExternalWorkerControlError(error4) {
|
|
|
246000
246105
|
return "outdated_computer";
|
|
246001
246106
|
if (error4 instanceof RemoteFollowUpTimeoutError)
|
|
246002
246107
|
return "steer_timeout";
|
|
246108
|
+
if (error4 instanceof RemoteFollowUpSocketClosedError)
|
|
246109
|
+
return "socket_closed";
|
|
246003
246110
|
const message2 = errorMessage5(error4);
|
|
246111
|
+
if (message2 === "App-server socket closed")
|
|
246112
|
+
return "socket_closed";
|
|
246004
246113
|
if (message2 === CLAUDE_TURN_START_TIMEOUT_ERROR || message2 === CLAUDE_INTERRUPT_ACK_TIMEOUT_ERROR)
|
|
246005
246114
|
return "worker_busy";
|
|
246006
246115
|
if (/^Computer ".*" is offline(?:\.|$)/.test(message2) || message2.startsWith("Timed out waiting for cloud sandbox "))
|
|
@@ -246232,7 +246341,7 @@ async function launchRemoteExternalCodingAgent(params, deps) {
|
|
|
246232
246341
|
const toolCallId = params.toolCallId ?? `remote-${randomUUID46()}`;
|
|
246233
246342
|
let client;
|
|
246234
246343
|
try {
|
|
246235
|
-
client = await connect
|
|
246344
|
+
client = await connectRemoteWorkerWithRetry(connect, params.signal);
|
|
246236
246345
|
} catch (error4) {
|
|
246237
246346
|
return fail2("connect", `Can't reach ${computer}: ${errorMessage5(error4)}`);
|
|
246238
246347
|
}
|
|
@@ -246422,7 +246531,7 @@ async function deliverRemoteExternalCodingAgentMessage(params, deps) {
|
|
|
246422
246531
|
const bareAgentId = formatExternalCodingAgentId(target.type, target.sessionId);
|
|
246423
246532
|
let response;
|
|
246424
246533
|
try {
|
|
246425
|
-
response = await client
|
|
246534
|
+
response = await sendRemoteFollowUpWithReconnect(client, {
|
|
246426
246535
|
request_id: requestId,
|
|
246427
246536
|
runtime: {
|
|
246428
246537
|
agent_id: params.parentScope.agentId,
|
|
@@ -246432,12 +246541,9 @@ async function deliverRemoteExternalCodingAgentMessage(params, deps) {
|
|
|
246432
246541
|
agent_id: bareAgentId,
|
|
246433
246542
|
message: params.message,
|
|
246434
246543
|
tool_call_id: toolCallId
|
|
246435
|
-
},
|
|
246544
|
+
}, connect, (reconnected) => follower.attach(reconnected), target.computer);
|
|
246436
246545
|
} catch (error4) {
|
|
246437
246546
|
follower.close();
|
|
246438
|
-
if (errorMessage5(error4) === `Timed out waiting for ${requestId}`) {
|
|
246439
|
-
throw new RemoteFollowUpTimeoutError(`${target.computer} didn't confirm the follow-up within ${Math.round(REMOTE_SUBAGENT_MESSAGE_TIMEOUT_MS / 1000)}s. The message may not have been delivered; check the worker's output, or send it again.`);
|
|
246440
|
-
}
|
|
246441
246547
|
throw error4;
|
|
246442
246548
|
}
|
|
246443
246549
|
if (!response.success) {
|
|
@@ -246509,7 +246615,7 @@ async function deliverRemoteExternalCodingAgentMessage(params, deps) {
|
|
|
246509
246615
|
outputFile: tracked.outputFile
|
|
246510
246616
|
};
|
|
246511
246617
|
}
|
|
246512
|
-
var REMOTE_EXTERNAL_WORKER_STOPPED, DISPLAY_NAMES, RemoteWorkerLostError, OutdatedRemoteWorkerError,
|
|
246618
|
+
var REMOTE_EXTERNAL_WORKER_STOPPED, DISPLAY_NAMES, RemoteWorkerLostError, OutdatedRemoteWorkerError, MAX_RECONNECT_DELAY_MS = 30000;
|
|
246513
246619
|
var init_remote_external_coding_agent = __esm(() => {
|
|
246514
246620
|
init_subagent_state();
|
|
246515
246621
|
init_app_server_client();
|
|
@@ -246521,6 +246627,8 @@ var init_remote_external_coding_agent = __esm(() => {
|
|
|
246521
246627
|
init_error_reporting();
|
|
246522
246628
|
init_claude_steer_timeouts();
|
|
246523
246629
|
init_external_coding_agent();
|
|
246630
|
+
init_remote_connect_retry();
|
|
246631
|
+
init_remote_follow_up_retry();
|
|
246524
246632
|
init_remote_subagent_events();
|
|
246525
246633
|
REMOTE_EXTERNAL_WORKER_STOPPED = Symbol("remote external worker stopped");
|
|
246526
246634
|
DISPLAY_NAMES = {
|
|
@@ -246533,8 +246641,6 @@ var init_remote_external_coding_agent = __esm(() => {
|
|
|
246533
246641
|
};
|
|
246534
246642
|
OutdatedRemoteWorkerError = class OutdatedRemoteWorkerError extends Error {
|
|
246535
246643
|
};
|
|
246536
|
-
RemoteFollowUpTimeoutError = class RemoteFollowUpTimeoutError extends Error {
|
|
246537
|
-
};
|
|
246538
246644
|
});
|
|
246539
246645
|
|
|
246540
246646
|
// src/tools/impl/subagent-computer.ts
|
|
@@ -249395,7 +249501,7 @@ var init_github_pull_request_watch = __esm(() => {
|
|
|
249395
249501
|
});
|
|
249396
249502
|
|
|
249397
249503
|
// src/tools/impl/github-pull-request-cloud.ts
|
|
249398
|
-
import { setTimeout as
|
|
249504
|
+
import { setTimeout as delay6 } from "node:timers/promises";
|
|
249399
249505
|
async function requestSnapshot(ref, signal) {
|
|
249400
249506
|
const client = await getClient();
|
|
249401
249507
|
try {
|
|
@@ -249467,7 +249573,7 @@ function createGitHubPullRequestSnapshotFetcher(deps = {}) {
|
|
|
249467
249573
|
const now2 = deps.now ?? Date.now;
|
|
249468
249574
|
const random3 = deps.random ?? Math.random;
|
|
249469
249575
|
const wait = deps.wait ?? (async (ms, signal) => {
|
|
249470
|
-
await
|
|
249576
|
+
await delay6(ms, undefined, { signal });
|
|
249471
249577
|
});
|
|
249472
249578
|
let hasSnapshot = false;
|
|
249473
249579
|
let unsupported = false;
|
|
@@ -249820,7 +249926,7 @@ import {
|
|
|
249820
249926
|
writeFileSync as writeFileSync33
|
|
249821
249927
|
} from "node:fs";
|
|
249822
249928
|
import { dirname as dirname32, join as join74 } from "node:path";
|
|
249823
|
-
import { setTimeout as
|
|
249929
|
+
import { setTimeout as delay7 } from "node:timers/promises";
|
|
249824
249930
|
function errorText(error4) {
|
|
249825
249931
|
const message2 = error4 instanceof Error ? error4.message : String(error4);
|
|
249826
249932
|
return scrubSecretsFromString(message2, {}).replace(/\s+/g, " ").trim().slice(0, 500);
|
|
@@ -249829,7 +249935,7 @@ function pollDelayMs(failedPolls) {
|
|
|
249829
249935
|
return Math.min(WATCH_POLL_MS * 2 ** failedPolls, WATCH_MAX_POLL_MS);
|
|
249830
249936
|
}
|
|
249831
249937
|
async function defaultWait(signal, milliseconds) {
|
|
249832
|
-
await
|
|
249938
|
+
await delay7(milliseconds, undefined, { signal });
|
|
249833
249939
|
}
|
|
249834
249940
|
function saveSnapshot(path32, snapshot2) {
|
|
249835
249941
|
if (!path32)
|
|
@@ -250074,8 +250180,6 @@ ${event}
|
|
|
250074
250180
|
let freshnessNoticeSent = false;
|
|
250075
250181
|
let nextPollMs = WATCH_POLL_MS;
|
|
250076
250182
|
let failedPolls = 0;
|
|
250077
|
-
let failureStartedAt;
|
|
250078
|
-
let lastNotifiedError;
|
|
250079
250183
|
while (processState.status === "running") {
|
|
250080
250184
|
try {
|
|
250081
250185
|
await wait(controller.signal, nextPollMs);
|
|
@@ -250093,14 +250197,7 @@ ${event}
|
|
|
250093
250197
|
freshnessNoticeSent = false;
|
|
250094
250198
|
}
|
|
250095
250199
|
nextPollMs = WATCH_POLL_MS;
|
|
250096
|
-
if (lastNotifiedError !== undefined) {
|
|
250097
|
-
emit([
|
|
250098
|
-
`WatchPR recovered after ${failedPolls} failed poll${failedPolls === 1 ? "" : "s"}.`
|
|
250099
|
-
]);
|
|
250100
|
-
}
|
|
250101
250200
|
failedPolls = 0;
|
|
250102
|
-
failureStartedAt = undefined;
|
|
250103
|
-
lastNotifiedError = undefined;
|
|
250104
250201
|
const sameHead = current.headSha === previous.headSha;
|
|
250105
250202
|
const stableCurrent = { ...current, readinessConfirmed: false };
|
|
250106
250203
|
stableCurrent.readinessConfirmed = Boolean(sameHead && hasGitHubPullRequestReadyConditions(previous) && hasGitHubPullRequestReadyConditions(stableCurrent));
|
|
@@ -250141,7 +250238,6 @@ ${event}
|
|
|
250141
250238
|
}
|
|
250142
250239
|
failedPolls += 1;
|
|
250143
250240
|
nextPollMs = pollDelayMs(failedPolls);
|
|
250144
|
-
failureStartedAt ??= now2();
|
|
250145
250241
|
const message2 = errorText(error4);
|
|
250146
250242
|
if (!output.append(`[poll error ${failedPolls}] ${message2}
|
|
250147
250243
|
`)) {
|
|
@@ -250150,12 +250246,6 @@ ${event}
|
|
|
250150
250246
|
controller.abort();
|
|
250151
250247
|
return;
|
|
250152
250248
|
}
|
|
250153
|
-
if (now2() - failureStartedAt >= WATCH_REFRESH_ERROR_NOTIFY_AFTER_MS && message2 !== lastNotifiedError) {
|
|
250154
|
-
emit([
|
|
250155
|
-
`WatchPR could not refresh ${ref.url}: ${message2}. Retrying.`
|
|
250156
|
-
]);
|
|
250157
|
-
lastNotifiedError = message2;
|
|
250158
|
-
}
|
|
250159
250249
|
}
|
|
250160
250250
|
}
|
|
250161
250251
|
})().catch((error4) => {
|
|
@@ -250192,7 +250282,7 @@ Output file: ${outputFile}`
|
|
|
250192
250282
|
};
|
|
250193
250283
|
});
|
|
250194
250284
|
}
|
|
250195
|
-
var WATCH_POLL_MS = 30000, WATCH_MAX_POLL_MS,
|
|
250285
|
+
var WATCH_POLL_MS = 30000, WATCH_MAX_POLL_MS, WATCH_FRESH_SNAPSHOT_NOTIFY_AFTER_MS;
|
|
250196
250286
|
var init_watch_pr = __esm(() => {
|
|
250197
250287
|
init_monitors();
|
|
250198
250288
|
init_runtime_context();
|
|
@@ -250210,7 +250300,6 @@ var init_watch_pr = __esm(() => {
|
|
|
250210
250300
|
init_monitor_timeout();
|
|
250211
250301
|
init_process_manager();
|
|
250212
250302
|
WATCH_MAX_POLL_MS = 5 * 60000;
|
|
250213
|
-
WATCH_REFRESH_ERROR_NOTIFY_AFTER_MS = 5 * 60000;
|
|
250214
250303
|
WATCH_FRESH_SNAPSHOT_NOTIFY_AFTER_MS = 30 * 60000;
|
|
250215
250304
|
});
|
|
250216
250305
|
|
|
@@ -258075,11 +258164,11 @@ function scheduleDurableQueueRestore(listener, capacityReleased = true) {
|
|
|
258075
258164
|
clearDurableQueueRestoreRetry(listener);
|
|
258076
258165
|
return;
|
|
258077
258166
|
}
|
|
258078
|
-
const
|
|
258167
|
+
const delay8 = Math.min(DURABLE_QUEUE_RESTORE_MAX_RETRY_DELAY_MS, DURABLE_QUEUE_RESTORE_RETRY_DELAY_MS * 2 ** Math.min(failures - 1, 16));
|
|
258079
258168
|
listener.durableQueueRestoreTimer = setTimeout(() => {
|
|
258080
258169
|
listener.durableQueueRestoreTimer = undefined;
|
|
258081
258170
|
scheduleDurableQueueRestore(listener, false);
|
|
258082
|
-
},
|
|
258171
|
+
}, delay8);
|
|
258083
258172
|
listener.durableQueueRestoreTimer.unref?.();
|
|
258084
258173
|
} finally {
|
|
258085
258174
|
listener.durableQueueRestoreScheduled = false;
|
|
@@ -264896,7 +264985,7 @@ async function acquireRecoveryClaim(runtime, onLost = () => {}, dependencies = {
|
|
|
264896
264985
|
}
|
|
264897
264986
|
return null;
|
|
264898
264987
|
}
|
|
264899
|
-
const claim = new RecoveryClaim(runtime, runtime.agentId, runtime.conversationId, connectionId, connectionGeneration, response.token, response.fence, request4, dependencies.schedule ?? ((callback,
|
|
264988
|
+
const claim = new RecoveryClaim(runtime, runtime.agentId, runtime.conversationId, connectionId, connectionGeneration, response.token, response.fence, request4, dependencies.schedule ?? ((callback, delay8) => setTimeout(callback, delay8)), dependencies.cancel ?? ((timer) => clearTimeout(timer)), onLost, now2, requestedAt + RECOVERY_CLAIM_TTL_MS - RECOVERY_CLAIM_EXPIRY_MARGIN_MS);
|
|
264900
264989
|
runtime.listener.activeRecoveryClaims ??= new Set;
|
|
264901
264990
|
runtime.listener.activeRecoveryClaims.add(claim);
|
|
264902
264991
|
refusalCounts.delete(runtime.listener);
|
|
@@ -427784,12 +427873,12 @@ ${options.prefix}` : `
|
|
|
427784
427873
|
this.pendingTimeouts = /* @__PURE__ */ new Map;
|
|
427785
427874
|
this.logger = logger.hasLevel(3) ? logger : undefined;
|
|
427786
427875
|
}
|
|
427787
|
-
schedule(operationId,
|
|
427876
|
+
schedule(operationId, delay8, cb) {
|
|
427788
427877
|
const pendingTimeout = this.pendingTimeouts.get(operationId);
|
|
427789
427878
|
if (pendingTimeout) {
|
|
427790
427879
|
this.host.clearTimeout(pendingTimeout);
|
|
427791
427880
|
}
|
|
427792
|
-
this.pendingTimeouts.set(operationId, this.host.setTimeout(_ThrottledOperations.run,
|
|
427881
|
+
this.pendingTimeouts.set(operationId, this.host.setTimeout(_ThrottledOperations.run, delay8, operationId, this, cb));
|
|
427793
427882
|
if (this.logger) {
|
|
427794
427883
|
this.logger.info(`Scheduled: ${operationId}${pendingTimeout ? ", Cancelled earlier one" : ""}`);
|
|
427795
427884
|
}
|
|
@@ -427810,9 +427899,9 @@ ${options.prefix}` : `
|
|
|
427810
427899
|
}
|
|
427811
427900
|
};
|
|
427812
427901
|
var GcTimer = class _GcTimer {
|
|
427813
|
-
constructor(host,
|
|
427902
|
+
constructor(host, delay8, logger) {
|
|
427814
427903
|
this.host = host;
|
|
427815
|
-
this.delay =
|
|
427904
|
+
this.delay = delay8;
|
|
427816
427905
|
this.logger = logger;
|
|
427817
427906
|
}
|
|
427818
427907
|
scheduleCollect() {
|
|
@@ -435852,12 +435941,12 @@ Project '${project.projectName}' (${ProjectKind[project.projectKind]}) ${counter
|
|
|
435852
435941
|
const project = this.projectService.tryGetDefaultProjectForFile(fileName);
|
|
435853
435942
|
return project && { fileName, project };
|
|
435854
435943
|
}
|
|
435855
|
-
getDiagnostics(next,
|
|
435944
|
+
getDiagnostics(next, delay8, fileArgs) {
|
|
435856
435945
|
if (this.suppressDiagnosticEvents) {
|
|
435857
435946
|
return;
|
|
435858
435947
|
}
|
|
435859
435948
|
if (fileArgs.length > 0) {
|
|
435860
|
-
this.updateErrorCheck(next, fileArgs,
|
|
435949
|
+
this.updateErrorCheck(next, fileArgs, delay8);
|
|
435861
435950
|
}
|
|
435862
435951
|
}
|
|
435863
435952
|
change(args) {
|
|
@@ -436219,7 +436308,7 @@ Additional information: BADCLIENT: Bad error code, ${badCode} not found in range
|
|
|
436219
436308
|
const spans = languageService.getBraceMatchingAtPosition(file, position);
|
|
436220
436309
|
return !spans ? undefined : simplifiedResult ? spans.map((span) => toProtocolTextSpan(span, scriptInfo)) : spans;
|
|
436221
436310
|
}
|
|
436222
|
-
getDiagnosticsForProject(next,
|
|
436311
|
+
getDiagnosticsForProject(next, delay8, fileName) {
|
|
436223
436312
|
if (this.suppressDiagnosticEvents) {
|
|
436224
436313
|
return;
|
|
436225
436314
|
}
|
|
@@ -436253,7 +436342,7 @@ Additional information: BADCLIENT: Bad error code, ${badCode} not found in range
|
|
|
436253
436342
|
}
|
|
436254
436343
|
const sortedFiles = [...highPriorityFiles, ...mediumPriorityFiles, ...lowPriorityFiles, ...veryLowPriorityFiles];
|
|
436255
436344
|
const checkList = sortedFiles.map((fileName2) => ({ fileName: fileName2, project }));
|
|
436256
|
-
this.updateErrorCheck(next, checkList,
|
|
436345
|
+
this.updateErrorCheck(next, checkList, delay8, false);
|
|
436257
436346
|
}
|
|
436258
436347
|
configurePlugin(args) {
|
|
436259
436348
|
this.projectService.configurePlugin(args);
|
|
@@ -440559,7 +440648,7 @@ function scheduleRecoveredApprovalRetry(runtime, retry3) {
|
|
|
440559
440648
|
retryStates.delete(runtime);
|
|
440560
440649
|
return;
|
|
440561
440650
|
}
|
|
440562
|
-
const
|
|
440651
|
+
const delay8 = retryDelay(state2.attempt);
|
|
440563
440652
|
state2.attempt += 1;
|
|
440564
440653
|
state2.scheduled = true;
|
|
440565
440654
|
state2.timer = setTimeout(() => {
|
|
@@ -440568,7 +440657,7 @@ function scheduleRecoveredApprovalRetry(runtime, retry3) {
|
|
|
440568
440657
|
state2.timer = undefined;
|
|
440569
440658
|
state2.scheduled = false;
|
|
440570
440659
|
scheduleRecoveredApprovalRetry(runtime, state2.retry);
|
|
440571
|
-
},
|
|
440660
|
+
}, delay8);
|
|
440572
440661
|
state2.timer.unref?.();
|
|
440573
440662
|
};
|
|
440574
440663
|
state2.retry().then((handled) => {
|
|
@@ -446631,12 +446720,12 @@ function rowToolCalls(row, index, diagnostics2) {
|
|
|
446631
446720
|
}
|
|
446632
446721
|
return calls;
|
|
446633
446722
|
}
|
|
446634
|
-
function
|
|
446723
|
+
function contentText3(content) {
|
|
446635
446724
|
if (typeof content === "string") {
|
|
446636
446725
|
if (content.startsWith(CONTENT_JSON_PREFIX)) {
|
|
446637
446726
|
const encoded = content.slice(CONTENT_JSON_PREFIX.length);
|
|
446638
446727
|
try {
|
|
446639
|
-
return
|
|
446728
|
+
return contentText3(JSON.parse(encoded));
|
|
446640
446729
|
} catch {
|
|
446641
446730
|
return encoded;
|
|
446642
446731
|
}
|
|
@@ -446722,7 +446811,7 @@ var init_hermes = __esm(() => {
|
|
|
446722
446811
|
});
|
|
446723
446812
|
};
|
|
446724
446813
|
if (row.role === "user") {
|
|
446725
|
-
const content =
|
|
446814
|
+
const content = contentText3(row.content);
|
|
446726
446815
|
if (content) {
|
|
446727
446816
|
emit({
|
|
446728
446817
|
type: "message",
|
|
@@ -446742,7 +446831,7 @@ var init_hermes = __esm(() => {
|
|
|
446742
446831
|
...timestamp ? { timestamp } : {}
|
|
446743
446832
|
});
|
|
446744
446833
|
}
|
|
446745
|
-
const content =
|
|
446834
|
+
const content = contentText3(row.content);
|
|
446746
446835
|
if (content) {
|
|
446747
446836
|
emit({
|
|
446748
446837
|
type: "message",
|
|
@@ -446765,7 +446854,7 @@ var init_hermes = __esm(() => {
|
|
|
446765
446854
|
if (row.role === "tool") {
|
|
446766
446855
|
emit({
|
|
446767
446856
|
type: "tool_result",
|
|
446768
|
-
content:
|
|
446857
|
+
content: contentText3(row.content),
|
|
446769
446858
|
...typeof row.tool_call_id === "string" && row.tool_call_id ? { callId: row.tool_call_id } : {},
|
|
446770
446859
|
...timestamp ? { timestamp } : {}
|
|
446771
446860
|
});
|
|
@@ -453835,10 +453924,10 @@ async function registerWithCloudRetry(opts, callbacks) {
|
|
|
453835
453924
|
}
|
|
453836
453925
|
attempt2++;
|
|
453837
453926
|
const backoffDelay = Math.min(REGISTER_INITIAL_DELAY_MS * 2 ** (attempt2 - 1), REGISTER_MAX_DELAY_MS);
|
|
453838
|
-
const
|
|
453839
|
-
const jitterWindow = Math.min(REGISTER_MAX_JITTER_MS, Math.floor(
|
|
453927
|
+
const delay8 = error4 instanceof RegistrationError && error4.retryAfterMs !== undefined ? Math.max(error4.retryAfterMs, backoffDelay) : backoffDelay;
|
|
453928
|
+
const jitterWindow = Math.min(REGISTER_MAX_JITTER_MS, Math.floor(delay8 * REGISTER_JITTER_RATIO));
|
|
453840
453929
|
const jitter2 = jitterWindow > 0 ? Math.floor((callbacks?.random ?? Math.random)() * jitterWindow) : 0;
|
|
453841
|
-
const retryDelay2 =
|
|
453930
|
+
const retryDelay2 = delay8 + jitter2;
|
|
453842
453931
|
if (error4 instanceof Error) {
|
|
453843
453932
|
callbacks?.onRetry?.(attempt2, retryDelay2, error4);
|
|
453844
453933
|
}
|
|
@@ -460692,7 +460781,7 @@ function applyCatalogModels(next, options = {}) {
|
|
|
460692
460781
|
}
|
|
460693
460782
|
if (options.requireManagedDefault !== false) {
|
|
460694
460783
|
const defaults6 = next.filter((model2) => model2.isDefault || model2.id === "auto");
|
|
460695
|
-
if (defaults6.length
|
|
460784
|
+
if (defaults6.length === 0) {
|
|
460696
460785
|
return false;
|
|
460697
460786
|
}
|
|
460698
460787
|
}
|
|
@@ -463131,6 +463220,7 @@ async function stopMonitor(command) {
|
|
|
463131
463220
|
actingUserId: command.runtime.acting_user_id,
|
|
463132
463221
|
text: formatMonitorEventNotification({
|
|
463133
463222
|
taskId: command.process_id,
|
|
463223
|
+
description: process21.description,
|
|
463134
463224
|
event: "The user cancelled this Monitor. Do not restart it unless the user asks."
|
|
463135
463225
|
})
|
|
463136
463226
|
});
|
|
@@ -463347,12 +463437,19 @@ async function handleSubagentMessageCommand(command, parent, deps = {}) {
|
|
|
463347
463437
|
}
|
|
463348
463438
|
})();
|
|
463349
463439
|
responses.set(key4, {
|
|
463350
|
-
expiresAt: now2 +
|
|
463440
|
+
expiresAt: now2 + REMOTE_SUBAGENT_MESSAGE_DEDUPE_PENDING_TTL_MS,
|
|
463351
463441
|
response
|
|
463352
463442
|
});
|
|
463353
463443
|
const result3 = await response;
|
|
463354
|
-
if (
|
|
463355
|
-
|
|
463444
|
+
if (responses.get(key4)?.response === response) {
|
|
463445
|
+
if (!result3.success)
|
|
463446
|
+
responses.delete(key4);
|
|
463447
|
+
else
|
|
463448
|
+
responses.set(key4, {
|
|
463449
|
+
expiresAt: (deps.now ?? Date.now)() + DEDUPE_TTL_MS,
|
|
463450
|
+
response
|
|
463451
|
+
});
|
|
463452
|
+
}
|
|
463356
463453
|
return result3;
|
|
463357
463454
|
}
|
|
463358
463455
|
async function handleSubagentStopCommand(command, parent) {
|
|
@@ -463412,6 +463509,7 @@ var DEDUPE_TTL_MS = 30000, responses;
|
|
|
463412
463509
|
var init_subagent_control = __esm(() => {
|
|
463413
463510
|
init_subagent_state();
|
|
463414
463511
|
init_runtime_context();
|
|
463512
|
+
init_claude_steer_timeouts();
|
|
463415
463513
|
init_claude_stream_session();
|
|
463416
463514
|
init_codex_app_server();
|
|
463417
463515
|
init_cursor_session();
|
|
@@ -463527,6 +463625,7 @@ var exports_task_control = {};
|
|
|
463527
463625
|
__export(exports_task_control, {
|
|
463528
463626
|
handleTaskControlCommand: () => handleTaskControlCommand
|
|
463529
463627
|
});
|
|
463628
|
+
import WebSocket12 from "ws";
|
|
463530
463629
|
async function handleTaskControlCommand(command, context3) {
|
|
463531
463630
|
const {
|
|
463532
463631
|
runtime,
|
|
@@ -463536,12 +463635,17 @@ async function handleTaskControlCommand(command, context3) {
|
|
|
463536
463635
|
runDetachedListenerTask: runDetachedListenerTask2,
|
|
463537
463636
|
safeSocketSend
|
|
463538
463637
|
} = context3;
|
|
463638
|
+
const arrivedOnRelay = connectionId !== undefined && connectionId === runtime.connectionId;
|
|
463639
|
+
const sendReply = (response) => {
|
|
463640
|
+
const replySocket = socket.readyState !== WebSocket12.OPEN && arrivedOnRelay && runtime.socket?.readyState === WebSocket12.OPEN ? runtime.socket : socket;
|
|
463641
|
+
safeSocketSend(replySocket, response, response.type, command.type);
|
|
463642
|
+
};
|
|
463539
463643
|
const execute = async () => {
|
|
463540
463644
|
if (command.type === "subagent_stop" && command.conversation) {
|
|
463541
463645
|
const response2 = await stopListenerConversation(command, context3.abortConversation ?? (async () => {
|
|
463542
463646
|
throw new Error("Listener cancellation is unavailable");
|
|
463543
463647
|
}));
|
|
463544
|
-
|
|
463648
|
+
sendReply(response2);
|
|
463545
463649
|
return;
|
|
463546
463650
|
}
|
|
463547
463651
|
if (command.type === "monitor_stop") {
|
|
@@ -463556,7 +463660,7 @@ async function handleTaskControlCommand(command, context3) {
|
|
|
463556
463660
|
}
|
|
463557
463661
|
const parent = getOrCreateScopedRuntime2(runtime, command.runtime.agent_id, command.runtime.conversation_id);
|
|
463558
463662
|
const response = command.type === "launch_subagent" ? await handleLaunchSubagentCommand(command, parent, connectionId) : command.type === "subagent_message" ? await handleSubagentMessageCommand(command, parent) : await handleSubagentStopCommand(command, parent);
|
|
463559
|
-
|
|
463663
|
+
sendReply(response);
|
|
463560
463664
|
};
|
|
463561
463665
|
if (command.type === "launch_subagent" || command.type === "subagent_message") {
|
|
463562
463666
|
runDetachedListenerTask2(command.type, execute);
|
|
@@ -465034,9 +465138,9 @@ var init_restored_queue_pump = __esm(() => {
|
|
|
465034
465138
|
});
|
|
465035
465139
|
|
|
465036
465140
|
// src/websocket/listener/socket-send.ts
|
|
465037
|
-
import
|
|
465141
|
+
import WebSocket13 from "ws";
|
|
465038
465142
|
function safeSocketSend(socket, payload, errorType, context3) {
|
|
465039
|
-
if (socket.readyState !==
|
|
465143
|
+
if (socket.readyState !== WebSocket13.OPEN)
|
|
465040
465144
|
return false;
|
|
465041
465145
|
try {
|
|
465042
465146
|
const serialized = typeof payload === "string" ? payload : JSON.stringify(payload);
|
|
@@ -465331,7 +465435,7 @@ var init_sync_replay = __esm(() => {
|
|
|
465331
465435
|
});
|
|
465332
465436
|
|
|
465333
465437
|
// src/websocket/listener/lifecycle.ts
|
|
465334
|
-
import
|
|
465438
|
+
import WebSocket14 from "ws";
|
|
465335
465439
|
function createRuntime() {
|
|
465336
465440
|
const bootWorkingDirectory = getCurrentWorkingDirectory();
|
|
465337
465441
|
return {
|
|
@@ -465601,7 +465705,7 @@ async function attachOpenListenerSocket(runtime, socket, opts, options = {}) {
|
|
|
465601
465705
|
abortStartupIngress();
|
|
465602
465706
|
return;
|
|
465603
465707
|
}
|
|
465604
|
-
const streamTransport = streamSocket?.readyState ===
|
|
465708
|
+
const streamTransport = streamSocket?.readyState === WebSocket14.OPEN ? streamSocket : null;
|
|
465605
465709
|
await startConnectedListenerRuntime(runtime, transport3, opts, processQueuedTurn, {
|
|
465606
465710
|
startHeartbeat: options.startHeartbeat ?? false,
|
|
465607
465711
|
startCronScheduler: options.startCronScheduler ?? true,
|
|
@@ -465686,10 +465790,10 @@ async function connectWithRetry(runtime, opts, attempt2 = 0, startTime = Date.no
|
|
|
465686
465790
|
opts.onError(new Error("Failed to connect after 5 minutes of retrying"));
|
|
465687
465791
|
return;
|
|
465688
465792
|
}
|
|
465689
|
-
const
|
|
465690
|
-
opts.onRetrying?.(attempt2, MAX_RETRY_ATTEMPTS,
|
|
465793
|
+
const delay8 = Math.min(INITIAL_RETRY_DELAY_MS2 * 2 ** (attempt2 - 1), MAX_RETRY_DELAY_MS);
|
|
465794
|
+
opts.onRetrying?.(attempt2, MAX_RETRY_ATTEMPTS, delay8, opts.connectionId);
|
|
465691
465795
|
await new Promise((resolve39) => {
|
|
465692
|
-
runtime.reconnectTimeout = setTimeout(resolve39,
|
|
465796
|
+
runtime.reconnectTimeout = setTimeout(resolve39, delay8);
|
|
465693
465797
|
});
|
|
465694
465798
|
runtime.reconnectTimeout = null;
|
|
465695
465799
|
if (runtime !== getActiveRuntime() || runtime.intentionallyClosed) {
|
|
@@ -465872,7 +465976,7 @@ async function connectWithRetry(runtime, opts, attempt2 = 0, startTime = Date.no
|
|
|
465872
465976
|
streamSocket.removeAllListeners("message");
|
|
465873
465977
|
streamSocket.removeAllListeners("open");
|
|
465874
465978
|
streamSocket.removeAllListeners("close");
|
|
465875
|
-
if (streamSocket.readyState ===
|
|
465979
|
+
if (streamSocket.readyState === WebSocket14.OPEN || streamSocket.readyState === WebSocket14.CONNECTING) {
|
|
465876
465980
|
streamSocket.close();
|
|
465877
465981
|
}
|
|
465878
465982
|
}
|
|
@@ -466997,7 +467101,7 @@ __export(exports_app_server, {
|
|
|
466997
467101
|
});
|
|
466998
467102
|
import { createServer as createServer7 } from "node:http";
|
|
466999
467103
|
import { hostname as hostname4 } from "node:os";
|
|
467000
|
-
import
|
|
467104
|
+
import WebSocket15, { WebSocketServer } from "ws";
|
|
467001
467105
|
function getRequiredAddressInfo(server2) {
|
|
467002
467106
|
const address = server2.address();
|
|
467003
467107
|
if (!address || typeof address === "string") {
|
|
@@ -467013,12 +467117,12 @@ function getWebSocketUrl(baseUrl, path46) {
|
|
|
467013
467117
|
function closeSocket(socket, code = 1001, reason = "closing") {
|
|
467014
467118
|
if (!socket)
|
|
467015
467119
|
return;
|
|
467016
|
-
if (socket.readyState ===
|
|
467120
|
+
if (socket.readyState === WebSocket15.OPEN || socket.readyState === WebSocket15.CONNECTING) {
|
|
467017
467121
|
socket.close(code, reason);
|
|
467018
467122
|
}
|
|
467019
467123
|
}
|
|
467020
467124
|
function terminateSocket(socket) {
|
|
467021
|
-
if (!socket || socket.readyState ===
|
|
467125
|
+
if (!socket || socket.readyState === WebSocket15.CLOSED)
|
|
467022
467126
|
return;
|
|
467023
467127
|
socket.terminate();
|
|
467024
467128
|
}
|
|
@@ -467205,7 +467309,7 @@ async function startAppServer(options = {}) {
|
|
|
467205
467309
|
client.terminate();
|
|
467206
467310
|
continue;
|
|
467207
467311
|
}
|
|
467208
|
-
if (client.readyState ===
|
|
467312
|
+
if (client.readyState === WebSocket15.OPEN) {
|
|
467209
467313
|
const sentAt = Date.now();
|
|
467210
467314
|
client.ping();
|
|
467211
467315
|
watchdog?.recordPing(sentAt);
|
|
@@ -477969,7 +478073,7 @@ async function runUsageSubcommand(argv) {
|
|
|
477969
478073
|
console.log(`Usage:
|
|
477970
478074
|
letta usage
|
|
477971
478075
|
|
|
477972
|
-
Show a Markdown overview of your plan
|
|
478076
|
+
Show a Markdown overview of your plan and remaining credit balance.
|
|
477973
478077
|
Local backend: model usage requires BYOK.
|
|
477974
478078
|
|
|
477975
478079
|
Options:
|
|
@@ -477983,20 +478087,12 @@ Options:
|
|
|
477983
478087
|
await settingsManager.initialize();
|
|
477984
478088
|
await getClient();
|
|
477985
478089
|
await settingsManager.flush();
|
|
477986
|
-
const
|
|
477987
|
-
getBalanceMetadata(),
|
|
477988
|
-
getModelQuotaMetadata()
|
|
477989
|
-
]);
|
|
478090
|
+
const balance = await getBalanceMetadata();
|
|
477990
478091
|
const usage = `# Letta usage overview
|
|
477991
478092
|
Current plan: ${balance.billing_tier}
|
|
477992
478093
|
|
|
477993
478094
|
## Usage Credits (non-BYOK models)
|
|
477994
478095
|
* Balance: ${balance.total_balance} credits
|
|
477995
|
-
|
|
477996
|
-
## Usage Quota (\`letta/*\` models)
|
|
477997
|
-
* Bucket (full/high/medium/low/empty): ${quota.lettaTier.bucket} (daily: ${quota.lettaTier.dailyBucket ?? "Unavailable"})
|
|
477998
|
-
* Quota Window End: ${quota.quotaWindowEnd}
|
|
477999
|
-
* Daily Quota Window End: ${quota.dailyQuotaWindowEnd ?? "Unavailable"}
|
|
478000
478096
|
`;
|
|
478001
478097
|
await new Promise((resolve42, reject2) => {
|
|
478002
478098
|
process.stdout.write(usage, (error4) => error4 ? reject2(error4) : resolve42());
|
|
@@ -482264,7 +482360,7 @@ async function handleChannelsSlashCommand(runtime, args) {
|
|
|
482264
482360
|
|
|
482265
482361
|
// src/channels/gateway-local.ts
|
|
482266
482362
|
import { createHash as createHash23 } from "node:crypto";
|
|
482267
|
-
import
|
|
482363
|
+
import WebSocket16 from "ws";
|
|
482268
482364
|
async function executeChannelServiceCommand(command) {
|
|
482269
482365
|
if (!isDetachedChannelsCommand(command)) {
|
|
482270
482366
|
throw new Error(`Unsupported ChannelGateway command: ${command.type}`);
|
|
@@ -482335,7 +482431,7 @@ async function startLocalChannelGateway(options) {
|
|
|
482335
482431
|
await settingsManager.initialize();
|
|
482336
482432
|
const client = createAppServerClient({
|
|
482337
482433
|
url: options.appServerUrl,
|
|
482338
|
-
WebSocket:
|
|
482434
|
+
WebSocket: WebSocket16
|
|
482339
482435
|
});
|
|
482340
482436
|
await client.connect();
|
|
482341
482437
|
let serverInfo;
|
|
@@ -530852,9 +530948,9 @@ function App2({
|
|
|
530852
530948
|
}
|
|
530853
530949
|
const elapsedSinceClear = Date.now() - lastClearAtRef.current;
|
|
530854
530950
|
const rateLimitDelay = elapsedSinceClear >= MIN_CLEAR_INTERVAL_MS ? 0 : MIN_CLEAR_INTERVAL_MS - elapsedSinceClear;
|
|
530855
|
-
const
|
|
530951
|
+
const delay8 = Math.max(RESIZE_SETTLE_MS, rateLimitDelay);
|
|
530856
530952
|
if (debugFlicker) {
|
|
530857
|
-
console.error(`[debug:flicker:resize-schedule] target=${targetColumns} delay=${
|
|
530953
|
+
console.error(`[debug:flicker:resize-schedule] target=${targetColumns} delay=${delay8}ms elapsedSinceClear=${elapsedSinceClear}ms`);
|
|
530858
530954
|
}
|
|
530859
530955
|
resizeClearTimeout.current = setTimeout(() => {
|
|
530860
530956
|
resizeClearTimeout.current = null;
|
|
@@ -530874,7 +530970,7 @@ function App2({
|
|
|
530874
530970
|
console.error(`[debug:flicker:resize-fire] clear target=${targetColumns}`);
|
|
530875
530971
|
}
|
|
530876
530972
|
clearAndRemount(targetColumns);
|
|
530877
|
-
},
|
|
530973
|
+
}, delay8);
|
|
530878
530974
|
}, [clearAndRemount, debugFlicker]);
|
|
530879
530975
|
import_react124.useEffect(() => {
|
|
530880
530976
|
const prev = prevColumnsRef.current;
|
|
@@ -531380,11 +531476,11 @@ function App2({
|
|
|
531380
531476
|
import_react124.useEffect(() => {
|
|
531381
531477
|
if (deferredCommitAt === null)
|
|
531382
531478
|
return;
|
|
531383
|
-
const
|
|
531479
|
+
const delay8 = Math.max(0, deferredCommitAt - Date.now());
|
|
531384
531480
|
const timer = setTimeout(() => {
|
|
531385
531481
|
setDeferredCommitAt(null);
|
|
531386
531482
|
refreshDerived();
|
|
531387
|
-
},
|
|
531483
|
+
}, delay8);
|
|
531388
531484
|
return () => clearTimeout(timer);
|
|
531389
531485
|
}, [deferredCommitAt, refreshDerived]);
|
|
531390
531486
|
const streamingRefreshTimeoutRef = import_react124.useRef(null);
|
|
@@ -533382,7 +533478,7 @@ USAGE
|
|
|
533382
533478
|
letta memory ... Memory filesystem subcommands
|
|
533383
533479
|
letta agents ... Agents subcommands (JSON-only)
|
|
533384
533480
|
letta model ... Get, list, or set models and reasoning (JSON-only)
|
|
533385
|
-
letta usage Show account
|
|
533481
|
+
letta usage Show account plan and remaining credits (Markdown)
|
|
533386
533482
|
letta computers ... List available remote computers (JSON-only)
|
|
533387
533483
|
letta teleport ... Move the current conversation between computers
|
|
533388
533484
|
letta messages ... Messages subcommands (JSON-only)
|
|
@@ -537329,4 +537425,4 @@ function registerBunOAuthFlows() {
|
|
|
537329
537425
|
registerBunOAuthFlows();
|
|
537330
537426
|
await init_src5().then(() => exports_src2);
|
|
537331
537427
|
|
|
537332
|
-
//# debugId=
|
|
537428
|
+
//# debugId=E9010BF867CFE3EB64756E2164756E21
|