@memberjunction/ai-agents 2.50.0 → 2.51.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.md CHANGED
@@ -14,6 +14,8 @@ The MemberJunction AI Agents package provides a comprehensive framework for crea
14
14
  - **🔧 Factory Pattern**: Enhanced AgentFactory for dynamic agent instantiation and extensibility
15
15
  - **🔐 Metadata-Driven**: Database-driven configuration for agents, types, and prompts
16
16
  - **📊 Analytics**: Hierarchical execution logging with performance tracking across agent workflows
17
+ - **📡 Streaming Support**: Real-time streaming of execution progress and AI model responses
18
+ - **🛑 Cancellation Support**: Graceful cancellation of long-running operations with AbortSignal
17
19
 
18
20
  ## Installation
19
21
 
@@ -21,12 +23,25 @@ The MemberJunction AI Agents package provides a comprehensive framework for crea
21
23
  npm install @memberjunction/ai-agents
22
24
  ```
23
25
 
26
+ ### Type Organization Update (2025)
27
+
28
+ As part of improving code organization and reducing circular dependencies:
29
+ - **This package** now contains all agent-specific types:
30
+ - Agent execution types (`AgentExecutionParams`, `AgentExecutionResult`, etc.)
31
+ - Agent runner types (`AgentRunnerParams`, `AgentRunnerResult`)
32
+ - Conductor types (`ConductorDecisionInput`, `ConductorDecisionResponse`)
33
+ - Progress and streaming callbacks
34
+ - **Base AI types** are imported from `@memberjunction/ai` (Core)
35
+ - **Prompt types** are imported from `@memberjunction/ai-prompts`
36
+ - **Engine types** (agent type definitions) are imported from `@memberjunction/aiengine`
37
+
24
38
  ## Requirements
25
39
 
26
40
  - Node.js 16+
27
41
  - MemberJunction Core libraries
42
+ - [@memberjunction/ai](../Core/README.md) for base AI types and interfaces
28
43
  - [@memberjunction/ai-prompts](../Prompts/README.md) for advanced prompt management
29
- - [@memberjunction/aiengine](../Engine/README.md) for AI model orchestration
44
+ - [@memberjunction/aiengine](../Engine/README.md) for AI model orchestration and agent type definitions
30
45
 
31
46
  ## Core Architecture
32
47
 
@@ -208,6 +223,583 @@ const result = await runner.Run({
208
223
  // The agent run record tracks the compression activity
209
224
  ```
210
225
 
226
+ ### Streaming and Progress Tracking
227
+
228
+ The AI Agents framework supports real-time streaming of execution progress and AI model responses:
229
+
230
+ ```typescript
231
+ import { AgentRunner } from '@memberjunction/ai-agents';
232
+
233
+ const runner = new AgentRunner();
234
+
235
+ // Execute with streaming and progress callbacks
236
+ const result = await runner.RunAgent({
237
+ agent: myAgent,
238
+ conversationMessages: messages,
239
+ contextUser: user,
240
+
241
+ // Progress callback for execution status updates
242
+ onProgress: (progress) => {
243
+ console.log(`[${progress.percentage}%] ${progress.step}: ${progress.message}`);
244
+
245
+ // Progress steps include:
246
+ // - initialization: Setting up the agent
247
+ // - validation: Validating agent configuration
248
+ // - prompt_execution: Executing AI prompts
249
+ // - action_execution: Running actions
250
+ // - subagent_execution: Running sub-agents
251
+ // - decision_processing: Processing next steps
252
+ // - finalization: Completing execution
253
+ },
254
+
255
+ // Streaming callback for real-time AI responses
256
+ onStreaming: (chunk) => {
257
+ process.stdout.write(chunk.content);
258
+
259
+ if (chunk.isComplete) {
260
+ console.log('\n--- Stream complete ---');
261
+ }
262
+
263
+ // Additional metadata available:
264
+ // - chunk.stepType: 'prompt', 'action', 'subagent', or 'chat'
265
+ // - chunk.stepEntityId: ID of the step being executed
266
+ // - chunk.modelName: AI model producing the content (for prompts)
267
+ }
268
+ });
269
+ ```
270
+
271
+ ### Cancellation Support
272
+
273
+ Long-running agent operations can be cancelled gracefully using AbortSignal:
274
+
275
+ ```typescript
276
+ import { AgentRunner } from '@memberjunction/ai-agents';
277
+
278
+ const runner = new AgentRunner();
279
+ const controller = new AbortController();
280
+
281
+ // Set up cancellation after 30 seconds
282
+ setTimeout(() => {
283
+ console.log('Cancelling agent execution...');
284
+ controller.abort();
285
+ }, 30000);
286
+
287
+ try {
288
+ const result = await runner.RunAgent({
289
+ agent: myAgent,
290
+ conversationMessages: messages,
291
+ contextUser: user,
292
+ cancellationToken: controller.signal,
293
+ onProgress: (progress) => {
294
+ console.log(`Progress: ${progress.message}`);
295
+ }
296
+ });
297
+
298
+ if (result.cancelled) {
299
+ console.log('Execution was cancelled:', result.cancellationReason);
300
+ }
301
+ } catch (error) {
302
+ if (controller.signal.aborted) {
303
+ console.log('Operation cancelled by user');
304
+ } else {
305
+ console.error('Execution error:', error);
306
+ }
307
+ }
308
+
309
+ // Cancellation is checked at multiple points:
310
+ // - Before starting execution
311
+ // - After initialization
312
+ // - Before each execution step
313
+ // - After prompt/action/sub-agent completion
314
+ // The agent run is properly marked as 'Cancelled' in the database
315
+ ```
316
+
317
+ ## Extending BaseAgent
318
+
319
+ The BaseAgent class provides a flexible execution pipeline that can be extended and customized through protected methods. This allows subclasses to override specific parts of the execution flow while maintaining the overall architecture.
320
+
321
+ ### Execution Pipeline Overview
322
+
323
+ The BaseAgent execution pipeline consists of the following overridable methods:
324
+
325
+ 1. **`initializeEngines()`** - Initialize AI and Action engines
326
+ 2. **`validateAgent()`** - Validate agent readiness
327
+ 3. **`loadAgentConfiguration()`** - Load agent type and prompts
328
+ 4. **`preparePromptParams()`** - Prepare hierarchical prompt parameters
329
+ 5. **`executePrompt()`** - Execute the configured prompts
330
+ 6. **`processNextStep()`** - Process agent type decisions
331
+ 7. **`handleActionResults()`** - Handle action execution and recursion
332
+ 8. **`handleSubAgentResult()`** - Handle sub-agent execution and recursion
333
+ 9. **`createActionResultMessage()`** - Format action results as chat messages
334
+ 10. **`createSubAgentResultMessage()`** - Format sub-agent results as chat messages
335
+
336
+ ### Creating Custom Agent Classes
337
+
338
+ ```typescript
339
+ import { BaseAgent, ExecuteAgentParams, ExecuteAgentResult } from '@memberjunction/ai-agents';
340
+ import { AIPromptParams } from '@memberjunction/ai-prompts';
341
+
342
+ export class CustomAnalysisAgent extends BaseAgent {
343
+ // Override initialization to add custom setup
344
+ protected async initializeEngines(contextUser?: UserInfo): Promise<void> {
345
+ await super.initializeEngines(contextUser);
346
+
347
+ // Add custom initialization
348
+ await this.initializeAnalysisTools();
349
+ }
350
+
351
+ // Override validation to add custom checks
352
+ protected async validateAgent(agent: AIAgentEntity): Promise<ExecuteAgentResult | null> {
353
+ const baseValidation = await super.validateAgent(agent);
354
+ if (baseValidation) return baseValidation;
355
+
356
+ // Add custom validation
357
+ if (!this.hasRequiredPermissions(agent)) {
358
+ return {
359
+ nextStep: 'failed',
360
+ errorMessage: 'Agent lacks required analysis permissions'
361
+ };
362
+ }
363
+
364
+ return null;
365
+ }
366
+
367
+ // Override prompt preparation to inject custom data
368
+ protected async preparePromptParams(
369
+ agentType: AIAgentTypeEntity,
370
+ systemPrompt: any,
371
+ childPrompt: any,
372
+ params: ExecuteAgentParams
373
+ ): Promise<AIPromptParams> {
374
+ const promptParams = await super.preparePromptParams(agentType, systemPrompt, childPrompt, params);
375
+
376
+ // Add custom context data
377
+ promptParams.data = {
378
+ ...promptParams.data,
379
+ analysisContext: await this.gatherAnalysisContext(),
380
+ historicalData: await this.loadHistoricalData()
381
+ };
382
+
383
+ return promptParams;
384
+ }
385
+
386
+ // Override action result formatting
387
+ protected createActionResultMessage(actions: AgentAction[], results: any[]): ChatMessage {
388
+ // Custom formatting for analysis results
389
+ const analysisResults = results.map((result, index) => {
390
+ return {
391
+ action: actions[index].name,
392
+ success: result.Success,
393
+ analysisScore: result.Params?.find(p => p.Name === 'score')?.Value,
394
+ insights: result.Params?.find(p => p.Name === 'insights')?.Value
395
+ };
396
+ });
397
+
398
+ return {
399
+ role: 'user',
400
+ content: `Analysis completed:\n${JSON.stringify(analysisResults, null, 2)}`
401
+ };
402
+ }
403
+ }
404
+ ```
405
+
406
+ ### Selective Method Overriding
407
+
408
+ You can override just the methods you need to customize:
409
+
410
+ ```typescript
411
+ export class StreamingAgent extends BaseAgent {
412
+ // Only override prompt execution to add streaming
413
+ protected async executePrompt(promptParams: AIPromptParams): Promise<any> {
414
+ // Add streaming configuration
415
+ promptParams.streaming = true;
416
+ promptParams.streamingCallback = (chunk) => {
417
+ this.handleStreamingChunk(chunk);
418
+ };
419
+
420
+ return await super.executePrompt(promptParams);
421
+ }
422
+
423
+ private handleStreamingChunk(chunk: string): void {
424
+ // Process streaming response chunks
425
+ console.log('Streaming:', chunk);
426
+ }
427
+ }
428
+ ```
429
+
430
+ ### Customizing Recursion Behavior
431
+
432
+ Override the action/sub-agent handling methods to customize recursion:
433
+
434
+ ```typescript
435
+ export class BatchProcessingAgent extends BaseAgent {
436
+ protected async handleActionResults(
437
+ params: ExecuteAgentParams,
438
+ nextStep: any,
439
+ promptResult: any
440
+ ): Promise<ExecuteAgentResult> {
441
+ // Execute actions
442
+ const actionResults = await this.ExecuteActions(nextStep.actions, params.contextUser);
443
+
444
+ // Batch results instead of immediate recursion
445
+ if (this.shouldBatchResults(actionResults)) {
446
+ this.batchedResults.push(...actionResults);
447
+
448
+ // Continue without recursion if batching
449
+ return {
450
+ nextStep: 'retry',
451
+ returnValue: { batching: true, count: this.batchedResults.length }
452
+ };
453
+ }
454
+
455
+ // Otherwise use default recursion behavior
456
+ return await super.handleActionResults(params, nextStep, promptResult);
457
+ }
458
+ }
459
+ ```
460
+
461
+ ### Advanced Pipeline Customization
462
+
463
+ For complex scenarios, you can completely override the Execute method while still using the helper methods:
464
+
465
+ ```typescript
466
+ export class MultiStageAgent extends BaseAgent {
467
+ public async Execute(params: ExecuteAgentParams): Promise<ExecuteAgentResult> {
468
+ // Stage 1: Initial analysis
469
+ const stage1Result = await this.executeStage1(params);
470
+ if (stage1Result.nextStep === 'failed') return stage1Result;
471
+
472
+ // Stage 2: Deep processing based on stage 1
473
+ const stage2Params = this.prepareStage2Params(params, stage1Result);
474
+ const stage2Result = await this.executeStage2(stage2Params);
475
+ if (stage2Result.nextStep === 'failed') return stage2Result;
476
+
477
+ // Stage 3: Synthesis and final execution
478
+ return await this.executeFinalStage(params, stage1Result, stage2Result);
479
+ }
480
+
481
+ private async executeStage1(params: ExecuteAgentParams): Promise<ExecuteAgentResult> {
482
+ // Use base methods for configuration loading
483
+ const config = await this.loadAgentConfiguration(params.agent);
484
+ if (!config.success) {
485
+ return { nextStep: 'failed', errorMessage: config.errorMessage };
486
+ }
487
+
488
+ // Custom stage 1 logic...
489
+ }
490
+ }
491
+ ```
492
+
493
+ ### Best Practices for Extending BaseAgent
494
+
495
+ 1. **Always call super methods** when overriding unless completely replacing functionality
496
+ 2. **Maintain the contract** - return the expected types from overridden methods
497
+ 3. **Use protected methods** for extensibility rather than duplicating logic
498
+ 4. **Document overrides** clearly in your subclass
499
+ 5. **Test thoroughly** - ensure your overrides work with the recursion logic
500
+ 6. **Handle errors gracefully** - follow the error result pattern
501
+ 7. **Preserve metadata** - pass through rawResult and other metadata
502
+
503
+ ### Common Extension Patterns
504
+
505
+ #### Adding Pre/Post Processing
506
+ ```typescript
507
+ protected async executePrompt(promptParams: AIPromptParams): Promise<any> {
508
+ // Pre-processing
509
+ await this.beforePromptExecution(promptParams);
510
+
511
+ // Execute
512
+ const result = await super.executePrompt(promptParams);
513
+
514
+ // Post-processing
515
+ await this.afterPromptExecution(result);
516
+
517
+ return result;
518
+ }
519
+ ```
520
+
521
+ #### Custom Context Injection
522
+ ```typescript
523
+ protected async preparePromptParams(...args): Promise<AIPromptParams> {
524
+ const params = await super.preparePromptParams(...args);
525
+
526
+ // Inject custom context
527
+ params.data.customContext = await this.loadCustomContext();
528
+ params.conversationMessages = this.preprocessMessages(params.conversationMessages);
529
+
530
+ return params;
531
+ }
532
+ ```
533
+
534
+ #### Conditional Execution Flow
535
+ ```typescript
536
+ protected async processNextStep(
537
+ params: ExecuteAgentParams,
538
+ agentType: AIAgentTypeEntity,
539
+ promptResult: any
540
+ ): Promise<ExecuteAgentResult> {
541
+ // Check for special conditions
542
+ if (this.shouldUseAlternativeFlow(promptResult)) {
543
+ return await this.executeAlternativeFlow(params, promptResult);
544
+ }
545
+
546
+ // Otherwise use default flow
547
+ return await super.processNextStep(params, agentType, promptResult);
548
+ }
549
+ ```
550
+
551
+ ## Enhanced Execution Result Structure
552
+
553
+ The AI Agents framework now provides comprehensive execution tracking through the enhanced `ExecuteAgentResult` type. This structure gives complete visibility into every step of agent execution, including all prompts, actions, sub-agents, and decisions made along the way.
554
+
555
+ ### ExecuteAgentResult
556
+
557
+ The main result structure returned from agent execution:
558
+
559
+ ```typescript
560
+ interface ExecuteAgentResult {
561
+ // Core execution outcome
562
+ success: boolean; // Whether the overall execution was successful
563
+ finalStep: BaseAgentNextStep['step']; // The final step type that terminated execution
564
+ returnValue?: any; // Optional return value from the agent
565
+ errorMessage?: string; // Error message if execution failed
566
+
567
+ // Tracking and history
568
+ agentRun: AIAgentRunEntity; // Database entity tracking this execution
569
+ executionChain: ExecutionChainStep[]; // Complete chain of execution steps
570
+ }
571
+ ```
572
+
573
+ ### ExecutionChainStep
574
+
575
+ Each step in the execution chain captures:
576
+
577
+ ```typescript
578
+ interface ExecutionChainStep {
579
+ stepEntity: AIAgentRunStepEntity; // Database entity for this step
580
+ executionType: 'prompt' | 'action' | 'sub-agent' | 'decision' | 'chat' | 'validation';
581
+ executionResult: StepExecutionResult; // The actual result (varies by type)
582
+ nextStepDecision: NextStepDecision; // What was decided after this step
583
+ startTime: Date; // When the step started
584
+ endTime?: Date; // When the step completed
585
+ durationMs?: number; // Execution duration in milliseconds
586
+ }
587
+ ```
588
+
589
+ ### Step Execution Results
590
+
591
+ Different execution types have specialized result structures:
592
+
593
+ #### PromptExecutionResult
594
+ ```typescript
595
+ {
596
+ type: 'prompt';
597
+ promptId: string;
598
+ promptName: string;
599
+ result: AIPromptRunResult; // Native result from @memberjunction/ai-prompts
600
+ }
601
+ ```
602
+
603
+ #### ActionExecutionResult
604
+ ```typescript
605
+ {
606
+ type: 'action';
607
+ actionId: string;
608
+ actionName: string;
609
+ result: ActionResult | ActionResultSimple; // Native result from @memberjunction/actions
610
+ }
611
+ ```
612
+
613
+ #### SubAgentExecutionResult
614
+ ```typescript
615
+ {
616
+ type: 'sub-agent';
617
+ subAgentId: string;
618
+ subAgentName: string;
619
+ result: ExecuteAgentResult; // Recursive - full execution result of sub-agent
620
+ }
621
+ ```
622
+
623
+ ### Usage Example
624
+
625
+ ```typescript
626
+ const runner = new AgentRunner();
627
+ const result = await runner.RunAgent({
628
+ agent: myAgent,
629
+ conversationMessages: messages,
630
+ contextUser: user
631
+ });
632
+
633
+ // Access execution outcome
634
+ console.log(`Success: ${result.success}`);
635
+ console.log(`Final step: ${result.finalStep}`);
636
+ console.log(`Return value:`, result.returnValue);
637
+
638
+ // Access the agent run record
639
+ console.log(`Agent run ID: ${result.agentRun.ID}`);
640
+ console.log(`Started at: ${result.agentRun.StartedAt}`);
641
+ console.log(`Duration: ${result.agentRun.CompletedAt - result.agentRun.StartedAt}ms`);
642
+
643
+ // Analyze the execution chain
644
+ result.executionChain.forEach((step, index) => {
645
+ console.log(`\nStep ${index + 1}: ${step.executionType}`);
646
+ console.log(` Name: ${step.stepEntity.StepName}`);
647
+ console.log(` Duration: ${step.durationMs}ms`);
648
+ console.log(` Success: ${step.stepEntity.Success}`);
649
+
650
+ // Access type-specific results
651
+ switch (step.executionResult.type) {
652
+ case 'prompt':
653
+ console.log(` Prompt: ${step.executionResult.promptName}`);
654
+ console.log(` Tokens used: ${step.executionResult.result.tokensUsed}`);
655
+ break;
656
+ case 'action':
657
+ console.log(` Action: ${step.executionResult.actionName}`);
658
+ console.log(` Result: ${step.executionResult.result.Success}`);
659
+ break;
660
+ case 'sub-agent':
661
+ console.log(` Sub-agent: ${step.executionResult.subAgentName}`);
662
+ console.log(` Sub-steps: ${step.executionResult.result.executionChain.length}`);
663
+ break;
664
+ }
665
+
666
+ // Show what was decided next
667
+ console.log(` Next decision: ${step.nextStepDecision.decision}`);
668
+ console.log(` Reasoning: ${step.nextStepDecision.reasoning}`);
669
+ });
670
+
671
+ // Visualize the execution flow
672
+ const executionFlow = result.executionChain
673
+ .map(step => `${step.executionType} → ${step.nextStepDecision.decision}`)
674
+ .join(' → ');
675
+ console.log(`\nExecution flow: ${executionFlow}`);
676
+ ```
677
+
678
+ ### Database Persistence
679
+
680
+ All execution data is automatically persisted to the database:
681
+
682
+ - **AIAgentRun**: Tracks the overall agent execution
683
+ - Links to parent runs for sub-agent tracking
684
+ - Stores final results and state
685
+ - Tracks timing and success status
686
+
687
+ - **AIAgentRunStep**: Tracks individual execution steps
688
+ - Links to the parent run
689
+ - Stores step-specific data (input/output)
690
+ - Tracks step timing and success
691
+
692
+ This enables:
693
+ - Historical analysis of agent behavior
694
+ - Performance optimization based on real data
695
+ - Debugging complex agent interactions
696
+ - Compliance and audit trails
697
+
698
+ ### Analyzing Sub-Agent Execution
699
+
700
+ Sub-agent results are fully recursive, allowing deep analysis:
701
+
702
+ ```typescript
703
+ function analyzeExecutionDepth(result: ExecuteAgentResult, depth = 0): void {
704
+ const indent = ' '.repeat(depth);
705
+ console.log(`${indent}Agent: ${result.agentRun.AgentID}`);
706
+ console.log(`${indent}Steps: ${result.executionChain.length}`);
707
+
708
+ // Find sub-agent executions
709
+ const subAgentSteps = result.executionChain.filter(
710
+ step => step.executionType === 'sub-agent'
711
+ ) as Array<{ executionResult: SubAgentExecutionResult }>;
712
+
713
+ // Recursively analyze sub-agents
714
+ for (const step of subAgentSteps) {
715
+ analyzeExecutionDepth(step.executionResult.result, depth + 1);
716
+ }
717
+ }
718
+
719
+ // Analyze the entire execution tree
720
+ analyzeExecutionDepth(result);
721
+ ```
722
+
723
+ ### Performance Analysis
724
+
725
+ Use the execution chain for performance optimization:
726
+
727
+ ```typescript
728
+ // Calculate time spent in each type of operation
729
+ const timingAnalysis = result.executionChain.reduce((acc, step) => {
730
+ const type = step.executionType;
731
+ acc[type] = (acc[type] || 0) + (step.durationMs || 0);
732
+ return acc;
733
+ }, {} as Record<string, number>);
734
+
735
+ console.log('Time spent by operation type:', timingAnalysis);
736
+
737
+ // Find slowest steps
738
+ const slowestSteps = result.executionChain
739
+ .filter(step => step.durationMs)
740
+ .sort((a, b) => b.durationMs! - a.durationMs!)
741
+ .slice(0, 5);
742
+
743
+ console.log('Top 5 slowest steps:', slowestSteps.map(s => ({
744
+ name: s.stepEntity.StepName,
745
+ duration: s.durationMs,
746
+ type: s.executionType
747
+ })));
748
+ ```
749
+
750
+ ## Type Exports
751
+
752
+ The Agents package exports comprehensive types for agent operations:
753
+
754
+ ### Core Agent Types
755
+ - `AgentExecutionParams` - Parameters for agent execution
756
+ - `AgentExecutionResult` - Result from agent execution
757
+ - `BaseAgentNextStep` - Next step decision structure
758
+ - `ExecutionChainStep` - Individual step in execution chain
759
+
760
+ ### Agent Runner Types
761
+ - `AgentRunnerParams` - Parameters for AgentRunner
762
+ - `AgentRunnerResult` - Enhanced result with decision history
763
+ - `AgentProgressUpdate` - Progress tracking structure
764
+ - `AgentStreamingUpdate` - Streaming content structure
765
+
766
+ ### Conductor Types
767
+ - `ConductorDecisionInput` - Input for conductor decisions
768
+ - `ConductorDecisionResponse` - Structured decision response
769
+ - `ExecutionStep` - Individual execution plan step
770
+ - `ConductorDecisionType` - Decision type enumeration
771
+
772
+ ### Factory and Interface Types
773
+ - `IAgentFactory` - Factory interface for agent creation
774
+ - `BaseAgent` - Base class for all agents
775
+ - `ConductorAgent` - Specialized conductor agent class
776
+
777
+ ## Import Examples
778
+
779
+ ```typescript
780
+ // Import main classes
781
+ import { BaseAgent, ConductorAgent, AgentRunner } from '@memberjunction/ai-agents';
782
+ import { GetAgentFactory } from '@memberjunction/ai-agents';
783
+
784
+ // Import types
785
+ import {
786
+ AgentExecutionParams,
787
+ AgentExecutionResult,
788
+ AgentRunnerParams,
789
+ AgentRunnerResult,
790
+ ConductorDecisionResponse
791
+ } from '@memberjunction/ai-agents';
792
+
793
+ // Import base AI types from Core
794
+ import { ChatMessage, ChatResult } from '@memberjunction/ai';
795
+
796
+ // Import prompt types when needed
797
+ import { AIPromptParams, AIPromptRunResult } from '@memberjunction/ai-prompts';
798
+
799
+ // Import entity types
800
+ import { AIAgentEntity, AIAgentTypeEntity } from '@memberjunction/core-entities';
801
+ ```
802
+
211
803
  ## API Reference
212
804
 
213
805
  ### AgentRunner Class
@@ -396,8 +988,8 @@ await agentPrompt.Save();
396
988
  - `@memberjunction/core`: ^2.43.0 - MemberJunction core library
397
989
  - `@memberjunction/global`: ^2.43.0 - MemberJunction global utilities
398
990
  - `@memberjunction/core-entities`: ^2.43.0 - MemberJunction entity definitions
399
- - `@memberjunction/ai`: ^2.43.0 - Base AI functionality
400
- - `@memberjunction/aiengine`: ^2.43.0 - AI model orchestration
991
+ - `@memberjunction/ai`: ^2.43.0 - Base AI types and interfaces (imported for core types)
992
+ - `@memberjunction/aiengine`: ^2.43.0 - AI model orchestration and agent type definitions
401
993
  - `@memberjunction/ai-prompts`: ^2.43.0 - Advanced prompt management
402
994
  - `@memberjunction/templates`: ^2.43.0 - Template rendering support
403
995
  - `rxjs`: ^7.8.1 - Reactive programming support
@@ -1,4 +1,5 @@
1
- import { ExecuteAgentParams, ExecuteAgentResult } from './types';
1
+ import { ExecuteAgentResult } from '@memberjunction/aiengine';
2
+ import { ExecuteAgentParams } from './types';
2
3
  export declare class AgentRunner {
3
4
  RunAgent(params: ExecuteAgentParams): Promise<ExecuteAgentResult>;
4
5
  }
@@ -1 +1 @@
1
- {"version":3,"file":"AgentRunner.d.ts","sourceRoot":"","sources":["../src/AgentRunner.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAqBjE,qBAAa,WAAW;IAcP,QAAQ,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAwCjF"}
1
+ {"version":3,"file":"AgentRunner.d.ts","sourceRoot":"","sources":["../src/AgentRunner.ts"],"names":[],"mappings":"AAcA,OAAO,EAAY,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAExE,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAqB7C,qBAAa,WAAW;IAcP,QAAQ,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC;CA4CjF"}
@@ -26,8 +26,11 @@ class AgentRunner {
26
26
  const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
27
27
  (0, core_1.LogError)(`AgentRunner execution failed: ${errorMessage}`, undefined, error);
28
28
  return {
29
- nextStep: 'failed',
30
- errorMessage
29
+ success: false,
30
+ finalStep: 'failed',
31
+ errorMessage,
32
+ agentRun: null,
33
+ executionTree: []
31
34
  };
32
35
  }
33
36
  }
@@ -1 +1 @@
1
- {"version":3,"file":"AgentRunner.js","sourceRoot":"","sources":["../src/AgentRunner.ts"],"names":[],"mappings":";;;AAYA,+CAA2D;AAC3D,mDAAkD;AAClD,uDAAoD;AACpD,6CAAyC;AAsBzC,MAAa,WAAW;IAcb,KAAK,CAAC,QAAQ,CAAC,MAA0B;QAC5C,IAAI,CAAC;YACD,IAAA,gBAAS,EAAC,8CAA8C,MAAM,CAAC,KAAK,CAAC,IAAI,SAAS,MAAM,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC;YAGtG,MAAM,mBAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;YAG1D,MAAM,SAAS,GAAG,mBAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YACzF,IAAI,CAAC,SAAS,EAAE,CAAC;gBACb,MAAM,IAAI,KAAK,CAAC,gCAAgC,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;YAC3E,CAAC;YAGD,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,WAAW,IAAI,SAAS,CAAC,WAAW,CAAC;YACtE,IAAA,gBAAS,EAAC,oCAAoC,WAAW,EAAE,CAAC,CAAC;YAE7D,MAAM,aAAa,GAAG,iBAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,cAAc,CAC/D,sBAAS,EACT,WAAW,CACd,CAAC;YAEF,IAAI,CAAC,aAAa,EAAE,CAAC;gBACjB,MAAM,IAAI,KAAK,CAAC,qDAAqD,WAAW,EAAE,CAAC,CAAC;YACxF,CAAC;YAGD,OAAO,MAAM,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAE/C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,wBAAwB,CAAC;YACvF,IAAA,eAAQ,EAAC,iCAAiC,YAAY,EAAE,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;YAG5E,OAAO;gBACH,QAAQ,EAAE,QAAQ;gBAClB,YAAY;aACf,CAAC;QACN,CAAC;IACL,CAAC;CACJ;AAtDD,kCAsDC"}
1
+ {"version":3,"file":"AgentRunner.js","sourceRoot":"","sources":["../src/AgentRunner.ts"],"names":[],"mappings":";;;AAYA,+CAA2D;AAC3D,mDAAkD;AAClD,uDAAwE;AACxE,6CAAyC;AAsBzC,MAAa,WAAW;IAcb,KAAK,CAAC,QAAQ,CAAC,MAA0B;QAC5C,IAAI,CAAC;YACD,IAAA,gBAAS,EAAC,8CAA8C,MAAM,CAAC,KAAK,CAAC,IAAI,SAAS,MAAM,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC;YAGtG,MAAM,mBAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;YAG1D,MAAM,SAAS,GAAG,mBAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YACzF,IAAI,CAAC,SAAS,EAAE,CAAC;gBACb,MAAM,IAAI,KAAK,CAAC,gCAAgC,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;YAC3E,CAAC;YAGD,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,WAAW,IAAI,SAAS,CAAC,WAAW,CAAC;YACtE,IAAA,gBAAS,EAAC,oCAAoC,WAAW,EAAE,CAAC,CAAC;YAE7D,MAAM,aAAa,GAAG,iBAAQ,CAAC,QAAQ,CAAC,YAAY,CAAC,cAAc,CAC/D,sBAAS,EACT,WAAW,CACd,CAAC;YAEF,IAAI,CAAC,aAAa,EAAE,CAAC;gBACjB,MAAM,IAAI,KAAK,CAAC,qDAAqD,WAAW,EAAE,CAAC,CAAC;YACxF,CAAC;YAGD,OAAO,MAAM,aAAa,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAE/C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,wBAAwB,CAAC;YACvF,IAAA,eAAQ,EAAC,iCAAiC,YAAY,EAAE,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;YAI5E,OAAO;gBACH,OAAO,EAAE,KAAK;gBACd,SAAS,EAAE,QAAQ;gBACnB,YAAY;gBACZ,QAAQ,EAAE,IAAW;gBACrB,aAAa,EAAE,EAAE;aACpB,CAAC;QACN,CAAC;IACL,CAAC;CACJ;AA1DD,kCA0DC"}
@@ -0,0 +1,6 @@
1
+ import { AIPromptRunResult } from '@memberjunction/ai';
2
+ import { BaseAgentNextStep } from '@memberjunction/aiengine';
3
+ export declare abstract class BaseAgentType {
4
+ abstract DetermineNextStep(promptResult: AIPromptRunResult): Promise<BaseAgentNextStep>;
5
+ }
6
+ //# sourceMappingURL=base-agent-type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-agent-type.d.ts","sourceRoot":"","sources":["../../src/agent-types/base-agent-type.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAoC7D,8BAAsB,aAAa;aA4Bf,iBAAiB,CAAC,YAAY,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC;CACjG"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-agent-type.js","sourceRoot":"","sources":["../../src/agent-types/base-agent-type.ts"],"names":[],"mappings":";;;AAkDA,MAAsB,aAAa;CA6BlC;AA7BD,sCA6BC"}
@@ -1,2 +1,3 @@
1
- export * from './LoopAgentType';
1
+ export * from './base-agent-type';
2
+ export * from './loop-agent-type';
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/agent-types/index.ts"],"names":[],"mappings":"AAYA,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/agent-types/index.ts"],"names":[],"mappings":"AAYA,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC"}