@robota-sdk/agent-core 3.0.0-beta.52 → 3.0.0-beta.53

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.
@@ -714,57 +714,6 @@ interface IParameterValidationResult {
714
714
  * Generic tool executor function
715
715
  */
716
716
  type TToolExecutor<TParams = TToolParameters, TResult = TUniversalValue> = (parameters: TParams, context?: IToolExecutionContext) => Promise<TResult>;
717
- /**
718
- * OpenAPI specification configuration
719
- */
720
- interface IOpenAPIToolConfig {
721
- /** OpenAPI 3.0 specification */
722
- spec: {
723
- openapi: string;
724
- info: {
725
- title: string;
726
- version: string;
727
- description?: string;
728
- };
729
- servers?: Array<{
730
- url: string;
731
- description?: string;
732
- }>;
733
- paths: Record<string, Record<string, string | number | boolean | Record<string, string | number | boolean>>>;
734
- components?: Record<string, Record<string, string | number | boolean>>;
735
- };
736
- /** Operation ID from the OpenAPI spec */
737
- operationId: string;
738
- /** Base URL for API calls */
739
- baseURL: string;
740
- /** Authentication configuration */
741
- auth?: {
742
- type: 'bearer' | 'apiKey' | 'basic';
743
- token?: string;
744
- apiKey?: string;
745
- header?: string;
746
- username?: string;
747
- password?: string;
748
- };
749
- }
750
- /**
751
- * MCP (Model Context Protocol) configuration
752
- */
753
- interface IMCPToolConfig {
754
- /** MCP server endpoint */
755
- endpoint: string;
756
- /** Protocol version */
757
- version?: string;
758
- /** Authentication configuration */
759
- auth?: {
760
- type: 'bearer' | 'apiKey';
761
- token: string;
762
- };
763
- /** Tool-specific configuration */
764
- toolConfig?: Record<string, string | number | boolean>;
765
- /** Timeout in milliseconds */
766
- timeout?: number;
767
- }
768
717
  /**
769
718
  * Base tool interface
770
719
  */
@@ -828,23 +777,6 @@ interface IToolRegistry {
828
777
  */
829
778
  clear(): void;
830
779
  }
831
- /**
832
- * Tool factory interface
833
- */
834
- interface IToolFactory {
835
- /**
836
- * Create function tool from schema and function
837
- */
838
- createFunctionTool(schema: IToolSchema, fn: TToolExecutor): IFunctionTool;
839
- /**
840
- * Create tool from OpenAPI specification
841
- */
842
- createOpenAPITool(config: IOpenAPIToolConfig): ITool;
843
- /**
844
- * Create MCP tool
845
- */
846
- createMCPTool(config: IMCPToolConfig): ITool;
847
- }
848
780
 
849
781
  declare const EXECUTION_EVENT_NAMES: {
850
782
  readonly START: "execution.start";
@@ -1941,6 +1873,75 @@ interface IAgentFactory {
1941
1873
  mergeConfig(base: IAgentConfig, override: Partial<IAgentConfig>): IAgentConfig;
1942
1874
  }
1943
1875
 
1876
+ /**
1877
+ * OpenAPI specification configuration
1878
+ */
1879
+ interface IOpenAPIToolConfig {
1880
+ /** OpenAPI 3.0 specification */
1881
+ spec: {
1882
+ openapi: string;
1883
+ info: {
1884
+ title: string;
1885
+ version: string;
1886
+ description?: string;
1887
+ };
1888
+ servers?: Array<{
1889
+ url: string;
1890
+ description?: string;
1891
+ }>;
1892
+ paths: Record<string, Record<string, string | number | boolean | Record<string, string | number | boolean>>>;
1893
+ components?: Record<string, Record<string, string | number | boolean>>;
1894
+ };
1895
+ /** Operation ID from the OpenAPI spec */
1896
+ operationId: string;
1897
+ /** Base URL for API calls */
1898
+ baseURL: string;
1899
+ /** Authentication configuration */
1900
+ auth?: {
1901
+ type: 'bearer' | 'apiKey' | 'basic';
1902
+ token?: string;
1903
+ apiKey?: string;
1904
+ header?: string;
1905
+ username?: string;
1906
+ password?: string;
1907
+ };
1908
+ }
1909
+ /**
1910
+ * MCP (Model Context Protocol) configuration
1911
+ */
1912
+ interface IMCPToolConfig {
1913
+ /** MCP server endpoint */
1914
+ endpoint: string;
1915
+ /** Protocol version */
1916
+ version?: string;
1917
+ /** Authentication configuration */
1918
+ auth?: {
1919
+ type: 'bearer' | 'apiKey';
1920
+ token: string;
1921
+ };
1922
+ /** Tool-specific configuration */
1923
+ toolConfig?: Record<string, string | number | boolean>;
1924
+ /** Timeout in milliseconds */
1925
+ timeout?: number;
1926
+ }
1927
+ /**
1928
+ * Tool factory interface
1929
+ */
1930
+ interface IToolFactory {
1931
+ /**
1932
+ * Create function tool from schema and function
1933
+ */
1934
+ createFunctionTool(schema: IToolSchema, fn: TToolExecutor): IFunctionTool;
1935
+ /**
1936
+ * Create tool from OpenAPI specification
1937
+ */
1938
+ createOpenAPITool(config: IOpenAPIToolConfig): ITool;
1939
+ /**
1940
+ * Create MCP tool
1941
+ */
1942
+ createMCPTool(config: IMCPToolConfig): ITool;
1943
+ }
1944
+
1944
1945
  /**
1945
1946
  * Execution step definition for tools that support step-by-step progress reporting
1946
1947
  */
@@ -2507,72 +2508,13 @@ interface IExecutorAwareProviderConfig {
2507
2508
  [key: string]: string | number | boolean | IExecutor | undefined;
2508
2509
  }
2509
2510
  /**
2510
- * Base AI provider implementation with proper type constraints
2511
- * All AI providers should extend this class
2512
- *
2513
- * ========================================
2514
- * CRITICAL IMPLEMENTATION GUIDELINES
2515
- * ========================================
2516
- *
2517
- * ALL AI PROVIDER IMPLEMENTATIONS (OpenAI, Anthropic, Google, etc.) MUST:
2511
+ * Base AI provider implementation with proper type constraints.
2512
+ * All AI providers should extend this class.
2518
2513
  *
2519
- * 1. EXTEND THIS CLASS:
2520
- * ```typescript
2521
- * export class OpenAIProvider extends AbstractAIProvider {
2522
- * override readonly name = 'openai';
2523
- * override readonly version = '1.0.0';
2524
- * ```
2514
+ * Subclasses MUST: extend this class, use override keyword, call super() in constructor,
2515
+ * not redefine types that exist in agent-core, handle null message content correctly.
2525
2516
  *
2526
- * 2. USE IMPORTS FROM @robota-sdk/agent-core:
2527
- * ```typescript
2528
- * import { AbstractAIProvider } from '@robota-sdk/agent-core';
2529
- * import type {
2530
- * TUniversalMessage,
2531
- * ChatOptions,
2532
- * IToolCall,
2533
- * ToolSchema,
2534
- * AssistantMessage
2535
- * } from '@robota-sdk/agent-core';
2536
- * ```
2537
- *
2538
- * 3. USE OVERRIDE KEYWORD FOR ALL INHERITED METHODS:
2539
- * - override async chat(...)
2540
- * - override async *chatStream(...)
2541
- * - override supportsTools()
2542
- * - override validateConfig()
2543
- * - override async dispose()
2544
- *
2545
- * 4. DO NOT REDEFINE TYPES THAT EXIST IN @robota-sdk/agent-core:
2546
- * - TUniversalMessage
2547
- * - ChatOptions
2548
- * - IToolCall
2549
- * - ToolSchema
2550
- * - AssistantMessage
2551
- * - SystemMessage
2552
- * - UserMessage
2553
- * - ToolMessage
2554
- *
2555
- * 5. HANDLE MESSAGE CONTENT PROPERLY:
2556
- * - For tool calls: content should be null (not empty string)
2557
- * - For regular messages: content can be string or null
2558
- * - Always preserve null values from API responses
2559
- *
2560
- * 6. CALL SUPER() IN CONSTRUCTOR:
2561
- * ```typescript
2562
- * constructor(options: IProviderOptions) {
2563
- * super();
2564
- * // provider-specific initialization
2565
- * }
2566
- * ```
2567
- *
2568
- * This ensures ExecutionService can properly identify providers
2569
- * and prevents type conflicts across the codebase.
2570
- *
2571
- * ========================================
2572
- *
2573
- * @template TConfig - Provider configuration type (defaults to IProviderConfig for type safety)
2574
- * @template TUniversalMessage - Message type (defaults to TUniversalMessage for backward compatibility)
2575
- * @template TResponse - Response type (defaults to TUniversalMessage for backward compatibility)
2517
+ * @template TConfig - Provider configuration type
2576
2518
  */
2577
2519
  declare abstract class AbstractAIProvider<TConfig = IProviderConfig> implements IAIProvider {
2578
2520
  abstract readonly name: string;
@@ -2633,25 +2575,17 @@ declare abstract class AbstractAIProvider<TConfig = IProviderConfig> implements
2633
2575
  * @returns true if configuration is valid
2634
2576
  */
2635
2577
  validateConfig(): boolean;
2636
- /**
2637
- * Utility method for validating TUniversalMessage array
2638
- * @param messages - Messages to validate
2639
- */
2578
+ /** Validate that messages is a non-empty array with valid roles. */
2640
2579
  protected validateMessages(messages: TUniversalMessage[]): void;
2641
- /**
2642
- * Utility method for validating tool schemas
2643
- * @param tools - Tool schemas to validate
2644
- */
2580
+ /** Validate tool schemas. No-ops if tools is undefined. */
2645
2581
  protected validateTools(tools?: IToolSchema[]): void;
2646
2582
  /**
2647
2583
  * Execute chat via executor.
2648
- *
2649
2584
  * Subclasses should call this only when an executor is configured.
2650
2585
  */
2651
2586
  protected executeViaExecutorOrDirect(messages: TUniversalMessage[], options?: IChatOptions): Promise<TUniversalMessage>;
2652
2587
  /**
2653
2588
  * Execute streaming chat via executor.
2654
- *
2655
2589
  * Subclasses should call this only when an executor is configured.
2656
2590
  */
2657
2591
  protected executeStreamViaExecutorOrDirect(messages: TUniversalMessage[], options?: IChatOptions): AsyncIterable<TUniversalMessage>;
@@ -3361,17 +3295,43 @@ declare class EventEmitterPlugin extends AbstractPlugin<IEventEmitterPluginOptio
3361
3295
  off(eventType: TEventName, handlerIdOrListener: string | TEventEmitterListener): boolean;
3362
3296
  emit(eventType: TEventName, eventData?: Partial<IEventEmitterEventData>): Promise<void>;
3363
3297
  private processEvent;
3364
- private executeHandler;
3365
3298
  flushBuffer(): Promise<void>;
3366
3299
  getStats(): IEventEmitterPluginStats;
3367
3300
  clearAllListeners(): void;
3368
3301
  destroy(): Promise<void>;
3369
- private validateOptions;
3370
3302
  }
3371
3303
 
3372
3304
  /** Agent statistics metadata type */
3373
3305
  type TAgentStatsMetadata = Record<string, string | number | boolean | Date | string[]>;
3374
3306
 
3307
+ /** Shared model configuration shape used in setModel / getModel. */
3308
+ type TModelConfig = {
3309
+ provider: string;
3310
+ model: string;
3311
+ temperature?: number;
3312
+ maxTokens?: number;
3313
+ topP?: number;
3314
+ systemMessage?: string;
3315
+ };
3316
+ /** Return shape of getConfiguration(). */
3317
+ type TConfigurationSnapshot = {
3318
+ version: number;
3319
+ tools: Array<{
3320
+ name: string;
3321
+ parameters?: string[];
3322
+ }>;
3323
+ updatedAt: number;
3324
+ };
3325
+ /** Return shape of getModuleStats(). */
3326
+ type TModuleStats = {
3327
+ totalExecutions: number;
3328
+ successfulExecutions: number;
3329
+ failedExecutions: number;
3330
+ averageExecutionTime: number;
3331
+ lastExecutionTime?: Date;
3332
+ } | undefined;
3333
+ /** Shorthand for the plugin contract type used throughout this class. */
3334
+ type TPlugin = IPluginContract<IPluginOptions, IPluginStats> & IPluginHooks;
3375
3335
  /**
3376
3336
  * Core AI agent integrating multiple AI providers, tools, and plugins
3377
3337
  * into a unified conversational interface.
@@ -3401,68 +3361,33 @@ declare class Robota extends AbstractAgent<IAgentConfig, IRunOptions, TUniversal
3401
3361
  private pluginManager;
3402
3362
  private configManager;
3403
3363
  constructor(config: IAgentConfig);
3404
- private initDelegates;
3405
- private emitCreatedEvent;
3406
3364
  run(input: string, options?: IRunOptions): Promise<string>;
3407
3365
  runStream(input: string, options?: IRunOptions): AsyncGenerator<string, void, undefined>;
3408
3366
  private executionDeps;
3409
3367
  getHistory(): TUniversalMessage[];
3410
- /** Get full history timeline (IHistoryEntry[]) including events */
3411
- getFullHistory(): Array<{
3412
- id: string;
3413
- timestamp: Date;
3414
- category: string;
3415
- type: string;
3416
- data?: unknown;
3417
- }>;
3418
- /** Add an event entry to history */
3419
- addHistoryEntry(entry: {
3420
- id: string;
3421
- timestamp: Date;
3422
- category: string;
3423
- type: string;
3424
- data?: unknown;
3425
- }): void;
3368
+ getFullHistory(): IHistoryEntry[];
3369
+ addHistoryEntry(entry: IHistoryEntry): void;
3426
3370
  clearHistory(): void;
3427
- /** Inject a message into conversation history without triggering execution. */
3428
- injectMessage(role: 'user' | 'assistant' | 'system', content: string): void;
3371
+ injectMessage(role: 'user' | 'assistant' | 'system' | 'tool', content: string, options?: {
3372
+ toolCallId?: string;
3373
+ name?: string;
3374
+ }): void;
3429
3375
  updateTools(next: Array<IToolWithEventService>): Promise<{
3430
3376
  version: number;
3431
3377
  }>;
3432
3378
  updateConfiguration(patch: Partial<IAgentConfig>): Promise<{
3433
3379
  version: number;
3434
3380
  }>;
3435
- getConfiguration(): Promise<{
3436
- version: number;
3437
- tools: Array<{
3438
- name: string;
3439
- parameters?: string[];
3440
- }>;
3441
- updatedAt: number;
3442
- }>;
3443
- setModel(mc: {
3444
- provider: string;
3445
- model: string;
3446
- temperature?: number;
3447
- maxTokens?: number;
3448
- topP?: number;
3449
- systemMessage?: string;
3450
- }): void;
3451
- getModel(): {
3452
- provider: string;
3453
- model: string;
3454
- temperature?: number;
3455
- maxTokens?: number;
3456
- topP?: number;
3457
- systemMessage?: string;
3458
- };
3381
+ getConfiguration(): Promise<TConfigurationSnapshot>;
3382
+ setModel(mc: TModelConfig): void;
3383
+ getModel(): TModelConfig;
3459
3384
  registerTool(tool: AbstractTool): void;
3460
3385
  unregisterTool(toolName: string): void;
3461
3386
  getConfig(): IAgentConfig;
3462
- addPlugin(plugin: IPluginContract<IPluginOptions, IPluginStats> & IPluginHooks): void;
3387
+ addPlugin(plugin: TPlugin): void;
3463
3388
  removePlugin(pluginName: string): boolean;
3464
- getPlugin(pluginName: string): (IPluginContract<IPluginOptions, IPluginStats> & IPluginHooks) | undefined;
3465
- getPlugins(): Array<IPluginContract<IPluginOptions, IPluginStats> & IPluginHooks>;
3389
+ getPlugin(pluginName: string): TPlugin | undefined;
3390
+ getPlugins(): TPlugin[];
3466
3391
  getPluginNames(): string[];
3467
3392
  registerModule(module: IModule, options?: {
3468
3393
  autoInitialize?: boolean;
@@ -3485,13 +3410,7 @@ declare class Robota extends AbstractAgent<IAgentConfig, IRunOptions, TUniversal
3485
3410
  error?: Error;
3486
3411
  duration?: number;
3487
3412
  }>;
3488
- getModuleStats(moduleName: string): {
3489
- totalExecutions: number;
3490
- successfulExecutions: number;
3491
- failedExecutions: number;
3492
- averageExecutionTime: number;
3493
- lastExecutionTime?: Date;
3494
- } | undefined;
3413
+ getModuleStats(moduleName: string): TModuleStats;
3495
3414
  getStats(): {
3496
3415
  name: string;
3497
3416
  version: string;
@@ -3510,7 +3429,6 @@ declare class Robota extends AbstractAgent<IAgentConfig, IRunOptions, TUniversal
3510
3429
  private ensureFullyInitialized;
3511
3430
  private doAsyncInit;
3512
3431
  private emitAgentEvent;
3513
- private buildOwnerPath;
3514
3432
  }
3515
3433
 
3516
3434
  /**
@@ -3631,6 +3549,7 @@ interface IAgentLifecycleEvents {
3631
3549
  /** Called when agent is destroyed */
3632
3550
  onDestroy?: (agentId: string) => Promise<void> | void;
3633
3551
  }
3552
+
3634
3553
  /**
3635
3554
  * Agent Factory for creating and managing agents
3636
3555
  * Instance-based for isolated agent factory management
@@ -3704,18 +3623,6 @@ declare class AgentFactory {
3704
3623
  isValid: boolean;
3705
3624
  errors: string[];
3706
3625
  };
3707
- /**
3708
- * Apply default configuration values
3709
- */
3710
- private applyDefaults;
3711
- /**
3712
- * Generate unique agent ID
3713
- */
3714
- private generateAgentId;
3715
- /**
3716
- * Update creation statistics
3717
- */
3718
- private updateCreationStats;
3719
3626
  }
3720
3627
 
3721
3628
  declare class EventHistoryModule implements IEventHistoryModule {
@@ -4194,11 +4101,13 @@ interface IExecutionProxyConfig {
4194
4101
  task?: boolean;
4195
4102
  };
4196
4103
  }
4104
+ /** Internal target shape for proxy interception */
4105
+ type TExecutionProxyTarget = Record<string, TUniversalValue>;
4106
+ /** Internal args shape for proxy interception */
4107
+ type TExecutionProxyArgs = TUniversalValue[];
4197
4108
  /**
4198
4109
  * Metadata extractor function type
4199
4110
  */
4200
- type TExecutionProxyTarget = Record<string, TUniversalValue>;
4201
- type TExecutionProxyArgs = TUniversalValue[];
4202
4111
  type TMetadataExtractor = (target: TExecutionProxyTarget, methodName: string, args: TExecutionProxyArgs) => Record<string, TUniversalValue>;
4203
4112
  /**
4204
4113
  * Method configuration for proxy
@@ -4210,6 +4119,7 @@ interface IMethodConfig {
4210
4119
  extractMetadata?: TMetadataExtractor;
4211
4120
  extractResult?: (result: TUniversalValue) => Record<string, TUniversalValue>;
4212
4121
  }
4122
+
4213
4123
  /**
4214
4124
  * ExecutionProxy - Automatic event emission using Proxy pattern
4215
4125
  *
@@ -4406,7 +4316,7 @@ declare function formatTokenCount(tokens: number): string;
4406
4316
  * Hook system types — Claude Code compatible event/hook model.
4407
4317
  */
4408
4318
  /** Hook lifecycle events */
4409
- type THookEvent = 'PreToolUse' | 'PostToolUse' | 'SessionStart' | 'Stop' | 'PreCompact' | 'PostCompact' | 'UserPromptSubmit' | 'Notification';
4319
+ type THookEvent = 'PreToolUse' | 'PostToolUse' | 'SessionStart' | 'Stop' | 'PreCompact' | 'PostCompact' | 'UserPromptSubmit';
4410
4320
  /** Command hook — executes a shell command */
4411
4321
  interface ICommandHookDefinition {
4412
4322
  type: 'command';