@librechat/agents 3.4.3 → 3.4.4
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/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 +5 -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/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/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 +3 -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/utils/callbacks.mjs +8 -1
- package/dist/esm/utils/callbacks.mjs.map +1 -1
- 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/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 +1 -1
- package/src/graphs/Graph.ts +33 -9
- package/src/graphs/__tests__/Graph.reasoning.test.ts +57 -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/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/index.ts +1 -0
- package/src/types/stream.ts +9 -0
- package/src/utils/callbacks.ts +21 -0
package/dist/cjs/stream.cjs
CHANGED
|
@@ -5,12 +5,13 @@ const require_truncation = require("./utils/truncation.cjs");
|
|
|
5
5
|
const require_toolContent = require("./utils/toolContent.cjs");
|
|
6
6
|
const require_ids = require("./messages/ids.cjs");
|
|
7
7
|
const require_events = require("./utils/events.cjs");
|
|
8
|
+
const require_assistantPhase = require("./messages/assistantPhase.cjs");
|
|
8
9
|
require("./messages/index.cjs");
|
|
9
10
|
const require_llm = require("./utils/llm.cjs");
|
|
10
11
|
const require_streamedToolCallSeals = require("./tools/streamedToolCallSeals.cjs");
|
|
12
|
+
const require_streamLimits = require("./llm/streamLimits.cjs");
|
|
11
13
|
const require_eagerEventExecution = require("./tools/eagerEventExecution.cjs");
|
|
12
14
|
const require_handlers = require("./tools/handlers.cjs");
|
|
13
|
-
const require_streamLimits = require("./llm/streamLimits.cjs");
|
|
14
15
|
const require_intentArg = require("./tools/intentArg.cjs");
|
|
15
16
|
const require_toolOutputReferences = require("./tools/toolOutputReferences.cjs");
|
|
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 = require_ids.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
|
+
...require_assistantPhase.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);
|
|
@@ -804,11 +811,37 @@ var ChatModelStreamHandler = class {
|
|
|
804
811
|
}
|
|
805
812
|
if (isEmptyContent) return;
|
|
806
813
|
if (hasGoogleServerSideToolContent) return;
|
|
814
|
+
if (Array.isArray(content) && content.every(isTextContentPart)) {
|
|
815
|
+
const contentGroups = require_assistantPhase.splitAssistantTextContentByPhase(content);
|
|
816
|
+
const currentStepId = graph.stepKeyIds?.get(stepKey)?.at(-1);
|
|
817
|
+
const currentStep = currentStepId == null ? void 0 : graph.getRunStep(currentStepId);
|
|
818
|
+
const currentPhase = currentStep?.stepDetails.type === "message_creation" ? currentStep.stepDetails.message_creation.phase : void 0;
|
|
819
|
+
const nextPhase = require_assistantPhase.getMessageCreationContentMetadata(contentGroups[0]).phase;
|
|
820
|
+
const phaseChanged = currentPhase != null && nextPhase != null && currentPhase !== nextPhase;
|
|
821
|
+
if (contentGroups.length > 1 || phaseChanged) {
|
|
822
|
+
for (const contentGroup of contentGroups) {
|
|
823
|
+
const currentStepId = await dispatchMessageCreationStep({
|
|
824
|
+
graph,
|
|
825
|
+
stepKey,
|
|
826
|
+
content: contentGroup,
|
|
827
|
+
metadata
|
|
828
|
+
});
|
|
829
|
+
await graph.dispatchMessageDelta(currentStepId, { content: contentGroup }, metadata);
|
|
830
|
+
}
|
|
831
|
+
return;
|
|
832
|
+
}
|
|
833
|
+
}
|
|
807
834
|
const message_id = require_ids.getMessageId(stepKey, graph) ?? "";
|
|
808
|
-
if (message_id)
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
835
|
+
if (message_id) {
|
|
836
|
+
const fallbackContentType = agentContext.currentTokenType === "text" ? "text" : "think";
|
|
837
|
+
await graph.dispatchRunStep(stepKey, {
|
|
838
|
+
type: "message_creation",
|
|
839
|
+
message_creation: {
|
|
840
|
+
message_id,
|
|
841
|
+
...require_assistantPhase.getMessageCreationContentMetadata(content, fallbackContentType)
|
|
842
|
+
}
|
|
843
|
+
}, metadata);
|
|
844
|
+
}
|
|
812
845
|
let stepId = graph.getStepIdByKey(stepKey);
|
|
813
846
|
let runStep = graph.getRunStep(stepId);
|
|
814
847
|
if (shouldStartFreshMessageStepAfterGoogleServerSideTool({
|
|
@@ -820,6 +853,7 @@ var ChatModelStreamHandler = class {
|
|
|
820
853
|
stepId = await dispatchMessageCreationStep({
|
|
821
854
|
graph,
|
|
822
855
|
stepKey,
|
|
856
|
+
content,
|
|
823
857
|
metadata
|
|
824
858
|
});
|
|
825
859
|
runStep = graph.getRunStep(stepId);
|
|
@@ -861,7 +895,10 @@ hasToolCallChunks: ${hasToolCallChunks}
|
|
|
861
895
|
const message_id = require_ids.getMessageId(newStepKey, graph) ?? "";
|
|
862
896
|
await graph.dispatchRunStep(newStepKey, {
|
|
863
897
|
type: "message_creation",
|
|
864
|
-
message_creation: {
|
|
898
|
+
message_creation: {
|
|
899
|
+
message_id,
|
|
900
|
+
content_type: "text"
|
|
901
|
+
}
|
|
865
902
|
}, metadata);
|
|
866
903
|
const newStepId = graph.getStepIdByKey(newStepKey);
|
|
867
904
|
await graph.dispatchMessageDelta(newStepId, { content: [{
|