@letta-ai/letta-code 0.29.1 → 0.29.2
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/app-server-client.js +10 -1
- package/dist/app-server-client.js.map +3 -3
- package/dist/types/app-server-client.d.ts +2 -1
- package/dist/types/app-server-client.d.ts.map +1 -1
- package/dist/types/types/app-server-info.d.ts +23 -0
- package/dist/types/types/app-server-info.d.ts.map +1 -0
- package/dist/types/types/app-server-protocol.d.ts +2 -0
- package/dist/types/types/app-server-protocol.d.ts.map +1 -1
- package/dist/types/types/conversation-fork-protocol.d.ts +9 -0
- package/dist/types/types/conversation-fork-protocol.d.ts.map +1 -0
- package/dist/types/types/protocol_v2.d.ts +4 -8
- package/dist/types/types/protocol_v2.d.ts.map +1 -1
- package/letta.js +288 -97
- package/package.json +5 -5
- package/scripts/source-file-size-baseline.json +1 -1
package/letta.js
CHANGED
|
@@ -5462,7 +5462,7 @@ var package_default;
|
|
|
5462
5462
|
var init_package = __esm(() => {
|
|
5463
5463
|
package_default = {
|
|
5464
5464
|
name: "@letta-ai/letta-code",
|
|
5465
|
-
version: "0.29.
|
|
5465
|
+
version: "0.29.2",
|
|
5466
5466
|
description: "Letta Code is a CLI tool for interacting with stateful Letta agents from the terminal.",
|
|
5467
5467
|
type: "module",
|
|
5468
5468
|
packageManager: "bun@1.3.0",
|
|
@@ -5492,7 +5492,7 @@ var init_package = __esm(() => {
|
|
|
5492
5492
|
exports: {
|
|
5493
5493
|
".": "./letta.js",
|
|
5494
5494
|
"./app-server-protocol": {
|
|
5495
|
-
types: "./dist/types/app-server-protocol.d.ts"
|
|
5495
|
+
types: "./dist/types/types/app-server-protocol.d.ts"
|
|
5496
5496
|
},
|
|
5497
5497
|
"./app-server-client": {
|
|
5498
5498
|
types: "./dist/types/app-server-client.d.ts",
|
|
@@ -5500,7 +5500,7 @@ var init_package = __esm(() => {
|
|
|
5500
5500
|
import: "./dist/app-server-client.js"
|
|
5501
5501
|
},
|
|
5502
5502
|
"./protocol": {
|
|
5503
|
-
types: "./dist/types/protocol.d.ts"
|
|
5503
|
+
types: "./dist/types/types/protocol.d.ts"
|
|
5504
5504
|
},
|
|
5505
5505
|
"./agent-presets": {
|
|
5506
5506
|
types: "./dist/types/agent-presets.d.ts",
|
|
@@ -5613,7 +5613,7 @@ var init_package = __esm(() => {
|
|
|
5613
5613
|
"./dist/types/agent-presets.d.ts"
|
|
5614
5614
|
],
|
|
5615
5615
|
"app-server-protocol": [
|
|
5616
|
-
"./dist/types/app-server-protocol.d.ts"
|
|
5616
|
+
"./dist/types/types/app-server-protocol.d.ts"
|
|
5617
5617
|
],
|
|
5618
5618
|
"app-server-client": [
|
|
5619
5619
|
"./dist/types/app-server-client.d.ts"
|
|
@@ -5625,7 +5625,7 @@ var init_package = __esm(() => {
|
|
|
5625
5625
|
"./dist/types/channels-slack.d.ts"
|
|
5626
5626
|
],
|
|
5627
5627
|
protocol: [
|
|
5628
|
-
"./dist/types/protocol.d.ts"
|
|
5628
|
+
"./dist/types/types/protocol.d.ts"
|
|
5629
5629
|
]
|
|
5630
5630
|
}
|
|
5631
5631
|
}
|
|
@@ -163511,7 +163511,8 @@ __export(exports_conversations, {
|
|
|
163511
163511
|
async function forkConversation(conversationId, options3 = {}) {
|
|
163512
163512
|
const query2 = {
|
|
163513
163513
|
...options3.agentId ? { agent_id: options3.agentId } : {},
|
|
163514
|
-
...options3.hidden !== undefined ? { hidden: options3.hidden } : {}
|
|
163514
|
+
...options3.hidden !== undefined ? { hidden: options3.hidden } : {},
|
|
163515
|
+
...options3.messageId ? { message_id: options3.messageId } : {}
|
|
163515
163516
|
};
|
|
163516
163517
|
return apiRequest("POST", `/v1/conversations/${encodeURIComponent(conversationId)}/fork`, undefined, { query: query2, ...options3.headers ? { headers: options3.headers } : {} });
|
|
163517
163518
|
}
|
|
@@ -170213,7 +170214,13 @@ class TurnLifecycle {
|
|
|
170213
170214
|
return this.#lastStopReason;
|
|
170214
170215
|
}
|
|
170215
170216
|
get currentLease() {
|
|
170216
|
-
|
|
170217
|
+
if (this.#state.kind === "active") {
|
|
170218
|
+
return this.#state.lease;
|
|
170219
|
+
}
|
|
170220
|
+
if (this.#state.kind === "cancelling" && !this.#state.ownerFinished) {
|
|
170221
|
+
return this.#state.lease;
|
|
170222
|
+
}
|
|
170223
|
+
return null;
|
|
170217
170224
|
}
|
|
170218
170225
|
snapshot() {
|
|
170219
170226
|
const state = this.#state;
|
|
@@ -170263,7 +170270,7 @@ class TurnLifecycle {
|
|
|
170263
170270
|
return lease;
|
|
170264
170271
|
}
|
|
170265
170272
|
isCurrent(lease) {
|
|
170266
|
-
return (this.#state.kind === "active" || this.#state.kind === "cancelling") && this.#state.lease.id === lease.id;
|
|
170273
|
+
return (this.#state.kind === "active" || this.#state.kind === "cancelling") && (this.#state.kind !== "cancelling" || !this.#state.ownerFinished) && this.#state.lease.id === lease.id;
|
|
170267
170274
|
}
|
|
170268
170275
|
setStatus(lease, status) {
|
|
170269
170276
|
if (this.#state.kind !== "active" || !this.isCurrent(lease)) {
|
|
@@ -170319,7 +170326,7 @@ class TurnLifecycle {
|
|
|
170319
170326
|
this.#state = IDLE_STATE;
|
|
170320
170327
|
return true;
|
|
170321
170328
|
}
|
|
170322
|
-
requestCancellation() {
|
|
170329
|
+
requestCancellation(options3) {
|
|
170323
170330
|
const state = this.#state;
|
|
170324
170331
|
if (state.kind === "cancelling") {
|
|
170325
170332
|
return {
|
|
@@ -170348,7 +170355,9 @@ class TurnLifecycle {
|
|
|
170348
170355
|
abortController: state.abortController,
|
|
170349
170356
|
runId: state.runId,
|
|
170350
170357
|
executingToolCallIds: [...state.executingToolCallIds],
|
|
170351
|
-
loopStatus: "WAITING_ON_INPUT"
|
|
170358
|
+
loopStatus: "WAITING_ON_INPUT",
|
|
170359
|
+
ownerFinished: false,
|
|
170360
|
+
externalSettlementPending: options3?.waitForExternalSettlement === true
|
|
170352
170361
|
};
|
|
170353
170362
|
return {
|
|
170354
170363
|
transitioned: true,
|
|
@@ -170359,17 +170368,39 @@ class TurnLifecycle {
|
|
|
170359
170368
|
}
|
|
170360
170369
|
finish(lease, stopReason) {
|
|
170361
170370
|
const state = this.#state;
|
|
170362
|
-
if (state.kind !== "active" && state.kind !== "cancelling" || state.lease.id !== lease.id) {
|
|
170371
|
+
if (state.kind !== "active" && state.kind !== "cancelling" || state.lease.id !== lease.id || state.kind === "cancelling" && state.ownerFinished) {
|
|
170363
170372
|
return { finished: false, previousKind: null, runId: null };
|
|
170364
170373
|
}
|
|
170365
170374
|
this.#lastStopReason = stopReason;
|
|
170366
|
-
|
|
170375
|
+
if (state.kind === "cancelling" && state.externalSettlementPending) {
|
|
170376
|
+
this.#state = {
|
|
170377
|
+
...state,
|
|
170378
|
+
ownerFinished: true
|
|
170379
|
+
};
|
|
170380
|
+
} else {
|
|
170381
|
+
this.#state = IDLE_STATE;
|
|
170382
|
+
}
|
|
170367
170383
|
return {
|
|
170368
170384
|
finished: true,
|
|
170369
170385
|
previousKind: state.kind,
|
|
170370
170386
|
runId: state.runId
|
|
170371
170387
|
};
|
|
170372
170388
|
}
|
|
170389
|
+
settleCancellation(lease) {
|
|
170390
|
+
const state = this.#state;
|
|
170391
|
+
if (state.kind !== "cancelling" || state.lease.id !== lease.id || !state.externalSettlementPending) {
|
|
170392
|
+
return { settled: false, released: false };
|
|
170393
|
+
}
|
|
170394
|
+
if (state.ownerFinished) {
|
|
170395
|
+
this.#state = IDLE_STATE;
|
|
170396
|
+
return { settled: true, released: true };
|
|
170397
|
+
}
|
|
170398
|
+
this.#state = {
|
|
170399
|
+
...state,
|
|
170400
|
+
externalSettlementPending: false
|
|
170401
|
+
};
|
|
170402
|
+
return { settled: true, released: false };
|
|
170403
|
+
}
|
|
170373
170404
|
reset(stopReason = "cancelled") {
|
|
170374
170405
|
const state = this.#state;
|
|
170375
170406
|
if (state.kind === "active" || state.kind === "cancelling") {
|
|
@@ -373430,54 +373461,11 @@ var init_memory_git = __esm(() => {
|
|
|
373430
373461
|
NO_UPSTREAM_PULL_ERROR_RE = /(there is no tracking information for the current branch|no upstream configured|no tracking branch)/i;
|
|
373431
373462
|
});
|
|
373432
373463
|
|
|
373433
|
-
// src/backend/local/local-conversation-list.ts
|
|
373434
|
-
function optionalString(value) {
|
|
373435
|
-
return typeof value === "string" ? value : undefined;
|
|
373436
|
-
}
|
|
373437
|
-
function matchesSummarySearch(conversation, normalizedSearch) {
|
|
373438
|
-
if (!normalizedSearch)
|
|
373439
|
-
return true;
|
|
373440
|
-
return conversation.id.toLowerCase().includes(normalizedSearch) || (conversation.summary?.toLowerCase().includes(normalizedSearch) ?? false);
|
|
373441
|
-
}
|
|
373442
|
-
function listLocalConversations(source2, body) {
|
|
373443
|
-
const bodyRecord = body ?? {};
|
|
373444
|
-
const agentId = optionalString(bodyRecord.agent_id);
|
|
373445
|
-
const after = optionalString(bodyRecord.after);
|
|
373446
|
-
const normalizedSearch = optionalString(bodyRecord.summary_search)?.trim().toLowerCase();
|
|
373447
|
-
const limit3 = typeof bodyRecord.limit === "number" ? bodyRecord.limit : 20;
|
|
373448
|
-
let conversations = [...source2].filter((conversation) => conversation.id !== "default" && (bodyRecord.include_hidden === true || !conversation.hidden) && (!agentId || conversation.agent_id === agentId) && matchesSummarySearch(conversation, normalizedSearch));
|
|
373449
|
-
conversations.sort((a, b) => {
|
|
373450
|
-
const aDate = a.last_message_at ?? a.updated_at ?? a.created_at ?? "";
|
|
373451
|
-
const bDate = b.last_message_at ?? b.updated_at ?? b.created_at ?? "";
|
|
373452
|
-
return bDate.localeCompare(aDate);
|
|
373453
|
-
});
|
|
373454
|
-
if (after) {
|
|
373455
|
-
const afterIndex = conversations.findIndex((conversation) => conversation.id === after);
|
|
373456
|
-
if (afterIndex >= 0)
|
|
373457
|
-
conversations = conversations.slice(afterIndex + 1);
|
|
373458
|
-
}
|
|
373459
|
-
return conversations.slice(0, limit3);
|
|
373460
|
-
}
|
|
373461
|
-
|
|
373462
|
-
// src/backend/local/local-message.ts
|
|
373463
|
-
function emptyLocalUsage() {
|
|
373464
|
-
return {
|
|
373465
|
-
input: 0,
|
|
373466
|
-
output: 0,
|
|
373467
|
-
cacheRead: 0,
|
|
373468
|
-
cacheWrite: 0,
|
|
373469
|
-
totalTokens: 0,
|
|
373470
|
-
cost: {
|
|
373471
|
-
input: 0,
|
|
373472
|
-
output: 0,
|
|
373473
|
-
cacheRead: 0,
|
|
373474
|
-
cacheWrite: 0,
|
|
373475
|
-
total: 0
|
|
373476
|
-
}
|
|
373477
|
-
};
|
|
373478
|
-
}
|
|
373479
|
-
|
|
373480
373464
|
// src/backend/local/local-message-projection.ts
|
|
373465
|
+
function sourceLocalMessageIdFromStoredMessageId(messageId) {
|
|
373466
|
+
const variantSeparator = messageId.search(/:(assistant|reasoning|tool):/);
|
|
373467
|
+
return variantSeparator >= 0 ? messageId.slice(0, variantSeparator) : messageId;
|
|
373468
|
+
}
|
|
373481
373469
|
function isLocalToolCallContent(content) {
|
|
373482
373470
|
return content.type === "toolCall" && typeof content.id === "string";
|
|
373483
373471
|
}
|
|
@@ -373813,6 +373801,96 @@ function mergeSnapshotContentWithExistingToolCalls(snapshotContent, existingCont
|
|
|
373813
373801
|
}
|
|
373814
373802
|
var LOCAL_REPAIRED_TOOL_RESULT_TEXT_MAX_CHARS = 40000;
|
|
373815
373803
|
|
|
373804
|
+
// src/backend/local/local-conversation-fork.ts
|
|
373805
|
+
function projectMessage(message, agentId, conversationId) {
|
|
373806
|
+
return projectLocalMessageToStoredMessages(message, agentId, conversationId, FORK_PROJECTION_FALLBACK_DATE);
|
|
373807
|
+
}
|
|
373808
|
+
function truncateAssistantThroughProjectedMessage(message, projectedMessageId, agentId, conversationId) {
|
|
373809
|
+
const selectedProjection = projectMessage(message, agentId, conversationId).find((projected) => projected.id === projectedMessageId);
|
|
373810
|
+
if (!selectedProjection)
|
|
373811
|
+
return message;
|
|
373812
|
+
const selectedJson = JSON.stringify(selectedProjection);
|
|
373813
|
+
for (let end = 1;end <= message.content.length; end += 1) {
|
|
373814
|
+
const candidate = { ...message, content: message.content.slice(0, end) };
|
|
373815
|
+
const candidateProjection = projectMessage(candidate, agentId, conversationId);
|
|
373816
|
+
const selectedCandidate = candidateProjection.find((projected) => projected.id === projectedMessageId);
|
|
373817
|
+
if (candidateProjection.at(-1)?.id === projectedMessageId && JSON.stringify(selectedCandidate) === selectedJson) {
|
|
373818
|
+
return candidate;
|
|
373819
|
+
}
|
|
373820
|
+
}
|
|
373821
|
+
return message;
|
|
373822
|
+
}
|
|
373823
|
+
function selectLocalMessagesForFork(messages, messageId, agentId, conversationId) {
|
|
373824
|
+
if (!messageId)
|
|
373825
|
+
return messages;
|
|
373826
|
+
for (let sourceIndex = 0;sourceIndex < messages.length; sourceIndex += 1) {
|
|
373827
|
+
const sourceMessage = messages[sourceIndex];
|
|
373828
|
+
if (!sourceMessage)
|
|
373829
|
+
continue;
|
|
373830
|
+
const projected = projectMessage(sourceMessage, agentId, conversationId);
|
|
373831
|
+
const projectedIndex = projected.findIndex((message) => message.id === messageId);
|
|
373832
|
+
if (projectedIndex < 0)
|
|
373833
|
+
continue;
|
|
373834
|
+
if (sourceMessage.role !== "assistant" || projectedIndex === projected.length - 1) {
|
|
373835
|
+
return messages.slice(0, sourceIndex + 1);
|
|
373836
|
+
}
|
|
373837
|
+
return [
|
|
373838
|
+
...messages.slice(0, sourceIndex),
|
|
373839
|
+
truncateAssistantThroughProjectedMessage(sourceMessage, messageId, agentId, conversationId)
|
|
373840
|
+
];
|
|
373841
|
+
}
|
|
373842
|
+
return;
|
|
373843
|
+
}
|
|
373844
|
+
var FORK_PROJECTION_FALLBACK_DATE = "1970-01-01T00:00:00.000Z";
|
|
373845
|
+
var init_local_conversation_fork = () => {};
|
|
373846
|
+
|
|
373847
|
+
// src/backend/local/local-conversation-list.ts
|
|
373848
|
+
function optionalString(value) {
|
|
373849
|
+
return typeof value === "string" ? value : undefined;
|
|
373850
|
+
}
|
|
373851
|
+
function matchesSummarySearch(conversation, normalizedSearch) {
|
|
373852
|
+
if (!normalizedSearch)
|
|
373853
|
+
return true;
|
|
373854
|
+
return conversation.id.toLowerCase().includes(normalizedSearch) || (conversation.summary?.toLowerCase().includes(normalizedSearch) ?? false);
|
|
373855
|
+
}
|
|
373856
|
+
function listLocalConversations(source2, body) {
|
|
373857
|
+
const bodyRecord = body ?? {};
|
|
373858
|
+
const agentId = optionalString(bodyRecord.agent_id);
|
|
373859
|
+
const after = optionalString(bodyRecord.after);
|
|
373860
|
+
const normalizedSearch = optionalString(bodyRecord.summary_search)?.trim().toLowerCase();
|
|
373861
|
+
const limit3 = typeof bodyRecord.limit === "number" ? bodyRecord.limit : 20;
|
|
373862
|
+
let conversations = [...source2].filter((conversation) => conversation.id !== "default" && (bodyRecord.include_hidden === true || !conversation.hidden) && (!agentId || conversation.agent_id === agentId) && matchesSummarySearch(conversation, normalizedSearch));
|
|
373863
|
+
conversations.sort((a, b) => {
|
|
373864
|
+
const aDate = a.last_message_at ?? a.updated_at ?? a.created_at ?? "";
|
|
373865
|
+
const bDate = b.last_message_at ?? b.updated_at ?? b.created_at ?? "";
|
|
373866
|
+
return bDate.localeCompare(aDate);
|
|
373867
|
+
});
|
|
373868
|
+
if (after) {
|
|
373869
|
+
const afterIndex = conversations.findIndex((conversation) => conversation.id === after);
|
|
373870
|
+
if (afterIndex >= 0)
|
|
373871
|
+
conversations = conversations.slice(afterIndex + 1);
|
|
373872
|
+
}
|
|
373873
|
+
return conversations.slice(0, limit3);
|
|
373874
|
+
}
|
|
373875
|
+
|
|
373876
|
+
// src/backend/local/local-message.ts
|
|
373877
|
+
function emptyLocalUsage() {
|
|
373878
|
+
return {
|
|
373879
|
+
input: 0,
|
|
373880
|
+
output: 0,
|
|
373881
|
+
cacheRead: 0,
|
|
373882
|
+
cacheWrite: 0,
|
|
373883
|
+
totalTokens: 0,
|
|
373884
|
+
cost: {
|
|
373885
|
+
input: 0,
|
|
373886
|
+
output: 0,
|
|
373887
|
+
cacheRead: 0,
|
|
373888
|
+
cacheWrite: 0,
|
|
373889
|
+
total: 0
|
|
373890
|
+
}
|
|
373891
|
+
};
|
|
373892
|
+
}
|
|
373893
|
+
|
|
373816
373894
|
// src/backend/local/local-model-normalization.ts
|
|
373817
373895
|
function supportedModelSettingsFromBody(bodyRecord) {
|
|
373818
373896
|
const modelSettings = isRecord(bodyRecord.model_settings) ? { ...bodyRecord.model_settings } : {};
|
|
@@ -374192,10 +374270,6 @@ function getIncludedMessageTypes(body) {
|
|
|
374192
374270
|
const messageTypes = value.filter((item) => typeof item === "string" && item.length > 0);
|
|
374193
374271
|
return messageTypes.length > 0 ? new Set(messageTypes) : undefined;
|
|
374194
374272
|
}
|
|
374195
|
-
function sourceLocalMessageIdFromStoredMessageId(messageId) {
|
|
374196
|
-
const variantSeparator = messageId.search(/:(assistant|reasoning|tool):/);
|
|
374197
|
-
return variantSeparator >= 0 ? messageId.slice(0, variantSeparator) : messageId;
|
|
374198
|
-
}
|
|
374199
374273
|
function toStoredOutputFields(chunk) {
|
|
374200
374274
|
const { id: _id, date: _date2, agent_id, conversation_id, ...fields } = chunk;
|
|
374201
374275
|
return fields;
|
|
@@ -374802,6 +374876,10 @@ class LocalStore {
|
|
|
374802
374876
|
throw new LocalBackendNotFoundError("Agent", targetAgentId);
|
|
374803
374877
|
}
|
|
374804
374878
|
this.ensureAgent(targetAgentId);
|
|
374879
|
+
const sourceMessages = selectLocalMessagesForFork(this.localMessagesForConversation(source2.id, source2.agent_id), options3.messageId, source2.agent_id, source2.id);
|
|
374880
|
+
if (!sourceMessages) {
|
|
374881
|
+
throw new LocalBackendNotFoundError("Message", options3.messageId ?? "");
|
|
374882
|
+
}
|
|
374805
374883
|
const forkedConversationId = this.nextConversationId(targetAgentId);
|
|
374806
374884
|
const forked = createLocalConversationRecord(forkedConversationId, targetAgentId, this.conversationSeq, {
|
|
374807
374885
|
summary: source2.summary ?? null,
|
|
@@ -374809,7 +374887,6 @@ class LocalStore {
|
|
|
374809
374887
|
...source2.model_settings !== undefined ? { model_settings: source2.model_settings } : {},
|
|
374810
374888
|
...typeof options3.hidden === "boolean" ? { hidden: options3.hidden } : {}
|
|
374811
374889
|
});
|
|
374812
|
-
const sourceMessages = this.localMessagesForConversation(source2.id, source2.agent_id);
|
|
374813
374890
|
const forkedMessages = sourceMessages.map((message) => this.cloneLocalMessageForConversation(message, forked.id, targetAgentId));
|
|
374814
374891
|
forked.in_context_message_ids = forkedMessages.map((message) => message.id);
|
|
374815
374892
|
const targetKey = this.conversationKey(forked.id, targetAgentId);
|
|
@@ -376104,6 +376181,7 @@ class LocalStore {
|
|
|
376104
376181
|
var DEFAULT_LOCAL_AGENT_NAME = "Letta Code", DEFAULT_LOCAL_MODEL = "local/default", LEGACY_LOCAL_CONTEXT_WINDOW_LIMIT = 128000, DEFAULT_LOCAL_CONVERSATION_ID_PREFIX = "local-conv-", DEFAULT_LOCAL_STORED_MESSAGE_ID_PREFIX = "letta-msg-", DEFAULT_LOCAL_UI_MESSAGE_ID_PREFIX = "ui-msg-", LocalBackendNotFoundError, LOCAL_TRANSCRIPT_LEGACY_SCHEMA_VERSION = 1, LOCAL_TRANSCRIPT_SCHEMA_VERSION = 2, LOCAL_TRANSCRIPT_LEGACY_MESSAGE_FORMAT = "pi-ai-message-jsonl", LOCAL_TRANSCRIPT_MESSAGE_FORMAT = "pi-session-entry-jsonl", LOCAL_TRANSCRIPT_PROVIDER_STACK = "pi-ai", LocalTranscriptMigrationRequiredError, LocalTranscriptRepairRequiredError;
|
|
376105
376182
|
var init_local_store = __esm(() => {
|
|
376106
376183
|
init_constants2();
|
|
376184
|
+
init_local_conversation_fork();
|
|
376107
376185
|
init_local_model_normalization();
|
|
376108
376186
|
init_local_stream_chunks();
|
|
376109
376187
|
LocalBackendNotFoundError = class LocalBackendNotFoundError extends Error {
|
|
@@ -377729,6 +377807,26 @@ class HeadlessBackend {
|
|
|
377729
377807
|
}
|
|
377730
377808
|
return { status: "cancelled" };
|
|
377731
377809
|
}
|
|
377810
|
+
async cancelRun(...args) {
|
|
377811
|
+
const [agentId, runId] = args;
|
|
377812
|
+
const run = this.runs.get(runId);
|
|
377813
|
+
if (!run || run.agent_id !== agentId || isTerminalRun(run)) {
|
|
377814
|
+
return { [runId]: "failed" };
|
|
377815
|
+
}
|
|
377816
|
+
if (run.conversation_id) {
|
|
377817
|
+
this.store.settleInterruptedToolCalls(run.conversation_id, { agentId });
|
|
377818
|
+
} else {
|
|
377819
|
+
this.store.settleInterruptedToolCalls(agentId);
|
|
377820
|
+
}
|
|
377821
|
+
const controller = this.runControllerByRunId.get(runId);
|
|
377822
|
+
this.recordRunChunk(runId, {
|
|
377823
|
+
message_type: "stop_reason",
|
|
377824
|
+
stop_reason: "cancelled"
|
|
377825
|
+
});
|
|
377826
|
+
this.completeRun(runId, "cancelled");
|
|
377827
|
+
controller?.abort();
|
|
377828
|
+
return { [runId]: "cancelled" };
|
|
377829
|
+
}
|
|
377732
377830
|
async retrieveRun(runId) {
|
|
377733
377831
|
const run = this.runs.get(runId);
|
|
377734
377832
|
if (!run)
|
|
@@ -378321,7 +378419,8 @@ function parseLlamaCppNativeModels(data) {
|
|
|
378321
378419
|
const id2 = record5.id ?? record5.name;
|
|
378322
378420
|
if (typeof id2 !== "string" || id2.length === 0)
|
|
378323
378421
|
continue;
|
|
378324
|
-
const
|
|
378422
|
+
const statusRecord = record5.status && typeof record5.status === "object" ? record5.status : undefined;
|
|
378423
|
+
const status = statusRecord?.value;
|
|
378325
378424
|
const architecture = record5.architecture && typeof record5.architecture === "object" ? record5.architecture : undefined;
|
|
378326
378425
|
const modalities = Array.isArray(architecture?.input_modalities) ? architecture.input_modalities.filter((value) => typeof value === "string") : undefined;
|
|
378327
378426
|
const meta3 = record5.meta && typeof record5.meta === "object" ? record5.meta : undefined;
|
|
@@ -378331,7 +378430,8 @@ function parseLlamaCppNativeModels(data) {
|
|
|
378331
378430
|
if (status !== undefined || modalities !== undefined || contextLength !== undefined) {
|
|
378332
378431
|
sawMetadata = true;
|
|
378333
378432
|
}
|
|
378334
|
-
|
|
378433
|
+
const selectable = status === undefined || status === "loaded" || status === "sleeping" || status === "unloaded" && statusRecord?.failed !== true;
|
|
378434
|
+
if (!selectable)
|
|
378335
378435
|
continue;
|
|
378336
378436
|
parsed.push(llamaCppModelMetadata(id2, {
|
|
378337
378437
|
...modalities !== undefined ? { vision: modalities.includes("image") } : {},
|
|
@@ -381902,6 +382002,10 @@ class APIBackend {
|
|
|
381902
382002
|
const client = await this.getClient();
|
|
381903
382003
|
return client.conversations.cancel(conversationIdOrAgentId);
|
|
381904
382004
|
}
|
|
382005
|
+
async cancelRun(agentId, runId) {
|
|
382006
|
+
const client = await this.getClient();
|
|
382007
|
+
return client.agents.messages.cancel(agentId, { run_ids: [runId] });
|
|
382008
|
+
}
|
|
381905
382009
|
async retrieveRun(runId) {
|
|
381906
382010
|
const client = await this.getClient();
|
|
381907
382011
|
return client.runs.retrieve(runId);
|
|
@@ -445556,6 +445660,26 @@ function actingUserRequestOptions(actingUserId) {
|
|
|
445556
445660
|
}
|
|
445557
445661
|
var ACTING_USER_ID_HEADER = "X-Letta-Acting-User-Id";
|
|
445558
445662
|
|
|
445663
|
+
// src/websocket/listener/management-protocol-inbound.ts
|
|
445664
|
+
function isObjectRecord(value) {
|
|
445665
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
445666
|
+
}
|
|
445667
|
+
function isConversationForkBody(value) {
|
|
445668
|
+
if (!isObjectRecord(value))
|
|
445669
|
+
return false;
|
|
445670
|
+
return (value.agent_id === undefined || value.agent_id === null || typeof value.agent_id === "string" && value.agent_id.length > 0) && (value.hidden === undefined || typeof value.hidden === "boolean") && (value.message_id === undefined || typeof value.message_id === "string" && value.message_id.length > 0);
|
|
445671
|
+
}
|
|
445672
|
+
function isAppServerInfoCommand(value) {
|
|
445673
|
+
if (!isObjectRecord(value))
|
|
445674
|
+
return false;
|
|
445675
|
+
return value.type === "app_server_info" && typeof value.request_id === "string" && value.request_id.length > 0;
|
|
445676
|
+
}
|
|
445677
|
+
function isConversationForkCommand(value) {
|
|
445678
|
+
if (!isObjectRecord(value))
|
|
445679
|
+
return false;
|
|
445680
|
+
return value.type === "conversation_fork" && typeof value.request_id === "string" && typeof value.conversation_id === "string" && (value.body === undefined || isConversationForkBody(value.body));
|
|
445681
|
+
}
|
|
445682
|
+
|
|
445559
445683
|
// src/websocket/listener/protocol-inbound.ts
|
|
445560
445684
|
function isExperimentId(value) {
|
|
445561
445685
|
return typeof value === "string" && EXPERIMENT_IDS.has(value);
|
|
@@ -445566,7 +445690,7 @@ function isStringArray6(value) {
|
|
|
445566
445690
|
function isStringRecord2(value) {
|
|
445567
445691
|
return !!value && typeof value === "object" && !Array.isArray(value) && Object.values(value).every((item) => typeof item === "string");
|
|
445568
445692
|
}
|
|
445569
|
-
function
|
|
445693
|
+
function isObjectRecord2(value) {
|
|
445570
445694
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
445571
445695
|
}
|
|
445572
445696
|
function isRuntimeScope(value) {
|
|
@@ -445716,27 +445840,27 @@ function isDevicePermissionMode(value) {
|
|
|
445716
445840
|
return value === "standard" || value === "acceptEdits" || value === "unrestricted";
|
|
445717
445841
|
}
|
|
445718
445842
|
function isRuntimeStartCreateAgentOptions(value) {
|
|
445719
|
-
if (!
|
|
445843
|
+
if (!isObjectRecord2(value))
|
|
445720
445844
|
return false;
|
|
445721
|
-
return
|
|
445845
|
+
return isObjectRecord2(value.body) && (value.pin_global === undefined || typeof value.pin_global === "boolean") && (value.memfs === undefined || typeof value.memfs === "boolean");
|
|
445722
445846
|
}
|
|
445723
445847
|
function isRuntimeStartCreateConversationOptions(value) {
|
|
445724
|
-
if (!
|
|
445848
|
+
if (!isObjectRecord2(value))
|
|
445725
445849
|
return false;
|
|
445726
|
-
return value.body === undefined ||
|
|
445850
|
+
return value.body === undefined || isObjectRecord2(value.body);
|
|
445727
445851
|
}
|
|
445728
445852
|
function isRuntimeStartClientInfo(value) {
|
|
445729
|
-
if (!
|
|
445853
|
+
if (!isObjectRecord2(value))
|
|
445730
445854
|
return false;
|
|
445731
445855
|
return typeof value.name === "string" && (value.title === undefined || typeof value.title === "string") && (value.version === undefined || typeof value.version === "string");
|
|
445732
445856
|
}
|
|
445733
445857
|
function isExternalToolDefinitionPayload(value) {
|
|
445734
|
-
if (!
|
|
445858
|
+
if (!isObjectRecord2(value))
|
|
445735
445859
|
return false;
|
|
445736
|
-
return typeof value.name === "string" && (value.label === undefined || typeof value.label === "string") && typeof value.description === "string" &&
|
|
445860
|
+
return typeof value.name === "string" && (value.label === undefined || typeof value.label === "string") && typeof value.description === "string" && isObjectRecord2(value.parameters);
|
|
445737
445861
|
}
|
|
445738
445862
|
function isRuntimeStartExternalToolsGroup(value) {
|
|
445739
|
-
if (!
|
|
445863
|
+
if (!isObjectRecord2(value))
|
|
445740
445864
|
return false;
|
|
445741
445865
|
return (value.scope_id === undefined || typeof value.scope_id === "string") && Array.isArray(value.tools) && value.tools.every(isExternalToolDefinitionPayload);
|
|
445742
445866
|
}
|
|
@@ -445747,7 +445871,7 @@ function isRuntimeStartCommand(value) {
|
|
|
445747
445871
|
return c.type === "runtime_start" && typeof c.request_id === "string" && (c.agent_id === undefined || typeof c.agent_id === "string") && (c.create_agent === undefined || isRuntimeStartCreateAgentOptions(c.create_agent)) && (c.conversation_id === undefined || typeof c.conversation_id === "string") && (c.create_conversation === undefined || isRuntimeStartCreateConversationOptions(c.create_conversation)) && (c.cwd === undefined || c.cwd === null || typeof c.cwd === "string") && (c.mode === undefined || isDevicePermissionMode(c.mode)) && (c.skill_sources === undefined || isSkillSourceArray(c.skill_sources)) && (c.client_info === undefined || isRuntimeStartClientInfo(c.client_info)) && (c.recover_approvals === undefined || typeof c.recover_approvals === "boolean") && (c.force_device_status === undefined || typeof c.force_device_status === "boolean") && (c.external_tools === undefined || Array.isArray(c.external_tools) && c.external_tools.every(isRuntimeStartExternalToolsGroup));
|
|
445748
445872
|
}
|
|
445749
445873
|
function isExternalToolCallResponseCommand(value) {
|
|
445750
|
-
if (!
|
|
445874
|
+
if (!isObjectRecord2(value))
|
|
445751
445875
|
return false;
|
|
445752
445876
|
if (value.type !== "external_tool_call_response" || typeof value.request_id !== "string") {
|
|
445753
445877
|
return false;
|
|
@@ -445758,10 +445882,10 @@ function isExternalToolCallResponseCommand(value) {
|
|
|
445758
445882
|
if (value.result === undefined) {
|
|
445759
445883
|
return typeof value.error === "string";
|
|
445760
445884
|
}
|
|
445761
|
-
if (!
|
|
445885
|
+
if (!isObjectRecord2(value.result)) {
|
|
445762
445886
|
return false;
|
|
445763
445887
|
}
|
|
445764
|
-
return Array.isArray(value.result.content) && value.result.content.every(
|
|
445888
|
+
return Array.isArray(value.result.content) && value.result.content.every(isObjectRecord2) && (value.result.is_error === undefined || typeof value.result.is_error === "boolean");
|
|
445765
445889
|
}
|
|
445766
445890
|
function isTerminalSpawnCommand(value) {
|
|
445767
445891
|
if (!value || typeof value !== "object")
|
|
@@ -446021,7 +446145,7 @@ function isAgentListCommand(value) {
|
|
|
446021
446145
|
if (!value || typeof value !== "object")
|
|
446022
446146
|
return false;
|
|
446023
446147
|
const c = value;
|
|
446024
|
-
return c.type === "agent_list" && typeof c.request_id === "string" && (c.query === undefined ||
|
|
446148
|
+
return c.type === "agent_list" && typeof c.request_id === "string" && (c.query === undefined || isObjectRecord2(c.query));
|
|
446025
446149
|
}
|
|
446026
446150
|
function isAgentRetrieveCommand(value) {
|
|
446027
446151
|
if (!value || typeof value !== "object")
|
|
@@ -446033,13 +446157,13 @@ function isAgentCreateCommand(value) {
|
|
|
446033
446157
|
if (!value || typeof value !== "object")
|
|
446034
446158
|
return false;
|
|
446035
446159
|
const c = value;
|
|
446036
|
-
return c.type === "agent_create" && typeof c.request_id === "string" &&
|
|
446160
|
+
return c.type === "agent_create" && typeof c.request_id === "string" && isObjectRecord2(c.body);
|
|
446037
446161
|
}
|
|
446038
446162
|
function isAgentUpdateCommand(value) {
|
|
446039
446163
|
if (!value || typeof value !== "object")
|
|
446040
446164
|
return false;
|
|
446041
446165
|
const c = value;
|
|
446042
|
-
return c.type === "agent_update" && typeof c.request_id === "string" && typeof c.agent_id === "string" &&
|
|
446166
|
+
return c.type === "agent_update" && typeof c.request_id === "string" && typeof c.agent_id === "string" && isObjectRecord2(c.body);
|
|
446043
446167
|
}
|
|
446044
446168
|
function isAgentDeleteCommand(value) {
|
|
446045
446169
|
if (!value || typeof value !== "object")
|
|
@@ -446051,7 +446175,7 @@ function isConversationListCommand(value) {
|
|
|
446051
446175
|
if (!value || typeof value !== "object")
|
|
446052
446176
|
return false;
|
|
446053
446177
|
const c = value;
|
|
446054
|
-
return c.type === "conversation_list" && typeof c.request_id === "string" && (c.query === undefined ||
|
|
446178
|
+
return c.type === "conversation_list" && typeof c.request_id === "string" && (c.query === undefined || isObjectRecord2(c.query));
|
|
446055
446179
|
}
|
|
446056
446180
|
function isConversationRetrieveCommand(value) {
|
|
446057
446181
|
if (!value || typeof value !== "object")
|
|
@@ -446063,37 +446187,31 @@ function isConversationCreateCommand(value) {
|
|
|
446063
446187
|
if (!value || typeof value !== "object")
|
|
446064
446188
|
return false;
|
|
446065
446189
|
const c = value;
|
|
446066
|
-
return c.type === "conversation_create" && typeof c.request_id === "string" &&
|
|
446190
|
+
return c.type === "conversation_create" && typeof c.request_id === "string" && isObjectRecord2(c.body);
|
|
446067
446191
|
}
|
|
446068
446192
|
function isConversationUpdateCommand(value) {
|
|
446069
446193
|
if (!value || typeof value !== "object")
|
|
446070
446194
|
return false;
|
|
446071
446195
|
const c = value;
|
|
446072
|
-
return c.type === "conversation_update" && typeof c.request_id === "string" && typeof c.conversation_id === "string" &&
|
|
446196
|
+
return c.type === "conversation_update" && typeof c.request_id === "string" && typeof c.conversation_id === "string" && isObjectRecord2(c.body);
|
|
446073
446197
|
}
|
|
446074
446198
|
function isConversationRecompileCommand(value) {
|
|
446075
446199
|
if (!value || typeof value !== "object")
|
|
446076
446200
|
return false;
|
|
446077
446201
|
const c = value;
|
|
446078
|
-
return c.type === "conversation_recompile" && typeof c.request_id === "string" && typeof c.conversation_id === "string" && (c.body === undefined ||
|
|
446079
|
-
}
|
|
446080
|
-
function isConversationForkCommand(value) {
|
|
446081
|
-
if (!value || typeof value !== "object")
|
|
446082
|
-
return false;
|
|
446083
|
-
const c = value;
|
|
446084
|
-
return c.type === "conversation_fork" && typeof c.request_id === "string" && typeof c.conversation_id === "string" && (c.body === undefined || isObjectRecord(c.body));
|
|
446202
|
+
return c.type === "conversation_recompile" && typeof c.request_id === "string" && typeof c.conversation_id === "string" && (c.body === undefined || isObjectRecord2(c.body));
|
|
446085
446203
|
}
|
|
446086
446204
|
function isConversationMessagesListCommand(value) {
|
|
446087
446205
|
if (!value || typeof value !== "object")
|
|
446088
446206
|
return false;
|
|
446089
446207
|
const c = value;
|
|
446090
|
-
return c.type === "conversation_messages_list" && typeof c.request_id === "string" && typeof c.conversation_id === "string" && (c.query === undefined ||
|
|
446208
|
+
return c.type === "conversation_messages_list" && typeof c.request_id === "string" && typeof c.conversation_id === "string" && (c.query === undefined || isObjectRecord2(c.query));
|
|
446091
446209
|
}
|
|
446092
446210
|
function isConversationCompactCommand(value) {
|
|
446093
446211
|
if (!value || typeof value !== "object")
|
|
446094
446212
|
return false;
|
|
446095
446213
|
const c = value;
|
|
446096
|
-
return c.type === "conversation_compact" && typeof c.request_id === "string" && typeof c.conversation_id === "string" && (c.body === undefined ||
|
|
446214
|
+
return c.type === "conversation_compact" && typeof c.request_id === "string" && typeof c.conversation_id === "string" && (c.body === undefined || isObjectRecord2(c.body));
|
|
446097
446215
|
}
|
|
446098
446216
|
function isGetReflectionSettingsCommand(value) {
|
|
446099
446217
|
if (!value || typeof value !== "object")
|
|
@@ -446348,7 +446466,7 @@ function parseServerMessage(data) {
|
|
|
446348
446466
|
if (legacyInput) {
|
|
446349
446467
|
return legacyInput;
|
|
446350
446468
|
}
|
|
446351
|
-
if (isInputCommand(parsed) || isChangeDeviceStateCommand(parsed) || isAbortMessageCommand(parsed) || isSyncCommand(parsed) || isRuntimeStartCommand(parsed) || isExternalToolCallResponseCommand(parsed) || isTerminalSpawnCommand(parsed) || isTerminalInputCommand(parsed) || isTerminalResizeCommand(parsed) || isTerminalKillCommand(parsed) || isSearchFilesCommand(parsed) || isGrepInFilesCommand(parsed) || isListInDirectoryCommand(parsed) || isGetTreeCommand(parsed) || isReadFileCommand(parsed) || isWriteFileCommand(parsed) || isWatchFileCommand(parsed) || isUnwatchFileCommand(parsed) || isEditFileCommand(parsed) || isFileOpsCommand(parsed) || isListMemoryCommand(parsed) || isMemoryHistoryCommand(parsed) || isMemoryFileAtRefCommand(parsed) || isMemoryCommitDiffCommand(parsed) || isReadMemoryFileCommand(parsed) || isWriteMemoryFileCommand(parsed) || isDeleteMemoryFileCommand(parsed) || isEnableMemfsCommand(parsed) || isListModelsCommand(parsed) || isListConnectProvidersCommand(parsed) || isConnectProviderCommand(parsed) || isDisconnectProviderCommand(parsed) || isChatGPTUsageReadCommand(parsed) || isUpdateModelCommand(parsed) || isUpdateToolsetCommand(parsed) || isCronListCommand(parsed) || isCronAddCommand(parsed) || isCronGetCommand(parsed) || isCronRunsCommand(parsed) || isCronTriggerCommand(parsed) || isCronUpdateCommand(parsed) || isCronDeleteCommand(parsed) || isCronDeleteAllCommand(parsed) || isSkillEnableCommand(parsed) || isSkillDisableCommand(parsed) || isCreateAgentCommand(parsed) || isAgentListCommand(parsed) || isAgentRetrieveCommand(parsed) || isAgentCreateCommand(parsed) || isAgentUpdateCommand(parsed) || isAgentDeleteCommand(parsed) || isConversationListCommand(parsed) || isConversationRetrieveCommand(parsed) || isConversationCreateCommand(parsed) || isConversationUpdateCommand(parsed) || isConversationRecompileCommand(parsed) || isConversationForkCommand(parsed) || isConversationMessagesListCommand(parsed) || isConversationCompactCommand(parsed) || isGetCwdMapCommand(parsed) || isGetExperimentsCommand(parsed) || isSetExperimentCommand(parsed) || isGetReflectionSettingsCommand(parsed) || isSetReflectionSettingsCommand(parsed) || isChannelsListCommand(parsed) || isChannelAccountsListCommand(parsed) || isChannelAccountCreateCommand(parsed) || isChannelAccountUpdateCommand(parsed) || isChannelAccountBindCommand(parsed) || isChannelAccountUnbindCommand(parsed) || isChannelAccountDeleteCommand(parsed) || isChannelAccountStartCommand(parsed) || isChannelAccountStopCommand(parsed) || isChannelGetConfigCommand(parsed) || isChannelSetConfigCommand(parsed) || isChannelStartCommand(parsed) || isChannelStopCommand(parsed) || isChannelPairingsListCommand(parsed) || isChannelPairingBindCommand(parsed) || isChannelRoutesListCommand(parsed) || isChannelTargetsListCommand(parsed) || isChannelTargetBindCommand(parsed) || isChannelRouteUpdateCommand(parsed) || isChannelRouteRemoveCommand(parsed) || isExecuteCommandCommand(parsed) || isRemoveQueueItemCommand(parsed) || isSearchBranchesCommand(parsed) || isCheckoutBranchCommand(parsed) || isSecretListCommand(parsed) || isSecretApplyCommand(parsed)) {
|
|
446469
|
+
if (isInputCommand(parsed) || isChangeDeviceStateCommand(parsed) || isAbortMessageCommand(parsed) || isSyncCommand(parsed) || isRuntimeStartCommand(parsed) || isExternalToolCallResponseCommand(parsed) || isTerminalSpawnCommand(parsed) || isTerminalInputCommand(parsed) || isTerminalResizeCommand(parsed) || isTerminalKillCommand(parsed) || isSearchFilesCommand(parsed) || isGrepInFilesCommand(parsed) || isListInDirectoryCommand(parsed) || isGetTreeCommand(parsed) || isReadFileCommand(parsed) || isWriteFileCommand(parsed) || isWatchFileCommand(parsed) || isUnwatchFileCommand(parsed) || isEditFileCommand(parsed) || isFileOpsCommand(parsed) || isListMemoryCommand(parsed) || isMemoryHistoryCommand(parsed) || isMemoryFileAtRefCommand(parsed) || isMemoryCommitDiffCommand(parsed) || isReadMemoryFileCommand(parsed) || isWriteMemoryFileCommand(parsed) || isDeleteMemoryFileCommand(parsed) || isEnableMemfsCommand(parsed) || isListModelsCommand(parsed) || isListConnectProvidersCommand(parsed) || isConnectProviderCommand(parsed) || isDisconnectProviderCommand(parsed) || isChatGPTUsageReadCommand(parsed) || isUpdateModelCommand(parsed) || isUpdateToolsetCommand(parsed) || isCronListCommand(parsed) || isCronAddCommand(parsed) || isCronGetCommand(parsed) || isCronRunsCommand(parsed) || isCronTriggerCommand(parsed) || isCronUpdateCommand(parsed) || isCronDeleteCommand(parsed) || isCronDeleteAllCommand(parsed) || isSkillEnableCommand(parsed) || isSkillDisableCommand(parsed) || isAppServerInfoCommand(parsed) || isCreateAgentCommand(parsed) || isAgentListCommand(parsed) || isAgentRetrieveCommand(parsed) || isAgentCreateCommand(parsed) || isAgentUpdateCommand(parsed) || isAgentDeleteCommand(parsed) || isConversationListCommand(parsed) || isConversationRetrieveCommand(parsed) || isConversationCreateCommand(parsed) || isConversationUpdateCommand(parsed) || isConversationRecompileCommand(parsed) || isConversationForkCommand(parsed) || isConversationMessagesListCommand(parsed) || isConversationCompactCommand(parsed) || isGetCwdMapCommand(parsed) || isGetExperimentsCommand(parsed) || isSetExperimentCommand(parsed) || isGetReflectionSettingsCommand(parsed) || isSetReflectionSettingsCommand(parsed) || isChannelsListCommand(parsed) || isChannelAccountsListCommand(parsed) || isChannelAccountCreateCommand(parsed) || isChannelAccountUpdateCommand(parsed) || isChannelAccountBindCommand(parsed) || isChannelAccountUnbindCommand(parsed) || isChannelAccountDeleteCommand(parsed) || isChannelAccountStartCommand(parsed) || isChannelAccountStopCommand(parsed) || isChannelGetConfigCommand(parsed) || isChannelSetConfigCommand(parsed) || isChannelStartCommand(parsed) || isChannelStopCommand(parsed) || isChannelPairingsListCommand(parsed) || isChannelPairingBindCommand(parsed) || isChannelRoutesListCommand(parsed) || isChannelTargetsListCommand(parsed) || isChannelTargetBindCommand(parsed) || isChannelRouteUpdateCommand(parsed) || isChannelRouteRemoveCommand(parsed) || isExecuteCommandCommand(parsed) || isRemoveQueueItemCommand(parsed) || isSearchBranchesCommand(parsed) || isCheckoutBranchCommand(parsed) || isSecretListCommand(parsed) || isSecretApplyCommand(parsed)) {
|
|
446352
446470
|
return parsed;
|
|
446353
446471
|
}
|
|
446354
446472
|
const invalidInput = getInvalidInputReason(parsed);
|
|
@@ -446626,6 +446744,7 @@ async function handleAgentConversationManagementCommand(parsed, socket, safeSock
|
|
|
446626
446744
|
const conversation = await backend3.forkConversation(parsed.conversation_id, {
|
|
446627
446745
|
...typeof parsed.body?.agent_id === "string" ? { agentId: parsed.body.agent_id } : {},
|
|
446628
446746
|
...typeof parsed.body?.hidden === "boolean" ? { hidden: parsed.body.hidden } : {},
|
|
446747
|
+
...typeof parsed.body?.message_id === "string" ? { messageId: parsed.body.message_id } : {},
|
|
446629
446748
|
...actingUserRequestOptions(parsed.acting_user_id) ?? {}
|
|
446630
446749
|
});
|
|
446631
446750
|
safeSocketSend(socket, {
|
|
@@ -459568,6 +459687,12 @@ async function handleAbortMessageInput(listener, params, deps = {}) {
|
|
|
459568
459687
|
const cancelId = conversationId === "default" || !conversationId ? agentId : conversationId;
|
|
459569
459688
|
await getBackend().cancelConversation(cancelId);
|
|
459570
459689
|
},
|
|
459690
|
+
cancelRun: async (agentId, runId) => {
|
|
459691
|
+
const result = await getBackend().cancelRun(agentId, runId);
|
|
459692
|
+
if (result[runId] !== "cancelled") {
|
|
459693
|
+
throw new Error(`Backend did not cancel run ${runId}`);
|
|
459694
|
+
}
|
|
459695
|
+
},
|
|
459571
459696
|
...deps
|
|
459572
459697
|
};
|
|
459573
459698
|
if (listener !== resolvedDeps.getActiveRuntime() || listener.intentionallyClosed) {
|
|
@@ -459583,7 +459708,9 @@ async function handleAbortMessageInput(listener, params, deps = {}) {
|
|
|
459583
459708
|
if (!hasActiveTurn && !hasPendingApprovals) {
|
|
459584
459709
|
return false;
|
|
459585
459710
|
}
|
|
459586
|
-
const cancellation = scopedRuntime.turnLifecycle.requestCancellation(
|
|
459711
|
+
const cancellation = scopedRuntime.turnLifecycle.requestCancellation({
|
|
459712
|
+
waitForExternalSettlement: hasActiveTurn && Boolean(scopedRuntime.agentId)
|
|
459713
|
+
});
|
|
459587
459714
|
const interruptedRunId = cancellation.runId;
|
|
459588
459715
|
const pendingRequestsSnapshot = hasPendingApprovals ? resolvedDeps.getPendingControlRequests(listener, scope) : [];
|
|
459589
459716
|
if (cancellation.executingToolCallIds.length > 0 && (!scopedRuntime.pendingInterruptedResults || scopedRuntime.pendingInterruptedResults.length === 0)) {
|
|
@@ -459646,7 +459773,17 @@ async function handleAbortMessageInput(listener, params, deps = {}) {
|
|
|
459646
459773
|
const cancelConversationId = scopedRuntime.conversationId;
|
|
459647
459774
|
const cancelAgentId = scopedRuntime.agentId;
|
|
459648
459775
|
if (cancelAgentId) {
|
|
459649
|
-
|
|
459776
|
+
const cancelRunId = interruptedRunId ?? params.command.run_id ?? null;
|
|
459777
|
+
const backendCancellation = cancelRunId ? resolvedDeps.cancelRun(cancelAgentId, cancelRunId).catch(() => resolvedDeps.cancelConversation(cancelAgentId, cancelConversationId)) : resolvedDeps.cancelConversation(cancelAgentId, cancelConversationId);
|
|
459778
|
+
backendCancellation.catch(() => {}).finally(() => {
|
|
459779
|
+
if (!cancellation.lease) {
|
|
459780
|
+
return;
|
|
459781
|
+
}
|
|
459782
|
+
const settlement = scopedRuntime.turnLifecycle.settleCancellation(cancellation.lease);
|
|
459783
|
+
if (settlement.released) {
|
|
459784
|
+
resolvedDeps.scheduleQueuePump(scopedRuntime, params.socket, params.opts, params.processQueuedTurn);
|
|
459785
|
+
}
|
|
459786
|
+
});
|
|
459650
459787
|
}
|
|
459651
459788
|
resolvedDeps.scheduleQueuePump(scopedRuntime, params.socket, params.opts, params.processQueuedTurn);
|
|
459652
459789
|
return true;
|
|
@@ -462006,6 +462143,41 @@ var init_file_commands = __esm(async () => {
|
|
|
462006
462143
|
ignoreConfigCache = new Map;
|
|
462007
462144
|
});
|
|
462008
462145
|
|
|
462146
|
+
// src/types/app-server-info.ts
|
|
462147
|
+
var APP_SERVER_PROTOCOL_VERSION = 1;
|
|
462148
|
+
|
|
462149
|
+
// src/websocket/listener/commands/app-server-info.ts
|
|
462150
|
+
function buildAppServerInfoResponse(command, options3) {
|
|
462151
|
+
return {
|
|
462152
|
+
type: "app_server_info_response",
|
|
462153
|
+
request_id: command.request_id,
|
|
462154
|
+
success: true,
|
|
462155
|
+
backend: options3.backend,
|
|
462156
|
+
letta_code_version: options3.version,
|
|
462157
|
+
protocol_version: APP_SERVER_PROTOCOL_VERSION,
|
|
462158
|
+
capabilities: {
|
|
462159
|
+
agent_management: true,
|
|
462160
|
+
conversation_management: true,
|
|
462161
|
+
memory_management: true,
|
|
462162
|
+
runtime_start: true,
|
|
462163
|
+
split_channels: true
|
|
462164
|
+
}
|
|
462165
|
+
};
|
|
462166
|
+
}
|
|
462167
|
+
function getAppServerInfoResponse(requestId) {
|
|
462168
|
+
return buildAppServerInfoResponse({ type: "app_server_info", request_id: requestId }, {
|
|
462169
|
+
backend: isLocalBackendEnabled() ? "local" : "api",
|
|
462170
|
+
version: getVersion()
|
|
462171
|
+
});
|
|
462172
|
+
}
|
|
462173
|
+
function handleAppServerInfoCommand(command, context3) {
|
|
462174
|
+
context3.safeSocketSend(context3.socket, getAppServerInfoResponse(command.request_id), "listener_app_server_info_send_failed", "listener_app_server_info");
|
|
462175
|
+
}
|
|
462176
|
+
var init_app_server_info = __esm(() => {
|
|
462177
|
+
init_backend2();
|
|
462178
|
+
init_version();
|
|
462179
|
+
});
|
|
462180
|
+
|
|
462009
462181
|
// src/providers/chatgpt-usage-service.ts
|
|
462010
462182
|
import { hostname as hostname4 } from "node:os";
|
|
462011
462183
|
function asRecord7(value) {
|
|
@@ -463388,6 +463560,10 @@ function createListenerMessageHandler(params) {
|
|
|
463388
463560
|
});
|
|
463389
463561
|
return;
|
|
463390
463562
|
}
|
|
463563
|
+
if (parsed.type === "app_server_info") {
|
|
463564
|
+
handleAppServerInfoCommand(parsed, { socket, safeSocketSend });
|
|
463565
|
+
return;
|
|
463566
|
+
}
|
|
463391
463567
|
if (handleRuntimeStartProtocolCommand(parsed, {
|
|
463392
463568
|
socket,
|
|
463393
463569
|
runtime,
|
|
@@ -463758,6 +463934,7 @@ var init_message_router = __esm(async () => {
|
|
|
463758
463934
|
init_settings_manager();
|
|
463759
463935
|
init_debug();
|
|
463760
463936
|
init_terminal_handler();
|
|
463937
|
+
init_app_server_info();
|
|
463761
463938
|
init_cwd();
|
|
463762
463939
|
init_runtime6();
|
|
463763
463940
|
await __promiseAll([
|
|
@@ -469796,6 +469973,19 @@ async function startAppServer(options3 = {}) {
|
|
|
469796
469973
|
`);
|
|
469797
469974
|
return;
|
|
469798
469975
|
}
|
|
469976
|
+
if (requestUrl.pathname === "/app-server-info") {
|
|
469977
|
+
const authError = authorizeUpgrade(request.headers, authPolicy);
|
|
469978
|
+
if (authError) {
|
|
469979
|
+
response.writeHead(authError.statusCode, {
|
|
469980
|
+
"content-type": "application/json"
|
|
469981
|
+
});
|
|
469982
|
+
response.end(JSON.stringify({ error: authError.message }));
|
|
469983
|
+
return;
|
|
469984
|
+
}
|
|
469985
|
+
response.writeHead(200, { "content-type": "application/json" });
|
|
469986
|
+
response.end(JSON.stringify(getAppServerInfoResponse("http-info")));
|
|
469987
|
+
return;
|
|
469988
|
+
}
|
|
469799
469989
|
if (options3.openaiApi && isOpenAiCompatPath(requestUrl.pathname)) {
|
|
469800
469990
|
handleOpenAiCompatRequest(request, response, {
|
|
469801
469991
|
authPolicy,
|
|
@@ -469915,6 +470105,7 @@ var init_app_server = __esm(async () => {
|
|
|
469915
470105
|
init_settings_manager();
|
|
469916
470106
|
init_telemetry();
|
|
469917
470107
|
init_app_server_auth();
|
|
470108
|
+
init_app_server_info();
|
|
469918
470109
|
init_runtime6();
|
|
469919
470110
|
await __promiseAll([
|
|
469920
470111
|
init_manager4(),
|
|
@@ -541037,4 +541228,4 @@ function registerBunOAuthFlows() {
|
|
|
541037
541228
|
registerBunOAuthFlows();
|
|
541038
541229
|
await init_src5().then(() => exports_src2);
|
|
541039
541230
|
|
|
541040
|
-
//# debugId=
|
|
541231
|
+
//# debugId=5A6EDC9BFD941DD864756E2164756E21
|