@librechat/agents 3.4.3 → 3.4.5
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/cjs/graphs/Graph.cjs +27 -14
- package/dist/cjs/graphs/Graph.cjs.map +1 -1
- package/dist/cjs/graphs/MultiAgentGraph.cjs +1 -1
- package/dist/cjs/hitl/askUserQuestions.cjs +66 -0
- package/dist/cjs/hitl/askUserQuestions.cjs.map +1 -0
- package/dist/cjs/hitl/askUserQuestionsInterrupt.cjs +46 -0
- package/dist/cjs/hitl/askUserQuestionsInterrupt.cjs.map +1 -0
- package/dist/cjs/hitl/index.cjs +2 -0
- package/dist/cjs/instrumentation.cjs +3 -3
- package/dist/cjs/langfuse.cjs +3 -3
- package/dist/cjs/langfuseRuntimeScope.cjs +1 -1
- package/dist/cjs/langfuseToolOutputTracing.cjs +2 -2
- package/dist/cjs/main.cjs +11 -1
- package/dist/cjs/messages/assistantPhase.cjs +59 -0
- package/dist/cjs/messages/assistantPhase.cjs.map +1 -0
- package/dist/cjs/messages/index.cjs +1 -0
- package/dist/cjs/prompts/activityLabel.cjs +76 -0
- package/dist/cjs/prompts/activityLabel.cjs.map +1 -1
- package/dist/cjs/run.cjs +200 -10
- package/dist/cjs/run.cjs.map +1 -1
- package/dist/cjs/session/AgentSession.cjs +1 -1
- package/dist/cjs/stream.cjs +45 -8
- package/dist/cjs/stream.cjs.map +1 -1
- package/dist/cjs/tools/ToolNode.cjs +3 -3
- package/dist/cjs/tools/subagent/SubagentExecutor.cjs +81 -6
- package/dist/cjs/tools/subagent/SubagentExecutor.cjs.map +1 -1
- package/dist/cjs/types/hitl.cjs +13 -0
- package/dist/cjs/types/hitl.cjs.map +1 -0
- package/dist/cjs/utils/callbacks.cjs +8 -0
- package/dist/cjs/utils/callbacks.cjs.map +1 -1
- package/dist/esm/graphs/Graph.mjs +27 -14
- package/dist/esm/graphs/Graph.mjs.map +1 -1
- package/dist/esm/graphs/MultiAgentGraph.mjs +1 -1
- package/dist/esm/hitl/askUserQuestions.mjs +66 -0
- package/dist/esm/hitl/askUserQuestions.mjs.map +1 -0
- package/dist/esm/hitl/askUserQuestionsInterrupt.mjs +43 -0
- package/dist/esm/hitl/askUserQuestionsInterrupt.mjs.map +1 -0
- package/dist/esm/hitl/index.mjs +2 -0
- package/dist/esm/instrumentation.mjs +3 -3
- package/dist/esm/langfuse.mjs +3 -3
- package/dist/esm/langfuseRuntimeScope.mjs +1 -1
- package/dist/esm/langfuseToolOutputTracing.mjs +2 -2
- package/dist/esm/main.mjs +5 -2
- package/dist/esm/messages/assistantPhase.mjs +57 -0
- package/dist/esm/messages/assistantPhase.mjs.map +1 -0
- package/dist/esm/messages/index.mjs +1 -0
- package/dist/esm/prompts/activityLabel.mjs +74 -1
- package/dist/esm/prompts/activityLabel.mjs.map +1 -1
- package/dist/esm/run.mjs +202 -12
- package/dist/esm/run.mjs.map +1 -1
- package/dist/esm/session/AgentSession.mjs +1 -1
- package/dist/esm/stream.mjs +45 -8
- package/dist/esm/stream.mjs.map +1 -1
- package/dist/esm/tools/ToolNode.mjs +3 -3
- package/dist/esm/tools/subagent/SubagentExecutor.mjs +81 -6
- package/dist/esm/tools/subagent/SubagentExecutor.mjs.map +1 -1
- package/dist/esm/types/hitl.mjs +13 -0
- package/dist/esm/types/hitl.mjs.map +1 -0
- package/dist/esm/utils/callbacks.mjs +8 -1
- package/dist/esm/utils/callbacks.mjs.map +1 -1
- package/dist/types/hitl/askUserQuestions.d.ts +24 -0
- package/dist/types/hitl/askUserQuestionsInterrupt.d.ts +11 -0
- package/dist/types/hitl/index.d.ts +2 -0
- package/dist/types/messages/assistantPhase.d.ts +22 -0
- package/dist/types/messages/index.d.ts +1 -0
- package/dist/types/prompts/activityLabel.d.ts +21 -1
- package/dist/types/run.d.ts +15 -2
- package/dist/types/types/activityLabel.d.ts +63 -0
- package/dist/types/types/assistantPhase.d.ts +6 -0
- package/dist/types/types/graph.d.ts +8 -1
- package/dist/types/types/hitl.d.ts +31 -2
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/types/stream.d.ts +11 -0
- package/dist/types/utils/callbacks.d.ts +1 -0
- package/package.json +2 -1
- package/src/graphs/Graph.ts +33 -9
- package/src/graphs/__tests__/Graph.reasoning.test.ts +57 -0
- package/src/hitl/askUserQuestions.ts +126 -0
- package/src/hitl/askUserQuestionsInterrupt.ts +115 -0
- package/src/hitl/index.ts +6 -0
- package/src/messages/assistantPhase.test.ts +75 -0
- package/src/messages/assistantPhase.ts +91 -0
- package/src/messages/index.ts +1 -0
- package/src/prompts/activityLabel.ts +177 -1
- package/src/run.ts +403 -21
- package/src/specs/activity-label-prompt.test.ts +123 -1
- package/src/specs/activity-phase-label.test.ts +306 -0
- package/src/specs/ask-user-questions.live.test.ts +185 -0
- package/src/specs/ask-user-questions.test.ts +293 -0
- package/src/stream.ts +69 -12
- package/src/tools/__tests__/SubagentExecutor.test.ts +436 -0
- package/src/tools/subagent/SubagentExecutor.ts +160 -8
- package/src/types/activityLabel.ts +65 -0
- package/src/types/assistantPhase.ts +6 -0
- package/src/types/graph.ts +8 -0
- package/src/types/hitl.ts +36 -2
- package/src/types/index.ts +1 -0
- package/src/types/stream.ts +9 -0
- package/src/utils/callbacks.ts +21 -0
package/dist/esm/stream.mjs
CHANGED
|
@@ -5,12 +5,13 @@ import { calculateMaxToolResultChars, truncateToolResultContent } from "./utils/
|
|
|
5
5
|
import { serializeStructuredValueBounded, serializeToolContentBounded } from "./utils/toolContent.mjs";
|
|
6
6
|
import { getMessageId } from "./messages/ids.mjs";
|
|
7
7
|
import { safeDispatchCustomEvent } from "./utils/events.mjs";
|
|
8
|
+
import { getMessageCreationContentMetadata, splitAssistantTextContentByPhase } from "./messages/assistantPhase.mjs";
|
|
8
9
|
import "./messages/index.mjs";
|
|
9
10
|
import { isGoogleLike } from "./utils/llm.mjs";
|
|
10
11
|
import { getStreamedToolCallAdapter, getStreamedToolCallSeal, streamedToolCallAdapterAllowsSequentialSeal } from "./tools/streamedToolCallSeals.mjs";
|
|
12
|
+
import { STREAM_LIMIT_EPOCH_KEY, StreamLimitExceededError, claimStreamLimitCharge, combineCompleteToolCalls, enforceCompleteToolCallArgLimit, enforceStreamDeltaEventLimit, enforceStreamedToolCallArgLimit, requiresStreamLimitAccounting } from "./llm/streamLimits.mjs";
|
|
11
13
|
import { buildToolExecutionRequestPlan, coerceRecordArgs, normalizeError } from "./tools/eagerEventExecution.mjs";
|
|
12
14
|
import { handleServerToolResult, handleToolCallChunks, handleToolCalls } from "./tools/handlers.mjs";
|
|
13
|
-
import { STREAM_LIMIT_EPOCH_KEY, StreamLimitExceededError, claimStreamLimitCharge, combineCompleteToolCalls, enforceCompleteToolCallArgLimit, enforceStreamDeltaEventLimit, enforceStreamedToolCallArgLimit, requiresStreamLimitAccounting } from "./llm/streamLimits.mjs";
|
|
14
15
|
import { outcomeFieldsFromResult, resolveToolOutcome } from "./tools/intentArg.mjs";
|
|
15
16
|
import { TOOL_OUTPUT_REF_PATTERN } from "./tools/toolOutputReferences.mjs";
|
|
16
17
|
//#region src/stream.ts
|
|
@@ -206,11 +207,14 @@ function shouldStartFreshMessageStepAfterGoogleServerSideTool({ graph, stepId, r
|
|
|
206
207
|
if (typeof content === "string") return true;
|
|
207
208
|
return content.every((c) => isTextContentPart(c)) || content.every((c) => isReasoningContentPart(c));
|
|
208
209
|
}
|
|
209
|
-
async function dispatchMessageCreationStep({ graph, stepKey, metadata }) {
|
|
210
|
+
async function dispatchMessageCreationStep({ graph, stepKey, content, contentType, metadata }) {
|
|
210
211
|
const messageId = getMessageId(stepKey, graph, true) ?? "";
|
|
211
212
|
return graph.dispatchRunStep(stepKey, {
|
|
212
213
|
type: "message_creation",
|
|
213
|
-
message_creation: {
|
|
214
|
+
message_creation: {
|
|
215
|
+
message_id: messageId,
|
|
216
|
+
...getMessageCreationContentMetadata(content, contentType)
|
|
217
|
+
}
|
|
214
218
|
}, metadata);
|
|
215
219
|
}
|
|
216
220
|
async function dispatchMessageContentParts({ graph, stepKey, content, metadata }) {
|
|
@@ -218,6 +222,7 @@ async function dispatchMessageContentParts({ graph, stepKey, content, metadata }
|
|
|
218
222
|
const currentStepId = await dispatchMessageCreationStep({
|
|
219
223
|
graph,
|
|
220
224
|
stepKey,
|
|
225
|
+
content: [contentPart],
|
|
221
226
|
metadata
|
|
222
227
|
});
|
|
223
228
|
if (isGoogleServerSideToolContentPart(contentPart)) markGoogleServerSideToolMessageStep(graph, currentStepId);
|
|
@@ -229,6 +234,8 @@ async function dispatchReasoningContentParts({ graph, stepKey, content, metadata
|
|
|
229
234
|
const currentStepId = await dispatchMessageCreationStep({
|
|
230
235
|
graph,
|
|
231
236
|
stepKey,
|
|
237
|
+
content,
|
|
238
|
+
contentType: "think",
|
|
232
239
|
metadata
|
|
233
240
|
});
|
|
234
241
|
await graph.dispatchReasoningDelta(currentStepId, { content }, metadata);
|
|
@@ -803,11 +810,37 @@ var ChatModelStreamHandler = class {
|
|
|
803
810
|
}
|
|
804
811
|
if (isEmptyContent) return;
|
|
805
812
|
if (hasGoogleServerSideToolContent) return;
|
|
813
|
+
if (Array.isArray(content) && content.every(isTextContentPart)) {
|
|
814
|
+
const contentGroups = splitAssistantTextContentByPhase(content);
|
|
815
|
+
const currentStepId = graph.stepKeyIds?.get(stepKey)?.at(-1);
|
|
816
|
+
const currentStep = currentStepId == null ? void 0 : graph.getRunStep(currentStepId);
|
|
817
|
+
const currentPhase = currentStep?.stepDetails.type === "message_creation" ? currentStep.stepDetails.message_creation.phase : void 0;
|
|
818
|
+
const nextPhase = getMessageCreationContentMetadata(contentGroups[0]).phase;
|
|
819
|
+
const phaseChanged = currentPhase != null && nextPhase != null && currentPhase !== nextPhase;
|
|
820
|
+
if (contentGroups.length > 1 || phaseChanged) {
|
|
821
|
+
for (const contentGroup of contentGroups) {
|
|
822
|
+
const currentStepId = await dispatchMessageCreationStep({
|
|
823
|
+
graph,
|
|
824
|
+
stepKey,
|
|
825
|
+
content: contentGroup,
|
|
826
|
+
metadata
|
|
827
|
+
});
|
|
828
|
+
await graph.dispatchMessageDelta(currentStepId, { content: contentGroup }, metadata);
|
|
829
|
+
}
|
|
830
|
+
return;
|
|
831
|
+
}
|
|
832
|
+
}
|
|
806
833
|
const message_id = getMessageId(stepKey, graph) ?? "";
|
|
807
|
-
if (message_id)
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
834
|
+
if (message_id) {
|
|
835
|
+
const fallbackContentType = agentContext.currentTokenType === "text" ? "text" : "think";
|
|
836
|
+
await graph.dispatchRunStep(stepKey, {
|
|
837
|
+
type: "message_creation",
|
|
838
|
+
message_creation: {
|
|
839
|
+
message_id,
|
|
840
|
+
...getMessageCreationContentMetadata(content, fallbackContentType)
|
|
841
|
+
}
|
|
842
|
+
}, metadata);
|
|
843
|
+
}
|
|
811
844
|
let stepId = graph.getStepIdByKey(stepKey);
|
|
812
845
|
let runStep = graph.getRunStep(stepId);
|
|
813
846
|
if (shouldStartFreshMessageStepAfterGoogleServerSideTool({
|
|
@@ -819,6 +852,7 @@ var ChatModelStreamHandler = class {
|
|
|
819
852
|
stepId = await dispatchMessageCreationStep({
|
|
820
853
|
graph,
|
|
821
854
|
stepKey,
|
|
855
|
+
content,
|
|
822
856
|
metadata
|
|
823
857
|
});
|
|
824
858
|
runStep = graph.getRunStep(stepId);
|
|
@@ -860,7 +894,10 @@ hasToolCallChunks: ${hasToolCallChunks}
|
|
|
860
894
|
const message_id = getMessageId(newStepKey, graph) ?? "";
|
|
861
895
|
await graph.dispatchRunStep(newStepKey, {
|
|
862
896
|
type: "message_creation",
|
|
863
|
-
message_creation: {
|
|
897
|
+
message_creation: {
|
|
898
|
+
message_id,
|
|
899
|
+
content_type: "text"
|
|
900
|
+
}
|
|
864
901
|
}, metadata);
|
|
865
902
|
const newStepId = graph.getStepIdByKey(newStepKey);
|
|
866
903
|
await graph.dispatchMessageDelta(newStepId, { content: [{
|