@librechat/agents 3.1.66-dev.0 → 3.1.67-dev.0

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/agents/AgentContext.cjs +47 -18
  2. package/dist/cjs/agents/AgentContext.cjs.map +1 -1
  3. package/dist/cjs/common/enum.cjs +1 -0
  4. package/dist/cjs/common/enum.cjs.map +1 -1
  5. package/dist/cjs/graphs/Graph.cjs +69 -0
  6. package/dist/cjs/graphs/Graph.cjs.map +1 -1
  7. package/dist/cjs/hooks/types.cjs.map +1 -1
  8. package/dist/cjs/main.cjs +12 -0
  9. package/dist/cjs/main.cjs.map +1 -1
  10. package/dist/cjs/summarization/node.cjs +44 -0
  11. package/dist/cjs/summarization/node.cjs.map +1 -1
  12. package/dist/cjs/tools/SubagentTool.cjs +92 -0
  13. package/dist/cjs/tools/SubagentTool.cjs.map +1 -0
  14. package/dist/cjs/tools/subagent/SubagentExecutor.cjs +261 -0
  15. package/dist/cjs/tools/subagent/SubagentExecutor.cjs.map +1 -0
  16. package/dist/esm/agents/AgentContext.mjs +47 -18
  17. package/dist/esm/agents/AgentContext.mjs.map +1 -1
  18. package/dist/esm/common/enum.mjs +1 -0
  19. package/dist/esm/common/enum.mjs.map +1 -1
  20. package/dist/esm/graphs/Graph.mjs +69 -0
  21. package/dist/esm/graphs/Graph.mjs.map +1 -1
  22. package/dist/esm/hooks/types.mjs.map +1 -1
  23. package/dist/esm/main.mjs +2 -0
  24. package/dist/esm/main.mjs.map +1 -1
  25. package/dist/esm/summarization/node.mjs +44 -0
  26. package/dist/esm/summarization/node.mjs.map +1 -1
  27. package/dist/esm/tools/SubagentTool.mjs +85 -0
  28. package/dist/esm/tools/SubagentTool.mjs.map +1 -0
  29. package/dist/esm/tools/subagent/SubagentExecutor.mjs +256 -0
  30. package/dist/esm/tools/subagent/SubagentExecutor.mjs.map +1 -0
  31. package/dist/types/agents/AgentContext.d.ts +12 -0
  32. package/dist/types/common/enum.d.ts +2 -1
  33. package/dist/types/hooks/types.d.ts +12 -1
  34. package/dist/types/index.d.ts +2 -0
  35. package/dist/types/summarization/node.d.ts +2 -0
  36. package/dist/types/tools/SubagentTool.d.ts +36 -0
  37. package/dist/types/tools/subagent/SubagentExecutor.d.ts +83 -0
  38. package/dist/types/tools/subagent/index.d.ts +2 -0
  39. package/dist/types/types/graph.d.ts +25 -0
  40. package/dist/types/types/llm.d.ts +14 -2
  41. package/package.json +2 -1
  42. package/src/agents/AgentContext.ts +54 -17
  43. package/src/agents/__tests__/AgentContext.test.ts +110 -0
  44. package/src/common/enum.ts +1 -0
  45. package/src/graphs/Graph.ts +88 -0
  46. package/src/hooks/__tests__/compactHooks.test.ts +214 -0
  47. package/src/hooks/index.ts +4 -2
  48. package/src/hooks/types.ts +17 -1
  49. package/src/index.ts +2 -0
  50. package/src/scripts/multi-agent-subagent.ts +246 -0
  51. package/src/specs/subagent.test.ts +305 -0
  52. package/src/summarization/node.ts +53 -0
  53. package/src/tools/SubagentTool.ts +100 -0
  54. package/src/tools/__tests__/SubagentExecutor.test.ts +615 -0
  55. package/src/tools/__tests__/SubagentTool.test.ts +149 -0
  56. package/src/tools/__tests__/subagentHooks.test.ts +215 -0
  57. package/src/tools/subagent/SubagentExecutor.ts +344 -0
  58. package/src/tools/subagent/index.ts +12 -0
  59. package/src/types/graph.ts +27 -0
  60. package/src/types/llm.ts +16 -2
@@ -0,0 +1,12 @@
1
+ export {
2
+ SubagentExecutor,
3
+ filterSubagentResult,
4
+ resolveSubagentConfigs,
5
+ buildChildInputs,
6
+ } from './SubagentExecutor';
7
+ export type {
8
+ SubagentExecuteParams,
9
+ SubagentExecuteResult,
10
+ SubagentExecutorOptions,
11
+ ChildGraphFactory,
12
+ } from './SubagentExecutor';
@@ -388,6 +388,29 @@ export type MultiAgentGraphInput = StandardGraphInput & {
388
388
  edges: GraphEdge[];
389
389
  };
390
390
 
391
+ /** Configuration for a subagent type that can be spawned by a parent agent. */
392
+ export type SubagentConfig = {
393
+ /** Identifier used in the tool's `subagent_type` enum (e.g. 'researcher', 'coder'). */
394
+ type: string;
395
+ /** Human-readable display name. */
396
+ name: string;
397
+ /** What this subagent specializes in — shown to the LLM. */
398
+ description: string;
399
+ /** Full agent config for the child graph. Omit when `self` is true. */
400
+ agentInputs?: AgentInputs;
401
+ /** When true, reuse the parent's AgentInputs (context isolation without separate config). */
402
+ self?: boolean;
403
+ /** Max AGENT→TOOLS cycles before forced stop (default: 25). */
404
+ maxTurns?: number;
405
+ /** Allow this subagent to spawn its own subagents (default: false). */
406
+ allowNested?: boolean;
407
+ };
408
+
409
+ /** SubagentConfig with agentInputs guaranteed present (self-spawn resolved). */
410
+ export type ResolvedSubagentConfig = SubagentConfig & {
411
+ agentInputs: AgentInputs;
412
+ };
413
+
391
414
  export interface AgentInputs {
392
415
  agentId: string;
393
416
  /** Human-readable name for the agent (used in handoff context). Defaults to agentId if not provided. */
@@ -431,6 +454,10 @@ export interface AgentInputs {
431
454
  maxToolResultChars?: number;
432
455
  /** Pre-computed tool schema token count (from cache). Skips recalculation when provided. */
433
456
  toolSchemaTokens?: number;
457
+ /** Subagent configurations for hierarchical delegation. Each defines a child agent type. */
458
+ subagentConfigs?: SubagentConfig[];
459
+ /** Maximum subagent nesting depth. Default 1 means top-level agents can spawn subagents but subagents cannot nest further. */
460
+ maxSubagentDepth?: number;
434
461
  }
435
462
 
436
463
  export interface ContextPruningConfig {
package/src/types/llm.ts CHANGED
@@ -45,7 +45,20 @@ export type AzureClientOptions = Partial<OpenAIChatInput> &
45
45
  } & BaseChatModelParams & {
46
46
  configuration?: OAIClientOptions;
47
47
  };
48
- export type ThinkingConfig = AnthropicInput['thinking'];
48
+ /**
49
+ * Controls whether Claude's reasoning content is returned in adaptive
50
+ * thinking responses. Added for Claude Opus 4.7, which omits thinking by
51
+ * default unless the caller opts in with `'summarized'`.
52
+ * @see https://platform.claude.com/docs/en/about-claude/models/whats-new-claude-4-7#thinking-content-omitted-by-default
53
+ */
54
+ export type ThinkingDisplay = 'summarized' | 'omitted';
55
+ export type ThinkingConfigAdaptive = {
56
+ type: 'adaptive';
57
+ display?: ThinkingDisplay;
58
+ };
59
+ export type ThinkingConfig =
60
+ | NonNullable<AnthropicInput['thinking']>
61
+ | ThinkingConfigAdaptive;
49
62
  export type ChatOpenAIToolType =
50
63
  | BindToolsInput
51
64
  | OpenAIClient.ChatCompletionTool;
@@ -60,7 +73,8 @@ export type GoogleThinkingConfig = {
60
73
  thinkingLevel?: string;
61
74
  };
62
75
  export type OpenAIClientOptions = ChatOpenAIFields;
63
- export type AnthropicClientOptions = AnthropicInput & {
76
+ export type AnthropicClientOptions = Omit<AnthropicInput, 'thinking'> & {
77
+ thinking?: ThinkingConfig;
64
78
  promptCache?: boolean;
65
79
  };
66
80
  export type MistralAIClientOptions = ChatMistralAIInput;