art-framework 0.3.9 → 0.4.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/dist/index.d.cts CHANGED
@@ -437,6 +437,47 @@ declare class LLMStreamSocket extends TypedSocket<StreamEvent, StreamEventTypeFi
437
437
  notifyStreamEvent(event: StreamEvent): void;
438
438
  }
439
439
 
440
+ declare enum TodoItemStatus {
441
+ PENDING = "pending",
442
+ IN_PROGRESS = "in_progress",
443
+ COMPLETED = "completed",
444
+ FAILED = "failed",
445
+ CANCELLED = "cancelled",
446
+ WAITING = "waiting"
447
+ }
448
+ interface TodoItem {
449
+ id: string;
450
+ description: string;
451
+ status: TodoItemStatus;
452
+ dependencies?: string[];
453
+ result?: any;
454
+ thoughts?: string[];
455
+ toolCalls?: ParsedToolCall[];
456
+ toolResults?: ToolResult[];
457
+ createdTimestamp: number;
458
+ updatedTimestamp: number;
459
+ }
460
+ interface PESAgentStateData {
461
+ threadId: string;
462
+ intent: string;
463
+ title: string;
464
+ plan: string;
465
+ todoList: TodoItem[];
466
+ currentStepId: string | null;
467
+ isPaused: boolean;
468
+ }
469
+ interface ExecutionOutput {
470
+ thoughts?: string;
471
+ content?: string;
472
+ toolCalls?: ParsedToolCall[];
473
+ nextStepDecision?: 'continue' | 'wait' | 'complete_item' | 'update_plan';
474
+ updatedPlan?: {
475
+ intent?: string;
476
+ plan?: string;
477
+ todoList?: TodoItem[];
478
+ };
479
+ }
480
+
440
481
  /**
441
482
  * @module types/schemas
442
483
  * This module defines Zod schemas for validating the core data structures of the ART framework,
@@ -996,6 +1037,10 @@ declare enum ObservationType {
996
1037
  FINAL_RESPONSE = "FINAL_RESPONSE",
997
1038
  /** Records changes made to the agent's persistent state. */
998
1039
  STATE_UPDATE = "STATE_UPDATE",
1040
+ /** Records updates to the plan structure (intent, title, or list changes). */
1041
+ PLAN_UPDATE = "PLAN_UPDATE",
1042
+ /** Records status changes of a specific todo item. */
1043
+ ITEM_STATUS_CHANGE = "ITEM_STATUS_CHANGE",
999
1044
  /** Logged by Agent Core when LLM stream consumption begins. */
1000
1045
  LLM_STREAM_START = "LLM_STREAM_START",
1001
1046
  /** Logged by Agent Core upon receiving a METADATA stream event. Content should be LLMMetadata. */
@@ -1043,6 +1088,12 @@ interface Observation {
1043
1088
  * @property {string} threadId
1044
1089
  */
1045
1090
  threadId: string;
1091
+ /**
1092
+ * An optional identifier for the parent object (e.g., a TodoItem ID) to which this observation belongs.
1093
+ * This allows differentiation between primary (user query) and secondary (sub-task) observations.
1094
+ * @property {string} [parentId]
1095
+ */
1096
+ parentId?: string;
1046
1097
  /**
1047
1098
  * An optional identifier for tracing a request across multiple systems or components.
1048
1099
  * @property {string} [traceId]
@@ -2829,7 +2880,14 @@ interface OutputParser {
2829
2880
  plan?: string;
2830
2881
  toolCalls?: ParsedToolCall[];
2831
2882
  thoughts?: string;
2883
+ todoList?: TodoItem[];
2832
2884
  }>;
2885
+ /**
2886
+ * Parses the raw string output from the execution LLM call (per todo item).
2887
+ * @param output - The raw string response from the execution LLM call.
2888
+ * @returns A promise resolving to the structured execution output.
2889
+ */
2890
+ parseExecutionOutput(output: string): Promise<ExecutionOutput>;
2833
2891
  /**
2834
2892
  * Parses the raw string output from the synthesis LLM call to extract the final, user-facing response content.
2835
2893
  * This might involve removing extraneous tags or formatting.
@@ -3442,6 +3500,76 @@ declare class McpManager {
3442
3500
  uninstallServer(serverId: string): Promise<void>;
3443
3501
  }
3444
3502
 
3503
+ /**
3504
+ * Configuration object required by the AgentFactory and createArtInstance function.
3505
+ * This will now use ArtInstanceConfig from types.ts which includes stateSavingStrategy.
3506
+ */
3507
+ /**
3508
+ * Handles the instantiation and wiring of all core ART framework components based on provided configuration.
3509
+ * This class performs the dependency injection needed to create a functional `ArtInstance`.
3510
+ * It's typically used internally by the `createArtInstance` function.
3511
+ */
3512
+ declare class AgentFactory {
3513
+ private config;
3514
+ private storageAdapter;
3515
+ private uiSystem;
3516
+ private conversationRepository;
3517
+ private observationRepository;
3518
+ private stateRepository;
3519
+ private a2aTaskRepository;
3520
+ private conversationManager;
3521
+ private stateManager;
3522
+ private observationManager;
3523
+ private toolRegistry;
3524
+ private providerManager;
3525
+ private reasoningEngine;
3526
+ private outputParser;
3527
+ private systemPromptResolver;
3528
+ private toolSystem;
3529
+ private authManager;
3530
+ private mcpManager;
3531
+ private agentDiscoveryService;
3532
+ private taskDelegationService;
3533
+ /**
3534
+ * Creates a new AgentFactory instance.
3535
+ * @param config - The configuration specifying which adapters and components to use.
3536
+ */
3537
+ constructor(config: ArtInstanceConfig);
3538
+ /**
3539
+ * Asynchronously initializes all core components based on the configuration.
3540
+ * This includes setting up the storage adapter, repositories, managers, tool registry,
3541
+ * reasoning engine, and UI system.
3542
+ * This method MUST be called before `createAgent()`.
3543
+ * @returns A promise that resolves when initialization is complete.
3544
+ * @throws {Error} If configuration is invalid or initialization fails for a component.
3545
+ */
3546
+ initialize(): Promise<void>;
3547
+ /**
3548
+ * Creates an instance of the configured Agent Core (e.g., `PESAgent`) and injects
3549
+ * all necessary initialized dependencies (managers, systems, etc.).
3550
+ * Requires `initialize()` to have been successfully called beforehand.
3551
+ * @returns An instance implementing the `IAgentCore` interface.
3552
+ * @throws {Error} If `initialize()` was not called or if essential components failed to initialize.
3553
+ */
3554
+ createAgent(): IAgentCore;
3555
+ /** Gets the initialized Storage Adapter instance. */
3556
+ getStorageAdapter(): StorageAdapter | null;
3557
+ /** Gets the initialized UI System instance. */
3558
+ getUISystem(): UISystem$1 | null;
3559
+ /** Gets the initialized Tool Registry instance. */
3560
+ getToolRegistry(): ToolRegistry$1 | null;
3561
+ /** Gets the initialized State Manager instance. */
3562
+ getStateManager(): StateManager$1 | null;
3563
+ /** Gets the initialized Conversation Manager instance. */
3564
+ getConversationManager(): ConversationManager | null;
3565
+ /** Gets the initialized Observation Manager instance. */
3566
+ getObservationManager(): ObservationManager | null;
3567
+ /** Gets the initialized Auth Manager instance. */
3568
+ getAuthManager(): AuthManager | null;
3569
+ /** Gets the initialized MCP Manager instance. */
3570
+ getMcpManager(): McpManager | null;
3571
+ }
3572
+
3445
3573
  /**
3446
3574
  * High-level factory function to create and initialize a complete ART framework instance.
3447
3575
  * This simplifies the setup process by handling the instantiation and wiring of all
@@ -3683,92 +3811,27 @@ interface PESAgentDependencies {
3683
3811
  }
3684
3812
  /**
3685
3813
  * Implements the Plan-Execute-Synthesize (PES) agent orchestration logic.
3686
- * This agent follows a structured approach:
3687
- * 1. **Plan:** Understand the user query, determine intent, and create a plan (potentially involving tool calls).
3688
- * 2. **Execute:** Run any necessary tools identified in the planning phase.
3689
- * 3. **Synthesize:** Generate a final response based on the query, plan, and tool results.
3690
- *
3691
- * It constructs standardized prompts (`ArtStandardPrompt`) directly as JavaScript objects
3692
- * for the `ReasoningEngine`. It processes the `StreamEvent` output from the reasoning engine for both planning and synthesis.
3814
+ * Refactored to support persistent TodoList execution and iterative refinement.
3693
3815
  */
3694
3816
  declare class PESAgent implements IAgentCore {
3695
3817
  private readonly deps;
3696
3818
  private readonly persona;
3697
- /**
3698
- * Creates an instance of the PESAgent.
3699
- * @param {module:core/agents/pes-agent.PESAgentDependencies} dependencies - An object containing instances of all required subsystems (managers, registries, etc.).
3700
- */
3701
3819
  constructor(dependencies: PESAgentDependencies);
3702
- /**
3703
- * Executes the full Plan-Execute-Synthesize cycle for a given user query.
3704
- *
3705
- * **Workflow:**
3706
- * 1. **Initiation & Config:** Loads thread configuration and resolves system prompt
3707
- * 2. **Data Gathering:** Gathers history, available tools
3708
- * 3. **Loop (ReAct-like):**
3709
- * - **Planning:** LLM call for planning and parsing (with access to history of previous steps).
3710
- * - **A2A Discovery & Delegation:** Identifies and delegates A2A tasks.
3711
- * - **Tool Execution:** Executes identified local tool calls.
3712
- * - **Observation:** Results are fed back into the next iteration.
3713
- * 4. **Synthesis:** LLM call for final response generation including all results
3714
- * 5. **Finalization:** Saves messages and cleanup
3715
- *
3716
- * @param {AgentProps} props - The input properties containing the user query, threadId, userId, traceId, etc.
3717
- * @returns {Promise<AgentFinalResponse>} A promise resolving to the final response, including the AI message and execution metadata.
3718
- * @throws {ARTError} If a critical error occurs that prevents the agent from completing the process.
3719
- */
3720
3820
  process(props: AgentProps): Promise<AgentFinalResponse>;
3721
- /**
3722
- * Loads thread configuration and resolves the system prompt hierarchy.
3723
- * @private
3724
- */
3821
+ private _saveState;
3822
+ private _recordPlanObservations;
3823
+ private _performPlanning;
3824
+ private _performPlanRefinement;
3825
+ private _callPlanningLLM;
3826
+ private _executeTodoList;
3827
+ private _processTodoItem;
3828
+ private _performSynthesis;
3725
3829
  private _loadConfiguration;
3726
- /**
3727
- * Gathers conversation history for the current thread.
3728
- * @private
3729
- */
3730
3830
  private _gatherHistory;
3731
- /**
3732
- * Gathers available tools for the current thread.
3733
- * @private
3734
- */
3735
3831
  private _gatherTools;
3736
- /**
3737
- * Performs the planning phase including LLM call and output parsing.
3738
- * @private
3739
- */
3740
- private _performPlanning;
3741
- /**
3742
- * Delegates A2A tasks identified in the planning phase.
3743
- * @private
3744
- */
3745
3832
  private _delegateA2ATasks;
3746
- /**
3747
- * Waits for A2A tasks to complete with configurable timeout.
3748
- * @private
3749
- */
3750
3833
  private _waitForA2ACompletion;
3751
- /**
3752
- * Executes local tools identified during planning.
3753
- * @private
3754
- */
3755
- private _executeLocalTools;
3756
- /**
3757
- * Performs the synthesis phase including LLM call for final response generation.
3758
- * @private
3759
- */
3760
- private _performSynthesis;
3761
- /**
3762
- * Finalizes the agent execution by saving the final message and performing cleanup.
3763
- * @private
3764
- */
3765
3834
  private _finalize;
3766
- /**
3767
- * Formats conversation history messages for direct inclusion in ArtStandardPrompt.
3768
- * Converts internal MessageRole to ArtStandardMessageRole.
3769
- * @param history - Array of ConversationMessage objects.
3770
- * @returns Array of messages suitable for ArtStandardPrompt.
3771
- */
3772
3835
  private formatHistoryForPrompt;
3773
3836
  }
3774
3837
 
@@ -4081,7 +4144,7 @@ declare class SupabaseStorageAdapter implements StorageAdapter {
4081
4144
  interface GeminiAdapterOptions {
4082
4145
  /** Your Google AI API key (e.g., from Google AI Studio). Handle securely. */
4083
4146
  apiKey: string;
4084
- /** The default Gemini model ID to use (e.g., 'gemini-1.5-flash-latest', 'gemini-pro'). Defaults to 'gemini-1.5-flash-latest' if not provided. */
4147
+ /** The default Gemini model ID to use (e.g., 'gemini-2.5-flash', 'gemini-pro'). Defaults to 'gemini-2.5-flash' if not provided. */
4085
4148
  model?: string;
4086
4149
  /** Optional: Override the base URL for the Google Generative AI API. */
4087
4150
  apiBaseUrl?: string;
@@ -5204,4 +5267,4 @@ declare const generateUUID: () => string;
5204
5267
  */
5205
5268
  declare const VERSION = "0.3.8";
5206
5269
 
5207
- export { type A2AAgentInfo, type A2ATask, type A2ATaskEvent, type A2ATaskFilter, type A2ATaskMetadata, A2ATaskPriority, type A2ATaskResult, A2ATaskSocket, A2ATaskStatus, ARTError, AdapterInstantiationError, type AgentDiscoveryConfig, AgentDiscoveryService, type AgentFinalResponse, type AgentOptions, type AgentPersona, type AgentProps, type AgentState, AnthropicAdapter, type AnthropicAdapterOptions, ApiKeyStrategy, ApiQueueTimeoutError, type ArtInstance, type ArtInstanceConfig, type ArtStandardMessage, type ArtStandardMessageRole, ArtStandardMessageSchema, type ArtStandardPrompt, ArtStandardPromptSchema, AuthManager, type AvailableProviderEntry, CalculatorTool, type CallOptions, type ConversationManager, type ConversationMessage, ConversationSocket, type CreateA2ATaskRequest, DeepSeekAdapter, type DeepSeekAdapterOptions, ErrorCode, type ExecutionContext, type ExecutionMetadata, type FilterOptions, type FormattedPrompt, GeminiAdapter, type GeminiAdapterOptions, GenericOAuthStrategy, type IA2ATaskRepository, type IAgentCore, type IAuthStrategy, type IConversationRepository, type IObservationRepository, type IProviderManager, type IStateRepository, type IToolExecutor, type ITypedSocket, InMemoryStorageAdapter, IndexedDBStorageAdapter, type JsonObjectSchema, type JsonSchema, type LLMMetadata, LLMStreamSocket, LocalInstanceBusyError, LocalProviderConflictError, LogLevel, Logger, type LoggerConfig, type ManagedAdapterAccessor, McpClientController, McpManager, type McpManagerConfig, McpProxyTool, type McpResource, type McpResourceTemplate, type McpServerConfig, type McpServerStatus, type McpToolDefinition, type MessageOptions, MessageRole, ModelCapability, type OAuthConfig, type Observation, type ObservationFilter, type ObservationManager, ObservationSocket, ObservationType, OllamaAdapter, type OllamaAdapterOptions, OpenAIAdapter, type OpenAIAdapterOptions, OpenRouterAdapter, type OpenRouterAdapterOptions, type OutputParser, PESAgent, type PKCEOAuthConfig, PKCEOAuthStrategy, type ParsedToolCall, type PromptBlueprint, type PromptContext, type ProviderAdapter, type ProviderManagerConfig, ProviderManagerImpl, type ReasoningEngine, type RuntimeProviderConfig, type StageSpecificPrompts, StateManager, type StateSavingStrategy, type StorageAdapter, type StreamEvent, type StreamEventTypeFilter, SupabaseStorageAdapter, type SystemPromptMergeStrategy, type SystemPromptOverride, type SystemPromptResolver, type SystemPromptSpec, type SystemPromptsRegistry, type TaskDelegationConfig, TaskDelegationService, type TaskStatusResponse, type ThreadConfig, type ThreadContext, ToolRegistry, type ToolResult, type ToolSchema, type ToolSystem, TypedSocket, UISystem, UnknownProviderError, type UnsubscribeFunction, type UpdateA2ATaskRequest, VERSION, type ZyntopiaOAuthConfig, ZyntopiaOAuthStrategy, createArtInstance, generateUUID };
5270
+ export { type A2AAgentInfo, type A2ATask, type A2ATaskEvent, type A2ATaskFilter, type A2ATaskMetadata, A2ATaskPriority, type A2ATaskResult, A2ATaskSocket, A2ATaskStatus, ARTError, AdapterInstantiationError, type AgentDiscoveryConfig, AgentDiscoveryService, AgentFactory, type AgentFinalResponse, type AgentOptions, type AgentPersona, type AgentProps, type AgentState, AnthropicAdapter, type AnthropicAdapterOptions, ApiKeyStrategy, ApiQueueTimeoutError, type ArtInstance, type ArtInstanceConfig, type ArtStandardMessage, type ArtStandardMessageRole, ArtStandardMessageSchema, type ArtStandardPrompt, ArtStandardPromptSchema, AuthManager, type AvailableProviderEntry, CalculatorTool, type CallOptions, type ConversationManager, type ConversationMessage, ConversationSocket, type CreateA2ATaskRequest, DeepSeekAdapter, type DeepSeekAdapterOptions, ErrorCode, type ExecutionContext, type ExecutionMetadata, type ExecutionOutput, type FilterOptions, type FormattedPrompt, GeminiAdapter, type GeminiAdapterOptions, GenericOAuthStrategy, type IA2ATaskRepository, type IAgentCore, type IAuthStrategy, type IConversationRepository, type IObservationRepository, type IProviderManager, type IStateRepository, type IToolExecutor, type ITypedSocket, InMemoryStorageAdapter, IndexedDBStorageAdapter, type JsonObjectSchema, type JsonSchema, type LLMMetadata, LLMStreamSocket, LocalInstanceBusyError, LocalProviderConflictError, LogLevel, Logger, type LoggerConfig, type ManagedAdapterAccessor, McpClientController, McpManager, type McpManagerConfig, McpProxyTool, type McpResource, type McpResourceTemplate, type McpServerConfig, type McpServerStatus, type McpToolDefinition, type MessageOptions, MessageRole, ModelCapability, type OAuthConfig, type Observation, type ObservationFilter, type ObservationManager, ObservationSocket, ObservationType, OllamaAdapter, type OllamaAdapterOptions, OpenAIAdapter, type OpenAIAdapterOptions, OpenRouterAdapter, type OpenRouterAdapterOptions, type OutputParser, PESAgent, type PESAgentStateData, type PKCEOAuthConfig, PKCEOAuthStrategy, type ParsedToolCall, type PromptBlueprint, type PromptContext, type ProviderAdapter, type ProviderManagerConfig, ProviderManagerImpl, type ReasoningEngine, type RuntimeProviderConfig, type StageSpecificPrompts, StateManager, type StateSavingStrategy, type StorageAdapter, type StreamEvent, type StreamEventTypeFilter, SupabaseStorageAdapter, type SystemPromptMergeStrategy, type SystemPromptOverride, type SystemPromptResolver, type SystemPromptSpec, type SystemPromptsRegistry, type TaskDelegationConfig, TaskDelegationService, type TaskStatusResponse, type ThreadConfig, type ThreadContext, type TodoItem, TodoItemStatus, ToolRegistry, type ToolResult, type ToolSchema, type ToolSystem, TypedSocket, UISystem, UnknownProviderError, type UnsubscribeFunction, type UpdateA2ATaskRequest, VERSION, type ZyntopiaOAuthConfig, ZyntopiaOAuthStrategy, createArtInstance, generateUUID };
package/dist/index.d.ts CHANGED
@@ -437,6 +437,47 @@ declare class LLMStreamSocket extends TypedSocket<StreamEvent, StreamEventTypeFi
437
437
  notifyStreamEvent(event: StreamEvent): void;
438
438
  }
439
439
 
440
+ declare enum TodoItemStatus {
441
+ PENDING = "pending",
442
+ IN_PROGRESS = "in_progress",
443
+ COMPLETED = "completed",
444
+ FAILED = "failed",
445
+ CANCELLED = "cancelled",
446
+ WAITING = "waiting"
447
+ }
448
+ interface TodoItem {
449
+ id: string;
450
+ description: string;
451
+ status: TodoItemStatus;
452
+ dependencies?: string[];
453
+ result?: any;
454
+ thoughts?: string[];
455
+ toolCalls?: ParsedToolCall[];
456
+ toolResults?: ToolResult[];
457
+ createdTimestamp: number;
458
+ updatedTimestamp: number;
459
+ }
460
+ interface PESAgentStateData {
461
+ threadId: string;
462
+ intent: string;
463
+ title: string;
464
+ plan: string;
465
+ todoList: TodoItem[];
466
+ currentStepId: string | null;
467
+ isPaused: boolean;
468
+ }
469
+ interface ExecutionOutput {
470
+ thoughts?: string;
471
+ content?: string;
472
+ toolCalls?: ParsedToolCall[];
473
+ nextStepDecision?: 'continue' | 'wait' | 'complete_item' | 'update_plan';
474
+ updatedPlan?: {
475
+ intent?: string;
476
+ plan?: string;
477
+ todoList?: TodoItem[];
478
+ };
479
+ }
480
+
440
481
  /**
441
482
  * @module types/schemas
442
483
  * This module defines Zod schemas for validating the core data structures of the ART framework,
@@ -996,6 +1037,10 @@ declare enum ObservationType {
996
1037
  FINAL_RESPONSE = "FINAL_RESPONSE",
997
1038
  /** Records changes made to the agent's persistent state. */
998
1039
  STATE_UPDATE = "STATE_UPDATE",
1040
+ /** Records updates to the plan structure (intent, title, or list changes). */
1041
+ PLAN_UPDATE = "PLAN_UPDATE",
1042
+ /** Records status changes of a specific todo item. */
1043
+ ITEM_STATUS_CHANGE = "ITEM_STATUS_CHANGE",
999
1044
  /** Logged by Agent Core when LLM stream consumption begins. */
1000
1045
  LLM_STREAM_START = "LLM_STREAM_START",
1001
1046
  /** Logged by Agent Core upon receiving a METADATA stream event. Content should be LLMMetadata. */
@@ -1043,6 +1088,12 @@ interface Observation {
1043
1088
  * @property {string} threadId
1044
1089
  */
1045
1090
  threadId: string;
1091
+ /**
1092
+ * An optional identifier for the parent object (e.g., a TodoItem ID) to which this observation belongs.
1093
+ * This allows differentiation between primary (user query) and secondary (sub-task) observations.
1094
+ * @property {string} [parentId]
1095
+ */
1096
+ parentId?: string;
1046
1097
  /**
1047
1098
  * An optional identifier for tracing a request across multiple systems or components.
1048
1099
  * @property {string} [traceId]
@@ -2829,7 +2880,14 @@ interface OutputParser {
2829
2880
  plan?: string;
2830
2881
  toolCalls?: ParsedToolCall[];
2831
2882
  thoughts?: string;
2883
+ todoList?: TodoItem[];
2832
2884
  }>;
2885
+ /**
2886
+ * Parses the raw string output from the execution LLM call (per todo item).
2887
+ * @param output - The raw string response from the execution LLM call.
2888
+ * @returns A promise resolving to the structured execution output.
2889
+ */
2890
+ parseExecutionOutput(output: string): Promise<ExecutionOutput>;
2833
2891
  /**
2834
2892
  * Parses the raw string output from the synthesis LLM call to extract the final, user-facing response content.
2835
2893
  * This might involve removing extraneous tags or formatting.
@@ -3442,6 +3500,76 @@ declare class McpManager {
3442
3500
  uninstallServer(serverId: string): Promise<void>;
3443
3501
  }
3444
3502
 
3503
+ /**
3504
+ * Configuration object required by the AgentFactory and createArtInstance function.
3505
+ * This will now use ArtInstanceConfig from types.ts which includes stateSavingStrategy.
3506
+ */
3507
+ /**
3508
+ * Handles the instantiation and wiring of all core ART framework components based on provided configuration.
3509
+ * This class performs the dependency injection needed to create a functional `ArtInstance`.
3510
+ * It's typically used internally by the `createArtInstance` function.
3511
+ */
3512
+ declare class AgentFactory {
3513
+ private config;
3514
+ private storageAdapter;
3515
+ private uiSystem;
3516
+ private conversationRepository;
3517
+ private observationRepository;
3518
+ private stateRepository;
3519
+ private a2aTaskRepository;
3520
+ private conversationManager;
3521
+ private stateManager;
3522
+ private observationManager;
3523
+ private toolRegistry;
3524
+ private providerManager;
3525
+ private reasoningEngine;
3526
+ private outputParser;
3527
+ private systemPromptResolver;
3528
+ private toolSystem;
3529
+ private authManager;
3530
+ private mcpManager;
3531
+ private agentDiscoveryService;
3532
+ private taskDelegationService;
3533
+ /**
3534
+ * Creates a new AgentFactory instance.
3535
+ * @param config - The configuration specifying which adapters and components to use.
3536
+ */
3537
+ constructor(config: ArtInstanceConfig);
3538
+ /**
3539
+ * Asynchronously initializes all core components based on the configuration.
3540
+ * This includes setting up the storage adapter, repositories, managers, tool registry,
3541
+ * reasoning engine, and UI system.
3542
+ * This method MUST be called before `createAgent()`.
3543
+ * @returns A promise that resolves when initialization is complete.
3544
+ * @throws {Error} If configuration is invalid or initialization fails for a component.
3545
+ */
3546
+ initialize(): Promise<void>;
3547
+ /**
3548
+ * Creates an instance of the configured Agent Core (e.g., `PESAgent`) and injects
3549
+ * all necessary initialized dependencies (managers, systems, etc.).
3550
+ * Requires `initialize()` to have been successfully called beforehand.
3551
+ * @returns An instance implementing the `IAgentCore` interface.
3552
+ * @throws {Error} If `initialize()` was not called or if essential components failed to initialize.
3553
+ */
3554
+ createAgent(): IAgentCore;
3555
+ /** Gets the initialized Storage Adapter instance. */
3556
+ getStorageAdapter(): StorageAdapter | null;
3557
+ /** Gets the initialized UI System instance. */
3558
+ getUISystem(): UISystem$1 | null;
3559
+ /** Gets the initialized Tool Registry instance. */
3560
+ getToolRegistry(): ToolRegistry$1 | null;
3561
+ /** Gets the initialized State Manager instance. */
3562
+ getStateManager(): StateManager$1 | null;
3563
+ /** Gets the initialized Conversation Manager instance. */
3564
+ getConversationManager(): ConversationManager | null;
3565
+ /** Gets the initialized Observation Manager instance. */
3566
+ getObservationManager(): ObservationManager | null;
3567
+ /** Gets the initialized Auth Manager instance. */
3568
+ getAuthManager(): AuthManager | null;
3569
+ /** Gets the initialized MCP Manager instance. */
3570
+ getMcpManager(): McpManager | null;
3571
+ }
3572
+
3445
3573
  /**
3446
3574
  * High-level factory function to create and initialize a complete ART framework instance.
3447
3575
  * This simplifies the setup process by handling the instantiation and wiring of all
@@ -3683,92 +3811,27 @@ interface PESAgentDependencies {
3683
3811
  }
3684
3812
  /**
3685
3813
  * Implements the Plan-Execute-Synthesize (PES) agent orchestration logic.
3686
- * This agent follows a structured approach:
3687
- * 1. **Plan:** Understand the user query, determine intent, and create a plan (potentially involving tool calls).
3688
- * 2. **Execute:** Run any necessary tools identified in the planning phase.
3689
- * 3. **Synthesize:** Generate a final response based on the query, plan, and tool results.
3690
- *
3691
- * It constructs standardized prompts (`ArtStandardPrompt`) directly as JavaScript objects
3692
- * for the `ReasoningEngine`. It processes the `StreamEvent` output from the reasoning engine for both planning and synthesis.
3814
+ * Refactored to support persistent TodoList execution and iterative refinement.
3693
3815
  */
3694
3816
  declare class PESAgent implements IAgentCore {
3695
3817
  private readonly deps;
3696
3818
  private readonly persona;
3697
- /**
3698
- * Creates an instance of the PESAgent.
3699
- * @param {module:core/agents/pes-agent.PESAgentDependencies} dependencies - An object containing instances of all required subsystems (managers, registries, etc.).
3700
- */
3701
3819
  constructor(dependencies: PESAgentDependencies);
3702
- /**
3703
- * Executes the full Plan-Execute-Synthesize cycle for a given user query.
3704
- *
3705
- * **Workflow:**
3706
- * 1. **Initiation & Config:** Loads thread configuration and resolves system prompt
3707
- * 2. **Data Gathering:** Gathers history, available tools
3708
- * 3. **Loop (ReAct-like):**
3709
- * - **Planning:** LLM call for planning and parsing (with access to history of previous steps).
3710
- * - **A2A Discovery & Delegation:** Identifies and delegates A2A tasks.
3711
- * - **Tool Execution:** Executes identified local tool calls.
3712
- * - **Observation:** Results are fed back into the next iteration.
3713
- * 4. **Synthesis:** LLM call for final response generation including all results
3714
- * 5. **Finalization:** Saves messages and cleanup
3715
- *
3716
- * @param {AgentProps} props - The input properties containing the user query, threadId, userId, traceId, etc.
3717
- * @returns {Promise<AgentFinalResponse>} A promise resolving to the final response, including the AI message and execution metadata.
3718
- * @throws {ARTError} If a critical error occurs that prevents the agent from completing the process.
3719
- */
3720
3820
  process(props: AgentProps): Promise<AgentFinalResponse>;
3721
- /**
3722
- * Loads thread configuration and resolves the system prompt hierarchy.
3723
- * @private
3724
- */
3821
+ private _saveState;
3822
+ private _recordPlanObservations;
3823
+ private _performPlanning;
3824
+ private _performPlanRefinement;
3825
+ private _callPlanningLLM;
3826
+ private _executeTodoList;
3827
+ private _processTodoItem;
3828
+ private _performSynthesis;
3725
3829
  private _loadConfiguration;
3726
- /**
3727
- * Gathers conversation history for the current thread.
3728
- * @private
3729
- */
3730
3830
  private _gatherHistory;
3731
- /**
3732
- * Gathers available tools for the current thread.
3733
- * @private
3734
- */
3735
3831
  private _gatherTools;
3736
- /**
3737
- * Performs the planning phase including LLM call and output parsing.
3738
- * @private
3739
- */
3740
- private _performPlanning;
3741
- /**
3742
- * Delegates A2A tasks identified in the planning phase.
3743
- * @private
3744
- */
3745
3832
  private _delegateA2ATasks;
3746
- /**
3747
- * Waits for A2A tasks to complete with configurable timeout.
3748
- * @private
3749
- */
3750
3833
  private _waitForA2ACompletion;
3751
- /**
3752
- * Executes local tools identified during planning.
3753
- * @private
3754
- */
3755
- private _executeLocalTools;
3756
- /**
3757
- * Performs the synthesis phase including LLM call for final response generation.
3758
- * @private
3759
- */
3760
- private _performSynthesis;
3761
- /**
3762
- * Finalizes the agent execution by saving the final message and performing cleanup.
3763
- * @private
3764
- */
3765
3834
  private _finalize;
3766
- /**
3767
- * Formats conversation history messages for direct inclusion in ArtStandardPrompt.
3768
- * Converts internal MessageRole to ArtStandardMessageRole.
3769
- * @param history - Array of ConversationMessage objects.
3770
- * @returns Array of messages suitable for ArtStandardPrompt.
3771
- */
3772
3835
  private formatHistoryForPrompt;
3773
3836
  }
3774
3837
 
@@ -4081,7 +4144,7 @@ declare class SupabaseStorageAdapter implements StorageAdapter {
4081
4144
  interface GeminiAdapterOptions {
4082
4145
  /** Your Google AI API key (e.g., from Google AI Studio). Handle securely. */
4083
4146
  apiKey: string;
4084
- /** The default Gemini model ID to use (e.g., 'gemini-1.5-flash-latest', 'gemini-pro'). Defaults to 'gemini-1.5-flash-latest' if not provided. */
4147
+ /** The default Gemini model ID to use (e.g., 'gemini-2.5-flash', 'gemini-pro'). Defaults to 'gemini-2.5-flash' if not provided. */
4085
4148
  model?: string;
4086
4149
  /** Optional: Override the base URL for the Google Generative AI API. */
4087
4150
  apiBaseUrl?: string;
@@ -5204,4 +5267,4 @@ declare const generateUUID: () => string;
5204
5267
  */
5205
5268
  declare const VERSION = "0.3.8";
5206
5269
 
5207
- export { type A2AAgentInfo, type A2ATask, type A2ATaskEvent, type A2ATaskFilter, type A2ATaskMetadata, A2ATaskPriority, type A2ATaskResult, A2ATaskSocket, A2ATaskStatus, ARTError, AdapterInstantiationError, type AgentDiscoveryConfig, AgentDiscoveryService, type AgentFinalResponse, type AgentOptions, type AgentPersona, type AgentProps, type AgentState, AnthropicAdapter, type AnthropicAdapterOptions, ApiKeyStrategy, ApiQueueTimeoutError, type ArtInstance, type ArtInstanceConfig, type ArtStandardMessage, type ArtStandardMessageRole, ArtStandardMessageSchema, type ArtStandardPrompt, ArtStandardPromptSchema, AuthManager, type AvailableProviderEntry, CalculatorTool, type CallOptions, type ConversationManager, type ConversationMessage, ConversationSocket, type CreateA2ATaskRequest, DeepSeekAdapter, type DeepSeekAdapterOptions, ErrorCode, type ExecutionContext, type ExecutionMetadata, type FilterOptions, type FormattedPrompt, GeminiAdapter, type GeminiAdapterOptions, GenericOAuthStrategy, type IA2ATaskRepository, type IAgentCore, type IAuthStrategy, type IConversationRepository, type IObservationRepository, type IProviderManager, type IStateRepository, type IToolExecutor, type ITypedSocket, InMemoryStorageAdapter, IndexedDBStorageAdapter, type JsonObjectSchema, type JsonSchema, type LLMMetadata, LLMStreamSocket, LocalInstanceBusyError, LocalProviderConflictError, LogLevel, Logger, type LoggerConfig, type ManagedAdapterAccessor, McpClientController, McpManager, type McpManagerConfig, McpProxyTool, type McpResource, type McpResourceTemplate, type McpServerConfig, type McpServerStatus, type McpToolDefinition, type MessageOptions, MessageRole, ModelCapability, type OAuthConfig, type Observation, type ObservationFilter, type ObservationManager, ObservationSocket, ObservationType, OllamaAdapter, type OllamaAdapterOptions, OpenAIAdapter, type OpenAIAdapterOptions, OpenRouterAdapter, type OpenRouterAdapterOptions, type OutputParser, PESAgent, type PKCEOAuthConfig, PKCEOAuthStrategy, type ParsedToolCall, type PromptBlueprint, type PromptContext, type ProviderAdapter, type ProviderManagerConfig, ProviderManagerImpl, type ReasoningEngine, type RuntimeProviderConfig, type StageSpecificPrompts, StateManager, type StateSavingStrategy, type StorageAdapter, type StreamEvent, type StreamEventTypeFilter, SupabaseStorageAdapter, type SystemPromptMergeStrategy, type SystemPromptOverride, type SystemPromptResolver, type SystemPromptSpec, type SystemPromptsRegistry, type TaskDelegationConfig, TaskDelegationService, type TaskStatusResponse, type ThreadConfig, type ThreadContext, ToolRegistry, type ToolResult, type ToolSchema, type ToolSystem, TypedSocket, UISystem, UnknownProviderError, type UnsubscribeFunction, type UpdateA2ATaskRequest, VERSION, type ZyntopiaOAuthConfig, ZyntopiaOAuthStrategy, createArtInstance, generateUUID };
5270
+ export { type A2AAgentInfo, type A2ATask, type A2ATaskEvent, type A2ATaskFilter, type A2ATaskMetadata, A2ATaskPriority, type A2ATaskResult, A2ATaskSocket, A2ATaskStatus, ARTError, AdapterInstantiationError, type AgentDiscoveryConfig, AgentDiscoveryService, AgentFactory, type AgentFinalResponse, type AgentOptions, type AgentPersona, type AgentProps, type AgentState, AnthropicAdapter, type AnthropicAdapterOptions, ApiKeyStrategy, ApiQueueTimeoutError, type ArtInstance, type ArtInstanceConfig, type ArtStandardMessage, type ArtStandardMessageRole, ArtStandardMessageSchema, type ArtStandardPrompt, ArtStandardPromptSchema, AuthManager, type AvailableProviderEntry, CalculatorTool, type CallOptions, type ConversationManager, type ConversationMessage, ConversationSocket, type CreateA2ATaskRequest, DeepSeekAdapter, type DeepSeekAdapterOptions, ErrorCode, type ExecutionContext, type ExecutionMetadata, type ExecutionOutput, type FilterOptions, type FormattedPrompt, GeminiAdapter, type GeminiAdapterOptions, GenericOAuthStrategy, type IA2ATaskRepository, type IAgentCore, type IAuthStrategy, type IConversationRepository, type IObservationRepository, type IProviderManager, type IStateRepository, type IToolExecutor, type ITypedSocket, InMemoryStorageAdapter, IndexedDBStorageAdapter, type JsonObjectSchema, type JsonSchema, type LLMMetadata, LLMStreamSocket, LocalInstanceBusyError, LocalProviderConflictError, LogLevel, Logger, type LoggerConfig, type ManagedAdapterAccessor, McpClientController, McpManager, type McpManagerConfig, McpProxyTool, type McpResource, type McpResourceTemplate, type McpServerConfig, type McpServerStatus, type McpToolDefinition, type MessageOptions, MessageRole, ModelCapability, type OAuthConfig, type Observation, type ObservationFilter, type ObservationManager, ObservationSocket, ObservationType, OllamaAdapter, type OllamaAdapterOptions, OpenAIAdapter, type OpenAIAdapterOptions, OpenRouterAdapter, type OpenRouterAdapterOptions, type OutputParser, PESAgent, type PESAgentStateData, type PKCEOAuthConfig, PKCEOAuthStrategy, type ParsedToolCall, type PromptBlueprint, type PromptContext, type ProviderAdapter, type ProviderManagerConfig, ProviderManagerImpl, type ReasoningEngine, type RuntimeProviderConfig, type StageSpecificPrompts, StateManager, type StateSavingStrategy, type StorageAdapter, type StreamEvent, type StreamEventTypeFilter, SupabaseStorageAdapter, type SystemPromptMergeStrategy, type SystemPromptOverride, type SystemPromptResolver, type SystemPromptSpec, type SystemPromptsRegistry, type TaskDelegationConfig, TaskDelegationService, type TaskStatusResponse, type ThreadConfig, type ThreadContext, type TodoItem, TodoItemStatus, ToolRegistry, type ToolResult, type ToolSchema, type ToolSystem, TypedSocket, UISystem, UnknownProviderError, type UnsubscribeFunction, type UpdateA2ATaskRequest, VERSION, type ZyntopiaOAuthConfig, ZyntopiaOAuthStrategy, createArtInstance, generateUUID };