illuma-agents 1.0.37 → 1.0.39
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 +112 -14
- package/dist/cjs/agents/AgentContext.cjs.map +1 -1
- package/dist/cjs/common/enum.cjs +5 -1
- package/dist/cjs/common/enum.cjs.map +1 -1
- package/dist/cjs/graphs/Graph.cjs +148 -8
- package/dist/cjs/graphs/Graph.cjs.map +1 -1
- package/dist/cjs/graphs/MultiAgentGraph.cjs +277 -11
- package/dist/cjs/graphs/MultiAgentGraph.cjs.map +1 -1
- package/dist/cjs/llm/bedrock/index.cjs +128 -61
- package/dist/cjs/llm/bedrock/index.cjs.map +1 -1
- package/dist/cjs/main.cjs +22 -7
- package/dist/cjs/main.cjs.map +1 -1
- package/dist/cjs/messages/cache.cjs +140 -46
- package/dist/cjs/messages/cache.cjs.map +1 -1
- package/dist/cjs/messages/core.cjs +1 -1
- package/dist/cjs/messages/core.cjs.map +1 -1
- package/dist/cjs/messages/tools.cjs +2 -2
- package/dist/cjs/messages/tools.cjs.map +1 -1
- package/dist/cjs/schemas/validate.cjs +173 -0
- package/dist/cjs/schemas/validate.cjs.map +1 -0
- package/dist/cjs/stream.cjs +4 -2
- package/dist/cjs/stream.cjs.map +1 -1
- package/dist/cjs/tools/BrowserTools.cjs.map +1 -1
- package/dist/cjs/tools/CodeExecutor.cjs +22 -21
- package/dist/cjs/tools/CodeExecutor.cjs.map +1 -1
- package/dist/cjs/tools/ProgrammaticToolCalling.cjs +14 -11
- package/dist/cjs/tools/ProgrammaticToolCalling.cjs.map +1 -1
- package/dist/cjs/tools/ToolNode.cjs +101 -2
- package/dist/cjs/tools/ToolNode.cjs.map +1 -1
- package/dist/cjs/tools/ToolSearch.cjs +862 -0
- package/dist/cjs/tools/ToolSearch.cjs.map +1 -0
- package/dist/esm/agents/AgentContext.mjs +112 -14
- package/dist/esm/agents/AgentContext.mjs.map +1 -1
- package/dist/esm/common/enum.mjs +5 -1
- package/dist/esm/common/enum.mjs.map +1 -1
- package/dist/esm/graphs/Graph.mjs +149 -9
- package/dist/esm/graphs/Graph.mjs.map +1 -1
- package/dist/esm/graphs/MultiAgentGraph.mjs +278 -12
- package/dist/esm/graphs/MultiAgentGraph.mjs.map +1 -1
- package/dist/esm/llm/bedrock/index.mjs +127 -60
- package/dist/esm/llm/bedrock/index.mjs.map +1 -1
- package/dist/esm/main.mjs +2 -1
- package/dist/esm/main.mjs.map +1 -1
- package/dist/esm/messages/cache.mjs +140 -46
- package/dist/esm/messages/cache.mjs.map +1 -1
- package/dist/esm/messages/core.mjs +1 -1
- package/dist/esm/messages/core.mjs.map +1 -1
- package/dist/esm/messages/tools.mjs +2 -2
- package/dist/esm/messages/tools.mjs.map +1 -1
- package/dist/esm/schemas/validate.mjs +167 -0
- package/dist/esm/schemas/validate.mjs.map +1 -0
- package/dist/esm/stream.mjs +4 -2
- package/dist/esm/stream.mjs.map +1 -1
- package/dist/esm/tools/BrowserTools.mjs.map +1 -1
- package/dist/esm/tools/CodeExecutor.mjs +22 -21
- package/dist/esm/tools/CodeExecutor.mjs.map +1 -1
- package/dist/esm/tools/ProgrammaticToolCalling.mjs +14 -11
- package/dist/esm/tools/ProgrammaticToolCalling.mjs.map +1 -1
- package/dist/esm/tools/ToolNode.mjs +102 -3
- package/dist/esm/tools/ToolNode.mjs.map +1 -1
- package/dist/esm/tools/ToolSearch.mjs +827 -0
- package/dist/esm/tools/ToolSearch.mjs.map +1 -0
- package/dist/types/agents/AgentContext.d.ts +51 -1
- package/dist/types/common/enum.d.ts +6 -2
- package/dist/types/graphs/Graph.d.ts +12 -0
- package/dist/types/graphs/MultiAgentGraph.d.ts +16 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/llm/bedrock/index.d.ts +89 -11
- package/dist/types/llm/bedrock/types.d.ts +27 -0
- package/dist/types/llm/bedrock/utils/index.d.ts +5 -0
- package/dist/types/llm/bedrock/utils/message_inputs.d.ts +31 -0
- package/dist/types/llm/bedrock/utils/message_outputs.d.ts +33 -0
- package/dist/types/messages/cache.d.ts +4 -1
- package/dist/types/schemas/index.d.ts +1 -0
- package/dist/types/schemas/validate.d.ts +36 -0
- package/dist/types/tools/CodeExecutor.d.ts +0 -3
- package/dist/types/tools/ProgrammaticToolCalling.d.ts +0 -3
- package/dist/types/tools/ToolNode.d.ts +3 -1
- package/dist/types/tools/ToolSearch.d.ts +148 -0
- package/dist/types/types/graph.d.ts +71 -0
- package/dist/types/types/llm.d.ts +3 -1
- package/dist/types/types/tools.d.ts +42 -2
- package/package.json +13 -6
- package/src/agents/AgentContext.test.ts +312 -0
- package/src/agents/AgentContext.ts +144 -16
- package/src/common/enum.ts +5 -1
- package/src/graphs/Graph.ts +214 -13
- package/src/graphs/MultiAgentGraph.ts +350 -13
- package/src/index.ts +4 -1
- package/src/llm/bedrock/index.ts +221 -99
- package/src/llm/bedrock/llm.spec.ts +616 -0
- package/src/llm/bedrock/types.ts +51 -0
- package/src/llm/bedrock/utils/index.ts +18 -0
- package/src/llm/bedrock/utils/message_inputs.ts +563 -0
- package/src/llm/bedrock/utils/message_outputs.ts +310 -0
- package/src/messages/__tests__/tools.test.ts +21 -21
- package/src/messages/cache.test.ts +304 -0
- package/src/messages/cache.ts +183 -53
- package/src/messages/core.ts +1 -1
- package/src/messages/tools.ts +2 -2
- package/src/schemas/index.ts +2 -0
- package/src/schemas/validate.test.ts +358 -0
- package/src/schemas/validate.ts +238 -0
- package/src/scripts/caching.ts +27 -19
- package/src/scripts/code_exec_files.ts +58 -15
- package/src/scripts/code_exec_multi_session.ts +241 -0
- package/src/scripts/code_exec_session.ts +282 -0
- package/src/scripts/multi-agent-conditional.ts +1 -0
- package/src/scripts/multi-agent-supervisor.ts +1 -0
- package/src/scripts/programmatic_exec_agent.ts +4 -4
- package/src/scripts/test-handoff-preamble.ts +277 -0
- package/src/scripts/test-parallel-handoffs.ts +291 -0
- package/src/scripts/test-tools-before-handoff.ts +8 -4
- package/src/scripts/test_code_api.ts +361 -0
- package/src/scripts/thinking-bedrock.ts +159 -0
- package/src/scripts/thinking.ts +39 -18
- package/src/scripts/{tool_search_regex.ts → tool_search.ts} +5 -5
- package/src/scripts/tools.ts +7 -3
- package/src/specs/cache.simple.test.ts +396 -0
- package/src/stream.ts +4 -2
- package/src/tools/BrowserTools.ts +39 -17
- package/src/tools/CodeExecutor.ts +26 -23
- package/src/tools/ProgrammaticToolCalling.ts +18 -14
- package/src/tools/ToolNode.ts +114 -1
- package/src/tools/ToolSearch.ts +1041 -0
- package/src/tools/__tests__/ProgrammaticToolCalling.test.ts +0 -2
- package/src/tools/__tests__/{ToolSearchRegex.integration.test.ts → ToolSearch.integration.test.ts} +6 -6
- package/src/tools/__tests__/ToolSearch.test.ts +1003 -0
- package/src/types/graph.test.ts +183 -0
- package/src/types/graph.ts +73 -0
- package/src/types/llm.ts +3 -1
- package/src/types/tools.ts +51 -2
- package/dist/cjs/tools/ToolSearchRegex.cjs +0 -455
- package/dist/cjs/tools/ToolSearchRegex.cjs.map +0 -1
- package/dist/esm/tools/ToolSearchRegex.mjs +0 -448
- package/dist/esm/tools/ToolSearchRegex.mjs.map +0 -1
- package/dist/types/tools/ToolSearchRegex.d.ts +0 -80
- package/src/tools/ToolSearchRegex.ts +0 -535
- package/src/tools/__tests__/ToolSearchRegex.test.ts +0 -232
|
@@ -3,16 +3,13 @@ import { DynamicStructuredTool } from '@langchain/core/tools';
|
|
|
3
3
|
import type * as t from '@/types';
|
|
4
4
|
declare const ProgrammaticToolCallingSchema: z.ZodObject<{
|
|
5
5
|
code: z.ZodString;
|
|
6
|
-
session_id: z.ZodOptional<z.ZodString>;
|
|
7
6
|
timeout: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
8
7
|
}, "strip", z.ZodTypeAny, {
|
|
9
8
|
code: string;
|
|
10
9
|
timeout: number;
|
|
11
|
-
session_id?: string | undefined;
|
|
12
10
|
}, {
|
|
13
11
|
code: string;
|
|
14
12
|
timeout?: number | undefined;
|
|
15
|
-
session_id?: string | undefined;
|
|
16
13
|
}>;
|
|
17
14
|
/**
|
|
18
15
|
* Normalizes a tool name to Python identifier format.
|
|
@@ -16,7 +16,9 @@ export declare class ToolNode<T = any> extends RunnableCallable<T, T> {
|
|
|
16
16
|
private toolRegistry?;
|
|
17
17
|
/** Cached programmatic tools (computed once on first PTC call) */
|
|
18
18
|
private programmaticCache?;
|
|
19
|
-
|
|
19
|
+
/** Reference to Graph's sessions map for automatic session injection */
|
|
20
|
+
private sessions?;
|
|
21
|
+
constructor({ tools, toolMap, name, tags, errorHandler, toolCallStepIds, handleToolErrors, loadRuntimeTools, toolRegistry, sessions, }: t.ToolNodeConstructorParams);
|
|
20
22
|
/**
|
|
21
23
|
* Returns cached programmatic tools, computing once on first access.
|
|
22
24
|
* Single iteration builds both toolMap and toolDefs simultaneously.
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { DynamicStructuredTool } from '@langchain/core/tools';
|
|
3
|
+
import type * as t from '@/types';
|
|
4
|
+
/** Zod schema type for tool search parameters */
|
|
5
|
+
type ToolSearchSchema = z.ZodObject<{
|
|
6
|
+
query: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
7
|
+
fields: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodEnum<['name', 'description', 'parameters']>>>>;
|
|
8
|
+
max_results: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
9
|
+
mcp_server: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
10
|
+
}>;
|
|
11
|
+
/**
|
|
12
|
+
* Creates the Zod schema with dynamic query description based on mode.
|
|
13
|
+
* @param mode - The search mode determining query interpretation
|
|
14
|
+
* @returns Zod schema for tool search parameters
|
|
15
|
+
*/
|
|
16
|
+
declare function createToolSearchSchema(mode: t.ToolSearchMode): ToolSearchSchema;
|
|
17
|
+
/**
|
|
18
|
+
* Extracts the MCP server name from a tool name.
|
|
19
|
+
* MCP tools follow the pattern: toolName_mcp_serverName
|
|
20
|
+
* @param toolName - The full tool name
|
|
21
|
+
* @returns The server name if it's an MCP tool, undefined otherwise
|
|
22
|
+
*/
|
|
23
|
+
declare function extractMcpServerName(toolName: string): string | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Checks if a tool belongs to a specific MCP server.
|
|
26
|
+
* @param toolName - The full tool name
|
|
27
|
+
* @param serverName - The server name to match
|
|
28
|
+
* @returns True if the tool belongs to the specified server
|
|
29
|
+
*/
|
|
30
|
+
declare function isFromMcpServer(toolName: string, serverName: string): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Checks if a tool belongs to any of the specified MCP servers.
|
|
33
|
+
* @param toolName - The full tool name
|
|
34
|
+
* @param serverNames - Array of server names to match
|
|
35
|
+
* @returns True if the tool belongs to any of the specified servers
|
|
36
|
+
*/
|
|
37
|
+
declare function isFromAnyMcpServer(toolName: string, serverNames: string[]): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Normalizes server filter input to always be an array.
|
|
40
|
+
* @param serverFilter - String, array of strings, or undefined
|
|
41
|
+
* @returns Array of server names (empty if none specified)
|
|
42
|
+
*/
|
|
43
|
+
declare function normalizeServerFilter(serverFilter: string | string[] | undefined): string[];
|
|
44
|
+
/**
|
|
45
|
+
* Extracts all unique MCP server names from a tool registry.
|
|
46
|
+
* @param toolRegistry - The tool registry to scan
|
|
47
|
+
* @param onlyDeferred - If true, only considers deferred tools
|
|
48
|
+
* @returns Array of unique server names, sorted alphabetically
|
|
49
|
+
*/
|
|
50
|
+
declare function getAvailableMcpServers(toolRegistry: t.LCToolRegistry | undefined, onlyDeferred?: boolean): string[];
|
|
51
|
+
/**
|
|
52
|
+
* Escapes special regex characters in a string to use as a literal pattern.
|
|
53
|
+
* @param pattern - The string to escape
|
|
54
|
+
* @returns The escaped string safe for use in a RegExp
|
|
55
|
+
*/
|
|
56
|
+
declare function escapeRegexSpecialChars(pattern: string): string;
|
|
57
|
+
/**
|
|
58
|
+
* Counts the maximum nesting depth of groups in a regex pattern.
|
|
59
|
+
* @param pattern - The regex pattern to analyze
|
|
60
|
+
* @returns The maximum nesting depth
|
|
61
|
+
*/
|
|
62
|
+
declare function countNestedGroups(pattern: string): number;
|
|
63
|
+
/**
|
|
64
|
+
* Detects nested quantifiers that can cause catastrophic backtracking.
|
|
65
|
+
* Patterns like (a+)+, (a*)*, (a+)*, etc.
|
|
66
|
+
* @param pattern - The regex pattern to check
|
|
67
|
+
* @returns True if nested quantifiers are detected
|
|
68
|
+
*/
|
|
69
|
+
declare function hasNestedQuantifiers(pattern: string): boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Checks if a regex pattern contains potentially dangerous constructs.
|
|
72
|
+
* @param pattern - The regex pattern to validate
|
|
73
|
+
* @returns True if the pattern is dangerous
|
|
74
|
+
*/
|
|
75
|
+
declare function isDangerousPattern(pattern: string): boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Sanitizes a regex pattern for safe execution.
|
|
78
|
+
* If the pattern is dangerous, it will be escaped to a literal string search.
|
|
79
|
+
* @param pattern - The regex pattern to sanitize
|
|
80
|
+
* @returns Object containing the safe pattern and whether it was escaped
|
|
81
|
+
*/
|
|
82
|
+
declare function sanitizeRegex(pattern: string): {
|
|
83
|
+
safe: string;
|
|
84
|
+
wasEscaped: boolean;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Performs BM25-based search for better relevance ranking.
|
|
88
|
+
* Uses Okapi BM25 algorithm for term frequency and document length normalization.
|
|
89
|
+
* @param tools - Array of tool metadata to search
|
|
90
|
+
* @param query - The search query
|
|
91
|
+
* @param fields - Which fields to search
|
|
92
|
+
* @param maxResults - Maximum results to return
|
|
93
|
+
* @returns Search response with matching tools ranked by BM25 score
|
|
94
|
+
*/
|
|
95
|
+
declare function performLocalSearch(tools: t.ToolMetadata[], query: string, fields: string[], maxResults: number): t.ToolSearchResponse;
|
|
96
|
+
/**
|
|
97
|
+
* Extracts the base tool name (without MCP server suffix) from a full tool name.
|
|
98
|
+
* @param toolName - The full tool name
|
|
99
|
+
* @returns The base tool name without server suffix
|
|
100
|
+
*/
|
|
101
|
+
declare function getBaseToolName(toolName: string): string;
|
|
102
|
+
/**
|
|
103
|
+
* Generates a compact listing of deferred tools grouped by server.
|
|
104
|
+
* Format: "server: tool1, tool2, tool3"
|
|
105
|
+
* Non-MCP tools are grouped under "other".
|
|
106
|
+
* @param toolRegistry - The tool registry
|
|
107
|
+
* @param onlyDeferred - Whether to only include deferred tools
|
|
108
|
+
* @returns Formatted string with tools grouped by server
|
|
109
|
+
*/
|
|
110
|
+
declare function getDeferredToolsListing(toolRegistry: t.LCToolRegistry | undefined, onlyDeferred: boolean): string;
|
|
111
|
+
/**
|
|
112
|
+
* Formats a server listing response as structured JSON.
|
|
113
|
+
* NOTE: This is a PREVIEW only - tools are NOT discovered/loaded.
|
|
114
|
+
* @param tools - Array of tool metadata from the server(s)
|
|
115
|
+
* @param serverNames - The MCP server name(s)
|
|
116
|
+
* @returns JSON string showing all tools grouped by server
|
|
117
|
+
*/
|
|
118
|
+
declare function formatServerListing(tools: t.ToolMetadata[], serverNames: string | string[]): string;
|
|
119
|
+
/**
|
|
120
|
+
* Creates a Tool Search tool for discovering tools from a large registry.
|
|
121
|
+
*
|
|
122
|
+
* This tool enables AI agents to dynamically discover tools from a large library
|
|
123
|
+
* without loading all tool definitions into the LLM context window. The agent
|
|
124
|
+
* can search for relevant tools on-demand.
|
|
125
|
+
*
|
|
126
|
+
* **Modes:**
|
|
127
|
+
* - `code_interpreter` (default): Uses external sandbox for regex search. Safer for complex patterns.
|
|
128
|
+
* - `local`: Uses safe substring matching locally. No network call, faster, completely safe from ReDoS.
|
|
129
|
+
*
|
|
130
|
+
* The tool registry can be provided either:
|
|
131
|
+
* 1. At initialization time via params.toolRegistry
|
|
132
|
+
* 2. At runtime via config.configurable.toolRegistry when invoking
|
|
133
|
+
*
|
|
134
|
+
* @param params - Configuration parameters for the tool (toolRegistry is optional)
|
|
135
|
+
* @returns A LangChain DynamicStructuredTool for tool searching
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* // Option 1: Code interpreter mode (regex via sandbox)
|
|
139
|
+
* const tool = createToolSearch({ apiKey, toolRegistry });
|
|
140
|
+
* await tool.invoke({ query: 'expense.*report' });
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* // Option 2: Local mode (safe substring search, no API key needed)
|
|
144
|
+
* const tool = createToolSearch({ mode: 'local', toolRegistry });
|
|
145
|
+
* await tool.invoke({ query: 'expense' });
|
|
146
|
+
*/
|
|
147
|
+
declare function createToolSearch(initParams?: t.ToolSearchParams): DynamicStructuredTool<ReturnType<typeof createToolSearchSchema>>;
|
|
148
|
+
export { createToolSearch, performLocalSearch, extractMcpServerName, isFromMcpServer, isFromAnyMcpServer, normalizeServerFilter, getAvailableMcpServers, getDeferredToolsListing, getBaseToolName, formatServerListing, sanitizeRegex, escapeRegexSpecialChars, isDangerousPattern, countNestedGroups, hasNestedQuantifiers, };
|
|
@@ -27,6 +27,11 @@ export type SystemCallbacks = {
|
|
|
27
27
|
};
|
|
28
28
|
export type BaseGraphState = {
|
|
29
29
|
messages: BaseMessage[];
|
|
30
|
+
/**
|
|
31
|
+
* Structured response when using structured output mode.
|
|
32
|
+
* Contains the validated JSON response conforming to the configured schema.
|
|
33
|
+
*/
|
|
34
|
+
structuredResponse?: Record<string, unknown>;
|
|
30
35
|
};
|
|
31
36
|
export type MultiAgentGraphState = BaseGraphState & {
|
|
32
37
|
agentMessages?: BaseMessage[];
|
|
@@ -234,8 +239,68 @@ export type GraphEdge = {
|
|
|
234
239
|
export type MultiAgentGraphInput = StandardGraphInput & {
|
|
235
240
|
edges: GraphEdge[];
|
|
236
241
|
};
|
|
242
|
+
/**
|
|
243
|
+
* Structured output mode determines how the agent returns structured data.
|
|
244
|
+
* - 'tool': Uses tool calling to return structured output (works with all tool-calling models)
|
|
245
|
+
* - 'provider': Uses provider-native structured output (OpenAI, Anthropic, etc.)
|
|
246
|
+
* - 'auto': Automatically selects the best strategy based on model capabilities
|
|
247
|
+
*/
|
|
248
|
+
export type StructuredOutputMode = 'tool' | 'provider' | 'auto';
|
|
249
|
+
/**
|
|
250
|
+
* Configuration for structured JSON output from agents.
|
|
251
|
+
* When configured, the agent will return a validated JSON response
|
|
252
|
+
* instead of streaming text.
|
|
253
|
+
*/
|
|
254
|
+
export interface StructuredOutputConfig {
|
|
255
|
+
/**
|
|
256
|
+
* JSON Schema defining the output structure.
|
|
257
|
+
* The model will be forced to return data conforming to this schema.
|
|
258
|
+
*/
|
|
259
|
+
schema: Record<string, unknown>;
|
|
260
|
+
/**
|
|
261
|
+
* Name for the structured output format (used in tool mode).
|
|
262
|
+
* @default 'StructuredResponse'
|
|
263
|
+
*/
|
|
264
|
+
name?: string;
|
|
265
|
+
/**
|
|
266
|
+
* Description of what the structured output represents.
|
|
267
|
+
* Helps the model understand the expected format.
|
|
268
|
+
*/
|
|
269
|
+
description?: string;
|
|
270
|
+
/**
|
|
271
|
+
* Output mode strategy.
|
|
272
|
+
* @default 'auto'
|
|
273
|
+
*/
|
|
274
|
+
mode?: StructuredOutputMode;
|
|
275
|
+
/**
|
|
276
|
+
* Enable strict schema validation.
|
|
277
|
+
* When true, the response must exactly match the schema.
|
|
278
|
+
* @default true
|
|
279
|
+
*/
|
|
280
|
+
strict?: boolean;
|
|
281
|
+
/**
|
|
282
|
+
* Error handling configuration.
|
|
283
|
+
* - true: Auto-retry on validation errors (default)
|
|
284
|
+
* - false: Throw error on validation failure
|
|
285
|
+
* - string: Custom error message for retry
|
|
286
|
+
*/
|
|
287
|
+
handleErrors?: boolean | string;
|
|
288
|
+
/**
|
|
289
|
+
* Maximum number of retry attempts on validation failure.
|
|
290
|
+
* @default 2
|
|
291
|
+
*/
|
|
292
|
+
maxRetries?: number;
|
|
293
|
+
/**
|
|
294
|
+
* Include the raw AI message along with structured response.
|
|
295
|
+
* Useful for debugging.
|
|
296
|
+
* @default false
|
|
297
|
+
*/
|
|
298
|
+
includeRaw?: boolean;
|
|
299
|
+
}
|
|
237
300
|
export interface AgentInputs {
|
|
238
301
|
agentId: string;
|
|
302
|
+
/** Human-readable name for the agent (used in handoff context). Defaults to agentId if not provided. */
|
|
303
|
+
name?: string;
|
|
239
304
|
toolEnd?: boolean;
|
|
240
305
|
toolMap?: ToolMap;
|
|
241
306
|
tools?: GraphTools;
|
|
@@ -261,4 +326,10 @@ export interface AgentInputs {
|
|
|
261
326
|
* and can be cached by Bedrock/Anthropic prompt caching.
|
|
262
327
|
*/
|
|
263
328
|
dynamicContext?: string;
|
|
329
|
+
/**
|
|
330
|
+
* Structured output configuration.
|
|
331
|
+
* When set, disables streaming and returns a validated JSON response
|
|
332
|
+
* conforming to the specified schema.
|
|
333
|
+
*/
|
|
334
|
+
structuredOutput?: StructuredOutputConfig;
|
|
264
335
|
}
|
|
@@ -37,7 +37,9 @@ export type AnthropicReasoning = {
|
|
|
37
37
|
thinkingBudget?: number;
|
|
38
38
|
};
|
|
39
39
|
export type OpenAIClientOptions = ChatOpenAIFields;
|
|
40
|
-
export type AnthropicClientOptions = AnthropicInput
|
|
40
|
+
export type AnthropicClientOptions = AnthropicInput & {
|
|
41
|
+
promptCache?: boolean;
|
|
42
|
+
};
|
|
41
43
|
export type MistralAIClientOptions = ChatMistralAIInput;
|
|
42
44
|
export type VertexAIClientOptions = ChatVertexAIInput & {
|
|
43
45
|
includeThoughts?: boolean;
|
|
@@ -29,6 +29,8 @@ export type ToolNodeOptions = {
|
|
|
29
29
|
errorHandler?: (data: ToolErrorData, metadata?: Record<string, unknown>) => Promise<void>;
|
|
30
30
|
/** Tool registry for lazy computation of programmatic tools and tool search */
|
|
31
31
|
toolRegistry?: LCToolRegistry;
|
|
32
|
+
/** Reference to Graph's sessions map for automatic session injection */
|
|
33
|
+
sessions?: ToolSessionMap;
|
|
32
34
|
};
|
|
33
35
|
export type ToolNodeConstructorParams = ToolRefs & ToolNodeOptions;
|
|
34
36
|
export type ToolEndEvent = {
|
|
@@ -55,6 +57,8 @@ export type FileRef = {
|
|
|
55
57
|
id: string;
|
|
56
58
|
name: string;
|
|
57
59
|
path?: string;
|
|
60
|
+
/** Session ID this file belongs to (for multi-session file tracking) */
|
|
61
|
+
session_id?: string;
|
|
58
62
|
};
|
|
59
63
|
export type FileRefs = FileRef[];
|
|
60
64
|
export type ExecuteResult = {
|
|
@@ -99,12 +103,18 @@ export type ProgrammaticCache = {
|
|
|
99
103
|
toolMap: ToolMap;
|
|
100
104
|
toolDefs: LCTool[];
|
|
101
105
|
};
|
|
102
|
-
/**
|
|
103
|
-
export type
|
|
106
|
+
/** Search mode: code_interpreter uses external sandbox, local uses safe substring matching */
|
|
107
|
+
export type ToolSearchMode = 'code_interpreter' | 'local';
|
|
108
|
+
/** Parameters for creating a Tool Search tool */
|
|
109
|
+
export type ToolSearchParams = {
|
|
104
110
|
apiKey?: string;
|
|
105
111
|
toolRegistry?: LCToolRegistry;
|
|
106
112
|
onlyDeferred?: boolean;
|
|
107
113
|
baseUrl?: string;
|
|
114
|
+
/** Search mode: 'code_interpreter' (default) uses sandbox for regex, 'local' uses safe substring matching */
|
|
115
|
+
mode?: ToolSearchMode;
|
|
116
|
+
/** Filter tools to only those from specific MCP server(s). Can be a single name or array of names. */
|
|
117
|
+
mcpServer?: string | string[];
|
|
108
118
|
[key: string]: unknown;
|
|
109
119
|
};
|
|
110
120
|
/** Simplified tool metadata for search purposes */
|
|
@@ -199,3 +209,33 @@ export type ProgrammaticToolCallingParams = {
|
|
|
199
209
|
/** Environment variable key for API key */
|
|
200
210
|
[key: string]: unknown;
|
|
201
211
|
};
|
|
212
|
+
/**
|
|
213
|
+
* Tracks code execution session state for automatic file persistence.
|
|
214
|
+
* Stored in Graph.sessions and injected into subsequent tool invocations.
|
|
215
|
+
*/
|
|
216
|
+
export type CodeSessionContext = {
|
|
217
|
+
/** Session ID from the code execution environment */
|
|
218
|
+
session_id: string;
|
|
219
|
+
/** Files generated in this session (for context/tracking) */
|
|
220
|
+
files: FileRefs;
|
|
221
|
+
/** Timestamp of last update */
|
|
222
|
+
lastUpdated: number;
|
|
223
|
+
};
|
|
224
|
+
/**
|
|
225
|
+
* Artifact structure returned by code execution tools (CodeExecutor, PTC).
|
|
226
|
+
* Used to extract session context after tool completion.
|
|
227
|
+
*/
|
|
228
|
+
export type CodeExecutionArtifact = {
|
|
229
|
+
session_id?: string;
|
|
230
|
+
files?: FileRefs;
|
|
231
|
+
};
|
|
232
|
+
/**
|
|
233
|
+
* Generic session context union type for different tool types.
|
|
234
|
+
* Extend this as new tool session types are added.
|
|
235
|
+
*/
|
|
236
|
+
export type ToolSessionContext = CodeSessionContext;
|
|
237
|
+
/**
|
|
238
|
+
* Map of tool names to their session contexts.
|
|
239
|
+
* Keys are tool constants (e.g., Constants.EXECUTE_CODE, Constants.PROGRAMMATIC_TOOL_CALLING).
|
|
240
|
+
*/
|
|
241
|
+
export type ToolSessionMap = Map<string, ToolSessionContext>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "illuma-agents",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.39",
|
|
4
4
|
"main": "./dist/cjs/main.cjs",
|
|
5
5
|
"module": "./dist/esm/main.mjs",
|
|
6
6
|
"types": "./dist/types/index.d.ts",
|
|
@@ -44,14 +44,17 @@
|
|
|
44
44
|
"code_exec": "node -r dotenv/config --loader ./tsconfig-paths-bootstrap.mjs --experimental-specifier-resolution=node ./src/scripts/code_exec.ts --provider 'openAI' --name 'Jo' --location 'New York, NY'",
|
|
45
45
|
"image": "node -r dotenv/config --loader ./tsconfig-paths-bootstrap.mjs --experimental-specifier-resolution=node ./src/scripts/image.ts --provider 'google' --name 'Jo' --location 'New York, NY'",
|
|
46
46
|
"code_exec_files": "node -r dotenv/config --loader ./tsconfig-paths-bootstrap.mjs --experimental-specifier-resolution=node ./src/scripts/code_exec_files.ts --provider 'openAI' --name 'Jo' --location 'New York, NY'",
|
|
47
|
-
"
|
|
48
|
-
"
|
|
47
|
+
"code_exec_session": "node -r dotenv/config --loader ./tsconfig-paths-bootstrap.mjs --experimental-specifier-resolution=node ./src/scripts/code_exec_session.ts --provider 'openAI' --name 'Jo' --location 'New York, NY'",
|
|
48
|
+
"code_exec_multi_session": "node -r dotenv/config --loader ./tsconfig-paths-bootstrap.mjs --experimental-specifier-resolution=node ./src/scripts/code_exec_multi_session.ts --provider 'openAI' --name 'Jo' --location 'New York, NY'",
|
|
49
|
+
"code_exec_simple": "node -r dotenv/config --loader ./tsconfig-paths-bootstrap.mjs --experimental-specifier-resolution=node ./src/scripts/code_exec_simple.ts --provider 'openAI' --name 'Jo' --location 'New York, NY'",
|
|
50
|
+
"simple": "node -r dotenv/config --loader ./tsconfig-paths-bootstrap.mjs --experimental-specifier-resolution=node ./src/scripts/simple.ts --provider 'bedrock' --name 'Jo' --location 'New York, NY'",
|
|
49
51
|
"caching": "node -r dotenv/config --loader ./tsconfig-paths-bootstrap.mjs --experimental-specifier-resolution=node ./src/scripts/caching.ts --name 'Jo' --location 'New York, NY'",
|
|
50
52
|
"thinking": "node -r dotenv/config --loader ./tsconfig-paths-bootstrap.mjs --experimental-specifier-resolution=node ./src/scripts/thinking.ts --name 'Jo' --location 'New York, NY'",
|
|
53
|
+
"thinking:bedrock": "node -r dotenv/config --loader ./tsconfig-paths-bootstrap.mjs --experimental-specifier-resolution=node ./src/scripts/thinking-bedrock.ts --name 'Jo' --location 'New York, NY'",
|
|
51
54
|
"memory": "node -r dotenv/config --loader ./tsconfig-paths-bootstrap.mjs --experimental-specifier-resolution=node ./src/scripts/memory.ts --provider 'openAI' --name 'Jo' --location 'New York, NY'",
|
|
52
|
-
"tool": "node --trace-warnings -r dotenv/config --loader ./tsconfig-paths-bootstrap.mjs --experimental-specifier-resolution=node ./src/scripts/tools.ts --provider '
|
|
55
|
+
"tool": "node --trace-warnings -r dotenv/config --loader ./tsconfig-paths-bootstrap.mjs --experimental-specifier-resolution=node ./src/scripts/tools.ts --provider 'bedrock' --name 'Jo' --location 'New York, NY'",
|
|
53
56
|
"search": "node -r dotenv/config --loader ./tsconfig-paths-bootstrap.mjs --experimental-specifier-resolution=node ./src/scripts/search.ts --provider 'bedrock' --name 'Jo' --location 'New York, NY'",
|
|
54
|
-
"
|
|
57
|
+
"tool_search": "node -r dotenv/config --loader ./tsconfig-paths-bootstrap.mjs --experimental-specifier-resolution=node ./src/scripts/tool_search.ts",
|
|
55
58
|
"programmatic_exec": "node -r dotenv/config --loader ./tsconfig-paths-bootstrap.mjs --experimental-specifier-resolution=node ./src/scripts/programmatic_exec.ts",
|
|
56
59
|
"code_exec_ptc": "node -r dotenv/config --loader ./tsconfig-paths-bootstrap.mjs --experimental-specifier-resolution=node ./src/scripts/code_exec_ptc.ts --provider 'openAI' --name 'Jo' --location 'New York, NY'",
|
|
57
60
|
"programmatic_exec_agent": "node -r dotenv/config --loader ./tsconfig-paths-bootstrap.mjs --experimental-specifier-resolution=node ./src/scripts/programmatic_exec_agent.ts --provider 'openAI' --name 'Jo' --location 'New York, NY'",
|
|
@@ -69,6 +72,7 @@
|
|
|
69
72
|
"multi-agent-sequence": "node -r dotenv/config --loader ./tsconfig-paths-bootstrap.mjs --experimental-specifier-resolution=node ./src/scripts/multi-agent-sequence.ts",
|
|
70
73
|
"multi-agent-conditional": "node -r dotenv/config --loader ./tsconfig-paths-bootstrap.mjs --experimental-specifier-resolution=node ./src/scripts/multi-agent-conditional.ts",
|
|
71
74
|
"multi-agent-supervisor": "node -r dotenv/config --loader ./tsconfig-paths-bootstrap.mjs --experimental-specifier-resolution=node ./src/scripts/multi-agent-supervisor.ts",
|
|
75
|
+
"test-handoff-preamble": "node -r dotenv/config --loader ./tsconfig-paths-bootstrap.mjs --experimental-specifier-resolution=node ./src/scripts/test-handoff-preamble.ts",
|
|
72
76
|
"multi-agent-list-handoff": "node -r dotenv/config --loader ./tsconfig-paths-bootstrap.mjs --experimental-specifier-resolution=node ./src/scripts/test-multi-agent-list-handoff.ts",
|
|
73
77
|
"test-parallel-agent-labeling": "node -r dotenv/config --loader ./tsconfig-paths-bootstrap.mjs --experimental-specifier-resolution=node ./src/scripts/test-parallel-agent-labeling.ts",
|
|
74
78
|
"test-thinking-handoff": "node -r dotenv/config --loader ./tsconfig-paths-bootstrap.mjs --experimental-specifier-resolution=node ./src/scripts/test-thinking-handoff.ts",
|
|
@@ -87,7 +91,7 @@
|
|
|
87
91
|
"start:collab5": "node --loader ./tsconfig-paths-bootstrap.mjs --experimental-specifier-resolution=node ./src/scripts/collab_design_v5.ts",
|
|
88
92
|
"start:dev": "node --loader ./tsconfig-paths-bootstrap.mjs --experimental-specifier-resolution=node ./src/main.ts",
|
|
89
93
|
"supervised": "node -r dotenv/config --loader ./tsconfig-paths-bootstrap.mjs --experimental-specifier-resolution=node ./src/scripts/supervised.ts --provider anthropic --name Jo --location \"New York, NY\"",
|
|
90
|
-
"test": "jest",
|
|
94
|
+
"test": "NODE_OPTIONS='--experimental-vm-modules' jest",
|
|
91
95
|
"test:memory": "NODE_OPTIONS='--expose-gc' npx jest src/specs/title.memory-leak.test.ts",
|
|
92
96
|
"test:all": "npm test -- --testPathIgnorePatterns=title.memory-leak.test.ts && npm run test:memory",
|
|
93
97
|
"reinstall": "npm run clean && npm ci && rm -rf ./dist && npm run build",
|
|
@@ -102,6 +106,7 @@
|
|
|
102
106
|
}
|
|
103
107
|
},
|
|
104
108
|
"dependencies": {
|
|
109
|
+
"@aws-sdk/client-bedrock-runtime": "^3.970.0",
|
|
105
110
|
"@langchain/anthropic": "^0.3.26",
|
|
106
111
|
"@langchain/aws": "^0.1.15",
|
|
107
112
|
"@langchain/core": "^0.3.80",
|
|
@@ -124,6 +129,7 @@
|
|
|
124
129
|
"https-proxy-agent": "^7.0.6",
|
|
125
130
|
"mathjs": "^15.1.0",
|
|
126
131
|
"nanoid": "^3.3.7",
|
|
132
|
+
"okapibm25": "^1.4.1",
|
|
127
133
|
"openai": "5.8.2"
|
|
128
134
|
},
|
|
129
135
|
"imports": {
|
|
@@ -151,6 +157,7 @@
|
|
|
151
157
|
"eslint-plugin-import": "^2.31.0",
|
|
152
158
|
"husky": "^9.1.7",
|
|
153
159
|
"jest": "^30.2.0",
|
|
160
|
+
"jest-util": "^30.2.0",
|
|
154
161
|
"lint-staged": "^15.2.7",
|
|
155
162
|
"prettier": "^3.6.2",
|
|
156
163
|
"rollup": "^4.34.6",
|