illuma-agents 1.0.49 → 1.0.51
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 +62 -14
- 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/graphs/Graph.cjs +48 -2
- 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 -17
- 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 +62 -14
- 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/graphs/Graph.mjs +48 -2
- 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 -4
- 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 -0
- 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 +32 -1
- 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 -4
- package/src/agents/AgentContext.test.ts +99 -0
- package/src/agents/AgentContext.ts +74 -20
- package/src/common/enum.ts +2 -0
- package/src/graphs/Graph.ts +56 -4
- package/src/graphs/MultiAgentGraph.ts +26 -17
- package/src/index.ts +2 -3
- 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 +33 -1
- 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/deepagents/DeepAgentBackend.cjs +0 -170
- package/dist/cjs/deepagents/DeepAgentBackend.cjs.map +0 -1
- package/dist/cjs/deepagents/DeepAgentRuntime.cjs +0 -135
- package/dist/cjs/deepagents/DeepAgentRuntime.cjs.map +0 -1
- package/dist/cjs/deepagents/types.cjs +0 -29
- package/dist/cjs/deepagents/types.cjs.map +0 -1
- package/dist/esm/deepagents/DeepAgentBackend.mjs +0 -168
- package/dist/esm/deepagents/DeepAgentBackend.mjs.map +0 -1
- package/dist/esm/deepagents/DeepAgentRuntime.mjs +0 -132
- package/dist/esm/deepagents/DeepAgentRuntime.mjs.map +0 -1
- package/dist/esm/deepagents/types.mjs +0 -26
- package/dist/esm/deepagents/types.mjs.map +0 -1
- package/dist/types/deepagents/DeepAgentBackend.d.ts +0 -82
- package/dist/types/deepagents/DeepAgentRuntime.d.ts +0 -46
- package/dist/types/deepagents/index.d.ts +0 -16
- package/dist/types/deepagents/types.d.ts +0 -105
- package/src/deepagents/DeepAgentBackend.ts +0 -214
- package/src/deepagents/DeepAgentRuntime.ts +0 -187
- package/src/deepagents/index.ts +0 -25
- package/src/deepagents/types.ts +0 -118
- package/src/specs/deepagents.test.ts +0 -286
package/src/graphs/Graph.ts
CHANGED
|
@@ -66,6 +66,7 @@ import { getChatModelClass, manualToolStreamProviders } from '@/llm/providers';
|
|
|
66
66
|
import { ToolNode as CustomToolNode, toolsCondition } from '@/tools/ToolNode';
|
|
67
67
|
import { ChatOpenAI, AzureChatOpenAI } from '@/llm/openai';
|
|
68
68
|
import { safeDispatchCustomEvent } from '@/utils/events';
|
|
69
|
+
import { createSchemaOnlyTools } from '@/tools/schema';
|
|
69
70
|
import { AgentContext } from '@/agents/AgentContext';
|
|
70
71
|
import { createFakeStreamingLLM } from '@/llm/fake';
|
|
71
72
|
import { HandlerRegistry } from '@/events';
|
|
@@ -524,6 +525,28 @@ export class StandardGraph extends Graph<t.BaseGraphState, t.GraphNode> {
|
|
|
524
525
|
currentToolMap?: t.ToolMap;
|
|
525
526
|
agentContext?: AgentContext;
|
|
526
527
|
}): CustomToolNode<t.BaseGraphState> | ToolNode<t.BaseGraphState> {
|
|
528
|
+
const toolDefinitions = agentContext?.toolDefinitions;
|
|
529
|
+
const eventDrivenMode =
|
|
530
|
+
toolDefinitions != null && toolDefinitions.length > 0;
|
|
531
|
+
|
|
532
|
+
if (eventDrivenMode) {
|
|
533
|
+
const schemaTools = createSchemaOnlyTools(toolDefinitions);
|
|
534
|
+
const toolDefMap = new Map(toolDefinitions.map((def) => [def.name, def]));
|
|
535
|
+
|
|
536
|
+
return new CustomToolNode<t.BaseGraphState>({
|
|
537
|
+
tools: schemaTools as t.GenericTool[],
|
|
538
|
+
toolMap: new Map(schemaTools.map((tool) => [tool.name, tool])),
|
|
539
|
+
toolCallStepIds: this.toolCallStepIds,
|
|
540
|
+
errorHandler: (data, metadata) =>
|
|
541
|
+
StandardGraph.handleToolCallErrorStatic(this, data, metadata),
|
|
542
|
+
toolRegistry: agentContext?.toolRegistry,
|
|
543
|
+
sessions: this.sessions,
|
|
544
|
+
eventDrivenMode: true,
|
|
545
|
+
toolDefinitions: toolDefMap,
|
|
546
|
+
agentId: agentContext?.agentId,
|
|
547
|
+
});
|
|
548
|
+
}
|
|
549
|
+
|
|
527
550
|
return new CustomToolNode<t.BaseGraphState>({
|
|
528
551
|
tools: (currentTools as t.GenericTool[] | undefined) ?? [],
|
|
529
552
|
toolMap: currentToolMap,
|
|
@@ -677,11 +700,13 @@ export class StandardGraph extends Graph<t.BaseGraphState, t.GraphNode> {
|
|
|
677
700
|
finalMessages,
|
|
678
701
|
schema,
|
|
679
702
|
structuredOutputConfig,
|
|
703
|
+
provider,
|
|
680
704
|
}: {
|
|
681
705
|
currentModel: t.ChatModelInstance;
|
|
682
706
|
finalMessages: BaseMessage[];
|
|
683
707
|
schema: Record<string, unknown>;
|
|
684
708
|
structuredOutputConfig: t.StructuredOutputConfig;
|
|
709
|
+
provider?: Providers;
|
|
685
710
|
},
|
|
686
711
|
config?: RunnableConfig
|
|
687
712
|
): Promise<{
|
|
@@ -705,15 +730,41 @@ export class StandardGraph extends Graph<t.BaseGraphState, t.GraphNode> {
|
|
|
705
730
|
|
|
706
731
|
const {
|
|
707
732
|
name = 'StructuredResponse',
|
|
733
|
+
mode = 'auto',
|
|
708
734
|
includeRaw = false,
|
|
709
735
|
handleErrors = true,
|
|
710
736
|
maxRetries = 2,
|
|
711
737
|
} = structuredOutputConfig;
|
|
712
738
|
|
|
739
|
+
// Determine the method based on mode and provider
|
|
740
|
+
// - 'tool': Use tool calling (works well with OpenAI)
|
|
741
|
+
// - 'json_mode': Use JSON mode (works well with Bedrock/Anthropic)
|
|
742
|
+
// - 'auto': Auto-detect based on provider
|
|
743
|
+
let method: 'functionCalling' | 'jsonMode' | 'jsonSchema' | undefined;
|
|
744
|
+
|
|
745
|
+
if (mode === 'tool') {
|
|
746
|
+
method = 'functionCalling';
|
|
747
|
+
} else if (mode === 'provider') {
|
|
748
|
+
// Use native JSON mode - best for Anthropic/Bedrock
|
|
749
|
+
method = 'jsonMode';
|
|
750
|
+
} else {
|
|
751
|
+
// Auto mode: choose based on provider
|
|
752
|
+
// Bedrock and Anthropic work better with JSON mode
|
|
753
|
+
// OpenAI, Azure work better with function calling
|
|
754
|
+
if (provider === Providers.BEDROCK || provider === Providers.ANTHROPIC) {
|
|
755
|
+
method = 'jsonMode';
|
|
756
|
+
} else if (provider === Providers.GOOGLE || provider === Providers.VERTEXAI) {
|
|
757
|
+
// Gemini supports native JSON mode
|
|
758
|
+
method = 'jsonMode';
|
|
759
|
+
}
|
|
760
|
+
// For OpenAI/Azure, leave undefined to use default (function calling)
|
|
761
|
+
}
|
|
762
|
+
|
|
713
763
|
// Use withStructuredOutput to bind the schema
|
|
714
764
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
715
765
|
const structuredModel = (model as any).withStructuredOutput(schema, {
|
|
716
766
|
name,
|
|
767
|
+
method,
|
|
717
768
|
includeRaw,
|
|
718
769
|
strict: structuredOutputConfig.strict !== false,
|
|
719
770
|
});
|
|
@@ -1073,7 +1124,7 @@ export class StandardGraph extends Graph<t.BaseGraphState, t.GraphNode> {
|
|
|
1073
1124
|
// Get a fresh model WITHOUT tools bound - bindTools() returns RunnableBinding which lacks withStructuredOutput
|
|
1074
1125
|
// Also disable thinking mode - Anthropic/Bedrock doesn't allow tool_choice with thinking enabled
|
|
1075
1126
|
const structuredClientOptions = { ...agentContext.clientOptions } as t.ClientOptions;
|
|
1076
|
-
|
|
1127
|
+
|
|
1077
1128
|
// Remove thinking configuration for Bedrock
|
|
1078
1129
|
if (agentContext.provider === Providers.BEDROCK) {
|
|
1079
1130
|
const bedrockOpts = structuredClientOptions as t.BedrockAnthropicClientOptions;
|
|
@@ -1084,7 +1135,7 @@ export class StandardGraph extends Graph<t.BaseGraphState, t.GraphNode> {
|
|
|
1084
1135
|
bedrockOpts.additionalModelRequestFields = additionalFields;
|
|
1085
1136
|
}
|
|
1086
1137
|
}
|
|
1087
|
-
|
|
1138
|
+
|
|
1088
1139
|
// Remove thinking configuration for Anthropic
|
|
1089
1140
|
if (agentContext.provider === Providers.ANTHROPIC) {
|
|
1090
1141
|
const anthropicOpts = structuredClientOptions as t.AnthropicClientOptions;
|
|
@@ -1092,12 +1143,12 @@ export class StandardGraph extends Graph<t.BaseGraphState, t.GraphNode> {
|
|
|
1092
1143
|
delete anthropicOpts.thinking;
|
|
1093
1144
|
}
|
|
1094
1145
|
}
|
|
1095
|
-
|
|
1146
|
+
|
|
1096
1147
|
const structuredModel = this.getNewModel({
|
|
1097
1148
|
provider: agentContext.provider,
|
|
1098
1149
|
clientOptions: structuredClientOptions,
|
|
1099
1150
|
});
|
|
1100
|
-
|
|
1151
|
+
|
|
1101
1152
|
const { structuredResponse, rawMessage } =
|
|
1102
1153
|
await this.attemptStructuredInvoke(
|
|
1103
1154
|
{
|
|
@@ -1105,6 +1156,7 @@ export class StandardGraph extends Graph<t.BaseGraphState, t.GraphNode> {
|
|
|
1105
1156
|
finalMessages,
|
|
1106
1157
|
schema,
|
|
1107
1158
|
structuredOutputConfig: agentContext.structuredOutput,
|
|
1159
|
+
provider: agentContext.provider,
|
|
1108
1160
|
},
|
|
1109
1161
|
config
|
|
1110
1162
|
);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
1
|
import { tool } from '@langchain/core/tools';
|
|
3
2
|
import { PromptTemplate } from '@langchain/core/prompts';
|
|
4
3
|
import {
|
|
@@ -292,7 +291,8 @@ export class MultiAgentGraph extends StandardGraph {
|
|
|
292
291
|
|
|
293
292
|
tools.push(
|
|
294
293
|
tool(
|
|
295
|
-
async (
|
|
294
|
+
async (rawInput, config) => {
|
|
295
|
+
const input = rawInput as Record<string, unknown>;
|
|
296
296
|
const state = getCurrentTaskInput() as t.BaseGraphState;
|
|
297
297
|
const toolCallId =
|
|
298
298
|
(config as ToolRunnableConfig | undefined)?.toolCall?.id ??
|
|
@@ -343,13 +343,17 @@ export class MultiAgentGraph extends StandardGraph {
|
|
|
343
343
|
{
|
|
344
344
|
name: toolName,
|
|
345
345
|
schema: hasHandoffInput
|
|
346
|
-
?
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
346
|
+
? {
|
|
347
|
+
type: 'object',
|
|
348
|
+
properties: {
|
|
349
|
+
[promptKey]: {
|
|
350
|
+
type: 'string',
|
|
351
|
+
description: handoffInputDescription as string,
|
|
352
|
+
},
|
|
353
|
+
},
|
|
354
|
+
required: [],
|
|
355
|
+
}
|
|
356
|
+
: { type: 'object', properties: {}, required: [] },
|
|
353
357
|
description: toolDescription,
|
|
354
358
|
}
|
|
355
359
|
)
|
|
@@ -371,7 +375,8 @@ export class MultiAgentGraph extends StandardGraph {
|
|
|
371
375
|
|
|
372
376
|
tools.push(
|
|
373
377
|
tool(
|
|
374
|
-
async (
|
|
378
|
+
async (rawInput, config) => {
|
|
379
|
+
const input = rawInput as Record<string, unknown>;
|
|
375
380
|
const toolCallId =
|
|
376
381
|
(config as ToolRunnableConfig | undefined)?.toolCall?.id ??
|
|
377
382
|
'unknown';
|
|
@@ -470,13 +475,17 @@ export class MultiAgentGraph extends StandardGraph {
|
|
|
470
475
|
{
|
|
471
476
|
name: toolName,
|
|
472
477
|
schema: hasHandoffInput
|
|
473
|
-
?
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
478
|
+
? {
|
|
479
|
+
type: 'object',
|
|
480
|
+
properties: {
|
|
481
|
+
[promptKey]: {
|
|
482
|
+
type: 'string',
|
|
483
|
+
description: handoffInputDescription as string,
|
|
484
|
+
},
|
|
485
|
+
},
|
|
486
|
+
required: [],
|
|
487
|
+
}
|
|
488
|
+
: { type: 'object', properties: {}, required: [] },
|
|
480
489
|
description: toolDescription,
|
|
481
490
|
}
|
|
482
491
|
)
|
package/src/index.ts
CHANGED
|
@@ -8,15 +8,14 @@ export * from './messages';
|
|
|
8
8
|
/* Graphs */
|
|
9
9
|
export * from './graphs';
|
|
10
10
|
|
|
11
|
-
/* Deep Agents */
|
|
12
|
-
export * from './deepagents';
|
|
13
|
-
|
|
14
11
|
/* Tools */
|
|
15
12
|
export * from './tools/Calculator';
|
|
16
13
|
export * from './tools/CodeExecutor';
|
|
17
14
|
export * from './tools/BrowserTools';
|
|
18
15
|
export * from './tools/ProgrammaticToolCalling';
|
|
19
16
|
export * from './tools/ToolSearch';
|
|
17
|
+
export * from './tools/ToolNode';
|
|
18
|
+
export * from './tools/schema';
|
|
20
19
|
export * from './tools/handlers';
|
|
21
20
|
export * from './tools/search';
|
|
22
21
|
|
|
@@ -11,13 +11,13 @@ config();
|
|
|
11
11
|
import fetch, { RequestInit } from 'node-fetch';
|
|
12
12
|
import { HttpsProxyAgent } from 'https-proxy-agent';
|
|
13
13
|
|
|
14
|
-
const API_KEY = process.env.
|
|
14
|
+
const API_KEY = process.env.CODE_EXECUTOR_API_KEY ?? '';
|
|
15
15
|
const BASE_URL =
|
|
16
|
-
process.env.
|
|
16
|
+
process.env.ILLUMA_CODE_BASEURL ?? 'https://api.illuma.ai/v1';
|
|
17
17
|
const PROXY = process.env.PROXY;
|
|
18
18
|
|
|
19
19
|
if (!API_KEY) {
|
|
20
|
-
console.error('
|
|
20
|
+
console.error('CODE_EXECUTOR_API_KEY not set');
|
|
21
21
|
process.exit(1);
|
|
22
22
|
}
|
|
23
23
|
|
|
@@ -52,7 +52,7 @@ async function makeRequest(
|
|
|
52
52
|
method: body ? 'POST' : 'GET',
|
|
53
53
|
headers: {
|
|
54
54
|
'Content-Type': 'application/json',
|
|
55
|
-
'User-Agent': '
|
|
55
|
+
'User-Agent': 'Illuma/1.0',
|
|
56
56
|
'X-API-Key': API_KEY,
|
|
57
57
|
},
|
|
58
58
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
// src/specs/agent-handoffs.test.ts
|
|
2
|
-
import { z } from 'zod';
|
|
3
2
|
import { DynamicStructuredTool } from '@langchain/core/tools';
|
|
4
3
|
import { HumanMessage, ToolMessage } from '@langchain/core/messages';
|
|
5
4
|
import type { ToolCall } from '@langchain/core/messages/tool';
|
|
@@ -708,7 +707,7 @@ describe('Agent Handoffs Tests', () => {
|
|
|
708
707
|
const customTool = new DynamicStructuredTool({
|
|
709
708
|
name: 'custom_tool',
|
|
710
709
|
description: 'A custom tool',
|
|
711
|
-
schema:
|
|
710
|
+
schema: { type: 'object', properties: {}, required: [] },
|
|
712
711
|
func: async (): Promise<string> => 'Tool result',
|
|
713
712
|
});
|
|
714
713
|
|