@letta-ai/letta-code 0.29.1 → 0.29.3
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.cjs +531 -0
- package/dist/app-server-client.cjs.map +11 -0
- package/dist/app-server-client.js +53 -1
- package/dist/app-server-client.js.map +5 -4
- package/dist/types/app-server-client.d.ts +32 -3
- package/dist/types/app-server-client.d.ts.map +1 -1
- package/dist/types/types/app-server-info.d.ts +25 -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 +293 -98
- package/package.json +10 -6
- 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.3",
|
|
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",
|
|
@@ -5480,6 +5480,8 @@ var init_package = __esm(() => {
|
|
|
5480
5480
|
"vendor",
|
|
5481
5481
|
"dist/app-server-client.js",
|
|
5482
5482
|
"dist/app-server-client.js.map",
|
|
5483
|
+
"dist/app-server-client.cjs",
|
|
5484
|
+
"dist/app-server-client.cjs.map",
|
|
5483
5485
|
"dist/agent-presets.js",
|
|
5484
5486
|
"dist/agent-presets.js.map",
|
|
5485
5487
|
"dist/channels-public.js",
|
|
@@ -5492,15 +5494,17 @@ var init_package = __esm(() => {
|
|
|
5492
5494
|
exports: {
|
|
5493
5495
|
".": "./letta.js",
|
|
5494
5496
|
"./app-server-protocol": {
|
|
5495
|
-
types: "./dist/types/app-server-protocol.d.ts"
|
|
5497
|
+
types: "./dist/types/types/app-server-protocol.d.ts"
|
|
5496
5498
|
},
|
|
5497
5499
|
"./app-server-client": {
|
|
5498
5500
|
types: "./dist/types/app-server-client.d.ts",
|
|
5499
5501
|
browser: "./dist/app-server-client.js",
|
|
5500
|
-
import: "./dist/app-server-client.js"
|
|
5502
|
+
import: "./dist/app-server-client.js",
|
|
5503
|
+
require: "./dist/app-server-client.cjs",
|
|
5504
|
+
default: "./dist/app-server-client.js"
|
|
5501
5505
|
},
|
|
5502
5506
|
"./protocol": {
|
|
5503
|
-
types: "./dist/types/protocol.d.ts"
|
|
5507
|
+
types: "./dist/types/types/protocol.d.ts"
|
|
5504
5508
|
},
|
|
5505
5509
|
"./agent-presets": {
|
|
5506
5510
|
types: "./dist/types/agent-presets.d.ts",
|
|
@@ -5613,7 +5617,7 @@ var init_package = __esm(() => {
|
|
|
5613
5617
|
"./dist/types/agent-presets.d.ts"
|
|
5614
5618
|
],
|
|
5615
5619
|
"app-server-protocol": [
|
|
5616
|
-
"./dist/types/app-server-protocol.d.ts"
|
|
5620
|
+
"./dist/types/types/app-server-protocol.d.ts"
|
|
5617
5621
|
],
|
|
5618
5622
|
"app-server-client": [
|
|
5619
5623
|
"./dist/types/app-server-client.d.ts"
|
|
@@ -5625,7 +5629,7 @@ var init_package = __esm(() => {
|
|
|
5625
5629
|
"./dist/types/channels-slack.d.ts"
|
|
5626
5630
|
],
|
|
5627
5631
|
protocol: [
|
|
5628
|
-
"./dist/types/protocol.d.ts"
|
|
5632
|
+
"./dist/types/types/protocol.d.ts"
|
|
5629
5633
|
]
|
|
5630
5634
|
}
|
|
5631
5635
|
}
|
|
@@ -163511,7 +163515,8 @@ __export(exports_conversations, {
|
|
|
163511
163515
|
async function forkConversation(conversationId, options3 = {}) {
|
|
163512
163516
|
const query2 = {
|
|
163513
163517
|
...options3.agentId ? { agent_id: options3.agentId } : {},
|
|
163514
|
-
...options3.hidden !== undefined ? { hidden: options3.hidden } : {}
|
|
163518
|
+
...options3.hidden !== undefined ? { hidden: options3.hidden } : {},
|
|
163519
|
+
...options3.messageId ? { message_id: options3.messageId } : {}
|
|
163515
163520
|
};
|
|
163516
163521
|
return apiRequest("POST", `/v1/conversations/${encodeURIComponent(conversationId)}/fork`, undefined, { query: query2, ...options3.headers ? { headers: options3.headers } : {} });
|
|
163517
163522
|
}
|
|
@@ -170213,7 +170218,13 @@ class TurnLifecycle {
|
|
|
170213
170218
|
return this.#lastStopReason;
|
|
170214
170219
|
}
|
|
170215
170220
|
get currentLease() {
|
|
170216
|
-
|
|
170221
|
+
if (this.#state.kind === "active") {
|
|
170222
|
+
return this.#state.lease;
|
|
170223
|
+
}
|
|
170224
|
+
if (this.#state.kind === "cancelling" && !this.#state.ownerFinished) {
|
|
170225
|
+
return this.#state.lease;
|
|
170226
|
+
}
|
|
170227
|
+
return null;
|
|
170217
170228
|
}
|
|
170218
170229
|
snapshot() {
|
|
170219
170230
|
const state = this.#state;
|
|
@@ -170263,7 +170274,7 @@ class TurnLifecycle {
|
|
|
170263
170274
|
return lease;
|
|
170264
170275
|
}
|
|
170265
170276
|
isCurrent(lease) {
|
|
170266
|
-
return (this.#state.kind === "active" || this.#state.kind === "cancelling") && this.#state.lease.id === lease.id;
|
|
170277
|
+
return (this.#state.kind === "active" || this.#state.kind === "cancelling") && (this.#state.kind !== "cancelling" || !this.#state.ownerFinished) && this.#state.lease.id === lease.id;
|
|
170267
170278
|
}
|
|
170268
170279
|
setStatus(lease, status) {
|
|
170269
170280
|
if (this.#state.kind !== "active" || !this.isCurrent(lease)) {
|
|
@@ -170319,7 +170330,7 @@ class TurnLifecycle {
|
|
|
170319
170330
|
this.#state = IDLE_STATE;
|
|
170320
170331
|
return true;
|
|
170321
170332
|
}
|
|
170322
|
-
requestCancellation() {
|
|
170333
|
+
requestCancellation(options3) {
|
|
170323
170334
|
const state = this.#state;
|
|
170324
170335
|
if (state.kind === "cancelling") {
|
|
170325
170336
|
return {
|
|
@@ -170348,7 +170359,9 @@ class TurnLifecycle {
|
|
|
170348
170359
|
abortController: state.abortController,
|
|
170349
170360
|
runId: state.runId,
|
|
170350
170361
|
executingToolCallIds: [...state.executingToolCallIds],
|
|
170351
|
-
loopStatus: "WAITING_ON_INPUT"
|
|
170362
|
+
loopStatus: "WAITING_ON_INPUT",
|
|
170363
|
+
ownerFinished: false,
|
|
170364
|
+
externalSettlementPending: options3?.waitForExternalSettlement === true
|
|
170352
170365
|
};
|
|
170353
170366
|
return {
|
|
170354
170367
|
transitioned: true,
|
|
@@ -170359,17 +170372,39 @@ class TurnLifecycle {
|
|
|
170359
170372
|
}
|
|
170360
170373
|
finish(lease, stopReason) {
|
|
170361
170374
|
const state = this.#state;
|
|
170362
|
-
if (state.kind !== "active" && state.kind !== "cancelling" || state.lease.id !== lease.id) {
|
|
170375
|
+
if (state.kind !== "active" && state.kind !== "cancelling" || state.lease.id !== lease.id || state.kind === "cancelling" && state.ownerFinished) {
|
|
170363
170376
|
return { finished: false, previousKind: null, runId: null };
|
|
170364
170377
|
}
|
|
170365
170378
|
this.#lastStopReason = stopReason;
|
|
170366
|
-
|
|
170379
|
+
if (state.kind === "cancelling" && state.externalSettlementPending) {
|
|
170380
|
+
this.#state = {
|
|
170381
|
+
...state,
|
|
170382
|
+
ownerFinished: true
|
|
170383
|
+
};
|
|
170384
|
+
} else {
|
|
170385
|
+
this.#state = IDLE_STATE;
|
|
170386
|
+
}
|
|
170367
170387
|
return {
|
|
170368
170388
|
finished: true,
|
|
170369
170389
|
previousKind: state.kind,
|
|
170370
170390
|
runId: state.runId
|
|
170371
170391
|
};
|
|
170372
170392
|
}
|
|
170393
|
+
settleCancellation(lease) {
|
|
170394
|
+
const state = this.#state;
|
|
170395
|
+
if (state.kind !== "cancelling" || state.lease.id !== lease.id || !state.externalSettlementPending) {
|
|
170396
|
+
return { settled: false, released: false };
|
|
170397
|
+
}
|
|
170398
|
+
if (state.ownerFinished) {
|
|
170399
|
+
this.#state = IDLE_STATE;
|
|
170400
|
+
return { settled: true, released: true };
|
|
170401
|
+
}
|
|
170402
|
+
this.#state = {
|
|
170403
|
+
...state,
|
|
170404
|
+
externalSettlementPending: false
|
|
170405
|
+
};
|
|
170406
|
+
return { settled: true, released: false };
|
|
170407
|
+
}
|
|
170373
170408
|
reset(stopReason = "cancelled") {
|
|
170374
170409
|
const state = this.#state;
|
|
170375
170410
|
if (state.kind === "active" || state.kind === "cancelling") {
|
|
@@ -373430,54 +373465,11 @@ var init_memory_git = __esm(() => {
|
|
|
373430
373465
|
NO_UPSTREAM_PULL_ERROR_RE = /(there is no tracking information for the current branch|no upstream configured|no tracking branch)/i;
|
|
373431
373466
|
});
|
|
373432
373467
|
|
|
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
373468
|
// src/backend/local/local-message-projection.ts
|
|
373469
|
+
function sourceLocalMessageIdFromStoredMessageId(messageId) {
|
|
373470
|
+
const variantSeparator = messageId.search(/:(assistant|reasoning|tool):/);
|
|
373471
|
+
return variantSeparator >= 0 ? messageId.slice(0, variantSeparator) : messageId;
|
|
373472
|
+
}
|
|
373481
373473
|
function isLocalToolCallContent(content) {
|
|
373482
373474
|
return content.type === "toolCall" && typeof content.id === "string";
|
|
373483
373475
|
}
|
|
@@ -373813,6 +373805,96 @@ function mergeSnapshotContentWithExistingToolCalls(snapshotContent, existingCont
|
|
|
373813
373805
|
}
|
|
373814
373806
|
var LOCAL_REPAIRED_TOOL_RESULT_TEXT_MAX_CHARS = 40000;
|
|
373815
373807
|
|
|
373808
|
+
// src/backend/local/local-conversation-fork.ts
|
|
373809
|
+
function projectMessage(message, agentId, conversationId) {
|
|
373810
|
+
return projectLocalMessageToStoredMessages(message, agentId, conversationId, FORK_PROJECTION_FALLBACK_DATE);
|
|
373811
|
+
}
|
|
373812
|
+
function truncateAssistantThroughProjectedMessage(message, projectedMessageId, agentId, conversationId) {
|
|
373813
|
+
const selectedProjection = projectMessage(message, agentId, conversationId).find((projected) => projected.id === projectedMessageId);
|
|
373814
|
+
if (!selectedProjection)
|
|
373815
|
+
return message;
|
|
373816
|
+
const selectedJson = JSON.stringify(selectedProjection);
|
|
373817
|
+
for (let end = 1;end <= message.content.length; end += 1) {
|
|
373818
|
+
const candidate = { ...message, content: message.content.slice(0, end) };
|
|
373819
|
+
const candidateProjection = projectMessage(candidate, agentId, conversationId);
|
|
373820
|
+
const selectedCandidate = candidateProjection.find((projected) => projected.id === projectedMessageId);
|
|
373821
|
+
if (candidateProjection.at(-1)?.id === projectedMessageId && JSON.stringify(selectedCandidate) === selectedJson) {
|
|
373822
|
+
return candidate;
|
|
373823
|
+
}
|
|
373824
|
+
}
|
|
373825
|
+
return message;
|
|
373826
|
+
}
|
|
373827
|
+
function selectLocalMessagesForFork(messages, messageId, agentId, conversationId) {
|
|
373828
|
+
if (!messageId)
|
|
373829
|
+
return messages;
|
|
373830
|
+
for (let sourceIndex = 0;sourceIndex < messages.length; sourceIndex += 1) {
|
|
373831
|
+
const sourceMessage = messages[sourceIndex];
|
|
373832
|
+
if (!sourceMessage)
|
|
373833
|
+
continue;
|
|
373834
|
+
const projected = projectMessage(sourceMessage, agentId, conversationId);
|
|
373835
|
+
const projectedIndex = projected.findIndex((message) => message.id === messageId);
|
|
373836
|
+
if (projectedIndex < 0)
|
|
373837
|
+
continue;
|
|
373838
|
+
if (sourceMessage.role !== "assistant" || projectedIndex === projected.length - 1) {
|
|
373839
|
+
return messages.slice(0, sourceIndex + 1);
|
|
373840
|
+
}
|
|
373841
|
+
return [
|
|
373842
|
+
...messages.slice(0, sourceIndex),
|
|
373843
|
+
truncateAssistantThroughProjectedMessage(sourceMessage, messageId, agentId, conversationId)
|
|
373844
|
+
];
|
|
373845
|
+
}
|
|
373846
|
+
return;
|
|
373847
|
+
}
|
|
373848
|
+
var FORK_PROJECTION_FALLBACK_DATE = "1970-01-01T00:00:00.000Z";
|
|
373849
|
+
var init_local_conversation_fork = () => {};
|
|
373850
|
+
|
|
373851
|
+
// src/backend/local/local-conversation-list.ts
|
|
373852
|
+
function optionalString(value) {
|
|
373853
|
+
return typeof value === "string" ? value : undefined;
|
|
373854
|
+
}
|
|
373855
|
+
function matchesSummarySearch(conversation, normalizedSearch) {
|
|
373856
|
+
if (!normalizedSearch)
|
|
373857
|
+
return true;
|
|
373858
|
+
return conversation.id.toLowerCase().includes(normalizedSearch) || (conversation.summary?.toLowerCase().includes(normalizedSearch) ?? false);
|
|
373859
|
+
}
|
|
373860
|
+
function listLocalConversations(source2, body) {
|
|
373861
|
+
const bodyRecord = body ?? {};
|
|
373862
|
+
const agentId = optionalString(bodyRecord.agent_id);
|
|
373863
|
+
const after = optionalString(bodyRecord.after);
|
|
373864
|
+
const normalizedSearch = optionalString(bodyRecord.summary_search)?.trim().toLowerCase();
|
|
373865
|
+
const limit3 = typeof bodyRecord.limit === "number" ? bodyRecord.limit : 20;
|
|
373866
|
+
let conversations = [...source2].filter((conversation) => conversation.id !== "default" && (bodyRecord.include_hidden === true || !conversation.hidden) && (!agentId || conversation.agent_id === agentId) && matchesSummarySearch(conversation, normalizedSearch));
|
|
373867
|
+
conversations.sort((a, b) => {
|
|
373868
|
+
const aDate = a.last_message_at ?? a.updated_at ?? a.created_at ?? "";
|
|
373869
|
+
const bDate = b.last_message_at ?? b.updated_at ?? b.created_at ?? "";
|
|
373870
|
+
return bDate.localeCompare(aDate);
|
|
373871
|
+
});
|
|
373872
|
+
if (after) {
|
|
373873
|
+
const afterIndex = conversations.findIndex((conversation) => conversation.id === after);
|
|
373874
|
+
if (afterIndex >= 0)
|
|
373875
|
+
conversations = conversations.slice(afterIndex + 1);
|
|
373876
|
+
}
|
|
373877
|
+
return conversations.slice(0, limit3);
|
|
373878
|
+
}
|
|
373879
|
+
|
|
373880
|
+
// src/backend/local/local-message.ts
|
|
373881
|
+
function emptyLocalUsage() {
|
|
373882
|
+
return {
|
|
373883
|
+
input: 0,
|
|
373884
|
+
output: 0,
|
|
373885
|
+
cacheRead: 0,
|
|
373886
|
+
cacheWrite: 0,
|
|
373887
|
+
totalTokens: 0,
|
|
373888
|
+
cost: {
|
|
373889
|
+
input: 0,
|
|
373890
|
+
output: 0,
|
|
373891
|
+
cacheRead: 0,
|
|
373892
|
+
cacheWrite: 0,
|
|
373893
|
+
total: 0
|
|
373894
|
+
}
|
|
373895
|
+
};
|
|
373896
|
+
}
|
|
373897
|
+
|
|
373816
373898
|
// src/backend/local/local-model-normalization.ts
|
|
373817
373899
|
function supportedModelSettingsFromBody(bodyRecord) {
|
|
373818
373900
|
const modelSettings = isRecord(bodyRecord.model_settings) ? { ...bodyRecord.model_settings } : {};
|
|
@@ -374192,10 +374274,6 @@ function getIncludedMessageTypes(body) {
|
|
|
374192
374274
|
const messageTypes = value.filter((item) => typeof item === "string" && item.length > 0);
|
|
374193
374275
|
return messageTypes.length > 0 ? new Set(messageTypes) : undefined;
|
|
374194
374276
|
}
|
|
374195
|
-
function sourceLocalMessageIdFromStoredMessageId(messageId) {
|
|
374196
|
-
const variantSeparator = messageId.search(/:(assistant|reasoning|tool):/);
|
|
374197
|
-
return variantSeparator >= 0 ? messageId.slice(0, variantSeparator) : messageId;
|
|
374198
|
-
}
|
|
374199
374277
|
function toStoredOutputFields(chunk) {
|
|
374200
374278
|
const { id: _id, date: _date2, agent_id, conversation_id, ...fields } = chunk;
|
|
374201
374279
|
return fields;
|
|
@@ -374802,6 +374880,10 @@ class LocalStore {
|
|
|
374802
374880
|
throw new LocalBackendNotFoundError("Agent", targetAgentId);
|
|
374803
374881
|
}
|
|
374804
374882
|
this.ensureAgent(targetAgentId);
|
|
374883
|
+
const sourceMessages = selectLocalMessagesForFork(this.localMessagesForConversation(source2.id, source2.agent_id), options3.messageId, source2.agent_id, source2.id);
|
|
374884
|
+
if (!sourceMessages) {
|
|
374885
|
+
throw new LocalBackendNotFoundError("Message", options3.messageId ?? "");
|
|
374886
|
+
}
|
|
374805
374887
|
const forkedConversationId = this.nextConversationId(targetAgentId);
|
|
374806
374888
|
const forked = createLocalConversationRecord(forkedConversationId, targetAgentId, this.conversationSeq, {
|
|
374807
374889
|
summary: source2.summary ?? null,
|
|
@@ -374809,7 +374891,6 @@ class LocalStore {
|
|
|
374809
374891
|
...source2.model_settings !== undefined ? { model_settings: source2.model_settings } : {},
|
|
374810
374892
|
...typeof options3.hidden === "boolean" ? { hidden: options3.hidden } : {}
|
|
374811
374893
|
});
|
|
374812
|
-
const sourceMessages = this.localMessagesForConversation(source2.id, source2.agent_id);
|
|
374813
374894
|
const forkedMessages = sourceMessages.map((message) => this.cloneLocalMessageForConversation(message, forked.id, targetAgentId));
|
|
374814
374895
|
forked.in_context_message_ids = forkedMessages.map((message) => message.id);
|
|
374815
374896
|
const targetKey = this.conversationKey(forked.id, targetAgentId);
|
|
@@ -376104,6 +376185,7 @@ class LocalStore {
|
|
|
376104
376185
|
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
376186
|
var init_local_store = __esm(() => {
|
|
376106
376187
|
init_constants2();
|
|
376188
|
+
init_local_conversation_fork();
|
|
376107
376189
|
init_local_model_normalization();
|
|
376108
376190
|
init_local_stream_chunks();
|
|
376109
376191
|
LocalBackendNotFoundError = class LocalBackendNotFoundError extends Error {
|
|
@@ -377729,6 +377811,26 @@ class HeadlessBackend {
|
|
|
377729
377811
|
}
|
|
377730
377812
|
return { status: "cancelled" };
|
|
377731
377813
|
}
|
|
377814
|
+
async cancelRun(...args) {
|
|
377815
|
+
const [agentId, runId] = args;
|
|
377816
|
+
const run = this.runs.get(runId);
|
|
377817
|
+
if (!run || run.agent_id !== agentId || isTerminalRun(run)) {
|
|
377818
|
+
return { [runId]: "failed" };
|
|
377819
|
+
}
|
|
377820
|
+
if (run.conversation_id) {
|
|
377821
|
+
this.store.settleInterruptedToolCalls(run.conversation_id, { agentId });
|
|
377822
|
+
} else {
|
|
377823
|
+
this.store.settleInterruptedToolCalls(agentId);
|
|
377824
|
+
}
|
|
377825
|
+
const controller = this.runControllerByRunId.get(runId);
|
|
377826
|
+
this.recordRunChunk(runId, {
|
|
377827
|
+
message_type: "stop_reason",
|
|
377828
|
+
stop_reason: "cancelled"
|
|
377829
|
+
});
|
|
377830
|
+
this.completeRun(runId, "cancelled");
|
|
377831
|
+
controller?.abort();
|
|
377832
|
+
return { [runId]: "cancelled" };
|
|
377833
|
+
}
|
|
377732
377834
|
async retrieveRun(runId) {
|
|
377733
377835
|
const run = this.runs.get(runId);
|
|
377734
377836
|
if (!run)
|
|
@@ -378321,7 +378423,8 @@ function parseLlamaCppNativeModels(data) {
|
|
|
378321
378423
|
const id2 = record5.id ?? record5.name;
|
|
378322
378424
|
if (typeof id2 !== "string" || id2.length === 0)
|
|
378323
378425
|
continue;
|
|
378324
|
-
const
|
|
378426
|
+
const statusRecord = record5.status && typeof record5.status === "object" ? record5.status : undefined;
|
|
378427
|
+
const status = statusRecord?.value;
|
|
378325
378428
|
const architecture = record5.architecture && typeof record5.architecture === "object" ? record5.architecture : undefined;
|
|
378326
378429
|
const modalities = Array.isArray(architecture?.input_modalities) ? architecture.input_modalities.filter((value) => typeof value === "string") : undefined;
|
|
378327
378430
|
const meta3 = record5.meta && typeof record5.meta === "object" ? record5.meta : undefined;
|
|
@@ -378331,7 +378434,8 @@ function parseLlamaCppNativeModels(data) {
|
|
|
378331
378434
|
if (status !== undefined || modalities !== undefined || contextLength !== undefined) {
|
|
378332
378435
|
sawMetadata = true;
|
|
378333
378436
|
}
|
|
378334
|
-
|
|
378437
|
+
const selectable = status === undefined || status === "loaded" || status === "sleeping" || status === "unloaded" && statusRecord?.failed !== true;
|
|
378438
|
+
if (!selectable)
|
|
378335
378439
|
continue;
|
|
378336
378440
|
parsed.push(llamaCppModelMetadata(id2, {
|
|
378337
378441
|
...modalities !== undefined ? { vision: modalities.includes("image") } : {},
|
|
@@ -381902,6 +382006,10 @@ class APIBackend {
|
|
|
381902
382006
|
const client = await this.getClient();
|
|
381903
382007
|
return client.conversations.cancel(conversationIdOrAgentId);
|
|
381904
382008
|
}
|
|
382009
|
+
async cancelRun(agentId, runId) {
|
|
382010
|
+
const client = await this.getClient();
|
|
382011
|
+
return client.agents.messages.cancel(agentId, { run_ids: [runId] });
|
|
382012
|
+
}
|
|
381905
382013
|
async retrieveRun(runId) {
|
|
381906
382014
|
const client = await this.getClient();
|
|
381907
382015
|
return client.runs.retrieve(runId);
|
|
@@ -445556,6 +445664,26 @@ function actingUserRequestOptions(actingUserId) {
|
|
|
445556
445664
|
}
|
|
445557
445665
|
var ACTING_USER_ID_HEADER = "X-Letta-Acting-User-Id";
|
|
445558
445666
|
|
|
445667
|
+
// src/websocket/listener/management-protocol-inbound.ts
|
|
445668
|
+
function isObjectRecord(value) {
|
|
445669
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
445670
|
+
}
|
|
445671
|
+
function isConversationForkBody(value) {
|
|
445672
|
+
if (!isObjectRecord(value))
|
|
445673
|
+
return false;
|
|
445674
|
+
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);
|
|
445675
|
+
}
|
|
445676
|
+
function isAppServerInfoCommand(value) {
|
|
445677
|
+
if (!isObjectRecord(value))
|
|
445678
|
+
return false;
|
|
445679
|
+
return value.type === "app_server_info" && typeof value.request_id === "string" && value.request_id.length > 0;
|
|
445680
|
+
}
|
|
445681
|
+
function isConversationForkCommand(value) {
|
|
445682
|
+
if (!isObjectRecord(value))
|
|
445683
|
+
return false;
|
|
445684
|
+
return value.type === "conversation_fork" && typeof value.request_id === "string" && typeof value.conversation_id === "string" && (value.body === undefined || isConversationForkBody(value.body));
|
|
445685
|
+
}
|
|
445686
|
+
|
|
445559
445687
|
// src/websocket/listener/protocol-inbound.ts
|
|
445560
445688
|
function isExperimentId(value) {
|
|
445561
445689
|
return typeof value === "string" && EXPERIMENT_IDS.has(value);
|
|
@@ -445566,7 +445694,7 @@ function isStringArray6(value) {
|
|
|
445566
445694
|
function isStringRecord2(value) {
|
|
445567
445695
|
return !!value && typeof value === "object" && !Array.isArray(value) && Object.values(value).every((item) => typeof item === "string");
|
|
445568
445696
|
}
|
|
445569
|
-
function
|
|
445697
|
+
function isObjectRecord2(value) {
|
|
445570
445698
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
445571
445699
|
}
|
|
445572
445700
|
function isRuntimeScope(value) {
|
|
@@ -445716,27 +445844,27 @@ function isDevicePermissionMode(value) {
|
|
|
445716
445844
|
return value === "standard" || value === "acceptEdits" || value === "unrestricted";
|
|
445717
445845
|
}
|
|
445718
445846
|
function isRuntimeStartCreateAgentOptions(value) {
|
|
445719
|
-
if (!
|
|
445847
|
+
if (!isObjectRecord2(value))
|
|
445720
445848
|
return false;
|
|
445721
|
-
return
|
|
445849
|
+
return isObjectRecord2(value.body) && (value.pin_global === undefined || typeof value.pin_global === "boolean") && (value.memfs === undefined || typeof value.memfs === "boolean");
|
|
445722
445850
|
}
|
|
445723
445851
|
function isRuntimeStartCreateConversationOptions(value) {
|
|
445724
|
-
if (!
|
|
445852
|
+
if (!isObjectRecord2(value))
|
|
445725
445853
|
return false;
|
|
445726
|
-
return value.body === undefined ||
|
|
445854
|
+
return value.body === undefined || isObjectRecord2(value.body);
|
|
445727
445855
|
}
|
|
445728
445856
|
function isRuntimeStartClientInfo(value) {
|
|
445729
|
-
if (!
|
|
445857
|
+
if (!isObjectRecord2(value))
|
|
445730
445858
|
return false;
|
|
445731
445859
|
return typeof value.name === "string" && (value.title === undefined || typeof value.title === "string") && (value.version === undefined || typeof value.version === "string");
|
|
445732
445860
|
}
|
|
445733
445861
|
function isExternalToolDefinitionPayload(value) {
|
|
445734
|
-
if (!
|
|
445862
|
+
if (!isObjectRecord2(value))
|
|
445735
445863
|
return false;
|
|
445736
|
-
return typeof value.name === "string" && (value.label === undefined || typeof value.label === "string") && typeof value.description === "string" &&
|
|
445864
|
+
return typeof value.name === "string" && (value.label === undefined || typeof value.label === "string") && typeof value.description === "string" && isObjectRecord2(value.parameters);
|
|
445737
445865
|
}
|
|
445738
445866
|
function isRuntimeStartExternalToolsGroup(value) {
|
|
445739
|
-
if (!
|
|
445867
|
+
if (!isObjectRecord2(value))
|
|
445740
445868
|
return false;
|
|
445741
445869
|
return (value.scope_id === undefined || typeof value.scope_id === "string") && Array.isArray(value.tools) && value.tools.every(isExternalToolDefinitionPayload);
|
|
445742
445870
|
}
|
|
@@ -445747,7 +445875,7 @@ function isRuntimeStartCommand(value) {
|
|
|
445747
445875
|
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
445876
|
}
|
|
445749
445877
|
function isExternalToolCallResponseCommand(value) {
|
|
445750
|
-
if (!
|
|
445878
|
+
if (!isObjectRecord2(value))
|
|
445751
445879
|
return false;
|
|
445752
445880
|
if (value.type !== "external_tool_call_response" || typeof value.request_id !== "string") {
|
|
445753
445881
|
return false;
|
|
@@ -445758,10 +445886,10 @@ function isExternalToolCallResponseCommand(value) {
|
|
|
445758
445886
|
if (value.result === undefined) {
|
|
445759
445887
|
return typeof value.error === "string";
|
|
445760
445888
|
}
|
|
445761
|
-
if (!
|
|
445889
|
+
if (!isObjectRecord2(value.result)) {
|
|
445762
445890
|
return false;
|
|
445763
445891
|
}
|
|
445764
|
-
return Array.isArray(value.result.content) && value.result.content.every(
|
|
445892
|
+
return Array.isArray(value.result.content) && value.result.content.every(isObjectRecord2) && (value.result.is_error === undefined || typeof value.result.is_error === "boolean");
|
|
445765
445893
|
}
|
|
445766
445894
|
function isTerminalSpawnCommand(value) {
|
|
445767
445895
|
if (!value || typeof value !== "object")
|
|
@@ -446021,7 +446149,7 @@ function isAgentListCommand(value) {
|
|
|
446021
446149
|
if (!value || typeof value !== "object")
|
|
446022
446150
|
return false;
|
|
446023
446151
|
const c = value;
|
|
446024
|
-
return c.type === "agent_list" && typeof c.request_id === "string" && (c.query === undefined ||
|
|
446152
|
+
return c.type === "agent_list" && typeof c.request_id === "string" && (c.query === undefined || isObjectRecord2(c.query));
|
|
446025
446153
|
}
|
|
446026
446154
|
function isAgentRetrieveCommand(value) {
|
|
446027
446155
|
if (!value || typeof value !== "object")
|
|
@@ -446033,13 +446161,13 @@ function isAgentCreateCommand(value) {
|
|
|
446033
446161
|
if (!value || typeof value !== "object")
|
|
446034
446162
|
return false;
|
|
446035
446163
|
const c = value;
|
|
446036
|
-
return c.type === "agent_create" && typeof c.request_id === "string" &&
|
|
446164
|
+
return c.type === "agent_create" && typeof c.request_id === "string" && isObjectRecord2(c.body);
|
|
446037
446165
|
}
|
|
446038
446166
|
function isAgentUpdateCommand(value) {
|
|
446039
446167
|
if (!value || typeof value !== "object")
|
|
446040
446168
|
return false;
|
|
446041
446169
|
const c = value;
|
|
446042
|
-
return c.type === "agent_update" && typeof c.request_id === "string" && typeof c.agent_id === "string" &&
|
|
446170
|
+
return c.type === "agent_update" && typeof c.request_id === "string" && typeof c.agent_id === "string" && isObjectRecord2(c.body);
|
|
446043
446171
|
}
|
|
446044
446172
|
function isAgentDeleteCommand(value) {
|
|
446045
446173
|
if (!value || typeof value !== "object")
|
|
@@ -446051,7 +446179,7 @@ function isConversationListCommand(value) {
|
|
|
446051
446179
|
if (!value || typeof value !== "object")
|
|
446052
446180
|
return false;
|
|
446053
446181
|
const c = value;
|
|
446054
|
-
return c.type === "conversation_list" && typeof c.request_id === "string" && (c.query === undefined ||
|
|
446182
|
+
return c.type === "conversation_list" && typeof c.request_id === "string" && (c.query === undefined || isObjectRecord2(c.query));
|
|
446055
446183
|
}
|
|
446056
446184
|
function isConversationRetrieveCommand(value) {
|
|
446057
446185
|
if (!value || typeof value !== "object")
|
|
@@ -446063,37 +446191,31 @@ function isConversationCreateCommand(value) {
|
|
|
446063
446191
|
if (!value || typeof value !== "object")
|
|
446064
446192
|
return false;
|
|
446065
446193
|
const c = value;
|
|
446066
|
-
return c.type === "conversation_create" && typeof c.request_id === "string" &&
|
|
446194
|
+
return c.type === "conversation_create" && typeof c.request_id === "string" && isObjectRecord2(c.body);
|
|
446067
446195
|
}
|
|
446068
446196
|
function isConversationUpdateCommand(value) {
|
|
446069
446197
|
if (!value || typeof value !== "object")
|
|
446070
446198
|
return false;
|
|
446071
446199
|
const c = value;
|
|
446072
|
-
return c.type === "conversation_update" && typeof c.request_id === "string" && typeof c.conversation_id === "string" &&
|
|
446200
|
+
return c.type === "conversation_update" && typeof c.request_id === "string" && typeof c.conversation_id === "string" && isObjectRecord2(c.body);
|
|
446073
446201
|
}
|
|
446074
446202
|
function isConversationRecompileCommand(value) {
|
|
446075
446203
|
if (!value || typeof value !== "object")
|
|
446076
446204
|
return false;
|
|
446077
446205
|
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));
|
|
446206
|
+
return c.type === "conversation_recompile" && typeof c.request_id === "string" && typeof c.conversation_id === "string" && (c.body === undefined || isObjectRecord2(c.body));
|
|
446085
446207
|
}
|
|
446086
446208
|
function isConversationMessagesListCommand(value) {
|
|
446087
446209
|
if (!value || typeof value !== "object")
|
|
446088
446210
|
return false;
|
|
446089
446211
|
const c = value;
|
|
446090
|
-
return c.type === "conversation_messages_list" && typeof c.request_id === "string" && typeof c.conversation_id === "string" && (c.query === undefined ||
|
|
446212
|
+
return c.type === "conversation_messages_list" && typeof c.request_id === "string" && typeof c.conversation_id === "string" && (c.query === undefined || isObjectRecord2(c.query));
|
|
446091
446213
|
}
|
|
446092
446214
|
function isConversationCompactCommand(value) {
|
|
446093
446215
|
if (!value || typeof value !== "object")
|
|
446094
446216
|
return false;
|
|
446095
446217
|
const c = value;
|
|
446096
|
-
return c.type === "conversation_compact" && typeof c.request_id === "string" && typeof c.conversation_id === "string" && (c.body === undefined ||
|
|
446218
|
+
return c.type === "conversation_compact" && typeof c.request_id === "string" && typeof c.conversation_id === "string" && (c.body === undefined || isObjectRecord2(c.body));
|
|
446097
446219
|
}
|
|
446098
446220
|
function isGetReflectionSettingsCommand(value) {
|
|
446099
446221
|
if (!value || typeof value !== "object")
|
|
@@ -446348,7 +446470,7 @@ function parseServerMessage(data) {
|
|
|
446348
446470
|
if (legacyInput) {
|
|
446349
446471
|
return legacyInput;
|
|
446350
446472
|
}
|
|
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)) {
|
|
446473
|
+
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
446474
|
return parsed;
|
|
446353
446475
|
}
|
|
446354
446476
|
const invalidInput = getInvalidInputReason(parsed);
|
|
@@ -446626,6 +446748,7 @@ async function handleAgentConversationManagementCommand(parsed, socket, safeSock
|
|
|
446626
446748
|
const conversation = await backend3.forkConversation(parsed.conversation_id, {
|
|
446627
446749
|
...typeof parsed.body?.agent_id === "string" ? { agentId: parsed.body.agent_id } : {},
|
|
446628
446750
|
...typeof parsed.body?.hidden === "boolean" ? { hidden: parsed.body.hidden } : {},
|
|
446751
|
+
...typeof parsed.body?.message_id === "string" ? { messageId: parsed.body.message_id } : {},
|
|
446629
446752
|
...actingUserRequestOptions(parsed.acting_user_id) ?? {}
|
|
446630
446753
|
});
|
|
446631
446754
|
safeSocketSend(socket, {
|
|
@@ -459568,6 +459691,12 @@ async function handleAbortMessageInput(listener, params, deps = {}) {
|
|
|
459568
459691
|
const cancelId = conversationId === "default" || !conversationId ? agentId : conversationId;
|
|
459569
459692
|
await getBackend().cancelConversation(cancelId);
|
|
459570
459693
|
},
|
|
459694
|
+
cancelRun: async (agentId, runId) => {
|
|
459695
|
+
const result = await getBackend().cancelRun(agentId, runId);
|
|
459696
|
+
if (result[runId] !== "cancelled") {
|
|
459697
|
+
throw new Error(`Backend did not cancel run ${runId}`);
|
|
459698
|
+
}
|
|
459699
|
+
},
|
|
459571
459700
|
...deps
|
|
459572
459701
|
};
|
|
459573
459702
|
if (listener !== resolvedDeps.getActiveRuntime() || listener.intentionallyClosed) {
|
|
@@ -459583,7 +459712,9 @@ async function handleAbortMessageInput(listener, params, deps = {}) {
|
|
|
459583
459712
|
if (!hasActiveTurn && !hasPendingApprovals) {
|
|
459584
459713
|
return false;
|
|
459585
459714
|
}
|
|
459586
|
-
const cancellation = scopedRuntime.turnLifecycle.requestCancellation(
|
|
459715
|
+
const cancellation = scopedRuntime.turnLifecycle.requestCancellation({
|
|
459716
|
+
waitForExternalSettlement: hasActiveTurn && Boolean(scopedRuntime.agentId)
|
|
459717
|
+
});
|
|
459587
459718
|
const interruptedRunId = cancellation.runId;
|
|
459588
459719
|
const pendingRequestsSnapshot = hasPendingApprovals ? resolvedDeps.getPendingControlRequests(listener, scope) : [];
|
|
459589
459720
|
if (cancellation.executingToolCallIds.length > 0 && (!scopedRuntime.pendingInterruptedResults || scopedRuntime.pendingInterruptedResults.length === 0)) {
|
|
@@ -459646,7 +459777,17 @@ async function handleAbortMessageInput(listener, params, deps = {}) {
|
|
|
459646
459777
|
const cancelConversationId = scopedRuntime.conversationId;
|
|
459647
459778
|
const cancelAgentId = scopedRuntime.agentId;
|
|
459648
459779
|
if (cancelAgentId) {
|
|
459649
|
-
|
|
459780
|
+
const cancelRunId = interruptedRunId ?? params.command.run_id ?? null;
|
|
459781
|
+
const backendCancellation = cancelRunId ? resolvedDeps.cancelRun(cancelAgentId, cancelRunId).catch(() => resolvedDeps.cancelConversation(cancelAgentId, cancelConversationId)) : resolvedDeps.cancelConversation(cancelAgentId, cancelConversationId);
|
|
459782
|
+
backendCancellation.catch(() => {}).finally(() => {
|
|
459783
|
+
if (!cancellation.lease) {
|
|
459784
|
+
return;
|
|
459785
|
+
}
|
|
459786
|
+
const settlement = scopedRuntime.turnLifecycle.settleCancellation(cancellation.lease);
|
|
459787
|
+
if (settlement.released) {
|
|
459788
|
+
resolvedDeps.scheduleQueuePump(scopedRuntime, params.socket, params.opts, params.processQueuedTurn);
|
|
459789
|
+
}
|
|
459790
|
+
});
|
|
459650
459791
|
}
|
|
459651
459792
|
resolvedDeps.scheduleQueuePump(scopedRuntime, params.socket, params.opts, params.processQueuedTurn);
|
|
459652
459793
|
return true;
|
|
@@ -462006,6 +462147,41 @@ var init_file_commands = __esm(async () => {
|
|
|
462006
462147
|
ignoreConfigCache = new Map;
|
|
462007
462148
|
});
|
|
462008
462149
|
|
|
462150
|
+
// src/types/app-server-info.ts
|
|
462151
|
+
var APP_SERVER_PROTOCOL_VERSION = 1;
|
|
462152
|
+
|
|
462153
|
+
// src/websocket/listener/commands/app-server-info.ts
|
|
462154
|
+
function buildAppServerInfoResponse(command, options3) {
|
|
462155
|
+
return {
|
|
462156
|
+
type: "app_server_info_response",
|
|
462157
|
+
request_id: command.request_id,
|
|
462158
|
+
success: true,
|
|
462159
|
+
backend: options3.backend,
|
|
462160
|
+
letta_code_version: options3.version,
|
|
462161
|
+
protocol_version: APP_SERVER_PROTOCOL_VERSION,
|
|
462162
|
+
capabilities: {
|
|
462163
|
+
agent_management: true,
|
|
462164
|
+
conversation_management: true,
|
|
462165
|
+
memory_management: true,
|
|
462166
|
+
runtime_start: true,
|
|
462167
|
+
split_channels: true
|
|
462168
|
+
}
|
|
462169
|
+
};
|
|
462170
|
+
}
|
|
462171
|
+
function getAppServerInfoResponse(requestId) {
|
|
462172
|
+
return buildAppServerInfoResponse({ type: "app_server_info", request_id: requestId }, {
|
|
462173
|
+
backend: isLocalBackendEnabled() ? "local" : "api",
|
|
462174
|
+
version: getVersion()
|
|
462175
|
+
});
|
|
462176
|
+
}
|
|
462177
|
+
function handleAppServerInfoCommand(command, context3) {
|
|
462178
|
+
context3.safeSocketSend(context3.socket, getAppServerInfoResponse(command.request_id), "listener_app_server_info_send_failed", "listener_app_server_info");
|
|
462179
|
+
}
|
|
462180
|
+
var init_app_server_info = __esm(() => {
|
|
462181
|
+
init_backend2();
|
|
462182
|
+
init_version();
|
|
462183
|
+
});
|
|
462184
|
+
|
|
462009
462185
|
// src/providers/chatgpt-usage-service.ts
|
|
462010
462186
|
import { hostname as hostname4 } from "node:os";
|
|
462011
462187
|
function asRecord7(value) {
|
|
@@ -463388,6 +463564,10 @@ function createListenerMessageHandler(params) {
|
|
|
463388
463564
|
});
|
|
463389
463565
|
return;
|
|
463390
463566
|
}
|
|
463567
|
+
if (parsed.type === "app_server_info") {
|
|
463568
|
+
handleAppServerInfoCommand(parsed, { socket, safeSocketSend });
|
|
463569
|
+
return;
|
|
463570
|
+
}
|
|
463391
463571
|
if (handleRuntimeStartProtocolCommand(parsed, {
|
|
463392
463572
|
socket,
|
|
463393
463573
|
runtime,
|
|
@@ -463758,6 +463938,7 @@ var init_message_router = __esm(async () => {
|
|
|
463758
463938
|
init_settings_manager();
|
|
463759
463939
|
init_debug();
|
|
463760
463940
|
init_terminal_handler();
|
|
463941
|
+
init_app_server_info();
|
|
463761
463942
|
init_cwd();
|
|
463762
463943
|
init_runtime6();
|
|
463763
463944
|
await __promiseAll([
|
|
@@ -469796,6 +469977,19 @@ async function startAppServer(options3 = {}) {
|
|
|
469796
469977
|
`);
|
|
469797
469978
|
return;
|
|
469798
469979
|
}
|
|
469980
|
+
if (requestUrl.pathname === "/app-server-info") {
|
|
469981
|
+
const authError = authorizeUpgrade(request.headers, authPolicy);
|
|
469982
|
+
if (authError) {
|
|
469983
|
+
response.writeHead(authError.statusCode, {
|
|
469984
|
+
"content-type": "application/json"
|
|
469985
|
+
});
|
|
469986
|
+
response.end(JSON.stringify({ error: authError.message }));
|
|
469987
|
+
return;
|
|
469988
|
+
}
|
|
469989
|
+
response.writeHead(200, { "content-type": "application/json" });
|
|
469990
|
+
response.end(JSON.stringify(getAppServerInfoResponse("http-info")));
|
|
469991
|
+
return;
|
|
469992
|
+
}
|
|
469799
469993
|
if (options3.openaiApi && isOpenAiCompatPath(requestUrl.pathname)) {
|
|
469800
469994
|
handleOpenAiCompatRequest(request, response, {
|
|
469801
469995
|
authPolicy,
|
|
@@ -469915,6 +470109,7 @@ var init_app_server = __esm(async () => {
|
|
|
469915
470109
|
init_settings_manager();
|
|
469916
470110
|
init_telemetry();
|
|
469917
470111
|
init_app_server_auth();
|
|
470112
|
+
init_app_server_info();
|
|
469918
470113
|
init_runtime6();
|
|
469919
470114
|
await __promiseAll([
|
|
469920
470115
|
init_manager4(),
|
|
@@ -541037,4 +541232,4 @@ function registerBunOAuthFlows() {
|
|
|
541037
541232
|
registerBunOAuthFlows();
|
|
541038
541233
|
await init_src5().then(() => exports_src2);
|
|
541039
541234
|
|
|
541040
|
-
//# debugId=
|
|
541235
|
+
//# debugId=CFB812BEB8775E6764756E2164756E21
|