praisonai 1.3.4 → 1.3.6
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/agent/context.d.ts +6 -0
- package/dist/agent/context.js +24 -3
- package/dist/agent/enhanced.d.ts +6 -0
- package/dist/agent/enhanced.js +32 -6
- package/dist/agent/image.d.ts +6 -0
- package/dist/agent/image.js +28 -5
- package/dist/agent/prompt-expander.d.ts +3 -0
- package/dist/agent/prompt-expander.js +18 -3
- package/dist/agent/query-rewriter.d.ts +3 -0
- package/dist/agent/query-rewriter.js +18 -3
- package/dist/agent/research.d.ts +3 -0
- package/dist/agent/research.js +20 -4
- package/dist/agent/simple.d.ts +39 -1
- package/dist/agent/simple.js +145 -5
- package/dist/auto/index.d.ts +6 -0
- package/dist/auto/index.js +24 -3
- package/dist/cli/commands/benchmark.d.ts +19 -0
- package/dist/cli/commands/benchmark.js +484 -0
- package/dist/cli/commands/chat.js +2 -2
- package/dist/cli/commands/embed.d.ts +20 -0
- package/dist/cli/commands/embed.js +366 -0
- package/dist/cli/spec/cli-spec.js +32 -0
- package/dist/guardrails/llm-guardrail.d.ts +6 -0
- package/dist/guardrails/llm-guardrail.js +24 -3
- package/dist/llm/backend-resolver.d.ts +77 -0
- package/dist/llm/backend-resolver.js +242 -0
- package/dist/llm/embeddings.d.ts +66 -0
- package/dist/llm/embeddings.js +294 -0
- package/dist/llm/index.d.ts +2 -0
- package/dist/llm/index.js +19 -1
- package/package.json +1 -1
package/dist/agent/context.d.ts
CHANGED
|
@@ -24,12 +24,18 @@ export declare class ContextAgent {
|
|
|
24
24
|
readonly name: string;
|
|
25
25
|
readonly instructions: string;
|
|
26
26
|
private provider;
|
|
27
|
+
private providerPromise;
|
|
28
|
+
private llmModel;
|
|
27
29
|
private knowledgeBase?;
|
|
28
30
|
private contextWindow;
|
|
29
31
|
private maxContextTokens;
|
|
30
32
|
private messages;
|
|
31
33
|
private verbose;
|
|
32
34
|
constructor(config: ContextAgentConfig);
|
|
35
|
+
/**
|
|
36
|
+
* Get the LLM provider (lazy initialization with AI SDK backend)
|
|
37
|
+
*/
|
|
38
|
+
private getProvider;
|
|
33
39
|
/**
|
|
34
40
|
* Chat with context awareness
|
|
35
41
|
*/
|
package/dist/agent/context.js
CHANGED
|
@@ -5,21 +5,41 @@
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.ContextAgent = void 0;
|
|
7
7
|
exports.createContextAgent = createContextAgent;
|
|
8
|
-
const
|
|
8
|
+
const backend_resolver_1 = require("../llm/backend-resolver");
|
|
9
9
|
/**
|
|
10
10
|
* Context Agent - Agent with RAG and context management
|
|
11
11
|
*/
|
|
12
12
|
class ContextAgent {
|
|
13
13
|
constructor(config) {
|
|
14
|
+
this.provider = null;
|
|
15
|
+
this.providerPromise = null;
|
|
14
16
|
this.messages = [];
|
|
15
17
|
this.name = config.name || `ContextAgent_${Math.random().toString(36).substr(2, 9)}`;
|
|
16
18
|
this.instructions = config.instructions;
|
|
17
|
-
this.
|
|
19
|
+
this.llmModel = config.llm || 'openai/gpt-4o-mini';
|
|
18
20
|
this.knowledgeBase = config.knowledgeBase;
|
|
19
21
|
this.contextWindow = config.contextWindow ?? 10;
|
|
20
22
|
this.maxContextTokens = config.maxContextTokens ?? 4000;
|
|
21
23
|
this.verbose = config.verbose ?? false;
|
|
22
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Get the LLM provider (lazy initialization with AI SDK backend)
|
|
27
|
+
*/
|
|
28
|
+
async getProvider() {
|
|
29
|
+
if (this.provider) {
|
|
30
|
+
return this.provider;
|
|
31
|
+
}
|
|
32
|
+
if (!this.providerPromise) {
|
|
33
|
+
this.providerPromise = (async () => {
|
|
34
|
+
const result = await (0, backend_resolver_1.resolveBackend)(this.llmModel, {
|
|
35
|
+
attribution: { agentId: this.name },
|
|
36
|
+
});
|
|
37
|
+
this.provider = result.provider;
|
|
38
|
+
return result.provider;
|
|
39
|
+
})();
|
|
40
|
+
}
|
|
41
|
+
return this.providerPromise;
|
|
42
|
+
}
|
|
23
43
|
/**
|
|
24
44
|
* Chat with context awareness
|
|
25
45
|
*/
|
|
@@ -51,7 +71,8 @@ class ContextAgent {
|
|
|
51
71
|
...this.getRecentMessages()
|
|
52
72
|
];
|
|
53
73
|
// Generate response
|
|
54
|
-
const
|
|
74
|
+
const provider = await this.getProvider();
|
|
75
|
+
const result = await provider.generateText({ messages });
|
|
55
76
|
// Add assistant message
|
|
56
77
|
this.messages.push({
|
|
57
78
|
role: 'assistant',
|
package/dist/agent/enhanced.d.ts
CHANGED
|
@@ -50,6 +50,8 @@ export declare class EnhancedAgent {
|
|
|
50
50
|
readonly instructions: string;
|
|
51
51
|
readonly sessionId: string;
|
|
52
52
|
private provider;
|
|
53
|
+
private providerPromise;
|
|
54
|
+
private llmModel;
|
|
53
55
|
private session;
|
|
54
56
|
private toolRegistry;
|
|
55
57
|
private verbose;
|
|
@@ -59,6 +61,10 @@ export declare class EnhancedAgent {
|
|
|
59
61
|
private maxTokens?;
|
|
60
62
|
private outputSchema?;
|
|
61
63
|
constructor(config: EnhancedAgentConfig);
|
|
64
|
+
/**
|
|
65
|
+
* Get the LLM provider (lazy initialization with AI SDK backend)
|
|
66
|
+
*/
|
|
67
|
+
private getProvider;
|
|
62
68
|
private registerTools;
|
|
63
69
|
/**
|
|
64
70
|
* Add a tool to the agent
|
package/dist/agent/enhanced.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.EnhancedAgent = void 0;
|
|
7
|
-
const
|
|
7
|
+
const backend_resolver_1 = require("../llm/backend-resolver");
|
|
8
8
|
const session_1 = require("../session");
|
|
9
9
|
const decorator_1 = require("../tools/decorator");
|
|
10
10
|
const logger_1 = require("../utils/logger");
|
|
@@ -13,6 +13,8 @@ const logger_1 = require("../utils/logger");
|
|
|
13
13
|
*/
|
|
14
14
|
class EnhancedAgent {
|
|
15
15
|
constructor(config) {
|
|
16
|
+
this.provider = null;
|
|
17
|
+
this.providerPromise = null;
|
|
16
18
|
this.name = config.name || `Agent_${Math.random().toString(36).substr(2, 9)}`;
|
|
17
19
|
this.instructions = config.instructions;
|
|
18
20
|
this.verbose = config.verbose ?? true;
|
|
@@ -21,8 +23,8 @@ class EnhancedAgent {
|
|
|
21
23
|
this.temperature = config.temperature ?? 0.7;
|
|
22
24
|
this.maxTokens = config.maxTokens;
|
|
23
25
|
this.outputSchema = config.outputSchema;
|
|
24
|
-
//
|
|
25
|
-
this.
|
|
26
|
+
// Store model string for lazy provider initialization
|
|
27
|
+
this.llmModel = config.llm || 'openai/gpt-4o-mini';
|
|
26
28
|
// Initialize session
|
|
27
29
|
if (config.session) {
|
|
28
30
|
this.session = config.session;
|
|
@@ -41,6 +43,27 @@ class EnhancedAgent {
|
|
|
41
43
|
}
|
|
42
44
|
logger_1.Logger.setVerbose(this.verbose);
|
|
43
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Get the LLM provider (lazy initialization with AI SDK backend)
|
|
48
|
+
*/
|
|
49
|
+
async getProvider() {
|
|
50
|
+
if (this.provider) {
|
|
51
|
+
return this.provider;
|
|
52
|
+
}
|
|
53
|
+
if (!this.providerPromise) {
|
|
54
|
+
this.providerPromise = (async () => {
|
|
55
|
+
const result = await (0, backend_resolver_1.resolveBackend)(this.llmModel, {
|
|
56
|
+
attribution: {
|
|
57
|
+
agentId: this.name,
|
|
58
|
+
sessionId: this.sessionId,
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
this.provider = result.provider;
|
|
62
|
+
return result.provider;
|
|
63
|
+
})();
|
|
64
|
+
}
|
|
65
|
+
return this.providerPromise;
|
|
66
|
+
}
|
|
44
67
|
registerTools(tools) {
|
|
45
68
|
if (!tools)
|
|
46
69
|
return;
|
|
@@ -118,7 +141,8 @@ class EnhancedAgent {
|
|
|
118
141
|
iterations++;
|
|
119
142
|
if (options.stream && !tools && options.onToken) {
|
|
120
143
|
// Streaming without tools
|
|
121
|
-
const
|
|
144
|
+
const provider = await this.getProvider();
|
|
145
|
+
const stream = await provider.streamText({
|
|
122
146
|
messages,
|
|
123
147
|
temperature: options.temperature ?? this.temperature,
|
|
124
148
|
maxTokens: options.maxTokens ?? this.maxTokens,
|
|
@@ -140,7 +164,8 @@ class EnhancedAgent {
|
|
|
140
164
|
}
|
|
141
165
|
else if (options.outputSchema) {
|
|
142
166
|
// Structured output
|
|
143
|
-
const
|
|
167
|
+
const provider = await this.getProvider();
|
|
168
|
+
const objResult = await provider.generateObject({
|
|
144
169
|
messages,
|
|
145
170
|
schema: options.outputSchema ?? this.outputSchema,
|
|
146
171
|
temperature: options.temperature ?? this.temperature,
|
|
@@ -156,7 +181,8 @@ class EnhancedAgent {
|
|
|
156
181
|
}
|
|
157
182
|
else {
|
|
158
183
|
// Regular generation with potential tool calls
|
|
159
|
-
|
|
184
|
+
const provider = await this.getProvider();
|
|
185
|
+
result = await provider.generateText({
|
|
160
186
|
messages,
|
|
161
187
|
temperature: options.temperature ?? this.temperature,
|
|
162
188
|
maxTokens: options.maxTokens ?? this.maxTokens,
|
package/dist/agent/image.d.ts
CHANGED
|
@@ -25,9 +25,15 @@ export interface ImageAgentConfig {
|
|
|
25
25
|
export declare class ImageAgent {
|
|
26
26
|
readonly name: string;
|
|
27
27
|
private provider;
|
|
28
|
+
private providerPromise;
|
|
29
|
+
private llmModel;
|
|
28
30
|
private imageModel;
|
|
29
31
|
private verbose;
|
|
30
32
|
constructor(config?: ImageAgentConfig);
|
|
33
|
+
/**
|
|
34
|
+
* Get the LLM provider (lazy initialization with AI SDK backend)
|
|
35
|
+
*/
|
|
36
|
+
private getProvider;
|
|
31
37
|
/**
|
|
32
38
|
* Analyze an image
|
|
33
39
|
*/
|
package/dist/agent/image.js
CHANGED
|
@@ -5,17 +5,37 @@
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.ImageAgent = void 0;
|
|
7
7
|
exports.createImageAgent = createImageAgent;
|
|
8
|
-
const
|
|
8
|
+
const backend_resolver_1 = require("../llm/backend-resolver");
|
|
9
9
|
/**
|
|
10
10
|
* ImageAgent - Agent for image generation and analysis
|
|
11
11
|
*/
|
|
12
12
|
class ImageAgent {
|
|
13
13
|
constructor(config = {}) {
|
|
14
|
+
this.provider = null;
|
|
15
|
+
this.providerPromise = null;
|
|
14
16
|
this.name = config.name || `ImageAgent_${Math.random().toString(36).substr(2, 9)}`;
|
|
15
|
-
this.
|
|
17
|
+
this.llmModel = config.llm || 'openai/gpt-4o-mini';
|
|
16
18
|
this.imageModel = config.imageModel || 'dall-e-3';
|
|
17
19
|
this.verbose = config.verbose ?? false;
|
|
18
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Get the LLM provider (lazy initialization with AI SDK backend)
|
|
23
|
+
*/
|
|
24
|
+
async getProvider() {
|
|
25
|
+
if (this.provider) {
|
|
26
|
+
return this.provider;
|
|
27
|
+
}
|
|
28
|
+
if (!this.providerPromise) {
|
|
29
|
+
this.providerPromise = (async () => {
|
|
30
|
+
const result = await (0, backend_resolver_1.resolveBackend)(this.llmModel, {
|
|
31
|
+
attribution: { agentId: this.name },
|
|
32
|
+
});
|
|
33
|
+
this.provider = result.provider;
|
|
34
|
+
return result.provider;
|
|
35
|
+
})();
|
|
36
|
+
}
|
|
37
|
+
return this.providerPromise;
|
|
38
|
+
}
|
|
19
39
|
/**
|
|
20
40
|
* Analyze an image
|
|
21
41
|
*/
|
|
@@ -36,7 +56,8 @@ class ImageAgent {
|
|
|
36
56
|
]
|
|
37
57
|
}
|
|
38
58
|
];
|
|
39
|
-
const
|
|
59
|
+
const provider = await this.getProvider();
|
|
60
|
+
const result = await provider.generateText({ messages });
|
|
40
61
|
if (this.verbose) {
|
|
41
62
|
console.log(`[ImageAgent] Analysis: ${result.text.substring(0, 100)}...`);
|
|
42
63
|
}
|
|
@@ -60,7 +81,8 @@ class ImageAgent {
|
|
|
60
81
|
if (imageUrl) {
|
|
61
82
|
return this.analyze({ imageUrl, prompt });
|
|
62
83
|
}
|
|
63
|
-
const
|
|
84
|
+
const provider = await this.getProvider();
|
|
85
|
+
const result = await provider.generateText({
|
|
64
86
|
messages: [{ role: 'user', content: prompt }]
|
|
65
87
|
});
|
|
66
88
|
return result.text;
|
|
@@ -80,7 +102,8 @@ class ImageAgent {
|
|
|
80
102
|
]
|
|
81
103
|
}
|
|
82
104
|
];
|
|
83
|
-
const
|
|
105
|
+
const provider = await this.getProvider();
|
|
106
|
+
const result = await provider.generateText({ messages });
|
|
84
107
|
return result.text;
|
|
85
108
|
}
|
|
86
109
|
}
|
|
@@ -20,9 +20,12 @@ export interface PromptExpanderConfig {
|
|
|
20
20
|
export declare class PromptExpanderAgent {
|
|
21
21
|
readonly name: string;
|
|
22
22
|
private provider;
|
|
23
|
+
private providerPromise;
|
|
24
|
+
private llmModel;
|
|
23
25
|
private defaultStrategy;
|
|
24
26
|
private verbose;
|
|
25
27
|
constructor(config?: PromptExpanderConfig);
|
|
28
|
+
private getProvider;
|
|
26
29
|
/**
|
|
27
30
|
* Expand a prompt
|
|
28
31
|
*/
|
|
@@ -5,17 +5,31 @@
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.PromptExpanderAgent = void 0;
|
|
7
7
|
exports.createPromptExpanderAgent = createPromptExpanderAgent;
|
|
8
|
-
const
|
|
8
|
+
const backend_resolver_1 = require("../llm/backend-resolver");
|
|
9
9
|
/**
|
|
10
10
|
* PromptExpanderAgent - Expand prompts with more detail and context
|
|
11
11
|
*/
|
|
12
12
|
class PromptExpanderAgent {
|
|
13
13
|
constructor(config = {}) {
|
|
14
|
+
this.provider = null;
|
|
15
|
+
this.providerPromise = null;
|
|
14
16
|
this.name = config.name || `PromptExpander_${Math.random().toString(36).substr(2, 9)}`;
|
|
15
|
-
this.
|
|
17
|
+
this.llmModel = config.llm || 'openai/gpt-4o-mini';
|
|
16
18
|
this.defaultStrategy = config.defaultStrategy || 'auto';
|
|
17
19
|
this.verbose = config.verbose ?? false;
|
|
18
20
|
}
|
|
21
|
+
async getProvider() {
|
|
22
|
+
if (this.provider)
|
|
23
|
+
return this.provider;
|
|
24
|
+
if (!this.providerPromise) {
|
|
25
|
+
this.providerPromise = (async () => {
|
|
26
|
+
const result = await (0, backend_resolver_1.resolveBackend)(this.llmModel, { attribution: { agentId: this.name } });
|
|
27
|
+
this.provider = result.provider;
|
|
28
|
+
return result.provider;
|
|
29
|
+
})();
|
|
30
|
+
}
|
|
31
|
+
return this.providerPromise;
|
|
32
|
+
}
|
|
19
33
|
/**
|
|
20
34
|
* Expand a prompt
|
|
21
35
|
*/
|
|
@@ -23,7 +37,8 @@ class PromptExpanderAgent {
|
|
|
23
37
|
const useStrategy = strategy || this.defaultStrategy;
|
|
24
38
|
const actualStrategy = useStrategy === 'auto' ? this.detectStrategy(prompt) : useStrategy;
|
|
25
39
|
const systemPrompt = this.getSystemPrompt(actualStrategy);
|
|
26
|
-
const
|
|
40
|
+
const provider = await this.getProvider();
|
|
41
|
+
const result = await provider.generateText({
|
|
27
42
|
messages: [
|
|
28
43
|
{ role: 'system', content: systemPrompt },
|
|
29
44
|
{ role: 'user', content: `Expand this prompt: ${prompt}` }
|
|
@@ -20,9 +20,12 @@ export interface QueryRewriterConfig {
|
|
|
20
20
|
export declare class QueryRewriterAgent {
|
|
21
21
|
readonly name: string;
|
|
22
22
|
private provider;
|
|
23
|
+
private providerPromise;
|
|
24
|
+
private llmModel;
|
|
23
25
|
private defaultStrategy;
|
|
24
26
|
private verbose;
|
|
25
27
|
constructor(config?: QueryRewriterConfig);
|
|
28
|
+
private getProvider;
|
|
26
29
|
/**
|
|
27
30
|
* Rewrite a query
|
|
28
31
|
*/
|
|
@@ -5,17 +5,31 @@
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.QueryRewriterAgent = void 0;
|
|
7
7
|
exports.createQueryRewriterAgent = createQueryRewriterAgent;
|
|
8
|
-
const
|
|
8
|
+
const backend_resolver_1 = require("../llm/backend-resolver");
|
|
9
9
|
/**
|
|
10
10
|
* QueryRewriterAgent - Optimize and rewrite queries
|
|
11
11
|
*/
|
|
12
12
|
class QueryRewriterAgent {
|
|
13
13
|
constructor(config = {}) {
|
|
14
|
+
this.provider = null;
|
|
15
|
+
this.providerPromise = null;
|
|
14
16
|
this.name = config.name || `QueryRewriter_${Math.random().toString(36).substr(2, 9)}`;
|
|
15
|
-
this.
|
|
17
|
+
this.llmModel = config.llm || 'openai/gpt-4o-mini';
|
|
16
18
|
this.defaultStrategy = config.defaultStrategy || 'auto';
|
|
17
19
|
this.verbose = config.verbose ?? false;
|
|
18
20
|
}
|
|
21
|
+
async getProvider() {
|
|
22
|
+
if (this.provider)
|
|
23
|
+
return this.provider;
|
|
24
|
+
if (!this.providerPromise) {
|
|
25
|
+
this.providerPromise = (async () => {
|
|
26
|
+
const result = await (0, backend_resolver_1.resolveBackend)(this.llmModel, { attribution: { agentId: this.name } });
|
|
27
|
+
this.provider = result.provider;
|
|
28
|
+
return result.provider;
|
|
29
|
+
})();
|
|
30
|
+
}
|
|
31
|
+
return this.providerPromise;
|
|
32
|
+
}
|
|
19
33
|
/**
|
|
20
34
|
* Rewrite a query
|
|
21
35
|
*/
|
|
@@ -23,7 +37,8 @@ class QueryRewriterAgent {
|
|
|
23
37
|
const useStrategy = strategy || this.defaultStrategy;
|
|
24
38
|
const actualStrategy = useStrategy === 'auto' ? this.detectStrategy(query) : useStrategy;
|
|
25
39
|
const prompt = this.buildPrompt(query, actualStrategy);
|
|
26
|
-
const
|
|
40
|
+
const provider = await this.getProvider();
|
|
41
|
+
const result = await provider.generateText({
|
|
27
42
|
messages: [
|
|
28
43
|
{ role: 'system', content: this.getSystemPrompt(actualStrategy) },
|
|
29
44
|
{ role: 'user', content: prompt }
|
package/dist/agent/research.d.ts
CHANGED
|
@@ -31,10 +31,13 @@ export interface DeepResearchConfig {
|
|
|
31
31
|
export declare class DeepResearchAgent {
|
|
32
32
|
readonly name: string;
|
|
33
33
|
private provider;
|
|
34
|
+
private providerPromise;
|
|
35
|
+
private llmModel;
|
|
34
36
|
private maxIterations;
|
|
35
37
|
private searchTool?;
|
|
36
38
|
private verbose;
|
|
37
39
|
constructor(config?: DeepResearchConfig);
|
|
40
|
+
private getProvider;
|
|
38
41
|
/**
|
|
39
42
|
* Conduct deep research on a topic
|
|
40
43
|
*/
|
package/dist/agent/research.js
CHANGED
|
@@ -5,18 +5,32 @@
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.DeepResearchAgent = void 0;
|
|
7
7
|
exports.createDeepResearchAgent = createDeepResearchAgent;
|
|
8
|
-
const
|
|
8
|
+
const backend_resolver_1 = require("../llm/backend-resolver");
|
|
9
9
|
/**
|
|
10
10
|
* DeepResearchAgent - Comprehensive research with citations
|
|
11
11
|
*/
|
|
12
12
|
class DeepResearchAgent {
|
|
13
13
|
constructor(config = {}) {
|
|
14
|
+
this.provider = null;
|
|
15
|
+
this.providerPromise = null;
|
|
14
16
|
this.name = config.name || `ResearchAgent_${Math.random().toString(36).substr(2, 9)}`;
|
|
15
|
-
this.
|
|
17
|
+
this.llmModel = config.llm || 'openai/gpt-4o-mini';
|
|
16
18
|
this.maxIterations = config.maxIterations ?? 5;
|
|
17
19
|
this.searchTool = config.searchTool;
|
|
18
20
|
this.verbose = config.verbose ?? false;
|
|
19
21
|
}
|
|
22
|
+
async getProvider() {
|
|
23
|
+
if (this.provider)
|
|
24
|
+
return this.provider;
|
|
25
|
+
if (!this.providerPromise) {
|
|
26
|
+
this.providerPromise = (async () => {
|
|
27
|
+
const result = await (0, backend_resolver_1.resolveBackend)(this.llmModel, { attribution: { agentId: this.name } });
|
|
28
|
+
this.provider = result.provider;
|
|
29
|
+
return result.provider;
|
|
30
|
+
})();
|
|
31
|
+
}
|
|
32
|
+
return this.providerPromise;
|
|
33
|
+
}
|
|
20
34
|
/**
|
|
21
35
|
* Conduct deep research on a topic
|
|
22
36
|
*/
|
|
@@ -76,7 +90,8 @@ class DeepResearchAgent {
|
|
|
76
90
|
};
|
|
77
91
|
}
|
|
78
92
|
async generateSearchQueries(query) {
|
|
79
|
-
const
|
|
93
|
+
const provider = await this.getProvider();
|
|
94
|
+
const result = await provider.generateText({
|
|
80
95
|
messages: [
|
|
81
96
|
{
|
|
82
97
|
role: 'system',
|
|
@@ -91,7 +106,8 @@ class DeepResearchAgent {
|
|
|
91
106
|
const context = citations.length > 0
|
|
92
107
|
? `\n\nRelevant sources:\n${citations.map(c => `- ${c.title}: ${c.snippet || ''}`).join('\n')}`
|
|
93
108
|
: '';
|
|
94
|
-
const
|
|
109
|
+
const provider = await this.getProvider();
|
|
110
|
+
const result = await provider.generateText({
|
|
95
111
|
messages: [
|
|
96
112
|
{
|
|
97
113
|
role: 'system',
|
package/dist/agent/simple.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { DbAdapter } from '../db/types';
|
|
2
|
+
import type { LLMProvider } from '../llm/providers/types';
|
|
2
3
|
/**
|
|
3
4
|
* Agent Configuration
|
|
4
5
|
*
|
|
@@ -108,9 +109,13 @@ export declare class Agent {
|
|
|
108
109
|
private cacheTTL;
|
|
109
110
|
private responseCache;
|
|
110
111
|
private telemetryEnabled;
|
|
112
|
+
private _backend;
|
|
113
|
+
private _backendPromise;
|
|
114
|
+
private _backendSource;
|
|
115
|
+
private _useAISDKBackend;
|
|
111
116
|
constructor(config: SimpleAgentConfig);
|
|
112
117
|
/**
|
|
113
|
-
* Generate a session ID based on current hour
|
|
118
|
+
* Generate a unique session ID based on current hour, agent name, and random suffix
|
|
114
119
|
*/
|
|
115
120
|
private generateSessionId;
|
|
116
121
|
/**
|
|
@@ -182,6 +187,39 @@ export declare class Agent {
|
|
|
182
187
|
* Clear response cache
|
|
183
188
|
*/
|
|
184
189
|
clearCache(): void;
|
|
190
|
+
/**
|
|
191
|
+
* Get the resolved backend (AI SDK preferred, native fallback)
|
|
192
|
+
* Lazy initialization - backend is only resolved on first use
|
|
193
|
+
*/
|
|
194
|
+
getBackend(): Promise<LLMProvider>;
|
|
195
|
+
/**
|
|
196
|
+
* Get the backend source (ai-sdk, native, custom, or legacy)
|
|
197
|
+
*/
|
|
198
|
+
getBackendSource(): 'ai-sdk' | 'native' | 'custom' | 'legacy';
|
|
199
|
+
/**
|
|
200
|
+
* Embed text using AI SDK (preferred) or native provider
|
|
201
|
+
*
|
|
202
|
+
* @param text - Text to embed (string or array of strings)
|
|
203
|
+
* @param options - Embedding options
|
|
204
|
+
* @returns Embedding vector(s)
|
|
205
|
+
*
|
|
206
|
+
* @example Single text
|
|
207
|
+
* ```typescript
|
|
208
|
+
* const embedding = await agent.embed("Hello world");
|
|
209
|
+
* ```
|
|
210
|
+
*
|
|
211
|
+
* @example Multiple texts
|
|
212
|
+
* ```typescript
|
|
213
|
+
* const embeddings = await agent.embed(["Hello", "World"]);
|
|
214
|
+
* ```
|
|
215
|
+
*/
|
|
216
|
+
embed(text: string | string[], options?: {
|
|
217
|
+
model?: string;
|
|
218
|
+
}): Promise<number[] | number[][]>;
|
|
219
|
+
/**
|
|
220
|
+
* Get the model string for this agent
|
|
221
|
+
*/
|
|
222
|
+
getModel(): string;
|
|
185
223
|
}
|
|
186
224
|
/**
|
|
187
225
|
* Configuration for multi-agent orchestration
|