@librechat/agents 3.7.10 → 3.7.12

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.
Files changed (60) hide show
  1. package/dist/cjs/graphs/Graph.cjs +11 -1
  2. package/dist/cjs/graphs/Graph.cjs.map +1 -1
  3. package/dist/cjs/graphs/MultiAgentGraph.cjs +36 -3
  4. package/dist/cjs/graphs/MultiAgentGraph.cjs.map +1 -1
  5. package/dist/cjs/langfuse.cjs +6 -2
  6. package/dist/cjs/langfuse.cjs.map +1 -1
  7. package/dist/cjs/main.cjs +2 -0
  8. package/dist/cjs/messages/format.cjs +6 -34
  9. package/dist/cjs/messages/format.cjs.map +1 -1
  10. package/dist/cjs/run.cjs +5 -1
  11. package/dist/cjs/run.cjs.map +1 -1
  12. package/dist/cjs/tools/BashProgrammaticToolCalling.cjs +22 -6
  13. package/dist/cjs/tools/BashProgrammaticToolCalling.cjs.map +1 -1
  14. package/dist/cjs/tools/ProgrammaticCallerPolicy.cjs +10 -0
  15. package/dist/cjs/tools/ProgrammaticCallerPolicy.cjs.map +1 -1
  16. package/dist/cjs/tools/ProgrammaticToolCalling.cjs +43 -6
  17. package/dist/cjs/tools/ProgrammaticToolCalling.cjs.map +1 -1
  18. package/dist/cjs/tools/ToolNode.cjs +12 -2
  19. package/dist/cjs/tools/ToolNode.cjs.map +1 -1
  20. package/dist/cjs/tools/local/LocalProgrammaticToolCalling.cjs +5 -3
  21. package/dist/cjs/tools/local/LocalProgrammaticToolCalling.cjs.map +1 -1
  22. package/dist/esm/graphs/Graph.mjs +11 -1
  23. package/dist/esm/graphs/Graph.mjs.map +1 -1
  24. package/dist/esm/graphs/MultiAgentGraph.mjs +36 -3
  25. package/dist/esm/graphs/MultiAgentGraph.mjs.map +1 -1
  26. package/dist/esm/langfuse.mjs +6 -2
  27. package/dist/esm/langfuse.mjs.map +1 -1
  28. package/dist/esm/main.mjs +2 -2
  29. package/dist/esm/messages/format.mjs +6 -34
  30. package/dist/esm/messages/format.mjs.map +1 -1
  31. package/dist/esm/run.mjs +5 -1
  32. package/dist/esm/run.mjs.map +1 -1
  33. package/dist/esm/tools/BashProgrammaticToolCalling.mjs +23 -7
  34. package/dist/esm/tools/BashProgrammaticToolCalling.mjs.map +1 -1
  35. package/dist/esm/tools/ProgrammaticCallerPolicy.mjs +10 -1
  36. package/dist/esm/tools/ProgrammaticCallerPolicy.mjs.map +1 -1
  37. package/dist/esm/tools/ProgrammaticToolCalling.mjs +42 -7
  38. package/dist/esm/tools/ProgrammaticToolCalling.mjs.map +1 -1
  39. package/dist/esm/tools/ToolNode.mjs +12 -2
  40. package/dist/esm/tools/ToolNode.mjs.map +1 -1
  41. package/dist/esm/tools/local/LocalProgrammaticToolCalling.mjs +5 -3
  42. package/dist/esm/tools/local/LocalProgrammaticToolCalling.mjs.map +1 -1
  43. package/dist/types/langfuse.d.ts +5 -1
  44. package/dist/types/messages/format.d.ts +2 -1
  45. package/dist/types/tools/ProgrammaticCallerPolicy.d.ts +12 -0
  46. package/dist/types/tools/ProgrammaticToolCalling.d.ts +35 -0
  47. package/dist/types/tools/ToolNode.d.ts +4 -1
  48. package/dist/types/types/tools.d.ts +5 -0
  49. package/package.json +1 -1
  50. package/src/graphs/Graph.ts +10 -0
  51. package/src/graphs/MultiAgentGraph.ts +71 -2
  52. package/src/langfuse.ts +12 -0
  53. package/src/messages/format.ts +23 -70
  54. package/src/run.ts +4 -0
  55. package/src/tools/BashProgrammaticToolCalling.ts +57 -19
  56. package/src/tools/ProgrammaticCallerPolicy.ts +31 -0
  57. package/src/tools/ProgrammaticToolCalling.ts +132 -19
  58. package/src/tools/ToolNode.ts +19 -0
  59. package/src/tools/local/LocalProgrammaticToolCalling.ts +19 -8
  60. package/src/types/tools.ts +5 -0
@@ -738,6 +738,9 @@ export class ToolNode<T = any> extends RunnableCallable<T, T> {
738
738
  * even where `agentId` (the subagent-scope marker) is undefined.
739
739
  */
740
740
  private executingAgentId?: string;
741
+ private executingAgentName?: string;
742
+ private rootAgentId?: string;
743
+ private rootAgentName?: string;
741
744
  /** Tool names that bypass event dispatch and execute directly (e.g., graph-managed handoff tools) */
742
745
  private directToolNames?: Set<string>;
743
746
  /**
@@ -823,6 +826,9 @@ export class ToolNode<T = any> extends RunnableCallable<T, T> {
823
826
  eagerEventToolSuppressions,
824
827
  agentId,
825
828
  executingAgentId,
829
+ executingAgentName,
830
+ rootAgentId,
831
+ rootAgentName,
826
832
  directToolNames,
827
833
  interruptingToolNames,
828
834
  codeSessionToolNames,
@@ -902,6 +908,9 @@ export class ToolNode<T = any> extends RunnableCallable<T, T> {
902
908
  // Default to agentId so callers constructing ToolNode directly (who pass the
903
909
  // existing agentId option) still get attribution without knowing the new option.
904
910
  this.executingAgentId = executingAgentId ?? agentId;
911
+ this.executingAgentName = executingAgentName;
912
+ this.rootAgentId = rootAgentId;
913
+ this.rootAgentName = rootAgentName;
905
914
  this.directToolNames = directToolNames;
906
915
  this.interruptingToolNames =
907
916
  interruptingToolNames != null && interruptingToolNames.size > 0
@@ -963,6 +972,16 @@ export class ToolNode<T = any> extends RunnableCallable<T, T> {
963
972
  metadata: {
964
973
  ...options?.metadata,
965
974
  agentId: this.executingAgentId,
975
+ activeAgentId: this.executingAgentId,
976
+ ...(this.executingAgentName == null
977
+ ? {}
978
+ : { activeAgentName: this.executingAgentName }),
979
+ ...(this.rootAgentId == null
980
+ ? {}
981
+ : { rootAgentId: this.rootAgentId }),
982
+ ...(this.rootAgentName == null
983
+ ? {}
984
+ : { rootAgentName: this.rootAgentName }),
966
985
  },
967
986
  };
968
987
  return withLangfuseRuntimeScope(
@@ -589,17 +589,28 @@ async function runLocalProgrammaticTool(args: {
589
589
  programmaticToolName: runnerName,
590
590
  });
591
591
 
592
- if (toolMap == null || toolMap.size === 0) {
593
- throw new Error('No toolMap provided for local programmatic execution.');
594
- }
595
- if (toolDefs == null || toolDefs.length === 0) {
596
- throw new Error(
597
- 'No tool definitions provided for local programmatic execution.'
598
- );
592
+ /* The local program builder supports zero stubs, so a call that selected no
593
+ * tools needs neither a toolMap nor toolDefs. Injected context is still
594
+ * required to conclude that. */
595
+ const needsNoTools =
596
+ selectedTools.length === 0 &&
597
+ (args.params.tool_manifest?.length === 0 ||
598
+ toolDefs != null ||
599
+ disallowedToolDefs != null);
600
+
601
+ if (!needsNoTools) {
602
+ if (toolMap == null || toolMap.size === 0) {
603
+ throw new Error('No toolMap provided for local programmatic execution.');
604
+ }
605
+ if (toolDefs == null || toolDefs.length === 0) {
606
+ throw new Error(
607
+ 'No tool definitions provided for local programmatic execution.'
608
+ );
609
+ }
599
610
  }
600
611
 
601
612
  const { effectiveTools, effectiveMap } = createEffectiveToolMap(
602
- toolMap,
613
+ toolMap ?? new Map(),
603
614
  selectedTools
604
615
  );
605
616
  const bridge = await createToolBridge(effectiveMap, hookContext);
@@ -148,6 +148,11 @@ export type ToolNodeOptions = {
148
148
  /** ID of the agent that owns this tool node, surfaced to hooks as `executingAgentId`
149
149
  * so a batch can be attributed to a specific agent even where `agentId` is undefined. */
150
150
  executingAgentId?: string;
151
+ /** Name of the agent that owns this tool node, used for active Langfuse attribution. */
152
+ executingAgentName?: string;
153
+ /** Root graph-agent identity retained alongside the currently executing tool owner. */
154
+ rootAgentId?: string;
155
+ rootAgentName?: string;
151
156
  /** Tool names that must be executed directly (via runTool) even in event-driven mode (e.g., graph-managed handoff tools) */
152
157
  directToolNames?: Set<string>;
153
158
  /**