praisonai 1.2.4 → 1.3.1
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/index.d.ts +18 -5
- package/dist/agent/index.js +31 -6
- package/dist/agent/router.d.ts +68 -4
- package/dist/agent/router.js +100 -4
- package/dist/agent/simple.d.ts +179 -1
- package/dist/agent/simple.js +224 -5
- package/dist/cli/commands/agent.d.ts +30 -0
- package/dist/cli/commands/agent.js +162 -0
- package/dist/cli/commands/agents.d.ts +24 -0
- package/dist/cli/commands/agents.js +177 -0
- package/dist/db/index.d.ts +22 -3
- package/dist/db/index.js +87 -13
- package/dist/index.d.ts +52 -13
- package/dist/index.js +92 -28
- package/dist/planning/index.d.ts +120 -0
- package/dist/planning/index.js +248 -1
- package/dist/telemetry/index.d.ts +73 -0
- package/dist/telemetry/index.js +101 -1
- package/dist/workflows/index.d.ts +21 -0
- package/dist/workflows/index.js +31 -0
- package/package.json +1 -1
package/dist/agent/index.d.ts
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Module - Core agent classes for PraisonAI
|
|
3
|
+
*
|
|
4
|
+
* The primary exports are:
|
|
5
|
+
* - Agent: Single agent with instructions, tools, and optional persistence
|
|
6
|
+
* - Agents: Multi-agent orchestration (alias for PraisonAIAgents)
|
|
7
|
+
* - Router: Simplified keyword/pattern-based routing
|
|
8
|
+
* - Workflow: Step-based workflow execution (from workflows module)
|
|
9
|
+
*/
|
|
10
|
+
export { Agent, PraisonAIAgents, Agents } from './simple';
|
|
11
|
+
export type { SimpleAgentConfig, PraisonAIAgentsConfig } from './simple';
|
|
12
|
+
export { Router, RouterAgent, createRouter, routeConditions } from './router';
|
|
13
|
+
export type { RouterConfig, RouteConfig, RouteContext, SimpleRouterConfig, SimpleRouteConfig } from './router';
|
|
14
|
+
export { Task } from './types';
|
|
15
|
+
export type { TaskConfig, AgentConfig as TaskAgentConfig } from './types';
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated Task mode is no longer needed. Use Agent with role/goal/backstory instead.
|
|
18
|
+
*/
|
|
1
19
|
export declare function setTaskMode(enabled: boolean): void;
|
|
2
|
-
export { Agent, PraisonAIAgents, Task } from './proxy';
|
|
3
|
-
export type { ProxyAgentConfig } from './proxy';
|
|
4
|
-
export type { AgentConfig } from './types';
|
|
5
|
-
export type { TaskConfig } from './types';
|
|
6
|
-
export type { PraisonAIAgentsConfig, SimpleAgentConfig } from './simple';
|
package/dist/agent/index.js
CHANGED
|
@@ -1,13 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Agent Module - Core agent classes for PraisonAI
|
|
4
|
+
*
|
|
5
|
+
* The primary exports are:
|
|
6
|
+
* - Agent: Single agent with instructions, tools, and optional persistence
|
|
7
|
+
* - Agents: Multi-agent orchestration (alias for PraisonAIAgents)
|
|
8
|
+
* - Router: Simplified keyword/pattern-based routing
|
|
9
|
+
* - Workflow: Step-based workflow execution (from workflows module)
|
|
10
|
+
*/
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Task = exports.PraisonAIAgents = exports.Agent = void 0;
|
|
12
|
+
exports.Task = exports.routeConditions = exports.createRouter = exports.RouterAgent = exports.Router = exports.Agents = exports.PraisonAIAgents = exports.Agent = void 0;
|
|
4
13
|
exports.setTaskMode = setTaskMode;
|
|
5
|
-
//
|
|
14
|
+
// Core exports - the main API surface
|
|
15
|
+
var simple_1 = require("./simple");
|
|
16
|
+
Object.defineProperty(exports, "Agent", { enumerable: true, get: function () { return simple_1.Agent; } });
|
|
17
|
+
Object.defineProperty(exports, "PraisonAIAgents", { enumerable: true, get: function () { return simple_1.PraisonAIAgents; } });
|
|
18
|
+
Object.defineProperty(exports, "Agents", { enumerable: true, get: function () { return simple_1.Agents; } });
|
|
19
|
+
// Router exports
|
|
20
|
+
var router_1 = require("./router");
|
|
21
|
+
Object.defineProperty(exports, "Router", { enumerable: true, get: function () { return router_1.Router; } });
|
|
22
|
+
Object.defineProperty(exports, "RouterAgent", { enumerable: true, get: function () { return router_1.RouterAgent; } });
|
|
23
|
+
Object.defineProperty(exports, "createRouter", { enumerable: true, get: function () { return router_1.createRouter; } });
|
|
24
|
+
Object.defineProperty(exports, "routeConditions", { enumerable: true, get: function () { return router_1.routeConditions; } });
|
|
25
|
+
// Task support (for advanced use cases)
|
|
26
|
+
var types_1 = require("./types");
|
|
27
|
+
Object.defineProperty(exports, "Task", { enumerable: true, get: function () { return types_1.Task; } });
|
|
28
|
+
// Legacy compatibility - setTaskMode is deprecated but kept for backward compat
|
|
6
29
|
let useTaskMode = false;
|
|
30
|
+
/**
|
|
31
|
+
* @deprecated Task mode is no longer needed. Use Agent with role/goal/backstory instead.
|
|
32
|
+
*/
|
|
7
33
|
function setTaskMode(enabled) {
|
|
34
|
+
if (enabled) {
|
|
35
|
+
console.warn('setTaskMode() is deprecated. Use Agent({ role, goal, backstory }) instead of task mode.');
|
|
36
|
+
}
|
|
8
37
|
useTaskMode = enabled;
|
|
9
38
|
}
|
|
10
|
-
var proxy_1 = require("./proxy");
|
|
11
|
-
Object.defineProperty(exports, "Agent", { enumerable: true, get: function () { return proxy_1.Agent; } });
|
|
12
|
-
Object.defineProperty(exports, "PraisonAIAgents", { enumerable: true, get: function () { return proxy_1.PraisonAIAgents; } });
|
|
13
|
-
Object.defineProperty(exports, "Task", { enumerable: true, get: function () { return proxy_1.Task; } });
|
package/dist/agent/router.d.ts
CHANGED
|
@@ -1,12 +1,32 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Router Agent - Route requests to specialized agents
|
|
3
|
+
*
|
|
4
|
+
* @example Simple usage (5 lines)
|
|
5
|
+
* ```typescript
|
|
6
|
+
* import { Agent, Router } from 'praisonai';
|
|
7
|
+
*
|
|
8
|
+
* const router = new Router({
|
|
9
|
+
* math: { agent: new Agent({ instructions: 'Math expert' }), keywords: ['calculate', 'math'] },
|
|
10
|
+
* code: { agent: new Agent({ instructions: 'Code expert' }), keywords: ['code', 'program'] }
|
|
11
|
+
* });
|
|
12
|
+
* await router.chat('Calculate 2+2'); // Routes to math agent
|
|
13
|
+
* ```
|
|
3
14
|
*/
|
|
4
15
|
import type { EnhancedAgent } from './enhanced';
|
|
16
|
+
import { Agent } from './simple';
|
|
17
|
+
type AnyAgent = Agent | EnhancedAgent;
|
|
5
18
|
export interface RouteConfig {
|
|
6
|
-
agent:
|
|
19
|
+
agent: AnyAgent;
|
|
7
20
|
condition: (input: string, context?: RouteContext) => boolean | Promise<boolean>;
|
|
8
21
|
priority?: number;
|
|
9
22
|
}
|
|
23
|
+
/** Simplified route definition */
|
|
24
|
+
export interface SimpleRouteConfig {
|
|
25
|
+
agent: AnyAgent;
|
|
26
|
+
keywords?: string[];
|
|
27
|
+
pattern?: RegExp;
|
|
28
|
+
priority?: number;
|
|
29
|
+
}
|
|
10
30
|
export interface RouteContext {
|
|
11
31
|
history?: string[];
|
|
12
32
|
metadata?: Record<string, any>;
|
|
@@ -14,9 +34,11 @@ export interface RouteContext {
|
|
|
14
34
|
export interface RouterConfig {
|
|
15
35
|
name?: string;
|
|
16
36
|
routes: RouteConfig[];
|
|
17
|
-
defaultAgent?:
|
|
37
|
+
defaultAgent?: AnyAgent;
|
|
18
38
|
verbose?: boolean;
|
|
19
39
|
}
|
|
40
|
+
/** Simplified router config - just a map of route name to config */
|
|
41
|
+
export type SimpleRouterConfig = Record<string, SimpleRouteConfig>;
|
|
20
42
|
/**
|
|
21
43
|
* Router Agent - Routes requests to the most appropriate agent
|
|
22
44
|
*/
|
|
@@ -30,9 +52,13 @@ export declare class RouterAgent {
|
|
|
30
52
|
* Route a request to the appropriate agent
|
|
31
53
|
*/
|
|
32
54
|
route(input: string, context?: RouteContext): Promise<{
|
|
33
|
-
agent:
|
|
55
|
+
agent: AnyAgent;
|
|
34
56
|
response: string;
|
|
35
57
|
} | null>;
|
|
58
|
+
/**
|
|
59
|
+
* Simplified chat method - routes and returns just the response
|
|
60
|
+
*/
|
|
61
|
+
chat(input: string, context?: RouteContext): Promise<string>;
|
|
36
62
|
/**
|
|
37
63
|
* Add a route
|
|
38
64
|
*/
|
|
@@ -72,6 +98,44 @@ export declare const routeConditions: {
|
|
|
72
98
|
or: (...conditions: Array<(input: string, context?: RouteContext) => boolean>) => (input: string, context?: RouteContext) => boolean;
|
|
73
99
|
};
|
|
74
100
|
/**
|
|
75
|
-
* Create a router agent
|
|
101
|
+
* Create a router agent (legacy API)
|
|
76
102
|
*/
|
|
77
103
|
export declare function createRouter(config: RouterConfig): RouterAgent;
|
|
104
|
+
/**
|
|
105
|
+
* Simplified Router class - uses keyword/pattern-based routing
|
|
106
|
+
*
|
|
107
|
+
* @example Simple usage (5 lines)
|
|
108
|
+
* ```typescript
|
|
109
|
+
* import { Agent, Router } from 'praisonai';
|
|
110
|
+
*
|
|
111
|
+
* const router = new Router({
|
|
112
|
+
* math: { agent: new Agent({ instructions: 'Math expert' }), keywords: ['calculate', 'math'] },
|
|
113
|
+
* code: { agent: new Agent({ instructions: 'Code expert' }), keywords: ['code', 'program'] }
|
|
114
|
+
* });
|
|
115
|
+
* await router.chat('Calculate 2+2'); // Routes to math agent
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
export declare class Router {
|
|
119
|
+
private routerAgent;
|
|
120
|
+
private agentMap;
|
|
121
|
+
constructor(config: SimpleRouterConfig, options?: {
|
|
122
|
+
default?: string;
|
|
123
|
+
verbose?: boolean;
|
|
124
|
+
});
|
|
125
|
+
/**
|
|
126
|
+
* Route and get response
|
|
127
|
+
*/
|
|
128
|
+
chat(input: string): Promise<string>;
|
|
129
|
+
/**
|
|
130
|
+
* Route and get full result with agent info
|
|
131
|
+
*/
|
|
132
|
+
route(input: string): Promise<{
|
|
133
|
+
agent: AnyAgent;
|
|
134
|
+
response: string;
|
|
135
|
+
} | null>;
|
|
136
|
+
/**
|
|
137
|
+
* Get agent by name
|
|
138
|
+
*/
|
|
139
|
+
getAgent(name: string): AnyAgent | undefined;
|
|
140
|
+
}
|
|
141
|
+
export {};
|
package/dist/agent/router.js
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
3
|
* Router Agent - Route requests to specialized agents
|
|
4
|
+
*
|
|
5
|
+
* @example Simple usage (5 lines)
|
|
6
|
+
* ```typescript
|
|
7
|
+
* import { Agent, Router } from 'praisonai';
|
|
8
|
+
*
|
|
9
|
+
* const router = new Router({
|
|
10
|
+
* math: { agent: new Agent({ instructions: 'Math expert' }), keywords: ['calculate', 'math'] },
|
|
11
|
+
* code: { agent: new Agent({ instructions: 'Code expert' }), keywords: ['code', 'program'] }
|
|
12
|
+
* });
|
|
13
|
+
* await router.chat('Calculate 2+2'); // Routes to math agent
|
|
14
|
+
* ```
|
|
4
15
|
*/
|
|
5
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.routeConditions = exports.RouterAgent = void 0;
|
|
17
|
+
exports.Router = exports.routeConditions = exports.RouterAgent = void 0;
|
|
7
18
|
exports.createRouter = createRouter;
|
|
8
19
|
/**
|
|
9
20
|
* Router Agent - Routes requests to the most appropriate agent
|
|
@@ -26,7 +37,9 @@ class RouterAgent {
|
|
|
26
37
|
console.log(`[Router] Routing to: ${route.agent.name}`);
|
|
27
38
|
}
|
|
28
39
|
const response = await route.agent.chat(input);
|
|
29
|
-
|
|
40
|
+
// Handle both Agent (returns string) and EnhancedAgent (returns ChatResult)
|
|
41
|
+
const responseText = typeof response === 'string' ? response : response.text;
|
|
42
|
+
return { agent: route.agent, response: responseText };
|
|
30
43
|
}
|
|
31
44
|
}
|
|
32
45
|
if (this.defaultAgent) {
|
|
@@ -34,10 +47,21 @@ class RouterAgent {
|
|
|
34
47
|
console.log(`[Router] Using default agent: ${this.defaultAgent.name}`);
|
|
35
48
|
}
|
|
36
49
|
const response = await this.defaultAgent.chat(input);
|
|
37
|
-
|
|
50
|
+
const responseText = typeof response === 'string' ? response : response.text;
|
|
51
|
+
return { agent: this.defaultAgent, response: responseText };
|
|
38
52
|
}
|
|
39
53
|
return null;
|
|
40
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* Simplified chat method - routes and returns just the response
|
|
57
|
+
*/
|
|
58
|
+
async chat(input, context) {
|
|
59
|
+
const result = await this.route(input, context);
|
|
60
|
+
if (!result) {
|
|
61
|
+
throw new Error('No matching route found and no default agent configured');
|
|
62
|
+
}
|
|
63
|
+
return result.response;
|
|
64
|
+
}
|
|
41
65
|
/**
|
|
42
66
|
* Add a route
|
|
43
67
|
*/
|
|
@@ -106,8 +130,80 @@ exports.routeConditions = {
|
|
|
106
130
|
}
|
|
107
131
|
};
|
|
108
132
|
/**
|
|
109
|
-
* Create a router agent
|
|
133
|
+
* Create a router agent (legacy API)
|
|
110
134
|
*/
|
|
111
135
|
function createRouter(config) {
|
|
112
136
|
return new RouterAgent(config);
|
|
113
137
|
}
|
|
138
|
+
/**
|
|
139
|
+
* Simplified Router class - uses keyword/pattern-based routing
|
|
140
|
+
*
|
|
141
|
+
* @example Simple usage (5 lines)
|
|
142
|
+
* ```typescript
|
|
143
|
+
* import { Agent, Router } from 'praisonai';
|
|
144
|
+
*
|
|
145
|
+
* const router = new Router({
|
|
146
|
+
* math: { agent: new Agent({ instructions: 'Math expert' }), keywords: ['calculate', 'math'] },
|
|
147
|
+
* code: { agent: new Agent({ instructions: 'Code expert' }), keywords: ['code', 'program'] }
|
|
148
|
+
* });
|
|
149
|
+
* await router.chat('Calculate 2+2'); // Routes to math agent
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
class Router {
|
|
153
|
+
constructor(config, options) {
|
|
154
|
+
this.agentMap = new Map();
|
|
155
|
+
const routes = [];
|
|
156
|
+
let defaultAgent;
|
|
157
|
+
for (const [name, routeConfig] of Object.entries(config)) {
|
|
158
|
+
this.agentMap.set(name, routeConfig.agent);
|
|
159
|
+
// Build condition from keywords or pattern
|
|
160
|
+
let condition;
|
|
161
|
+
if (routeConfig.keywords) {
|
|
162
|
+
condition = exports.routeConditions.keywords(routeConfig.keywords);
|
|
163
|
+
}
|
|
164
|
+
else if (routeConfig.pattern) {
|
|
165
|
+
condition = exports.routeConditions.pattern(routeConfig.pattern);
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
condition = exports.routeConditions.always();
|
|
169
|
+
}
|
|
170
|
+
routes.push({
|
|
171
|
+
agent: routeConfig.agent,
|
|
172
|
+
condition,
|
|
173
|
+
priority: routeConfig.priority
|
|
174
|
+
});
|
|
175
|
+
// Set default agent
|
|
176
|
+
if (options?.default === name) {
|
|
177
|
+
defaultAgent = routeConfig.agent;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
// If no default specified, use first agent
|
|
181
|
+
if (!defaultAgent && routes.length > 0) {
|
|
182
|
+
defaultAgent = routes[0].agent;
|
|
183
|
+
}
|
|
184
|
+
this.routerAgent = new RouterAgent({
|
|
185
|
+
routes,
|
|
186
|
+
defaultAgent,
|
|
187
|
+
verbose: options?.verbose
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Route and get response
|
|
192
|
+
*/
|
|
193
|
+
async chat(input) {
|
|
194
|
+
return this.routerAgent.chat(input);
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Route and get full result with agent info
|
|
198
|
+
*/
|
|
199
|
+
async route(input) {
|
|
200
|
+
return this.routerAgent.route(input);
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Get agent by name
|
|
204
|
+
*/
|
|
205
|
+
getAgent(name) {
|
|
206
|
+
return this.agentMap.get(name);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
exports.Router = Router;
|
package/dist/agent/simple.d.ts
CHANGED
|
@@ -1,13 +1,89 @@
|
|
|
1
|
+
import type { DbAdapter } from '../db/types';
|
|
2
|
+
/**
|
|
3
|
+
* Agent Configuration
|
|
4
|
+
*
|
|
5
|
+
* The Agent class is the primary entry point for PraisonAI.
|
|
6
|
+
* It supports both simple instruction-based agents and advanced configurations.
|
|
7
|
+
*
|
|
8
|
+
* @example Simple usage (3 lines)
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { Agent } from 'praisonai';
|
|
11
|
+
* const agent = new Agent({ instructions: "You are helpful" });
|
|
12
|
+
* await agent.chat("Hello!");
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* @example With tools (5 lines)
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const getWeather = (city: string) => `Weather in ${city}: 20°C`;
|
|
18
|
+
* const agent = new Agent({
|
|
19
|
+
* instructions: "You provide weather info",
|
|
20
|
+
* tools: [getWeather]
|
|
21
|
+
* });
|
|
22
|
+
* await agent.chat("Weather in Paris?");
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @example With persistence (4 lines)
|
|
26
|
+
* ```typescript
|
|
27
|
+
* import { Agent, db } from 'praisonai';
|
|
28
|
+
* const agent = new Agent({
|
|
29
|
+
* instructions: "You are helpful",
|
|
30
|
+
* db: db("sqlite:./data.db"),
|
|
31
|
+
* sessionId: "my-session"
|
|
32
|
+
* });
|
|
33
|
+
* await agent.chat("Hello!");
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
1
36
|
export interface SimpleAgentConfig {
|
|
37
|
+
/** Agent instructions/system prompt (required) */
|
|
2
38
|
instructions: string;
|
|
39
|
+
/** Agent name (auto-generated if not provided) */
|
|
3
40
|
name?: string;
|
|
41
|
+
/** Enable verbose logging (default: true) */
|
|
4
42
|
verbose?: boolean;
|
|
43
|
+
/** Enable pretty output formatting */
|
|
5
44
|
pretty?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* LLM model to use. Accepts:
|
|
47
|
+
* - Model name: "gpt-4o-mini", "claude-3-sonnet"
|
|
48
|
+
* - Provider/model: "openai/gpt-4o", "anthropic/claude-3"
|
|
49
|
+
* Default: "gpt-4o-mini"
|
|
50
|
+
*/
|
|
6
51
|
llm?: string;
|
|
52
|
+
/** Enable markdown formatting in responses */
|
|
7
53
|
markdown?: boolean;
|
|
54
|
+
/** Enable streaming responses (default: true) */
|
|
8
55
|
stream?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Tools available to the agent.
|
|
58
|
+
* Can be plain functions (auto-schema) or OpenAI tool definitions.
|
|
59
|
+
*/
|
|
9
60
|
tools?: any[] | Function[];
|
|
61
|
+
/** Map of tool function implementations */
|
|
10
62
|
toolFunctions?: Record<string, Function>;
|
|
63
|
+
/** Database adapter for persistence */
|
|
64
|
+
db?: DbAdapter;
|
|
65
|
+
/** Session ID for conversation persistence (auto-generated if not provided) */
|
|
66
|
+
sessionId?: string;
|
|
67
|
+
/** Run ID for tracing (auto-generated if not provided) */
|
|
68
|
+
runId?: string;
|
|
69
|
+
/** Max messages to restore from history (default: 100) */
|
|
70
|
+
historyLimit?: number;
|
|
71
|
+
/** Auto-restore conversation history from db (default: true) */
|
|
72
|
+
autoRestore?: boolean;
|
|
73
|
+
/** Auto-persist messages to db (default: true) */
|
|
74
|
+
autoPersist?: boolean;
|
|
75
|
+
/** Enable caching of responses */
|
|
76
|
+
cache?: boolean;
|
|
77
|
+
/** Cache TTL in seconds (default: 3600) */
|
|
78
|
+
cacheTTL?: number;
|
|
79
|
+
/** Enable telemetry tracking (default: false, opt-in) */
|
|
80
|
+
telemetry?: boolean;
|
|
81
|
+
/** Agent role (advanced mode) */
|
|
82
|
+
role?: string;
|
|
83
|
+
/** Agent goal (advanced mode) */
|
|
84
|
+
goal?: string;
|
|
85
|
+
/** Agent backstory (advanced mode) */
|
|
86
|
+
backstory?: string;
|
|
11
87
|
}
|
|
12
88
|
export declare class Agent {
|
|
13
89
|
private instructions;
|
|
@@ -20,7 +96,35 @@ export declare class Agent {
|
|
|
20
96
|
private llmService;
|
|
21
97
|
private tools?;
|
|
22
98
|
private toolFunctions;
|
|
99
|
+
private dbAdapter?;
|
|
100
|
+
private sessionId;
|
|
101
|
+
private runId;
|
|
102
|
+
private messages;
|
|
103
|
+
private dbInitialized;
|
|
104
|
+
private historyLimit;
|
|
105
|
+
private autoRestore;
|
|
106
|
+
private autoPersist;
|
|
107
|
+
private cache;
|
|
108
|
+
private cacheTTL;
|
|
109
|
+
private responseCache;
|
|
110
|
+
private telemetryEnabled;
|
|
23
111
|
constructor(config: SimpleAgentConfig);
|
|
112
|
+
/**
|
|
113
|
+
* Generate a session ID based on current hour and agent name (like Python SDK)
|
|
114
|
+
*/
|
|
115
|
+
private generateSessionId;
|
|
116
|
+
/**
|
|
117
|
+
* Initialize DB session - restore history on first chat (lazy)
|
|
118
|
+
*/
|
|
119
|
+
private initDbSession;
|
|
120
|
+
/**
|
|
121
|
+
* Get cached response if available and not expired
|
|
122
|
+
*/
|
|
123
|
+
private getCachedResponse;
|
|
124
|
+
/**
|
|
125
|
+
* Cache a response
|
|
126
|
+
*/
|
|
127
|
+
private cacheResponse;
|
|
24
128
|
private createSystemPrompt;
|
|
25
129
|
/**
|
|
26
130
|
* Register a tool function that can be called by the model
|
|
@@ -49,9 +153,39 @@ export declare class Agent {
|
|
|
49
153
|
start(prompt: string, previousResult?: string): Promise<string>;
|
|
50
154
|
chat(prompt: string, previousResult?: string): Promise<string>;
|
|
51
155
|
execute(previousResult?: string): Promise<string>;
|
|
156
|
+
/**
|
|
157
|
+
* Persist a message to the database
|
|
158
|
+
*/
|
|
159
|
+
private persistMessage;
|
|
160
|
+
/**
|
|
161
|
+
* Get the session ID for this agent
|
|
162
|
+
*/
|
|
163
|
+
getSessionId(): string;
|
|
164
|
+
/**
|
|
165
|
+
* Get the run ID for this agent
|
|
166
|
+
*/
|
|
167
|
+
getRunId(): string;
|
|
52
168
|
getResult(): string | null;
|
|
53
169
|
getInstructions(): string;
|
|
170
|
+
/**
|
|
171
|
+
* Get conversation history
|
|
172
|
+
*/
|
|
173
|
+
getHistory(): Array<{
|
|
174
|
+
role: string;
|
|
175
|
+
content: string | null;
|
|
176
|
+
}>;
|
|
177
|
+
/**
|
|
178
|
+
* Clear conversation history (in memory and optionally in DB)
|
|
179
|
+
*/
|
|
180
|
+
clearHistory(clearDb?: boolean): Promise<void>;
|
|
181
|
+
/**
|
|
182
|
+
* Clear response cache
|
|
183
|
+
*/
|
|
184
|
+
clearCache(): void;
|
|
54
185
|
}
|
|
186
|
+
/**
|
|
187
|
+
* Configuration for multi-agent orchestration
|
|
188
|
+
*/
|
|
55
189
|
export interface PraisonAIAgentsConfig {
|
|
56
190
|
agents: Agent[];
|
|
57
191
|
tasks?: string[];
|
|
@@ -59,15 +193,59 @@ export interface PraisonAIAgentsConfig {
|
|
|
59
193
|
pretty?: boolean;
|
|
60
194
|
process?: 'sequential' | 'parallel';
|
|
61
195
|
}
|
|
196
|
+
/**
|
|
197
|
+
* Multi-agent orchestration class
|
|
198
|
+
*
|
|
199
|
+
* @example Simple array syntax
|
|
200
|
+
* ```typescript
|
|
201
|
+
* import { Agent, Agents } from 'praisonai';
|
|
202
|
+
*
|
|
203
|
+
* const researcher = new Agent({ instructions: "Research the topic" });
|
|
204
|
+
* const writer = new Agent({ instructions: "Write based on research" });
|
|
205
|
+
*
|
|
206
|
+
* const agents = new Agents([researcher, writer]);
|
|
207
|
+
* await agents.start();
|
|
208
|
+
* ```
|
|
209
|
+
*
|
|
210
|
+
* @example Config object syntax
|
|
211
|
+
* ```typescript
|
|
212
|
+
* const agents = new Agents({
|
|
213
|
+
* agents: [researcher, writer],
|
|
214
|
+
* process: 'parallel'
|
|
215
|
+
* });
|
|
216
|
+
* ```
|
|
217
|
+
*/
|
|
62
218
|
export declare class PraisonAIAgents {
|
|
63
219
|
private agents;
|
|
64
220
|
private tasks;
|
|
65
221
|
private verbose;
|
|
66
222
|
private pretty;
|
|
67
223
|
private process;
|
|
68
|
-
|
|
224
|
+
/**
|
|
225
|
+
* Create a multi-agent orchestration
|
|
226
|
+
* @param configOrAgents - Either an array of agents or a config object
|
|
227
|
+
*/
|
|
228
|
+
constructor(configOrAgents: PraisonAIAgentsConfig | Agent[]);
|
|
69
229
|
private generateTasks;
|
|
70
230
|
private executeSequential;
|
|
71
231
|
start(): Promise<string[]>;
|
|
72
232
|
chat(): Promise<string[]>;
|
|
73
233
|
}
|
|
234
|
+
/**
|
|
235
|
+
* Agents - Alias for PraisonAIAgents
|
|
236
|
+
*
|
|
237
|
+
* This is the recommended class name for multi-agent orchestration.
|
|
238
|
+
* PraisonAIAgents is kept for backward compatibility.
|
|
239
|
+
*
|
|
240
|
+
* @example
|
|
241
|
+
* ```typescript
|
|
242
|
+
* import { Agent, Agents } from 'praisonai';
|
|
243
|
+
*
|
|
244
|
+
* const agents = new Agents([
|
|
245
|
+
* new Agent({ instructions: "Research the topic" }),
|
|
246
|
+
* new Agent({ instructions: "Write based on research" })
|
|
247
|
+
* ]);
|
|
248
|
+
* await agents.start();
|
|
249
|
+
* ```
|
|
250
|
+
*/
|
|
251
|
+
export declare const Agents: typeof PraisonAIAgents;
|