praisonai 1.0.12 → 1.0.14
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/proxy.d.ts +2 -0
- package/dist/agent/proxy.js +17 -8
- package/dist/agent/simple.d.ts +4 -2
- package/dist/agent/simple.js +44 -23
- package/package.json +4 -3
package/dist/agent/proxy.d.ts
CHANGED
|
@@ -7,7 +7,9 @@ export interface ProxyAgentConfig extends Partial<SimpleAgentConfig>, Partial<Ta
|
|
|
7
7
|
export declare class Agent {
|
|
8
8
|
private simpleAgent;
|
|
9
9
|
private taskAgent;
|
|
10
|
+
private instructions;
|
|
10
11
|
constructor(config: ProxyAgentConfig);
|
|
12
|
+
getInstructions(): string;
|
|
11
13
|
execute(input: Task | string): Promise<any>;
|
|
12
14
|
start(prompt: string, previousResult?: string): Promise<string>;
|
|
13
15
|
chat(prompt: string, previousResult?: string): Promise<string>;
|
package/dist/agent/proxy.js
CHANGED
|
@@ -8,6 +8,7 @@ class Agent {
|
|
|
8
8
|
constructor(config) {
|
|
9
9
|
this.simpleAgent = null;
|
|
10
10
|
this.taskAgent = null;
|
|
11
|
+
this.instructions = config.instructions || '';
|
|
11
12
|
// Auto-detect mode based on task presence
|
|
12
13
|
if (config.task) {
|
|
13
14
|
const taskConfig = {
|
|
@@ -23,7 +24,7 @@ class Agent {
|
|
|
23
24
|
}
|
|
24
25
|
else {
|
|
25
26
|
const simpleConfig = {
|
|
26
|
-
instructions:
|
|
27
|
+
instructions: this.instructions,
|
|
27
28
|
name: config.name,
|
|
28
29
|
verbose: config.verbose,
|
|
29
30
|
llm: config.llm,
|
|
@@ -32,6 +33,9 @@ class Agent {
|
|
|
32
33
|
this.simpleAgent = new simple_1.Agent(simpleConfig);
|
|
33
34
|
}
|
|
34
35
|
}
|
|
36
|
+
getInstructions() {
|
|
37
|
+
return this.instructions;
|
|
38
|
+
}
|
|
35
39
|
async execute(input) {
|
|
36
40
|
if (this.taskAgent) {
|
|
37
41
|
const task = input;
|
|
@@ -82,9 +86,9 @@ class PraisonAIAgents {
|
|
|
82
86
|
this.simpleImpl = null;
|
|
83
87
|
this.taskImpl = null;
|
|
84
88
|
// Auto-detect mode based on tasks type
|
|
85
|
-
if (Array.isArray(config.tasks)
|
|
86
|
-
// If tasks are strings, use simple mode
|
|
87
|
-
if (typeof config.tasks[0] === 'string') {
|
|
89
|
+
if (Array.isArray(config.tasks)) {
|
|
90
|
+
// If tasks are provided and are strings, use simple mode
|
|
91
|
+
if (config.tasks.length > 0 && typeof config.tasks[0] === 'string') {
|
|
88
92
|
this.simpleImpl = new simple_1.PraisonAIAgents({
|
|
89
93
|
agents: config.agents,
|
|
90
94
|
tasks: config.tasks,
|
|
@@ -92,8 +96,8 @@ class PraisonAIAgents {
|
|
|
92
96
|
process: config.process
|
|
93
97
|
});
|
|
94
98
|
}
|
|
95
|
-
else {
|
|
96
|
-
//
|
|
99
|
+
else if (config.tasks.length > 0) {
|
|
100
|
+
// If tasks are provided but not strings, use task mode
|
|
97
101
|
this.taskImpl = new types_1.PraisonAIAgents({
|
|
98
102
|
agents: config.agents,
|
|
99
103
|
tasks: config.tasks,
|
|
@@ -103,8 +107,13 @@ class PraisonAIAgents {
|
|
|
103
107
|
});
|
|
104
108
|
}
|
|
105
109
|
}
|
|
106
|
-
|
|
107
|
-
|
|
110
|
+
// If no tasks provided, create simple implementation with auto-generated tasks
|
|
111
|
+
if (!this.simpleImpl && !this.taskImpl) {
|
|
112
|
+
this.simpleImpl = new simple_1.PraisonAIAgents({
|
|
113
|
+
agents: config.agents,
|
|
114
|
+
verbose: config.verbose,
|
|
115
|
+
process: config.process
|
|
116
|
+
});
|
|
108
117
|
}
|
|
109
118
|
}
|
|
110
119
|
async start() {
|
package/dist/agent/simple.d.ts
CHANGED
|
@@ -22,10 +22,11 @@ export declare class Agent {
|
|
|
22
22
|
chat(prompt: string, previousResult?: string): Promise<string>;
|
|
23
23
|
execute(previousResult?: string): Promise<string>;
|
|
24
24
|
getResult(): string | null;
|
|
25
|
+
getInstructions(): string;
|
|
25
26
|
}
|
|
26
27
|
export interface PraisonAIAgentsConfig {
|
|
27
28
|
agents: Agent[];
|
|
28
|
-
tasks
|
|
29
|
+
tasks?: string[];
|
|
29
30
|
verbose?: boolean;
|
|
30
31
|
pretty?: boolean;
|
|
31
32
|
process?: 'sequential' | 'parallel';
|
|
@@ -37,7 +38,8 @@ export declare class PraisonAIAgents {
|
|
|
37
38
|
private pretty;
|
|
38
39
|
private process;
|
|
39
40
|
constructor(config: PraisonAIAgentsConfig);
|
|
41
|
+
private generateTasks;
|
|
42
|
+
private executeSequential;
|
|
40
43
|
start(): Promise<string[]>;
|
|
41
44
|
chat(): Promise<string[]>;
|
|
42
|
-
private executeSequential;
|
|
43
45
|
}
|
package/dist/agent/simple.js
CHANGED
|
@@ -60,51 +60,72 @@ class Agent {
|
|
|
60
60
|
getResult() {
|
|
61
61
|
return null;
|
|
62
62
|
}
|
|
63
|
+
getInstructions() {
|
|
64
|
+
return this.instructions;
|
|
65
|
+
}
|
|
63
66
|
}
|
|
64
67
|
exports.Agent = Agent;
|
|
65
68
|
class PraisonAIAgents {
|
|
66
69
|
constructor(config) {
|
|
67
70
|
this.agents = config.agents;
|
|
68
|
-
this.
|
|
69
|
-
this.
|
|
70
|
-
this.pretty = config.pretty || false;
|
|
71
|
+
this.verbose = config.verbose ?? process.env.PRAISON_VERBOSE !== 'false';
|
|
72
|
+
this.pretty = config.pretty ?? process.env.PRAISON_PRETTY === 'true';
|
|
71
73
|
this.process = config.process || 'sequential';
|
|
74
|
+
// Auto-generate tasks if not provided
|
|
75
|
+
this.tasks = config.tasks || this.generateTasks();
|
|
72
76
|
// Configure logging
|
|
73
|
-
logger_1.Logger.setVerbose(
|
|
74
|
-
logger_1.Logger.setPretty(
|
|
77
|
+
logger_1.Logger.setVerbose(this.verbose);
|
|
78
|
+
logger_1.Logger.setPretty(this.pretty);
|
|
79
|
+
}
|
|
80
|
+
generateTasks() {
|
|
81
|
+
return this.agents.map(agent => {
|
|
82
|
+
const instructions = agent.getInstructions();
|
|
83
|
+
// Extract task from instructions - get first sentence or whole instruction if no period
|
|
84
|
+
const task = instructions.split('.')[0].trim();
|
|
85
|
+
return task;
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
async executeSequential() {
|
|
89
|
+
const results = [];
|
|
90
|
+
let previousResult;
|
|
91
|
+
for (let i = 0; i < this.agents.length; i++) {
|
|
92
|
+
const agent = this.agents[i];
|
|
93
|
+
const task = this.tasks[i];
|
|
94
|
+
await logger_1.Logger.debug(`Running agent ${i + 1}: ${agent.name}`);
|
|
95
|
+
await logger_1.Logger.debug(`Task: ${task}`);
|
|
96
|
+
const result = await agent.start(task, previousResult);
|
|
97
|
+
results.push(result);
|
|
98
|
+
previousResult = result;
|
|
99
|
+
}
|
|
100
|
+
return results;
|
|
75
101
|
}
|
|
76
102
|
async start() {
|
|
77
103
|
await logger_1.Logger.debug('Starting PraisonAI Agents execution...');
|
|
104
|
+
await logger_1.Logger.debug('Process mode:', this.process);
|
|
105
|
+
await logger_1.Logger.debug('Tasks:', this.tasks);
|
|
78
106
|
let results;
|
|
79
107
|
if (this.process === 'parallel') {
|
|
80
|
-
|
|
108
|
+
// Run all agents in parallel
|
|
109
|
+
const promises = this.agents.map((agent, i) => {
|
|
110
|
+
const task = this.tasks[i];
|
|
111
|
+
return agent.start(task);
|
|
112
|
+
});
|
|
113
|
+
results = await Promise.all(promises);
|
|
81
114
|
}
|
|
82
115
|
else {
|
|
116
|
+
// Run agents sequentially (default)
|
|
83
117
|
results = await this.executeSequential();
|
|
84
118
|
}
|
|
85
119
|
if (this.verbose) {
|
|
86
|
-
|
|
87
|
-
results.
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
});
|
|
120
|
+
await logger_1.Logger.info('PraisonAI Agents execution completed.');
|
|
121
|
+
for (let i = 0; i < results.length; i++) {
|
|
122
|
+
await logger_1.Logger.section(`Result from Agent ${i + 1}`, results[i]);
|
|
123
|
+
}
|
|
91
124
|
}
|
|
92
125
|
return results;
|
|
93
126
|
}
|
|
94
127
|
async chat() {
|
|
95
128
|
return this.start();
|
|
96
129
|
}
|
|
97
|
-
async executeSequential() {
|
|
98
|
-
const results = [];
|
|
99
|
-
for (let i = 0; i < this.agents.length; i++) {
|
|
100
|
-
const agent = this.agents[i];
|
|
101
|
-
const task = this.tasks[i];
|
|
102
|
-
const previousResult = i > 0 ? results[i - 1] : undefined;
|
|
103
|
-
await logger_1.Logger.info(`Agent ${agent.name} starting with prompt: ${task}`);
|
|
104
|
-
const result = await agent.start(task, previousResult);
|
|
105
|
-
results.push(result);
|
|
106
|
-
}
|
|
107
|
-
return results;
|
|
108
|
-
}
|
|
109
130
|
}
|
|
110
131
|
exports.PraisonAIAgents = PraisonAIAgents;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "praisonai",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.14",
|
|
4
4
|
"description": "PraisonAI TypeScript AI Agents Framework - Node.js, npm, and Javascript AI Agents Framework",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"fast-xml-parser": "^4.5.1",
|
|
63
63
|
"node-fetch": "^3.3.2",
|
|
64
64
|
"openai": "^4.81.0",
|
|
65
|
-
"praisonai": "^1.0.
|
|
65
|
+
"praisonai": "^1.0.12"
|
|
66
66
|
},
|
|
67
67
|
"optionalDependencies": {
|
|
68
68
|
"boxen": "^7.1.1",
|
|
@@ -72,7 +72,8 @@
|
|
|
72
72
|
"ora": "^5.4.1"
|
|
73
73
|
},
|
|
74
74
|
"overrides": {
|
|
75
|
-
"whatwg-url": "^14.1.0"
|
|
75
|
+
"whatwg-url": "^14.1.0",
|
|
76
|
+
"node-fetch": "^3.3.2"
|
|
76
77
|
},
|
|
77
78
|
"engines": {
|
|
78
79
|
"node": ">=14.0.0"
|