illuma-agents 1.0.47 → 1.0.50
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 +44 -14
- package/dist/cjs/agents/AgentContext.cjs.map +1 -1
- package/dist/cjs/common/enum.cjs +2 -1
- package/dist/cjs/common/enum.cjs.map +1 -1
- package/dist/cjs/graphs/Graph.cjs +19 -0
- package/dist/cjs/graphs/Graph.cjs.map +1 -1
- package/dist/cjs/graphs/MultiAgentGraph.cjs +26 -17
- package/dist/cjs/graphs/MultiAgentGraph.cjs.map +1 -1
- package/dist/cjs/llm/openai/index.cjs +1 -0
- package/dist/cjs/llm/openai/index.cjs.map +1 -1
- package/dist/cjs/main.cjs +9 -3
- package/dist/cjs/main.cjs.map +1 -1
- package/dist/cjs/stream.cjs +0 -14
- package/dist/cjs/stream.cjs.map +1 -1
- package/dist/cjs/tools/CodeExecutor.cjs +37 -27
- package/dist/cjs/tools/CodeExecutor.cjs.map +1 -1
- package/dist/cjs/tools/ProgrammaticToolCalling.cjs +22 -18
- package/dist/cjs/tools/ProgrammaticToolCalling.cjs.map +1 -1
- package/dist/cjs/tools/ToolNode.cjs +100 -5
- package/dist/cjs/tools/ToolNode.cjs.map +1 -1
- package/dist/cjs/tools/ToolSearch.cjs +38 -31
- package/dist/cjs/tools/ToolSearch.cjs.map +1 -1
- package/dist/cjs/tools/schema.cjs +31 -0
- package/dist/cjs/tools/schema.cjs.map +1 -0
- package/dist/cjs/tools/search/schema.cjs +25 -23
- package/dist/cjs/tools/search/schema.cjs.map +1 -1
- package/dist/cjs/tools/search/tool.cjs +9 -33
- package/dist/cjs/tools/search/tool.cjs.map +1 -1
- package/dist/cjs/utils/schema.cjs +27 -0
- package/dist/cjs/utils/schema.cjs.map +1 -0
- package/dist/cjs/utils/title.cjs +28 -14
- package/dist/cjs/utils/title.cjs.map +1 -1
- package/dist/esm/agents/AgentContext.mjs +44 -14
- package/dist/esm/agents/AgentContext.mjs.map +1 -1
- package/dist/esm/common/enum.mjs +2 -1
- package/dist/esm/common/enum.mjs.map +1 -1
- package/dist/esm/graphs/Graph.mjs +19 -0
- package/dist/esm/graphs/Graph.mjs.map +1 -1
- package/dist/esm/graphs/MultiAgentGraph.mjs +26 -17
- package/dist/esm/graphs/MultiAgentGraph.mjs.map +1 -1
- package/dist/esm/llm/openai/index.mjs +1 -0
- package/dist/esm/llm/openai/index.mjs.map +1 -1
- package/dist/esm/main.mjs +3 -1
- package/dist/esm/main.mjs.map +1 -1
- package/dist/esm/stream.mjs +0 -14
- package/dist/esm/stream.mjs.map +1 -1
- package/dist/esm/tools/CodeExecutor.mjs +37 -27
- package/dist/esm/tools/CodeExecutor.mjs.map +1 -1
- package/dist/esm/tools/ProgrammaticToolCalling.mjs +22 -18
- package/dist/esm/tools/ProgrammaticToolCalling.mjs.map +1 -1
- package/dist/esm/tools/ToolNode.mjs +101 -6
- package/dist/esm/tools/ToolNode.mjs.map +1 -1
- package/dist/esm/tools/ToolSearch.mjs +38 -31
- package/dist/esm/tools/ToolSearch.mjs.map +1 -1
- package/dist/esm/tools/schema.mjs +28 -0
- package/dist/esm/tools/schema.mjs.map +1 -0
- package/dist/esm/tools/search/schema.mjs +25 -23
- package/dist/esm/tools/search/schema.mjs.map +1 -1
- package/dist/esm/tools/search/tool.mjs +10 -34
- package/dist/esm/tools/search/tool.mjs.map +1 -1
- package/dist/esm/utils/schema.mjs +24 -0
- package/dist/esm/utils/schema.mjs.map +1 -0
- package/dist/esm/utils/title.mjs +28 -14
- package/dist/esm/utils/title.mjs.map +1 -1
- package/dist/types/agents/AgentContext.d.ts +13 -2
- package/dist/types/common/enum.d.ts +2 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/tools/CodeExecutor.d.ts +1 -15
- package/dist/types/tools/ProgrammaticToolCalling.d.ts +1 -13
- package/dist/types/tools/ToolNode.d.ts +12 -1
- package/dist/types/tools/ToolSearch.d.ts +1 -15
- package/dist/types/tools/schema.d.ts +12 -0
- package/dist/types/tools/search/schema.d.ts +25 -7
- package/dist/types/tools/search/tool.d.ts +1 -52
- package/dist/types/tools/search/types.d.ts +5 -23
- package/dist/types/types/graph.d.ts +6 -0
- package/dist/types/types/tools.d.ts +55 -0
- package/dist/types/utils/index.d.ts +1 -0
- package/dist/types/utils/schema.d.ts +8 -0
- package/package.json +2 -3
- package/src/agents/AgentContext.ts +55 -19
- package/src/common/enum.ts +2 -1
- package/src/graphs/Graph.ts +27 -4
- package/src/graphs/MultiAgentGraph.ts +26 -17
- package/src/index.ts +2 -1
- package/src/scripts/test_code_api.ts +4 -4
- package/src/specs/agent-handoffs.test.ts +1 -2
- package/src/specs/azure.simple.test.ts +214 -175
- package/src/specs/thinking-prune.test.ts +6 -6
- package/src/specs/tool-error.test.ts +7 -2
- package/src/stream.ts +0 -17
- package/src/test/mockTools.ts +34 -14
- package/src/tools/CodeExecutor.ts +48 -31
- package/src/tools/ProgrammaticToolCalling.ts +25 -24
- package/src/tools/ToolNode.ts +137 -15
- package/src/tools/ToolSearch.ts +55 -44
- package/src/tools/__tests__/ProgrammaticToolCalling.integration.test.ts +10 -9
- package/src/tools/__tests__/ToolSearch.integration.test.ts +10 -9
- package/src/tools/schema.ts +37 -0
- package/src/tools/search/schema.ts +30 -25
- package/src/tools/search/tool.ts +23 -16
- package/src/tools/search/types.ts +5 -29
- package/src/types/graph.ts +6 -0
- package/src/types/tools.ts +58 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/schema.ts +35 -0
- package/src/utils/title.ts +31 -19
- package/LICENSE +0 -21
- package/dist/cjs/tools/PresentationTool.cjs +0 -291
- package/dist/cjs/tools/PresentationTool.cjs.map +0 -1
- package/dist/esm/tools/PresentationTool.mjs +0 -288
- package/dist/esm/tools/PresentationTool.mjs.map +0 -1
- package/dist/types/tools/PresentationTool.d.ts +0 -2358
- package/src/tools/PresentationTool.ts +0 -356
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { zodToJsonSchema } from 'zod-to-json-schema';
|
|
2
|
+
|
|
3
|
+
// src/utils/schema.ts
|
|
4
|
+
/** Checks if a schema is a Zod schema by looking for the _def property */
|
|
5
|
+
function isZodSchema(schema) {
|
|
6
|
+
return (schema != null && typeof schema === 'object' && '_def' in schema);
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Converts a schema to JSON schema format.
|
|
10
|
+
* Handles both Zod schemas (converts) and JSON schemas (passthrough).
|
|
11
|
+
*/
|
|
12
|
+
function toJsonSchema(schema, name, description) {
|
|
13
|
+
if (isZodSchema(schema)) {
|
|
14
|
+
const zodSchema = schema;
|
|
15
|
+
const described = description != null && description !== ''
|
|
16
|
+
? zodSchema.describe(description)
|
|
17
|
+
: schema;
|
|
18
|
+
return zodToJsonSchema(described, name ?? '');
|
|
19
|
+
}
|
|
20
|
+
return schema;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { isZodSchema, toJsonSchema };
|
|
24
|
+
//# sourceMappingURL=schema.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.mjs","sources":["../../../src/utils/schema.ts"],"sourcesContent":["// src/utils/schema.ts\nimport { zodToJsonSchema } from 'zod-to-json-schema';\nimport type { ZodTypeAny } from 'zod';\n\n/** Checks if a schema is a Zod schema by looking for the _def property */\nexport function isZodSchema(schema: unknown): schema is ZodTypeAny {\n return (\n schema != null && typeof schema === 'object' && '_def' in (schema as object)\n );\n}\n\n/**\n * Converts a schema to JSON schema format.\n * Handles both Zod schemas (converts) and JSON schemas (passthrough).\n */\nexport function toJsonSchema(\n schema: unknown,\n name?: string,\n description?: string\n): Record<string, unknown> {\n if (isZodSchema(schema)) {\n const zodSchema = schema as ZodTypeAny & {\n describe: (desc: string) => ZodTypeAny;\n };\n const described =\n description != null && description !== ''\n ? zodSchema.describe(description)\n : schema;\n return zodToJsonSchema(\n described as Parameters<typeof zodToJsonSchema>[0],\n name ?? ''\n );\n }\n return schema as Record<string, unknown>;\n}\n"],"names":[],"mappings":";;AAAA;AAIA;AACM,SAAU,WAAW,CAAC,MAAe,EAAA;AACzC,IAAA,QACE,MAAM,IAAI,IAAI,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,IAAK,MAAiB;AAEhF;AAEA;;;AAGG;SACa,YAAY,CAC1B,MAAe,EACf,IAAa,EACb,WAAoB,EAAA;AAEpB,IAAA,IAAI,WAAW,CAAC,MAAM,CAAC,EAAE;QACvB,MAAM,SAAS,GAAG,MAEjB;QACD,MAAM,SAAS,GACb,WAAW,IAAI,IAAI,IAAI,WAAW,KAAK;AACrC,cAAE,SAAS,CAAC,QAAQ,CAAC,WAAW;cAC9B,MAAM;QACZ,OAAO,eAAe,CACpB,SAAkD,EAClD,IAAI,IAAI,EAAE,CACX;;AAEH,IAAA,OAAO,MAAiC;AAC1C;;;;"}
|
package/dist/esm/utils/title.mjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
1
|
import { ChatPromptTemplate } from '@langchain/core/prompts';
|
|
3
2
|
import { RunnableLambda, RunnableSequence } from '@langchain/core/runnables';
|
|
4
3
|
import { ContentTypes } from '../common/enum.mjs';
|
|
@@ -8,17 +7,30 @@ const defaultTitlePrompt = `Analyze this conversation and provide:
|
|
|
8
7
|
2. A concise title in the detected language (5 words or less, no punctuation or quotation)
|
|
9
8
|
|
|
10
9
|
{convo}`;
|
|
11
|
-
const titleSchema =
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
10
|
+
const titleSchema = {
|
|
11
|
+
type: 'object',
|
|
12
|
+
properties: {
|
|
13
|
+
title: {
|
|
14
|
+
type: 'string',
|
|
15
|
+
description: 'A concise title for the conversation in 5 words or less, without punctuation or quotation',
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
required: ['title'],
|
|
19
|
+
};
|
|
20
|
+
const combinedSchema = {
|
|
21
|
+
type: 'object',
|
|
22
|
+
properties: {
|
|
23
|
+
language: {
|
|
24
|
+
type: 'string',
|
|
25
|
+
description: 'The detected language of the conversation',
|
|
26
|
+
},
|
|
27
|
+
title: {
|
|
28
|
+
type: 'string',
|
|
29
|
+
description: 'A concise title for the conversation in 5 words or less, without punctuation or quotation',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
required: ['language', 'title'],
|
|
33
|
+
};
|
|
22
34
|
const createTitleRunnable = async (model, _titlePrompt) => {
|
|
23
35
|
// Disabled since this works fine
|
|
24
36
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -33,13 +45,15 @@ const createTitleRunnable = async (model, _titlePrompt) => {
|
|
|
33
45
|
/** Wrap titleOnlyChain in RunnableLambda to create parent span */
|
|
34
46
|
const titleOnlyChain = new RunnableLambda({
|
|
35
47
|
func: async (input, config) => {
|
|
36
|
-
|
|
48
|
+
const result = await titleOnlyInnerChain.invoke(input, config);
|
|
49
|
+
return result;
|
|
37
50
|
},
|
|
38
51
|
}).withConfig({ runName: 'TitleOnlyChain' });
|
|
39
52
|
/** Wrap combinedChain in RunnableLambda to create parent span */
|
|
40
53
|
const combinedChain = new RunnableLambda({
|
|
41
54
|
func: async (input, config) => {
|
|
42
|
-
|
|
55
|
+
const result = await combinedInnerChain.invoke(input, config);
|
|
56
|
+
return result;
|
|
43
57
|
},
|
|
44
58
|
}).withConfig({ runName: 'TitleLanguageChain' });
|
|
45
59
|
/** Runnable to add default values if needed */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"title.mjs","sources":["../../../src/utils/title.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"title.mjs","sources":["../../../src/utils/title.ts"],"sourcesContent":["import { ChatPromptTemplate } from '@langchain/core/prompts';\nimport { RunnableLambda, RunnableSequence } from '@langchain/core/runnables';\nimport type { Runnable, RunnableConfig } from '@langchain/core/runnables';\nimport type { AIMessage } from '@langchain/core/messages';\nimport type * as t from '@/types';\nimport { ContentTypes } from '@/common';\n\nconst defaultTitlePrompt = `Analyze this conversation and provide:\n1. The detected language of the conversation\n2. A concise title in the detected language (5 words or less, no punctuation or quotation)\n\n{convo}`;\n\nconst titleSchema = {\n type: 'object',\n properties: {\n title: {\n type: 'string',\n description:\n 'A concise title for the conversation in 5 words or less, without punctuation or quotation',\n },\n },\n required: ['title'],\n} as const;\n\nconst combinedSchema = {\n type: 'object',\n properties: {\n language: {\n type: 'string',\n description: 'The detected language of the conversation',\n },\n title: {\n type: 'string',\n description:\n 'A concise title for the conversation in 5 words or less, without punctuation or quotation',\n },\n },\n required: ['language', 'title'],\n} as const;\n\nexport const createTitleRunnable = async (\n model: t.ChatModelInstance,\n _titlePrompt?: string\n): Promise<Runnable> => {\n // Disabled since this works fine\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n /* @ts-ignore */\n const titleLLM = model.withStructuredOutput(titleSchema);\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n /* @ts-ignore */\n const combinedLLM = model.withStructuredOutput(combinedSchema);\n\n const titlePrompt = ChatPromptTemplate.fromTemplate(\n _titlePrompt ?? defaultTitlePrompt\n ).withConfig({ runName: 'TitlePrompt' });\n\n const titleOnlyInnerChain = RunnableSequence.from([titlePrompt, titleLLM]);\n const combinedInnerChain = RunnableSequence.from([titlePrompt, combinedLLM]);\n\n /** Wrap titleOnlyChain in RunnableLambda to create parent span */\n const titleOnlyChain = new RunnableLambda({\n func: async (\n input: { convo: string },\n config?: Partial<RunnableConfig>\n ): Promise<{ title: string }> => {\n const result = await titleOnlyInnerChain.invoke(input, config);\n return result as { title: string };\n },\n }).withConfig({ runName: 'TitleOnlyChain' });\n\n /** Wrap combinedChain in RunnableLambda to create parent span */\n const combinedChain = new RunnableLambda({\n func: async (\n input: { convo: string },\n config?: Partial<RunnableConfig>\n ): Promise<{ language: string; title: string }> => {\n const result = await combinedInnerChain.invoke(input, config);\n return result as { language: string; title: string };\n },\n }).withConfig({ runName: 'TitleLanguageChain' });\n\n /** Runnable to add default values if needed */\n const addDefaults = new RunnableLambda({\n func: (\n result: { language: string; title: string } | undefined\n ): { language: string; title: string } => ({\n language: result?.language ?? 'English',\n title: result?.title ?? '',\n }),\n }).withConfig({ runName: 'AddDefaults' });\n\n const combinedChainInner = RunnableSequence.from([\n combinedChain,\n addDefaults,\n ]);\n\n /** Wrap combinedChainWithDefaults in RunnableLambda to create parent span */\n const combinedChainWithDefaults = new RunnableLambda({\n func: async (\n input: { convo: string },\n config?: Partial<RunnableConfig>\n ): Promise<{ language: string; title: string }> => {\n return await combinedChainInner.invoke(input, config);\n },\n }).withConfig({ runName: 'CombinedChainWithDefaults' });\n\n return new RunnableLambda({\n func: async (\n input: {\n convo: string;\n inputText: string;\n skipLanguage: boolean;\n },\n config?: Partial<RunnableConfig>\n ): Promise<{ language: string; title: string } | { title: string }> => {\n const invokeInput = { convo: input.convo };\n\n if (input.skipLanguage) {\n return (await titleOnlyChain.invoke(invokeInput, config)) as {\n title: string;\n };\n }\n\n return await combinedChainWithDefaults.invoke(invokeInput, config);\n },\n }).withConfig({ runName: 'TitleGenerator' });\n};\n\nconst defaultCompletionPrompt = `Provide a concise, 5-word-or-less title for the conversation, using title case conventions. Only return the title itself.\n\nConversation:\n{convo}`;\n\nexport const createCompletionTitleRunnable = async (\n model: t.ChatModelInstance,\n titlePrompt?: string\n): Promise<Runnable> => {\n const completionPrompt = ChatPromptTemplate.fromTemplate(\n titlePrompt ?? defaultCompletionPrompt\n ).withConfig({ runName: 'CompletionTitlePrompt' });\n\n /** Runnable to extract content from model response */\n const extractContent = new RunnableLambda({\n func: (response: AIMessage): { title: string } => {\n let content = '';\n if (typeof response.content === 'string') {\n content = response.content;\n } else if (Array.isArray(response.content)) {\n content = response.content\n .filter(\n (part): part is { type: ContentTypes.TEXT; text: string } =>\n part.type === ContentTypes.TEXT\n )\n .map((part) => part.text)\n .join('');\n }\n return { title: content.trim() };\n },\n }).withConfig({ runName: 'ExtractTitle' });\n\n const innerChain = RunnableSequence.from([\n completionPrompt,\n model,\n extractContent,\n ]);\n\n /** Wrap in RunnableLambda to create a parent span for LangFuse */\n return new RunnableLambda({\n func: async (\n input: { convo: string },\n config?: Partial<RunnableConfig>\n ): Promise<{ title: string }> => {\n return await innerChain.invoke(input, config);\n },\n }).withConfig({ runName: 'CompletionTitleChain' });\n};\n"],"names":[],"mappings":"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"}
|
|
@@ -45,6 +45,11 @@ export declare class AgentContext {
|
|
|
45
45
|
* Used for tool search and programmatic tool calling.
|
|
46
46
|
*/
|
|
47
47
|
toolRegistry?: t.LCToolRegistry;
|
|
48
|
+
/**
|
|
49
|
+
* Serializable tool definitions for event-driven execution.
|
|
50
|
+
* When provided, ToolNode operates in event-driven mode.
|
|
51
|
+
*/
|
|
52
|
+
toolDefinitions?: t.LCTool[];
|
|
48
53
|
/** Set of tool names discovered via tool search (to be loaded) */
|
|
49
54
|
discoveredToolNames: Set<string>;
|
|
50
55
|
/** Instructions for this agent */
|
|
@@ -99,7 +104,7 @@ export declare class AgentContext {
|
|
|
99
104
|
* instead of streaming text.
|
|
100
105
|
*/
|
|
101
106
|
structuredOutput?: t.StructuredOutputConfig;
|
|
102
|
-
constructor({ agentId, name, provider, clientOptions, maxContextTokens, streamBuffer, tokenCounter, tools, toolMap, toolRegistry, instructions, additionalInstructions, dynamicContext, reasoningKey, toolEnd, instructionTokens, useLegacyContent, structuredOutput, }: {
|
|
107
|
+
constructor({ agentId, name, provider, clientOptions, maxContextTokens, streamBuffer, tokenCounter, tools, toolMap, toolRegistry, toolDefinitions, instructions, additionalInstructions, dynamicContext, reasoningKey, toolEnd, instructionTokens, useLegacyContent, structuredOutput, }: {
|
|
103
108
|
agentId: string;
|
|
104
109
|
name?: string;
|
|
105
110
|
provider: Providers;
|
|
@@ -110,6 +115,7 @@ export declare class AgentContext {
|
|
|
110
115
|
tools?: t.GraphTools;
|
|
111
116
|
toolMap?: t.ToolMap;
|
|
112
117
|
toolRegistry?: t.LCToolRegistry;
|
|
118
|
+
toolDefinitions?: t.LCTool[];
|
|
113
119
|
instructions?: string;
|
|
114
120
|
additionalInstructions?: string;
|
|
115
121
|
dynamicContext?: string;
|
|
@@ -251,10 +257,15 @@ export declare class AgentContext {
|
|
|
251
257
|
markToolsAsDiscovered(toolNames: string[]): boolean;
|
|
252
258
|
/**
|
|
253
259
|
* Gets tools that should be bound to the LLM.
|
|
254
|
-
*
|
|
260
|
+
* In event-driven mode (toolDefinitions present, tools empty), creates schema-only tools.
|
|
261
|
+
* Otherwise filters tool instances based on:
|
|
255
262
|
* 1. Non-deferred tools with allowed_callers: ['direct']
|
|
256
263
|
* 2. Discovered tools (from tool search)
|
|
257
264
|
* @returns Array of tools to bind to model
|
|
258
265
|
*/
|
|
259
266
|
getToolsForBinding(): t.GraphTools | undefined;
|
|
267
|
+
/** Creates schema-only tools from toolDefinitions for event-driven mode */
|
|
268
|
+
private getEventDrivenToolsForBinding;
|
|
269
|
+
/** Filters tool instances for binding based on registry config */
|
|
270
|
+
private filterToolsForBinding;
|
|
260
271
|
}
|
|
@@ -21,6 +21,8 @@ export declare enum GraphEvents {
|
|
|
21
21
|
ON_CONTEXT_ANALYTICS = "on_context_analytics",
|
|
22
22
|
/** [Custom] Structured output event - emitted when agent returns structured JSON */
|
|
23
23
|
ON_STRUCTURED_OUTPUT = "on_structured_output",
|
|
24
|
+
/** [Custom] Request to execute tools - dispatched by ToolNode, handled by host */
|
|
25
|
+
ON_TOOL_EXECUTE = "on_tool_execute",
|
|
24
26
|
/** Custom event, emitted by system */
|
|
25
27
|
ON_CUSTOM_EVENT = "on_custom_event",
|
|
26
28
|
/** Emitted when a chat model starts processing. */
|
|
@@ -118,7 +120,6 @@ export declare enum Callback {
|
|
|
118
120
|
export declare enum Constants {
|
|
119
121
|
OFFICIAL_CODE_BASEURL = "https://api.illuma.ai/v1",
|
|
120
122
|
EXECUTE_CODE = "execute_code",
|
|
121
|
-
CREATE_PRESENTATION = "create_presentation",
|
|
122
123
|
TOOL_SEARCH = "tool_search",
|
|
123
124
|
PROGRAMMATIC_TOOL_CALLING = "run_tools_with_code",
|
|
124
125
|
WEB_SEARCH = "web_search",
|
package/dist/types/index.d.ts
CHANGED
|
@@ -6,10 +6,11 @@ export * from './messages';
|
|
|
6
6
|
export * from './graphs';
|
|
7
7
|
export * from './tools/Calculator';
|
|
8
8
|
export * from './tools/CodeExecutor';
|
|
9
|
-
export * from './tools/PresentationTool';
|
|
10
9
|
export * from './tools/BrowserTools';
|
|
11
10
|
export * from './tools/ProgrammaticToolCalling';
|
|
12
11
|
export * from './tools/ToolSearch';
|
|
12
|
+
export * from './tools/ToolNode';
|
|
13
|
+
export * from './tools/schema';
|
|
13
14
|
export * from './tools/handlers';
|
|
14
15
|
export * from './tools/search';
|
|
15
16
|
export * from './schemas';
|
|
@@ -1,20 +1,6 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
1
|
import { DynamicStructuredTool } from '@langchain/core/tools';
|
|
3
2
|
import type * as t from '@/types';
|
|
4
3
|
export declare const imageExtRegex: RegExp;
|
|
5
4
|
export declare const getCodeBaseURL: () => string;
|
|
6
|
-
declare
|
|
7
|
-
lang: z.ZodEnum<["py", "js", "ts", "c", "cpp", "java", "php", "rs", "go", "d", "f90", "r"]>;
|
|
8
|
-
code: z.ZodString;
|
|
9
|
-
args: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
10
|
-
}, "strip", z.ZodTypeAny, {
|
|
11
|
-
code: string;
|
|
12
|
-
lang: "r" | "d" | "py" | "js" | "ts" | "c" | "cpp" | "java" | "php" | "rs" | "go" | "f90";
|
|
13
|
-
args?: string[] | undefined;
|
|
14
|
-
}, {
|
|
15
|
-
code: string;
|
|
16
|
-
lang: "r" | "d" | "py" | "js" | "ts" | "c" | "cpp" | "java" | "php" | "rs" | "go" | "f90";
|
|
17
|
-
args?: string[] | undefined;
|
|
18
|
-
}>;
|
|
19
|
-
declare function createCodeExecutionTool(params?: t.CodeExecutionToolParams): DynamicStructuredTool<typeof CodeExecutionToolSchema>;
|
|
5
|
+
declare function createCodeExecutionTool(params?: t.CodeExecutionToolParams): DynamicStructuredTool;
|
|
20
6
|
export { createCodeExecutionTool };
|
|
@@ -1,16 +1,5 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
1
|
import { DynamicStructuredTool } from '@langchain/core/tools';
|
|
3
2
|
import type * as t from '@/types';
|
|
4
|
-
declare const ProgrammaticToolCallingSchema: z.ZodObject<{
|
|
5
|
-
code: z.ZodString;
|
|
6
|
-
timeout: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
|
|
7
|
-
}, "strip", z.ZodTypeAny, {
|
|
8
|
-
code: string;
|
|
9
|
-
timeout: number;
|
|
10
|
-
}, {
|
|
11
|
-
code: string;
|
|
12
|
-
timeout?: number | undefined;
|
|
13
|
-
}>;
|
|
14
3
|
/**
|
|
15
4
|
* Normalizes a tool name to Python identifier format.
|
|
16
5
|
* Must match the Code API's `normalizePythonFunctionName` exactly:
|
|
@@ -103,5 +92,4 @@ export declare function formatCompletedResponse(response: t.ProgrammaticExecutio
|
|
|
103
92
|
* { configurable: { toolMap } }
|
|
104
93
|
* );
|
|
105
94
|
*/
|
|
106
|
-
export declare function createProgrammaticToolCallingTool(initParams?: t.ProgrammaticToolCallingParams): DynamicStructuredTool
|
|
107
|
-
export {};
|
|
95
|
+
export declare function createProgrammaticToolCallingTool(initParams?: t.ProgrammaticToolCallingParams): DynamicStructuredTool;
|
|
@@ -18,7 +18,13 @@ export declare class ToolNode<T = any> extends RunnableCallable<T, T> {
|
|
|
18
18
|
private programmaticCache?;
|
|
19
19
|
/** Reference to Graph's sessions map for automatic session injection */
|
|
20
20
|
private sessions?;
|
|
21
|
-
|
|
21
|
+
/** When true, dispatches ON_TOOL_EXECUTE events instead of invoking tools directly */
|
|
22
|
+
private eventDrivenMode;
|
|
23
|
+
/** Tool definitions for event-driven mode */
|
|
24
|
+
private toolDefinitions?;
|
|
25
|
+
/** Agent ID for event-driven mode */
|
|
26
|
+
private agentId?;
|
|
27
|
+
constructor({ tools, toolMap, name, tags, errorHandler, toolCallStepIds, handleToolErrors, loadRuntimeTools, toolRegistry, sessions, eventDrivenMode, toolDefinitions, agentId, }: t.ToolNodeConstructorParams);
|
|
22
28
|
/**
|
|
23
29
|
* Returns cached programmatic tools, computing once on first access.
|
|
24
30
|
* Single iteration builds both toolMap and toolDefs simultaneously.
|
|
@@ -33,6 +39,11 @@ export declare class ToolNode<T = any> extends RunnableCallable<T, T> {
|
|
|
33
39
|
* Runs a single tool call with error handling
|
|
34
40
|
*/
|
|
35
41
|
protected runTool(call: ToolCall, config: RunnableConfig): Promise<BaseMessage | Command>;
|
|
42
|
+
/**
|
|
43
|
+
* Execute all tool calls via ON_TOOL_EXECUTE event dispatch.
|
|
44
|
+
* Used in event-driven mode where the host handles actual tool execution.
|
|
45
|
+
*/
|
|
46
|
+
private executeViaEvent;
|
|
36
47
|
protected run(input: any, config: RunnableConfig): Promise<T>;
|
|
37
48
|
private isSendInput;
|
|
38
49
|
private isMessagesState;
|
|
@@ -1,19 +1,5 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
1
|
import { DynamicStructuredTool } from '@langchain/core/tools';
|
|
3
2
|
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
3
|
/**
|
|
18
4
|
* Extracts the MCP server name from a tool name.
|
|
19
5
|
* MCP tools follow the pattern: toolName_mcp_serverName
|
|
@@ -144,5 +130,5 @@ declare function formatServerListing(tools: t.ToolMetadata[], serverNames: strin
|
|
|
144
130
|
* const tool = createToolSearch({ mode: 'local', toolRegistry });
|
|
145
131
|
* await tool.invoke({ query: 'expense' });
|
|
146
132
|
*/
|
|
147
|
-
declare function createToolSearch(initParams?: t.ToolSearchParams): DynamicStructuredTool
|
|
133
|
+
declare function createToolSearch(initParams?: t.ToolSearchParams): DynamicStructuredTool;
|
|
148
134
|
export { createToolSearch, performLocalSearch, extractMcpServerName, isFromMcpServer, isFromAnyMcpServer, normalizeServerFilter, getAvailableMcpServers, getDeferredToolsListing, getBaseToolName, formatServerListing, sanitizeRegex, escapeRegexSpecialChars, isDangerousPattern, countNestedGroups, hasNestedQuantifiers, };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type StructuredToolInterface } from '@langchain/core/tools';
|
|
2
|
+
import type { LCTool } from '@/types';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a schema-only tool for LLM binding in event-driven mode.
|
|
5
|
+
* These tools have valid schemas for the LLM to understand but should
|
|
6
|
+
* never be invoked directly - ToolNode handles execution via events.
|
|
7
|
+
*/
|
|
8
|
+
export declare function createSchemaOnlyTool(definition: LCTool): StructuredToolInterface;
|
|
9
|
+
/**
|
|
10
|
+
* Creates schema-only tools for all definitions in an array.
|
|
11
|
+
*/
|
|
12
|
+
export declare function createSchemaOnlyTools(definitions: LCTool[]): StructuredToolInterface[];
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
1
|
export declare enum DATE_RANGE {
|
|
3
2
|
PAST_HOUR = "h",
|
|
4
3
|
PAST_24_HOURS = "d",
|
|
@@ -8,9 +7,28 @@ export declare enum DATE_RANGE {
|
|
|
8
7
|
}
|
|
9
8
|
export declare const DEFAULT_QUERY_DESCRIPTION: string;
|
|
10
9
|
export declare const DEFAULT_COUNTRY_DESCRIPTION: string;
|
|
11
|
-
export declare const querySchema:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export declare const
|
|
16
|
-
|
|
10
|
+
export declare const querySchema: {
|
|
11
|
+
readonly type: "string";
|
|
12
|
+
readonly description: string;
|
|
13
|
+
};
|
|
14
|
+
export declare const dateSchema: {
|
|
15
|
+
readonly type: "string";
|
|
16
|
+
readonly enum: DATE_RANGE[];
|
|
17
|
+
readonly description: "Date range for search results.";
|
|
18
|
+
};
|
|
19
|
+
export declare const countrySchema: {
|
|
20
|
+
readonly type: "string";
|
|
21
|
+
readonly description: string;
|
|
22
|
+
};
|
|
23
|
+
export declare const imagesSchema: {
|
|
24
|
+
readonly type: "boolean";
|
|
25
|
+
readonly description: "Whether to also run an image search.";
|
|
26
|
+
};
|
|
27
|
+
export declare const videosSchema: {
|
|
28
|
+
readonly type: "boolean";
|
|
29
|
+
readonly description: "Whether to also run a video search.";
|
|
30
|
+
};
|
|
31
|
+
export declare const newsSchema: {
|
|
32
|
+
readonly type: "boolean";
|
|
33
|
+
readonly description: "Whether to also run a news search.";
|
|
34
|
+
};
|
|
@@ -1,54 +1,3 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
1
|
import { DynamicStructuredTool } from '@langchain/core/tools';
|
|
3
2
|
import type * as t from './types';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Creates a search tool with a schema that dynamically includes the country field
|
|
7
|
-
* only when the searchProvider is 'serper'.
|
|
8
|
-
*
|
|
9
|
-
* Supports multiple scraper providers:
|
|
10
|
-
* - Firecrawl (default): Full-featured web scraping with multiple formats
|
|
11
|
-
* - Serper: Lightweight scraping using Serper's scrape API
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```typescript
|
|
15
|
-
* // Using Firecrawl scraper (default)
|
|
16
|
-
* const searchTool = createSearchTool({
|
|
17
|
-
* searchProvider: 'serper',
|
|
18
|
-
* scraperProvider: 'firecrawl',
|
|
19
|
-
* firecrawlApiKey: 'your-firecrawl-key'
|
|
20
|
-
* });
|
|
21
|
-
*
|
|
22
|
-
* // Using Serper scraper
|
|
23
|
-
* const searchTool = createSearchTool({
|
|
24
|
-
* searchProvider: 'serper',
|
|
25
|
-
* scraperProvider: 'serper',
|
|
26
|
-
* serperApiKey: 'your-serper-key'
|
|
27
|
-
* });
|
|
28
|
-
* ```
|
|
29
|
-
*
|
|
30
|
-
* @param config - The search tool configuration
|
|
31
|
-
* @returns A DynamicStructuredTool with a schema that depends on the searchProvider
|
|
32
|
-
*/
|
|
33
|
-
export declare const createSearchTool: (config?: t.SearchToolConfig) => DynamicStructuredTool<z.ZodObject<{
|
|
34
|
-
query: z.ZodString;
|
|
35
|
-
date: z.ZodOptional<z.ZodNativeEnum<typeof DATE_RANGE>>;
|
|
36
|
-
country?: z.ZodOptional<z.ZodString>;
|
|
37
|
-
images: z.ZodOptional<z.ZodBoolean>;
|
|
38
|
-
videos: z.ZodOptional<z.ZodBoolean>;
|
|
39
|
-
news: z.ZodOptional<z.ZodBoolean>;
|
|
40
|
-
}, "strip", z.ZodTypeAny, {
|
|
41
|
-
query: string;
|
|
42
|
-
videos?: boolean | undefined;
|
|
43
|
-
images?: boolean | undefined;
|
|
44
|
-
news?: boolean | undefined;
|
|
45
|
-
date?: DATE_RANGE | undefined;
|
|
46
|
-
country?: unknown;
|
|
47
|
-
}, {
|
|
48
|
-
query: string;
|
|
49
|
-
videos?: boolean | undefined;
|
|
50
|
-
images?: boolean | undefined;
|
|
51
|
-
news?: boolean | undefined;
|
|
52
|
-
date?: DATE_RANGE | undefined;
|
|
53
|
-
country?: unknown;
|
|
54
|
-
}>>;
|
|
3
|
+
export declare const createSearchTool: (config?: t.SearchToolConfig) => DynamicStructuredTool;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
1
|
import type { Logger as WinstonLogger } from 'winston';
|
|
3
2
|
import type { RunnableConfig } from '@langchain/core/runnables';
|
|
4
3
|
import type { BaseReranker } from './rerankers';
|
|
@@ -569,25 +568,8 @@ export type ProcessSourcesFields = {
|
|
|
569
568
|
/** Skip scraping if content was already extracted directly (e.g., direct URL extraction) */
|
|
570
569
|
skipScraping?: boolean;
|
|
571
570
|
};
|
|
572
|
-
export
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
videos: z.ZodOptional<z.ZodBoolean>;
|
|
578
|
-
news: z.ZodOptional<z.ZodBoolean>;
|
|
579
|
-
}, 'strip', z.ZodTypeAny, {
|
|
580
|
-
query: string;
|
|
581
|
-
date?: DATE_RANGE;
|
|
582
|
-
country?: unknown;
|
|
583
|
-
images?: boolean;
|
|
584
|
-
videos?: boolean;
|
|
585
|
-
news?: boolean;
|
|
586
|
-
}, {
|
|
587
|
-
query: string;
|
|
588
|
-
date?: DATE_RANGE;
|
|
589
|
-
country?: unknown;
|
|
590
|
-
images?: boolean;
|
|
591
|
-
videos?: boolean;
|
|
592
|
-
news?: boolean;
|
|
593
|
-
}>;
|
|
571
|
+
export interface SearchToolSchema {
|
|
572
|
+
type: 'object';
|
|
573
|
+
properties: Record<string, unknown>;
|
|
574
|
+
required: string[];
|
|
575
|
+
}
|
|
@@ -332,4 +332,10 @@ export interface AgentInputs {
|
|
|
332
332
|
* conforming to the specified schema.
|
|
333
333
|
*/
|
|
334
334
|
structuredOutput?: StructuredOutputConfig;
|
|
335
|
+
/**
|
|
336
|
+
* Serializable tool definitions for event-driven execution.
|
|
337
|
+
* When provided, ToolNode operates in event-driven mode, dispatching
|
|
338
|
+
* ON_TOOL_EXECUTE events instead of invoking tools directly.
|
|
339
|
+
*/
|
|
340
|
+
toolDefinitions?: LCTool[];
|
|
335
341
|
}
|
|
@@ -31,6 +31,12 @@ export type ToolNodeOptions = {
|
|
|
31
31
|
toolRegistry?: LCToolRegistry;
|
|
32
32
|
/** Reference to Graph's sessions map for automatic session injection */
|
|
33
33
|
sessions?: ToolSessionMap;
|
|
34
|
+
/** When true, dispatches ON_TOOL_EXECUTE events instead of invoking tools directly */
|
|
35
|
+
eventDrivenMode?: boolean;
|
|
36
|
+
/** Tool definitions for event-driven mode (used for context, not invocation) */
|
|
37
|
+
toolDefinitions?: Map<string, LCTool>;
|
|
38
|
+
/** Agent ID for event-driven mode (used to identify which agent's context to use) */
|
|
39
|
+
agentId?: string;
|
|
34
40
|
};
|
|
35
41
|
export type ToolNodeConstructorParams = ToolRefs & ToolNodeOptions;
|
|
36
42
|
export type ToolEndEvent = {
|
|
@@ -96,6 +102,55 @@ export type LCTool = {
|
|
|
96
102
|
* Options: 'direct', 'code_execution'
|
|
97
103
|
*/
|
|
98
104
|
allowed_callers?: AllowedCaller[];
|
|
105
|
+
/** Response format for the tool output */
|
|
106
|
+
responseFormat?: 'content' | 'content_and_artifact';
|
|
107
|
+
/** Server name for MCP tools */
|
|
108
|
+
serverName?: string;
|
|
109
|
+
/** Tool type classification */
|
|
110
|
+
toolType?: 'builtin' | 'mcp' | 'action';
|
|
111
|
+
};
|
|
112
|
+
/** Single tool call within a batch request for event-driven execution */
|
|
113
|
+
export type ToolCallRequest = {
|
|
114
|
+
/** Tool call ID from the LLM */
|
|
115
|
+
id: string;
|
|
116
|
+
/** Tool name */
|
|
117
|
+
name: string;
|
|
118
|
+
/** Tool arguments */
|
|
119
|
+
args: Record<string, unknown>;
|
|
120
|
+
/** Step ID for tracking */
|
|
121
|
+
stepId?: string;
|
|
122
|
+
/** Usage turn count for this tool */
|
|
123
|
+
turn?: number;
|
|
124
|
+
};
|
|
125
|
+
/** Batch request containing ALL tool calls for a graph step */
|
|
126
|
+
export type ToolExecuteBatchRequest = {
|
|
127
|
+
/** All tool calls from the AIMessage */
|
|
128
|
+
toolCalls: ToolCallRequest[];
|
|
129
|
+
/** User ID for context */
|
|
130
|
+
userId?: string;
|
|
131
|
+
/** Agent ID for context */
|
|
132
|
+
agentId?: string;
|
|
133
|
+
/** Runtime configurable from RunnableConfig (includes user, userMCPAuthMap, etc.) */
|
|
134
|
+
configurable?: Record<string, unknown>;
|
|
135
|
+
/** Runtime metadata from RunnableConfig (includes thread_id, run_id, provider, etc.) */
|
|
136
|
+
metadata?: Record<string, unknown>;
|
|
137
|
+
/** Promise resolver - handler calls this with ALL results */
|
|
138
|
+
resolve: (results: ToolExecuteResult[]) => void;
|
|
139
|
+
/** Promise rejector - handler calls this on fatal error */
|
|
140
|
+
reject: (error: Error) => void;
|
|
141
|
+
};
|
|
142
|
+
/** Result for a single tool call in event-driven execution */
|
|
143
|
+
export type ToolExecuteResult = {
|
|
144
|
+
/** Matches ToolCallRequest.id */
|
|
145
|
+
toolCallId: string;
|
|
146
|
+
/** Tool output content */
|
|
147
|
+
content: string | unknown[];
|
|
148
|
+
/** Optional artifact (for content_and_artifact format) */
|
|
149
|
+
artifact?: unknown;
|
|
150
|
+
/** Execution status */
|
|
151
|
+
status: 'success' | 'error';
|
|
152
|
+
/** Error message if status is 'error' */
|
|
153
|
+
errorMessage?: string;
|
|
99
154
|
};
|
|
100
155
|
/** Map of tool names to tool definitions */
|
|
101
156
|
export type LCToolRegistry = Map<string, LCTool>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ZodTypeAny } from 'zod';
|
|
2
|
+
/** Checks if a schema is a Zod schema by looking for the _def property */
|
|
3
|
+
export declare function isZodSchema(schema: unknown): schema is ZodTypeAny;
|
|
4
|
+
/**
|
|
5
|
+
* Converts a schema to JSON schema format.
|
|
6
|
+
* Handles both Zod schemas (converts) and JSON schemas (passthrough).
|
|
7
|
+
*/
|
|
8
|
+
export declare function toJsonSchema(schema: unknown, name?: string, description?: string): Record<string, unknown>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "illuma-agents",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.50",
|
|
4
4
|
"main": "./dist/cjs/main.cjs",
|
|
5
5
|
"module": "./dist/esm/main.mjs",
|
|
6
6
|
"types": "./dist/types/index.d.ts",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"url": "https://github.com/codevakure/agents"
|
|
19
19
|
},
|
|
20
20
|
"author": "Illuma Team",
|
|
21
|
-
"license": "
|
|
21
|
+
"license": "UNLICENSED",
|
|
22
22
|
"packageManager": "npm@10.5.2",
|
|
23
23
|
"engines": {
|
|
24
24
|
"node": ">=14.0.0"
|
|
@@ -26,7 +26,6 @@
|
|
|
26
26
|
"files": [
|
|
27
27
|
"dist",
|
|
28
28
|
"src",
|
|
29
|
-
"LICENSE",
|
|
30
29
|
"README.md"
|
|
31
30
|
],
|
|
32
31
|
"scripts": {
|