illuma-agents 1.0.9 → 1.0.11
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/LICENSE +1 -1
- package/dist/cjs/agents/AgentContext.cjs +228 -27
- package/dist/cjs/agents/AgentContext.cjs.map +1 -1
- package/dist/cjs/common/enum.cjs +2 -0
- package/dist/cjs/common/enum.cjs.map +1 -1
- package/dist/cjs/events.cjs +3 -0
- package/dist/cjs/events.cjs.map +1 -1
- package/dist/cjs/graphs/Graph.cjs +29 -19
- package/dist/cjs/graphs/Graph.cjs.map +1 -1
- package/dist/cjs/instrumentation.cjs +1 -1
- package/dist/cjs/instrumentation.cjs.map +1 -1
- package/dist/cjs/llm/anthropic/index.cjs +1 -1
- package/dist/cjs/llm/anthropic/index.cjs.map +1 -1
- package/dist/cjs/llm/bedrock/index.cjs +122 -7
- package/dist/cjs/llm/bedrock/index.cjs.map +1 -1
- package/dist/cjs/llm/google/index.cjs +1 -1
- package/dist/cjs/llm/google/index.cjs.map +1 -1
- package/dist/cjs/llm/openai/index.cjs +108 -6
- package/dist/cjs/llm/openai/index.cjs.map +1 -1
- package/dist/cjs/llm/openai/utils/index.cjs +87 -1
- package/dist/cjs/llm/openai/utils/index.cjs.map +1 -1
- package/dist/cjs/llm/openrouter/index.cjs +176 -2
- package/dist/cjs/llm/openrouter/index.cjs.map +1 -1
- package/dist/cjs/main.cjs +18 -0
- package/dist/cjs/main.cjs.map +1 -1
- package/dist/cjs/messages/cache.cjs +149 -54
- package/dist/cjs/messages/cache.cjs.map +1 -1
- package/dist/cjs/messages/tools.cjs +85 -0
- package/dist/cjs/messages/tools.cjs.map +1 -0
- package/dist/cjs/stream.cjs +20 -0
- package/dist/cjs/stream.cjs.map +1 -1
- package/dist/cjs/tools/CodeExecutor.cjs +4 -0
- package/dist/cjs/tools/CodeExecutor.cjs.map +1 -1
- package/dist/cjs/tools/ProgrammaticToolCalling.cjs +438 -0
- package/dist/cjs/tools/ProgrammaticToolCalling.cjs.map +1 -0
- package/dist/cjs/tools/ToolNode.cjs +54 -6
- package/dist/cjs/tools/ToolNode.cjs.map +1 -1
- package/dist/cjs/tools/ToolSearchRegex.cjs +455 -0
- package/dist/cjs/tools/ToolSearchRegex.cjs.map +1 -0
- package/dist/cjs/tools/search/tool.cjs +21 -1
- package/dist/cjs/tools/search/tool.cjs.map +1 -1
- package/dist/cjs/utils/run.cjs +5 -1
- package/dist/cjs/utils/run.cjs.map +1 -1
- package/dist/esm/agents/AgentContext.mjs +228 -27
- package/dist/esm/agents/AgentContext.mjs.map +1 -1
- package/dist/esm/common/enum.mjs +2 -0
- package/dist/esm/common/enum.mjs.map +1 -1
- package/dist/esm/events.mjs +4 -1
- package/dist/esm/events.mjs.map +1 -1
- package/dist/esm/graphs/Graph.mjs +29 -19
- package/dist/esm/graphs/Graph.mjs.map +1 -1
- package/dist/esm/instrumentation.mjs +1 -1
- package/dist/esm/instrumentation.mjs.map +1 -1
- package/dist/esm/llm/anthropic/index.mjs +1 -1
- package/dist/esm/llm/anthropic/index.mjs.map +1 -1
- package/dist/esm/llm/bedrock/index.mjs +122 -7
- package/dist/esm/llm/bedrock/index.mjs.map +1 -1
- package/dist/esm/llm/google/index.mjs +1 -1
- package/dist/esm/llm/google/index.mjs.map +1 -1
- package/dist/esm/llm/openai/index.mjs +109 -7
- package/dist/esm/llm/openai/index.mjs.map +1 -1
- package/dist/esm/llm/openai/utils/index.mjs +88 -2
- package/dist/esm/llm/openai/utils/index.mjs.map +1 -1
- package/dist/esm/llm/openrouter/index.mjs +176 -2
- package/dist/esm/llm/openrouter/index.mjs.map +1 -1
- package/dist/esm/main.mjs +3 -0
- package/dist/esm/main.mjs.map +1 -1
- package/dist/esm/messages/cache.mjs +149 -54
- package/dist/esm/messages/cache.mjs.map +1 -1
- package/dist/esm/messages/tools.mjs +82 -0
- package/dist/esm/messages/tools.mjs.map +1 -0
- package/dist/esm/stream.mjs +20 -0
- package/dist/esm/stream.mjs.map +1 -1
- package/dist/esm/tools/CodeExecutor.mjs +4 -0
- package/dist/esm/tools/CodeExecutor.mjs.map +1 -1
- package/dist/esm/tools/ProgrammaticToolCalling.mjs +430 -0
- package/dist/esm/tools/ProgrammaticToolCalling.mjs.map +1 -0
- package/dist/esm/tools/ToolNode.mjs +54 -6
- package/dist/esm/tools/ToolNode.mjs.map +1 -1
- package/dist/esm/tools/ToolSearchRegex.mjs +448 -0
- package/dist/esm/tools/ToolSearchRegex.mjs.map +1 -0
- package/dist/esm/tools/search/tool.mjs +21 -1
- package/dist/esm/tools/search/tool.mjs.map +1 -1
- package/dist/esm/utils/run.mjs +5 -1
- package/dist/esm/utils/run.mjs.map +1 -1
- package/dist/types/agents/AgentContext.d.ts +65 -5
- package/dist/types/common/enum.d.ts +2 -0
- package/dist/types/graphs/Graph.d.ts +3 -2
- package/dist/types/index.d.ts +2 -0
- package/dist/types/llm/anthropic/index.d.ts +1 -1
- package/dist/types/llm/bedrock/index.d.ts +31 -4
- package/dist/types/llm/google/index.d.ts +1 -1
- package/dist/types/llm/openai/index.d.ts +4 -3
- package/dist/types/llm/openai/utils/index.d.ts +10 -1
- package/dist/types/llm/openrouter/index.d.ts +5 -2
- package/dist/types/messages/cache.d.ts +23 -8
- package/dist/types/messages/index.d.ts +1 -0
- package/dist/types/messages/tools.d.ts +17 -0
- package/dist/types/test/mockTools.d.ts +28 -0
- package/dist/types/tools/ProgrammaticToolCalling.d.ts +91 -0
- package/dist/types/tools/ToolNode.d.ts +10 -2
- package/dist/types/tools/ToolSearchRegex.d.ts +80 -0
- package/dist/types/types/graph.d.ts +7 -1
- package/dist/types/types/tools.d.ts +138 -0
- package/package.json +8 -3
- package/src/agents/AgentContext.ts +267 -27
- package/src/agents/__tests__/AgentContext.test.ts +805 -0
- package/src/common/enum.ts +2 -0
- package/src/events.ts +5 -1
- package/src/graphs/Graph.ts +35 -20
- package/src/index.ts +2 -0
- package/src/instrumentation.ts +1 -1
- package/src/llm/anthropic/index.ts +2 -2
- package/src/llm/bedrock/__tests__/bedrock-caching.test.ts +473 -0
- package/src/llm/bedrock/index.ts +150 -13
- package/src/llm/google/index.ts +2 -2
- package/src/llm/google/llm.spec.ts +3 -1
- package/src/llm/openai/index.ts +135 -9
- package/src/llm/openai/utils/index.ts +116 -1
- package/src/llm/openrouter/index.ts +224 -3
- package/src/messages/__tests__/tools.test.ts +473 -0
- package/src/messages/cache.ts +163 -61
- package/src/messages/index.ts +1 -0
- package/src/messages/tools.ts +99 -0
- package/src/scripts/code_exec_ptc.ts +334 -0
- package/src/scripts/programmatic_exec.ts +396 -0
- package/src/scripts/programmatic_exec_agent.ts +231 -0
- package/src/scripts/tool_search_regex.ts +162 -0
- package/src/specs/thinking-prune.test.ts +52 -118
- package/src/stream.ts +26 -0
- package/src/test/mockTools.ts +366 -0
- package/src/tools/CodeExecutor.ts +4 -0
- package/src/tools/ProgrammaticToolCalling.ts +558 -0
- package/src/tools/ToolNode.ts +60 -7
- package/src/tools/ToolSearchRegex.ts +535 -0
- package/src/tools/__tests__/ProgrammaticToolCalling.integration.test.ts +318 -0
- package/src/tools/__tests__/ProgrammaticToolCalling.test.ts +853 -0
- package/src/tools/__tests__/ToolSearchRegex.integration.test.ts +161 -0
- package/src/tools/__tests__/ToolSearchRegex.test.ts +232 -0
- package/src/tools/search/jina-reranker.test.ts +16 -16
- package/src/tools/search/tool.ts +23 -1
- package/src/types/graph.ts +7 -1
- package/src/types/tools.ts +166 -0
- package/src/utils/llmConfig.ts +8 -2
- package/src/utils/run.ts +5 -1
- package/src/tools/search/direct-url.test.ts +0 -530
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { DynamicStructuredTool } from '@langchain/core/tools';
|
|
3
|
+
import type * as t from '@/types';
|
|
4
|
+
declare const ProgrammaticToolCallingSchema: z.ZodObject<{
|
|
5
|
+
code: z.ZodString;
|
|
6
|
+
session_id: z.ZodOptional<z.ZodString>;
|
|
7
|
+
timeout: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
code: string;
|
|
10
|
+
timeout: number;
|
|
11
|
+
session_id?: string | undefined;
|
|
12
|
+
}, {
|
|
13
|
+
code: string;
|
|
14
|
+
timeout?: number | undefined;
|
|
15
|
+
session_id?: string | undefined;
|
|
16
|
+
}>;
|
|
17
|
+
/**
|
|
18
|
+
* Normalizes a tool name to Python identifier format.
|
|
19
|
+
* Must match the Code API's `normalizePythonFunctionName` exactly:
|
|
20
|
+
* 1. Replace hyphens and spaces with underscores
|
|
21
|
+
* 2. Remove any other invalid characters
|
|
22
|
+
* 3. Prefix with underscore if starts with number
|
|
23
|
+
* 4. Append `_tool` if it's a Python keyword
|
|
24
|
+
* @param name - The tool name to normalize
|
|
25
|
+
* @returns Normalized Python-safe identifier
|
|
26
|
+
*/
|
|
27
|
+
export declare function normalizeToPythonIdentifier(name: string): string;
|
|
28
|
+
/**
|
|
29
|
+
* Extracts tool names that are actually called in the Python code.
|
|
30
|
+
* Handles hyphen/underscore conversion since Python identifiers use underscores.
|
|
31
|
+
* @param code - The Python code to analyze
|
|
32
|
+
* @param toolNameMap - Map from normalized Python name to original tool name
|
|
33
|
+
* @returns Set of original tool names found in the code
|
|
34
|
+
*/
|
|
35
|
+
export declare function extractUsedToolNames(code: string, toolNameMap: Map<string, string>): Set<string>;
|
|
36
|
+
/**
|
|
37
|
+
* Filters tool definitions to only include tools actually used in the code.
|
|
38
|
+
* Handles the hyphen-to-underscore conversion for Python compatibility.
|
|
39
|
+
* @param toolDefs - All available tool definitions
|
|
40
|
+
* @param code - The Python code to analyze
|
|
41
|
+
* @param debug - Enable debug logging
|
|
42
|
+
* @returns Filtered array of tool definitions
|
|
43
|
+
*/
|
|
44
|
+
export declare function filterToolsByUsage(toolDefs: t.LCTool[], code: string, debug?: boolean): t.LCTool[];
|
|
45
|
+
/**
|
|
46
|
+
* Makes an HTTP request to the Code API.
|
|
47
|
+
* @param endpoint - The API endpoint URL
|
|
48
|
+
* @param apiKey - The API key for authentication
|
|
49
|
+
* @param body - The request body
|
|
50
|
+
* @param proxy - Optional HTTP proxy URL
|
|
51
|
+
* @returns The parsed API response
|
|
52
|
+
*/
|
|
53
|
+
export declare function makeRequest(endpoint: string, apiKey: string, body: Record<string, unknown>, proxy?: string): Promise<t.ProgrammaticExecutionResponse>;
|
|
54
|
+
/**
|
|
55
|
+
* Executes tools in parallel when requested by the API.
|
|
56
|
+
* Uses Promise.all for parallel execution, catching individual errors.
|
|
57
|
+
* @param toolCalls - Array of tool calls from the API
|
|
58
|
+
* @param toolMap - Map of tool names to executable tools
|
|
59
|
+
* @returns Array of tool results
|
|
60
|
+
*/
|
|
61
|
+
export declare function executeTools(toolCalls: t.PTCToolCall[], toolMap: t.ToolMap): Promise<t.PTCToolResult[]>;
|
|
62
|
+
/**
|
|
63
|
+
* Formats the completed response for the agent.
|
|
64
|
+
* @param response - The completed API response
|
|
65
|
+
* @returns Tuple of [formatted string, artifact]
|
|
66
|
+
*/
|
|
67
|
+
export declare function formatCompletedResponse(response: t.ProgrammaticExecutionResponse): [string, t.ProgrammaticExecutionArtifact];
|
|
68
|
+
/**
|
|
69
|
+
* Creates a Programmatic Tool Calling tool for complex multi-tool workflows.
|
|
70
|
+
*
|
|
71
|
+
* This tool enables AI agents to write Python code that orchestrates multiple
|
|
72
|
+
* tool calls programmatically, reducing LLM round-trips and token usage.
|
|
73
|
+
*
|
|
74
|
+
* The tool map must be provided at runtime via config.configurable.toolMap.
|
|
75
|
+
*
|
|
76
|
+
* @param params - Configuration parameters (apiKey, baseUrl, maxRoundTrips, proxy)
|
|
77
|
+
* @returns A LangChain DynamicStructuredTool for programmatic tool calling
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* const ptcTool = createProgrammaticToolCallingTool({
|
|
81
|
+
* apiKey: process.env.CODE_API_KEY,
|
|
82
|
+
* maxRoundTrips: 20
|
|
83
|
+
* });
|
|
84
|
+
*
|
|
85
|
+
* const [output, artifact] = await ptcTool.invoke(
|
|
86
|
+
* { code, tools },
|
|
87
|
+
* { configurable: { toolMap } }
|
|
88
|
+
* );
|
|
89
|
+
*/
|
|
90
|
+
export declare function createProgrammaticToolCallingTool(initParams?: t.ProgrammaticToolCallingParams): DynamicStructuredTool<typeof ProgrammaticToolCallingSchema>;
|
|
91
|
+
export {};
|
|
@@ -5,7 +5,6 @@ import type { BaseMessage } from '@langchain/core/messages';
|
|
|
5
5
|
import type * as t from '@/types';
|
|
6
6
|
import { RunnableCallable } from '@/utils';
|
|
7
7
|
export declare class ToolNode<T = any> extends RunnableCallable<T, T> {
|
|
8
|
-
tools: t.GenericTool[];
|
|
9
8
|
private toolMap;
|
|
10
9
|
private loadRuntimeTools?;
|
|
11
10
|
handleToolErrors: boolean;
|
|
@@ -13,7 +12,16 @@ export declare class ToolNode<T = any> extends RunnableCallable<T, T> {
|
|
|
13
12
|
toolCallStepIds?: Map<string, string>;
|
|
14
13
|
errorHandler?: t.ToolNodeConstructorParams['errorHandler'];
|
|
15
14
|
private toolUsageCount;
|
|
16
|
-
|
|
15
|
+
/** Tool registry for filtering (lazy computation of programmatic maps) */
|
|
16
|
+
private toolRegistry?;
|
|
17
|
+
/** Cached programmatic tools (computed once on first PTC call) */
|
|
18
|
+
private programmaticCache?;
|
|
19
|
+
constructor({ tools, toolMap, name, tags, errorHandler, toolCallStepIds, handleToolErrors, loadRuntimeTools, toolRegistry, }: t.ToolNodeConstructorParams);
|
|
20
|
+
/**
|
|
21
|
+
* Returns cached programmatic tools, computing once on first access.
|
|
22
|
+
* Single iteration builds both toolMap and toolDefs simultaneously.
|
|
23
|
+
*/
|
|
24
|
+
private getProgrammaticTools;
|
|
17
25
|
/**
|
|
18
26
|
* Returns a snapshot of the current tool usage counts.
|
|
19
27
|
* @returns A ReadonlyMap where keys are tool names and values are their usage counts.
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { DynamicStructuredTool } from '@langchain/core/tools';
|
|
3
|
+
import type * as t from '@/types';
|
|
4
|
+
declare const ToolSearchRegexSchema: z.ZodObject<{
|
|
5
|
+
query: z.ZodString;
|
|
6
|
+
fields: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodEnum<["name", "description", "parameters"]>, "many">>>;
|
|
7
|
+
max_results: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
query: string;
|
|
10
|
+
fields: ("name" | "description" | "parameters")[];
|
|
11
|
+
max_results: number;
|
|
12
|
+
}, {
|
|
13
|
+
query: string;
|
|
14
|
+
fields?: ("name" | "description" | "parameters")[] | undefined;
|
|
15
|
+
max_results?: number | undefined;
|
|
16
|
+
}>;
|
|
17
|
+
/**
|
|
18
|
+
* Escapes special regex characters in a string to use as a literal pattern.
|
|
19
|
+
* @param pattern - The string to escape
|
|
20
|
+
* @returns The escaped string safe for use in a RegExp
|
|
21
|
+
*/
|
|
22
|
+
declare function escapeRegexSpecialChars(pattern: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* Counts the maximum nesting depth of groups in a regex pattern.
|
|
25
|
+
* @param pattern - The regex pattern to analyze
|
|
26
|
+
* @returns The maximum nesting depth
|
|
27
|
+
*/
|
|
28
|
+
declare function countNestedGroups(pattern: string): number;
|
|
29
|
+
/**
|
|
30
|
+
* Detects nested quantifiers that can cause catastrophic backtracking.
|
|
31
|
+
* Patterns like (a+)+, (a*)*, (a+)*, etc.
|
|
32
|
+
* @param pattern - The regex pattern to check
|
|
33
|
+
* @returns True if nested quantifiers are detected
|
|
34
|
+
*/
|
|
35
|
+
declare function hasNestedQuantifiers(pattern: string): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Checks if a regex pattern contains potentially dangerous constructs.
|
|
38
|
+
* @param pattern - The regex pattern to validate
|
|
39
|
+
* @returns True if the pattern is dangerous
|
|
40
|
+
*/
|
|
41
|
+
declare function isDangerousPattern(pattern: string): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Sanitizes a regex pattern for safe execution.
|
|
44
|
+
* If the pattern is dangerous, it will be escaped to a literal string search.
|
|
45
|
+
* @param pattern - The regex pattern to sanitize
|
|
46
|
+
* @returns Object containing the safe pattern and whether it was escaped
|
|
47
|
+
*/
|
|
48
|
+
declare function sanitizeRegex(pattern: string): {
|
|
49
|
+
safe: string;
|
|
50
|
+
wasEscaped: boolean;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Creates a Tool Search Regex tool for discovering tools from a large registry.
|
|
54
|
+
*
|
|
55
|
+
* This tool enables AI agents to dynamically discover tools from a large library
|
|
56
|
+
* without loading all tool definitions into the LLM context window. The agent
|
|
57
|
+
* can search for relevant tools on-demand using regex patterns.
|
|
58
|
+
*
|
|
59
|
+
* The tool registry can be provided either:
|
|
60
|
+
* 1. At initialization time via params.toolRegistry
|
|
61
|
+
* 2. At runtime via config.configurable.toolRegistry when invoking
|
|
62
|
+
*
|
|
63
|
+
* @param params - Configuration parameters for the tool (toolRegistry is optional)
|
|
64
|
+
* @returns A LangChain DynamicStructuredTool for tool searching
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* // Option 1: Registry at initialization
|
|
68
|
+
* const tool = createToolSearchRegexTool({ apiKey, toolRegistry });
|
|
69
|
+
* await tool.invoke({ query: 'expense' });
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* // Option 2: Registry at runtime
|
|
73
|
+
* const tool = createToolSearchRegexTool({ apiKey });
|
|
74
|
+
* await tool.invoke(
|
|
75
|
+
* { query: 'expense' },
|
|
76
|
+
* { configurable: { toolRegistry, onlyDeferred: true } }
|
|
77
|
+
* );
|
|
78
|
+
*/
|
|
79
|
+
declare function createToolSearchRegexTool(initParams?: t.ToolSearchRegexParams): DynamicStructuredTool<typeof ToolSearchRegexSchema>;
|
|
80
|
+
export { createToolSearchRegexTool, sanitizeRegex, escapeRegexSpecialChars, isDangerousPattern, countNestedGroups, hasNestedQuantifiers, };
|
|
@@ -4,7 +4,7 @@ import type { BaseMessage, AIMessageChunk, SystemMessage } from '@langchain/core
|
|
|
4
4
|
import type { RunnableConfig, Runnable } from '@langchain/core/runnables';
|
|
5
5
|
import type { ChatGenerationChunk } from '@langchain/core/outputs';
|
|
6
6
|
import type { GoogleAIToolType } from '@langchain/google-common';
|
|
7
|
-
import type { ToolMap, ToolEndEvent, GenericTool } from '@/types/tools';
|
|
7
|
+
import type { ToolMap, ToolEndEvent, GenericTool, LCTool } from '@/types/tools';
|
|
8
8
|
import type { Providers, Callback, GraphNodeKeys } from '@/common';
|
|
9
9
|
import type { StandardGraph, MultiAgentGraph } from '@/graphs';
|
|
10
10
|
import type { ClientOptions } from '@/types/llm';
|
|
@@ -248,4 +248,10 @@ export interface AgentInputs {
|
|
|
248
248
|
reasoningKey?: 'reasoning_content' | 'reasoning';
|
|
249
249
|
/** Format content blocks as strings (for legacy compatibility i.e. Ollama/Azure Serverless) */
|
|
250
250
|
useLegacyContent?: boolean;
|
|
251
|
+
/**
|
|
252
|
+
* Tool definitions for all tools, including deferred and programmatic.
|
|
253
|
+
* Used for tool search and programmatic tool calling.
|
|
254
|
+
* Maps tool name to LCTool definition.
|
|
255
|
+
*/
|
|
256
|
+
toolRegistry?: Map<string, LCTool>;
|
|
251
257
|
}
|
|
@@ -25,6 +25,8 @@ export type ToolNodeOptions = {
|
|
|
25
25
|
loadRuntimeTools?: ToolRefGenerator;
|
|
26
26
|
toolCallStepIds?: Map<string, string>;
|
|
27
27
|
errorHandler?: (data: ToolErrorData, metadata?: Record<string, unknown>) => Promise<void>;
|
|
28
|
+
/** Tool registry for lazy computation of programmatic tools and tool search */
|
|
29
|
+
toolRegistry?: LCToolRegistry;
|
|
28
30
|
};
|
|
29
31
|
export type ToolNodeConstructorParams = ToolRefs & ToolNodeOptions;
|
|
30
32
|
export type ToolEndEvent = {
|
|
@@ -59,3 +61,139 @@ export type ExecuteResult = {
|
|
|
59
61
|
stderr: string;
|
|
60
62
|
files?: FileRefs;
|
|
61
63
|
};
|
|
64
|
+
/** JSON Schema type definition for tool parameters */
|
|
65
|
+
export type JsonSchemaType = {
|
|
66
|
+
type: 'string' | 'number' | 'integer' | 'float' | 'boolean' | 'array' | 'object';
|
|
67
|
+
enum?: string[];
|
|
68
|
+
items?: JsonSchemaType;
|
|
69
|
+
properties?: Record<string, JsonSchemaType>;
|
|
70
|
+
required?: string[];
|
|
71
|
+
description?: string;
|
|
72
|
+
additionalProperties?: boolean | JsonSchemaType;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Specifies which contexts can invoke a tool (inspired by Anthropic's allowed_callers)
|
|
76
|
+
* - 'direct': Only callable directly by the LLM (default if omitted)
|
|
77
|
+
* - 'code_execution': Only callable from within programmatic code execution
|
|
78
|
+
*/
|
|
79
|
+
export type AllowedCaller = 'direct' | 'code_execution';
|
|
80
|
+
/** Tool definition with optional deferred loading and caller restrictions */
|
|
81
|
+
export type LCTool = {
|
|
82
|
+
name: string;
|
|
83
|
+
description?: string;
|
|
84
|
+
parameters?: JsonSchemaType;
|
|
85
|
+
/** When true, tool is not loaded into context initially (for tool search) */
|
|
86
|
+
defer_loading?: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Which contexts can invoke this tool.
|
|
89
|
+
* Default: ['direct'] (only callable directly by LLM)
|
|
90
|
+
* Options: 'direct', 'code_execution'
|
|
91
|
+
*/
|
|
92
|
+
allowed_callers?: AllowedCaller[];
|
|
93
|
+
};
|
|
94
|
+
/** Map of tool names to tool definitions */
|
|
95
|
+
export type LCToolRegistry = Map<string, LCTool>;
|
|
96
|
+
export type ProgrammaticCache = {
|
|
97
|
+
toolMap: ToolMap;
|
|
98
|
+
toolDefs: LCTool[];
|
|
99
|
+
};
|
|
100
|
+
/** Parameters for creating a Tool Search Regex tool */
|
|
101
|
+
export type ToolSearchRegexParams = {
|
|
102
|
+
apiKey?: string;
|
|
103
|
+
toolRegistry?: LCToolRegistry;
|
|
104
|
+
onlyDeferred?: boolean;
|
|
105
|
+
baseUrl?: string;
|
|
106
|
+
[key: string]: unknown;
|
|
107
|
+
};
|
|
108
|
+
/** Simplified tool metadata for search purposes */
|
|
109
|
+
export type ToolMetadata = {
|
|
110
|
+
name: string;
|
|
111
|
+
description: string;
|
|
112
|
+
parameters?: JsonSchemaType;
|
|
113
|
+
};
|
|
114
|
+
/** Individual search result for a matching tool */
|
|
115
|
+
export type ToolSearchResult = {
|
|
116
|
+
tool_name: string;
|
|
117
|
+
match_score: number;
|
|
118
|
+
matched_field: string;
|
|
119
|
+
snippet: string;
|
|
120
|
+
};
|
|
121
|
+
/** Response from the tool search operation */
|
|
122
|
+
export type ToolSearchResponse = {
|
|
123
|
+
tool_references: ToolSearchResult[];
|
|
124
|
+
total_tools_searched: number;
|
|
125
|
+
pattern_used: string;
|
|
126
|
+
};
|
|
127
|
+
/** Artifact returned alongside the formatted search results */
|
|
128
|
+
export type ToolSearchArtifact = {
|
|
129
|
+
tool_references: ToolSearchResult[];
|
|
130
|
+
metadata: {
|
|
131
|
+
total_searched: number;
|
|
132
|
+
pattern: string;
|
|
133
|
+
error?: string;
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
/**
|
|
137
|
+
* Tool call requested by the Code API during programmatic execution
|
|
138
|
+
*/
|
|
139
|
+
export type PTCToolCall = {
|
|
140
|
+
/** Unique ID like "call_001" */
|
|
141
|
+
id: string;
|
|
142
|
+
/** Tool name */
|
|
143
|
+
name: string;
|
|
144
|
+
/** Input parameters */
|
|
145
|
+
input: Record<string, any>;
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* Tool result sent back to the Code API
|
|
149
|
+
*/
|
|
150
|
+
export type PTCToolResult = {
|
|
151
|
+
/** Matches PTCToolCall.id */
|
|
152
|
+
call_id: string;
|
|
153
|
+
/** Tool execution result (any JSON-serializable value) */
|
|
154
|
+
result: any;
|
|
155
|
+
/** Whether tool execution failed */
|
|
156
|
+
is_error: boolean;
|
|
157
|
+
/** Error details if is_error=true */
|
|
158
|
+
error_message?: string;
|
|
159
|
+
};
|
|
160
|
+
/**
|
|
161
|
+
* Response from the Code API for programmatic execution
|
|
162
|
+
*/
|
|
163
|
+
export type ProgrammaticExecutionResponse = {
|
|
164
|
+
status: 'tool_call_required' | 'completed' | 'error' | unknown;
|
|
165
|
+
session_id?: string;
|
|
166
|
+
/** Present when status='tool_call_required' */
|
|
167
|
+
continuation_token?: string;
|
|
168
|
+
tool_calls?: PTCToolCall[];
|
|
169
|
+
/** Present when status='completed' */
|
|
170
|
+
stdout?: string;
|
|
171
|
+
stderr?: string;
|
|
172
|
+
files?: FileRefs;
|
|
173
|
+
/** Present when status='error' */
|
|
174
|
+
error?: string;
|
|
175
|
+
};
|
|
176
|
+
/**
|
|
177
|
+
* Artifact returned by the PTC tool
|
|
178
|
+
*/
|
|
179
|
+
export type ProgrammaticExecutionArtifact = {
|
|
180
|
+
session_id?: string;
|
|
181
|
+
files?: FileRefs;
|
|
182
|
+
};
|
|
183
|
+
/**
|
|
184
|
+
* Initialization parameters for the PTC tool
|
|
185
|
+
*/
|
|
186
|
+
export type ProgrammaticToolCallingParams = {
|
|
187
|
+
/** Code API key (or use CODE_API_KEY env var) */
|
|
188
|
+
apiKey?: string;
|
|
189
|
+
/** Code API base URL (or use CODE_BASEURL env var) */
|
|
190
|
+
baseUrl?: string;
|
|
191
|
+
/** Safety limit for round-trips (default: 20) */
|
|
192
|
+
maxRoundTrips?: number;
|
|
193
|
+
/** HTTP proxy URL */
|
|
194
|
+
proxy?: string;
|
|
195
|
+
/** Enable debug logging (or set PTC_DEBUG=true env var) */
|
|
196
|
+
debug?: boolean;
|
|
197
|
+
/** Environment variable key for API key */
|
|
198
|
+
[key: string]: unknown;
|
|
199
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "illuma-agents",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.11",
|
|
4
4
|
"main": "./dist/cjs/main.cjs",
|
|
5
5
|
"module": "./dist/esm/main.mjs",
|
|
6
6
|
"types": "./dist/types/index.d.ts",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"scripts": {
|
|
35
35
|
"prepare": "node husky-setup.js",
|
|
36
36
|
"prepublishOnly": "npm run build",
|
|
37
|
-
"build": "
|
|
37
|
+
"build": "cross-env NODE_ENV=production rollup -c && tsc -p tsconfig.build.json",
|
|
38
38
|
"build:dev": "rollup -c",
|
|
39
39
|
"start": "node dist/esm/main.js",
|
|
40
40
|
"clean": "node ./config/clean.js",
|
|
@@ -51,8 +51,12 @@
|
|
|
51
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'",
|
|
52
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
53
|
"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'",
|
|
54
|
-
"tool": "node -r dotenv/config --loader ./tsconfig-paths-bootstrap.mjs --experimental-specifier-resolution=node ./src/scripts/tools.ts --provider '
|
|
54
|
+
"tool": "node --trace-warnings -r dotenv/config --loader ./tsconfig-paths-bootstrap.mjs --experimental-specifier-resolution=node ./src/scripts/tools.ts --provider 'openrouter' --name 'Jo' --location 'New York, NY'",
|
|
55
55
|
"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'",
|
|
56
|
+
"tool_search_regex": "node -r dotenv/config --loader ./tsconfig-paths-bootstrap.mjs --experimental-specifier-resolution=node ./src/scripts/tool_search_regex.ts",
|
|
57
|
+
"programmatic_exec": "node -r dotenv/config --loader ./tsconfig-paths-bootstrap.mjs --experimental-specifier-resolution=node ./src/scripts/programmatic_exec.ts",
|
|
58
|
+
"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'",
|
|
59
|
+
"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'",
|
|
56
60
|
"ant_web_search": "node -r dotenv/config --loader ./tsconfig-paths-bootstrap.mjs --experimental-specifier-resolution=node ./src/scripts/ant_web_search.ts --name 'Jo' --location 'New York, NY'",
|
|
57
61
|
"ant_web_search_edge_case": "node -r dotenv/config --loader ./tsconfig-paths-bootstrap.mjs --experimental-specifier-resolution=node ./src/scripts/ant_web_search_edge_case.ts --name 'Jo' --location 'New York, NY'",
|
|
58
62
|
"ant_web_search_error_edge_case": "node -r dotenv/config --loader ./tsconfig-paths-bootstrap.mjs --experimental-specifier-resolution=node ./src/scripts/ant_web_search_error_edge_case.ts --name 'Jo' --location 'New York, NY'",
|
|
@@ -140,6 +144,7 @@
|
|
|
140
144
|
"@types/yargs-parser": "^21.0.3",
|
|
141
145
|
"@typescript-eslint/eslint-plugin": "^8.24.0",
|
|
142
146
|
"@typescript-eslint/parser": "^8.24.0",
|
|
147
|
+
"cross-env": "^10.1.0",
|
|
143
148
|
"eslint": "^9.39.1",
|
|
144
149
|
"eslint-import-resolver-typescript": "^3.7.0",
|
|
145
150
|
"eslint-plugin-import": "^2.31.0",
|