@letta-ai/letta-code 0.1.17 → 0.1.18
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/letta.js +30 -9
- package/package.json +1 -1
package/letta.js
CHANGED
|
@@ -6677,7 +6677,7 @@ var package_default;
|
|
|
6677
6677
|
var init_package = __esm(() => {
|
|
6678
6678
|
package_default = {
|
|
6679
6679
|
name: "@letta-ai/letta-code",
|
|
6680
|
-
version: "0.1.
|
|
6680
|
+
version: "0.1.18",
|
|
6681
6681
|
description: "Letta Code is a CLI tool for interacting with stateful Letta agents from the terminal.",
|
|
6682
6682
|
type: "module",
|
|
6683
6683
|
bin: {
|
|
@@ -35659,6 +35659,11 @@ async function drainStream(stream, buffers, refresh, abortSignal) {
|
|
|
35659
35659
|
let stopReason = null;
|
|
35660
35660
|
let lastRunId = null;
|
|
35661
35661
|
let lastSeqId = null;
|
|
35662
|
+
const resetToolState = () => {
|
|
35663
|
+
toolCallId = null;
|
|
35664
|
+
toolName = null;
|
|
35665
|
+
toolArgs = null;
|
|
35666
|
+
};
|
|
35662
35667
|
for await (const chunk of stream) {
|
|
35663
35668
|
if (abortSignal?.aborted) {
|
|
35664
35669
|
stopReason = "cancelled";
|
|
@@ -35672,6 +35677,9 @@ async function drainStream(stream, buffers, refresh, abortSignal) {
|
|
|
35672
35677
|
}
|
|
35673
35678
|
if (chunk.message_type === "ping")
|
|
35674
35679
|
continue;
|
|
35680
|
+
if (chunk.message_type === "tool_return_message") {
|
|
35681
|
+
resetToolState();
|
|
35682
|
+
}
|
|
35675
35683
|
if (chunk.message_type === "approval_request_message") {
|
|
35676
35684
|
approvalRequestId = chunk.id;
|
|
35677
35685
|
}
|
|
@@ -35679,8 +35687,7 @@ async function drainStream(stream, buffers, refresh, abortSignal) {
|
|
|
35679
35687
|
const toolCall = chunk.tool_call || (Array.isArray(chunk.tool_calls) && chunk.tool_calls.length > 0 ? chunk.tool_calls[0] : null);
|
|
35680
35688
|
if (toolCall?.tool_call_id) {
|
|
35681
35689
|
if (toolCallId && toolCall.tool_call_id !== toolCallId) {
|
|
35682
|
-
|
|
35683
|
-
toolArgs = null;
|
|
35690
|
+
resetToolState();
|
|
35684
35691
|
}
|
|
35685
35692
|
toolCallId = toolCall.tool_call_id;
|
|
35686
35693
|
}
|
|
@@ -35709,11 +35716,25 @@ async function drainStream(stream, buffers, refresh, abortSignal) {
|
|
|
35709
35716
|
}
|
|
35710
35717
|
markCurrentLineAsFinished(buffers);
|
|
35711
35718
|
queueMicrotask(refresh);
|
|
35712
|
-
|
|
35713
|
-
|
|
35714
|
-
toolName
|
|
35715
|
-
|
|
35716
|
-
|
|
35719
|
+
let approval = null;
|
|
35720
|
+
if (stopReason === "requires_approval") {
|
|
35721
|
+
if (!toolCallId || !toolName || !toolArgs || !approvalRequestId) {
|
|
35722
|
+
console.error("[drainStream] Incomplete approval state at end of turn:", {
|
|
35723
|
+
hasToolCallId: !!toolCallId,
|
|
35724
|
+
hasToolName: !!toolName,
|
|
35725
|
+
hasToolArgs: !!toolArgs,
|
|
35726
|
+
hasApprovalRequestId: !!approvalRequestId
|
|
35727
|
+
});
|
|
35728
|
+
} else {
|
|
35729
|
+
approval = {
|
|
35730
|
+
toolCallId,
|
|
35731
|
+
toolName,
|
|
35732
|
+
toolArgs
|
|
35733
|
+
};
|
|
35734
|
+
}
|
|
35735
|
+
resetToolState();
|
|
35736
|
+
approvalRequestId = null;
|
|
35737
|
+
}
|
|
35717
35738
|
const apiDurationMs = performance.now() - startTime;
|
|
35718
35739
|
return { stopReason, approval, lastRunId, lastSeqId, apiDurationMs };
|
|
35719
35740
|
}
|
|
@@ -45999,4 +46020,4 @@ Note: Flags should use double dashes for full names (e.g., --yolo, not -yolo)`);
|
|
|
45999
46020
|
}
|
|
46000
46021
|
main();
|
|
46001
46022
|
|
|
46002
|
-
//# debugId=
|
|
46023
|
+
//# debugId=0F309FBC4BD78D6B64756E2164756E21
|