@ai.ntellect/core 0.2.8 → 0.3.0
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.FR.md +58 -19
 - package/README.md +40 -17
 - package/agent/index.ts +54 -26
 - package/dist/agent/index.d.ts +12 -8
 - package/dist/agent/index.js +34 -12
 - package/dist/index.d.ts +2 -1
 - package/dist/index.js +2 -1
 - package/dist/llm/evaluator/context.d.ts +0 -1
 - package/dist/llm/evaluator/context.js +3 -12
 - package/dist/llm/evaluator/index.d.ts +7 -1
 - package/dist/llm/evaluator/index.js +37 -24
 - package/dist/llm/interpreter/context.d.ts +32 -0
 - package/dist/llm/interpreter/context.js +90 -0
 - package/dist/llm/interpreter/index.d.ts +17 -0
 - package/dist/llm/{synthesizer → interpreter}/index.js +18 -27
 - package/dist/llm/orchestrator/context.js +1 -1
 - package/dist/llm/orchestrator/index.d.ts +7 -3
 - package/dist/llm/orchestrator/index.js +5 -48
 - package/dist/memory/cache.d.ts +2 -2
 - package/dist/memory/cache.js +4 -5
 - package/dist/memory/persistent.d.ts +1 -0
 - package/dist/memory/persistent.js +2 -1
 - package/dist/test.d.ts +54 -0
 - package/dist/test.js +125 -20
 - package/dist/types.d.ts +12 -13
 - package/index.ts +2 -2
 - package/llm/evaluator/context.ts +3 -12
 - package/llm/evaluator/index.ts +57 -27
 - package/llm/interpreter/context.ts +89 -0
 - package/llm/{synthesizer → interpreter}/index.ts +20 -26
 - package/llm/orchestrator/context.ts +1 -1
 - package/llm/orchestrator/index.ts +14 -67
 - package/memory/cache.ts +5 -6
 - package/memory/persistent.ts +3 -1
 - package/package.json +1 -1
 - package/types.ts +13 -13
 - package/dist/llm/synthesizer/context.d.ts +0 -15
 - package/dist/llm/synthesizer/context.js +0 -71
 - package/dist/llm/synthesizer/index.d.ts +0 -14
 - package/llm/synthesizer/context.ts +0 -68
 
| 
         @@ -8,33 +8,34 @@ const types_1 = require("../../types"); 
     | 
|
| 
       8 
8 
     | 
    
         
             
            const inject_actions_1 = require("../../utils/inject-actions");
         
     | 
| 
       9 
9 
     | 
    
         
             
            const context_1 = require("./context");
         
     | 
| 
       10 
10 
     | 
    
         
             
            class Evaluator {
         
     | 
| 
       11 
     | 
    
         
            -
                constructor(tools, memory) {
         
     | 
| 
      
 11 
     | 
    
         
            +
                constructor(tools, memory, interpreters) {
         
     | 
| 
       12 
12 
     | 
    
         
             
                    this.model = (0, openai_1.openai)("gpt-4o");
         
     | 
| 
       13 
13 
     | 
    
         
             
                    this.tools = tools;
         
     | 
| 
       14 
14 
     | 
    
         
             
                    this.memory = memory;
         
     | 
| 
      
 15 
     | 
    
         
            +
                    this.interpreters = interpreters;
         
     | 
| 
       15 
16 
     | 
    
         
             
                }
         
     | 
| 
       16 
17 
     | 
    
         
             
                composeContext(state) {
         
     | 
| 
       17 
     | 
    
         
            -
                    const {  
     | 
| 
       18 
     | 
    
         
            -
                    const { role, language, guidelines } = behavior;
         
     | 
| 
       19 
     | 
    
         
            -
                    const { important, warnings 
     | 
| 
      
 18 
     | 
    
         
            +
                    const { userRequest, results } = state;
         
     | 
| 
      
 19 
     | 
    
         
            +
                    const { role, language, guidelines } = context_1.evaluatorContext.behavior;
         
     | 
| 
      
 20 
     | 
    
         
            +
                    const { important, warnings } = guidelines;
         
     | 
| 
       20 
21 
     | 
    
         
             
                    const context = `
         
     | 
| 
       21 
22 
     | 
    
         
             
                  # ROLE: ${role}
         
     | 
| 
       22 
23 
     | 
    
         
             
                  # LANGUAGE: ${language}
         
     | 
| 
       23 
24 
     | 
    
         
             
                  # IMPORTANT: ${important.join("\n")}
         
     | 
| 
       24 
25 
     | 
    
         
             
                  # NEVER: ${warnings.join("\n")}
         
     | 
| 
       25 
26 
     | 
    
         
             
                  # USER_REQUEST: ${userRequest}
         
     | 
| 
       26 
     | 
    
         
            -
                  # ACTIONS AVAILABLE: ${(0, inject_actions_1.injectActions)( 
     | 
| 
      
 27 
     | 
    
         
            +
                  # ACTIONS AVAILABLE: ${(0, inject_actions_1.injectActions)(this.tools)}
         
     | 
| 
       27 
28 
     | 
    
         
             
                  # CURRENT_RESULTS: ${results}
         
     | 
| 
       28 
     | 
    
         
            -
                  #  
     | 
| 
      
 29 
     | 
    
         
            +
                  # INTERPRETERS: ${this.interpreters
         
     | 
| 
      
 30 
     | 
    
         
            +
                        .map((interpreter) => interpreter.name)
         
     | 
| 
      
 31 
     | 
    
         
            +
                        .join(", ")}
         
     | 
| 
       29 
32 
     | 
    
         
             
                `;
         
     | 
| 
       30 
33 
     | 
    
         
             
                    return context;
         
     | 
| 
       31 
34 
     | 
    
         
             
                }
         
     | 
| 
       32 
35 
     | 
    
         
             
                async process(prompt, results) {
         
     | 
| 
       33 
36 
     | 
    
         
             
                    try {
         
     | 
| 
       34 
37 
     | 
    
         
             
                        const context = this.composeContext({
         
     | 
| 
       35 
     | 
    
         
            -
                            behavior: context_1.evaluatorContext.behavior,
         
     | 
| 
       36 
38 
     | 
    
         
             
                            userRequest: prompt,
         
     | 
| 
       37 
     | 
    
         
            -
                            actions: this.tools,
         
     | 
| 
       38 
39 
     | 
    
         
             
                            results: results,
         
     | 
| 
       39 
40 
     | 
    
         
             
                        });
         
     | 
| 
       40 
41 
     | 
    
         
             
                        console.log("\n🔍 Evaluator processing");
         
     | 
| 
         @@ -44,11 +45,11 @@ class Evaluator { 
     | 
|
| 
       44 
45 
     | 
    
         
             
                            schema: zod_1.z.object({
         
     | 
| 
       45 
46 
     | 
    
         
             
                                actionsCompleted: zod_1.z.array(zod_1.z.string()),
         
     | 
| 
       46 
47 
     | 
    
         
             
                                actionsFailed: zod_1.z.array(zod_1.z.string()),
         
     | 
| 
       47 
     | 
    
         
            -
                                 
     | 
| 
       48 
     | 
    
         
            -
             
     | 
| 
       49 
     | 
    
         
            -
                                     
     | 
| 
       50 
     | 
    
         
            -
                                    content: zod_1.z.string(),
         
     | 
| 
      
 48 
     | 
    
         
            +
                                extraInformationsToStore: zod_1.z.array(zod_1.z.object({
         
     | 
| 
      
 49 
     | 
    
         
            +
                                    memoryType: zod_1.z.enum(["episodic", "semantic", "procedural"]),
         
     | 
| 
      
 50 
     | 
    
         
            +
                                    queryForData: zod_1.z.string(),
         
     | 
| 
       51 
51 
     | 
    
         
             
                                    data: zod_1.z.string(),
         
     | 
| 
      
 52 
     | 
    
         
            +
                                    tags: zod_1.z.array(zod_1.z.string()),
         
     | 
| 
       52 
53 
     | 
    
         
             
                                })),
         
     | 
| 
       53 
54 
     | 
    
         
             
                                response: zod_1.z.string(),
         
     | 
| 
       54 
55 
     | 
    
         
             
                                isNextActionNeeded: zod_1.z.boolean(),
         
     | 
| 
         @@ -60,9 +61,10 @@ class Evaluator { 
     | 
|
| 
       60 
61 
     | 
    
         
             
                                    })),
         
     | 
| 
       61 
62 
     | 
    
         
             
                                })),
         
     | 
| 
       62 
63 
     | 
    
         
             
                                why: zod_1.z.string(),
         
     | 
| 
      
 64 
     | 
    
         
            +
                                interpreter: zod_1.z.string(),
         
     | 
| 
       63 
65 
     | 
    
         
             
                            }),
         
     | 
| 
       64 
66 
     | 
    
         
             
                            prompt: prompt,
         
     | 
| 
       65 
     | 
    
         
            -
                            system: context 
     | 
| 
      
 67 
     | 
    
         
            +
                            system: `${context}`,
         
     | 
| 
       66 
68 
     | 
    
         
             
                            temperature: 0,
         
     | 
| 
       67 
69 
     | 
    
         
             
                        });
         
     | 
| 
       68 
70 
     | 
    
         
             
                        const validatedResponse = {
         
     | 
| 
         @@ -72,30 +74,41 @@ class Evaluator { 
     | 
|
| 
       72 
74 
     | 
    
         
             
                                parameters: action.parameters || {},
         
     | 
| 
       73 
75 
     | 
    
         
             
                            })),
         
     | 
| 
       74 
76 
     | 
    
         
             
                        };
         
     | 
| 
       75 
     | 
    
         
            -
                        if (validatedResponse. 
     | 
| 
      
 77 
     | 
    
         
            +
                        if (validatedResponse.extraInformationsToStore.length > 0) {
         
     | 
| 
       76 
78 
     | 
    
         
             
                            console.log("\n💭 Processing important memories to store", validatedResponse);
         
     | 
| 
       77 
     | 
    
         
            -
                            for (const item of validatedResponse. 
     | 
| 
      
 79 
     | 
    
         
            +
                            for (const item of validatedResponse.extraInformationsToStore) {
         
     | 
| 
       78 
80 
     | 
    
         
             
                                console.log("\n📝 Processing memory item:");
         
     | 
| 
       79 
81 
     | 
    
         
             
                                console.log("Type:", item.memoryType);
         
     | 
| 
       80 
     | 
    
         
            -
                                console.log("Content:", item. 
     | 
| 
       81 
     | 
    
         
            -
                                const memories = await this.memory.searchSimilarQueries(item. 
     | 
| 
       82 
     | 
    
         
            -
                                    similarityThreshold:  
     | 
| 
      
 82 
     | 
    
         
            +
                                console.log("Content:", item.queryForData);
         
     | 
| 
      
 83 
     | 
    
         
            +
                                const memories = await this.memory.persistent.searchSimilarQueries(item.queryForData, {
         
     | 
| 
      
 84 
     | 
    
         
            +
                                    similarityThreshold: 70,
         
     | 
| 
       83 
85 
     | 
    
         
             
                                });
         
     | 
| 
       84 
86 
     | 
    
         
             
                                if (memories.length > 0) {
         
     | 
| 
       85 
87 
     | 
    
         
             
                                    console.log("🔄 Similar memory already exists - skipping");
         
     | 
| 
       86 
88 
     | 
    
         
             
                                    continue;
         
     | 
| 
       87 
89 
     | 
    
         
             
                                }
         
     | 
| 
       88 
90 
     | 
    
         
             
                                console.log("✨ Storing new memory");
         
     | 
| 
       89 
     | 
    
         
            -
                                await this.memory.createMemory({
         
     | 
| 
      
 91 
     | 
    
         
            +
                                await this.memory.persistent.createMemory({
         
     | 
| 
       90 
92 
     | 
    
         
             
                                    id: crypto.randomUUID(),
         
     | 
| 
       91 
93 
     | 
    
         
             
                                    purpose: item.memoryType,
         
     | 
| 
       92 
     | 
    
         
            -
                                    query: item. 
     | 
| 
      
 94 
     | 
    
         
            +
                                    query: item.queryForData,
         
     | 
| 
       93 
95 
     | 
    
         
             
                                    data: item.data,
         
     | 
| 
       94 
96 
     | 
    
         
             
                                    scope: types_1.MemoryScope.GLOBAL,
         
     | 
| 
       95 
97 
     | 
    
         
             
                                    createdAt: new Date(),
         
     | 
| 
       96 
98 
     | 
    
         
             
                                });
         
     | 
| 
       97 
99 
     | 
    
         
             
                            }
         
     | 
| 
       98 
100 
     | 
    
         
             
                        }
         
     | 
| 
      
 101 
     | 
    
         
            +
                        // Storing workflow actions completed
         
     | 
| 
      
 102 
     | 
    
         
            +
                        const cacheMemory = this.memory.cache;
         
     | 
| 
      
 103 
     | 
    
         
            +
                        if (cacheMemory) {
         
     | 
| 
      
 104 
     | 
    
         
            +
                            cacheMemory.createMemory({
         
     | 
| 
      
 105 
     | 
    
         
            +
                                content: prompt,
         
     | 
| 
      
 106 
     | 
    
         
            +
                                type: types_1.MemoryType.ACTION,
         
     | 
| 
      
 107 
     | 
    
         
            +
                                data: validatedResponse.actionsCompleted,
         
     | 
| 
      
 108 
     | 
    
         
            +
                                scope: types_1.MemoryScope.GLOBAL,
         
     | 
| 
      
 109 
     | 
    
         
            +
                            });
         
     | 
| 
      
 110 
     | 
    
         
            +
                            console.log("✅ Workflow actions completed stored in cache", prompt, validatedResponse.actionsCompleted);
         
     | 
| 
      
 111 
     | 
    
         
            +
                        }
         
     | 
| 
       99 
112 
     | 
    
         
             
                        console.log("\n✅ Evaluation completed");
         
     | 
| 
       100 
113 
     | 
    
         
             
                        console.log("─".repeat(50));
         
     | 
| 
       101 
114 
     | 
    
         
             
                        console.log("Results:", JSON.stringify(validatedResponse, null, 2));
         
     | 
| 
         @@ -107,16 +120,16 @@ class Evaluator { 
     | 
|
| 
       107 
120 
     | 
    
         
             
                            console.log("Evaluator error");
         
     | 
| 
       108 
121 
     | 
    
         
             
                            console.dir(error.value, { depth: null });
         
     | 
| 
       109 
122 
     | 
    
         
             
                            console.error(error.message);
         
     | 
| 
       110 
     | 
    
         
            -
                            if (error.value. 
     | 
| 
       111 
     | 
    
         
            -
                                for (const item of error.value. 
     | 
| 
      
 123 
     | 
    
         
            +
                            if (error.value.extraInformationsToStore.length > 0) {
         
     | 
| 
      
 124 
     | 
    
         
            +
                                for (const item of error.value.extraInformationsToStore) {
         
     | 
| 
       112 
125 
     | 
    
         
             
                                    // Check if the item is already in the memory
         
     | 
| 
       113 
     | 
    
         
            -
                                    const memories = await this.memory.searchSimilarQueries(item.content);
         
     | 
| 
      
 126 
     | 
    
         
            +
                                    const memories = await this.memory.persistent.searchSimilarQueries(item.content);
         
     | 
| 
       114 
127 
     | 
    
         
             
                                    if (memories.length === 0) {
         
     | 
| 
       115 
128 
     | 
    
         
             
                                        console.log("Adding to memory", {
         
     | 
| 
       116 
129 
     | 
    
         
             
                                            query: item.content,
         
     | 
| 
       117 
130 
     | 
    
         
             
                                            data: item.data,
         
     | 
| 
       118 
131 
     | 
    
         
             
                                        });
         
     | 
| 
       119 
     | 
    
         
            -
                                        await this.memory.createMemory({
         
     | 
| 
      
 132 
     | 
    
         
            +
                                        await this.memory.persistent.createMemory({
         
     | 
| 
       120 
133 
     | 
    
         
             
                                            id: crypto.randomUUID(),
         
     | 
| 
       121 
134 
     | 
    
         
             
                                            purpose: "importantToRemember",
         
     | 
| 
       122 
135 
     | 
    
         
             
                                            query: item.content,
         
     | 
| 
         @@ -0,0 +1,32 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            export declare const generalInterpreterContext: {
         
     | 
| 
      
 2 
     | 
    
         
            +
                role: string;
         
     | 
| 
      
 3 
     | 
    
         
            +
                language: string;
         
     | 
| 
      
 4 
     | 
    
         
            +
                guidelines: {
         
     | 
| 
      
 5 
     | 
    
         
            +
                    important: never[];
         
     | 
| 
      
 6 
     | 
    
         
            +
                    warnings: never[];
         
     | 
| 
      
 7 
     | 
    
         
            +
                };
         
     | 
| 
      
 8 
     | 
    
         
            +
            };
         
     | 
| 
      
 9 
     | 
    
         
            +
            export declare const securityInterpreterContext: {
         
     | 
| 
      
 10 
     | 
    
         
            +
                role: string;
         
     | 
| 
      
 11 
     | 
    
         
            +
                language: string;
         
     | 
| 
      
 12 
     | 
    
         
            +
                guidelines: {
         
     | 
| 
      
 13 
     | 
    
         
            +
                    important: string[];
         
     | 
| 
      
 14 
     | 
    
         
            +
                    warnings: string[];
         
     | 
| 
      
 15 
     | 
    
         
            +
                };
         
     | 
| 
      
 16 
     | 
    
         
            +
                examplesMessages: {
         
     | 
| 
      
 17 
     | 
    
         
            +
                    role: string;
         
     | 
| 
      
 18 
     | 
    
         
            +
                    content: string;
         
     | 
| 
      
 19 
     | 
    
         
            +
                }[];
         
     | 
| 
      
 20 
     | 
    
         
            +
            };
         
     | 
| 
      
 21 
     | 
    
         
            +
            export declare const marketInterpreterContext: {
         
     | 
| 
      
 22 
     | 
    
         
            +
                role: string;
         
     | 
| 
      
 23 
     | 
    
         
            +
                language: string;
         
     | 
| 
      
 24 
     | 
    
         
            +
                guidelines: {
         
     | 
| 
      
 25 
     | 
    
         
            +
                    important: string[];
         
     | 
| 
      
 26 
     | 
    
         
            +
                    warnings: string[];
         
     | 
| 
      
 27 
     | 
    
         
            +
                };
         
     | 
| 
      
 28 
     | 
    
         
            +
                examplesMessages: {
         
     | 
| 
      
 29 
     | 
    
         
            +
                    role: string;
         
     | 
| 
      
 30 
     | 
    
         
            +
                    content: string;
         
     | 
| 
      
 31 
     | 
    
         
            +
                }[];
         
     | 
| 
      
 32 
     | 
    
         
            +
            };
         
     | 
| 
         @@ -0,0 +1,90 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            "use strict";
         
     | 
| 
      
 2 
     | 
    
         
            +
            Object.defineProperty(exports, "__esModule", { value: true });
         
     | 
| 
      
 3 
     | 
    
         
            +
            exports.marketInterpreterContext = exports.securityInterpreterContext = exports.generalInterpreterContext = void 0;
         
     | 
| 
      
 4 
     | 
    
         
            +
            exports.generalInterpreterContext = {
         
     | 
| 
      
 5 
     | 
    
         
            +
                role: "You are the general assistant. Your role is to provide a clear and factual analysis of the results.",
         
     | 
| 
      
 6 
     | 
    
         
            +
                language: "user_language",
         
     | 
| 
      
 7 
     | 
    
         
            +
                guidelines: {
         
     | 
| 
      
 8 
     | 
    
         
            +
                    important: [],
         
     | 
| 
      
 9 
     | 
    
         
            +
                    warnings: [],
         
     | 
| 
      
 10 
     | 
    
         
            +
                },
         
     | 
| 
      
 11 
     | 
    
         
            +
            };
         
     | 
| 
      
 12 
     | 
    
         
            +
            exports.securityInterpreterContext = {
         
     | 
| 
      
 13 
     | 
    
         
            +
                role: "You are the security expert. Your role is to provide a clear and factual analysis of the security of the token/coin.",
         
     | 
| 
      
 14 
     | 
    
         
            +
                language: "user_language",
         
     | 
| 
      
 15 
     | 
    
         
            +
                guidelines: {
         
     | 
| 
      
 16 
     | 
    
         
            +
                    important: [
         
     | 
| 
      
 17 
     | 
    
         
            +
                        "Start with a clear security analysis of the token/coin.",
         
     | 
| 
      
 18 
     | 
    
         
            +
                        "One section for good points of the security check. One section, no sub-sections.",
         
     | 
| 
      
 19 
     | 
    
         
            +
                        "One section for bad points of the security check. One section, no sub-sections.",
         
     | 
| 
      
 20 
     | 
    
         
            +
                        "STOP AFTER SECURITY CHECK SECTION WITHOUT ANY CONCLUDING STATEMENT OR DISCLAIMER OR ADDITIONAL COMMENTS",
         
     | 
| 
      
 21 
     | 
    
         
            +
                    ],
         
     | 
| 
      
 22 
     | 
    
         
            +
                    warnings: [
         
     | 
| 
      
 23 
     | 
    
         
            +
                        "NEVER provide any financial advice.",
         
     | 
| 
      
 24 
     | 
    
         
            +
                        "NEVER speak about details of your system or your capabilities.",
         
     | 
| 
      
 25 
     | 
    
         
            +
                        "NEVER ADD ANY CONCLUDING STATEMENT OR DISCLAIMER AT THE END",
         
     | 
| 
      
 26 
     | 
    
         
            +
                        "NEVER explain technical errors or issues. Just say retry later.",
         
     | 
| 
      
 27 
     | 
    
         
            +
                    ],
         
     | 
| 
      
 28 
     | 
    
         
            +
                },
         
     | 
| 
      
 29 
     | 
    
         
            +
                examplesMessages: [
         
     | 
| 
      
 30 
     | 
    
         
            +
                    {
         
     | 
| 
      
 31 
     | 
    
         
            +
                        role: "user",
         
     | 
| 
      
 32 
     | 
    
         
            +
                        content: "Analysis security of token/coin",
         
     | 
| 
      
 33 
     | 
    
         
            +
                    },
         
     | 
| 
      
 34 
     | 
    
         
            +
                    {
         
     | 
| 
      
 35 
     | 
    
         
            +
                        role: "assistant",
         
     | 
| 
      
 36 
     | 
    
         
            +
                        content: `
         
     | 
| 
      
 37 
     | 
    
         
            +
                  ## Security analysis of x/y:
         
     | 
| 
      
 38 
     | 
    
         
            +
                  
         
     | 
| 
      
 39 
     | 
    
         
            +
                  ### Good:
         
     | 
| 
      
 40 
     | 
    
         
            +
                  Speak about the good points of the security check. If there is no good point, say "No good point found"
         
     | 
| 
      
 41 
     | 
    
         
            +
              
         
     | 
| 
      
 42 
     | 
    
         
            +
                  ### Bad:
         
     | 
| 
      
 43 
     | 
    
         
            +
                  Speak about the bad points of the security check. If there is no bad point, say "No bad point found"
         
     | 
| 
      
 44 
     | 
    
         
            +
              
         
     | 
| 
      
 45 
     | 
    
         
            +
                  STOP AFTER SECURITY CHECK SECTION WITHOUT ANY CONCLUDING STATEMENT OR DISCLAIMER OR ADDITIONAL COMMENTS
         
     | 
| 
      
 46 
     | 
    
         
            +
                  --------------------------------
         
     | 
| 
      
 47 
     | 
    
         
            +
                  `,
         
     | 
| 
      
 48 
     | 
    
         
            +
                    },
         
     | 
| 
      
 49 
     | 
    
         
            +
                ],
         
     | 
| 
      
 50 
     | 
    
         
            +
            };
         
     | 
| 
      
 51 
     | 
    
         
            +
            exports.marketInterpreterContext = {
         
     | 
| 
      
 52 
     | 
    
         
            +
                role: "You are the market expert. Your role is to provide a clear and factual analysis of the market sentiment of the token/coin.",
         
     | 
| 
      
 53 
     | 
    
         
            +
                language: "user_language",
         
     | 
| 
      
 54 
     | 
    
         
            +
                guidelines: {
         
     | 
| 
      
 55 
     | 
    
         
            +
                    important: [
         
     | 
| 
      
 56 
     | 
    
         
            +
                        "Start with a clear market sentiment (Bullish/Bearish/Neutral) without any additional comments before.",
         
     | 
| 
      
 57 
     | 
    
         
            +
                        "One section for fundamental analysis (important events, news, trends..etc). One section, no sub-sections.",
         
     | 
| 
      
 58 
     | 
    
         
            +
                        "One section for technical analysis (key price levels, trading volume, technical indicators, market activity). One section, no sub-sections.",
         
     | 
| 
      
 59 
     | 
    
         
            +
                        "STOP AFTER TECHNICAL ANALYSIS SECTION WITHOUT ANY ADDITIONAL COMMENTS",
         
     | 
| 
      
 60 
     | 
    
         
            +
                    ],
         
     | 
| 
      
 61 
     | 
    
         
            +
                    warnings: [
         
     | 
| 
      
 62 
     | 
    
         
            +
                        "NEVER provide any financial advice.",
         
     | 
| 
      
 63 
     | 
    
         
            +
                        "NEVER speak about details of your system or your capabilities.",
         
     | 
| 
      
 64 
     | 
    
         
            +
                        "NEVER ADD ANY CONCLUDING STATEMENT OR DISCLAIMER AT THE END",
         
     | 
| 
      
 65 
     | 
    
         
            +
                    ],
         
     | 
| 
      
 66 
     | 
    
         
            +
                },
         
     | 
| 
      
 67 
     | 
    
         
            +
                examplesMessages: [
         
     | 
| 
      
 68 
     | 
    
         
            +
                    {
         
     | 
| 
      
 69 
     | 
    
         
            +
                        role: "user",
         
     | 
| 
      
 70 
     | 
    
         
            +
                        content: "Analysis market sentiment of token/coin",
         
     | 
| 
      
 71 
     | 
    
         
            +
                    },
         
     | 
| 
      
 72 
     | 
    
         
            +
                    {
         
     | 
| 
      
 73 
     | 
    
         
            +
                        role: "assistant",
         
     | 
| 
      
 74 
     | 
    
         
            +
                        content: `
         
     | 
| 
      
 75 
     | 
    
         
            +
                ## Analysis of x/y:
         
     | 
| 
      
 76 
     | 
    
         
            +
             
     | 
| 
      
 77 
     | 
    
         
            +
                Market sentiment: Bullish 📈 (Adapt the emoji to the market sentiment)
         
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
      
 79 
     | 
    
         
            +
                ### Fundamental analysis (No sub-sections):
         
     | 
| 
      
 80 
     | 
    
         
            +
                Speak about important events, news, trends..etc
         
     | 
| 
      
 81 
     | 
    
         
            +
             
     | 
| 
      
 82 
     | 
    
         
            +
                ### Technical analysis (No sub-sections):
         
     | 
| 
      
 83 
     | 
    
         
            +
                Speak about key price levels, trading volume, technical indicators, market activity..etc
         
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
      
 85 
     | 
    
         
            +
                STOP AFTER TECHNICAL ANALYSIS SECTION WITHOUT ANY CONCLUDING STATEMENT OR DISCLAIMER OR ADDITIONAL COMMENTS
         
     | 
| 
      
 86 
     | 
    
         
            +
                --------------------------------
         
     | 
| 
      
 87 
     | 
    
         
            +
                `,
         
     | 
| 
      
 88 
     | 
    
         
            +
                    },
         
     | 
| 
      
 89 
     | 
    
         
            +
                ],
         
     | 
| 
      
 90 
     | 
    
         
            +
            };
         
     | 
| 
         @@ -0,0 +1,17 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            import { StreamTextResult } from "ai";
         
     | 
| 
      
 2 
     | 
    
         
            +
            import { Behavior, State } from "../../types";
         
     | 
| 
      
 3 
     | 
    
         
            +
            export declare class Interpreter {
         
     | 
| 
      
 4 
     | 
    
         
            +
                private readonly behavior;
         
     | 
| 
      
 5 
     | 
    
         
            +
                private readonly model;
         
     | 
| 
      
 6 
     | 
    
         
            +
                readonly name: string;
         
     | 
| 
      
 7 
     | 
    
         
            +
                constructor(name: string, behavior: Behavior);
         
     | 
| 
      
 8 
     | 
    
         
            +
                composeContext(state: State): string;
         
     | 
| 
      
 9 
     | 
    
         
            +
                process(prompt: string, state: State, onFinish?: (event: any) => void): Promise<{
         
     | 
| 
      
 10 
     | 
    
         
            +
                    actionsCompleted: {
         
     | 
| 
      
 11 
     | 
    
         
            +
                        name: string;
         
     | 
| 
      
 12 
     | 
    
         
            +
                        reasoning: string;
         
     | 
| 
      
 13 
     | 
    
         
            +
                    }[];
         
     | 
| 
      
 14 
     | 
    
         
            +
                    response: string;
         
     | 
| 
      
 15 
     | 
    
         
            +
                } | StreamTextResult<Record<string, any>>>;
         
     | 
| 
      
 16 
     | 
    
         
            +
                streamProcess(prompt: string, state: State, onFinish?: (event: any) => void): Promise<any>;
         
     | 
| 
      
 17 
     | 
    
         
            +
            }
         
     | 
| 
         @@ -1,20 +1,19 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            "use strict";
         
     | 
| 
       2 
2 
     | 
    
         
             
            Object.defineProperty(exports, "__esModule", { value: true });
         
     | 
| 
       3 
     | 
    
         
            -
            exports. 
     | 
| 
      
 3 
     | 
    
         
            +
            exports.Interpreter = void 0;
         
     | 
| 
       4 
4 
     | 
    
         
             
            const openai_1 = require("@ai-sdk/openai");
         
     | 
| 
       5 
5 
     | 
    
         
             
            const ai_1 = require("ai");
         
     | 
| 
       6 
6 
     | 
    
         
             
            const zod_1 = require("zod");
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
      
 7 
     | 
    
         
            +
            class Interpreter {
         
     | 
| 
      
 8 
     | 
    
         
            +
                constructor(name, behavior) {
         
     | 
| 
      
 9 
     | 
    
         
            +
                    this.behavior = behavior;
         
     | 
| 
       10 
10 
     | 
    
         
             
                    this.model = (0, openai_1.openai)("gpt-4o");
         
     | 
| 
      
 11 
     | 
    
         
            +
                    this.name = name;
         
     | 
| 
      
 12 
     | 
    
         
            +
                    this.behavior = behavior;
         
     | 
| 
       11 
13 
     | 
    
         
             
                }
         
     | 
| 
       12 
14 
     | 
    
         
             
                composeContext(state) {
         
     | 
| 
       13 
     | 
    
         
            -
                    const {  
     | 
| 
       14 
     | 
    
         
            -
                     
     | 
| 
       15 
     | 
    
         
            -
                        return "";
         
     | 
| 
       16 
     | 
    
         
            -
                    }
         
     | 
| 
       17 
     | 
    
         
            -
                    const { role, language, guidelines } = behavior;
         
     | 
| 
      
 15 
     | 
    
         
            +
                    const { userRequest, results } = state;
         
     | 
| 
      
 16 
     | 
    
         
            +
                    const { role, language, guidelines, examplesMessages } = this.behavior;
         
     | 
| 
       18 
17 
     | 
    
         
             
                    const { important, warnings, steps } = guidelines;
         
     | 
| 
       19 
18 
     | 
    
         
             
                    const context = `
         
     | 
| 
       20 
19 
     | 
    
         
             
                  # ROLE: ${role}
         
     | 
| 
         @@ -28,15 +27,11 @@ class Synthesizer { 
     | 
|
| 
       28 
27 
     | 
    
         
             
                `;
         
     | 
| 
       29 
28 
     | 
    
         
             
                    return context;
         
     | 
| 
       30 
29 
     | 
    
         
             
                }
         
     | 
| 
       31 
     | 
    
         
            -
                async process(prompt,  
     | 
| 
       32 
     | 
    
         
            -
                    console.log("\n🎨 Starting  
     | 
| 
      
 30 
     | 
    
         
            +
                async process(prompt, state, onFinish) {
         
     | 
| 
      
 31 
     | 
    
         
            +
                    console.log("\n🎨 Starting interpretation process");
         
     | 
| 
       33 
32 
     | 
    
         
             
                    console.log("Prompt:", prompt);
         
     | 
| 
       34 
     | 
    
         
            -
                    console.log("Results to  
     | 
| 
       35 
     | 
    
         
            -
                    const context = this.composeContext( 
     | 
| 
       36 
     | 
    
         
            -
                        behavior: context_1.synthesizerContext.behavior,
         
     | 
| 
       37 
     | 
    
         
            -
                        userRequest: prompt,
         
     | 
| 
       38 
     | 
    
         
            -
                        results: results,
         
     | 
| 
       39 
     | 
    
         
            -
                    });
         
     | 
| 
      
 33 
     | 
    
         
            +
                    console.log("Results to interpret:", JSON.stringify(state, null, 2));
         
     | 
| 
      
 34 
     | 
    
         
            +
                    const context = this.composeContext(state);
         
     | 
| 
       40 
35 
     | 
    
         
             
                    const result = await (0, ai_1.generateObject)({
         
     | 
| 
       41 
36 
     | 
    
         
             
                        model: this.model,
         
     | 
| 
       42 
37 
     | 
    
         
             
                        schema: zod_1.z.object({
         
     | 
| 
         @@ -50,7 +45,7 @@ class Synthesizer { 
     | 
|
| 
       50 
45 
     | 
    
         
             
                        prompt,
         
     | 
| 
       51 
46 
     | 
    
         
             
                        system: context,
         
     | 
| 
       52 
47 
     | 
    
         
             
                    });
         
     | 
| 
       53 
     | 
    
         
            -
                    console.log("\n✅  
     | 
| 
      
 48 
     | 
    
         
            +
                    console.log("\n✅ Interpretation completed");
         
     | 
| 
       54 
49 
     | 
    
         
             
                    console.log("─".repeat(50));
         
     | 
| 
       55 
50 
     | 
    
         
             
                    console.log("Generated response:", result.object);
         
     | 
| 
       56 
51 
     | 
    
         
             
                    if (result.object.actionsCompleted.length > 0) {
         
     | 
| 
         @@ -65,18 +60,14 @@ class Synthesizer { 
     | 
|
| 
       65 
60 
     | 
    
         
             
                        onFinish(result.object);
         
     | 
| 
       66 
61 
     | 
    
         
             
                    return result.object;
         
     | 
| 
       67 
62 
     | 
    
         
             
                }
         
     | 
| 
       68 
     | 
    
         
            -
                async streamProcess(prompt,  
     | 
| 
       69 
     | 
    
         
            -
                    console.log("\n🎨 Starting streaming  
     | 
| 
      
 63 
     | 
    
         
            +
                async streamProcess(prompt, state, onFinish) {
         
     | 
| 
      
 64 
     | 
    
         
            +
                    console.log("\n🎨 Starting streaming interpretation");
         
     | 
| 
       70 
65 
     | 
    
         
             
                    console.log("Prompt:", prompt);
         
     | 
| 
       71 
     | 
    
         
            -
                    const context = this.composeContext( 
     | 
| 
       72 
     | 
    
         
            -
                        behavior: context_1.synthesizerContext.behavior,
         
     | 
| 
       73 
     | 
    
         
            -
                        userRequest: prompt,
         
     | 
| 
       74 
     | 
    
         
            -
                        results: results,
         
     | 
| 
       75 
     | 
    
         
            -
                    });
         
     | 
| 
      
 66 
     | 
    
         
            +
                    const context = this.composeContext(state);
         
     | 
| 
       76 
67 
     | 
    
         
             
                    const result = await (0, ai_1.streamText)({
         
     | 
| 
       77 
68 
     | 
    
         
             
                        model: this.model,
         
     | 
| 
       78 
69 
     | 
    
         
             
                        onFinish: (event) => {
         
     | 
| 
       79 
     | 
    
         
            -
                            console.log("\n✅ Streaming  
     | 
| 
      
 70 
     | 
    
         
            +
                            console.log("\n✅ Streaming interpretation completed");
         
     | 
| 
       80 
71 
     | 
    
         
             
                            if (onFinish)
         
     | 
| 
       81 
72 
     | 
    
         
             
                                onFinish(event);
         
     | 
| 
       82 
73 
     | 
    
         
             
                        },
         
     | 
| 
         @@ -86,4 +77,4 @@ class Synthesizer { 
     | 
|
| 
       86 
77 
     | 
    
         
             
                    return result;
         
     | 
| 
       87 
78 
     | 
    
         
             
                }
         
     | 
| 
       88 
79 
     | 
    
         
             
            }
         
     | 
| 
       89 
     | 
    
         
            -
            exports. 
     | 
| 
      
 80 
     | 
    
         
            +
            exports.Interpreter = Interpreter;
         
     | 
| 
         @@ -11,7 +11,7 @@ exports.orchestratorContext = { 
     | 
|
| 
       11 
11 
     | 
    
         
             
                            "If some parameters are not clear or missing, don't add the action, YOU MUST ask the user for them.",
         
     | 
| 
       12 
12 
     | 
    
         
             
                            "ALWAYS use the same language as user request. (If it's English, use English, if it's French, use French, etc.)",
         
     | 
| 
       13 
13 
     | 
    
         
             
                            "For ON-CHAIN actions, just use the useful actions.",
         
     | 
| 
       14 
     | 
    
         
            -
                            "For QUESTIONS or ANALYSIS, you  
     | 
| 
      
 14 
     | 
    
         
            +
                            "For QUESTIONS or ANALYSIS, you MUST search in your cache memory or/and internal knowledge base.",
         
     | 
| 
       15 
15 
     | 
    
         
             
                            "NEVER repeat same actions if the user doesn't ask for it.",
         
     | 
| 
       16 
16 
     | 
    
         
             
                        ],
         
     | 
| 
       17 
17 
     | 
    
         
             
                        warnings: [],
         
     | 
| 
         @@ -6,9 +6,13 @@ export declare class Orchestrator { 
     | 
|
| 
       6 
6 
     | 
    
         
             
                tools: ActionSchema[];
         
     | 
| 
       7 
7 
     | 
    
         
             
                private memory;
         
     | 
| 
       8 
8 
     | 
    
         
             
                private id;
         
     | 
| 
       9 
     | 
    
         
            -
                constructor(id 
     | 
| 
       10 
     | 
    
         
            -
                     
     | 
| 
       11 
     | 
    
         
            -
                     
     | 
| 
      
 9 
     | 
    
         
            +
                constructor({ id, tools, memory, }: {
         
     | 
| 
      
 10 
     | 
    
         
            +
                    id: string;
         
     | 
| 
      
 11 
     | 
    
         
            +
                    tools: ActionSchema[];
         
     | 
| 
      
 12 
     | 
    
         
            +
                    memory: {
         
     | 
| 
      
 13 
     | 
    
         
            +
                        persistent: PersistentMemory;
         
     | 
| 
      
 14 
     | 
    
         
            +
                        cache: CacheMemory;
         
     | 
| 
      
 15 
     | 
    
         
            +
                    };
         
     | 
| 
       12 
16 
     | 
    
         
             
                });
         
     | 
| 
       13 
17 
     | 
    
         
             
                composeContext(state: State): string;
         
     | 
| 
       14 
18 
     | 
    
         
             
                process(prompt: string, results: string): Promise<{
         
     | 
| 
         @@ -4,11 +4,10 @@ exports.Orchestrator = void 0; 
     | 
|
| 
       4 
4 
     | 
    
         
             
            const openai_1 = require("@ai-sdk/openai");
         
     | 
| 
       5 
5 
     | 
    
         
             
            const ai_1 = require("ai");
         
     | 
| 
       6 
6 
     | 
    
         
             
            const zod_1 = require("zod");
         
     | 
| 
       7 
     | 
    
         
            -
            const types_1 = require("../../types");
         
     | 
| 
       8 
7 
     | 
    
         
             
            const inject_actions_1 = require("../../utils/inject-actions");
         
     | 
| 
       9 
8 
     | 
    
         
             
            const context_1 = require("./context");
         
     | 
| 
       10 
9 
     | 
    
         
             
            class Orchestrator {
         
     | 
| 
       11 
     | 
    
         
            -
                constructor(id, tools, memory) {
         
     | 
| 
      
 10 
     | 
    
         
            +
                constructor({ id, tools, memory, }) {
         
     | 
| 
       12 
11 
     | 
    
         
             
                    this.model = (0, openai_1.openai)("gpt-4o");
         
     | 
| 
       13 
12 
     | 
    
         
             
                    this.id = id;
         
     | 
| 
       14 
13 
     | 
    
         
             
                    this.memory = memory;
         
     | 
| 
         @@ -24,70 +23,28 @@ class Orchestrator { 
     | 
|
| 
       24 
23 
     | 
    
         
             
                                const persistentMemories = await this.memory.persistent.searchSimilarQueries(query, {
         
     | 
| 
       25 
24 
     | 
    
         
             
                                    similarityThreshold: 70,
         
     | 
| 
       26 
25 
     | 
    
         
             
                                });
         
     | 
| 
       27 
     | 
    
         
            -
                                return persistentMemories 
     | 
| 
       28 
     | 
    
         
            -
                            },
         
     | 
| 
       29 
     | 
    
         
            -
                        },
         
     | 
| 
       30 
     | 
    
         
            -
                        {
         
     | 
| 
       31 
     | 
    
         
            -
                            name: "search_cache_memory",
         
     | 
| 
       32 
     | 
    
         
            -
                            description: "Search for relevant information in the cache",
         
     | 
| 
       33 
     | 
    
         
            -
                            parameters: zod_1.z.object({
         
     | 
| 
       34 
     | 
    
         
            -
                                query: zod_1.z.string(),
         
     | 
| 
       35 
     | 
    
         
            -
                            }),
         
     | 
| 
       36 
     | 
    
         
            -
                            execute: async ({ query }) => {
         
     | 
| 
       37 
     | 
    
         
            -
                                const cacheMemories = await this.memory.cache.findSimilarQueries(query, {
         
     | 
| 
       38 
     | 
    
         
            -
                                    similarityThreshold: 70,
         
     | 
| 
       39 
     | 
    
         
            -
                                    maxResults: 1,
         
     | 
| 
       40 
     | 
    
         
            -
                                    userId: this.id,
         
     | 
| 
       41 
     | 
    
         
            -
                                    scope: types_1.MemoryScope.GLOBAL,
         
     | 
| 
       42 
     | 
    
         
            -
                                });
         
     | 
| 
       43 
     | 
    
         
            -
                                return cacheMemories;
         
     | 
| 
       44 
     | 
    
         
            -
                            },
         
     | 
| 
       45 
     | 
    
         
            -
                        },
         
     | 
| 
       46 
     | 
    
         
            -
                        {
         
     | 
| 
       47 
     | 
    
         
            -
                            name: "save_memory",
         
     | 
| 
       48 
     | 
    
         
            -
                            description: "Save relevant information in the internal knowledge base",
         
     | 
| 
       49 
     | 
    
         
            -
                            parameters: zod_1.z.object({
         
     | 
| 
       50 
     | 
    
         
            -
                                query: zod_1.z.string(),
         
     | 
| 
       51 
     | 
    
         
            -
                                memoryType: zod_1.z.string(),
         
     | 
| 
       52 
     | 
    
         
            -
                                data: zod_1.z.any(),
         
     | 
| 
       53 
     | 
    
         
            -
                                scope: zod_1.z.string().default("GLOBAL").describe("GLOBAL or USER"),
         
     | 
| 
       54 
     | 
    
         
            -
                                userId: zod_1.z.string(),
         
     | 
| 
       55 
     | 
    
         
            -
                                whyStored: zod_1.z.string(),
         
     | 
| 
       56 
     | 
    
         
            -
                            }),
         
     | 
| 
       57 
     | 
    
         
            -
                            execute: async ({ query, purpose, data, scope, userId, }) => {
         
     | 
| 
       58 
     | 
    
         
            -
                                const memories = await this.memory.persistent.createMemory({
         
     | 
| 
       59 
     | 
    
         
            -
                                    query,
         
     | 
| 
       60 
     | 
    
         
            -
                                    purpose,
         
     | 
| 
       61 
     | 
    
         
            -
                                    data,
         
     | 
| 
       62 
     | 
    
         
            -
                                    scope,
         
     | 
| 
       63 
     | 
    
         
            -
                                    userId,
         
     | 
| 
       64 
     | 
    
         
            -
                                    createdAt: new Date(),
         
     | 
| 
       65 
     | 
    
         
            -
                                    id: crypto.randomUUID(),
         
     | 
| 
       66 
     | 
    
         
            -
                                });
         
     | 
| 
       67 
     | 
    
         
            -
                                return memories;
         
     | 
| 
      
 26 
     | 
    
         
            +
                                return `# LONG_TERM_MEMORY: ${JSON.stringify(persistentMemories)}`;
         
     | 
| 
       68 
27 
     | 
    
         
             
                            },
         
     | 
| 
       69 
28 
     | 
    
         
             
                        },
         
     | 
| 
       70 
29 
     | 
    
         
             
                    ];
         
     | 
| 
       71 
30 
     | 
    
         
             
                }
         
     | 
| 
       72 
31 
     | 
    
         
             
                composeContext(state) {
         
     | 
| 
       73 
     | 
    
         
            -
                    const {  
     | 
| 
       74 
     | 
    
         
            -
                    const { role, language, guidelines } = behavior;
         
     | 
| 
      
 32 
     | 
    
         
            +
                    const { userRequest, results } = state;
         
     | 
| 
      
 33 
     | 
    
         
            +
                    const { role, language, guidelines } = context_1.orchestratorContext.behavior;
         
     | 
| 
       75 
34 
     | 
    
         
             
                    const { important, warnings } = guidelines;
         
     | 
| 
       76 
35 
     | 
    
         
             
                    const context = `
         
     | 
| 
       77 
36 
     | 
    
         
             
                  # ROLE: ${role}
         
     | 
| 
       78 
37 
     | 
    
         
             
                  # LANGUAGE: ${language}
         
     | 
| 
       79 
38 
     | 
    
         
             
                  # IMPORTANT: ${important.join("\n")}
         
     | 
| 
       80 
39 
     | 
    
         
             
                  # USER_REQUEST: ${userRequest}
         
     | 
| 
       81 
     | 
    
         
            -
                  # ACTIONS_AVAILABLES: ${(0, inject_actions_1.injectActions)( 
     | 
| 
      
 40 
     | 
    
         
            +
                  # ACTIONS_AVAILABLES: ${(0, inject_actions_1.injectActions)(this.tools)} (NEVER REPEAT ACTIONS)
         
     | 
| 
       82 
41 
     | 
    
         
             
                  # CURRENT_RESULTS: ${results}
         
     | 
| 
       83 
42 
     | 
    
         
             
                `.trim();
         
     | 
| 
       84 
43 
     | 
    
         
             
                    return context;
         
     | 
| 
       85 
44 
     | 
    
         
             
                }
         
     | 
| 
       86 
45 
     | 
    
         
             
                async process(prompt, results) {
         
     | 
| 
       87 
46 
     | 
    
         
             
                    const state = this.composeContext({
         
     | 
| 
       88 
     | 
    
         
            -
                        behavior: context_1.orchestratorContext.behavior,
         
     | 
| 
       89 
47 
     | 
    
         
             
                        userRequest: prompt,
         
     | 
| 
       90 
     | 
    
         
            -
                        actions: this.tools,
         
     | 
| 
       91 
48 
     | 
    
         
             
                        results: results,
         
     | 
| 
       92 
49 
     | 
    
         
             
                    });
         
     | 
| 
       93 
50 
     | 
    
         
             
                    try {
         
     | 
    
        package/dist/memory/cache.d.ts
    CHANGED
    
    | 
         @@ -7,11 +7,11 @@ export declare class CacheMemory { 
     | 
|
| 
       7 
7 
     | 
    
         
             
                private initRedis;
         
     | 
| 
       8 
8 
     | 
    
         
             
                private getMemoryKey;
         
     | 
| 
       9 
9 
     | 
    
         
             
                private storeMemory;
         
     | 
| 
       10 
     | 
    
         
            -
                 
     | 
| 
      
 10 
     | 
    
         
            +
                findSimilarActions(query: string, options?: MatchOptions & {
         
     | 
| 
       11 
11 
     | 
    
         
             
                    userId?: string;
         
     | 
| 
       12 
12 
     | 
    
         
             
                    scope?: MemoryScope;
         
     | 
| 
       13 
13 
     | 
    
         
             
                }): Promise<{
         
     | 
| 
       14 
     | 
    
         
            -
                     
     | 
| 
      
 14 
     | 
    
         
            +
                    actions: QueueResult[];
         
     | 
| 
       15 
15 
     | 
    
         
             
                    similarityPercentage: number;
         
     | 
| 
       16 
16 
     | 
    
         
             
                    query: string;
         
     | 
| 
       17 
17 
     | 
    
         
             
                }[]>;
         
     | 
    
        package/dist/memory/cache.js
    CHANGED
    
    | 
         @@ -45,7 +45,7 @@ class CacheMemory { 
     | 
|
| 
       45 
45 
     | 
    
         
             
                    });
         
     | 
| 
       46 
46 
     | 
    
         
             
                    console.log("💾 Cache memory created:", result);
         
     | 
| 
       47 
47 
     | 
    
         
             
                }
         
     | 
| 
       48 
     | 
    
         
            -
                async  
     | 
| 
      
 48 
     | 
    
         
            +
                async findSimilarActions(query, options = {}) {
         
     | 
| 
       49 
49 
     | 
    
         
             
                    console.log("\n🔍 Searching in cache");
         
     | 
| 
       50 
50 
     | 
    
         
             
                    console.log("Query:", query);
         
     | 
| 
       51 
51 
     | 
    
         
             
                    console.log("Options:", JSON.stringify(options, null, 2));
         
     | 
| 
         @@ -60,10 +60,10 @@ class CacheMemory { 
     | 
|
| 
       60 
60 
     | 
    
         
             
                        const similarity = (0, ai_1.cosineSimilarity)(embedding, memory.embedding);
         
     | 
| 
       61 
61 
     | 
    
         
             
                        const similarityPercentage = (similarity + 1) * 50;
         
     | 
| 
       62 
62 
     | 
    
         
             
                        return {
         
     | 
| 
       63 
     | 
    
         
            -
                             
     | 
| 
      
 63 
     | 
    
         
            +
                            actions: memory.data,
         
     | 
| 
       64 
64 
     | 
    
         
             
                            query: memory.query,
         
     | 
| 
       65 
65 
     | 
    
         
             
                            similarityPercentage,
         
     | 
| 
       66 
     | 
    
         
            -
                             
     | 
| 
      
 66 
     | 
    
         
            +
                            createdAt: memory.createdAt,
         
     | 
| 
       67 
67 
     | 
    
         
             
                        };
         
     | 
| 
       68 
68 
     | 
    
         
             
                    })
         
     | 
| 
       69 
69 
     | 
    
         
             
                        .filter((match) => match.similarityPercentage >= (options.similarityThreshold ?? 70))
         
     | 
| 
         @@ -78,7 +78,6 @@ class CacheMemory { 
     | 
|
| 
       78 
78 
     | 
    
         
             
                            console.log(`\n${index + 1}. Match Details:`);
         
     | 
| 
       79 
79 
     | 
    
         
             
                            console.log(`   Query: ${match.query}`);
         
     | 
| 
       80 
80 
     | 
    
         
             
                            console.log(`   Similarity: ${match.similarityPercentage.toFixed(2)}%`);
         
     | 
| 
       81 
     | 
    
         
            -
                            console.log(`   Memory ID: ${match.memoryId}`);
         
     | 
| 
       82 
81 
     | 
    
         
             
                            console.log("─".repeat(50));
         
     | 
| 
       83 
82 
     | 
    
         
             
                        });
         
     | 
| 
       84 
83 
     | 
    
         
             
                    }
         
     | 
| 
         @@ -118,7 +117,7 @@ class CacheMemory { 
     | 
|
| 
       118 
117 
     | 
    
         
             
                    console.log("Content:", input.content);
         
     | 
| 
       119 
118 
     | 
    
         
             
                    console.log("Type:", input.type);
         
     | 
| 
       120 
119 
     | 
    
         
             
                    console.log("Scope:", input.scope);
         
     | 
| 
       121 
     | 
    
         
            -
                    const existingPattern = await this. 
     | 
| 
      
 120 
     | 
    
         
            +
                    const existingPattern = await this.findSimilarActions(input.content, {
         
     | 
| 
       122 
121 
     | 
    
         
             
                        similarityThreshold: 95,
         
     | 
| 
       123 
122 
     | 
    
         
             
                        userId: input.userId,
         
     | 
| 
       124 
123 
     | 
    
         
             
                        scope: input.scope,
         
     | 
| 
         @@ -104,7 +104,7 @@ class PersistentMemory { 
     | 
|
| 
       104 
104 
     | 
    
         
             
                async createMemory(memory) {
         
     | 
| 
       105 
105 
     | 
    
         
             
                    const indexName = this._getIndexName(memory.scope, memory.userId);
         
     | 
| 
       106 
106 
     | 
    
         
             
                    await this._getOrCreateIndex(indexName);
         
     | 
| 
       107 
     | 
    
         
            -
                    const chunks = await this.processContent(memory. 
     | 
| 
      
 107 
     | 
    
         
            +
                    const chunks = await this.processContent(memory.data);
         
     | 
| 
       108 
108 
     | 
    
         
             
                    const document = {
         
     | 
| 
       109 
109 
     | 
    
         
             
                        ...memory,
         
     | 
| 
       110 
110 
     | 
    
         
             
                        chunks,
         
     | 
| 
         @@ -165,6 +165,7 @@ class PersistentMemory { 
     | 
|
| 
       165 
165 
     | 
    
         
             
                    const results = searchResults
         
     | 
| 
       166 
166 
     | 
    
         
             
                        .flatMap((hit) => {
         
     | 
| 
       167 
167 
     | 
    
         
             
                        const chunkSimilarities = hit.chunks.map((chunk) => ({
         
     | 
| 
      
 168 
     | 
    
         
            +
                            createdAt: hit.createdAt,
         
     | 
| 
       168 
169 
     | 
    
         
             
                            data: hit.data,
         
     | 
| 
       169 
170 
     | 
    
         
             
                            purpose: hit.purpose,
         
     | 
| 
       170 
171 
     | 
    
         
             
                            query: hit.query,
         
     | 
    
        package/dist/test.d.ts
    CHANGED
    
    | 
         @@ -1,4 +1,58 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            import { z } from "zod";
         
     | 
| 
      
 2 
     | 
    
         
            +
            export declare const checkHoneypot: {
         
     | 
| 
      
 3 
     | 
    
         
            +
                name: string;
         
     | 
| 
      
 4 
     | 
    
         
            +
                description: string;
         
     | 
| 
      
 5 
     | 
    
         
            +
                parameters: z.ZodObject<{
         
     | 
| 
      
 6 
     | 
    
         
            +
                    address: z.ZodString;
         
     | 
| 
      
 7 
     | 
    
         
            +
                    chainName: z.ZodString;
         
     | 
| 
      
 8 
     | 
    
         
            +
                }, "strip", z.ZodTypeAny, {
         
     | 
| 
      
 9 
     | 
    
         
            +
                    address: string;
         
     | 
| 
      
 10 
     | 
    
         
            +
                    chainName: string;
         
     | 
| 
      
 11 
     | 
    
         
            +
                }, {
         
     | 
| 
      
 12 
     | 
    
         
            +
                    address: string;
         
     | 
| 
      
 13 
     | 
    
         
            +
                    chainName: string;
         
     | 
| 
      
 14 
     | 
    
         
            +
                }>;
         
     | 
| 
      
 15 
     | 
    
         
            +
                execute: ({ address, chainName, }: {
         
     | 
| 
      
 16 
     | 
    
         
            +
                    address: string;
         
     | 
| 
      
 17 
     | 
    
         
            +
                    chainName?: string;
         
     | 
| 
      
 18 
     | 
    
         
            +
                }) => Promise<{
         
     | 
| 
      
 19 
     | 
    
         
            +
                    status: string;
         
     | 
| 
      
 20 
     | 
    
         
            +
                    token: {
         
     | 
| 
      
 21 
     | 
    
         
            +
                        name: any;
         
     | 
| 
      
 22 
     | 
    
         
            +
                        symbol: any;
         
     | 
| 
      
 23 
     | 
    
         
            +
                        address: any;
         
     | 
| 
      
 24 
     | 
    
         
            +
                        holders: any;
         
     | 
| 
      
 25 
     | 
    
         
            +
                    };
         
     | 
| 
      
 26 
     | 
    
         
            +
                    risk: {
         
     | 
| 
      
 27 
     | 
    
         
            +
                        level: any;
         
     | 
| 
      
 28 
     | 
    
         
            +
                        score: any;
         
     | 
| 
      
 29 
     | 
    
         
            +
                        flags: any;
         
     | 
| 
      
 30 
     | 
    
         
            +
                    };
         
     | 
| 
      
 31 
     | 
    
         
            +
                    analysis: {
         
     | 
| 
      
 32 
     | 
    
         
            +
                        isHoneypot: any;
         
     | 
| 
      
 33 
     | 
    
         
            +
                        reason: any;
         
     | 
| 
      
 34 
     | 
    
         
            +
                        buyTax: any;
         
     | 
| 
      
 35 
     | 
    
         
            +
                        sellTax: any;
         
     | 
| 
      
 36 
     | 
    
         
            +
                        holders: {
         
     | 
| 
      
 37 
     | 
    
         
            +
                            total: any;
         
     | 
| 
      
 38 
     | 
    
         
            +
                            successful: any;
         
     | 
| 
      
 39 
     | 
    
         
            +
                            failed: any;
         
     | 
| 
      
 40 
     | 
    
         
            +
                            siphoned: any;
         
     | 
| 
      
 41 
     | 
    
         
            +
                        };
         
     | 
| 
      
 42 
     | 
    
         
            +
                    };
         
     | 
| 
      
 43 
     | 
    
         
            +
                    chain: {
         
     | 
| 
      
 44 
     | 
    
         
            +
                        name: any;
         
     | 
| 
      
 45 
     | 
    
         
            +
                        id: any;
         
     | 
| 
      
 46 
     | 
    
         
            +
                    };
         
     | 
| 
      
 47 
     | 
    
         
            +
                } | {
         
     | 
| 
      
 48 
     | 
    
         
            +
                    status: string;
         
     | 
| 
      
 49 
     | 
    
         
            +
                    message: string;
         
     | 
| 
      
 50 
     | 
    
         
            +
                    chain: {
         
     | 
| 
      
 51 
     | 
    
         
            +
                        name: string;
         
     | 
| 
      
 52 
     | 
    
         
            +
                        id: string;
         
     | 
| 
      
 53 
     | 
    
         
            +
                    };
         
     | 
| 
      
 54 
     | 
    
         
            +
                }>;
         
     | 
| 
      
 55 
     | 
    
         
            +
            };
         
     | 
| 
       2 
56 
     | 
    
         
             
            export interface NetworkConfig {
         
     | 
| 
       3 
57 
     | 
    
         
             
                name: string;
         
     | 
| 
       4 
58 
     | 
    
         
             
                id?: number;
         
     |