illuma-agents 1.0.7 → 1.0.9
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 -5
- package/dist/cjs/common/enum.cjs +1 -2
- package/dist/cjs/common/enum.cjs.map +1 -1
- package/dist/cjs/instrumentation.cjs.map +1 -1
- package/dist/cjs/llm/anthropic/types.cjs.map +1 -1
- package/dist/cjs/llm/anthropic/utils/message_inputs.cjs +79 -2
- package/dist/cjs/llm/anthropic/utils/message_inputs.cjs.map +1 -1
- package/dist/cjs/llm/anthropic/utils/tools.cjs.map +1 -1
- package/dist/cjs/llm/bedrock/index.cjs +99 -0
- package/dist/cjs/llm/bedrock/index.cjs.map +1 -0
- package/dist/cjs/llm/fake.cjs.map +1 -1
- package/dist/cjs/llm/google/index.cjs +78 -9
- package/dist/cjs/llm/google/index.cjs.map +1 -1
- package/dist/cjs/llm/google/utils/common.cjs +185 -28
- package/dist/cjs/llm/google/utils/common.cjs.map +1 -1
- package/dist/cjs/llm/providers.cjs +13 -16
- package/dist/cjs/llm/providers.cjs.map +1 -1
- package/dist/cjs/llm/text.cjs.map +1 -1
- package/dist/cjs/messages/core.cjs +14 -14
- package/dist/cjs/messages/core.cjs.map +1 -1
- package/dist/cjs/messages/ids.cjs.map +1 -1
- package/dist/cjs/messages/prune.cjs.map +1 -1
- package/dist/cjs/run.cjs +10 -1
- package/dist/cjs/run.cjs.map +1 -1
- package/dist/cjs/splitStream.cjs.map +1 -1
- package/dist/cjs/stream.cjs +4 -1
- package/dist/cjs/stream.cjs.map +1 -1
- package/dist/cjs/tools/ToolNode.cjs +163 -55
- package/dist/cjs/tools/ToolNode.cjs.map +1 -1
- package/dist/cjs/tools/handlers.cjs +29 -25
- package/dist/cjs/tools/handlers.cjs.map +1 -1
- package/dist/cjs/tools/search/anthropic.cjs.map +1 -1
- package/dist/cjs/tools/search/content.cjs.map +1 -1
- package/dist/cjs/tools/search/firecrawl.cjs.map +1 -1
- package/dist/cjs/tools/search/format.cjs.map +1 -1
- package/dist/cjs/tools/search/highlights.cjs.map +1 -1
- package/dist/cjs/tools/search/rerankers.cjs.map +1 -1
- package/dist/cjs/tools/search/schema.cjs +25 -25
- package/dist/cjs/tools/search/schema.cjs.map +1 -1
- package/dist/cjs/tools/search/search.cjs +6 -1
- package/dist/cjs/tools/search/search.cjs.map +1 -1
- package/dist/cjs/tools/search/serper-scraper.cjs.map +1 -1
- package/dist/cjs/tools/search/tool.cjs +162 -35
- package/dist/cjs/tools/search/tool.cjs.map +1 -1
- package/dist/cjs/tools/search/utils.cjs.map +1 -1
- package/dist/cjs/utils/graph.cjs.map +1 -1
- package/dist/cjs/utils/llm.cjs +0 -1
- package/dist/cjs/utils/llm.cjs.map +1 -1
- package/dist/cjs/utils/misc.cjs.map +1 -1
- package/dist/cjs/utils/run.cjs.map +1 -1
- package/dist/cjs/utils/title.cjs +7 -7
- package/dist/cjs/utils/title.cjs.map +1 -1
- package/dist/esm/common/enum.mjs +1 -2
- package/dist/esm/common/enum.mjs.map +1 -1
- package/dist/esm/instrumentation.mjs.map +1 -1
- package/dist/esm/llm/anthropic/types.mjs.map +1 -1
- package/dist/esm/llm/anthropic/utils/message_inputs.mjs +79 -2
- package/dist/esm/llm/anthropic/utils/message_inputs.mjs.map +1 -1
- package/dist/esm/llm/anthropic/utils/tools.mjs.map +1 -1
- package/dist/esm/llm/bedrock/index.mjs +97 -0
- package/dist/esm/llm/bedrock/index.mjs.map +1 -0
- package/dist/esm/llm/fake.mjs.map +1 -1
- package/dist/esm/llm/google/index.mjs +79 -10
- package/dist/esm/llm/google/index.mjs.map +1 -1
- package/dist/esm/llm/google/utils/common.mjs +184 -30
- package/dist/esm/llm/google/utils/common.mjs.map +1 -1
- package/dist/esm/llm/providers.mjs +2 -5
- package/dist/esm/llm/providers.mjs.map +1 -1
- package/dist/esm/llm/text.mjs.map +1 -1
- package/dist/esm/messages/core.mjs +14 -14
- package/dist/esm/messages/core.mjs.map +1 -1
- package/dist/esm/messages/ids.mjs.map +1 -1
- package/dist/esm/messages/prune.mjs.map +1 -1
- package/dist/esm/run.mjs +10 -1
- package/dist/esm/run.mjs.map +1 -1
- package/dist/esm/splitStream.mjs.map +1 -1
- package/dist/esm/stream.mjs +4 -1
- package/dist/esm/stream.mjs.map +1 -1
- package/dist/esm/tools/ToolNode.mjs +164 -56
- package/dist/esm/tools/ToolNode.mjs.map +1 -1
- package/dist/esm/tools/handlers.mjs +30 -26
- package/dist/esm/tools/handlers.mjs.map +1 -1
- package/dist/esm/tools/search/anthropic.mjs.map +1 -1
- package/dist/esm/tools/search/content.mjs.map +1 -1
- package/dist/esm/tools/search/firecrawl.mjs.map +1 -1
- package/dist/esm/tools/search/format.mjs.map +1 -1
- package/dist/esm/tools/search/highlights.mjs.map +1 -1
- package/dist/esm/tools/search/rerankers.mjs.map +1 -1
- package/dist/esm/tools/search/schema.mjs +25 -25
- package/dist/esm/tools/search/schema.mjs.map +1 -1
- package/dist/esm/tools/search/search.mjs +6 -1
- package/dist/esm/tools/search/search.mjs.map +1 -1
- package/dist/esm/tools/search/serper-scraper.mjs.map +1 -1
- package/dist/esm/tools/search/tool.mjs +162 -35
- package/dist/esm/tools/search/tool.mjs.map +1 -1
- package/dist/esm/tools/search/utils.mjs.map +1 -1
- package/dist/esm/utils/graph.mjs.map +1 -1
- package/dist/esm/utils/llm.mjs +0 -1
- package/dist/esm/utils/llm.mjs.map +1 -1
- package/dist/esm/utils/misc.mjs.map +1 -1
- package/dist/esm/utils/run.mjs.map +1 -1
- package/dist/esm/utils/title.mjs +7 -7
- package/dist/esm/utils/title.mjs.map +1 -1
- package/dist/types/common/enum.d.ts +1 -2
- package/dist/types/llm/bedrock/index.d.ts +36 -0
- package/dist/types/llm/google/index.d.ts +10 -0
- package/dist/types/llm/google/types.d.ts +11 -1
- package/dist/types/llm/google/utils/common.d.ts +17 -2
- package/dist/types/tools/ToolNode.d.ts +9 -1
- package/dist/types/tools/search/types.d.ts +2 -0
- package/dist/types/types/llm.d.ts +3 -8
- package/dist/types/types/tools.d.ts +1 -1
- package/package.json +15 -11
- package/src/common/enum.ts +1 -2
- package/src/common/index.ts +1 -1
- package/src/instrumentation.ts +22 -22
- package/src/llm/anthropic/llm.spec.ts +1442 -1442
- package/src/llm/anthropic/types.ts +140 -140
- package/src/llm/anthropic/utils/message_inputs.ts +757 -660
- package/src/llm/anthropic/utils/output_parsers.ts +133 -133
- package/src/llm/anthropic/utils/tools.ts +29 -29
- package/src/llm/bedrock/index.ts +128 -0
- package/src/llm/fake.ts +133 -133
- package/src/llm/google/data/gettysburg10.wav +0 -0
- package/src/llm/google/data/hotdog.jpg +0 -0
- package/src/llm/google/index.ts +129 -14
- package/src/llm/google/llm.spec.ts +932 -0
- package/src/llm/google/types.ts +56 -43
- package/src/llm/google/utils/common.ts +873 -660
- package/src/llm/google/utils/tools.ts +160 -160
- package/src/llm/openai/types.ts +24 -24
- package/src/llm/openai/utils/isReasoningModel.test.ts +90 -90
- package/src/llm/providers.ts +2 -7
- package/src/llm/text.ts +94 -94
- package/src/messages/core.ts +463 -463
- package/src/messages/formatAgentMessages.tools.test.ts +400 -400
- package/src/messages/formatMessage.test.ts +693 -693
- package/src/messages/ids.ts +26 -26
- package/src/messages/prune.ts +567 -567
- package/src/messages/shiftIndexTokenCountMap.test.ts +81 -81
- package/src/mockStream.ts +98 -98
- package/src/prompts/collab.ts +5 -5
- package/src/prompts/index.ts +1 -1
- package/src/prompts/taskmanager.ts +61 -61
- package/src/run.ts +13 -4
- package/src/scripts/ant_web_search_edge_case.ts +162 -0
- package/src/scripts/ant_web_search_error_edge_case.ts +148 -0
- package/src/scripts/args.ts +48 -48
- package/src/scripts/caching.ts +123 -123
- package/src/scripts/code_exec_files.ts +193 -193
- package/src/scripts/empty_input.ts +137 -137
- package/src/scripts/image.ts +178 -178
- package/src/scripts/memory.ts +97 -97
- package/src/scripts/thinking.ts +149 -149
- package/src/specs/anthropic.simple.test.ts +67 -0
- package/src/specs/spec.utils.ts +3 -3
- package/src/specs/token-distribution-edge-case.test.ts +316 -316
- package/src/specs/tool-error.test.ts +193 -193
- package/src/splitStream.test.ts +691 -691
- package/src/splitStream.ts +234 -234
- package/src/stream.test.ts +94 -94
- package/src/stream.ts +4 -1
- package/src/tools/ToolNode.ts +206 -64
- package/src/tools/handlers.ts +32 -28
- package/src/tools/search/anthropic.ts +51 -51
- package/src/tools/search/content.test.ts +173 -173
- package/src/tools/search/content.ts +147 -147
- package/src/tools/search/direct-url.test.ts +530 -0
- package/src/tools/search/firecrawl.ts +210 -210
- package/src/tools/search/format.ts +250 -250
- package/src/tools/search/highlights.ts +320 -320
- package/src/tools/search/index.ts +2 -2
- package/src/tools/search/jina-reranker.test.ts +126 -126
- package/src/tools/search/output.md +2775 -2775
- package/src/tools/search/rerankers.ts +242 -242
- package/src/tools/search/schema.ts +63 -63
- package/src/tools/search/search.ts +766 -759
- package/src/tools/search/serper-scraper.ts +155 -155
- package/src/tools/search/test.html +883 -883
- package/src/tools/search/test.md +642 -642
- package/src/tools/search/test.ts +159 -159
- package/src/tools/search/tool.ts +619 -471
- package/src/tools/search/types.ts +689 -687
- package/src/tools/search/utils.ts +79 -79
- package/src/types/index.ts +6 -6
- package/src/types/llm.ts +2 -8
- package/src/types/tools.ts +80 -80
- package/src/utils/graph.ts +10 -10
- package/src/utils/llm.ts +26 -27
- package/src/utils/llmConfig.ts +5 -3
- package/src/utils/logging.ts +48 -48
- package/src/utils/misc.ts +57 -57
- package/src/utils/run.ts +100 -100
- package/src/utils/title.ts +165 -165
- package/dist/cjs/llm/ollama/index.cjs +0 -70
- package/dist/cjs/llm/ollama/index.cjs.map +0 -1
- package/dist/cjs/llm/ollama/utils.cjs +0 -158
- package/dist/cjs/llm/ollama/utils.cjs.map +0 -1
- package/dist/esm/llm/ollama/index.mjs +0 -68
- package/dist/esm/llm/ollama/index.mjs.map +0 -1
- package/dist/esm/llm/ollama/utils.mjs +0 -155
- package/dist/esm/llm/ollama/utils.mjs.map +0 -1
- package/dist/types/llm/ollama/index.d.ts +0 -8
- package/dist/types/llm/ollama/utils.d.ts +0 -7
- package/src/llm/ollama/index.ts +0 -92
- package/src/llm/ollama/utils.ts +0 -193
- package/src/proto/CollabGraph.ts +0 -269
- package/src/proto/TaskManager.ts +0 -243
- package/src/proto/collab.ts +0 -200
- package/src/proto/collab_design.ts +0 -184
- package/src/proto/collab_design_v2.ts +0 -224
- package/src/proto/collab_design_v3.ts +0 -255
- package/src/proto/collab_design_v4.ts +0 -220
- package/src/proto/collab_design_v5.ts +0 -251
- package/src/proto/collab_graph.ts +0 -181
- package/src/proto/collab_original.ts +0 -123
- package/src/proto/example.ts +0 -93
- package/src/proto/example_new.ts +0 -68
- package/src/proto/example_old.ts +0 -201
- package/src/proto/example_test.ts +0 -152
- package/src/proto/example_test_anthropic.ts +0 -100
- package/src/proto/log_stream.ts +0 -202
- package/src/proto/main_collab_community_event.ts +0 -133
- package/src/proto/main_collab_design_v2.ts +0 -96
- package/src/proto/main_collab_design_v4.ts +0 -100
- package/src/proto/main_collab_design_v5.ts +0 -135
- package/src/proto/main_collab_global_analysis.ts +0 -122
- package/src/proto/main_collab_hackathon_event.ts +0 -153
- package/src/proto/main_collab_space_mission.ts +0 -153
- package/src/proto/main_philosophy.ts +0 -210
- package/src/proto/original_script.ts +0 -126
- package/src/proto/standard.ts +0 -100
- package/src/proto/stream.ts +0 -56
- package/src/proto/tasks.ts +0 -118
- package/src/proto/tools/global_analysis_tools.ts +0 -86
- package/src/proto/tools/space_mission_tools.ts +0 -60
- package/src/proto/vertexai.ts +0 -54
|
@@ -1,79 +1,79 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
|
-
|
|
3
|
-
import type * as t from './types';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Singleton instance of the default logger
|
|
7
|
-
*/
|
|
8
|
-
let defaultLoggerInstance: t.Logger | null = null;
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Creates a default logger that maps to console methods
|
|
12
|
-
* Uses a singleton pattern to avoid creating multiple instances
|
|
13
|
-
* @returns A default logger that implements the Logger interface
|
|
14
|
-
*/
|
|
15
|
-
export const createDefaultLogger = (): t.Logger => {
|
|
16
|
-
if (!defaultLoggerInstance) {
|
|
17
|
-
defaultLoggerInstance = {
|
|
18
|
-
error: console.error,
|
|
19
|
-
warn: console.warn,
|
|
20
|
-
info: console.info,
|
|
21
|
-
debug: console.debug,
|
|
22
|
-
} as t.Logger;
|
|
23
|
-
}
|
|
24
|
-
return defaultLoggerInstance;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export const fileExtRegex =
|
|
28
|
-
/\.(pdf|jpe?g|png|gif|svg|webp|bmp|ico|tiff?|avif|heic|doc[xm]?|xls[xm]?|ppt[xm]?|zip|rar|mp[34]|mov|avi|wav)(?:\?.*)?$/i;
|
|
29
|
-
|
|
30
|
-
export const getDomainName = (
|
|
31
|
-
link: string,
|
|
32
|
-
metadata?: t.ScrapeMetadata,
|
|
33
|
-
logger?: t.Logger
|
|
34
|
-
): string | undefined => {
|
|
35
|
-
try {
|
|
36
|
-
const url = metadata?.sourceURL ?? metadata?.url ?? (link || '');
|
|
37
|
-
const domain = new URL(url).hostname.replace(/^www\./, '');
|
|
38
|
-
if (domain) {
|
|
39
|
-
return domain;
|
|
40
|
-
}
|
|
41
|
-
} catch (e) {
|
|
42
|
-
// URL parsing failed
|
|
43
|
-
if (logger) {
|
|
44
|
-
logger.error('Error parsing URL:', e);
|
|
45
|
-
} else {
|
|
46
|
-
console.error('Error parsing URL:', e);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return;
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
export function getAttribution(
|
|
54
|
-
link: string,
|
|
55
|
-
metadata?: t.ScrapeMetadata,
|
|
56
|
-
logger?: t.Logger
|
|
57
|
-
): string | undefined {
|
|
58
|
-
if (!metadata) return getDomainName(link, metadata, logger);
|
|
59
|
-
|
|
60
|
-
const twitterSite = metadata['twitter:site'];
|
|
61
|
-
const twitterSiteFormatted =
|
|
62
|
-
typeof twitterSite === 'string' ? twitterSite.replace(/^@/, '') : undefined;
|
|
63
|
-
|
|
64
|
-
const possibleAttributions = [
|
|
65
|
-
metadata.ogSiteName,
|
|
66
|
-
metadata['og:site_name'],
|
|
67
|
-
metadata.title?.split('|').pop()?.trim(),
|
|
68
|
-
twitterSiteFormatted,
|
|
69
|
-
];
|
|
70
|
-
|
|
71
|
-
const attribution = possibleAttributions.find(
|
|
72
|
-
(attr) => attr != null && typeof attr === 'string' && attr.trim() !== ''
|
|
73
|
-
);
|
|
74
|
-
if (attribution != null) {
|
|
75
|
-
return attribution;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return getDomainName(link, metadata, logger);
|
|
79
|
-
}
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
|
|
3
|
+
import type * as t from './types';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Singleton instance of the default logger
|
|
7
|
+
*/
|
|
8
|
+
let defaultLoggerInstance: t.Logger | null = null;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Creates a default logger that maps to console methods
|
|
12
|
+
* Uses a singleton pattern to avoid creating multiple instances
|
|
13
|
+
* @returns A default logger that implements the Logger interface
|
|
14
|
+
*/
|
|
15
|
+
export const createDefaultLogger = (): t.Logger => {
|
|
16
|
+
if (!defaultLoggerInstance) {
|
|
17
|
+
defaultLoggerInstance = {
|
|
18
|
+
error: console.error,
|
|
19
|
+
warn: console.warn,
|
|
20
|
+
info: console.info,
|
|
21
|
+
debug: console.debug,
|
|
22
|
+
} as t.Logger;
|
|
23
|
+
}
|
|
24
|
+
return defaultLoggerInstance;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const fileExtRegex =
|
|
28
|
+
/\.(pdf|jpe?g|png|gif|svg|webp|bmp|ico|tiff?|avif|heic|doc[xm]?|xls[xm]?|ppt[xm]?|zip|rar|mp[34]|mov|avi|wav)(?:\?.*)?$/i;
|
|
29
|
+
|
|
30
|
+
export const getDomainName = (
|
|
31
|
+
link: string,
|
|
32
|
+
metadata?: t.ScrapeMetadata,
|
|
33
|
+
logger?: t.Logger
|
|
34
|
+
): string | undefined => {
|
|
35
|
+
try {
|
|
36
|
+
const url = metadata?.sourceURL ?? metadata?.url ?? (link || '');
|
|
37
|
+
const domain = new URL(url).hostname.replace(/^www\./, '');
|
|
38
|
+
if (domain) {
|
|
39
|
+
return domain;
|
|
40
|
+
}
|
|
41
|
+
} catch (e) {
|
|
42
|
+
// URL parsing failed
|
|
43
|
+
if (logger) {
|
|
44
|
+
logger.error('Error parsing URL:', e);
|
|
45
|
+
} else {
|
|
46
|
+
console.error('Error parsing URL:', e);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export function getAttribution(
|
|
54
|
+
link: string,
|
|
55
|
+
metadata?: t.ScrapeMetadata,
|
|
56
|
+
logger?: t.Logger
|
|
57
|
+
): string | undefined {
|
|
58
|
+
if (!metadata) return getDomainName(link, metadata, logger);
|
|
59
|
+
|
|
60
|
+
const twitterSite = metadata['twitter:site'];
|
|
61
|
+
const twitterSiteFormatted =
|
|
62
|
+
typeof twitterSite === 'string' ? twitterSite.replace(/^@/, '') : undefined;
|
|
63
|
+
|
|
64
|
+
const possibleAttributions = [
|
|
65
|
+
metadata.ogSiteName,
|
|
66
|
+
metadata['og:site_name'],
|
|
67
|
+
metadata.title?.split('|').pop()?.trim(),
|
|
68
|
+
twitterSiteFormatted,
|
|
69
|
+
];
|
|
70
|
+
|
|
71
|
+
const attribution = possibleAttributions.find(
|
|
72
|
+
(attr) => attr != null && typeof attr === 'string' && attr.trim() !== ''
|
|
73
|
+
);
|
|
74
|
+
if (attribution != null) {
|
|
75
|
+
return attribution;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return getDomainName(link, metadata, logger);
|
|
79
|
+
}
|
package/src/types/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
// src/types/index.ts
|
|
2
|
-
export * from './graph';
|
|
3
|
-
export * from './llm';
|
|
4
|
-
export * from './run';
|
|
5
|
-
export * from './stream';
|
|
6
|
-
export * from './tools';
|
|
1
|
+
// src/types/index.ts
|
|
2
|
+
export * from './graph';
|
|
3
|
+
export * from './llm';
|
|
4
|
+
export * from './run';
|
|
5
|
+
export * from './stream';
|
|
6
|
+
export * from './tools';
|
package/src/types/llm.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
// src/types/llm.ts
|
|
2
|
-
import { ChatOllama } from '@langchain/ollama';
|
|
3
2
|
import { ChatMistralAI } from '@langchain/mistralai';
|
|
4
|
-
import { ChatBedrockConverse } from '@langchain/aws';
|
|
5
3
|
import type {
|
|
6
4
|
BindToolsInput,
|
|
7
5
|
BaseChatModelParams,
|
|
@@ -23,7 +21,6 @@ import type { RequestOptions } from '@google/generative-ai';
|
|
|
23
21
|
import type { StructuredTool } from '@langchain/core/tools';
|
|
24
22
|
import type { AnthropicInput } from '@langchain/anthropic';
|
|
25
23
|
import type { Runnable } from '@langchain/core/runnables';
|
|
26
|
-
import type { ChatOllamaInput } from '@langchain/ollama';
|
|
27
24
|
import type { OpenAI as OpenAIClient } from 'openai';
|
|
28
25
|
import type { ChatXAIInput } from '@langchain/xai';
|
|
29
26
|
import {
|
|
@@ -33,6 +30,7 @@ import {
|
|
|
33
30
|
ChatXAI,
|
|
34
31
|
} from '@/llm/openai';
|
|
35
32
|
import { CustomChatGoogleGenerativeAI } from '@/llm/google';
|
|
33
|
+
import { CustomChatBedrockConverse } from '@/llm/bedrock';
|
|
36
34
|
import { CustomAnthropic } from '@/llm/anthropic';
|
|
37
35
|
import { ChatOpenRouter } from '@/llm/openrouter';
|
|
38
36
|
import { ChatVertexAI } from '@/llm/vertexai';
|
|
@@ -57,7 +55,6 @@ export type AnthropicReasoning = {
|
|
|
57
55
|
thinkingBudget?: number;
|
|
58
56
|
};
|
|
59
57
|
export type OpenAIClientOptions = ChatOpenAIFields;
|
|
60
|
-
export type OllamaClientOptions = ChatOllamaInput;
|
|
61
58
|
export type AnthropicClientOptions = AnthropicInput;
|
|
62
59
|
export type MistralAIClientOptions = ChatMistralAIInput;
|
|
63
60
|
export type VertexAIClientOptions = ChatVertexAIInput & {
|
|
@@ -80,7 +77,6 @@ export type XAIClientOptions = ChatXAIInput;
|
|
|
80
77
|
export type ClientOptions =
|
|
81
78
|
| OpenAIClientOptions
|
|
82
79
|
| AzureClientOptions
|
|
83
|
-
| OllamaClientOptions
|
|
84
80
|
| AnthropicClientOptions
|
|
85
81
|
| MistralAIClientOptions
|
|
86
82
|
| VertexAIClientOptions
|
|
@@ -103,7 +99,6 @@ export type LLMConfig = SharedLLMConfig &
|
|
|
103
99
|
export type ProviderOptionsMap = {
|
|
104
100
|
[Providers.AZURE]: AzureClientOptions;
|
|
105
101
|
[Providers.OPENAI]: OpenAIClientOptions;
|
|
106
|
-
[Providers.OLLAMA]: OllamaClientOptions;
|
|
107
102
|
[Providers.GOOGLE]: GoogleClientOptions;
|
|
108
103
|
[Providers.VERTEXAI]: VertexAIClientOptions;
|
|
109
104
|
[Providers.DEEPSEEK]: DeepSeekClientOptions;
|
|
@@ -118,7 +113,6 @@ export type ProviderOptionsMap = {
|
|
|
118
113
|
export type ChatModelMap = {
|
|
119
114
|
[Providers.XAI]: ChatXAI;
|
|
120
115
|
[Providers.OPENAI]: ChatOpenAI;
|
|
121
|
-
[Providers.OLLAMA]: ChatOllama;
|
|
122
116
|
[Providers.AZURE]: AzureChatOpenAI;
|
|
123
117
|
[Providers.DEEPSEEK]: ChatDeepSeek;
|
|
124
118
|
[Providers.VERTEXAI]: ChatVertexAI;
|
|
@@ -126,7 +120,7 @@ export type ChatModelMap = {
|
|
|
126
120
|
[Providers.MISTRALAI]: ChatMistralAI;
|
|
127
121
|
[Providers.MISTRAL]: ChatMistralAI;
|
|
128
122
|
[Providers.OPENROUTER]: ChatOpenRouter;
|
|
129
|
-
[Providers.BEDROCK]:
|
|
123
|
+
[Providers.BEDROCK]: CustomChatBedrockConverse;
|
|
130
124
|
[Providers.GOOGLE]: CustomChatGoogleGenerativeAI;
|
|
131
125
|
};
|
|
132
126
|
|
package/src/types/tools.ts
CHANGED
|
@@ -1,80 +1,80 @@
|
|
|
1
|
-
// src/types/tools.ts
|
|
2
|
-
import type { StructuredToolInterface } from '@langchain/core/tools';
|
|
3
|
-
import type { RunnableToolLike } from '@langchain/core/runnables';
|
|
4
|
-
import type { ToolCall } from '@langchain/core/messages/tool';
|
|
5
|
-
import type { ToolErrorData } from './stream';
|
|
6
|
-
import { EnvVar } from '@/common';
|
|
7
|
-
|
|
8
|
-
/** Replacement type for `import type { ToolCall } from '@langchain/core/messages/tool'` in order to have stringified args typed */
|
|
9
|
-
export type CustomToolCall = {
|
|
10
|
-
name: string;
|
|
11
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
|
-
args: string | Record<string, any>;
|
|
13
|
-
id?: string;
|
|
14
|
-
type?: 'tool_call';
|
|
15
|
-
output?: string;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export type GenericTool = StructuredToolInterface | RunnableToolLike;
|
|
19
|
-
|
|
20
|
-
export type ToolMap = Map<string, GenericTool>;
|
|
21
|
-
export type ToolRefs = {
|
|
22
|
-
tools: GenericTool[];
|
|
23
|
-
toolMap?: ToolMap;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export type ToolRefGenerator = (tool_calls: ToolCall[]) => ToolRefs;
|
|
27
|
-
|
|
28
|
-
export type ToolNodeOptions = {
|
|
29
|
-
name?: string;
|
|
30
|
-
tags?: string[];
|
|
31
|
-
handleToolErrors?: boolean;
|
|
32
|
-
loadRuntimeTools?: ToolRefGenerator;
|
|
33
|
-
toolCallStepIds?: Map<string, string>;
|
|
34
|
-
errorHandler?: (
|
|
35
|
-
data: ToolErrorData,
|
|
36
|
-
metadata?: Record<string, unknown>
|
|
37
|
-
) => void
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export type ToolNodeConstructorParams = ToolRefs & ToolNodeOptions;
|
|
41
|
-
|
|
42
|
-
export type ToolEndEvent = {
|
|
43
|
-
/** The Step Id of the Tool Call */
|
|
44
|
-
id: string;
|
|
45
|
-
/** The Completed Tool Call */
|
|
46
|
-
tool_call: ToolCall;
|
|
47
|
-
/** The content index of the tool call */
|
|
48
|
-
index: number;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export type CodeEnvFile = {
|
|
52
|
-
id: string;
|
|
53
|
-
name: string;
|
|
54
|
-
session_id: string;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
export type CodeExecutionToolParams =
|
|
58
|
-
| undefined
|
|
59
|
-
| {
|
|
60
|
-
session_id?: string;
|
|
61
|
-
user_id?: string;
|
|
62
|
-
apiKey?: string;
|
|
63
|
-
files?: CodeEnvFile[];
|
|
64
|
-
[EnvVar.CODE_API_KEY]?: string;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
export type FileRef = {
|
|
68
|
-
id: string;
|
|
69
|
-
name: string;
|
|
70
|
-
path?: string;
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
export type FileRefs = FileRef[];
|
|
74
|
-
|
|
75
|
-
export type ExecuteResult = {
|
|
76
|
-
session_id: string;
|
|
77
|
-
stdout: string;
|
|
78
|
-
stderr: string;
|
|
79
|
-
files?: FileRefs;
|
|
80
|
-
};
|
|
1
|
+
// src/types/tools.ts
|
|
2
|
+
import type { StructuredToolInterface } from '@langchain/core/tools';
|
|
3
|
+
import type { RunnableToolLike } from '@langchain/core/runnables';
|
|
4
|
+
import type { ToolCall } from '@langchain/core/messages/tool';
|
|
5
|
+
import type { ToolErrorData } from './stream';
|
|
6
|
+
import { EnvVar } from '@/common';
|
|
7
|
+
|
|
8
|
+
/** Replacement type for `import type { ToolCall } from '@langchain/core/messages/tool'` in order to have stringified args typed */
|
|
9
|
+
export type CustomToolCall = {
|
|
10
|
+
name: string;
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
12
|
+
args: string | Record<string, any>;
|
|
13
|
+
id?: string;
|
|
14
|
+
type?: 'tool_call';
|
|
15
|
+
output?: string;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type GenericTool = StructuredToolInterface | RunnableToolLike;
|
|
19
|
+
|
|
20
|
+
export type ToolMap = Map<string, GenericTool>;
|
|
21
|
+
export type ToolRefs = {
|
|
22
|
+
tools: GenericTool[];
|
|
23
|
+
toolMap?: ToolMap;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export type ToolRefGenerator = (tool_calls: ToolCall[]) => ToolRefs;
|
|
27
|
+
|
|
28
|
+
export type ToolNodeOptions = {
|
|
29
|
+
name?: string;
|
|
30
|
+
tags?: string[];
|
|
31
|
+
handleToolErrors?: boolean;
|
|
32
|
+
loadRuntimeTools?: ToolRefGenerator;
|
|
33
|
+
toolCallStepIds?: Map<string, string>;
|
|
34
|
+
errorHandler?: (
|
|
35
|
+
data: ToolErrorData,
|
|
36
|
+
metadata?: Record<string, unknown>
|
|
37
|
+
) => Promise<void>;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export type ToolNodeConstructorParams = ToolRefs & ToolNodeOptions;
|
|
41
|
+
|
|
42
|
+
export type ToolEndEvent = {
|
|
43
|
+
/** The Step Id of the Tool Call */
|
|
44
|
+
id: string;
|
|
45
|
+
/** The Completed Tool Call */
|
|
46
|
+
tool_call: ToolCall;
|
|
47
|
+
/** The content index of the tool call */
|
|
48
|
+
index: number;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export type CodeEnvFile = {
|
|
52
|
+
id: string;
|
|
53
|
+
name: string;
|
|
54
|
+
session_id: string;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export type CodeExecutionToolParams =
|
|
58
|
+
| undefined
|
|
59
|
+
| {
|
|
60
|
+
session_id?: string;
|
|
61
|
+
user_id?: string;
|
|
62
|
+
apiKey?: string;
|
|
63
|
+
files?: CodeEnvFile[];
|
|
64
|
+
[EnvVar.CODE_API_KEY]?: string;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export type FileRef = {
|
|
68
|
+
id: string;
|
|
69
|
+
name: string;
|
|
70
|
+
path?: string;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export type FileRefs = FileRef[];
|
|
74
|
+
|
|
75
|
+
export type ExecuteResult = {
|
|
76
|
+
session_id: string;
|
|
77
|
+
stdout: string;
|
|
78
|
+
stderr: string;
|
|
79
|
+
files?: FileRefs;
|
|
80
|
+
};
|
package/src/utils/graph.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export const resetIfNotEmpty = <T>(value: T, resetValue: T): T => {
|
|
2
|
-
if (Array.isArray(value)) {
|
|
3
|
-
return value.length > 0 ? resetValue : value;
|
|
4
|
-
}
|
|
5
|
-
if (value instanceof Set || value instanceof Map) {
|
|
6
|
-
return value.size > 0 ? resetValue : value;
|
|
7
|
-
}
|
|
8
|
-
return value !== undefined ? resetValue : value;
|
|
9
|
-
};
|
|
10
|
-
|
|
1
|
+
export const resetIfNotEmpty = <T>(value: T, resetValue: T): T => {
|
|
2
|
+
if (Array.isArray(value)) {
|
|
3
|
+
return value.length > 0 ? resetValue : value;
|
|
4
|
+
}
|
|
5
|
+
if (value instanceof Set || value instanceof Map) {
|
|
6
|
+
return value.size > 0 ? resetValue : value;
|
|
7
|
+
}
|
|
8
|
+
return value !== undefined ? resetValue : value;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
11
|
export const joinKeys = (args: (string | number | undefined)[]): string => args.join('_');
|
package/src/utils/llm.ts
CHANGED
|
@@ -1,27 +1,26 @@
|
|
|
1
|
-
// src/utils/llm.ts
|
|
2
|
-
import { Providers } from '@/common';
|
|
3
|
-
|
|
4
|
-
export function isOpenAILike(provider?: string | Providers): boolean {
|
|
5
|
-
if (provider == null) {
|
|
6
|
-
return false;
|
|
7
|
-
}
|
|
8
|
-
return (
|
|
9
|
-
[
|
|
10
|
-
Providers.OPENAI,
|
|
11
|
-
Providers.AZURE,
|
|
12
|
-
Providers.OPENROUTER,
|
|
13
|
-
Providers.XAI,
|
|
14
|
-
Providers.DEEPSEEK,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
1
|
+
// src/utils/llm.ts
|
|
2
|
+
import { Providers } from '@/common';
|
|
3
|
+
|
|
4
|
+
export function isOpenAILike(provider?: string | Providers): boolean {
|
|
5
|
+
if (provider == null) {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
return (
|
|
9
|
+
[
|
|
10
|
+
Providers.OPENAI,
|
|
11
|
+
Providers.AZURE,
|
|
12
|
+
Providers.OPENROUTER,
|
|
13
|
+
Providers.XAI,
|
|
14
|
+
Providers.DEEPSEEK,
|
|
15
|
+
] as string[]
|
|
16
|
+
).includes(provider);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function isGoogleLike(provider?: string | Providers): boolean {
|
|
20
|
+
if (provider == null) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
return ([Providers.GOOGLE, Providers.VERTEXAI] as string[]).includes(
|
|
24
|
+
provider
|
|
25
|
+
);
|
|
26
|
+
}
|
package/src/utils/llmConfig.ts
CHANGED
|
@@ -78,12 +78,14 @@ export const llmConfigs: Record<string, t.LLMConfig | undefined> = {
|
|
|
78
78
|
azureOpenAIApiVersion: process.env.AZURE_OPENAI_API_VERSION,
|
|
79
79
|
model: process.env.AZURE_MODEL_NAME ?? 'gpt-4o',
|
|
80
80
|
},
|
|
81
|
-
|
|
82
|
-
provider: Providers.
|
|
81
|
+
ollama: {
|
|
82
|
+
provider: Providers.OPENAI,
|
|
83
83
|
model: 'gpt-oss:20b',
|
|
84
84
|
streaming: true,
|
|
85
85
|
streamUsage: true,
|
|
86
|
-
|
|
86
|
+
configuration: {
|
|
87
|
+
baseURL: 'http://localhost:11434/v1',
|
|
88
|
+
},
|
|
87
89
|
},
|
|
88
90
|
lmstudio: {
|
|
89
91
|
provider: Providers.OPENAI,
|
package/src/utils/logging.ts
CHANGED
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
// src/utils/logging.ts
|
|
2
|
-
import fs from 'fs';
|
|
3
|
-
import util from 'util';
|
|
4
|
-
|
|
5
|
-
export function setupLogging(logFileName: string): void {
|
|
6
|
-
const logFile = fs.createWriteStream(logFileName, { flags: 'a' });
|
|
7
|
-
|
|
8
|
-
const originalConsoleLog = console.log;
|
|
9
|
-
const originalConsoleError = console.error;
|
|
10
|
-
const originalStdoutWrite = process.stdout.write;
|
|
11
|
-
const originalStderrWrite = process.stderr.write;
|
|
12
|
-
|
|
13
|
-
console.log = function(...args): void {
|
|
14
|
-
logFile.write(util.format.apply(null, args) + ' ');
|
|
15
|
-
originalConsoleLog.apply(console, args);
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
console.error = function(...args): void {
|
|
19
|
-
logFile.write(util.format.apply(null, args) + ' ');
|
|
20
|
-
originalConsoleError.apply(console, args);
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
process.stdout.write = function(
|
|
24
|
-
buffer: Uint8Array | string,
|
|
25
|
-
cb?: ((err?: Error) => void) | string,
|
|
26
|
-
fd?: ((err?: Error) => void)
|
|
27
|
-
): boolean {
|
|
28
|
-
if (typeof buffer === 'string') {
|
|
29
|
-
logFile.write(buffer);
|
|
30
|
-
} else {
|
|
31
|
-
logFile.write(buffer.toString());
|
|
32
|
-
}
|
|
33
|
-
return originalStdoutWrite.call(process.stdout, buffer, cb as BufferEncoding | undefined, fd);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
process.stderr.write = function(
|
|
37
|
-
buffer: Uint8Array | string,
|
|
38
|
-
cb?: ((err?: Error) => void) | string,
|
|
39
|
-
fd?: ((err?: Error) => void)
|
|
40
|
-
): boolean {
|
|
41
|
-
if (typeof buffer === 'string') {
|
|
42
|
-
logFile.write(buffer);
|
|
43
|
-
} else {
|
|
44
|
-
logFile.write(buffer.toString());
|
|
45
|
-
}
|
|
46
|
-
return originalStderrWrite.call(process.stderr, buffer, cb as BufferEncoding | undefined, fd);
|
|
47
|
-
};
|
|
48
|
-
}
|
|
1
|
+
// src/utils/logging.ts
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import util from 'util';
|
|
4
|
+
|
|
5
|
+
export function setupLogging(logFileName: string): void {
|
|
6
|
+
const logFile = fs.createWriteStream(logFileName, { flags: 'a' });
|
|
7
|
+
|
|
8
|
+
const originalConsoleLog = console.log;
|
|
9
|
+
const originalConsoleError = console.error;
|
|
10
|
+
const originalStdoutWrite = process.stdout.write;
|
|
11
|
+
const originalStderrWrite = process.stderr.write;
|
|
12
|
+
|
|
13
|
+
console.log = function(...args): void {
|
|
14
|
+
logFile.write(util.format.apply(null, args) + ' ');
|
|
15
|
+
originalConsoleLog.apply(console, args);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
console.error = function(...args): void {
|
|
19
|
+
logFile.write(util.format.apply(null, args) + ' ');
|
|
20
|
+
originalConsoleError.apply(console, args);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
process.stdout.write = function(
|
|
24
|
+
buffer: Uint8Array | string,
|
|
25
|
+
cb?: ((err?: Error) => void) | string,
|
|
26
|
+
fd?: ((err?: Error) => void)
|
|
27
|
+
): boolean {
|
|
28
|
+
if (typeof buffer === 'string') {
|
|
29
|
+
logFile.write(buffer);
|
|
30
|
+
} else {
|
|
31
|
+
logFile.write(buffer.toString());
|
|
32
|
+
}
|
|
33
|
+
return originalStdoutWrite.call(process.stdout, buffer, cb as BufferEncoding | undefined, fd);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
process.stderr.write = function(
|
|
37
|
+
buffer: Uint8Array | string,
|
|
38
|
+
cb?: ((err?: Error) => void) | string,
|
|
39
|
+
fd?: ((err?: Error) => void)
|
|
40
|
+
): boolean {
|
|
41
|
+
if (typeof buffer === 'string') {
|
|
42
|
+
logFile.write(buffer);
|
|
43
|
+
} else {
|
|
44
|
+
logFile.write(buffer.toString());
|
|
45
|
+
}
|
|
46
|
+
return originalStderrWrite.call(process.stderr, buffer, cb as BufferEncoding | undefined, fd);
|
|
47
|
+
};
|
|
48
|
+
}
|