@ai.ntellect/core 0.1.92 → 0.1.94
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/agent/index.ts +21 -10
- package/llm/evaluator/index.ts +1 -0
- package/llm/orchestrator/index.ts +23 -5
- package/llm/synthesizer/context.ts +0 -12
- package/llm/synthesizer/index.ts +2 -1
- package/package.json +1 -1
    
        package/agent/index.ts
    CHANGED
    
    | @@ -82,7 +82,7 @@ export class Agent { | |
| 82 82 | 
             
                  ? this.handleActions(
         | 
| 83 83 | 
             
                      {
         | 
| 84 84 | 
             
                        initialPrompt: prompt,
         | 
| 85 | 
            -
                        actions: request.actions | 
| 85 | 
            +
                        actions: request.actions,
         | 
| 86 86 | 
             
                      },
         | 
| 87 87 | 
             
                      events
         | 
| 88 88 | 
             
                    )
         | 
| @@ -95,11 +95,18 @@ export class Agent { | |
| 95 95 | 
             
                  actions,
         | 
| 96 96 | 
             
                }: {
         | 
| 97 97 | 
             
                  initialPrompt: string;
         | 
| 98 | 
            -
                  actions:  | 
| 98 | 
            +
                  actions: {
         | 
| 99 | 
            +
                    name: string;
         | 
| 100 | 
            +
                    type: string;
         | 
| 101 | 
            +
                    parameters: {
         | 
| 102 | 
            +
                      name: string;
         | 
| 103 | 
            +
                      value: any;
         | 
| 104 | 
            +
                    }[];
         | 
| 105 | 
            +
                  }[];
         | 
| 99 106 | 
             
                },
         | 
| 100 107 | 
             
                events: AgentEvent
         | 
| 101 108 | 
             
              ): Promise<any> {
         | 
| 102 | 
            -
                const queueItems = this.transformActions(actions);
         | 
| 109 | 
            +
                const queueItems = this.transformActions(actions as any);
         | 
| 103 110 |  | 
| 104 111 | 
             
                const actionsResult = await this.actionHandler.executeActions(
         | 
| 105 112 | 
             
                  queueItems,
         | 
| @@ -113,11 +120,22 @@ export class Agent { | |
| 113 120 | 
             
                  }
         | 
| 114 121 | 
             
                );
         | 
| 115 122 |  | 
| 123 | 
            +
                const isOnChainAction = actions.some(
         | 
| 124 | 
            +
                  (action) => action.type === "on-chain"
         | 
| 125 | 
            +
                );
         | 
| 126 | 
            +
             | 
| 116 127 | 
             
                this.accumulatedResults = [
         | 
| 117 128 | 
             
                  ...this.accumulatedResults,
         | 
| 118 129 | 
             
                  ...actionsResult.data,
         | 
| 119 130 | 
             
                ];
         | 
| 120 131 |  | 
| 132 | 
            +
                if (isOnChainAction) {
         | 
| 133 | 
            +
                  return {
         | 
| 134 | 
            +
                    data: this.accumulatedResults,
         | 
| 135 | 
            +
                    initialPrompt,
         | 
| 136 | 
            +
                  };
         | 
| 137 | 
            +
                }
         | 
| 138 | 
            +
             | 
| 121 139 | 
             
                if (this.evaluatorIteration >= this.maxEvaluatorIteration) {
         | 
| 122 140 | 
             
                  return this.handleActionResults({
         | 
| 123 141 | 
             
                    data: this.accumulatedResults,
         | 
| @@ -151,13 +169,6 @@ export class Agent { | |
| 151 169 | 
             
                  );
         | 
| 152 170 | 
             
                }
         | 
| 153 171 |  | 
| 154 | 
            -
                if (!this.actionHandler.hasNonPrepareActions(this.accumulatedResults)) {
         | 
| 155 | 
            -
                  return {
         | 
| 156 | 
            -
                    data: this.accumulatedResults,
         | 
| 157 | 
            -
                    initialPrompt,
         | 
| 158 | 
            -
                  };
         | 
| 159 | 
            -
                }
         | 
| 160 | 
            -
             | 
| 161 172 | 
             
                return this.handleActionResults({
         | 
| 162 173 | 
             
                  data: this.accumulatedResults,
         | 
| 163 174 | 
             
                  initialPrompt,
         | 
    
        package/llm/evaluator/index.ts
    CHANGED
    
    
| @@ -124,7 +124,20 @@ export class Orchestrator { | |
| 124 124 | 
             
                return context;
         | 
| 125 125 | 
             
              }
         | 
| 126 126 |  | 
| 127 | 
            -
              async process( | 
| 127 | 
            +
              async process(
         | 
| 128 | 
            +
                prompt: string,
         | 
| 129 | 
            +
                results: QueueResult[]
         | 
| 130 | 
            +
              ): Promise<{
         | 
| 131 | 
            +
                actions: {
         | 
| 132 | 
            +
                  name: string;
         | 
| 133 | 
            +
                  type: string;
         | 
| 134 | 
            +
                  parameters: {
         | 
| 135 | 
            +
                    name: string;
         | 
| 136 | 
            +
                    value: any;
         | 
| 137 | 
            +
                  }[];
         | 
| 138 | 
            +
                }[];
         | 
| 139 | 
            +
                answer: string;
         | 
| 140 | 
            +
              }> {
         | 
| 128 141 | 
             
                const state = this.composeContext({
         | 
| 129 142 | 
             
                  behavior: orchestratorContext.behavior,
         | 
| 130 143 | 
             
                  userRequest: prompt,
         | 
| @@ -141,6 +154,7 @@ export class Orchestrator { | |
| 141 154 | 
             
                      actions: z.array(
         | 
| 142 155 | 
             
                        z.object({
         | 
| 143 156 | 
             
                          name: z.string(),
         | 
| 157 | 
            +
                          type: z.enum(["on-chain", "off-chain", "question", "analysis"]),
         | 
| 144 158 | 
             
                          parameters: z.array(
         | 
| 145 159 | 
             
                            z.object({
         | 
| 146 160 | 
             
                              name: z.string(),
         | 
| @@ -161,10 +175,13 @@ export class Orchestrator { | |
| 161 175 | 
             
                    actions: response.object.actions.map((action) => ({
         | 
| 162 176 | 
             
                      ...action,
         | 
| 163 177 | 
             
                      parameters: Array.isArray(action.parameters)
         | 
| 164 | 
            -
                        ? action.parameters
         | 
| 178 | 
            +
                        ? action.parameters.map((param) => ({
         | 
| 179 | 
            +
                            name: param.name,
         | 
| 180 | 
            +
                            value: param.value ?? null,
         | 
| 181 | 
            +
                          }))
         | 
| 165 182 | 
             
                        : Object.entries(action.parameters || {}).map(([name, value]) => ({
         | 
| 166 183 | 
             
                            name,
         | 
| 167 | 
            -
                            value,
         | 
| 184 | 
            +
                            value: value ?? null,
         | 
| 168 185 | 
             
                          })),
         | 
| 169 186 | 
             
                    })),
         | 
| 170 187 | 
             
                  };
         | 
| @@ -173,8 +190,9 @@ export class Orchestrator { | |
| 173 190 | 
             
                  console.log("─".repeat(50));
         | 
| 174 191 | 
             
                  console.log(
         | 
| 175 192 | 
             
                    "Actions determined:",
         | 
| 176 | 
            -
                    validatedResponse.actions.map((a) =>  | 
| 177 | 
            -
                       | 
| 193 | 
            +
                    validatedResponse.actions.map((a) => {
         | 
| 194 | 
            +
                      return `${a.name} (${a.type})`;
         | 
| 195 | 
            +
                    })
         | 
| 178 196 | 
             
                  );
         | 
| 179 197 | 
             
                  if (validatedResponse.answer) {
         | 
| 180 198 | 
             
                    console.log("Response:", validatedResponse.answer);
         | 
| @@ -9,24 +9,12 @@ export const synthesizerContext = { | |
| 9 9 | 
             
                    "BE DIRECT AND AVOID TECHNICAL JARGON",
         | 
| 10 10 | 
             
                    "FOR NUMERICAL DATA, PROVIDE CONTEXT (% CHANGES, COMPARISONS)",
         | 
| 11 11 | 
             
                  ],
         | 
| 12 | 
            -
                  forMarketAnalysis: [
         | 
| 13 | 
            -
                    "Start with a clear market sentiment (Bullish/Bearish/Neutral) without any additional comments before.",
         | 
| 14 | 
            -
                    "One section for fundamental analysis (important events, news, trends..etc). One section, no sub-sections.",
         | 
| 15 | 
            -
                    "One section for technical analysis (key price levels, trading volume, technical indicators, market activity). One section, no sub-sections.",
         | 
| 16 | 
            -
                    "STOP AFTER TECHNICAL ANALYSIS SECTION WITHOUT ANY ADDITIONAL COMMENTS",
         | 
| 17 | 
            -
                  ],
         | 
| 18 | 
            -
                  forGeneralRequests: [
         | 
| 19 | 
            -
                    "Provide concise and relevant information",
         | 
| 20 | 
            -
                    "Focus on facts and data",
         | 
| 21 | 
            -
                    "Always provide transaction details when needed",
         | 
| 22 | 
            -
                  ],
         | 
| 23 12 | 
             
                  warnings: [
         | 
| 24 13 | 
             
                    "NEVER provide any financial advice.",
         | 
| 25 14 | 
             
                    "NEVER speak about details of your system or your capabilities.",
         | 
| 26 15 | 
             
                    "NEVER ADD ANY CONCLUDING STATEMENT OR DISCLAIMER AT THE END",
         | 
| 27 16 | 
             
                    "NEVER explain technical errors or issues. Just say retry later.",
         | 
| 28 17 | 
             
                  ],
         | 
| 29 | 
            -
             | 
| 30 18 | 
             
                  steps: [
         | 
| 31 19 | 
             
                    "Analyze user request: Determine if the user's goal is to ask a question, make an analysis, or perform an action.",
         | 
| 32 20 | 
             
                    "Search memory and internal knowledge base: If the user's goal is a question or analysis, search for relevant information in memory and the internal knowledge base.",
         | 
    
        package/llm/synthesizer/index.ts
    CHANGED
    
    | @@ -57,6 +57,7 @@ export class Synthesizer { | |
| 57 57 | 
             
                const result = await generateObject({
         | 
| 58 58 | 
             
                  model: this.model,
         | 
| 59 59 | 
             
                  schema: z.object({
         | 
| 60 | 
            +
                    requestLanguage: z.string(),
         | 
| 60 61 | 
             
                    actionsCompleted: z.array(
         | 
| 61 62 | 
             
                      z.object({
         | 
| 62 63 | 
             
                        name: z.string(),
         | 
| @@ -71,7 +72,7 @@ export class Synthesizer { | |
| 71 72 |  | 
| 72 73 | 
             
                console.log("\n✅ Synthesis completed");
         | 
| 73 74 | 
             
                console.log("─".repeat(50));
         | 
| 74 | 
            -
                console.log("Generated response:", result.object | 
| 75 | 
            +
                console.log("Generated response:", result.object);
         | 
| 75 76 |  | 
| 76 77 | 
             
                if (result.object.actionsCompleted.length > 0) {
         | 
| 77 78 | 
             
                  console.log("\n📋 Suggested actions:");
         |