@librechat/agents 3.1.66 → 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.
- package/dist/cjs/agents/AgentContext.cjs +23 -3
- package/dist/cjs/agents/AgentContext.cjs.map +1 -1
- package/dist/cjs/common/enum.cjs +14 -0
- package/dist/cjs/common/enum.cjs.map +1 -1
- package/dist/cjs/graphs/Graph.cjs +72 -0
- package/dist/cjs/graphs/Graph.cjs.map +1 -1
- package/dist/cjs/hooks/HookRegistry.cjs +162 -0
- package/dist/cjs/hooks/HookRegistry.cjs.map +1 -0
- package/dist/cjs/hooks/executeHooks.cjs +276 -0
- package/dist/cjs/hooks/executeHooks.cjs.map +1 -0
- package/dist/cjs/hooks/matchers.cjs +256 -0
- package/dist/cjs/hooks/matchers.cjs.map +1 -0
- package/dist/cjs/hooks/types.cjs +27 -0
- package/dist/cjs/hooks/types.cjs.map +1 -0
- package/dist/cjs/main.cjs +52 -0
- package/dist/cjs/main.cjs.map +1 -1
- package/dist/cjs/messages/format.cjs +74 -12
- package/dist/cjs/messages/format.cjs.map +1 -1
- package/dist/cjs/run.cjs +111 -0
- package/dist/cjs/run.cjs.map +1 -1
- package/dist/cjs/summarization/node.cjs +44 -0
- package/dist/cjs/summarization/node.cjs.map +1 -1
- package/dist/cjs/tools/BashExecutor.cjs +175 -0
- package/dist/cjs/tools/BashExecutor.cjs.map +1 -0
- package/dist/cjs/tools/BashProgrammaticToolCalling.cjs +296 -0
- package/dist/cjs/tools/BashProgrammaticToolCalling.cjs.map +1 -0
- package/dist/cjs/tools/ReadFile.cjs +43 -0
- package/dist/cjs/tools/ReadFile.cjs.map +1 -0
- package/dist/cjs/tools/SkillTool.cjs +50 -0
- package/dist/cjs/tools/SkillTool.cjs.map +1 -0
- package/dist/cjs/tools/SubagentTool.cjs +92 -0
- package/dist/cjs/tools/SubagentTool.cjs.map +1 -0
- package/dist/cjs/tools/ToolNode.cjs +304 -140
- package/dist/cjs/tools/ToolNode.cjs.map +1 -1
- package/dist/cjs/tools/skillCatalog.cjs +84 -0
- package/dist/cjs/tools/skillCatalog.cjs.map +1 -0
- package/dist/cjs/tools/subagent/SubagentExecutor.cjs +261 -0
- package/dist/cjs/tools/subagent/SubagentExecutor.cjs.map +1 -0
- package/dist/esm/agents/AgentContext.mjs +23 -3
- package/dist/esm/agents/AgentContext.mjs.map +1 -1
- package/dist/esm/common/enum.mjs +13 -1
- package/dist/esm/common/enum.mjs.map +1 -1
- package/dist/esm/graphs/Graph.mjs +72 -0
- package/dist/esm/graphs/Graph.mjs.map +1 -1
- package/dist/esm/hooks/HookRegistry.mjs +160 -0
- package/dist/esm/hooks/HookRegistry.mjs.map +1 -0
- package/dist/esm/hooks/executeHooks.mjs +273 -0
- package/dist/esm/hooks/executeHooks.mjs.map +1 -0
- package/dist/esm/hooks/matchers.mjs +251 -0
- package/dist/esm/hooks/matchers.mjs.map +1 -0
- package/dist/esm/hooks/types.mjs +25 -0
- package/dist/esm/hooks/types.mjs.map +1 -0
- package/dist/esm/main.mjs +12 -1
- package/dist/esm/main.mjs.map +1 -1
- package/dist/esm/messages/format.mjs +66 -4
- package/dist/esm/messages/format.mjs.map +1 -1
- package/dist/esm/run.mjs +111 -0
- package/dist/esm/run.mjs.map +1 -1
- package/dist/esm/summarization/node.mjs +44 -0
- package/dist/esm/summarization/node.mjs.map +1 -1
- package/dist/esm/tools/BashExecutor.mjs +169 -0
- package/dist/esm/tools/BashExecutor.mjs.map +1 -0
- package/dist/esm/tools/BashProgrammaticToolCalling.mjs +287 -0
- package/dist/esm/tools/BashProgrammaticToolCalling.mjs.map +1 -0
- package/dist/esm/tools/ReadFile.mjs +38 -0
- package/dist/esm/tools/ReadFile.mjs.map +1 -0
- package/dist/esm/tools/SkillTool.mjs +45 -0
- package/dist/esm/tools/SkillTool.mjs.map +1 -0
- package/dist/esm/tools/SubagentTool.mjs +85 -0
- package/dist/esm/tools/SubagentTool.mjs.map +1 -0
- package/dist/esm/tools/ToolNode.mjs +306 -142
- package/dist/esm/tools/ToolNode.mjs.map +1 -1
- package/dist/esm/tools/skillCatalog.mjs +82 -0
- package/dist/esm/tools/skillCatalog.mjs.map +1 -0
- package/dist/esm/tools/subagent/SubagentExecutor.mjs +256 -0
- package/dist/esm/tools/subagent/SubagentExecutor.mjs.map +1 -0
- package/dist/types/agents/AgentContext.d.ts +6 -0
- package/dist/types/common/enum.d.ts +8 -1
- package/dist/types/graphs/Graph.d.ts +2 -0
- package/dist/types/hooks/HookRegistry.d.ts +56 -0
- package/dist/types/hooks/executeHooks.d.ts +79 -0
- package/dist/types/hooks/index.d.ts +6 -0
- package/dist/types/hooks/matchers.d.ts +95 -0
- package/dist/types/hooks/types.d.ts +320 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/messages/format.d.ts +2 -1
- package/dist/types/run.d.ts +1 -0
- package/dist/types/summarization/node.d.ts +2 -0
- package/dist/types/tools/BashExecutor.d.ts +45 -0
- package/dist/types/tools/BashProgrammaticToolCalling.d.ts +72 -0
- package/dist/types/tools/ReadFile.d.ts +28 -0
- package/dist/types/tools/SkillTool.d.ts +40 -0
- package/dist/types/tools/SubagentTool.d.ts +36 -0
- package/dist/types/tools/ToolNode.d.ts +24 -2
- package/dist/types/tools/skillCatalog.d.ts +19 -0
- package/dist/types/tools/subagent/SubagentExecutor.d.ts +83 -0
- package/dist/types/tools/subagent/index.d.ts +2 -0
- package/dist/types/types/graph.d.ts +25 -0
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/types/llm.d.ts +14 -2
- package/dist/types/types/run.d.ts +20 -0
- package/dist/types/types/skill.d.ts +9 -0
- package/dist/types/types/tools.d.ts +38 -1
- package/package.json +2 -1
- package/src/agents/AgentContext.ts +26 -2
- package/src/common/enum.ts +13 -0
- package/src/graphs/Graph.ts +92 -0
- package/src/hooks/HookRegistry.ts +208 -0
- package/src/hooks/__tests__/HookRegistry.test.ts +190 -0
- package/src/hooks/__tests__/compactHooks.test.ts +214 -0
- package/src/hooks/__tests__/executeHooks.test.ts +1013 -0
- package/src/hooks/__tests__/integration.test.ts +337 -0
- package/src/hooks/__tests__/matchers.test.ts +238 -0
- package/src/hooks/__tests__/toolHooks.test.ts +669 -0
- package/src/hooks/executeHooks.ts +375 -0
- package/src/hooks/index.ts +57 -0
- package/src/hooks/matchers.ts +280 -0
- package/src/hooks/types.ts +404 -0
- package/src/index.ts +10 -0
- package/src/messages/format.ts +74 -4
- package/src/messages/formatAgentMessages.skills.test.ts +334 -0
- package/src/run.ts +126 -0
- package/src/scripts/multi-agent-subagent.ts +246 -0
- package/src/specs/subagent.test.ts +305 -0
- package/src/summarization/node.ts +53 -0
- package/src/tools/BashExecutor.ts +205 -0
- package/src/tools/BashProgrammaticToolCalling.ts +397 -0
- package/src/tools/ReadFile.ts +39 -0
- package/src/tools/SkillTool.ts +46 -0
- package/src/tools/SubagentTool.ts +100 -0
- package/src/tools/ToolNode.ts +391 -169
- package/src/tools/__tests__/ReadFile.test.ts +44 -0
- package/src/tools/__tests__/SkillTool.test.ts +442 -0
- package/src/tools/__tests__/SubagentExecutor.test.ts +615 -0
- package/src/tools/__tests__/SubagentTool.test.ts +149 -0
- package/src/tools/__tests__/ToolNode.session.test.ts +12 -12
- package/src/tools/__tests__/skillCatalog.test.ts +161 -0
- package/src/tools/__tests__/subagentHooks.test.ts +215 -0
- package/src/tools/skillCatalog.ts +126 -0
- package/src/tools/subagent/SubagentExecutor.ts +344 -0
- package/src/tools/subagent/index.ts +12 -0
- package/src/types/graph.ts +27 -0
- package/src/types/index.ts +1 -0
- package/src/types/llm.ts +16 -2
- package/src/types/run.ts +20 -0
- package/src/types/skill.ts +11 -0
- package/src/types/tools.ts +41 -1
package/dist/types/index.d.ts
CHANGED
|
@@ -7,7 +7,14 @@ export * from './graphs';
|
|
|
7
7
|
export * from './summarization';
|
|
8
8
|
export * from './tools/Calculator';
|
|
9
9
|
export * from './tools/CodeExecutor';
|
|
10
|
+
export * from './tools/BashExecutor';
|
|
10
11
|
export * from './tools/ProgrammaticToolCalling';
|
|
12
|
+
export * from './tools/BashProgrammaticToolCalling';
|
|
13
|
+
export * from './tools/SkillTool';
|
|
14
|
+
export * from './tools/SubagentTool';
|
|
15
|
+
export * from './tools/subagent';
|
|
16
|
+
export * from './tools/ReadFile';
|
|
17
|
+
export * from './tools/skillCatalog';
|
|
11
18
|
export * from './tools/ToolSearch';
|
|
12
19
|
export * from './tools/ToolNode';
|
|
13
20
|
export * from './tools/schema';
|
|
@@ -15,6 +22,7 @@ export * from './tools/handlers';
|
|
|
15
22
|
export * from './tools/search';
|
|
16
23
|
export * from './common';
|
|
17
24
|
export * from './utils';
|
|
25
|
+
export * from './hooks';
|
|
18
26
|
export type * from './types';
|
|
19
27
|
export { CustomOpenAIClient } from './llm/openai';
|
|
20
28
|
export { ChatOpenRouter } from './llm/openrouter';
|
|
@@ -104,9 +104,10 @@ export declare const labelContentByAgent: (contentParts: MessageContentComplex[]
|
|
|
104
104
|
* @param payload - The array of messages to format.
|
|
105
105
|
* @param indexTokenCountMap - Optional map of message indices to token counts.
|
|
106
106
|
* @param tools - Optional set of tool names that are allowed in the request.
|
|
107
|
+
* @param skills - Optional map of skill name to body for reconstructing skill HumanMessages.
|
|
107
108
|
* @returns - Object containing formatted messages and updated indexTokenCountMap if provided.
|
|
108
109
|
*/
|
|
109
|
-
export declare const formatAgentMessages: (payload: TPayload, indexTokenCountMap?: Record<number, number | undefined>, tools?: Set<string>) => {
|
|
110
|
+
export declare const formatAgentMessages: (payload: TPayload, indexTokenCountMap?: Record<number, number | undefined>, tools?: Set<string>, skills?: Map<string, string>) => {
|
|
110
111
|
messages: Array<HumanMessage | AIMessage | SystemMessage | ToolMessage>;
|
|
111
112
|
indexTokenCountMap?: Record<number, number>;
|
|
112
113
|
/** Cross-run summary extracted from the payload. Should be forwarded to the
|
package/dist/types/run.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { RunnableConfig } from '@langchain/core/runnables';
|
|
2
2
|
import type { BaseMessage } from '@langchain/core/messages';
|
|
3
3
|
import type { AgentContext } from '@/agents/AgentContext';
|
|
4
|
+
import type { HookRegistry } from '@/hooks';
|
|
4
5
|
import type * as t from '@/types';
|
|
5
6
|
/** Structured checkpoint prompt for fresh summarization (no prior summary). */
|
|
6
7
|
export declare const DEFAULT_SUMMARIZATION_PROMPT = "Hold on, before you continue I need you to write me a checkpoint of everything so far. Your context window is filling up and this checkpoint replaces the messages above, so capture everything you need to pick right back up.\n\nDon't second-guess or fact-check anything you did, your tool results reflect exactly what happened. If a tool result appears truncated, that's just a display artifact from context management: the tool executed fully. Just record what you did and what you observed. Only the checkpoint, don't respond to me or continue the conversation.\n\n## Checkpoint\n\n## Goal\nWhat I asked you to do and any sub-goals you identified.\n\n## Constraints & Preferences\nAny rules, preferences, or configuration I established.\n\n## Progress\n### Done\n- What you completed and the outcomes\n\n### In Progress\n- What you're currently working on\n\n## Key Decisions\nDecisions you made and why.\n\n## Next Steps\nConcrete task actions remaining, in priority order.\n\n## Critical Context\nExact identifiers, names, error messages, URLs, and details you need to preserve verbatim.\n\nRules:\n- Record what you did and observed, don't judge or re-evaluate it\n- For each tool call: the tool name, key inputs, and the outcome\n- Preserve exact identifiers, names, errors, and references verbatim\n- Short declarative sentences\n- Skip empty sections";
|
|
@@ -14,6 +15,7 @@ interface CreateSummarizeNodeParams {
|
|
|
14
15
|
config?: RunnableConfig;
|
|
15
16
|
runId?: string;
|
|
16
17
|
isMultiAgent: boolean;
|
|
18
|
+
hookRegistry?: HookRegistry;
|
|
17
19
|
dispatchRunStep: (runStep: t.RunStep, config?: RunnableConfig) => Promise<void>;
|
|
18
20
|
dispatchRunStepCompleted: (stepId: string, result: t.StepCompleted, config?: RunnableConfig) => Promise<void>;
|
|
19
21
|
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { DynamicStructuredTool } from '@langchain/core/tools';
|
|
2
|
+
import type * as t from '@/types';
|
|
3
|
+
import { Constants } from '@/common';
|
|
4
|
+
export declare const BashExecutionToolSchema: {
|
|
5
|
+
readonly type: "object";
|
|
6
|
+
readonly properties: {
|
|
7
|
+
readonly command: {
|
|
8
|
+
readonly type: "string";
|
|
9
|
+
readonly description: "The bash command or script to execute.\n- The environment is stateless; variables and state don't persist between executions.\n- Generated files from previous executions are automatically available in \"/mnt/data/\".\n- Files from previous executions are automatically available and can be modified in place.\n- Input code **IS ALREADY** displayed to the user, so **DO NOT** repeat it in your response unless asked.\n- Output code **IS NOT** displayed to the user, so **DO** write all desired output explicitly.\n- IMPORTANT: You MUST explicitly print/output ALL results you want the user to see.\n- Use `echo`, `printf`, or `cat` for all outputs.";
|
|
10
|
+
};
|
|
11
|
+
readonly args: {
|
|
12
|
+
readonly type: "array";
|
|
13
|
+
readonly items: {
|
|
14
|
+
readonly type: "string";
|
|
15
|
+
};
|
|
16
|
+
readonly description: "Additional arguments to execute the command with. This should only be used if the input command requires additional arguments to run.";
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
readonly required: readonly ["command"];
|
|
20
|
+
};
|
|
21
|
+
export declare const BashExecutionToolDescription: string;
|
|
22
|
+
export declare const BashExecutionToolName = Constants.BASH_TOOL;
|
|
23
|
+
export declare const BashExecutionToolDefinition: {
|
|
24
|
+
readonly name: Constants.BASH_TOOL;
|
|
25
|
+
readonly description: string;
|
|
26
|
+
readonly schema: {
|
|
27
|
+
readonly type: "object";
|
|
28
|
+
readonly properties: {
|
|
29
|
+
readonly command: {
|
|
30
|
+
readonly type: "string";
|
|
31
|
+
readonly description: "The bash command or script to execute.\n- The environment is stateless; variables and state don't persist between executions.\n- Generated files from previous executions are automatically available in \"/mnt/data/\".\n- Files from previous executions are automatically available and can be modified in place.\n- Input code **IS ALREADY** displayed to the user, so **DO NOT** repeat it in your response unless asked.\n- Output code **IS NOT** displayed to the user, so **DO** write all desired output explicitly.\n- IMPORTANT: You MUST explicitly print/output ALL results you want the user to see.\n- Use `echo`, `printf`, or `cat` for all outputs.";
|
|
32
|
+
};
|
|
33
|
+
readonly args: {
|
|
34
|
+
readonly type: "array";
|
|
35
|
+
readonly items: {
|
|
36
|
+
readonly type: "string";
|
|
37
|
+
};
|
|
38
|
+
readonly description: "Additional arguments to execute the command with. This should only be used if the input command requires additional arguments to run.";
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
readonly required: readonly ["command"];
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
declare function createBashExecutionTool(params?: t.BashExecutionToolParams): DynamicStructuredTool;
|
|
45
|
+
export { createBashExecutionTool };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { DynamicStructuredTool } from '@langchain/core/tools';
|
|
2
|
+
import type * as t from '@/types';
|
|
3
|
+
import { Constants } from '@/common';
|
|
4
|
+
export declare const BashProgrammaticToolCallingSchema: {
|
|
5
|
+
readonly type: "object";
|
|
6
|
+
readonly properties: {
|
|
7
|
+
readonly code: {
|
|
8
|
+
readonly type: "string";
|
|
9
|
+
readonly minLength: 1;
|
|
10
|
+
readonly description: "Bash code that calls tools programmatically. Tools are available as bash functions.\n\nCRITICAL - STATELESS EXECUTION:\nEach call is a fresh bash shell. Variables and state do NOT persist between calls.\nYou MUST complete your entire workflow in ONE code block.\nDO NOT split work across multiple calls expecting to reuse variables.\n\nEach tool function accepts a JSON string as its argument.\nExample: tool_name '{\"key\": \"value\"}'\n\nExample (Complete workflow in one call):\n # Query data and process\n data=$(query_database '{\"sql\": \"SELECT * FROM users\"}')\n echo \"$data\" | jq '.[] | .name'\n\nExample (Parallel calls):\n web_search '{\"query\": \"SF weather\"}' > /tmp/sf.txt &\n web_search '{\"query\": \"NY weather\"}' > /tmp/ny.txt &\n wait\n echo \"SF: $(cat /tmp/sf.txt)\"\n echo \"NY: $(cat /tmp/ny.txt)\"\n\nRules:\n- EVERYTHING in one call—no state persists between executions\n- Tools are pre-defined as bash functions—DO NOT redefine them\n- Each tool function accepts a JSON string argument\n- Only echo/printf output returns to the model\n- Generated files are automatically available in /mnt/data/ for subsequent executions";
|
|
11
|
+
};
|
|
12
|
+
readonly timeout: {
|
|
13
|
+
readonly type: "integer";
|
|
14
|
+
readonly minimum: 1000;
|
|
15
|
+
readonly maximum: 300000;
|
|
16
|
+
readonly default: 60000;
|
|
17
|
+
readonly description: "Maximum execution time in milliseconds. Default: 60 seconds. Max: 5 minutes.";
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
readonly required: readonly ["code"];
|
|
21
|
+
};
|
|
22
|
+
export declare const BashProgrammaticToolCallingName = Constants.BASH_PROGRAMMATIC_TOOL_CALLING;
|
|
23
|
+
export declare const BashProgrammaticToolCallingDescription: string;
|
|
24
|
+
export declare const BashProgrammaticToolCallingDefinition: {
|
|
25
|
+
readonly name: Constants.BASH_PROGRAMMATIC_TOOL_CALLING;
|
|
26
|
+
readonly description: string;
|
|
27
|
+
readonly schema: {
|
|
28
|
+
readonly type: "object";
|
|
29
|
+
readonly properties: {
|
|
30
|
+
readonly code: {
|
|
31
|
+
readonly type: "string";
|
|
32
|
+
readonly minLength: 1;
|
|
33
|
+
readonly description: "Bash code that calls tools programmatically. Tools are available as bash functions.\n\nCRITICAL - STATELESS EXECUTION:\nEach call is a fresh bash shell. Variables and state do NOT persist between calls.\nYou MUST complete your entire workflow in ONE code block.\nDO NOT split work across multiple calls expecting to reuse variables.\n\nEach tool function accepts a JSON string as its argument.\nExample: tool_name '{\"key\": \"value\"}'\n\nExample (Complete workflow in one call):\n # Query data and process\n data=$(query_database '{\"sql\": \"SELECT * FROM users\"}')\n echo \"$data\" | jq '.[] | .name'\n\nExample (Parallel calls):\n web_search '{\"query\": \"SF weather\"}' > /tmp/sf.txt &\n web_search '{\"query\": \"NY weather\"}' > /tmp/ny.txt &\n wait\n echo \"SF: $(cat /tmp/sf.txt)\"\n echo \"NY: $(cat /tmp/ny.txt)\"\n\nRules:\n- EVERYTHING in one call—no state persists between executions\n- Tools are pre-defined as bash functions—DO NOT redefine them\n- Each tool function accepts a JSON string argument\n- Only echo/printf output returns to the model\n- Generated files are automatically available in /mnt/data/ for subsequent executions";
|
|
34
|
+
};
|
|
35
|
+
readonly timeout: {
|
|
36
|
+
readonly type: "integer";
|
|
37
|
+
readonly minimum: 1000;
|
|
38
|
+
readonly maximum: 300000;
|
|
39
|
+
readonly default: 60000;
|
|
40
|
+
readonly description: "Maximum execution time in milliseconds. Default: 60 seconds. Max: 5 minutes.";
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
readonly required: readonly ["code"];
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Normalizes a tool name to a valid bash function identifier.
|
|
48
|
+
* 1. Replace hyphens, spaces, dots with underscores
|
|
49
|
+
* 2. Remove any other invalid characters
|
|
50
|
+
* 3. Prefix with underscore if starts with number
|
|
51
|
+
* 4. Append `_tool` if it's a bash reserved word
|
|
52
|
+
*/
|
|
53
|
+
export declare function normalizeToBashIdentifier(name: string): string;
|
|
54
|
+
/**
|
|
55
|
+
* Extracts tool names that are actually called in the bash code.
|
|
56
|
+
* Bash functions are invoked as commands (no parentheses), so we match
|
|
57
|
+
* the normalized name as a word boundary.
|
|
58
|
+
*/
|
|
59
|
+
export declare function extractUsedBashToolNames(code: string, toolNameMap: Map<string, string>): Set<string>;
|
|
60
|
+
/**
|
|
61
|
+
* Filters tool definitions to only include tools actually used in the bash code.
|
|
62
|
+
*/
|
|
63
|
+
export declare function filterBashToolsByUsage(toolDefs: t.LCTool[], code: string, debug?: boolean): t.LCTool[];
|
|
64
|
+
/**
|
|
65
|
+
* Creates a Bash Programmatic Tool Calling tool for multi-tool orchestration.
|
|
66
|
+
*
|
|
67
|
+
* This tool enables AI agents to write bash scripts that orchestrate multiple
|
|
68
|
+
* tool calls programmatically via the remote Code API, reducing LLM round-trips.
|
|
69
|
+
*
|
|
70
|
+
* The tool map must be provided at runtime via config.toolCall (injected by ToolNode).
|
|
71
|
+
*/
|
|
72
|
+
export declare function createBashProgrammaticToolCallingTool(initParams?: t.BashProgrammaticToolCallingParams): DynamicStructuredTool;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Constants } from '@/common';
|
|
2
|
+
export declare const ReadFileToolName = Constants.READ_FILE;
|
|
3
|
+
export declare const ReadFileToolDescription = "Read the contents of a file. Returns text content with line numbers for easy reference.\n\nFor skill files, use the path format: {skillName}/{filePath} (e.g. \"pdf-analyzer/src/utils.py\", \"code-review/SKILL.md\").\n\nBEHAVIOR:\n- Text files: returned with numbered lines.\n- Images (png, jpeg, gif, webp): returned as visual content the model can see.\n- PDFs: returned as document content.\n- Other binary files: metadata returned with a note to use bash for processing.\n- Large files (>256KB text, >10MB binary): metadata only.\n- SKILL.md: returns the skill's instructions directly.\n\nCONSTRAINTS:\n- Only files from invoked skills or code execution output are accessible.\n- Do not guess file paths. Use paths from the skill documentation or tool output.";
|
|
4
|
+
export declare const ReadFileToolSchema: {
|
|
5
|
+
readonly type: "object";
|
|
6
|
+
readonly properties: {
|
|
7
|
+
readonly file_path: {
|
|
8
|
+
readonly type: "string";
|
|
9
|
+
readonly description: "Path to the file. For skill files: \"{skillName}/{path}\" (e.g. \"pdf-analyzer/src/utils.py\"). For code execution output: the path as returned by the execution tool.";
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
readonly required: readonly ["file_path"];
|
|
13
|
+
};
|
|
14
|
+
export declare const ReadFileToolDefinition: {
|
|
15
|
+
readonly name: Constants.READ_FILE;
|
|
16
|
+
readonly description: "Read the contents of a file. Returns text content with line numbers for easy reference.\n\nFor skill files, use the path format: {skillName}/{filePath} (e.g. \"pdf-analyzer/src/utils.py\", \"code-review/SKILL.md\").\n\nBEHAVIOR:\n- Text files: returned with numbered lines.\n- Images (png, jpeg, gif, webp): returned as visual content the model can see.\n- PDFs: returned as document content.\n- Other binary files: metadata returned with a note to use bash for processing.\n- Large files (>256KB text, >10MB binary): metadata only.\n- SKILL.md: returns the skill's instructions directly.\n\nCONSTRAINTS:\n- Only files from invoked skills or code execution output are accessible.\n- Do not guess file paths. Use paths from the skill documentation or tool output.";
|
|
17
|
+
readonly parameters: {
|
|
18
|
+
readonly type: "object";
|
|
19
|
+
readonly properties: {
|
|
20
|
+
readonly file_path: {
|
|
21
|
+
readonly type: "string";
|
|
22
|
+
readonly description: "Path to the file. For skill files: \"{skillName}/{path}\" (e.g. \"pdf-analyzer/src/utils.py\"). For code execution output: the path as returned by the execution tool.";
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
readonly required: readonly ["file_path"];
|
|
26
|
+
};
|
|
27
|
+
readonly responseFormat: "content_and_artifact";
|
|
28
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Constants } from '@/common';
|
|
2
|
+
export declare const SkillToolName = Constants.SKILL_TOOL;
|
|
3
|
+
export declare const SkillToolDescription = "Invoke a skill from the user's library. Skills provide domain-specific instructions loaded into the conversation context, and may also provide files accessible via available tools depending on the runtime environment.\n\nWHEN TO USE:\n- The user's request matches a skill listed in the \"Available Skills\" section of the system prompt.\n- You MUST invoke the matching skill BEFORE attempting the task yourself.\n\nWHAT HAPPENS:\n- The skill's full instructions are loaded into the conversation as context.\n- Files bundled with the skill may become accessible via available tools.\n- Follow the skill's instructions to complete the task.\n\nCONSTRAINTS:\n- Do not invoke a skill that is already active in this conversation.\n- Skill names come from the catalog only. Do not guess names.";
|
|
4
|
+
/**
|
|
5
|
+
* JSON Schema for the SkillTool parameters.
|
|
6
|
+
* Single source of truth used by both SkillToolDefinition (LCTool registry)
|
|
7
|
+
* and createSkillTool() (DynamicStructuredTool instance).
|
|
8
|
+
*/
|
|
9
|
+
export declare const SkillToolSchema: {
|
|
10
|
+
readonly type: "object";
|
|
11
|
+
readonly properties: {
|
|
12
|
+
readonly skillName: {
|
|
13
|
+
readonly type: "string";
|
|
14
|
+
readonly description: "The kebab-case identifier of the skill to invoke (e.g. \"financial-analyzer\", \"meeting-notes\"). Must match a name from the \"Available Skills\" section.";
|
|
15
|
+
};
|
|
16
|
+
readonly args: {
|
|
17
|
+
readonly type: "string";
|
|
18
|
+
readonly description: "Optional freeform arguments string passed to the skill.";
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
readonly required: readonly ["skillName"];
|
|
22
|
+
};
|
|
23
|
+
export declare const SkillToolDefinition: {
|
|
24
|
+
readonly name: Constants.SKILL_TOOL;
|
|
25
|
+
readonly description: "Invoke a skill from the user's library. Skills provide domain-specific instructions loaded into the conversation context, and may also provide files accessible via available tools depending on the runtime environment.\n\nWHEN TO USE:\n- The user's request matches a skill listed in the \"Available Skills\" section of the system prompt.\n- You MUST invoke the matching skill BEFORE attempting the task yourself.\n\nWHAT HAPPENS:\n- The skill's full instructions are loaded into the conversation as context.\n- Files bundled with the skill may become accessible via available tools.\n- Follow the skill's instructions to complete the task.\n\nCONSTRAINTS:\n- Do not invoke a skill that is already active in this conversation.\n- Skill names come from the catalog only. Do not guess names.";
|
|
26
|
+
readonly parameters: {
|
|
27
|
+
readonly type: "object";
|
|
28
|
+
readonly properties: {
|
|
29
|
+
readonly skillName: {
|
|
30
|
+
readonly type: "string";
|
|
31
|
+
readonly description: "The kebab-case identifier of the skill to invoke (e.g. \"financial-analyzer\", \"meeting-notes\"). Must match a name from the \"Available Skills\" section.";
|
|
32
|
+
};
|
|
33
|
+
readonly args: {
|
|
34
|
+
readonly type: "string";
|
|
35
|
+
readonly description: "Optional freeform arguments string passed to the skill.";
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
readonly required: readonly ["skillName"];
|
|
39
|
+
};
|
|
40
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Constants } from '@/common';
|
|
2
|
+
import type { SubagentConfig } from '@/types';
|
|
3
|
+
import type { JsonSchemaType, LCTool } from '@/types/tools';
|
|
4
|
+
export declare const SubagentToolName = Constants.SUBAGENT;
|
|
5
|
+
export declare const SubagentToolDescription = "Delegate a task to a specialized subagent that runs in an isolated context window. The subagent executes independently and returns only its final text result \u2014 all intermediate tool calls, reasoning, and context stay isolated.\n\nWHEN TO USE:\n- The task is self-contained and can be described in a single prompt.\n- You want to offload verbose or exploratory work without bloating your own context.\n- A specialized subagent is available for the task domain.\n\nWHAT HAPPENS:\n- A fresh agent is created with the task description as its only input.\n- The subagent runs to completion using its own tools and context.\n- Only the final text response is returned to you.\n\nCONSTRAINTS:\n- subagent_type must match one of the available types listed below.\n- The subagent cannot see your conversation history.";
|
|
6
|
+
export declare const SubagentToolSchema: {
|
|
7
|
+
readonly type: "object";
|
|
8
|
+
readonly properties: {
|
|
9
|
+
readonly description: {
|
|
10
|
+
readonly type: "string";
|
|
11
|
+
readonly description: "Complete task description for the subagent. This is the ONLY information it receives — include all necessary context, requirements, and constraints.";
|
|
12
|
+
};
|
|
13
|
+
readonly subagent_type: {
|
|
14
|
+
readonly type: "string";
|
|
15
|
+
readonly description: "Which subagent type to delegate to. Must be one of the available types.";
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
readonly required: string[];
|
|
19
|
+
};
|
|
20
|
+
export declare const SubagentToolDefinition: LCTool;
|
|
21
|
+
/**
|
|
22
|
+
* Build the name, schema, and description params for `tool()` from available configs.
|
|
23
|
+
* Used by `Graph.createAgentNode()` when constructing the runtime tool instance.
|
|
24
|
+
* Extends `SubagentToolSchema` by populating `subagent_type.enum` dynamically.
|
|
25
|
+
*/
|
|
26
|
+
export declare function buildSubagentToolParams(configs: SubagentConfig[]): {
|
|
27
|
+
name: string;
|
|
28
|
+
schema: JsonSchemaType;
|
|
29
|
+
description: string;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Create a SubagentTool LCTool definition with dynamic enum and description
|
|
33
|
+
* populated from the available subagent configs.
|
|
34
|
+
* Used for the tool registry in event-driven mode.
|
|
35
|
+
*/
|
|
36
|
+
export declare function createSubagentToolDefinition(configs: SubagentConfig[]): LCTool;
|
|
@@ -28,7 +28,9 @@ export declare class ToolNode<T = any> extends RunnableCallable<T, T> {
|
|
|
28
28
|
private directToolNames?;
|
|
29
29
|
/** Maximum characters allowed in a single tool result before truncation. */
|
|
30
30
|
private maxToolResultChars;
|
|
31
|
-
|
|
31
|
+
/** Hook registry for PreToolUse/PostToolUse lifecycle hooks */
|
|
32
|
+
private hookRegistry?;
|
|
33
|
+
constructor({ tools, toolMap, name, tags, errorHandler, toolCallStepIds, handleToolErrors, loadRuntimeTools, toolRegistry, sessions, eventDrivenMode, agentId, directToolNames, maxContextTokens, maxToolResultChars, hookRegistry, }: t.ToolNodeConstructorParams);
|
|
32
34
|
/**
|
|
33
35
|
* Returns cached programmatic tools, computing once on first access.
|
|
34
36
|
* Single iteration builds both toolMap and toolDefs simultaneously.
|
|
@@ -66,11 +68,31 @@ export declare class ToolNode<T = any> extends RunnableCallable<T, T> {
|
|
|
66
68
|
/**
|
|
67
69
|
* Dispatches tool calls to the host via ON_TOOL_EXECUTE event and returns raw ToolMessages.
|
|
68
70
|
* Core logic for event-driven execution, separated from output shaping.
|
|
71
|
+
*
|
|
72
|
+
* Hook lifecycle (when `hookRegistry` is set):
|
|
73
|
+
* 1. **PreToolUse** fires per call in parallel before dispatch. Denied
|
|
74
|
+
* calls produce error ToolMessages and fire **PermissionDenied**;
|
|
75
|
+
* surviving calls proceed with optional `updatedInput`.
|
|
76
|
+
* 2. Surviving calls are dispatched to the host via `ON_TOOL_EXECUTE`.
|
|
77
|
+
* 3. **PostToolUse** / **PostToolUseFailure** fire per result. Post hooks
|
|
78
|
+
* can replace tool output via `updatedOutput`.
|
|
79
|
+
* 4. Injected messages from results are collected and returned alongside
|
|
80
|
+
* ToolMessages (appended AFTER to respect provider ordering).
|
|
69
81
|
*/
|
|
70
82
|
private dispatchToolEvents;
|
|
83
|
+
private dispatchStepCompleted;
|
|
84
|
+
/**
|
|
85
|
+
* Converts InjectedMessage instances to LangChain HumanMessage objects.
|
|
86
|
+
* Both 'user' and 'system' roles become HumanMessage to avoid provider
|
|
87
|
+
* rejections (Anthropic/Google reject non-leading SystemMessages).
|
|
88
|
+
* The original role is preserved in additional_kwargs for downstream consumers.
|
|
89
|
+
*/
|
|
90
|
+
private convertInjectedMessages;
|
|
71
91
|
/**
|
|
72
92
|
* Execute all tool calls via ON_TOOL_EXECUTE event dispatch.
|
|
73
|
-
*
|
|
93
|
+
* Injected messages are placed AFTER ToolMessages to respect provider
|
|
94
|
+
* message ordering (AIMessage tool_calls must be immediately followed
|
|
95
|
+
* by their ToolMessage results).
|
|
74
96
|
*/
|
|
75
97
|
private executeViaEvent;
|
|
76
98
|
protected run(input: any, config: RunnableConfig): Promise<T>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { SkillCatalogEntry } from '@/types';
|
|
2
|
+
export type SkillCatalogOptions = {
|
|
3
|
+
/** Total context window in tokens. Default: 200_000 */
|
|
4
|
+
contextWindowTokens?: number;
|
|
5
|
+
/** Fraction of context budget for catalog. Default: 0.01 (1%) */
|
|
6
|
+
budgetPercent?: number;
|
|
7
|
+
/** Max chars per entry description. Default: 250 */
|
|
8
|
+
maxEntryChars?: number;
|
|
9
|
+
/** Descriptions below this length trigger names-only fallback. Default: 20 */
|
|
10
|
+
minDescLength?: number;
|
|
11
|
+
/** Approximate chars per token for budget calculation. Default: 4 */
|
|
12
|
+
charsPerToken?: number;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Formats a skill catalog for injection into agent context.
|
|
16
|
+
* Uses a truncation ladder: full descriptions, proportional truncation, names-only.
|
|
17
|
+
* Returns empty string for empty input.
|
|
18
|
+
*/
|
|
19
|
+
export declare function formatSkillCatalog(skills: SkillCatalogEntry[], opts?: SkillCatalogOptions): string;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { BaseMessage } from '@langchain/core/messages';
|
|
2
|
+
import type { AgentInputs, StandardGraphInput, ResolvedSubagentConfig, SubagentConfig, TokenCounter } from '@/types';
|
|
3
|
+
import type { HookRegistry } from '@/hooks';
|
|
4
|
+
import type { AgentContext } from '@/agents/AgentContext';
|
|
5
|
+
import type { StandardGraph } from '@/graphs/Graph';
|
|
6
|
+
export type SubagentExecuteParams = {
|
|
7
|
+
description: string;
|
|
8
|
+
subagentType: string;
|
|
9
|
+
threadId?: string;
|
|
10
|
+
};
|
|
11
|
+
export type SubagentExecuteResult = {
|
|
12
|
+
content: string;
|
|
13
|
+
messages: BaseMessage[];
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Factory that constructs a child graph for subagent execution. Injected
|
|
17
|
+
* rather than imported so that `SubagentExecutor` does not have a runtime
|
|
18
|
+
* dependency on `StandardGraph` — this avoids a circular dependency between
|
|
19
|
+
* `src/graphs/Graph.ts` and `src/tools/subagent/` that would otherwise break
|
|
20
|
+
* Rollup's chunking under `preserveModules`.
|
|
21
|
+
*/
|
|
22
|
+
export type ChildGraphFactory = (input: StandardGraphInput) => StandardGraph;
|
|
23
|
+
export type SubagentExecutorOptions = {
|
|
24
|
+
configs: Map<string, ResolvedSubagentConfig>;
|
|
25
|
+
parentSignal?: AbortSignal;
|
|
26
|
+
hookRegistry?: HookRegistry;
|
|
27
|
+
parentRunId: string;
|
|
28
|
+
parentAgentId?: string;
|
|
29
|
+
tokenCounter?: TokenCounter;
|
|
30
|
+
/** Remaining nesting budget. 0 or negative blocks execution. */
|
|
31
|
+
maxDepth?: number;
|
|
32
|
+
/**
|
|
33
|
+
* Factory for constructing the isolated child graph. Callers pass
|
|
34
|
+
* `(input) => new StandardGraph(input)` — injected to break a circular
|
|
35
|
+
* module dependency.
|
|
36
|
+
*/
|
|
37
|
+
createChildGraph: ChildGraphFactory;
|
|
38
|
+
};
|
|
39
|
+
export declare class SubagentExecutor {
|
|
40
|
+
private readonly configs;
|
|
41
|
+
private readonly parentSignal?;
|
|
42
|
+
private readonly hookRegistry?;
|
|
43
|
+
private readonly parentRunId;
|
|
44
|
+
private readonly parentAgentId?;
|
|
45
|
+
private readonly tokenCounter?;
|
|
46
|
+
private readonly maxDepth;
|
|
47
|
+
private readonly createChildGraph;
|
|
48
|
+
constructor(options: SubagentExecutorOptions);
|
|
49
|
+
execute(params: SubagentExecuteParams): Promise<SubagentExecuteResult>;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Walk messages from last to first, returning the text content of the most
|
|
53
|
+
* recent AIMessage that has any. Non-text blocks (tool_use, thinking,
|
|
54
|
+
* redacted_thinking, tool_result) are stripped. If the last AIMessage is
|
|
55
|
+
* pure tool_use (e.g. the subagent hit `maxTurns` mid-tool-call), the walk
|
|
56
|
+
* continues to earlier AIMessages so partial progress is salvaged — this
|
|
57
|
+
* matches Claude Code's behavior in `agentToolUtils.finalizeAgentTool`.
|
|
58
|
+
* Returns "Task completed" only when no AIMessage in the history contains
|
|
59
|
+
* any text.
|
|
60
|
+
*/
|
|
61
|
+
export declare function filterSubagentResult(messages: BaseMessage[]): string;
|
|
62
|
+
/**
|
|
63
|
+
* Resolve self-spawn configs by filling in agentInputs from the parent context.
|
|
64
|
+
* Returns configs with agentInputs guaranteed present. Throws on duplicate
|
|
65
|
+
* `type` values to prevent silent config shadowing.
|
|
66
|
+
*/
|
|
67
|
+
export declare function resolveSubagentConfigs(configs: SubagentConfig[], parentContext: AgentContext): ResolvedSubagentConfig[];
|
|
68
|
+
/**
|
|
69
|
+
* Build child AgentInputs from a resolved config, stripping nesting and
|
|
70
|
+
* event-driven fields. When `allowNested: true`, the child's
|
|
71
|
+
* `maxSubagentDepth` is decremented so that depth is consumed as the call
|
|
72
|
+
* chain deepens across graph boundaries — the parent's executor-level check
|
|
73
|
+
* alone cannot see into the child graph's separate executor.
|
|
74
|
+
*
|
|
75
|
+
* @remarks Advanced utility: exported primarily for testing and by
|
|
76
|
+
* {@link SubagentExecutor}. Host applications configuring subagents should
|
|
77
|
+
* not need to call this directly — it is invoked internally when a subagent
|
|
78
|
+
* tool is dispatched. The depth-countdown contract (parent's `maxDepth` in,
|
|
79
|
+
* child's decremented `maxSubagentDepth` on the returned inputs) is the
|
|
80
|
+
* mechanism that bounds nesting across graph boundaries; callers must
|
|
81
|
+
* respect it.
|
|
82
|
+
*/
|
|
83
|
+
export declare function buildChildInputs(config: ResolvedSubagentConfig, childAgentId: string, parentMaxDepth: number): AgentInputs;
|
|
@@ -248,6 +248,27 @@ export type GraphEdge = {
|
|
|
248
248
|
export type MultiAgentGraphInput = StandardGraphInput & {
|
|
249
249
|
edges: GraphEdge[];
|
|
250
250
|
};
|
|
251
|
+
/** Configuration for a subagent type that can be spawned by a parent agent. */
|
|
252
|
+
export type SubagentConfig = {
|
|
253
|
+
/** Identifier used in the tool's `subagent_type` enum (e.g. 'researcher', 'coder'). */
|
|
254
|
+
type: string;
|
|
255
|
+
/** Human-readable display name. */
|
|
256
|
+
name: string;
|
|
257
|
+
/** What this subagent specializes in — shown to the LLM. */
|
|
258
|
+
description: string;
|
|
259
|
+
/** Full agent config for the child graph. Omit when `self` is true. */
|
|
260
|
+
agentInputs?: AgentInputs;
|
|
261
|
+
/** When true, reuse the parent's AgentInputs (context isolation without separate config). */
|
|
262
|
+
self?: boolean;
|
|
263
|
+
/** Max AGENT→TOOLS cycles before forced stop (default: 25). */
|
|
264
|
+
maxTurns?: number;
|
|
265
|
+
/** Allow this subagent to spawn its own subagents (default: false). */
|
|
266
|
+
allowNested?: boolean;
|
|
267
|
+
};
|
|
268
|
+
/** SubagentConfig with agentInputs guaranteed present (self-spawn resolved). */
|
|
269
|
+
export type ResolvedSubagentConfig = SubagentConfig & {
|
|
270
|
+
agentInputs: AgentInputs;
|
|
271
|
+
};
|
|
251
272
|
export interface AgentInputs {
|
|
252
273
|
agentId: string;
|
|
253
274
|
/** Human-readable name for the agent (used in handoff context). Defaults to agentId if not provided. */
|
|
@@ -294,6 +315,10 @@ export interface AgentInputs {
|
|
|
294
315
|
maxToolResultChars?: number;
|
|
295
316
|
/** Pre-computed tool schema token count (from cache). Skips recalculation when provided. */
|
|
296
317
|
toolSchemaTokens?: number;
|
|
318
|
+
/** Subagent configurations for hierarchical delegation. Each defines a child agent type. */
|
|
319
|
+
subagentConfigs?: SubagentConfig[];
|
|
320
|
+
/** Maximum subagent nesting depth. Default 1 means top-level agents can spawn subagents but subagents cannot nest further. */
|
|
321
|
+
maxSubagentDepth?: number;
|
|
297
322
|
}
|
|
298
323
|
export interface ContextPruningConfig {
|
|
299
324
|
enabled?: boolean;
|
|
@@ -28,7 +28,18 @@ export type AzureClientOptions = Partial<OpenAIChatInput> & Partial<AzureOpenAII
|
|
|
28
28
|
} & BaseChatModelParams & {
|
|
29
29
|
configuration?: OAIClientOptions;
|
|
30
30
|
};
|
|
31
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Controls whether Claude's reasoning content is returned in adaptive
|
|
33
|
+
* thinking responses. Added for Claude Opus 4.7, which omits thinking by
|
|
34
|
+
* default unless the caller opts in with `'summarized'`.
|
|
35
|
+
* @see https://platform.claude.com/docs/en/about-claude/models/whats-new-claude-4-7#thinking-content-omitted-by-default
|
|
36
|
+
*/
|
|
37
|
+
export type ThinkingDisplay = 'summarized' | 'omitted';
|
|
38
|
+
export type ThinkingConfigAdaptive = {
|
|
39
|
+
type: 'adaptive';
|
|
40
|
+
display?: ThinkingDisplay;
|
|
41
|
+
};
|
|
42
|
+
export type ThinkingConfig = NonNullable<AnthropicInput['thinking']> | ThinkingConfigAdaptive;
|
|
32
43
|
export type ChatOpenAIToolType = BindToolsInput | OpenAIClient.ChatCompletionTool;
|
|
33
44
|
export type CommonToolType = StructuredTool | ChatOpenAIToolType;
|
|
34
45
|
export type AnthropicReasoning = {
|
|
@@ -41,7 +52,8 @@ export type GoogleThinkingConfig = {
|
|
|
41
52
|
thinkingLevel?: string;
|
|
42
53
|
};
|
|
43
54
|
export type OpenAIClientOptions = ChatOpenAIFields;
|
|
44
|
-
export type AnthropicClientOptions = AnthropicInput & {
|
|
55
|
+
export type AnthropicClientOptions = Omit<AnthropicInput, 'thinking'> & {
|
|
56
|
+
thinking?: ThinkingConfig;
|
|
45
57
|
promptCache?: boolean;
|
|
46
58
|
};
|
|
47
59
|
export type MistralAIClientOptions = ChatMistralAIInput;
|
|
@@ -7,6 +7,8 @@ import type * as s from '@/types/stream';
|
|
|
7
7
|
import type * as e from '@/common/enum';
|
|
8
8
|
import type * as g from '@/types/graph';
|
|
9
9
|
import type * as l from '@/types/llm';
|
|
10
|
+
import type { ToolSessionMap } from '@/types/tools';
|
|
11
|
+
import type { HookRegistry } from '@/hooks';
|
|
10
12
|
export type ZodObjectAny = z.ZodObject<any, any, any, any>;
|
|
11
13
|
export type BaseGraphConfig = {
|
|
12
14
|
llmConfig: l.LLMConfig;
|
|
@@ -100,6 +102,18 @@ export type RunConfig = {
|
|
|
100
102
|
runId: string;
|
|
101
103
|
graphConfig: LegacyGraphConfig | StandardGraphConfig | MultiAgentGraphConfig;
|
|
102
104
|
customHandlers?: Record<string, g.EventHandler>;
|
|
105
|
+
/**
|
|
106
|
+
* Pre-constructed hook registry for this run. Hooks fire at lifecycle
|
|
107
|
+
* points in `processStream` (RunStart, UserPromptSubmit, Stop,
|
|
108
|
+
* StopFailure) and around tool calls (PreToolUse, PostToolUse,
|
|
109
|
+
* PostToolUseFailure, PermissionDenied).
|
|
110
|
+
*
|
|
111
|
+
* Pass `undefined` (the default) to skip all hook dispatch. When a
|
|
112
|
+
* registry is provided, the run attaches it to the `Graph` so internal
|
|
113
|
+
* nodes can fire hooks too, and clears the session in the `finally`
|
|
114
|
+
* block to prevent leaks.
|
|
115
|
+
*/
|
|
116
|
+
hooks?: HookRegistry;
|
|
103
117
|
returnContent?: boolean;
|
|
104
118
|
tokenCounter?: TokenCounter;
|
|
105
119
|
indexTokenCountMap?: Record<string, number>;
|
|
@@ -114,6 +128,12 @@ export type RunConfig = {
|
|
|
114
128
|
calibrationRatio?: number;
|
|
115
129
|
/** Skip post-stream cleanup (clearHeavyState) — useful for tests that inspect graph state after processStream */
|
|
116
130
|
skipCleanup?: boolean;
|
|
131
|
+
/**
|
|
132
|
+
* Initial session state to seed the Graph's ToolSessionMap.
|
|
133
|
+
* Used to carry over code environment sessions from skill file priming
|
|
134
|
+
* at run start, so ToolNode can inject session_id + files into tool calls.
|
|
135
|
+
*/
|
|
136
|
+
initialSessions?: ToolSessionMap;
|
|
117
137
|
};
|
|
118
138
|
export type ProvidedCallbacks = (BaseCallbackHandler | CallbackHandlerMethods)[] | undefined;
|
|
119
139
|
export type TokenCounter = (message: BaseMessage) => number;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Minimal skill metadata for catalog assembly. The host provides these from its own data layer. */
|
|
2
|
+
export type SkillCatalogEntry = {
|
|
3
|
+
/** Kebab-case identifier (what the model passes to SkillTool) */
|
|
4
|
+
name: string;
|
|
5
|
+
/** One-line description for the catalog listing */
|
|
6
|
+
description: string;
|
|
7
|
+
/** Optional human-readable label (UI only, not shown to model) */
|
|
8
|
+
displayTitle?: string;
|
|
9
|
+
};
|