praisonai 1.0.0 → 1.0.2
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/README.md +89 -2
- package/dist/agent/agent.d.ts +0 -0
- package/dist/agent/agent.js +1 -0
- package/dist/agent/index.d.ts +5 -0
- package/dist/agent/index.js +13 -0
- package/dist/agent/proxy.d.ts +19 -0
- package/dist/agent/proxy.js +89 -0
- package/dist/agent/simple.d.ts +35 -0
- package/dist/agent/simple.js +86 -0
- package/dist/agent/types.d.ts +56 -0
- package/dist/agent/types.js +157 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +23 -0
- package/dist/knowledge/chunking.d.ts +0 -0
- package/dist/knowledge/chunking.js +1 -0
- package/dist/knowledge/index.d.ts +22 -0
- package/dist/knowledge/index.js +29 -0
- package/dist/knowledge/knowledge.d.ts +0 -0
- package/dist/knowledge/knowledge.js +1 -0
- package/dist/llm/index.d.ts +27 -0
- package/dist/llm/index.js +15 -0
- package/dist/llm/llm.d.ts +0 -0
- package/dist/llm/llm.js +1 -0
- package/dist/llm/openai.d.ts +15 -0
- package/dist/llm/openai.js +86 -0
- package/dist/main.d.ts +0 -0
- package/dist/main.js +1 -0
- package/dist/memory/index.d.ts +24 -0
- package/dist/memory/index.js +31 -0
- package/dist/memory/memory.d.ts +0 -0
- package/dist/memory/memory.js +1 -0
- package/dist/process/index.d.ts +25 -0
- package/dist/process/index.js +37 -0
- package/dist/process/process.d.ts +0 -0
- package/dist/process/process.js +1 -0
- package/dist/task/index.d.ts +25 -0
- package/dist/task/index.js +32 -0
- package/dist/task/task.d.ts +0 -0
- package/dist/task/task.js +1 -0
- package/dist/tools/arxivTools.d.ts +19 -0
- package/dist/tools/arxivTools.js +75 -0
- package/dist/tools/index.d.ts +12 -0
- package/dist/tools/index.js +29 -0
- package/dist/tools/test.d.ts +0 -0
- package/dist/tools/test.js +1 -0
- package/dist/utils/logger.d.ts +15 -0
- package/dist/utils/logger.js +54 -0
- package/package.json +68 -7
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface LLMConfig {
|
|
2
|
+
model: string;
|
|
3
|
+
temperature?: number;
|
|
4
|
+
maxTokens?: number;
|
|
5
|
+
apiKey?: string;
|
|
6
|
+
baseURL?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface LLMResponse {
|
|
9
|
+
text: string;
|
|
10
|
+
usage?: {
|
|
11
|
+
promptTokens: number;
|
|
12
|
+
completionTokens: number;
|
|
13
|
+
totalTokens: number;
|
|
14
|
+
};
|
|
15
|
+
metadata?: Record<string, any>;
|
|
16
|
+
}
|
|
17
|
+
export interface LLM {
|
|
18
|
+
config: LLMConfig;
|
|
19
|
+
generate(prompt: string): Promise<LLMResponse>;
|
|
20
|
+
generateStream(prompt: string): AsyncGenerator<string, void, unknown>;
|
|
21
|
+
}
|
|
22
|
+
export declare class BaseLLM implements LLM {
|
|
23
|
+
config: LLMConfig;
|
|
24
|
+
constructor(config: LLMConfig);
|
|
25
|
+
generate(prompt: string): Promise<LLMResponse>;
|
|
26
|
+
generateStream(prompt: string): AsyncGenerator<string, void, unknown>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseLLM = void 0;
|
|
4
|
+
class BaseLLM {
|
|
5
|
+
constructor(config) {
|
|
6
|
+
this.config = config;
|
|
7
|
+
}
|
|
8
|
+
async generate(prompt) {
|
|
9
|
+
throw new Error('Method not implemented.');
|
|
10
|
+
}
|
|
11
|
+
async *generateStream(prompt) {
|
|
12
|
+
throw new Error('Method not implemented.');
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.BaseLLM = BaseLLM;
|
|
File without changes
|
package/dist/llm/llm.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface LLMResponse {
|
|
2
|
+
content: string;
|
|
3
|
+
role: string;
|
|
4
|
+
}
|
|
5
|
+
export declare class OpenAIService {
|
|
6
|
+
private client;
|
|
7
|
+
private model;
|
|
8
|
+
constructor(model?: string);
|
|
9
|
+
generateText(prompt: string, systemPrompt?: string, temperature?: number): Promise<string>;
|
|
10
|
+
streamText(prompt: string, systemPrompt: string | undefined, temperature: number | undefined, onToken: (token: string) => void): Promise<void>;
|
|
11
|
+
chatCompletion(messages: Array<{
|
|
12
|
+
role: 'system' | 'user' | 'assistant';
|
|
13
|
+
content: string;
|
|
14
|
+
}>, temperature?: number): Promise<LLMResponse>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.OpenAIService = void 0;
|
|
7
|
+
const openai_1 = __importDefault(require("openai"));
|
|
8
|
+
const dotenv_1 = __importDefault(require("dotenv"));
|
|
9
|
+
const logger_1 = require("../utils/logger");
|
|
10
|
+
dotenv_1.default.config();
|
|
11
|
+
class OpenAIService {
|
|
12
|
+
constructor(model = 'gpt-4o-mini') {
|
|
13
|
+
if (!process.env.OPENAI_API_KEY) {
|
|
14
|
+
throw new Error('OPENAI_API_KEY not found in environment variables');
|
|
15
|
+
}
|
|
16
|
+
this.client = new openai_1.default({
|
|
17
|
+
apiKey: process.env.OPENAI_API_KEY
|
|
18
|
+
});
|
|
19
|
+
this.model = model;
|
|
20
|
+
logger_1.Logger.debug(`OpenAIService initialized with model: ${model}`);
|
|
21
|
+
}
|
|
22
|
+
async generateText(prompt, systemPrompt = '', temperature = 0.7) {
|
|
23
|
+
logger_1.Logger.debug('Generating text with OpenAI', {
|
|
24
|
+
model: this.model,
|
|
25
|
+
temperature,
|
|
26
|
+
systemPrompt,
|
|
27
|
+
prompt
|
|
28
|
+
});
|
|
29
|
+
const completion = await this.client.chat.completions.create({
|
|
30
|
+
model: this.model,
|
|
31
|
+
messages: [
|
|
32
|
+
{ role: 'system', content: systemPrompt },
|
|
33
|
+
{ role: 'user', content: prompt }
|
|
34
|
+
],
|
|
35
|
+
temperature,
|
|
36
|
+
});
|
|
37
|
+
const response = completion.choices[0].message.content || '';
|
|
38
|
+
logger_1.Logger.debug('OpenAI response received', { response });
|
|
39
|
+
return response;
|
|
40
|
+
}
|
|
41
|
+
async streamText(prompt, systemPrompt = '', temperature = 0.7, onToken) {
|
|
42
|
+
logger_1.Logger.debug('Streaming text with OpenAI', {
|
|
43
|
+
model: this.model,
|
|
44
|
+
temperature,
|
|
45
|
+
systemPrompt,
|
|
46
|
+
prompt
|
|
47
|
+
});
|
|
48
|
+
const stream = await this.client.chat.completions.create({
|
|
49
|
+
model: this.model,
|
|
50
|
+
messages: [
|
|
51
|
+
{ role: 'system', content: systemPrompt },
|
|
52
|
+
{ role: 'user', content: prompt }
|
|
53
|
+
],
|
|
54
|
+
temperature,
|
|
55
|
+
stream: true,
|
|
56
|
+
});
|
|
57
|
+
let fullResponse = '';
|
|
58
|
+
for await (const chunk of stream) {
|
|
59
|
+
const content = chunk.choices[0]?.delta?.content;
|
|
60
|
+
if (content) {
|
|
61
|
+
onToken(content);
|
|
62
|
+
fullResponse += content;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
logger_1.Logger.debug('OpenAI streaming completed', { fullResponse });
|
|
66
|
+
}
|
|
67
|
+
async chatCompletion(messages, temperature = 0.7) {
|
|
68
|
+
logger_1.Logger.debug('Chat completion with OpenAI', {
|
|
69
|
+
model: this.model,
|
|
70
|
+
temperature,
|
|
71
|
+
messages
|
|
72
|
+
});
|
|
73
|
+
const completion = await this.client.chat.completions.create({
|
|
74
|
+
model: this.model,
|
|
75
|
+
messages,
|
|
76
|
+
temperature,
|
|
77
|
+
});
|
|
78
|
+
const response = {
|
|
79
|
+
content: completion.choices[0].message.content || '',
|
|
80
|
+
role: completion.choices[0].message.role
|
|
81
|
+
};
|
|
82
|
+
logger_1.Logger.debug('OpenAI chat completion response received', { response });
|
|
83
|
+
return response;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
exports.OpenAIService = OpenAIService;
|
package/dist/main.d.ts
ADDED
|
File without changes
|
package/dist/main.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface Memory {
|
|
2
|
+
id: string;
|
|
3
|
+
content: any;
|
|
4
|
+
timestamp: Date;
|
|
5
|
+
metadata: Record<string, any>;
|
|
6
|
+
}
|
|
7
|
+
export interface MemoryStore {
|
|
8
|
+
add(memory: Memory): void;
|
|
9
|
+
get(id: string): Memory | undefined;
|
|
10
|
+
search(query: string): Memory[];
|
|
11
|
+
update(id: string, memory: Partial<Memory>): boolean;
|
|
12
|
+
delete(id: string): boolean;
|
|
13
|
+
clear(): void;
|
|
14
|
+
}
|
|
15
|
+
export declare class BaseMemoryStore implements MemoryStore {
|
|
16
|
+
private memories;
|
|
17
|
+
constructor();
|
|
18
|
+
add(memory: Memory): void;
|
|
19
|
+
get(id: string): Memory | undefined;
|
|
20
|
+
search(query: string): Memory[];
|
|
21
|
+
update(id: string, update: Partial<Memory>): boolean;
|
|
22
|
+
delete(id: string): boolean;
|
|
23
|
+
clear(): void;
|
|
24
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseMemoryStore = void 0;
|
|
4
|
+
class BaseMemoryStore {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.memories = new Map();
|
|
7
|
+
}
|
|
8
|
+
add(memory) {
|
|
9
|
+
this.memories.set(memory.id, memory);
|
|
10
|
+
}
|
|
11
|
+
get(id) {
|
|
12
|
+
return this.memories.get(id);
|
|
13
|
+
}
|
|
14
|
+
search(query) {
|
|
15
|
+
return Array.from(this.memories.values()).filter(m => JSON.stringify(m).toLowerCase().includes(query.toLowerCase()));
|
|
16
|
+
}
|
|
17
|
+
update(id, update) {
|
|
18
|
+
const existing = this.memories.get(id);
|
|
19
|
+
if (!existing)
|
|
20
|
+
return false;
|
|
21
|
+
this.memories.set(id, { ...existing, ...update });
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
delete(id) {
|
|
25
|
+
return this.memories.delete(id);
|
|
26
|
+
}
|
|
27
|
+
clear() {
|
|
28
|
+
this.memories.clear();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.BaseMemoryStore = BaseMemoryStore;
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface ProcessConfig {
|
|
2
|
+
maxRetries?: number;
|
|
3
|
+
timeout?: number;
|
|
4
|
+
metadata?: Record<string, any>;
|
|
5
|
+
}
|
|
6
|
+
export interface Process {
|
|
7
|
+
id: string;
|
|
8
|
+
status: 'pending' | 'running' | 'completed' | 'failed';
|
|
9
|
+
config: ProcessConfig;
|
|
10
|
+
start(): Promise<void>;
|
|
11
|
+
stop(): Promise<void>;
|
|
12
|
+
getStatus(): string;
|
|
13
|
+
getResult(): any;
|
|
14
|
+
}
|
|
15
|
+
export declare class BaseProcess implements Process {
|
|
16
|
+
id: string;
|
|
17
|
+
status: 'pending' | 'running' | 'completed' | 'failed';
|
|
18
|
+
config: ProcessConfig;
|
|
19
|
+
private result;
|
|
20
|
+
constructor(id: string, config?: ProcessConfig);
|
|
21
|
+
start(): Promise<void>;
|
|
22
|
+
stop(): Promise<void>;
|
|
23
|
+
getStatus(): string;
|
|
24
|
+
getResult(): any;
|
|
25
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseProcess = void 0;
|
|
4
|
+
class BaseProcess {
|
|
5
|
+
constructor(id, config = {}) {
|
|
6
|
+
this.id = id;
|
|
7
|
+
this.status = 'pending';
|
|
8
|
+
this.config = {
|
|
9
|
+
maxRetries: 3,
|
|
10
|
+
timeout: 30000,
|
|
11
|
+
...config
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
async start() {
|
|
15
|
+
this.status = 'running';
|
|
16
|
+
try {
|
|
17
|
+
// Implement process logic here
|
|
18
|
+
this.status = 'completed';
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
this.status = 'failed';
|
|
22
|
+
throw error;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
async stop() {
|
|
26
|
+
if (this.status === 'running') {
|
|
27
|
+
this.status = 'failed';
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
getStatus() {
|
|
31
|
+
return this.status;
|
|
32
|
+
}
|
|
33
|
+
getResult() {
|
|
34
|
+
return this.result;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.BaseProcess = BaseProcess;
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface TaskConfig {
|
|
2
|
+
priority?: number;
|
|
3
|
+
deadline?: Date;
|
|
4
|
+
dependencies?: string[];
|
|
5
|
+
metadata?: Record<string, any>;
|
|
6
|
+
}
|
|
7
|
+
export interface Task {
|
|
8
|
+
id: string;
|
|
9
|
+
name: string;
|
|
10
|
+
description: string;
|
|
11
|
+
status: 'pending' | 'in-progress' | 'completed' | 'failed';
|
|
12
|
+
config: TaskConfig;
|
|
13
|
+
execute(): Promise<void>;
|
|
14
|
+
cancel(): Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
export declare class BaseTask implements Task {
|
|
17
|
+
id: string;
|
|
18
|
+
name: string;
|
|
19
|
+
description: string;
|
|
20
|
+
status: 'pending' | 'in-progress' | 'completed' | 'failed';
|
|
21
|
+
config: TaskConfig;
|
|
22
|
+
constructor(id: string, name: string, description: string, config?: TaskConfig);
|
|
23
|
+
execute(): Promise<void>;
|
|
24
|
+
cancel(): Promise<void>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseTask = void 0;
|
|
4
|
+
class BaseTask {
|
|
5
|
+
constructor(id, name, description, config = {}) {
|
|
6
|
+
this.id = id;
|
|
7
|
+
this.name = name;
|
|
8
|
+
this.description = description;
|
|
9
|
+
this.status = 'pending';
|
|
10
|
+
this.config = {
|
|
11
|
+
priority: 1,
|
|
12
|
+
...config
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
async execute() {
|
|
16
|
+
this.status = 'in-progress';
|
|
17
|
+
try {
|
|
18
|
+
// Implement task execution logic here
|
|
19
|
+
this.status = 'completed';
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
this.status = 'failed';
|
|
23
|
+
throw error;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
async cancel() {
|
|
27
|
+
if (this.status === 'in-progress') {
|
|
28
|
+
this.status = 'failed';
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.BaseTask = BaseTask;
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { BaseTool } from './index';
|
|
2
|
+
export interface ArxivPaper {
|
|
3
|
+
id: string;
|
|
4
|
+
title: string;
|
|
5
|
+
authors: string[];
|
|
6
|
+
summary: string;
|
|
7
|
+
published: string;
|
|
8
|
+
updated: string;
|
|
9
|
+
link: string;
|
|
10
|
+
}
|
|
11
|
+
export declare class ArxivSearchTool extends BaseTool {
|
|
12
|
+
private parser;
|
|
13
|
+
constructor();
|
|
14
|
+
execute(query: string, maxResults?: number): Promise<ArxivPaper[]>;
|
|
15
|
+
}
|
|
16
|
+
export declare class ArxivDownloadTool extends BaseTool {
|
|
17
|
+
constructor();
|
|
18
|
+
execute(paperId: string): Promise<Buffer>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ArxivDownloadTool = exports.ArxivSearchTool = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const index_1 = require("./index");
|
|
9
|
+
const fast_xml_parser_1 = require("fast-xml-parser");
|
|
10
|
+
class ArxivSearchTool extends index_1.BaseTool {
|
|
11
|
+
constructor() {
|
|
12
|
+
super('arxiv-search', 'Search for academic papers on arXiv');
|
|
13
|
+
this.parser = new fast_xml_parser_1.XMLParser({
|
|
14
|
+
ignoreAttributes: false,
|
|
15
|
+
attributeNamePrefix: '@_'
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
async execute(query, maxResults = 10) {
|
|
19
|
+
try {
|
|
20
|
+
const response = await axios_1.default.get(`http://export.arxiv.org/api/query`, {
|
|
21
|
+
params: {
|
|
22
|
+
search_query: encodeURIComponent(query),
|
|
23
|
+
max_results: maxResults,
|
|
24
|
+
sortBy: 'lastUpdatedDate',
|
|
25
|
+
sortOrder: 'descending'
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
const parsed = this.parser.parse(response.data);
|
|
29
|
+
const entries = parsed.feed.entry;
|
|
30
|
+
if (!entries) {
|
|
31
|
+
return [];
|
|
32
|
+
}
|
|
33
|
+
// Handle both single and multiple entries
|
|
34
|
+
const entriesArray = Array.isArray(entries) ? entries : [entries];
|
|
35
|
+
return entriesArray.map((entry) => ({
|
|
36
|
+
id: entry.id.split('/abs/')[1],
|
|
37
|
+
title: entry.title.replace(/\s+/g, ' ').trim(),
|
|
38
|
+
authors: Array.isArray(entry.author)
|
|
39
|
+
? entry.author.map((a) => a.name)
|
|
40
|
+
: [entry.author.name],
|
|
41
|
+
summary: entry.summary.replace(/\s+/g, ' ').trim(),
|
|
42
|
+
published: entry.published,
|
|
43
|
+
updated: entry.updated,
|
|
44
|
+
link: entry.id
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
if (error instanceof Error) {
|
|
49
|
+
throw new Error(`Failed to search arXiv: ${error.message}`);
|
|
50
|
+
}
|
|
51
|
+
throw new Error('Failed to search arXiv: Unknown error');
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.ArxivSearchTool = ArxivSearchTool;
|
|
56
|
+
class ArxivDownloadTool extends index_1.BaseTool {
|
|
57
|
+
constructor() {
|
|
58
|
+
super('arxiv-download', 'Download PDF of an arXiv paper');
|
|
59
|
+
}
|
|
60
|
+
async execute(paperId) {
|
|
61
|
+
try {
|
|
62
|
+
const response = await axios_1.default.get(`https://arxiv.org/pdf/${paperId}.pdf`, {
|
|
63
|
+
responseType: 'arraybuffer'
|
|
64
|
+
});
|
|
65
|
+
return Buffer.from(response.data);
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
if (error instanceof Error) {
|
|
69
|
+
throw new Error(`Failed to download paper: ${error.message}`);
|
|
70
|
+
}
|
|
71
|
+
throw new Error('Failed to download paper: Unknown error');
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.ArxivDownloadTool = ArxivDownloadTool;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface Tool {
|
|
2
|
+
name: string;
|
|
3
|
+
description: string;
|
|
4
|
+
execute(...args: any[]): Promise<any>;
|
|
5
|
+
}
|
|
6
|
+
export declare class BaseTool implements Tool {
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
constructor(name: string, description: string);
|
|
10
|
+
execute(...args: any[]): Promise<any>;
|
|
11
|
+
}
|
|
12
|
+
export * from './arxivTools';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.BaseTool = void 0;
|
|
18
|
+
class BaseTool {
|
|
19
|
+
constructor(name, description) {
|
|
20
|
+
this.name = name;
|
|
21
|
+
this.description = description;
|
|
22
|
+
}
|
|
23
|
+
async execute(...args) {
|
|
24
|
+
throw new Error('Method not implemented.');
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.BaseTool = BaseTool;
|
|
28
|
+
// Export all tool modules
|
|
29
|
+
__exportStar(require("./arxivTools"), exports);
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare enum LogLevel {
|
|
2
|
+
DEBUG = 0,
|
|
3
|
+
INFO = 1,
|
|
4
|
+
WARN = 2,
|
|
5
|
+
ERROR = 3
|
|
6
|
+
}
|
|
7
|
+
export declare class Logger {
|
|
8
|
+
private static level;
|
|
9
|
+
private static getCircularReplacer;
|
|
10
|
+
private static formatContext;
|
|
11
|
+
static debug(message: string, context?: any): void;
|
|
12
|
+
static info(message: string, context?: any): void;
|
|
13
|
+
static warn(message: string, context?: any): void;
|
|
14
|
+
static error(message: string, context?: any): void;
|
|
15
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Logger = exports.LogLevel = void 0;
|
|
4
|
+
var LogLevel;
|
|
5
|
+
(function (LogLevel) {
|
|
6
|
+
LogLevel[LogLevel["DEBUG"] = 0] = "DEBUG";
|
|
7
|
+
LogLevel[LogLevel["INFO"] = 1] = "INFO";
|
|
8
|
+
LogLevel[LogLevel["WARN"] = 2] = "WARN";
|
|
9
|
+
LogLevel[LogLevel["ERROR"] = 3] = "ERROR";
|
|
10
|
+
})(LogLevel || (exports.LogLevel = LogLevel = {}));
|
|
11
|
+
class Logger {
|
|
12
|
+
static getCircularReplacer() {
|
|
13
|
+
const seen = new WeakSet();
|
|
14
|
+
return (key, value) => {
|
|
15
|
+
if (typeof value === 'object' && value !== null) {
|
|
16
|
+
if (seen.has(value)) {
|
|
17
|
+
return '[Circular]';
|
|
18
|
+
}
|
|
19
|
+
seen.add(value);
|
|
20
|
+
}
|
|
21
|
+
return value;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
static formatContext(context) {
|
|
25
|
+
try {
|
|
26
|
+
return JSON.stringify(context, this.getCircularReplacer(), 2);
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
return '[Unable to stringify context]';
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
static debug(message, context) {
|
|
33
|
+
if (this.level <= LogLevel.DEBUG) {
|
|
34
|
+
console.log(`[DEBUG] ${message}${context ? '\nContext: ' + this.formatContext(context) : ''}`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
static info(message, context) {
|
|
38
|
+
if (this.level <= LogLevel.INFO) {
|
|
39
|
+
console.log(`[INFO] ${message}${context ? '\nContext: ' + this.formatContext(context) : ''}`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
static warn(message, context) {
|
|
43
|
+
if (this.level <= LogLevel.WARN) {
|
|
44
|
+
console.warn(`[WARN] ${message}${context ? '\nContext: ' + this.formatContext(context) : ''}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
static error(message, context) {
|
|
48
|
+
if (this.level <= LogLevel.ERROR) {
|
|
49
|
+
console.error(`[ERROR] ${message}${context ? '\nContext: ' + this.formatContext(context) : ''}`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.Logger = Logger;
|
|
54
|
+
Logger.level = process.env.LOGLEVEL === 'debug' ? LogLevel.DEBUG : LogLevel.INFO;
|
package/package.json
CHANGED
|
@@ -1,12 +1,73 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "praisonai",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "AI
|
|
5
|
-
"main": "index.js",
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"description": "PraisonAI TypeScript AI Agents Framework - Node.js, npm, and Javascript AI Agents Framework",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
6
7
|
"scripts": {
|
|
7
|
-
"
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"test": "jest",
|
|
10
|
+
"lint": "eslint . --ext .ts",
|
|
11
|
+
"prepare": "npm run build",
|
|
12
|
+
"start": "ts-node src/main.ts",
|
|
13
|
+
"dev": "ts-node-dev --respawn src/main.ts",
|
|
14
|
+
"example:arxiv": "ts-node examples/tools/arxiv-tools.ts",
|
|
15
|
+
"clean": "rimraf dist",
|
|
16
|
+
"prebuild": "npm run clean"
|
|
8
17
|
},
|
|
9
|
-
"keywords": [
|
|
10
|
-
|
|
11
|
-
|
|
18
|
+
"keywords": [
|
|
19
|
+
"ai",
|
|
20
|
+
"agent",
|
|
21
|
+
"ai agent",
|
|
22
|
+
"ai agents",
|
|
23
|
+
"typescript ai",
|
|
24
|
+
"typescript ai agent",
|
|
25
|
+
"javascript ai agent",
|
|
26
|
+
"typescript ai agents",
|
|
27
|
+
"javascript ai agents",
|
|
28
|
+
"npm ai agent framework",
|
|
29
|
+
"npm ai agents framework",
|
|
30
|
+
"node ai agent framework",
|
|
31
|
+
"node ai agents framework",
|
|
32
|
+
"praisonai",
|
|
33
|
+
"ai agents framework",
|
|
34
|
+
"typescript ai agents framework",
|
|
35
|
+
"javascript ai agents framework",
|
|
36
|
+
"ai framework",
|
|
37
|
+
"typescript ai framework",
|
|
38
|
+
"javascript ai framework",
|
|
39
|
+
"ai agent framework",
|
|
40
|
+
"typescript ai agent framework",
|
|
41
|
+
"javascript ai agent framework"
|
|
42
|
+
],
|
|
43
|
+
"author": "Mervin Praison",
|
|
44
|
+
"license": "MIT",
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@types/jest": "^29.5.14",
|
|
47
|
+
"@types/node": "^22.12.0",
|
|
48
|
+
"@typescript-eslint/eslint-plugin": "^8.22.0",
|
|
49
|
+
"@typescript-eslint/parser": "^8.22.0",
|
|
50
|
+
"eslint": "^8.57.0",
|
|
51
|
+
"jest": "^29.7.0",
|
|
52
|
+
"rimraf": "^5.0.5",
|
|
53
|
+
"ts-jest": "^29.1.2",
|
|
54
|
+
"ts-node": "^10.9.2",
|
|
55
|
+
"ts-node-dev": "^2.0.0",
|
|
56
|
+
"typescript": "^5.7.3"
|
|
57
|
+
},
|
|
58
|
+
"dependencies": {
|
|
59
|
+
"axios": "^1.6.7",
|
|
60
|
+
"dotenv": "^16.4.1",
|
|
61
|
+
"fast-xml-parser": "^4.3.4",
|
|
62
|
+
"openai": "^4.24.7",
|
|
63
|
+
"praisonai": "^1.0.0"
|
|
64
|
+
},
|
|
65
|
+
"engines": {
|
|
66
|
+
"node": ">=14.0.0"
|
|
67
|
+
},
|
|
68
|
+
"files": [
|
|
69
|
+
"dist",
|
|
70
|
+
"README.md",
|
|
71
|
+
"LICENSE"
|
|
72
|
+
]
|
|
12
73
|
}
|