@robota-sdk/agent-core 3.0.0-beta.76 → 3.0.0-beta.78

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.
@@ -1,4941 +1,2 @@
1
- //#region src/interfaces/messages.d.ts
2
- /**
3
- * Message Contracts (Single Source of Truth)
4
- *
5
- * IMPORTANT:
6
- * - This module is owned by the `interfaces` layer.
7
- * - All message types used across the SDK must be defined here to avoid drift.
8
- * - Runtime values (variables/classes/objects) and compile-time types can share the same name in TypeScript.
9
- * Prefixing type aliases (`T*`) and interfaces (`I*`) reduces value/type name collision risk and review overhead.
10
- */
11
- /**
12
- * Universal message role type - provider-independent neutral role.
13
- */
14
- type TUniversalMessageRole = 'user' | 'assistant' | 'system' | 'tool';
15
- /**
16
- * Message metadata used across conversation history and provider adapters.
17
- */
18
- type TUniversalMessageMetadata = Record<string, string | number | boolean | Date | string[] | number[] | Record<string, number>>;
19
- /**
20
- * Universal multimodal message part contracts.
21
- */
22
- interface ITextMessagePart {
23
- type: 'text';
24
- text: string;
25
- }
26
- interface IInlineImageMessagePart {
27
- type: 'image_inline';
28
- mimeType: string;
29
- data: string;
30
- }
31
- interface IUriImageMessagePart {
32
- type: 'image_uri';
33
- uri: string;
34
- mimeType?: string;
35
- }
36
- type TUniversalMessagePart = ITextMessagePart | IInlineImageMessagePart | IUriImageMessagePart;
37
- /**
38
- * Tool call (OpenAI tool calling format).
39
- */
40
- interface IToolCall {
41
- id: string;
42
- type: 'function';
43
- function: {
44
- name: string;
45
- arguments: string;
46
- };
47
- }
48
- /** State of a message in conversation history */
49
- type TMessageState = 'complete' | 'interrupted';
50
- /**
51
- * Base message contract shared by all message variants.
52
- */
53
- interface IBaseMessage {
54
- /** Unique message identifier */
55
- id: string;
56
- /** Message creation timestamp */
57
- timestamp: Date;
58
- /** Whether this message is complete or was interrupted */
59
- state: TMessageState;
60
- /** Additional metadata */
61
- metadata?: TUniversalMessageMetadata;
62
- }
63
- interface IUserMessage extends IBaseMessage {
64
- role: 'user';
65
- content: string;
66
- parts?: TUniversalMessagePart[];
67
- name?: string;
68
- }
69
- interface IAssistantMessage extends IBaseMessage {
70
- role: 'assistant';
71
- /** Assistant response content (can be null when making tool calls) */
72
- content: string | null;
73
- parts?: TUniversalMessagePart[];
74
- toolCalls?: IToolCall[];
75
- }
76
- interface ISystemMessage extends IBaseMessage {
77
- role: 'system';
78
- content: string;
79
- parts?: TUniversalMessagePart[];
80
- name?: string;
81
- }
82
- interface IToolMessage extends IBaseMessage {
83
- role: 'tool';
84
- content: string;
85
- parts?: TUniversalMessagePart[];
86
- toolCallId: string;
87
- name?: string;
88
- }
89
- /**
90
- * Universal message union used across the SDK as the canonical contract.
91
- * Used for AI provider communication. Extracted from IHistoryEntry[] via filtering.
92
- */
93
- type TUniversalMessage = IUserMessage | IAssistantMessage | ISystemMessage | IToolMessage;
94
- /**
95
- * Universal history entry — the base type for all records in conversation history.
96
- *
97
- * History is a universal timeline that records everything: AI chat messages,
98
- * system events, skill invocations, permission decisions, etc.
99
- * AI provider receives only chat entries (filtered and converted to TUniversalMessage).
100
- * TUI can render any range of entries.
101
- *
102
- * - append-only, read-only
103
- * - category + type for classification (free-form strings, no pre-defined enum)
104
- * - data holds type-specific structured content
105
- */
106
- interface IHistoryEntry<T = unknown> {
107
- /** Unique entry identifier */
108
- id: string;
109
- /** Entry creation timestamp */
110
- timestamp: Date;
111
- /** Top-level classification: 'chat', 'event', etc. */
112
- category: string;
113
- /** Sub-classification within category. Free-form, not pre-defined. */
114
- type: string;
115
- /** Type-specific structured data */
116
- data?: T;
117
- }
118
- /** Check if a history entry is a chat message (for AI provider filtering). */
119
- declare function isChatEntry(entry: IHistoryEntry): boolean;
120
- /**
121
- * Convert a chat history entry to TUniversalMessage for AI provider consumption.
122
- * Only call on entries where isChatEntry() returns true.
123
- */
124
- declare function chatEntryToMessage(entry: IHistoryEntry): TUniversalMessage;
125
- /**
126
- * Convert a TUniversalMessage to an IHistoryEntry for storage.
127
- */
128
- declare function messageToHistoryEntry(message: TUniversalMessage): IHistoryEntry;
129
- /**
130
- * Filter history entries and convert chat entries to TUniversalMessage[].
131
- * Used when passing conversation to AI provider.
132
- */
133
- declare function getMessagesForAPI(history: IHistoryEntry[]): TUniversalMessage[];
134
- /**
135
- * Type guards for the canonical TUniversalMessage union.
136
- *
137
- * NOTE:
138
- * - These guards are owned by the `interfaces` layer and must not depend on managers/services.
139
- * - Call sites should use these guards instead of importing from manager layers.
140
- */
141
- declare function isUserMessage(message: TUniversalMessage): message is IUserMessage;
142
- declare function isAssistantMessage(message: TUniversalMessage): message is IAssistantMessage;
143
- declare function isSystemMessage(message: TUniversalMessage): message is ISystemMessage;
144
- declare function isToolMessage(message: TUniversalMessage): message is IToolMessage;
145
- //#endregion
146
- //#region src/interfaces/types.d.ts
147
- /**
148
- * Primitive value types - foundation for all other types
149
- * Extended to include null/undefined for agent contexts
150
- */
151
- type TPrimitiveValue = string | number | boolean | null | undefined;
152
- /**
153
- * Universal value type axis (recursive, JSON-like + Date).
154
- *
155
- * IMPORTANT:
156
- * - This axis is the single source of truth for payload/context/result values.
157
- * - It must support nested objects/arrays without `any`/`unknown`.
158
- */
159
- type TUniversalValue = TPrimitiveValue | Date | TUniversalArrayValue | IUniversalObjectValue;
160
- type TUniversalArrayValue = TUniversalValue[];
161
- interface IUniversalObjectValue {
162
- [key: string]: TUniversalValue;
163
- }
164
- /**
165
- * Metadata type - consistent across agent components
166
- */
167
- type TMetadataValue = TPrimitiveValue | TUniversalArrayValue | Date;
168
- type TMetadata = Record<string, TMetadataValue>;
169
- /**
170
- * Context data type - for execution contexts
171
- */
172
- type TContextData = Record<string, TUniversalValue>;
173
- /**
174
- * Logger data type - for logging contexts
175
- */
176
- type TLoggerData = Record<string, TUniversalValue | Date | Error>;
177
- /**
178
- * Configuration types - for agent configuration
179
- */
180
- type TComplexConfigValue = Record<string, TPrimitiveValue | TUniversalArrayValue | IUniversalObjectValue>;
181
- type TConfigValue = TPrimitiveValue | TUniversalArrayValue | IUniversalObjectValue | Array<TComplexConfigValue> | Array<Record<string, TPrimitiveValue | TUniversalArrayValue | IUniversalObjectValue>> | Array<TComplexConfigValue> | TComplexConfigValue;
182
- type TConfigData = Record<string, TConfigValue>;
183
- /**
184
- * Tool parameter value type - specific for tool parameters
185
- */
186
- type TToolParameters = Record<string, TUniversalValue>;
187
- /**
188
- * Tool result data type - for tool execution results
189
- */
190
- /**
191
- * Plugin context type - for plugin execution contexts
192
- */
193
- interface IPluginContext {
194
- input?: string;
195
- response?: string;
196
- messages?: TUniversalMessage[];
197
- responseMessage?: TUniversalMessage;
198
- metadata?: TMetadata;
199
- error?: Error;
200
- executionContext?: TContextData;
201
- }
202
- /**
203
- * Type utility functions for safe type checking and validation
204
- * @internal
205
- */
206
- declare const TypeUtils: {
207
- isPrimitive: (value: TUniversalValue) => value is TPrimitiveValue;
208
- isArray: (value: TUniversalValue) => value is TUniversalArrayValue;
209
- isObject: (value: TUniversalValue) => value is IUniversalObjectValue;
210
- isUniversalValue: (value: TUniversalValue) => value is TUniversalValue;
211
- };
212
- //#endregion
213
- //#region src/interfaces/cache.d.ts
214
- /**
215
- * Cache key identifying a unique LLM execution request
216
- */
217
- interface ICacheKey {
218
- /** SHA-256 hash of the serialized request */
219
- hash: string;
220
- /** Model identifier */
221
- model: string;
222
- /** Provider name */
223
- provider: string;
224
- }
225
- /**
226
- * Cached LLM response entry
227
- */
228
- interface ICacheEntry {
229
- /** Cache key that produced this entry */
230
- key: ICacheKey;
231
- /** Cached response content */
232
- response: string;
233
- /** When the entry was cached */
234
- timestamp: number;
235
- /** SHA-256 integrity hash of the response */
236
- integrityHash: string;
237
- }
238
- /**
239
- * Cache storage interface for pluggable backends
240
- */
241
- interface ICacheStorage {
242
- /** Retrieve a cached entry by key hash */
243
- get(hash: string): ICacheEntry | undefined;
244
- /** Store a cache entry */
245
- set(entry: ICacheEntry): void;
246
- /** Delete a cached entry by key hash */
247
- delete(hash: string): boolean;
248
- /** Clear all cached entries */
249
- clear(): void;
250
- /** Get cache statistics */
251
- getStats(): ICacheStats;
252
- }
253
- /**
254
- * Cache performance statistics
255
- */
256
- interface ICacheStats {
257
- /** Number of cache hits */
258
- hits: number;
259
- /** Number of cache misses */
260
- misses: number;
261
- /** Current number of cached entries */
262
- entries: number;
263
- /** Hit rate (hits / (hits + misses)), 0 if no lookups */
264
- hitRate: number;
265
- }
266
- /**
267
- * Configuration options for execution caching
268
- */
269
- interface ICacheOptions {
270
- /** Whether caching is enabled */
271
- enabled: boolean;
272
- /** Maximum number of cached entries */
273
- maxEntries: number;
274
- /** Time-to-live in milliseconds */
275
- ttlMs: number;
276
- }
277
- //#endregion
278
- //#region src/interfaces/provider-capabilities.d.ts
279
- interface IProviderFunctionCallingCapability {
280
- supported: boolean;
281
- reason?: string;
282
- }
283
- interface IProviderNativeWebToolCapability {
284
- supported: boolean;
285
- enabled: boolean;
286
- source?: string;
287
- reason?: string;
288
- }
289
- interface IProviderNativeWebToolCapabilities {
290
- webSearch: IProviderNativeWebToolCapability;
291
- webFetch: IProviderNativeWebToolCapability;
292
- }
293
- interface IProviderCapabilities {
294
- functionCalling: IProviderFunctionCallingCapability;
295
- nativeWebTools: IProviderNativeWebToolCapabilities;
296
- }
297
- interface IProviderNativeWebToolRequest {
298
- webSearch?: boolean;
299
- webFetch?: boolean;
300
- }
301
- declare function createDefaultProviderCapabilities(functionCallingSupported: boolean): IProviderCapabilities;
302
- declare function getProviderCapabilities(provider: IAIProvider): IProviderCapabilities;
303
- declare function assertProviderNativeWebToolsAvailable(providerName: string, capabilities: IProviderCapabilities, request: IProviderNativeWebToolRequest | undefined): void;
304
- //#endregion
305
- //#region src/interfaces/provider.d.ts
306
- /**
307
- * Reusable type definitions for provider layer
308
- */
309
- /**
310
- * Provider configuration value type
311
- * Used for storing provider-specific configuration values
312
- */
313
- type TProviderConfigValue = string | number | boolean;
314
- /**
315
- * JSON Schema parameter default value type
316
- * Used for default values in parameter schemas
317
- */
318
- type TParameterDefaultValue = string | number | boolean | null;
319
- /**
320
- * JSON Schema primitive types
321
- */
322
- type TJSONSchemaKind = 'string' | 'number' | 'integer' | 'boolean' | 'array' | 'object' | 'null';
323
- /**
324
- * JSON Schema enum values
325
- */
326
- type TJSONSchemaEnum = string[] | number[] | boolean[] | (string | number | boolean)[];
327
- /**
328
- * Tool schema definition
329
- */
330
- interface IToolSchema {
331
- name: string;
332
- description: string;
333
- parameters: {
334
- type: 'object';
335
- properties: Record<string, IParameterSchema>;
336
- required?: string[];
337
- additionalProperties?: boolean | IParameterSchema;
338
- };
339
- }
340
- /**
341
- * Parameter schema for tools
342
- */
343
- interface IParameterSchema {
344
- type: TJSONSchemaKind;
345
- description?: string;
346
- enum?: TJSONSchemaEnum;
347
- items?: IParameterSchema;
348
- properties?: Record<string, IParameterSchema>;
349
- additionalProperties?: IParameterSchema;
350
- minimum?: number;
351
- maximum?: number;
352
- pattern?: string;
353
- format?: string;
354
- default?: TParameterDefaultValue;
355
- }
356
- /**
357
- * Token usage statistics
358
- */
359
- interface ITokenUsage {
360
- promptTokens: number;
361
- completionTokens: number;
362
- totalTokens: number;
363
- }
364
- /**
365
- * Raw provider response interface
366
- */
367
- interface IRawProviderResponse {
368
- content: string | null;
369
- toolCalls?: IToolCall[];
370
- usage?: ITokenUsage;
371
- finishReason?: string;
372
- model?: string;
373
- metadata?: Record<string, TProviderConfigValue>;
374
- }
375
- /**
376
- * Provider request payload
377
- */
378
- interface IProviderRequest {
379
- messages: TUniversalMessage[];
380
- model?: string;
381
- temperature?: number;
382
- maxTokens?: number;
383
- tools?: IToolSchema[];
384
- systemMessage?: string;
385
- metadata?: Record<string, string | number | boolean>;
386
- }
387
- /**
388
- * Provider-specific configuration options
389
- */
390
- interface IProviderSpecificOptions {
391
- /** OpenAI specific options */
392
- openai?: {
393
- organization?: string;
394
- user?: string;
395
- stop?: string | string[];
396
- presencePenalty?: number;
397
- frequencyPenalty?: number;
398
- logitBias?: Record<string, number>;
399
- topP?: number;
400
- n?: number;
401
- stream?: boolean;
402
- suffix?: string;
403
- echo?: boolean;
404
- bestOf?: number;
405
- logprobs?: number;
406
- };
407
- /** Anthropic specific options */
408
- anthropic?: {
409
- stopSequences?: string[];
410
- topP?: number;
411
- topK?: number;
412
- metadata?: {
413
- userId?: string;
414
- };
415
- };
416
- /** Google specific options */
417
- google?: {
418
- candidateCount?: number;
419
- stopSequences?: string[];
420
- safetySettings?: Array<{
421
- category: string;
422
- threshold: string;
423
- }>;
424
- responseModalities?: Array<'TEXT' | 'IMAGE'>;
425
- topP?: number;
426
- topK?: number;
427
- };
428
- }
429
- /**
430
- * Callback for receiving text deltas during streaming.
431
- * Called for each text chunk as the model generates output.
432
- */
433
- type TTextDeltaCallback = (delta: string) => void;
434
- type TProviderNativeRawPayloadKind = 'request' | 'response' | 'stream_event';
435
- type TProviderNativeRawPayload = string | number | boolean | object | null | undefined;
436
- interface IProviderNativeRawPayloadEvent {
437
- provider: string;
438
- apiSurface?: string;
439
- payloadKind: TProviderNativeRawPayloadKind;
440
- payload: TProviderNativeRawPayload;
441
- sequence?: number;
442
- metadata?: Record<string, TProviderConfigValue>;
443
- }
444
- type TProviderNativeRawPayloadCallback = (event: IProviderNativeRawPayloadEvent) => void;
445
- /**
446
- * Reasoning-effort dial threaded per model invocation.
447
- *
448
- * Canonical SSOT for the effort union. `'high'` is the neutral default applied when
449
- * a caller leaves effort unset; `'xhigh'` is the long-running ("ultra") tier and
450
- * `'max'` the most exhaustive tier. Providers with a native reasoning-effort parameter
451
- * map this value onto it (clamping to their supported range); providers without a
452
- * native effort concept ignore it as a documented no-op.
453
- */
454
- type TModelEffort = 'low' | 'medium' | 'high' | 'xhigh' | 'max';
455
- /**
456
- * Options for AI provider chat requests
457
- */
458
- interface IChatOptions extends IProviderSpecificOptions {
459
- /** Tool schemas to provide to the AI provider */
460
- tools?: IToolSchema[];
461
- /** Maximum number of tokens to generate */
462
- maxTokens?: number;
463
- /** Temperature for response randomness (0-1) */
464
- temperature?: number;
465
- /**
466
- * Reasoning-effort dial for this invocation. Native-effort providers map it to their
467
- * request parameter; providers without native effort ignore it (documented no-op).
468
- * Threaded from session/model options; defaults to `'high'` at the framework→provider seam.
469
- */
470
- effort?: TModelEffort;
471
- /** Model to use for the request */
472
- model?: string;
473
- /** Callback for text deltas during streaming. When provided, the provider
474
- * should use streaming internally and call this for each text chunk,
475
- * while still returning the complete assembled message. */
476
- onTextDelta?: TTextDeltaCallback;
477
- /** Callback for provider-owned native SDK request/response/stream payload capture. */
478
- onProviderNativeRawPayload?: TProviderNativeRawPayloadCallback;
479
- /** AbortSignal for cancelling the provider call */
480
- signal?: AbortSignal;
481
- /** Provider-native hosted web tools requested for this call */
482
- nativeWebTools?: IProviderNativeWebToolRequest;
483
- /** Request structured output from the provider. */
484
- responseFormat?: {
485
- type: 'text' | 'json_object';
486
- };
487
- }
488
- /**
489
- * Provider-agnostic AI Provider interface
490
- * This interface uses only TUniversalMessage types and avoids provider-specific types
491
- */
492
- interface IAIProvider {
493
- /** Provider identifier */
494
- readonly name: string;
495
- /** Provider version */
496
- readonly version: string;
497
- /**
498
- * Generate response from AI model using TUniversalMessage
499
- * @param messages - Array of TUniversalMessage from conversation history
500
- * @param options - Chat options including tools, model settings, etc.
501
- * @returns Promise resolving to a TUniversalMessage response
502
- */
503
- chat(messages: TUniversalMessage[], options?: IChatOptions): Promise<TUniversalMessage>;
504
- /**
505
- * Generate streaming response from AI model using TUniversalMessage
506
- * @param messages - Array of TUniversalMessage from conversation history
507
- * @param options - Chat options including tools, model settings, etc.
508
- * @returns AsyncIterable of TUniversalMessage chunks
509
- */
510
- chatStream?(messages: TUniversalMessage[], options?: IChatOptions): AsyncIterable<TUniversalMessage>;
511
- /**
512
- * Generate response from AI model (raw provider response)
513
- * @param payload - Provider request payload
514
- * @returns Promise resolving to raw provider response
515
- */
516
- generateResponse(payload: IProviderRequest): Promise<IRawProviderResponse>;
517
- /**
518
- * Generate streaming response from AI model (raw provider response)
519
- * @param payload - Provider request payload
520
- * @returns AsyncIterable of raw provider response chunks
521
- */
522
- generateStreamingResponse?(payload: IProviderRequest): AsyncIterable<IRawProviderResponse>;
523
- /**
524
- * Check if the provider supports tool calling
525
- * @returns true if tool calling is supported
526
- */
527
- supportsTools(): boolean;
528
- /**
529
- * Report provider-neutral capability state.
530
- * Providers without native web support can omit this and use default capability helpers.
531
- */
532
- getCapabilities?(): IProviderCapabilities;
533
- /**
534
- * Optional generic hook for enabling provider-native hosted web behavior.
535
- */
536
- configureNativeWebTools?(request: IProviderNativeWebToolRequest): IProviderCapabilities;
537
- /**
538
- * Validate provider configuration
539
- * @returns true if configuration is valid
540
- */
541
- validateConfig(): boolean;
542
- /**
543
- * Clean up resources when provider is no longer needed
544
- */
545
- dispose?(): Promise<void>;
546
- /**
547
- * Close provider connections and cleanup resources
548
- */
549
- close?(): Promise<void>;
550
- }
551
- /**
552
- * Provider options interface
553
- */
554
- interface IProviderOptions {
555
- apiKey?: string;
556
- baseURL?: string;
557
- timeout?: number;
558
- retries?: number;
559
- maxConcurrentRequests?: number;
560
- defaultModel?: string;
561
- organization?: string;
562
- project?: string;
563
- /** Additional provider-specific configuration */
564
- extra?: Record<string, TProviderConfigValue>;
565
- }
566
- /**
567
- * Base union for provider option values.
568
- *
569
- * Purpose:
570
- * - Enable provider packages to compose their own option value unions without redefining the primitives.
571
- * - Keep the shared axis in @robota-sdk/agent-core (SSOT).
572
- *
573
- * Note:
574
- * - Provider packages may extend this with provider-specific runtime objects (e.g., OpenAI/Anthropic clients).
575
- */
576
- type TProviderOptionValueBase = string | number | boolean | undefined | null | TProviderOptionValueBase[] | {
577
- [key: string]: TProviderOptionValueBase;
578
- };
579
- //#endregion
580
- //#region src/plugins/event-emitter/types.d.ts
581
- declare const EXECUTION_EVENT_NAMES: {
582
- readonly START: "execution.start";
583
- readonly COMPLETE: "execution.complete";
584
- readonly ERROR: "execution.error";
585
- };
586
- declare const TOOL_EVENT_NAMES: {
587
- readonly CALL_START: "tool.call_start";
588
- readonly CALL_COMPLETE: "tool.call_complete";
589
- readonly CALL_ERROR: "tool.call_error";
590
- };
591
- declare const AGENT_EVENT_NAMES: {
592
- readonly EXECUTION_START: "agent.execution_start";
593
- readonly EXECUTION_COMPLETE: "agent.execution_complete";
594
- readonly EXECUTION_ERROR: "agent.execution_error";
595
- readonly CREATED: "agent.created";
596
- };
597
- type TExecutionEventName = (typeof EXECUTION_EVENT_NAMES)[keyof typeof EXECUTION_EVENT_NAMES];
598
- type TToolEventName = (typeof TOOL_EVENT_NAMES)[keyof typeof TOOL_EVENT_NAMES];
599
- type TAgentEventName = (typeof AGENT_EVENT_NAMES)[keyof typeof AGENT_EVENT_NAMES];
600
- /**
601
- * Event types that can be emitted.
602
- *
603
- * IMPORTANT:
604
- * - Do not use string literals for event names outside this module.
605
- * - Import and use EVENT_EMITTER_EVENTS instead.
606
- */
607
- declare const EVENT_EMITTER_EVENTS: {
608
- readonly EXECUTION_START: "execution.start";
609
- readonly EXECUTION_COMPLETE: "execution.complete";
610
- readonly EXECUTION_ERROR: "execution.error";
611
- readonly TOOL_BEFORE_EXECUTE: "tool.beforeExecute";
612
- readonly TOOL_AFTER_EXECUTE: "tool.afterExecute";
613
- readonly TOOL_SUCCESS: "tool.success";
614
- readonly TOOL_ERROR: "tool.call_error";
615
- readonly CONVERSATION_START: "conversation.start";
616
- readonly CONVERSATION_COMPLETE: "conversation.complete";
617
- readonly CONVERSATION_ERROR: "conversation.error";
618
- readonly AGENT_EXECUTION_START: "agent.execution_start";
619
- readonly AGENT_EXECUTION_COMPLETE: "agent.execution_complete";
620
- readonly AGENT_EXECUTION_ERROR: "agent.execution_error";
621
- readonly AGENT_CREATED: "agent.created";
622
- readonly AGENT_DESTROYED: "agent.destroyed";
623
- readonly PLUGIN_LOADED: "plugin.loaded";
624
- readonly PLUGIN_UNLOADED: "plugin.unloaded";
625
- readonly PLUGIN_ERROR: "plugin.error";
626
- readonly ERROR_OCCURRED: "error.occurred";
627
- readonly WARNING_OCCURRED: "warning.occurred";
628
- readonly MODULE_INITIALIZE_START: "module.initialize.start";
629
- readonly MODULE_INITIALIZE_COMPLETE: "module.initialize.complete";
630
- readonly MODULE_INITIALIZE_ERROR: "module.initialize.error";
631
- readonly MODULE_EXECUTION_START: "module.execution.start";
632
- readonly MODULE_EXECUTION_COMPLETE: "module.execution.complete";
633
- readonly MODULE_EXECUTION_ERROR: "module.execution.error";
634
- readonly MODULE_DISPOSE_START: "module.dispose.start";
635
- readonly MODULE_DISPOSE_COMPLETE: "module.dispose.complete";
636
- readonly MODULE_DISPOSE_ERROR: "module.dispose.error";
637
- readonly MODULE_REGISTERED: "module.registered";
638
- readonly MODULE_UNREGISTERED: "module.unregistered";
639
- readonly EXECUTION_HIERARCHY: "execution.hierarchy";
640
- readonly EXECUTION_REALTIME: "execution.realtime";
641
- readonly TOOL_REALTIME: "tool.realtime";
642
- readonly CUSTOM: "custom";
643
- };
644
- type TEventName = TExecutionEventName | TToolEventName | TAgentEventName | 'tool.beforeExecute' | 'tool.afterExecute' | 'tool.success' | 'conversation.start' | 'conversation.complete' | 'conversation.error' | 'agent.destroyed' | 'plugin.loaded' | 'plugin.unloaded' | 'plugin.error' | 'error.occurred' | 'warning.occurred' | 'module.initialize.start' | 'module.initialize.complete' | 'module.initialize.error' | 'module.execution.start' | 'module.execution.complete' | 'module.execution.error' | 'module.dispose.start' | 'module.dispose.complete' | 'module.dispose.error' | 'module.registered' | 'module.unregistered' | 'execution.hierarchy' | 'execution.realtime' | 'tool.realtime' | 'custom';
645
- /**
646
- * Valid event data value types
647
- */
648
- type TEventDataValue = string | number | boolean | Date | null | undefined | TEventDataValue[] | {
649
- [key: string]: TEventDataValue;
650
- };
651
- /**
652
- * Event data structure
653
- */
654
- interface IEventEmitterEventData {
655
- type: TEventName;
656
- timestamp: Date;
657
- executionId?: string;
658
- sessionId?: string;
659
- userId?: string;
660
- data?: Record<string, TEventDataValue>;
661
- error?: Error;
662
- metadata?: Record<string, TEventDataValue>;
663
- }
664
- /**
665
- * Event listener function
666
- */
667
- type TEventEmitterListener = (event: IEventEmitterEventData) => void | Promise<void>;
668
- /**
669
- * Console-like interface for the EventEmitterPlugin.
670
- *
671
- * Use this interface for typing instead of the concrete EventEmitterPlugin class.
672
- */
673
- interface IEventEmitterPlugin {
674
- on(eventType: TEventName, listener: TEventEmitterListener, options?: {
675
- once?: boolean;
676
- filter?: (event: IEventEmitterEventData) => boolean;
677
- }): string;
678
- once(eventType: TEventName, listener: TEventEmitterListener, filter?: (event: IEventEmitterEventData) => boolean): string;
679
- off(eventType: TEventName, handlerIdOrListener: string | TEventEmitterListener): boolean;
680
- emit(eventType: TEventName, eventData?: Partial<IEventEmitterEventData>): Promise<void>;
681
- }
682
- //#endregion
683
- //#region src/abstracts/abstract-module-types.d.ts
684
- /** Module execution context */
685
- interface IModuleExecutionContext {
686
- executionId?: string;
687
- sessionId?: string;
688
- userId?: string;
689
- agentName?: string;
690
- metadata?: Record<string, string | number | boolean | Date>;
691
- [key: string]: string | number | boolean | Date | Record<string, string | number | boolean | Date> | undefined;
692
- }
693
- /** Module execution result */
694
- interface IModuleExecutionResult {
695
- success: boolean;
696
- data?: IModuleResultData;
697
- error?: Error;
698
- duration?: number;
699
- metadata?: Record<string, string | number | boolean | Date>;
700
- }
701
- /** Module result data */
702
- interface IModuleResultData {
703
- [key: string]: string | number | boolean | Record<string, string | number | boolean> | undefined;
704
- }
705
- /** Base module options */
706
- interface IBaseModuleOptions {
707
- enabled?: boolean;
708
- config?: Record<string, string | number | boolean>;
709
- }
710
- /** Module capabilities */
711
- interface IModuleCapabilities {
712
- capabilities: string[];
713
- dependencies?: string[];
714
- optionalDependencies?: string[];
715
- }
716
- /** Module type descriptor */
717
- interface IModuleDescriptor {
718
- type: string;
719
- category: ModuleCategory;
720
- layer: ModuleLayer;
721
- dependencies?: string[];
722
- capabilities?: string[];
723
- }
724
- /** Module categories */
725
- declare enum ModuleCategory {
726
- CORE = "core",
727
- STORAGE = "storage",
728
- PROCESSING = "processing",
729
- INTEGRATION = "integration",
730
- INTERFACE = "interface",
731
- CAPABILITY = "capability"
732
- }
733
- /** Module layers */
734
- declare enum ModuleLayer {
735
- INFRASTRUCTURE = "infrastructure",
736
- CORE = "core",
737
- APPLICATION = "application",
738
- DOMAIN = "domain",
739
- PRESENTATION = "presentation"
740
- }
741
- /** Module data for introspection */
742
- interface IModuleData {
743
- name: string;
744
- version: string;
745
- type: string;
746
- enabled: boolean;
747
- initialized: boolean;
748
- capabilities: IModuleCapabilities;
749
- metadata?: Record<string, string | number | boolean>;
750
- }
751
- /** Module statistics */
752
- interface IModuleStats {
753
- enabled: boolean;
754
- initialized: boolean;
755
- executionCount: number;
756
- errorCount: number;
757
- lastActivity?: Date;
758
- averageExecutionTime?: number;
759
- [key: string]: string | number | boolean | Date | undefined;
760
- }
761
- /** Type-safe module interface */
762
- interface IModule<TOptions extends IBaseModuleOptions = IBaseModuleOptions, TStats = IModuleStats> {
763
- name: string;
764
- version: string;
765
- enabled: boolean;
766
- initialize(options?: TOptions, eventEmitter?: IEventEmitterPlugin): Promise<void>;
767
- dispose?(): Promise<void>;
768
- execute?(context: IModuleExecutionContext): Promise<IModuleExecutionResult>;
769
- getModuleType(): IModuleDescriptor;
770
- getCapabilities(): IModuleCapabilities;
771
- getData?(): IModuleData;
772
- getStats?(): TStats;
773
- isEnabled(): boolean;
774
- isInitialized(): boolean;
775
- }
776
- //#endregion
777
- //#region src/utils/logger.d.ts
778
- /**
779
- * Reusable type definitions for logger utility
780
- */
781
- /**
782
- * Log levels for the logger
783
- */
784
- type TUtilLogLevel = 'debug' | 'info' | 'warn' | 'error' | 'silent';
785
- /**
786
- * Log entry structure
787
- */
788
- interface IUtilLogEntry {
789
- timestamp: string;
790
- level: TUtilLogLevel;
791
- message: string;
792
- context?: TLoggerData;
793
- packageName?: string;
794
- }
795
- /**
796
- * Logger interface
797
- */
798
- interface ILogger {
799
- debug(...args: Array<TUniversalValue | TLoggerData | Error>): void;
800
- info(...args: Array<TUniversalValue | TLoggerData | Error>): void;
801
- warn(...args: Array<TUniversalValue | TLoggerData | Error>): void;
802
- error(...args: Array<TUniversalValue | TLoggerData | Error>): void;
803
- log(...args: Array<TUniversalValue | TLoggerData | Error>): void;
804
- group?(label?: string): void;
805
- groupEnd?(): void;
806
- }
807
- /**
808
- * Silent logger that does nothing (Null Object Pattern)
809
- *
810
- * IMPORTANT:
811
- * - This library must not write to stdio by default.
812
- * - Inject a real logger explicitly if you want output.
813
- */
814
- declare const SilentLogger: ILogger;
815
- /**
816
- * Console logger implementation
817
- * @internal
818
- */
819
- declare class ConsoleLogger implements ILogger {
820
- private level?;
821
- private packageName;
822
- private sinkLogger;
823
- constructor(packageName: string, logger?: ILogger);
824
- debug(...args: Array<TUniversalValue | TLoggerData | Error>): void;
825
- info(...args: Array<TUniversalValue | TLoggerData | Error>): void;
826
- warn(...args: Array<TUniversalValue | TLoggerData | Error>): void;
827
- error(...args: Array<TUniversalValue | TLoggerData | Error>): void;
828
- log(...args: Array<TUniversalValue | TLoggerData | Error>): void;
829
- private getLevel;
830
- private shouldLog;
831
- private forward;
832
- }
833
- /**
834
- * Create a named logger instance for a package or module.
835
- * Use this to create loggers with a specific name prefix for easy log filtering.
836
- */
837
- declare function createLogger(packageName: string, logger?: ILogger): ILogger;
838
- /**
839
- * Set global log level for all loggers
840
- */
841
- declare function setGlobalLogLevel(level: TUtilLogLevel): void;
842
- /**
843
- * Get global log level
844
- */
845
- declare function getGlobalLogLevel(): TUtilLogLevel;
846
- /**
847
- * Default logger for the agents package
848
- */
849
- declare const logger: ILogger;
850
- //#endregion
851
- //#region src/event-service/interfaces.d.ts
852
- /**
853
- * @fileoverview Event service interface definitions.
854
- *
855
- * These interfaces are the single source of truth for event-related contracts
856
- * within @robota-sdk/agent-core.
857
- */
858
- /**
859
- * Primitive value types for event payloads.
860
- */
861
- type TEventPrimitiveValue = string | number | boolean | null | undefined;
862
- /**
863
- * Recursive universal value type for event payloads (JSON-like + Date).
864
- */
865
- type TEventUniversalValue = TEventPrimitiveValue | Date | TEventUniversalValue[] | IEventObjectValue;
866
- interface IEventObjectValue {
867
- [key: string]: TEventUniversalValue;
868
- }
869
- /**
870
- * Logger data type for event metadata.
871
- */
872
- type TEventLoggerData = Record<string, TEventUniversalValue | Date | Error>;
873
- /**
874
- * A single segment in an explicit ownerPath.
875
- *
876
- * Path-only rule:
877
- * - Relationships must be derived from these explicit segments, not from parsing IDs.
878
- */
879
- interface IOwnerPathSegment {
880
- type: string;
881
- id: string;
882
- }
883
- /**
884
- * Event context that accompanies an emitted event.
885
- * This is the single source of truth for deterministic linking in subscribers.
886
- */
887
- interface IEventContext {
888
- ownerType: string;
889
- ownerId: string;
890
- ownerPath: IOwnerPathSegment[];
891
- /** Depth of the current execution in the hierarchy (0 = root) */
892
- depth?: number;
893
- /** Unique span identifier for distributed tracing correlation */
894
- spanId?: string;
895
- /** Optional structured metadata for debugging/observability */
896
- metadata?: TEventLoggerData;
897
- }
898
- /**
899
- * Allowed extension values for event payloads.
900
- */
901
- type TEventExtensionValue = TEventUniversalValue | TEventLoggerData | Error | IEventContext | IOwnerPathSegment[];
902
- /**
903
- * Base event payload shape.
904
- * Emitters may add additional fields, but MUST keep linkage information explicit.
905
- */
906
- interface IBaseEventData {
907
- /** Timestamp when the event was emitted. This is required for deterministic ordering. */
908
- timestamp: Date;
909
- /** Optional structured metadata */
910
- metadata?: TEventLoggerData;
911
- /** Extensible fields for event-specific payloads */
912
- [key: string]: TEventExtensionValue | undefined;
913
- }
914
- /**
915
- * Execution-related event payload.
916
- */
917
- interface IExecutionEventData extends IBaseEventData {}
918
- /**
919
- * Tool-related event payload.
920
- */
921
- interface IToolEventData extends IBaseEventData {
922
- toolName?: string;
923
- parameters?: Record<string, TEventUniversalValue>;
924
- }
925
- /**
926
- * Agent-related event payload.
927
- */
928
- interface IAgentEventData extends IBaseEventData {
929
- agentId?: string;
930
- }
931
- type TEventListener = (eventType: string, data: IBaseEventData, context?: IEventContext) => void;
932
- /**
933
- * Minimal EventService contract for emitting events.
934
- */
935
- interface IEventService {
936
- emit(eventType: string, data: IBaseEventData, context?: IEventContext): void;
937
- subscribe(listener: TEventListener): void;
938
- unsubscribe(listener: TEventListener): void;
939
- }
940
- /**
941
- * Explicit owner binding information used for scoped event emission.
942
- */
943
- interface IEventServiceOwnerBinding {
944
- ownerType: string;
945
- ownerId: string;
946
- ownerPath: IOwnerPathSegment[];
947
- }
948
- //#endregion
949
- //#region src/event-service/event-service.d.ts
950
- /**
951
- * Abstract base for event services.
952
- * Concrete implementations decide how events are delivered.
953
- */
954
- declare abstract class AbstractEventService implements IEventService {
955
- private listeners;
956
- abstract emit(eventType: string, data: IBaseEventData, context?: IEventContext): void;
957
- subscribe(listener: TEventListener): void;
958
- unsubscribe(listener: TEventListener): void;
959
- protected notifyListeners(eventType: string, data: IBaseEventData, context?: IEventContext): void;
960
- }
961
- /**
962
- * Default no-op event service (production-safe).
963
- * When injected, emit() intentionally does nothing.
964
- */
965
- declare class DefaultEventService extends AbstractEventService {
966
- emit(_eventType: string, _data: IBaseEventData, _context?: IEventContext): void;
967
- }
968
- /**
969
- * Singleton default event service instance.
970
- */
971
- declare const DEFAULT_ABSTRACT_EVENT_SERVICE: IEventService;
972
- /**
973
- * Check if a given service is the default no-op implementation.
974
- */
975
- declare function isDefaultEventService(service: IEventService): boolean;
976
- /**
977
- * Compose a full event name from owner prefix and local name.
978
- * Local names must not contain dots.
979
- */
980
- declare function composeEventName(ownerType: string, localName: string): string;
981
- /**
982
- * A scoped event service that always emits with an owner binding applied.
983
- */
984
- declare class StructuredEventService extends AbstractEventService {
985
- private readonly base;
986
- private readonly binding;
987
- constructor(base: IEventService, binding: IEventServiceOwnerBinding);
988
- emit(eventType: string, data: IBaseEventData, context?: IEventContext): void;
989
- subscribe(listener: TEventListener): void;
990
- unsubscribe(listener: TEventListener): void;
991
- }
992
- /**
993
- * Bind an EventService to an explicit owner path.
994
- * This is the standard entry point for scoped emission (path-only architecture).
995
- */
996
- declare function bindWithOwnerPath(base: IEventService, binding: IEventServiceOwnerBinding): IEventService;
997
- /**
998
- * Alias for bindWithOwnerPath for historical call sites.
999
- * Intentionally forwards to the single authoritative implementation.
1000
- */
1001
- declare function bindEventServiceOwner(base: IEventService, binding: IEventServiceOwnerBinding): IEventService;
1002
- /**
1003
- * Observable EventService that notifies subscribed listeners.
1004
- */
1005
- declare class ObservableEventService extends AbstractEventService {
1006
- emit(eventType: string, data: IBaseEventData, context?: IEventContext): void;
1007
- }
1008
- //#endregion
1009
- //#region src/event-service/task-events.d.ts
1010
- declare const TASK_EVENTS: {
1011
- readonly ASSIGNED: "assigned";
1012
- readonly COMPLETED: "completed";
1013
- };
1014
- declare const TASK_EVENT_PREFIX: "task";
1015
- //#endregion
1016
- //#region src/event-service/user-events.d.ts
1017
- declare const USER_EVENTS: {
1018
- readonly MESSAGE: "message";
1019
- readonly INPUT: "input";
1020
- };
1021
- declare const USER_EVENT_PREFIX: "user";
1022
- type TUserEvent = (typeof USER_EVENTS)[keyof typeof USER_EVENTS];
1023
- //#endregion
1024
- //#region src/interfaces/tool.d.ts
1025
- type TToolContextExtensionValue = TUniversalValue | Date | Error | TLoggerData | TContextData | TToolParameters | TToolMetadata;
1026
- /**
1027
- * Tool metadata structure - specific type definition
1028
- */
1029
- type TToolMetadata = Record<string, string | number | boolean | string[] | number[] | boolean[] | TToolParameters>;
1030
- /**
1031
- * Tool execution data - domain payload for tool results.
1032
- *
1033
- * IMPORTANT:
1034
- * - This must support structured tool outputs without resorting to `any`.
1035
- * - Prefer `ToolResultData` (derived from the canonical `UniversalValue` axis).
1036
- */
1037
- /**
1038
- * Tool execution result - extended for ToolExecutionData compatibility
1039
- */
1040
- interface IToolResult {
1041
- success: boolean;
1042
- data?: TUniversalValue;
1043
- error?: string;
1044
- metadata?: TToolMetadata;
1045
- [key: string]: TToolContextExtensionValue | undefined;
1046
- }
1047
- /**
1048
- * Enhanced tool execution result with additional metadata
1049
- */
1050
- interface IToolExecutionResult {
1051
- /** Whether execution was successful */
1052
- success: boolean;
1053
- /** Tool name that was executed */
1054
- toolName?: string;
1055
- /** Execution result or data */
1056
- result?: TUniversalValue;
1057
- /** Error message if execution failed */
1058
- error?: string;
1059
- /** Execution duration in milliseconds */
1060
- duration?: number;
1061
- /** Unique execution ID */
1062
- executionId?: string;
1063
- /** Additional metadata */
1064
- metadata?: TToolMetadata;
1065
- }
1066
- /**
1067
- * Tool execution context - type-safe context for tool execution
1068
- * Enhanced with hierarchical execution tracking support
1069
- */
1070
- interface IToolExecutionContext {
1071
- toolName: string;
1072
- parameters: TToolParameters;
1073
- executionId?: string;
1074
- userId?: string;
1075
- sessionId?: string;
1076
- metadata?: TToolMetadata;
1077
- /** Parent execution ID for hierarchical tool execution tracking */
1078
- parentExecutionId?: string;
1079
- /** Root execution ID (Team/Agent level) for complete execution tree tracking */
1080
- rootExecutionId?: string;
1081
- /** Execution depth level (0: Team, 1: Agent, 2: Tool, etc.) */
1082
- executionLevel?: number;
1083
- /** Execution path array showing the complete execution hierarchy */
1084
- executionPath?: string[];
1085
- /** Real-time execution data for accurate tracking (no simulation) */
1086
- realTimeData?: {
1087
- /** Actual execution start time */startTime: Date; /** Actual input parameters passed to the tool */
1088
- actualParameters: TToolParameters; /** Tool-provided estimated duration (optional) */
1089
- estimatedDuration?: number;
1090
- };
1091
- /**
1092
- * Additional tool execution context extensions.
1093
- *
1094
- * IMPORTANT:
1095
- * - Avoid ad-hoc top-level fields to keep the contract stable.
1096
- * - Use this map for forward-compatible extra data with constrained value types.
1097
- */
1098
- extensions?: Record<string, TToolContextExtensionValue>;
1099
- /** Owner context propagated from EventService */
1100
- ownerType?: string;
1101
- ownerId?: string;
1102
- ownerPath?: IOwnerPathSegment[];
1103
- sourceId?: string;
1104
- /**
1105
- * Tool-call scoped EventService instance.
1106
- * Caller (ExecutionService/ToolExecutionService) is responsible for providing
1107
- * an ownerPath-bound EventService for this tool call.
1108
- */
1109
- eventService?: IEventService;
1110
- /**
1111
- * Unbound base EventService instance.
1112
- *
1113
- * Required when a tool needs to create another owner-bound EventService
1114
- * for a different owner (e.g., creating an agent from a tool call).
1115
- *
1116
- * NOTE: Do not wrap an already owner-bound EventService to bind a different owner.
1117
- * Owner-bound instances must not be layered across different owners.
1118
- */
1119
- baseEventService?: IEventService;
1120
- }
1121
- /**
1122
- * Parameter validation result
1123
- */
1124
- interface IParameterValidationResult {
1125
- /** Whether parameters are valid */
1126
- isValid: boolean;
1127
- /** Validation error messages */
1128
- errors: string[];
1129
- }
1130
- /**
1131
- * Generic tool executor function
1132
- */
1133
- type TToolExecutor<TParams = TToolParameters, TResult = TUniversalValue> = (parameters: TParams, context?: IToolExecutionContext) => Promise<TResult>;
1134
- /**
1135
- * Base tool interface
1136
- */
1137
- interface ITool {
1138
- /** Tool schema */
1139
- schema: IToolSchema;
1140
- /**
1141
- * Execute the tool with given parameters
1142
- */
1143
- execute(parameters: TToolParameters, context?: IToolExecutionContext): Promise<IToolResult>;
1144
- /**
1145
- * Validate tool parameters
1146
- */
1147
- validate(parameters: TToolParameters): boolean;
1148
- /**
1149
- * Validate tool parameters with detailed result
1150
- */
1151
- validateParameters(parameters: TToolParameters): IParameterValidationResult;
1152
- /**
1153
- * Get tool description
1154
- */
1155
- getDescription(): string;
1156
- }
1157
- /**
1158
- * Function tool implementation
1159
- */
1160
- interface IFunctionTool extends ITool {
1161
- /** Function to execute */
1162
- fn: TToolExecutor;
1163
- }
1164
- /**
1165
- * Tool registry interface
1166
- */
1167
- interface IToolRegistry {
1168
- /**
1169
- * Register a tool
1170
- */
1171
- register(tool: ITool): void;
1172
- /**
1173
- * Unregister a tool
1174
- */
1175
- unregister(name: string): void;
1176
- /**
1177
- * Get tool by name
1178
- */
1179
- get(name: string): ITool | undefined;
1180
- /**
1181
- * Get all registered tools
1182
- */
1183
- getAll(): ITool[];
1184
- /**
1185
- * Get tool schemas
1186
- */
1187
- getSchemas(): IToolSchema[];
1188
- /**
1189
- * Check if tool exists
1190
- */
1191
- has(name: string): boolean;
1192
- /**
1193
- * Clear all tools
1194
- */
1195
- clear(): void;
1196
- }
1197
- //#endregion
1198
- //#region src/abstracts/abstract-plugin-types.d.ts
1199
- /** Plugin categories for classification */
1200
- declare enum PluginCategory {
1201
- MONITORING = "monitoring",
1202
- LOGGING = "logging",
1203
- STORAGE = "storage",
1204
- NOTIFICATION = "notification",
1205
- SECURITY = "security",
1206
- PERFORMANCE = "performance",
1207
- ERROR_HANDLING = "error_handling",
1208
- LIMITS = "limits",
1209
- EVENT_PROCESSING = "event_processing",
1210
- CUSTOM = "custom"
1211
- }
1212
- /** Plugin priority levels */
1213
- declare enum PluginPriority {
1214
- CRITICAL = 1000,
1215
- HIGH = 800,
1216
- NORMAL = 500,
1217
- LOW = 200,
1218
- MINIMAL = 100
1219
- }
1220
- /** Plugin execution context for all plugins */
1221
- interface IPluginExecutionContext {
1222
- executionId?: string;
1223
- sessionId?: string;
1224
- userId?: string;
1225
- messages?: TUniversalMessage[];
1226
- config?: Record<string, string | number | boolean>;
1227
- metadata?: Record<string, string | number | boolean | Date>;
1228
- [key: string]: string | number | boolean | Date | string[] | number[] | boolean[] | TUniversalMessage[] | Record<string, string | number | boolean> | Record<string, string | number | boolean | Date> | undefined;
1229
- }
1230
- /** Plugin execution result for all plugins */
1231
- interface IPluginExecutionResult {
1232
- response?: string;
1233
- content?: string;
1234
- duration?: number;
1235
- tokensUsed?: number;
1236
- toolsExecuted?: number;
1237
- success?: boolean;
1238
- usage?: {
1239
- totalTokens?: number;
1240
- promptTokens?: number;
1241
- completionTokens?: number;
1242
- };
1243
- toolCalls?: Array<{
1244
- id?: string;
1245
- name?: string;
1246
- arguments?: Record<string, string | number | boolean>;
1247
- result?: string | number | boolean | null;
1248
- }>;
1249
- results?: Array<{
1250
- id?: string;
1251
- type?: string;
1252
- data?: string | number | boolean | null;
1253
- success?: boolean;
1254
- }>;
1255
- error?: Error;
1256
- metadata?: Record<string, string | number | boolean | Date>;
1257
- }
1258
- /** Error context for plugin error handling */
1259
- interface IPluginErrorContext {
1260
- action: string;
1261
- tool?: string;
1262
- parameters?: TToolParameters;
1263
- result?: IToolExecutionResult;
1264
- error?: Error;
1265
- executionId?: string;
1266
- sessionId?: string;
1267
- userId?: string;
1268
- timestamp?: Date;
1269
- attempt?: number;
1270
- stack?: string;
1271
- metadata?: Record<string, string | number | boolean>;
1272
- }
1273
- /** Plugin configuration interface */
1274
- interface IPluginConfig extends IPluginOptions {
1275
- options?: Record<string, string | number | boolean>;
1276
- }
1277
- /** Plugin options that all plugin options should extend */
1278
- interface IPluginOptions {
1279
- enabled?: boolean;
1280
- category?: PluginCategory;
1281
- priority?: PluginPriority | number;
1282
- moduleEvents?: TEventName[];
1283
- subscribeToAllModuleEvents?: boolean;
1284
- }
1285
- /** Plugin data interface */
1286
- interface IPluginData {
1287
- name: string;
1288
- version: string;
1289
- enabled: boolean;
1290
- category: PluginCategory;
1291
- priority: number;
1292
- subscribedEvents: TEventName[];
1293
- metadata?: Record<string, string | number | boolean>;
1294
- }
1295
- /** Type-safe plugin interface with specific type parameters */
1296
- interface IPluginContract<TOptions extends IPluginOptions = IPluginOptions, TStats = IPluginStats> {
1297
- name: string;
1298
- version: string;
1299
- enabled: boolean;
1300
- category: PluginCategory;
1301
- priority: number;
1302
- initialize(options?: TOptions): Promise<void>;
1303
- cleanup?(): Promise<void>;
1304
- getData?(): IPluginData;
1305
- getStats?(): TStats;
1306
- subscribeToModuleEvents?(eventEmitter: IEventEmitterPlugin): Promise<void>;
1307
- unsubscribeFromModuleEvents?(eventEmitter: IEventEmitterPlugin): Promise<void>;
1308
- onModuleEvent?(eventName: TEventName, eventData: IEventEmitterEventData): Promise<void> | void;
1309
- }
1310
- /** Plugin statistics base interface with common metrics */
1311
- interface IPluginStats {
1312
- enabled: boolean;
1313
- calls: number;
1314
- errors: number;
1315
- lastActivity?: Date;
1316
- moduleEventsReceived?: number;
1317
- [key: string]: string | number | boolean | Date | string[] | number[] | boolean[] | Record<string, string | number | boolean | Date> | undefined;
1318
- }
1319
- /** Plugin interface extending IPluginContract */
1320
- interface IPlugin extends IPluginContract<IPluginConfig, IPluginStats> {}
1321
- /** Plugin lifecycle hooks */
1322
- interface IPluginHooks {
1323
- beforeRun?(input: string, options?: IRunOptions): Promise<void> | void;
1324
- afterRun?(input: string, response: string, options?: IRunOptions): Promise<void> | void;
1325
- beforeExecution?(context: IPluginExecutionContext): Promise<void> | void;
1326
- afterExecution?(context: IPluginExecutionContext, result: IPluginExecutionResult): Promise<void> | void;
1327
- beforeConversation?(context: IPluginExecutionContext): Promise<void> | void;
1328
- afterConversation?(context: IPluginExecutionContext, result: IPluginExecutionResult): Promise<void> | void;
1329
- beforeToolCall?(toolName: string, parameters: TToolParameters): Promise<void> | void;
1330
- beforeToolExecution?(context: IPluginExecutionContext, toolData: IToolExecutionContext): Promise<void> | void;
1331
- afterToolCall?(toolName: string, parameters: TToolParameters, result: IToolExecutionResult): Promise<void> | void;
1332
- afterToolExecution?(context: IPluginExecutionContext, toolResults: IPluginExecutionResult): Promise<void> | void;
1333
- beforeProviderCall?(messages: TUniversalMessage[]): Promise<void> | void;
1334
- afterProviderCall?(messages: TUniversalMessage[], response: TUniversalMessage): Promise<void> | void;
1335
- onStreamingChunk?(chunk: TUniversalMessage): Promise<void> | void;
1336
- onError?(error: Error, context?: IPluginErrorContext): Promise<void> | void;
1337
- onMessageAdded?(message: TUniversalMessage): Promise<void> | void;
1338
- onModuleEvent?(eventName: TEventName, eventData: IEventEmitterEventData): Promise<void> | void;
1339
- }
1340
- //#endregion
1341
- //#region src/abstracts/abstract-plugin.d.ts
1342
- /**
1343
- * Abstract class for all plugins with type parameter support.
1344
- * Provides plugin lifecycle management and common functionality.
1345
- * @template TOptions - Plugin options type that extends IPluginOptions
1346
- * @template TStats - Plugin statistics type
1347
- */
1348
- declare abstract class AbstractPlugin<TOptions extends IPluginOptions = IPluginOptions, TStats extends IPluginStats = IPluginStats> implements IPluginContract<TOptions, TStats>, IPluginHooks {
1349
- abstract readonly name: string;
1350
- abstract readonly version: string;
1351
- enabled: boolean;
1352
- category: PluginCategory;
1353
- priority: number;
1354
- protected options: TOptions | undefined;
1355
- protected eventEmitter: IEventEmitterPlugin | undefined;
1356
- protected subscribedEvents: TEventName[];
1357
- protected eventHandlers: Map<TEventName, string[]>;
1358
- protected readonly pluginLogger: ILogger;
1359
- protected stats: {
1360
- calls: number;
1361
- errors: number;
1362
- moduleEventsReceived: number;
1363
- lastActivity: Date | undefined;
1364
- };
1365
- initialize(options?: TOptions): Promise<void>;
1366
- subscribeToModuleEvents(eventEmitter: IEventEmitterPlugin): Promise<void>;
1367
- unsubscribeFromModuleEvents(eventEmitter: IEventEmitterPlugin): Promise<void>;
1368
- dispose(): Promise<void>;
1369
- enable(): void;
1370
- disable(): void;
1371
- isEnabled(): boolean;
1372
- getConfig(): IPluginConfig;
1373
- updateConfig(_config: IPluginConfig): void;
1374
- getData(): IPluginData;
1375
- clearData?(): void;
1376
- getStatus(): {
1377
- name: string;
1378
- version: string;
1379
- enabled: boolean;
1380
- initialized: boolean;
1381
- category: PluginCategory;
1382
- priority: number;
1383
- subscribedEventsCount: number;
1384
- hasEventEmitter: boolean;
1385
- };
1386
- getStats(): TStats;
1387
- protected updateCallStats(): void;
1388
- protected updateErrorStats(): void;
1389
- beforeRun?(input: string, options?: IRunOptions): Promise<void>;
1390
- afterRun?(input: string, response: string, options?: IRunOptions): Promise<void>;
1391
- beforeExecution?(context: IPluginExecutionContext): Promise<void>;
1392
- afterExecution?(context: IPluginExecutionContext, result: IPluginExecutionResult): Promise<void>;
1393
- beforeConversation?(context: IPluginExecutionContext): Promise<void>;
1394
- afterConversation?(context: IPluginExecutionContext, result: IPluginExecutionResult): Promise<void>;
1395
- beforeToolCall?(toolName: string, parameters: TToolParameters): Promise<void>;
1396
- beforeToolExecution?(context: IPluginExecutionContext, toolData: IToolExecutionContext): Promise<void>;
1397
- afterToolCall?(toolName: string, parameters: TToolParameters, result: IToolExecutionResult): Promise<void>;
1398
- afterToolExecution?(context: IPluginExecutionContext, toolResults: IPluginExecutionResult): Promise<void>;
1399
- beforeProviderCall?(messages: TUniversalMessage[]): Promise<void>;
1400
- afterProviderCall?(messages: TUniversalMessage[], response: TUniversalMessage): Promise<void>;
1401
- onStreamingChunk?(chunk: TUniversalMessage): Promise<void>;
1402
- onError?(error: Error, context?: IPluginErrorContext): Promise<void>;
1403
- onMessageAdded?(message: TUniversalMessage): Promise<void>;
1404
- onModuleEvent?(eventName: TEventName, eventData: IEventEmitterEventData): Promise<void>;
1405
- }
1406
- //#endregion
1407
- //#region src/abstracts/abstract-tool.d.ts
1408
- /**
1409
- * Options for AbstractTool construction
1410
- */
1411
- interface IAbstractToolOptions {
1412
- /**
1413
- * Optional logger for tool operations
1414
- * Defaults to SilentLogger if not provided
1415
- */
1416
- logger?: ILogger;
1417
- /**
1418
- * Optional event service for unified event emission
1419
- * If not provided, tool will operate silently without emitting events
1420
- *
1421
- * The caller should provide an EventService configured with appropriate settings
1422
- * (e.g., ownerPrefix='tool' for tool events)
1423
- *
1424
- * @since 2.1.0
1425
- */
1426
- eventService?: IEventService;
1427
- }
1428
- /**
1429
- * Tool execution function type with proper parameter constraints
1430
- */
1431
- type TToolExecutionFunction<TParams = TToolParameters, TResult = IToolResult> = (parameters: TParams) => Promise<TResult> | TResult;
1432
- /**
1433
- * Abstract tool interface with type parameters for enhanced type safety
1434
- *
1435
- * @template TParams - Tool parameters type (defaults to AbstractToolParameters for backward compatibility)
1436
- * @template TResult - Tool result type (defaults to ToolResult for backward compatibility)
1437
- */
1438
- interface IAbstractTool<TParams = TToolParameters, TResult = IToolResult> {
1439
- name: string;
1440
- description: string;
1441
- parameters: IToolSchema['parameters'];
1442
- execute: TToolExecutionFunction<TParams, TResult>;
1443
- }
1444
- /**
1445
- * Type-safe tool interface with type parameters
1446
- *
1447
- * @template TParameters - Tool parameters type (defaults to AbstractToolParameters for backward compatibility)
1448
- * @template TResult - Tool result type (defaults to ToolResult for backward compatibility)
1449
- */
1450
- interface IToolContract<TParameters = TToolParameters, TResult = IToolResult> {
1451
- readonly schema: IToolSchema;
1452
- execute(parameters: TParameters, context: IToolExecutionContext): Promise<TResult>;
1453
- validate(parameters: TParameters): boolean;
1454
- validateParameters(parameters: TParameters): IParameterValidationResult;
1455
- getDescription(): string;
1456
- getName(): string;
1457
- }
1458
- /**
1459
- * Runtime tool instance contract used by Robota internals.
1460
- *
1461
- * Tools passed into Agent configuration must support EventService injection
1462
- * so Robota can emit unified tool lifecycle events.
1463
- */
1464
- interface IToolWithEventService<TParameters = TToolParameters, TResult = IToolResult> extends IToolContract<TParameters, TResult> {
1465
- setEventService(eventService: IEventService | undefined): void;
1466
- }
1467
- /**
1468
- * Abstract base class for tools with type parameter support
1469
- * Provides type-safe parameter handling and result processing
1470
- *
1471
- * 🎯 ARCHITECTURAL PRINCIPLES:
1472
- * - Pure abstract class - depends only on interfaces
1473
- * - No concrete class dependencies (EventService interface only)
1474
- * - Dependency Injection for all external dependencies
1475
- * - Graceful degradation (undefined dependencies = silent operation)
1476
- *
1477
- * @template TParameters - Tool parameters type (defaults to TToolParameters)
1478
- * @template TResult - Tool result type (defaults to ToolResult for backward compatibility)
1479
- */
1480
- declare abstract class AbstractTool<TParameters = TToolParameters, TResult = IToolResult> implements IToolWithEventService<TParameters, TResult> {
1481
- abstract readonly schema: IToolSchema;
1482
- /**
1483
- * Logger for tool operations
1484
- */
1485
- protected readonly logger: ILogger;
1486
- /**
1487
- * EventService for direct event emission (optional)
1488
- * If undefined, tool operates silently without emitting events
1489
- */
1490
- private eventService;
1491
- /**
1492
- * Constructor with simplified options
1493
- *
1494
- * 🎯 DEPENDENCY INJECTION:
1495
- * All dependencies are injected via options parameter
1496
- * No concrete classes are instantiated within this constructor
1497
- *
1498
- * @param options - Configuration options for the tool
1499
- */
1500
- constructor(options?: IAbstractToolOptions);
1501
- /**
1502
- * Set EventService for post-construction injection
1503
- *
1504
- * 🎯 DEPENDENCY INJECTION:
1505
- * Accepts EventService as-is without transformation
1506
- * Caller is responsible for providing properly configured EventService
1507
- *
1508
- * @param eventService - EventService instance to use for event emission (or undefined for silent operation)
1509
- */
1510
- setEventService(eventService: IEventService | undefined): void;
1511
- /**
1512
- * Get current EventService (for testing/inspection)
1513
- */
1514
- protected getEventService(): IEventService | undefined;
1515
- /**
1516
- * Emit event through EventService (if available)
1517
- * If EventService is not available, silently ignores the event (Null Object Pattern)
1518
- *
1519
- * @param eventType - Type of event to emit
1520
- * @param data - Event data
1521
- */
1522
- protected emitEvent(eventType: string, data: IBaseEventData): void;
1523
- /**
1524
- * Execute tool with simplified lifecycle
1525
- * @param parameters - Tool parameters
1526
- * @param context - Optional execution context
1527
- * @returns Promise resolving to tool result
1528
- */
1529
- execute(parameters: TParameters, context: IToolExecutionContext): Promise<TResult>;
1530
- /**
1531
- * Concrete implementation of tool execution
1532
- * This method should be implemented by subclasses to provide actual tool logic
1533
- *
1534
- * @param parameters - Tool parameters
1535
- * @param context - Optional execution context
1536
- * @returns Promise resolving to tool result
1537
- */
1538
- protected abstract executeImpl(parameters: TParameters, context: IToolExecutionContext): Promise<TResult>;
1539
- validate(parameters: TParameters): boolean;
1540
- /**
1541
- * Validate tool parameters with detailed result (default implementation)
1542
- */
1543
- validateParameters(parameters: TParameters): IParameterValidationResult;
1544
- getDescription(): string;
1545
- getName(): string;
1546
- }
1547
- //#endregion
1548
- //#region src/interfaces/agent.d.ts
1549
- /**
1550
- * IExecutionContextInjection
1551
- *
1552
- * Minimal context payload used to inject an existing ownerPath into a new agent instance
1553
- * (e.g., when a tool creates an agent and must preserve absolute ownerPath semantics).
1554
- *
1555
- * NOTE: This is intentionally NOT ToolExecutionContext. ToolExecutionContext is for tool calls
1556
- * and requires toolName/parameters; agent creation only needs ownerPath and execution linkage.
1557
- */
1558
- interface IExecutionContextInjection {
1559
- ownerPath?: IOwnerPathSegment[];
1560
- parentExecutionId?: string;
1561
- rootExecutionId?: string;
1562
- executionLevel?: number;
1563
- sourceId?: string;
1564
- }
1565
- /**
1566
- * Provider-specific configuration
1567
- */
1568
- interface IAgentProviderConfig {
1569
- openai?: {
1570
- apiKey?: string;
1571
- baseURL?: string;
1572
- organization?: string;
1573
- [key: string]: TProviderConfigValue | undefined;
1574
- };
1575
- anthropic?: {
1576
- apiKey?: string;
1577
- baseURL?: string;
1578
- [key: string]: TProviderConfigValue | undefined;
1579
- };
1580
- google?: {
1581
- apiKey?: string;
1582
- projectId?: string;
1583
- location?: string;
1584
- [key: string]: TProviderConfigValue | undefined;
1585
- };
1586
- [provider: string]: Record<string, TProviderConfigValue | undefined> | undefined;
1587
- }
1588
- /**
1589
- * Agent configuration options - New design with aiProviders array and defaultModel
1590
- */
1591
- interface IAgentConfig {
1592
- id?: string;
1593
- name: string;
1594
- aiProviders: IAIProvider[];
1595
- defaultModel: {
1596
- provider: string;
1597
- model: string;
1598
- temperature?: number;
1599
- maxTokens?: number;
1600
- topP?: number;
1601
- systemMessage?: string; /** Reasoning-effort dial threaded to the provider request builder per call. */
1602
- effort?: TModelEffort;
1603
- };
1604
- tools?: Array<IToolWithEventService>;
1605
- plugins?: Array<IPluginContract<IPluginOptions, IPluginStats>>;
1606
- modules?: IModule[];
1607
- systemMessage?: string;
1608
- systemPrompt?: string;
1609
- conversationId?: string;
1610
- sessionId?: string;
1611
- userId?: string;
1612
- metadata?: TUniversalMessageMetadata;
1613
- context?: Record<string, TConfigValue>;
1614
- logging?: {
1615
- level?: TUtilLogLevel;
1616
- enabled?: boolean;
1617
- format?: string;
1618
- destination?: string;
1619
- };
1620
- providerConfig?: IAgentProviderConfig;
1621
- stream?: boolean;
1622
- toolChoice?: 'auto' | 'none' | string;
1623
- responseFormat?: IResponseFormatConfig;
1624
- safetySettings?: ISafetySetting[];
1625
- timeout?: number;
1626
- maxExecutionRounds?: number;
1627
- maxSameToolInputs?: number;
1628
- retryAttempts?: number;
1629
- rateLimiting?: {
1630
- enabled?: boolean;
1631
- maxRequests?: number;
1632
- windowMs?: number;
1633
- };
1634
- eventService?: IEventService;
1635
- executionContext?: IExecutionContextInjection;
1636
- cache?: ICacheOptions;
1637
- }
1638
- /**
1639
- * Agent template interface
1640
- */
1641
- interface IAgentTemplate {
1642
- id: string;
1643
- name: string;
1644
- description?: string;
1645
- category?: string;
1646
- tags?: string[];
1647
- config: IAgentConfig;
1648
- version?: string;
1649
- author?: string;
1650
- createdAt?: Date;
1651
- updatedAt?: Date;
1652
- }
1653
- /**
1654
- * Agent run options - type-safe interface for all agent execution options
1655
- */
1656
- interface IRunOptions {
1657
- temperature?: number;
1658
- maxTokens?: number;
1659
- stream?: boolean;
1660
- toolChoice?: 'auto' | 'none' | string;
1661
- sessionId?: string;
1662
- userId?: string;
1663
- metadata?: TMetadata;
1664
- /** AbortSignal for cancelling execution */
1665
- signal?: AbortSignal;
1666
- /** Per-run streaming text callback. Prefer this over mutating provider callback state. */
1667
- onTextDelta?: TTextDeltaCallback;
1668
- /** Per-run replay event callback for provider/tool execution boundaries. */
1669
- onExecutionEvent?: TExecutionEventCallback;
1670
- /**
1671
- * Maximum model/tool rounds for this run.
1672
- * Use 0 for no core round cap.
1673
- */
1674
- maxExecutionRounds?: number;
1675
- /** Max times the same tool may be called with identical input before aborting. Unset = no limit. */
1676
- maxSameToolInputs?: number;
1677
- }
1678
- type TExecutionEventData = Record<string, unknown>;
1679
- type TExecutionEventCallback = (event: string, data: TExecutionEventData) => void;
1680
- /**
1681
- * Generic agent interface with type parameters for enhanced type safety
1682
- *
1683
- * @template TConfig - Agent configuration type (defaults to IAgentConfig for backward compatibility)
1684
- * @template TContext - Execution context type (defaults to IRunOptions for backward compatibility)
1685
- * @template TUniversalMessage - Message type (defaults to TUniversalMessage for backward compatibility)
1686
- */
1687
- interface IAgent<TConfig = IAgentConfig, TContext = IRunOptions, TMessage = TUniversalMessage> {
1688
- /**
1689
- * Configure the agent with type-safe configuration
1690
- */
1691
- configure?(config: TConfig): Promise<void>;
1692
- /**
1693
- * Run agent with user input and type-safe context
1694
- */
1695
- run(input: string, context?: TContext): Promise<string>;
1696
- /**
1697
- * Run agent with streaming response and type-safe context
1698
- */
1699
- runStream(input: string, context?: TContext): AsyncGenerator<string, void, never>;
1700
- /**
1701
- * Get conversation history with type-safe messages
1702
- */
1703
- getHistory(): TMessage[];
1704
- /**
1705
- * Clear conversation history
1706
- */
1707
- clearHistory(): void;
1708
- }
1709
- /**
1710
- * Response format configuration
1711
- */
1712
- interface IResponseFormatConfig {
1713
- type?: 'text' | 'json_object';
1714
- schema?: Record<string, TConfigValue>;
1715
- }
1716
- /**
1717
- * Safety setting configuration
1718
- */
1719
- interface ISafetySetting {
1720
- category: string;
1721
- threshold: string;
1722
- [key: string]: TConfigValue;
1723
- }
1724
- //#endregion
1725
- //#region src/interfaces/provider-definition.d.ts
1726
- interface IProviderConfig {
1727
- name: string;
1728
- model: string;
1729
- apiKey?: string;
1730
- baseURL?: string;
1731
- timeout?: number;
1732
- options?: Record<string, TUniversalValue>;
1733
- /**
1734
- * Resolution origin. `'env-default'` means no settings profile existed and the config
1735
- * was synthesized from a provider definition's defaults because its `$ENV:` apiKey
1736
- * reference resolved — callers surface a startup notice for this case.
1737
- */
1738
- source?: 'env-default';
1739
- /**
1740
- * Name of the environment variable the env-default key was resolved from
1741
- * (set only when `source` is `'env-default'`) — lets callers name the variable in the
1742
- * startup notice without exposing the key value.
1743
- */
1744
- sourceEnvVar?: string;
1745
- }
1746
- interface IProviderProfileDefaults {
1747
- model?: string;
1748
- apiKey?: string;
1749
- baseURL?: string;
1750
- timeout?: number;
1751
- options?: Record<string, TUniversalValue>;
1752
- }
1753
- interface IProviderProfileConfig {
1754
- type?: string;
1755
- model?: string;
1756
- apiKey?: string;
1757
- baseURL?: string;
1758
- timeout?: number;
1759
- options?: Record<string, TUniversalValue>;
1760
- }
1761
- interface IProviderProbeResult {
1762
- ok: boolean;
1763
- message: string;
1764
- models?: string[];
1765
- }
1766
- type TProviderCredentialField = 'apiKey';
1767
- type TProviderSetupField = 'baseURL' | 'model' | TProviderCredentialField;
1768
- type TProviderSetupHelpLinkKind = 'api-key' | 'console' | 'official';
1769
- interface IProviderCredentialRequirement {
1770
- anyOf: readonly TProviderCredentialField[];
1771
- }
1772
- interface IProviderSetupHelpLink {
1773
- kind: TProviderSetupHelpLinkKind;
1774
- label: string;
1775
- url: string;
1776
- sourceUrl?: string;
1777
- lastVerifiedAt?: string;
1778
- }
1779
- type TProviderModelCatalogStatus = 'live' | 'generated' | 'fallback' | 'unavailable';
1780
- type TProviderModelLifecycle = 'active' | 'preview' | 'deprecated' | 'unavailable';
1781
- type TProviderModelCapability = 'tools' | 'vision' | 'json_schema' | 'reasoning' | 'native_web' | 'streaming';
1782
- interface IProviderModelCatalogEntry {
1783
- id: string;
1784
- displayName: string;
1785
- aliases?: readonly string[];
1786
- contextWindow?: number;
1787
- capabilities?: readonly TProviderModelCapability[];
1788
- lifecycle?: TProviderModelLifecycle;
1789
- lastVerifiedAt?: string;
1790
- sourceUrl?: string;
1791
- }
1792
- interface IProviderModelCatalog {
1793
- status: TProviderModelCatalogStatus;
1794
- entries?: readonly IProviderModelCatalogEntry[];
1795
- lastVerifiedAt?: string;
1796
- sourceUrl?: string;
1797
- message?: string;
1798
- }
1799
- interface IProviderModelCatalogRefreshOptions {
1800
- profile: IProviderProfileConfig;
1801
- }
1802
- type TProviderModelCatalogRefresh = (options: IProviderModelCatalogRefreshOptions) => Promise<IProviderModelCatalog>;
1803
- interface IProviderSetupStepDefinition {
1804
- key: TProviderSetupField;
1805
- title: string;
1806
- defaultValue?: string;
1807
- required?: boolean;
1808
- masked?: boolean;
1809
- }
1810
- type TProviderCategory = 'cloud-paid' | 'cloud-free' | 'local-free';
1811
- interface IProviderDefinition {
1812
- type: string;
1813
- aliases?: readonly string[];
1814
- displayName?: string;
1815
- description?: string;
1816
- /** Billing/hosting category shown as a badge in provider selection UI. */
1817
- category?: TProviderCategory;
1818
- defaults?: IProviderProfileDefaults;
1819
- modelCatalog?: IProviderModelCatalog;
1820
- refreshModelCatalog?: TProviderModelCatalogRefresh;
1821
- /** Maximum age in seconds before the model catalog is considered stale and auto-refreshed. */
1822
- modelCatalogCacheTtlSeconds?: number;
1823
- setupHelpLinks?: readonly IProviderSetupHelpLink[];
1824
- setupSteps?: readonly IProviderSetupStepDefinition[];
1825
- credentialRequirement?: IProviderCredentialRequirement;
1826
- requiresApiKey?: boolean;
1827
- createProvider: (config: IProviderConfig) => IAIProvider;
1828
- probeProfile?: (profile: IProviderProfileConfig) => Promise<IProviderProbeResult>;
1829
- }
1830
- declare function findProviderDefinition(definitions: readonly IProviderDefinition[], type: string): IProviderDefinition | undefined;
1831
- declare function formatSupportedProviderTypes(definitions: readonly IProviderDefinition[]): string;
1832
- declare function getProviderCredentialRequirement(definition: IProviderDefinition | undefined): IProviderCredentialRequirement | undefined;
1833
- //#endregion
1834
- //#region src/interfaces/media-provider.d.ts
1835
- /**
1836
- * Provider-agnostic media output reference.
1837
- * Providers must not return raw binary payloads in this contract.
1838
- */
1839
- interface IMediaOutputRef {
1840
- kind: 'asset' | 'uri';
1841
- assetId?: string;
1842
- uri?: string;
1843
- mimeType?: string;
1844
- bytes?: number;
1845
- }
1846
- interface IProviderMediaError {
1847
- code: 'PROVIDER_AUTH_ERROR' | 'PROVIDER_RATE_LIMITED' | 'PROVIDER_TIMEOUT' | 'PROVIDER_INVALID_REQUEST' | 'PROVIDER_UPSTREAM_ERROR' | 'PROVIDER_JOB_NOT_FOUND' | 'PROVIDER_JOB_NOT_CANCELLABLE';
1848
- message: string;
1849
- details?: Record<string, TUniversalValue>;
1850
- }
1851
- type TProviderMediaResult<TValue> = {
1852
- ok: true;
1853
- value: TValue;
1854
- } | {
1855
- ok: false;
1856
- error: IProviderMediaError;
1857
- };
1858
- interface IInlineImageInputSource {
1859
- kind: 'inline';
1860
- mimeType: string;
1861
- data: string;
1862
- }
1863
- interface IUriImageInputSource {
1864
- kind: 'uri';
1865
- uri: string;
1866
- mimeType?: string;
1867
- }
1868
- type TImageInputSource = IInlineImageInputSource | IUriImageInputSource;
1869
- interface IImageGenerationRequest {
1870
- prompt: string;
1871
- model: string;
1872
- }
1873
- interface IImageEditRequest {
1874
- image: TImageInputSource;
1875
- prompt: string;
1876
- model: string;
1877
- }
1878
- interface IImageComposeRequest {
1879
- images: TImageInputSource[];
1880
- prompt: string;
1881
- model: string;
1882
- }
1883
- interface IImageGenerationResult {
1884
- outputs: IMediaOutputRef[];
1885
- model: string;
1886
- }
1887
- interface IImageGenerationProvider {
1888
- generateImage(request: IImageGenerationRequest): Promise<TProviderMediaResult<IImageGenerationResult>>;
1889
- editImage?(request: IImageEditRequest): Promise<TProviderMediaResult<IImageGenerationResult>>;
1890
- composeImage?(request: IImageComposeRequest): Promise<TProviderMediaResult<IImageGenerationResult>>;
1891
- }
1892
- interface IVideoGenerationRequest {
1893
- prompt: string;
1894
- model: string;
1895
- durationSeconds?: number;
1896
- aspectRatio?: string;
1897
- seed?: number;
1898
- inputImages?: TImageInputSource[];
1899
- }
1900
- interface IVideoJobAccepted {
1901
- jobId: string;
1902
- status: 'queued' | 'running';
1903
- createdAt: string;
1904
- }
1905
- interface IVideoJobSnapshot {
1906
- jobId: string;
1907
- status: 'queued' | 'running' | 'succeeded' | 'failed' | 'cancelled';
1908
- output?: IMediaOutputRef;
1909
- error?: IProviderMediaError;
1910
- updatedAt: string;
1911
- }
1912
- interface IVideoGenerationProvider {
1913
- createVideo(request: IVideoGenerationRequest): Promise<TProviderMediaResult<IVideoJobAccepted>>;
1914
- getVideoJob(jobId: string): Promise<TProviderMediaResult<IVideoJobSnapshot>>;
1915
- cancelVideoJob(jobId: string): Promise<TProviderMediaResult<IVideoJobSnapshot>>;
1916
- }
1917
- declare function isImageGenerationProvider(provider: object): provider is IImageGenerationProvider;
1918
- declare function isVideoGenerationProvider(provider: object): provider is IVideoGenerationProvider;
1919
- //#endregion
1920
- //#region src/interfaces/manager.d.ts
1921
- /**
1922
- * Reusable type definitions for manager layer
1923
- */
1924
- /**
1925
- * Agent creation metadata type
1926
- * Used for storing additional information about agent creation and configuration
1927
- */
1928
- type TAgentCreationMetadata = Record<string, string | number | boolean | Date>;
1929
- /**
1930
- * Tool execution parameters for manager operations
1931
- * Used for tool parameter validation and execution in manager context
1932
- */
1933
- type TManagerToolParameters = Record<string, string | number | boolean | string[] | number[] | boolean[]>;
1934
- /**
1935
- * Configuration validation result
1936
- */
1937
- interface IConfigValidationResult {
1938
- isValid: boolean;
1939
- errors: string[];
1940
- warnings?: string[];
1941
- }
1942
- /**
1943
- * AI Provider Manager interface for provider registration and selection
1944
- */
1945
- interface IAIProviderManager {
1946
- /**
1947
- * Register an AI provider
1948
- */
1949
- addProvider(name: string, provider: IAIProvider): void;
1950
- /**
1951
- * Remove an AI provider
1952
- */
1953
- removeProvider(name: string): void;
1954
- /**
1955
- * Get registered provider by name
1956
- */
1957
- getProvider(name: string): IAIProvider | undefined;
1958
- /**
1959
- * Get all registered providers
1960
- */
1961
- getProviders(): Record<string, IAIProvider>;
1962
- /**
1963
- * Set current provider and model
1964
- */
1965
- setCurrentProvider(name: string, model: string): void;
1966
- /**
1967
- * Get current provider and model
1968
- */
1969
- getCurrentProvider(): {
1970
- provider: string;
1971
- model: string;
1972
- } | undefined;
1973
- /**
1974
- * Check if provider is configured
1975
- */
1976
- isConfigured(): boolean;
1977
- }
1978
- /**
1979
- * Tool Manager interface for tool registration and management
1980
- */
1981
- interface IToolManager {
1982
- /**
1983
- * Register a tool
1984
- */
1985
- addTool(schema: IToolSchema, executor: TToolExecutor): void;
1986
- /**
1987
- * Remove a tool by name
1988
- */
1989
- removeTool(name: string): void;
1990
- /**
1991
- * Get tool interface by name
1992
- */
1993
- getTool(name: string): ITool | undefined;
1994
- /**
1995
- * Get tool schema by name
1996
- */
1997
- getToolSchema(name: string): IToolSchema | undefined;
1998
- /**
1999
- * Get all registered tools
2000
- */
2001
- getTools(): IToolSchema[];
2002
- /**
2003
- * Execute a tool
2004
- */
2005
- executeTool(name: string, parameters: TToolParameters, context?: IToolExecutionContext): Promise<TUniversalValue>;
2006
- /**
2007
- * Check if tool exists
2008
- */
2009
- hasTool(name: string): boolean;
2010
- /**
2011
- * Set allowed tools (for filtering)
2012
- */
2013
- setAllowedTools(tools: string[]): void;
2014
- /**
2015
- * Get allowed tools
2016
- */
2017
- getAllowedTools(): string[] | undefined;
2018
- }
2019
- /**
2020
- * Agent creation options
2021
- */
2022
- interface IAgentCreationOptions {
2023
- /** Override default configuration */
2024
- overrides?: Partial<IAgentConfig>;
2025
- /** Validation options */
2026
- validation?: {
2027
- strict?: boolean;
2028
- skipOptional?: boolean;
2029
- };
2030
- /** Additional metadata */
2031
- metadata?: TAgentCreationMetadata;
2032
- }
2033
- /**
2034
- * Agent Factory interface for agent creation and configuration
2035
- */
2036
- interface IAgentFactory {
2037
- /**
2038
- * Create agent instance
2039
- */
2040
- createAgent(config: IAgentConfig, options?: IAgentCreationOptions): IAgent<IAgentConfig>;
2041
- /**
2042
- * Validate agent configuration
2043
- */
2044
- validateConfig(config: IAgentConfig): IConfigValidationResult;
2045
- /**
2046
- * Get default configuration
2047
- */
2048
- getDefaultConfig(): IAgentConfig;
2049
- /**
2050
- * Merge configurations
2051
- */
2052
- mergeConfig(base: IAgentConfig, override: Partial<IAgentConfig>): IAgentConfig;
2053
- }
2054
- //#endregion
2055
- //#region src/interfaces/tool-integration.d.ts
2056
- /**
2057
- * OpenAPI specification configuration
2058
- */
2059
- interface IOpenAPIToolConfig {
2060
- /** OpenAPI 3.0 specification */
2061
- spec: {
2062
- openapi: string;
2063
- info: {
2064
- title: string;
2065
- version: string;
2066
- description?: string;
2067
- };
2068
- servers?: Array<{
2069
- url: string;
2070
- description?: string;
2071
- }>;
2072
- paths: Record<string, Record<string, string | number | boolean | Record<string, string | number | boolean>>>;
2073
- components?: Record<string, Record<string, string | number | boolean>>;
2074
- };
2075
- /** Operation ID from the OpenAPI spec */
2076
- operationId: string;
2077
- /** Base URL for API calls */
2078
- baseURL: string;
2079
- /** Authentication configuration */
2080
- auth?: {
2081
- type: 'bearer' | 'apiKey' | 'basic';
2082
- token?: string;
2083
- apiKey?: string;
2084
- header?: string;
2085
- username?: string;
2086
- password?: string;
2087
- };
2088
- }
2089
- /**
2090
- * MCP (Model Context Protocol) configuration
2091
- */
2092
- interface IMCPToolConfig {
2093
- /** MCP server endpoint */
2094
- endpoint: string;
2095
- /** Protocol version */
2096
- version?: string;
2097
- /** Authentication configuration */
2098
- auth?: {
2099
- type: 'bearer' | 'apiKey';
2100
- token: string;
2101
- };
2102
- /** Tool-specific configuration */
2103
- toolConfig?: Record<string, string | number | boolean>;
2104
- /** Timeout in milliseconds */
2105
- timeout?: number;
2106
- }
2107
- /**
2108
- * Tool factory interface
2109
- */
2110
- interface IToolFactory {
2111
- /**
2112
- * Create function tool from schema and function
2113
- */
2114
- createFunctionTool(schema: IToolSchema, fn: TToolExecutor): IFunctionTool;
2115
- /**
2116
- * Create tool from OpenAPI specification
2117
- */
2118
- createOpenAPITool(config: IOpenAPIToolConfig): ITool;
2119
- /**
2120
- * Create MCP tool
2121
- */
2122
- createMCPTool(config: IMCPToolConfig): ITool;
2123
- }
2124
- //#endregion
2125
- //#region src/interfaces/progress-reporting.d.ts
2126
- /**
2127
- * Execution step definition for tools that support step-by-step progress reporting
2128
- */
2129
- interface IToolExecutionStep {
2130
- /** Unique identifier for this step */
2131
- id: string;
2132
- /** Human-readable name of the step */
2133
- name: string;
2134
- /** Tool-provided estimated duration for this step in milliseconds */
2135
- estimatedDuration: number;
2136
- /** Optional description of what this step does */
2137
- description?: string;
2138
- }
2139
- /**
2140
- * Progress callback function type for real-time progress updates
2141
- */
2142
- type TToolProgressCallback = (step: string, progress: number) => void;
2143
- /**
2144
- * 🆕 IProgressReportingTool - Optional interface for tools that can provide their own progress information
2145
- *
2146
- * This interface extends the standard ITool to allow tools to optionally provide:
2147
- * - Estimated execution duration
2148
- * - Step-by-step execution plans
2149
- * - Real-time progress callbacks
2150
- *
2151
- * Benefits:
2152
- * - Tools can provide accurate progress information based on their internal knowledge
2153
- * - No simulation or fake progress - only real tool-provided estimates
2154
- * - Completely optional - existing tools work unchanged
2155
- * - Tools can self-report progress for better user experience
2156
- */
2157
- interface IProgressReportingTool extends ITool {
2158
- /**
2159
- * Get estimated execution duration for given parameters (optional)
2160
- *
2161
- * Tools can implement this to provide accurate time estimates based on:
2162
- * - Parameter complexity (e.g., search query length, file size)
2163
- * - Historical execution data
2164
- * - Internal optimization knowledge
2165
- *
2166
- * @param parameters - The parameters that will be passed to execute()
2167
- * @returns Estimated duration in milliseconds, or undefined if not available
2168
- */
2169
- getEstimatedDuration?(parameters: TToolParameters): number;
2170
- /**
2171
- * Get execution steps for given parameters (optional)
2172
- *
2173
- * Tools can implement this to provide step-by-step execution plans:
2174
- * - webSearch: [query processing, API call, result parsing, filtering]
2175
- * - fileSearch: [file scanning, content reading, pattern matching, result formatting]
2176
- * - github-mcp: [authentication, API request, response processing, data transformation]
2177
- *
2178
- * @param parameters - The parameters that will be passed to execute()
2179
- * @returns Array of execution steps, or undefined if not available
2180
- */
2181
- getExecutionSteps?(parameters: TToolParameters): IToolExecutionStep[];
2182
- /**
2183
- * Set progress callback for real-time updates (optional)
2184
- *
2185
- * Tools can implement this to provide real-time progress updates during execution:
2186
- * - Called when each step starts/completes
2187
- * - Progress value between 0-100 representing completion percentage
2188
- * - Step name helps users understand what's currently happening
2189
- *
2190
- * @param callback - Function to call with progress updates
2191
- */
2192
- setProgressCallback?(callback: TToolProgressCallback): void;
2193
- }
2194
- /**
2195
- * Type guard to check if a tool implements progress reporting
2196
- */
2197
- declare function isProgressReportingTool(tool: ITool): tool is IProgressReportingTool;
2198
- /**
2199
- * Helper function to safely get estimated duration from any tool
2200
- */
2201
- declare function getToolEstimatedDuration(tool: ITool, parameters: TToolParameters): number | undefined;
2202
- /**
2203
- * Helper function to safely get execution steps from any tool
2204
- */
2205
- declare function getToolExecutionSteps(tool: ITool, parameters: TToolParameters): IToolExecutionStep[] | undefined;
2206
- /**
2207
- * Helper function to safely set progress callback on any tool
2208
- */
2209
- declare function setToolProgressCallback(tool: ITool, callback: TToolProgressCallback): boolean;
2210
- //#endregion
2211
- //#region src/interfaces/service.d.ts
2212
- /**
2213
- * Reusable type definitions for service layer
2214
- */
2215
- /**
2216
- * Metadata type for conversation and execution context
2217
- * Used for storing additional information about conversations, responses, and execution
2218
- */
2219
- type TConversationContextMetadata = Record<string, string | number | boolean | Date>;
2220
- /**
2221
- * Tool execution parameters type
2222
- * Used for passing parameters to tool execution methods
2223
- */
2224
- type TToolExecutionParameters = Record<string, string | number | boolean | string[] | number[] | boolean[]>;
2225
- /**
2226
- * Execution metadata type
2227
- * Used for storing metadata about execution processes and options
2228
- */
2229
- type TExecutionMetadata = Record<string, string | number | boolean | Date>;
2230
- /**
2231
- * Response metadata type
2232
- * Used for storing metadata about AI provider responses and streaming chunks
2233
- */
2234
- type TResponseMetadata = Record<string, string | number | boolean | Date>;
2235
- /**
2236
- * Tool call data structure for function calls
2237
- */
2238
- /**
2239
- * Tool execution request
2240
- */
2241
- interface IToolExecutionRequest {
2242
- toolName: string;
2243
- parameters: TToolParameters;
2244
- executionId?: string;
2245
- metadata?: TToolMetadata;
2246
- ownerType?: string;
2247
- ownerId?: string;
2248
- ownerPath?: IOwnerPathSegment[];
2249
- eventService?: IEventService;
2250
- baseEventService?: IEventService;
2251
- }
2252
- /**
2253
- * Conversation context containing messages and metadata
2254
- */
2255
- interface IConversationContext {
2256
- /** All messages in the conversation */
2257
- messages: TUniversalMessage[];
2258
- /** System message for the conversation */
2259
- systemMessage?: string;
2260
- /** Model to use for generation */
2261
- model: string;
2262
- /** Provider to use for generation */
2263
- provider: string;
2264
- /** Temperature for generation */
2265
- temperature?: number;
2266
- /** Maximum tokens to generate */
2267
- maxTokens?: number;
2268
- /** Available tools */
2269
- tools?: IToolSchema[];
2270
- /** Additional metadata */
2271
- metadata?: TConversationContextMetadata;
2272
- }
2273
- /**
2274
- * Response from AI provider
2275
- */
2276
- interface IConversationResponse {
2277
- /** Generated content */
2278
- content: string;
2279
- /** Tool calls if any */
2280
- toolCalls?: IToolCall[];
2281
- /** Usage statistics */
2282
- usage?: {
2283
- promptTokens: number;
2284
- completionTokens: number;
2285
- totalTokens: number;
2286
- };
2287
- /** Response metadata */
2288
- metadata?: TResponseMetadata;
2289
- /** Finish reason */
2290
- finishReason?: string;
2291
- }
2292
- /**
2293
- * Streaming response chunk
2294
- */
2295
- interface IStreamingChunk {
2296
- /** Content delta */
2297
- delta: string;
2298
- /** Whether this is the final chunk */
2299
- done: boolean;
2300
- /** Tool calls if any */
2301
- toolCalls?: IToolCall[];
2302
- /** Usage statistics (only in final chunk) */
2303
- usage?: {
2304
- promptTokens: number;
2305
- completionTokens: number;
2306
- totalTokens: number;
2307
- };
2308
- }
2309
- /**
2310
- * Service options for conversation operations
2311
- */
2312
- interface IConversationServiceOptions {
2313
- /** Maximum conversation history length */
2314
- maxHistoryLength?: number;
2315
- /** Whether to automatically retry on failure */
2316
- enableRetry?: boolean;
2317
- /** Maximum number of retries */
2318
- maxRetries?: number;
2319
- /** Retry delay in milliseconds */
2320
- retryDelay?: number;
2321
- /** Request timeout in milliseconds */
2322
- timeout?: number;
2323
- }
2324
- /**
2325
- * Context options for conversation preparation
2326
- */
2327
- interface IContextOptions {
2328
- systemMessage?: string;
2329
- temperature?: number;
2330
- maxTokens?: number;
2331
- tools?: IToolSchema[];
2332
- metadata?: TConversationContextMetadata;
2333
- }
2334
- /**
2335
- * Execution service options
2336
- */
2337
- interface IExecutionServiceOptions {
2338
- /** Maximum number of tool execution rounds */
2339
- maxToolRounds?: number;
2340
- /** Tool execution timeout */
2341
- toolTimeout?: number;
2342
- /** Whether to enable parallel tool execution */
2343
- enableParallelExecution?: boolean;
2344
- /** Additional execution metadata */
2345
- metadata?: TExecutionMetadata;
2346
- }
2347
- /**
2348
- * Interface for conversation service operations
2349
- * All methods should be stateless and pure functions
2350
- */
2351
- interface IConversationService {
2352
- /**
2353
- * Prepare conversation context from messages and configuration
2354
- * Pure function that transforms inputs to context object
2355
- */
2356
- prepareContext(messages: TUniversalMessage[], model: string, provider: string, contextOptions?: IContextOptions, serviceOptions?: IConversationServiceOptions): IConversationContext;
2357
- /**
2358
- * Generate a response using the AI provider
2359
- * Stateless operation that handles the full request-response cycle
2360
- */
2361
- generateResponse(provider: IAIProvider, context: IConversationContext, serviceOptions?: IConversationServiceOptions): Promise<IConversationResponse>;
2362
- /**
2363
- * Generate streaming response using the AI provider
2364
- * Stateless streaming operation
2365
- */
2366
- generateStreamingResponse(provider: IAIProvider, context: IConversationContext, serviceOptions?: IConversationServiceOptions): AsyncGenerator<IStreamingChunk, void, never>;
2367
- /**
2368
- * Validate conversation context
2369
- * Pure validation function
2370
- */
2371
- validateContext(context: IConversationContext): {
2372
- isValid: boolean;
2373
- errors: string[];
2374
- };
2375
- }
2376
- /**
2377
- * Interface for tool execution service operations
2378
- */
2379
- interface IToolExecutionService {
2380
- /**
2381
- * Execute a single tool
2382
- */
2383
- executeTool(toolName: string, parameters: TToolParameters): Promise<TUniversalValue>;
2384
- /**
2385
- * Execute multiple tools in parallel
2386
- */
2387
- executeToolsParallel(toolCalls: IToolExecutionRequest[]): Promise<TUniversalValue[]>;
2388
- /**
2389
- * Execute multiple tools sequentially
2390
- */
2391
- executeToolsSequential(toolCalls: IToolExecutionRequest[]): Promise<TUniversalValue[]>;
2392
- }
2393
- /**
2394
- * Interface for execution service operations
2395
- */
2396
- interface IExecutionService {
2397
- /**
2398
- * Execute complete agent pipeline
2399
- */
2400
- execute(input: string, context: IConversationContext, options?: IExecutionServiceOptions): Promise<string>;
2401
- /**
2402
- * Execute streaming agent pipeline
2403
- */
2404
- executeStream(input: string, context: IConversationContext, options?: IExecutionServiceOptions): AsyncGenerator<string, void, never>;
2405
- }
2406
- //#endregion
2407
- //#region src/interfaces/executor.d.ts
2408
- /**
2409
- * Request for executing a streaming chat completion through an executor
2410
- */
2411
- interface IChatExecutionRequest {
2412
- /** Array of messages in the conversation */
2413
- messages: TUniversalMessage[];
2414
- /** Chat options including model, temperature, etc. */
2415
- options?: IChatOptions;
2416
- /** Available tools for the AI to use */
2417
- tools?: IToolSchema[];
2418
- /** Target AI provider (e.g., 'openai', 'anthropic', 'google') */
2419
- provider: string;
2420
- /** Specific model to use */
2421
- model: string;
2422
- }
2423
- /**
2424
- * Request for executing a streaming chat completion through an executor
2425
- */
2426
- interface IStreamExecutionRequest extends IChatExecutionRequest {
2427
- /** Indicates this is a streaming request */
2428
- stream: true;
2429
- }
2430
- /**
2431
- * Interface for executing AI provider operations
2432
- *
2433
- * Executors abstract the execution mechanism, allowing providers to work
2434
- * with either local API calls or remote server calls transparently.
2435
- *
2436
- * Implementation patterns:
2437
- * - LocalExecutor: Direct API calls using provider SDKs
2438
- * - RemoteExecutor: HTTP/WebSocket calls to remote server
2439
- * - CacheExecutor: Cached responses with explicit error propagation
2440
- * - HybridExecutor: Conditional local/remote execution
2441
- */
2442
- interface IExecutor {
2443
- /**
2444
- * Execute a chat completion request
2445
- *
2446
- * @param request - Chat execution request with messages, options, and tools
2447
- * @returns Promise resolving to assistant message response
2448
- *
2449
- * @example
2450
- * ```typescript
2451
- * const response = await executor.executeChat({
2452
- * messages: [{ role: 'user', content: 'Hello!' }],
2453
- * options: { model: 'gpt-4', temperature: 0.7 },
2454
- * provider: 'openai',
2455
- * model: 'gpt-4'
2456
- * });
2457
- * ```
2458
- */
2459
- executeChat(request: IChatExecutionRequest): Promise<IAssistantMessage>;
2460
- /**
2461
- * Execute a streaming chat completion request
2462
- *
2463
- * @param request - Streaming chat execution request
2464
- * @returns AsyncIterable of message chunks
2465
- *
2466
- * @example
2467
- * ```typescript
2468
- * for await (const chunk of executor.executeChatStream({
2469
- * messages: [{ role: 'user', content: 'Tell me a story' }],
2470
- * options: { model: 'gpt-4' },
2471
- * provider: 'openai',
2472
- * model: 'gpt-4',
2473
- * stream: true
2474
- * })) {
2475
- * console.log(chunk.content);
2476
- * }
2477
- * ```
2478
- */
2479
- executeChatStream?(request: IStreamExecutionRequest): AsyncIterable<TUniversalMessage>;
2480
- /**
2481
- * Check if the executor supports tool calling
2482
- * @returns true if tool calling is supported
2483
- */
2484
- supportsTools(): boolean;
2485
- /**
2486
- * Validate executor configuration
2487
- * @returns true if configuration is valid
2488
- */
2489
- validateConfig(): boolean;
2490
- /**
2491
- * Clean up resources when executor is no longer needed
2492
- */
2493
- dispose?(): Promise<void>;
2494
- /**
2495
- * Get executor name/identifier
2496
- */
2497
- readonly name: string;
2498
- /**
2499
- * Get executor version
2500
- */
2501
- readonly version: string;
2502
- }
2503
- /**
2504
- * Configuration options for local executor
2505
- */
2506
- interface ILocalExecutorConfig {
2507
- /** Timeout for API requests in milliseconds */
2508
- timeout?: number;
2509
- /** Maximum number of retry attempts */
2510
- maxRetries?: number;
2511
- /** Base delay between retries in milliseconds */
2512
- retryDelay?: number;
2513
- /** Whether to enable request/response logging */
2514
- enableLogging?: boolean;
2515
- }
2516
- /**
2517
- * Configuration options for remote executor
2518
- */
2519
- interface IRemoteExecutorConfig {
2520
- /** Remote server URL */
2521
- serverUrl: string;
2522
- /** User authentication token */
2523
- userApiKey: string;
2524
- /** Timeout for HTTP requests in milliseconds */
2525
- timeout?: number;
2526
- /** Maximum number of retry attempts */
2527
- maxRetries?: number;
2528
- /** Whether to enable WebSocket for streaming */
2529
- enableWebSocket?: boolean;
2530
- /** Custom headers to include in requests */
2531
- headers?: Record<string, string>;
2532
- }
2533
- //#endregion
2534
- //#region src/interfaces/history-module.d.ts
2535
- interface IEventHistoryRecord {
2536
- eventName: string;
2537
- sequenceId: number;
2538
- timestamp: Date;
2539
- eventData: IBaseEventData;
2540
- context: IEventContext;
2541
- }
2542
- interface IEventHistorySnapshot {
2543
- lastSequenceId: number;
2544
- createdAt: Date;
2545
- }
2546
- interface IEventHistoryModule {
2547
- append(record: IEventHistoryRecord): void;
2548
- read(fromSequenceId: number, toSequenceId?: number): IEventHistoryRecord[];
2549
- readStream(fromSequenceId: number, toSequenceId?: number): AsyncIterable<IEventHistoryRecord>;
2550
- getSnapshot?(): IEventHistorySnapshot | undefined;
2551
- }
2552
- //#endregion
2553
- //#region src/interfaces/terminal-output.d.ts
2554
- /**
2555
- * Terminal output abstraction — port interface for components that need I/O.
2556
- * Owned by agent-core as a domain port. Implemented by agent-cli.
2557
- */
2558
- interface ISpinner {
2559
- stop(): void;
2560
- update(message: string): void;
2561
- }
2562
- interface ITerminalOutput {
2563
- write(text: string): void;
2564
- writeLine(text: string): void;
2565
- writeMarkdown(md: string): void;
2566
- writeError(text: string): void;
2567
- prompt(question: string): Promise<string>;
2568
- select(options: string[], initialIndex?: number): Promise<number>;
2569
- spinner(message: string): ISpinner;
2570
- }
2571
- //#endregion
2572
- //#region src/interfaces/session.d.ts
2573
- /**
2574
- * Minimal session abstraction shared across contract layers.
2575
- * Lives in agent-core (Domain) so interface-level packages can reference it
2576
- * without depending on agent-sessions (Session services layer).
2577
- */
2578
- interface ISession {
2579
- readonly sessionId: string;
2580
- }
2581
- //#endregion
2582
- //#region src/interfaces/file-system.d.ts
2583
- interface IDirent {
2584
- name: string;
2585
- isFile(): boolean;
2586
- isDirectory(): boolean;
2587
- }
2588
- interface IStats {
2589
- mtimeMs: number;
2590
- birthtimeMs: number;
2591
- size: number;
2592
- isFile(): boolean;
2593
- isDirectory(): boolean;
2594
- }
2595
- interface IFileSystem {
2596
- existsSync(path: string): boolean;
2597
- readFileSync(path: string, encoding: BufferEncoding): string;
2598
- writeFileSync(path: string, data: string, encoding?: BufferEncoding): void;
2599
- mkdirSync(path: string, options?: {
2600
- recursive?: boolean;
2601
- }): void;
2602
- readdirSync(path: string): string[];
2603
- readdirSync(path: string, options: {
2604
- withFileTypes: true;
2605
- }): IDirent[];
2606
- statSync(path: string): IStats;
2607
- rmSync(path: string, options?: {
2608
- recursive?: boolean;
2609
- force?: boolean;
2610
- }): void;
2611
- cpSync(source: string, destination: string, options?: {
2612
- recursive?: boolean;
2613
- }): void;
2614
- renameSync(oldPath: string, newPath: string): void;
2615
- constants: {
2616
- F_OK: number;
2617
- R_OK: number;
2618
- W_OK: number;
2619
- };
2620
- }
2621
- interface IFileSystemAsync {
2622
- access(path: string, mode?: number): Promise<void>;
2623
- copyFile(src: string, dest: string, flags?: number): Promise<void>;
2624
- mkdir(path: string, options?: {
2625
- recursive?: boolean;
2626
- }): Promise<void>;
2627
- readFile(path: string, encoding: BufferEncoding): Promise<string>;
2628
- readdir(path: string): Promise<string[]>;
2629
- readdir(path: string, options: {
2630
- withFileTypes: true;
2631
- }): Promise<IDirent[]>;
2632
- realpath(path: string): Promise<string>;
2633
- rename(oldPath: string, newPath: string): Promise<void>;
2634
- rm(path: string, options?: {
2635
- recursive?: boolean;
2636
- force?: boolean;
2637
- }): Promise<void>;
2638
- stat(path: string): Promise<IStats>;
2639
- writeFile(path: string, data: string, encoding?: BufferEncoding): Promise<void>;
2640
- }
2641
- //#endregion
2642
- //#region src/abstracts/abstract-agent.d.ts
2643
- declare abstract class AbstractAgent<TConfig = IAgentConfig, TContext = IRunOptions, TMessage = TUniversalMessage> implements IAgent<TConfig, TContext, TMessage> {
2644
- protected history: TMessage[];
2645
- protected isInitialized: boolean;
2646
- protected config?: TConfig;
2647
- /**
2648
- * Initialize the agent (subclass responsibility)
2649
- */
2650
- protected abstract initialize(): Promise<void>;
2651
- /**
2652
- * Configure the agent with type-safe configuration
2653
- */
2654
- configure(config: TConfig): Promise<void>;
2655
- /**
2656
- * Run agent with user input and type-safe context
2657
- */
2658
- abstract run(input: string, context?: TContext): Promise<string>;
2659
- /**
2660
- * Run agent with streaming response and type-safe context
2661
- */
2662
- abstract runStream(input: string, context?: TContext): AsyncGenerator<string, void, never>;
2663
- /**
2664
- * Get conversation history with type-safe messages
2665
- */
2666
- getHistory(): TMessage[];
2667
- /**
2668
- * Clear conversation history
2669
- */
2670
- clearHistory(): void;
2671
- /**
2672
- * Add message to history
2673
- */
2674
- protected addMessage(message: TMessage): void;
2675
- /**
2676
- * Validate user input
2677
- */
2678
- protected validateInput(input: string): void;
2679
- /**
2680
- * Ensure agent is initialized before running
2681
- */
2682
- protected ensureInitialized(): Promise<void>;
2683
- /**
2684
- * Cleanup resources
2685
- */
2686
- dispose(): Promise<void>;
2687
- }
2688
- //#endregion
2689
- //#region src/abstracts/abstract-manager.d.ts
2690
- /**
2691
- * @fileoverview Abstract Manager Base Class
2692
- *
2693
- * 🎯 ABSTRACT CLASS - DO NOT IMPORT CONCRETE IMPLEMENTATIONS
2694
- *
2695
- * This class defines the common lifecycle contract for all manager implementations.
2696
- * It enforces explicit initialization/disposal semantics so that subclasses can
2697
- * provide their own resource management logic while sharing guard rails.
2698
- *
2699
- * Architectural rules:
2700
- * - Depends only on abstractions (no concrete manager implementations)
2701
- * - Provides finalize hooks (`doInitialize`, `doDispose`) for subclasses
2702
- * - Guards public APIs via `ensureInitialized`
2703
- */
2704
- declare abstract class AbstractManager {
2705
- protected initialized: boolean;
2706
- /**
2707
- * Initialize the manager (idempotent)
2708
- */
2709
- initialize(): Promise<void>;
2710
- /**
2711
- * Subclass-specific initialization logic
2712
- */
2713
- protected abstract doInitialize(): Promise<void>;
2714
- /**
2715
- * Dispose manager resources (idempotent)
2716
- */
2717
- dispose(): Promise<void>;
2718
- /**
2719
- * Subclass-specific disposal logic
2720
- */
2721
- protected abstract doDispose(): Promise<void>;
2722
- /**
2723
- * Whether the manager completed initialization
2724
- */
2725
- isInitialized(): boolean;
2726
- /**
2727
- * Ensure manager is initialized before performing operations
2728
- */
2729
- protected ensureInitialized(): void;
2730
- }
2731
- //#endregion
2732
- //#region src/abstracts/abstract-ai-provider.d.ts
2733
- /**
2734
- * Provider logging data type
2735
- * Used for storing logging information in provider operations
2736
- */
2737
- type TProviderLoggingData = Record<string, string | number | boolean | Date | string[]>;
2738
- /**
2739
- * Provider configuration base interface
2740
- */
2741
- interface IProviderConfig$1 {
2742
- apiKey?: string;
2743
- baseUrl?: string;
2744
- timeout?: number;
2745
- [key: string]: string | number | boolean | undefined;
2746
- }
2747
- /**
2748
- * Enhanced provider configuration that supports executor injection
2749
- */
2750
- interface IExecutorAwareProviderConfig {
2751
- apiKey?: string;
2752
- baseUrl?: string;
2753
- timeout?: number;
2754
- /**
2755
- * Optional executor for handling AI requests
2756
- * When provided, the provider will delegate all chat operations to this executor
2757
- * instead of making direct API calls. This enables remote execution capabilities.
2758
- */
2759
- executor?: IExecutor;
2760
- [key: string]: string | number | boolean | IExecutor | undefined;
2761
- }
2762
- /**
2763
- * Base AI provider implementation with proper type constraints.
2764
- * All AI providers should extend this class.
2765
- *
2766
- * Subclasses MUST: extend this class, use override keyword, call super() in constructor,
2767
- * not redefine types that exist in agent-core, handle null message content correctly.
2768
- *
2769
- * @template TConfig - Provider configuration type
2770
- */
2771
- declare abstract class AbstractAIProvider<TConfig = IProviderConfig$1> implements IAIProvider {
2772
- abstract readonly name: string;
2773
- abstract readonly version: string;
2774
- protected config?: TConfig;
2775
- protected executor?: IExecutor;
2776
- protected readonly logger: ILogger;
2777
- constructor(logger?: ILogger);
2778
- /**
2779
- * Configure the provider with type-safe configuration
2780
- */
2781
- configure(config: TConfig): Promise<void>;
2782
- private hasExecutor;
2783
- /**
2784
- * Each provider must implement chat using their own native SDK types internally
2785
- * @param messages - Array of messages from conversation history
2786
- * @param options - Chat options including tools, model settings, etc.
2787
- * @returns Promise resolving to a response
2788
- */
2789
- abstract chat(messages: TUniversalMessage[], options?: IChatOptions): Promise<TUniversalMessage>;
2790
- /**
2791
- * Wrap an async iterable to yield to the macrotask queue periodically.
2792
- * Providers MUST use this when iterating over streaming events to ensure
2793
- * the main thread event loop stays responsive (ESC abort, Ctrl+C, etc.).
2794
- *
2795
- * Usage in provider:
2796
- * for await (const event of this.streamWithAbort(stream, signal)) { ... }
2797
- */
2798
- protected streamWithAbort<T>(source: AsyncIterable<T>, signal?: AbortSignal): AsyncGenerator<T>;
2799
- /**
2800
- * Each provider must implement streaming chat using their own native SDK types internally
2801
- * @param messages - Array of messages from conversation history
2802
- * @param options - Chat options including tools, model settings, etc.
2803
- * @returns AsyncIterable of response chunks
2804
- */
2805
- chatStream?(messages: TUniversalMessage[], options?: IChatOptions): AsyncIterable<TUniversalMessage>;
2806
- /**
2807
- * Provider-agnostic raw response API.
2808
- *
2809
- * This is the canonical "raw payload" entrypoint required by the AIProvider contract.
2810
- * The default implementation delegates to `chat()` and adapts the result into a
2811
- * RawProviderResponse shape.
2812
- */
2813
- generateResponse(payload: IProviderRequest): Promise<IRawProviderResponse>;
2814
- /**
2815
- * Provider-agnostic raw streaming API.
2816
- *
2817
- * If a provider does not implement chatStream, it does not support streaming.
2818
- */
2819
- generateStreamingResponse(payload: IProviderRequest): AsyncIterable<IRawProviderResponse>;
2820
- /**
2821
- * Default implementation - most modern providers support tools
2822
- * @returns true if tool calling is supported
2823
- */
2824
- supportsTools(): boolean;
2825
- getCapabilities(): IProviderCapabilities;
2826
- /**
2827
- * Default implementation - providers can override for specific validation
2828
- * @returns true if configuration is valid
2829
- */
2830
- validateConfig(): boolean;
2831
- /** Validate that messages is a non-empty array with valid roles. */
2832
- protected validateMessages(messages: TUniversalMessage[]): void;
2833
- /** Validate tool schemas. No-ops if tools is undefined. */
2834
- protected validateTools(tools?: IToolSchema[]): void;
2835
- protected validateNativeWebTools(request?: IProviderNativeWebToolRequest): void;
2836
- /**
2837
- * Execute chat via executor.
2838
- * Subclasses should call this only when an executor is configured.
2839
- */
2840
- protected executeViaExecutorOrDirect(messages: TUniversalMessage[], options?: IChatOptions): Promise<TUniversalMessage>;
2841
- /**
2842
- * Execute streaming chat via executor.
2843
- * Subclasses should call this only when an executor is configured.
2844
- */
2845
- protected executeStreamViaExecutorOrDirect(messages: TUniversalMessage[], options?: IChatOptions): AsyncIterable<TUniversalMessage>;
2846
- /**
2847
- * Clean up resources when provider is no longer needed
2848
- * Override this method in subclasses for additional cleanup
2849
- */
2850
- dispose(): Promise<void>;
2851
- }
2852
- //#endregion
2853
- //#region src/abstracts/abstract-executor.d.ts
2854
- /**
2855
- * @fileoverview Abstract Executor Base Class
2856
- *
2857
- * 🎯 ABSTRACT CLASS - DO NOT DEPEND ON CONCRETE IMPLEMENTATIONS
2858
- *
2859
- * Provides shared execution helpers (retry, timeout, validation, logging) for all
2860
- * executor implementations. Concrete executors should extend this class and inject
2861
- * their own logger implementation if they need custom logging behavior.
2862
- *
2863
- * @example
2864
- * ```typescript
2865
- * export class MyCustomExecutor extends AbstractExecutor {
2866
- * async executeChat(request: IChatExecutionRequest): Promise<AssistantMessage> {
2867
- * return this.withRetry(() => this.performChat(request));
2868
- * }
2869
- * }
2870
- * ```
2871
- */
2872
- declare abstract class AbstractExecutor implements IExecutor {
2873
- /**
2874
- * Logger injected via constructor (defaults to abstract logger)
2875
- */
2876
- protected readonly logger: ILogger;
2877
- constructor(logger?: ILogger);
2878
- abstract readonly name: string;
2879
- abstract readonly version: string;
2880
- /**
2881
- * Execute a chat completion request
2882
- * Must be implemented by concrete executor classes
2883
- */
2884
- abstract executeChat(request: IChatExecutionRequest): Promise<IAssistantMessage>;
2885
- /**
2886
- * Execute a streaming chat completion request
2887
- * Optional - can be implemented by concrete executor classes
2888
- */
2889
- abstract executeChatStream?(request: IStreamExecutionRequest): AsyncIterable<TUniversalMessage>;
2890
- /**
2891
- * Check if the executor supports tool calling
2892
- * Default implementation returns false, can be overridden
2893
- */
2894
- supportsTools(): boolean;
2895
- /**
2896
- * Validate executor configuration
2897
- * Default implementation returns true, can be overridden
2898
- */
2899
- validateConfig(): boolean;
2900
- /**
2901
- * Clean up resources when executor is no longer needed
2902
- * Default implementation does nothing, can be overridden
2903
- */
2904
- dispose?(): Promise<void>;
2905
- /**
2906
- * Execute function with retry logic
2907
- *
2908
- * @param fn - Function to execute with retries
2909
- * @param maxRetries - Maximum number of retry attempts (default: 3)
2910
- * @param retryDelay - Delay between retries in milliseconds (default: 1000)
2911
- * @returns Promise resolving to function result
2912
- */
2913
- protected withRetry<T>(fn: () => Promise<T>, maxRetries?: number, retryDelay?: number): Promise<T>;
2914
- /**
2915
- * Execute function with timeout
2916
- *
2917
- * @param promise - Promise to execute with timeout
2918
- * @param timeoutMs - Timeout in milliseconds
2919
- * @returns Promise resolving to function result
2920
- */
2921
- protected withTimeout<T>(promise: Promise<T>, timeoutMs: number): Promise<T>;
2922
- /**
2923
- * Delay execution for specified milliseconds
2924
- *
2925
- * @param ms - Milliseconds to delay
2926
- * @returns Promise that resolves after the delay
2927
- */
2928
- protected delay(ms: number): Promise<void>;
2929
- /**
2930
- * Log debug information (only if logging is enabled)
2931
- *
2932
- * @param message - Log message
2933
- * @param data - Optional data to log
2934
- */
2935
- protected logDebug(message: string, data?: TLoggerData): void;
2936
- /**
2937
- * Log error information
2938
- *
2939
- * @param message - Log message
2940
- * @param error - Error object
2941
- * @param data - Optional additional data
2942
- */
2943
- protected logError(message: string, error: Error, data?: TLoggerData): void;
2944
- /**
2945
- * Validate that request has required fields
2946
- *
2947
- * @param request - Chat execution request to validate
2948
- * @throws Error if validation fails
2949
- */
2950
- protected validateRequest(request: IChatExecutionRequest): void;
2951
- /**
2952
- * Validate that response is properly formatted
2953
- *
2954
- * @param response - Response to validate
2955
- * @throws Error if validation fails
2956
- */
2957
- protected validateResponse(response: TUniversalMessage): void;
2958
- }
2959
- //#endregion
2960
- //#region src/utils/message-converter.d.ts
2961
- /**
2962
- * Provider message format type.
2963
- *
2964
- * Provider packages own concrete message shapes. Core only carries the generic
2965
- * conversion hook and never branches on provider names.
2966
- */
2967
- type TProviderMessage = TUniversalMessage | IUniversalObjectValue;
2968
- type TMessageFormatConverter<TMessage extends TProviderMessage = TProviderMessage> = (messages: readonly TUniversalMessage[]) => TMessage[];
2969
- type TMessageConverterRegistry = Readonly<Record<string, TMessageFormatConverter>>;
2970
- /**
2971
- * Universal message converter utility
2972
- *
2973
- * The converter is registry-based so provider-specific message conversion is
2974
- * injected by provider packages or callers instead of being hardcoded in core.
2975
- */
2976
- declare class MessageConverter {
2977
- /**
2978
- * Convert messages using an injected converter or converter registry.
2979
- */
2980
- static toProviderFormat(messages: TUniversalMessage[], converter?: TMessageFormatConverter | string, registry?: TMessageConverterRegistry): TProviderMessage[];
2981
- /**
2982
- * Convert to universal format (no conversion)
2983
- */
2984
- private static toUniversalFormat;
2985
- /**
2986
- * Extract system message from messages
2987
- */
2988
- static extractSystemMessage(messages: TUniversalMessage[]): string | undefined;
2989
- /**
2990
- * Filter non-system messages
2991
- */
2992
- static filterNonSystemMessages(messages: TUniversalMessage[]): TUniversalMessage[];
2993
- }
2994
- //#endregion
2995
- //#region src/utils/validation.d.ts
2996
- /**
2997
- * Validation result interface
2998
- */
2999
- interface ISimpleValidationResult {
3000
- isValid: boolean;
3001
- errors: string[];
3002
- warnings?: string[];
3003
- }
3004
- /**
3005
- * Validation utility class
3006
- */
3007
- declare class Validator {
3008
- /**
3009
- * Validate agent configuration
3010
- */
3011
- static validateAgentConfig(config: Partial<IAgentConfig>): ISimpleValidationResult;
3012
- /**
3013
- * Validate user input string
3014
- */
3015
- static validateUserInput(input: string): ISimpleValidationResult;
3016
- /**
3017
- * Validate provider name
3018
- */
3019
- static validateProviderName(name: string): ISimpleValidationResult;
3020
- /**
3021
- * Validate model name
3022
- */
3023
- static validateModelName(name: string): ISimpleValidationResult;
3024
- /**
3025
- * Validate API key format (basic check)
3026
- */
3027
- static validateApiKey(apiKey: string): ISimpleValidationResult;
3028
- }
3029
- declare const validateAgentConfig: typeof Validator.validateAgentConfig;
3030
- declare const validateUserInput: typeof Validator.validateUserInput;
3031
- declare const validateProviderName: typeof Validator.validateProviderName;
3032
- declare const validateModelName: typeof Validator.validateModelName;
3033
- declare const validateApiKey: typeof Validator.validateApiKey;
3034
- //#endregion
3035
- //#region src/utils/errors.d.ts
3036
- /**
3037
- * Reusable type definitions for error utilities
3038
- */
3039
- /**
3040
- * Error context data type
3041
- * Used for storing contextual information in error instances
3042
- */
3043
- type TErrorContextData = Record<string, string | number | boolean | Date | Error | string[] | undefined>;
3044
- /**
3045
- * Error external input type
3046
- * Used for handling external errors from unknown sources
3047
- */
3048
- type TErrorExternalInput = Error | string | Record<string, string | number | boolean> | null | undefined;
3049
- /**
3050
- * Base error class for all Robota errors
3051
- */
3052
- declare abstract class RobotaError extends Error {
3053
- readonly context?: TErrorContextData | undefined;
3054
- abstract readonly code: string;
3055
- abstract readonly category: 'user' | 'system' | 'provider';
3056
- abstract readonly recoverable: boolean;
3057
- constructor(message: string, context?: TErrorContextData | undefined);
3058
- }
3059
- /**
3060
- * Configuration related errors
3061
- */
3062
- declare class ConfigurationError extends RobotaError {
3063
- readonly code = "CONFIGURATION_ERROR";
3064
- readonly category: "user";
3065
- readonly recoverable = false;
3066
- constructor(message: string, context?: TErrorContextData);
3067
- }
3068
- /**
3069
- * Input validation errors
3070
- */
3071
- declare class ValidationError extends RobotaError {
3072
- readonly field?: string | undefined;
3073
- readonly code = "VALIDATION_ERROR";
3074
- readonly category: "user";
3075
- readonly recoverable = false;
3076
- constructor(message: string, field?: string | undefined, context?: TErrorContextData);
3077
- }
3078
- /**
3079
- * Provider related errors
3080
- */
3081
- declare class ProviderError extends RobotaError {
3082
- readonly provider: string;
3083
- readonly originalError?: Error | undefined;
3084
- readonly code = "PROVIDER_ERROR";
3085
- readonly category: "provider";
3086
- readonly recoverable = true;
3087
- constructor(message: string, provider: string, originalError?: Error | undefined, context?: TErrorContextData);
3088
- }
3089
- /**
3090
- * Authentication errors
3091
- */
3092
- declare class AuthenticationError extends RobotaError {
3093
- readonly provider?: string | undefined;
3094
- readonly code = "AUTHENTICATION_ERROR";
3095
- readonly category: "user";
3096
- readonly recoverable = false;
3097
- constructor(message: string, provider?: string | undefined, context?: TErrorContextData);
3098
- }
3099
- /**
3100
- * Rate limit errors
3101
- */
3102
- declare class RateLimitError extends RobotaError {
3103
- readonly retryAfter?: number | undefined;
3104
- readonly provider?: string | undefined;
3105
- readonly code = "RATE_LIMIT_ERROR";
3106
- readonly category: "provider";
3107
- readonly recoverable = true;
3108
- constructor(message: string, retryAfter?: number | undefined, provider?: string | undefined, context?: TErrorContextData);
3109
- }
3110
- /**
3111
- * Network/connectivity errors
3112
- */
3113
- declare class NetworkError extends RobotaError {
3114
- readonly originalError?: Error | undefined;
3115
- readonly code = "NETWORK_ERROR";
3116
- readonly category: "system";
3117
- readonly recoverable = true;
3118
- constructor(message: string, originalError?: Error | undefined, context?: TErrorContextData);
3119
- }
3120
- /**
3121
- * Tool execution errors
3122
- */
3123
- declare class ToolExecutionError extends RobotaError {
3124
- readonly toolName: string;
3125
- readonly originalError?: Error | undefined;
3126
- readonly code = "TOOL_EXECUTION_ERROR";
3127
- readonly category: "system";
3128
- readonly recoverable = false;
3129
- constructor(message: string, toolName: string, originalError?: Error | undefined, context?: TErrorContextData);
3130
- }
3131
- /**
3132
- * Model not available errors
3133
- */
3134
- declare class ModelNotAvailableError extends RobotaError {
3135
- readonly availableModels?: string[] | undefined;
3136
- readonly code = "MODEL_NOT_AVAILABLE";
3137
- readonly category: "user";
3138
- readonly recoverable = false;
3139
- constructor(model: string, provider: string, availableModels?: string[] | undefined, context?: TErrorContextData);
3140
- }
3141
- /**
3142
- * Circuit breaker open error
3143
- */
3144
- declare class CircuitBreakerOpenError extends RobotaError {
3145
- readonly code = "CIRCUIT_BREAKER_OPEN";
3146
- readonly category: "system";
3147
- readonly recoverable = true;
3148
- constructor(message?: string, context?: TErrorContextData);
3149
- }
3150
- /**
3151
- * Plugin errors
3152
- */
3153
- declare class PluginError extends RobotaError {
3154
- readonly pluginName: string;
3155
- readonly code = "PLUGIN_ERROR";
3156
- readonly category: "system";
3157
- readonly recoverable = false;
3158
- constructor(message: string, pluginName: string, context?: TErrorContextData);
3159
- }
3160
- /**
3161
- * Storage related errors
3162
- */
3163
- declare class StorageError extends RobotaError {
3164
- readonly code = "STORAGE_ERROR";
3165
- readonly category: "system";
3166
- readonly recoverable = true;
3167
- constructor(message: string, context?: TErrorContextData);
3168
- }
3169
- /**
3170
- * Cache integrity validation errors
3171
- */
3172
- declare class CacheIntegrityError extends RobotaError {
3173
- readonly code = "CACHE_INTEGRITY_ERROR";
3174
- readonly category: "system";
3175
- readonly recoverable = false;
3176
- constructor(message: string, context?: TErrorContextData);
3177
- }
3178
- /**
3179
- * Error utility functions
3180
- */
3181
- declare class ErrorUtils {
3182
- /**
3183
- * Check if error is recoverable
3184
- */
3185
- static isRecoverable(error: Error): boolean;
3186
- /**
3187
- * Extract error code from any error
3188
- */
3189
- static getErrorCode(error: Error): string;
3190
- /**
3191
- * Create error from unknown value
3192
- */
3193
- static fromUnknown(error: TErrorExternalInput, defaultMessage?: string): RobotaError;
3194
- /**
3195
- * Wrap external errors
3196
- */
3197
- static wrapProviderError(error: TErrorExternalInput, provider: string, operation: string): ProviderError;
3198
- }
3199
- //#endregion
3200
- //#region src/utils/periodic-task.d.ts
3201
- interface IPeriodicTaskOptions {
3202
- name: string;
3203
- intervalMs: number;
3204
- }
3205
- /**
3206
- * Start a periodic async task with consistent error logging.
3207
- * SSOT helper to avoid duplicating setInterval(async () => ...) patterns.
3208
- */
3209
- declare function startPeriodicTask(logger: ILogger, options: IPeriodicTaskOptions, task: () => Promise<void>): TTimerId;
3210
- declare function stopPeriodicTask(timer: TTimerId | undefined): void;
3211
- //#endregion
3212
- //#region src/utils/index.d.ts
3213
- /**
3214
- * Cross-platform timer identifier type
3215
- * Works in both Node.js and browser environments
3216
- */
3217
- type TTimerId = ReturnType<typeof setTimeout>;
3218
- //#endregion
3219
- //#region src/managers/conversation-store.d.ts
3220
- /** API message format for provider consumption */
3221
- interface IProviderApiMessage {
3222
- role: string;
3223
- content: string | null;
3224
- tool_calls?: Array<{
3225
- id: string;
3226
- type: 'function';
3227
- function: {
3228
- name: string;
3229
- arguments: string;
3230
- };
3231
- }>;
3232
- tool_call_id?: string;
3233
- }
3234
- /**
3235
- * Conversation store with duplicate prevention and API format conversion.
3236
- * @public
3237
- */
3238
- declare class ConversationStore implements IConversationHistory {
3239
- private history;
3240
- private pendingAssistant;
3241
- constructor(maxMessages?: number);
3242
- addMessage(message: TUniversalMessage): void;
3243
- addUserMessage(content: string, metadata?: TUniversalMessageMetadata, parts?: TUniversalMessagePart[]): void;
3244
- addAssistantMessage(content: string | null, toolCalls?: IToolCall[], metadata?: TUniversalMessageMetadata, parts?: TUniversalMessagePart[]): void;
3245
- addSystemMessage(content: string, metadata?: TUniversalMessageMetadata, parts?: TUniversalMessagePart[]): void;
3246
- addToolMessage(content: string, toolCallId: string, toolName?: string, metadata?: TUniversalMessageMetadata, parts?: TUniversalMessagePart[]): void;
3247
- addToolMessageWithId(content: string, toolCallId: string, toolName: string, metadata?: TUniversalMessageMetadata, parts?: TUniversalMessagePart[]): void;
3248
- /** Add a raw history entry (events, etc.) */
3249
- addEntry(entry: IHistoryEntry): void;
3250
- /** Get all history entries (universal timeline) */
3251
- getHistory(): IHistoryEntry[];
3252
- getMessages(): TUniversalMessage[];
3253
- getMessagesByRole(role: TUniversalMessageRole): TUniversalMessage[];
3254
- getRecentMessages(count: number): TUniversalMessage[];
3255
- getMessageCount(): number;
3256
- /** Begin a new assistant response. Must be called before provider call.
3257
- * Ensures pendingAssistant exists so commitAssistant always has data to save. */
3258
- beginAssistant(): void;
3259
- /** Append streaming text delta to pending assistant response */
3260
- appendStreaming(delta: string): void;
3261
- /** Append a tool call to pending assistant response (deduplicates by id) */
3262
- appendToolCall(toolCall: IToolCall): void;
3263
- /**
3264
- * Commit pending assistant response to history.
3265
- * Precondition: beginAssistant() must have been called before the provider call.
3266
- * History is append-only — this always adds a message.
3267
- */
3268
- commitAssistant(state: TMessageState, metadata?: TUniversalMessageMetadata): void;
3269
- /** Discard pending assistant response without saving */
3270
- discardPending(): void;
3271
- /** Returns true if there is accumulated pending assistant state (streaming or tool calls) */
3272
- hasPendingAssistant(): boolean;
3273
- /** Get pending assistant content (empty string if no content streamed yet) */
3274
- getPendingContent(): string;
3275
- getMessagesForAPI(): IProviderApiMessage[];
3276
- clear(): void;
3277
- }
3278
- //#endregion
3279
- //#region src/managers/conversation-message-factory.d.ts
3280
- /** Create a user message. */
3281
- declare function createUserMessage(content: string, options?: {
3282
- name?: string;
3283
- metadata?: TUniversalMessageMetadata;
3284
- parts?: TUniversalMessagePart[];
3285
- }): IUserMessage;
3286
- /** Create an assistant message. */
3287
- declare function createAssistantMessage(content: string | null, options?: {
3288
- toolCalls?: IToolCall[];
3289
- metadata?: TUniversalMessageMetadata;
3290
- parts?: TUniversalMessagePart[];
3291
- state?: TMessageState;
3292
- }): IAssistantMessage;
3293
- /** Create a system message. */
3294
- declare function createSystemMessage(content: string, options?: {
3295
- name?: string;
3296
- metadata?: TUniversalMessageMetadata;
3297
- parts?: TUniversalMessagePart[];
3298
- }): ISystemMessage;
3299
- /** Create a tool message. */
3300
- declare function createToolMessage(content: string, options: {
3301
- toolCallId: string;
3302
- name?: string;
3303
- metadata?: TUniversalMessageMetadata;
3304
- parts?: TUniversalMessagePart[];
3305
- }): IToolMessage;
3306
- //#endregion
3307
- //#region src/managers/conversation-history-manager.d.ts
3308
- /** Interface for managing conversation history. @public */
3309
- interface IConversationHistory {
3310
- addMessage(message: TUniversalMessage): void;
3311
- addUserMessage(content: string, metadata?: TUniversalMessageMetadata, parts?: TUniversalMessagePart[]): void;
3312
- addAssistantMessage(content: string | null, toolCalls?: IToolCall[], metadata?: TUniversalMessageMetadata, parts?: TUniversalMessagePart[]): void;
3313
- addSystemMessage(content: string, metadata?: TUniversalMessageMetadata, parts?: TUniversalMessagePart[]): void;
3314
- addToolMessageWithId(content: string, toolCallId: string, toolName: string, metadata?: TUniversalMessageMetadata, parts?: TUniversalMessagePart[]): void;
3315
- addEntry(entry: IHistoryEntry): void;
3316
- getHistory(): IHistoryEntry[];
3317
- getMessages(): TUniversalMessage[];
3318
- getMessagesByRole(role: TUniversalMessageRole): TUniversalMessage[];
3319
- getRecentMessages(count: number): TUniversalMessage[];
3320
- clear(): void;
3321
- getMessageCount(): number;
3322
- }
3323
- /** Configuration options for ConversationHistory manager */
3324
- interface IConversationHistoryOptions {
3325
- maxMessagesPerConversation?: number;
3326
- maxConversations?: number;
3327
- }
3328
- /** Multi-session conversation history manager. @public */
3329
- declare class ConversationHistory {
3330
- private conversations;
3331
- private logger;
3332
- private readonly maxMessagesPerConversation;
3333
- private readonly maxConversations;
3334
- constructor(options?: IConversationHistoryOptions);
3335
- getConversationStore(conversationId: string): ConversationStore;
3336
- hasConversation(conversationId: string): boolean;
3337
- removeConversation(conversationId: string): boolean;
3338
- clearAll(): void;
3339
- getStats(): {
3340
- totalConversations: number;
3341
- conversationIds: string[];
3342
- totalMessages: number;
3343
- };
3344
- /** @internal */
3345
- private cleanupOldConversations;
3346
- }
3347
- //#endregion
3348
- //#region src/executors/local-executor.d.ts
3349
- /**
3350
- * Local executor that directly delegates to AI provider instances
3351
- *
3352
- * This executor maintains a registry of AI provider instances and delegates
3353
- * chat execution requests to the appropriate provider based on the provider
3354
- * name in the request. This is the "traditional" execution mode where
3355
- * API calls are made directly from the client.
3356
- *
3357
- * @example
3358
- * ```typescript
3359
- * import { LocalExecutor } from '@robota-sdk/agent-core';
3360
- * import { OpenAIProvider } from '@robota-sdk/agent-provider/openai';
3361
- *
3362
- * const executor = new LocalExecutor();
3363
- * executor.registerProvider('openai', new OpenAIProvider({ apiKey: 'sk-...' }));
3364
- *
3365
- * const response = await executor.executeChat({
3366
- * messages: [{ role: 'user', content: 'Hello!' }],
3367
- * provider: 'openai',
3368
- * model: 'gpt-4'
3369
- * });
3370
- * ```
3371
- */
3372
- declare class LocalExecutor extends AbstractExecutor {
3373
- readonly name = "local";
3374
- readonly version = "1.0.0";
3375
- private providers;
3376
- private config;
3377
- constructor(config?: ILocalExecutorConfig);
3378
- /**
3379
- * Register an AI provider instance for use with this executor
3380
- *
3381
- * @param name - Provider name (e.g., 'openai', 'anthropic', 'google')
3382
- * @param provider - Provider instance that implements the required chat methods
3383
- */
3384
- registerProvider(name: string, provider: IAIProviderInstance): void;
3385
- /**
3386
- * Unregister an AI provider
3387
- *
3388
- * @param name - Provider name to remove
3389
- */
3390
- unregisterProvider(name: string): void;
3391
- /**
3392
- * Get registered provider instance
3393
- *
3394
- * @param name - Provider name
3395
- * @returns Provider instance or undefined if not registered
3396
- */
3397
- getProvider(name: string): IAIProviderInstance | undefined;
3398
- /**
3399
- * Execute a chat completion request by delegating to the appropriate provider
3400
- */
3401
- executeChat(request: IChatExecutionRequest): Promise<IAssistantMessage>;
3402
- /**
3403
- * Execute a streaming chat completion request
3404
- */
3405
- executeChatStream(request: IStreamExecutionRequest): AsyncIterable<TUniversalMessage>;
3406
- /**
3407
- * Check if any registered providers support tools
3408
- */
3409
- supportsTools(): boolean;
3410
- /**
3411
- * Validate executor configuration and all registered providers
3412
- */
3413
- validateConfig(): boolean;
3414
- /**
3415
- * Clean up all registered providers
3416
- */
3417
- dispose(): Promise<void>;
3418
- }
3419
- /**
3420
- * Interface that AI provider instances must implement to work with LocalExecutor
3421
- *
3422
- * This interface represents the subset of AI provider methods that LocalExecutor
3423
- * needs to delegate to. It's designed to be compatible with existing BaseAIProvider
3424
- * implementations from @robota-sdk packages.
3425
- */
3426
- interface IAIProviderInstance {
3427
- /** Provider name */
3428
- readonly name?: string;
3429
- /** Chat completion method */
3430
- chat?(messages: TUniversalMessage[], options?: IChatOptions): Promise<TUniversalMessage>;
3431
- /** Streaming chat completion method */
3432
- chatStream?(messages: TUniversalMessage[], options?: IChatOptions): AsyncIterable<TUniversalMessage>;
3433
- /** Check if provider supports tools */
3434
- supportsTools?(): boolean;
3435
- /** Validate provider configuration */
3436
- validateConfig?(): boolean;
3437
- /** Clean up provider resources */
3438
- dispose?(): Promise<void>;
3439
- }
3440
- //#endregion
3441
- //#region src/utils/env-ref.d.ts
3442
- declare const ENV_REFERENCE_PREFIX = "$ENV:";
3443
- declare function isEnvReference(value: string): boolean;
3444
- declare function formatEnvReference(name: string): string;
3445
- declare function resolveEnvReference(value: string): string | undefined;
3446
- declare function hasUsableSecretReference(value: string | undefined): boolean;
3447
- //#endregion
3448
- //#region src/plugins/event-emitter/metrics.d.ts
3449
- interface IEventEmitterMetricsSnapshot {
3450
- totalEmitted: number;
3451
- totalErrors: number;
3452
- }
3453
- interface IEventEmitterMetrics {
3454
- incrementEmitted(): void;
3455
- incrementErrors(): void;
3456
- getSnapshot(): IEventEmitterMetricsSnapshot;
3457
- }
3458
- declare class InMemoryEventEmitterMetrics implements IEventEmitterMetrics {
3459
- private totalEmitted;
3460
- private totalErrors;
3461
- incrementEmitted(): void;
3462
- incrementErrors(): void;
3463
- getSnapshot(): IEventEmitterMetricsSnapshot;
3464
- }
3465
- //#endregion
3466
- //#region src/plugins/event-emitter/plugin-types.d.ts
3467
- /** Enhanced event data for hierarchical execution tracking */
3468
- interface IEventEmitterHierarchicalEventData extends IEventEmitterEventData {
3469
- parentExecutionId?: string;
3470
- rootExecutionId?: string;
3471
- executionLevel: number;
3472
- executionPath: string[];
3473
- realTimeData?: {
3474
- startTime: Date;
3475
- actualDuration?: number;
3476
- actualParameters?: TToolParameters;
3477
- actualResult?: IToolResult;
3478
- };
3479
- }
3480
- /** Event emitter configuration */
3481
- interface IEventEmitterPluginOptions extends IPluginOptions {
3482
- events?: TEventName[];
3483
- maxListeners?: number;
3484
- async?: boolean;
3485
- catchErrors?: boolean;
3486
- filters?: Record<TEventName, (event: IEventEmitterEventData) => boolean>;
3487
- buffer?: {
3488
- enabled: boolean;
3489
- maxSize: number;
3490
- flushInterval: number;
3491
- };
3492
- metrics?: IEventEmitterMetrics;
3493
- }
3494
- /** Event emitter plugin statistics */
3495
- interface IEventEmitterPluginStats extends IPluginStats {
3496
- eventTypes: TEventName[];
3497
- listenerCounts: Partial<Record<TEventName, number>>;
3498
- totalListeners: number;
3499
- bufferedEvents: number;
3500
- totalEmitted: number;
3501
- totalErrors: number;
3502
- }
3503
- //#endregion
3504
- //#region src/plugins/event-emitter-plugin.d.ts
3505
- /** Provides pub/sub event coordination during the agent execution lifecycle. */
3506
- declare class EventEmitterPlugin extends AbstractPlugin<IEventEmitterPluginOptions, IEventEmitterPluginStats> {
3507
- name: string;
3508
- version: string;
3509
- private pluginOptions;
3510
- private logger;
3511
- private handlers;
3512
- private eventBuffer;
3513
- private nextHandlerId;
3514
- private bufferTimer?;
3515
- private metrics;
3516
- constructor(options?: IEventEmitterPluginOptions);
3517
- beforeExecution(context: IPluginExecutionContext): Promise<void>;
3518
- afterExecution(context: IPluginExecutionContext, result: IPluginExecutionResult): Promise<void>;
3519
- beforeConversation(context: IPluginExecutionContext): Promise<void>;
3520
- afterConversation(context: IPluginExecutionContext, result: IPluginExecutionResult): Promise<void>;
3521
- beforeToolExecution(context: IPluginExecutionContext, toolData: IToolExecutionContext): Promise<void>;
3522
- afterToolExecution(context: IPluginExecutionContext, toolResults: IPluginExecutionResult): Promise<void>;
3523
- onError(error: Error, context?: IPluginErrorContext): Promise<void>;
3524
- on(eventType: TEventName, listener: TEventEmitterListener, options?: {
3525
- once?: boolean;
3526
- filter?: (event: IEventEmitterEventData) => boolean;
3527
- }): string;
3528
- once(eventType: TEventName, listener: TEventEmitterListener, filter?: (event: IEventEmitterEventData) => boolean): string;
3529
- off(eventType: TEventName, handlerIdOrListener: string | TEventEmitterListener): boolean;
3530
- emit(eventType: TEventName, eventData?: Partial<IEventEmitterEventData>): Promise<void>;
3531
- private processEvent;
3532
- flushBuffer(): Promise<void>;
3533
- getStats(): IEventEmitterPluginStats;
3534
- clearAllListeners(): void;
3535
- destroy(): Promise<void>;
3536
- }
3537
- //#endregion
3538
- //#region src/core/robota-types.d.ts
3539
- /** Shared model configuration shape used in setModel / getModel. */
3540
- interface IModelConfig {
3541
- provider: string;
3542
- model: string;
3543
- temperature?: number;
3544
- maxTokens?: number;
3545
- topP?: number;
3546
- systemMessage?: string;
3547
- /** Reasoning effort tier read per-call by the execution round (PRESET-013 live re-application channel). */
3548
- effort?: TModelEffort;
3549
- }
3550
- /** Return shape of getConfiguration(). */
3551
- interface IConfigurationSnapshot {
3552
- version: number;
3553
- tools: Array<{
3554
- name: string;
3555
- parameters?: string[];
3556
- }>;
3557
- updatedAt: number;
3558
- }
3559
- /** Return shape of getModuleStats(). */
3560
- type TModuleStats = {
3561
- totalExecutions: number;
3562
- successfulExecutions: number;
3563
- failedExecutions: number;
3564
- averageExecutionTime: number;
3565
- lastExecutionTime?: Date;
3566
- } | undefined;
3567
- type TRegisterModuleOptions = {
3568
- autoInitialize?: boolean;
3569
- validateDependencies?: boolean;
3570
- };
3571
- type TExecuteModuleContext = {
3572
- executionId?: string;
3573
- sessionId?: string;
3574
- userId?: string;
3575
- metadata?: Record<string, string | number | boolean | Date>;
3576
- };
3577
- type TExecuteModuleResult = {
3578
- success: boolean;
3579
- data?: IModuleResultData;
3580
- error?: Error;
3581
- duration?: number;
3582
- };
3583
- //#endregion
3584
- //#region src/core/robota-base.d.ts
3585
- type TPlugin = IPluginContract<IPluginOptions, IPluginStats> & IPluginHooks;
3586
- interface IModuleManagerProxy {
3587
- registerModule(module: IModule, options?: TRegisterModuleOptions): Promise<void>;
3588
- unregisterModule(moduleName: string): Promise<boolean>;
3589
- getModule(moduleName: string): IModule | undefined;
3590
- getModulesByType(moduleType: string): IModule[];
3591
- getModules(): IModule[];
3592
- getModuleNames(): string[];
3593
- hasModule(moduleName: string): boolean;
3594
- executeModule(moduleName: string, context: TExecuteModuleContext): Promise<TExecuteModuleResult>;
3595
- getModuleStats(moduleName: string): TModuleStats;
3596
- }
3597
- interface IPluginManagerProxy {
3598
- addPlugin(plugin: TPlugin): void;
3599
- removePlugin(pluginName: string): boolean;
3600
- getPlugin(pluginName: string): TPlugin | undefined;
3601
- getPlugins(): TPlugin[];
3602
- getPluginNames(): string[];
3603
- }
3604
- declare abstract class RobotaBase extends AbstractAgent<IAgentConfig, IRunOptions, TUniversalMessage> {
3605
- protected moduleManager: IModuleManagerProxy;
3606
- protected pluginManager: IPluginManagerProxy;
3607
- addPlugin(plugin: TPlugin): void;
3608
- removePlugin(pluginName: string): boolean;
3609
- getPlugin(pluginName: string): TPlugin | undefined;
3610
- getPlugins(): TPlugin[];
3611
- getPluginNames(): string[];
3612
- registerModule(module: IModule, options?: TRegisterModuleOptions): Promise<void>;
3613
- unregisterModule(moduleName: string): Promise<boolean>;
3614
- getModule(moduleName: string): IModule | undefined;
3615
- getModulesByType(moduleType: string): IModule[];
3616
- getModules(): IModule[];
3617
- getModuleNames(): string[];
3618
- hasModule(moduleName: string): boolean;
3619
- executeModule(moduleName: string, context: TExecuteModuleContext): Promise<TExecuteModuleResult>;
3620
- getModuleStats(moduleName: string): TModuleStats;
3621
- }
3622
- //#endregion
3623
- //#region src/managers/ai-provider-manager.d.ts
3624
- /**
3625
- * AI Provider Manager - manages AI provider instances
3626
- * Manages registration, selection, and state of AI providers
3627
- * Instance-based for isolated provider management
3628
- * @internal
3629
- */
3630
- declare class AIProviders extends AbstractManager implements IAIProviderManager {
3631
- private providers;
3632
- private currentProvider;
3633
- private currentModel;
3634
- constructor();
3635
- /**
3636
- * Initialize the manager
3637
- */
3638
- protected doInitialize(): Promise<void>;
3639
- /**
3640
- * Cleanup manager resources
3641
- */
3642
- protected doDispose(): Promise<void>;
3643
- /**
3644
- * Register an AI provider
3645
- */
3646
- addProvider(name: string, provider: IAIProvider): void;
3647
- /**
3648
- * Remove an AI provider
3649
- */
3650
- removeProvider(name: string): void;
3651
- /**
3652
- * Get registered provider by name
3653
- */
3654
- getProvider(name: string): IAIProvider | undefined;
3655
- /**
3656
- * Get all registered providers
3657
- */
3658
- getProviders(): Record<string, IAIProvider>;
3659
- /**
3660
- * Set current provider and model
3661
- */
3662
- setCurrentProvider(name: string, model: string): void;
3663
- /**
3664
- * Get current provider and model
3665
- */
3666
- getCurrentProvider(): {
3667
- provider: string;
3668
- model: string;
3669
- } | undefined;
3670
- /**
3671
- * Check if provider is configured
3672
- */
3673
- isConfigured(): boolean;
3674
- /**
3675
- * Get current provider instance
3676
- */
3677
- getCurrentProviderInstance(): IAIProvider | undefined;
3678
- /**
3679
- * Get provider names
3680
- */
3681
- getProviderNames(): string[];
3682
- /**
3683
- * Get providers by pattern
3684
- */
3685
- getProvidersByPattern(pattern: string | RegExp): Record<string, IAIProvider>;
3686
- /**
3687
- * Check if provider supports streaming
3688
- */
3689
- supportsStreaming(providerName?: string): boolean;
3690
- /**
3691
- * Get provider count
3692
- */
3693
- getProviderCount(): number;
3694
- }
3695
- //#endregion
3696
- //#region src/tool-registry/tool-registry.d.ts
3697
- /**
3698
- * Tool registry implementation
3699
- * Manages tool registration, validation, and retrieval
3700
- */
3701
- declare class ToolRegistry implements IToolRegistry {
3702
- private tools;
3703
- /**
3704
- * Register a tool
3705
- */
3706
- register(tool: ITool): void;
3707
- /**
3708
- * Unregister a tool
3709
- */
3710
- unregister(name: string): void;
3711
- /**
3712
- * Get tool by name
3713
- */
3714
- get(name: string): ITool | undefined;
3715
- /**
3716
- * Get all registered tools
3717
- */
3718
- getAll(): ITool[];
3719
- /**
3720
- * Get tool schemas
3721
- */
3722
- getSchemas(): IToolSchema[];
3723
- /**
3724
- * Check if tool exists
3725
- */
3726
- has(name: string): boolean;
3727
- /**
3728
- * Clear all tools
3729
- */
3730
- clear(): void;
3731
- /**
3732
- * Get tool names
3733
- */
3734
- getToolNames(): string[];
3735
- /**
3736
- * Get tools by pattern
3737
- */
3738
- getToolsByPattern(pattern: string | RegExp): ITool[];
3739
- /**
3740
- * Get tool count
3741
- */
3742
- size(): number;
3743
- /**
3744
- * Validate tool schema
3745
- */
3746
- private validateToolSchema;
3747
- }
3748
- //#endregion
3749
- //#region src/managers/tool-manager.d.ts
3750
- /**
3751
- * Tool Manager - manages tool registration and execution
3752
- * Manages tool registration and execution using Tool Registry
3753
- * Instance-based for isolated tool management
3754
- * @internal
3755
- */
3756
- declare class Tools extends AbstractManager implements IToolManager {
3757
- private registry;
3758
- private allowedTools?;
3759
- constructor();
3760
- /**
3761
- * Initialize the manager
3762
- */
3763
- protected doInitialize(): Promise<void>;
3764
- /**
3765
- * Cleanup manager resources
3766
- */
3767
- protected doDispose(): Promise<void>;
3768
- /**
3769
- * Register a tool with schema and executor function
3770
- */
3771
- addTool(schema: IToolSchema, executor: TToolExecutor): void;
3772
- /**
3773
- * Remove a tool by name
3774
- */
3775
- removeTool(name: string): void;
3776
- /**
3777
- * Get tool interface by name
3778
- */
3779
- getTool(name: string): ITool | undefined;
3780
- /**
3781
- * Get tool schema by name
3782
- */
3783
- getToolSchema(name: string): IToolSchema | undefined;
3784
- /**
3785
- * Get all registered tool schemas
3786
- */
3787
- getTools(): IToolSchema[];
3788
- /**
3789
- * Execute a tool with parameters
3790
- */
3791
- executeTool(name: string, parameters: TToolParameters, context?: IToolExecutionContext): Promise<TUniversalValue>;
3792
- /**
3793
- * Check if tool exists
3794
- */
3795
- hasTool(name: string): boolean;
3796
- /**
3797
- * Set allowed tools for filtering
3798
- */
3799
- setAllowedTools(tools: string[]): void;
3800
- /**
3801
- * Get allowed tools
3802
- */
3803
- getAllowedTools(): string[] | undefined;
3804
- /**
3805
- * Get tool registry instance (for advanced operations)
3806
- */
3807
- getRegistry(): ToolRegistry;
3808
- /**
3809
- * Get tool count
3810
- */
3811
- getToolCount(): number;
3812
- }
3813
- //#endregion
3814
- //#region src/core/robota-config-manager.d.ts
3815
- /** Agent statistics metadata type */
3816
- type TAgentStatsMetadata = Record<string, string | number | boolean | Date | string[]>;
3817
- //#endregion
3818
- //#region src/services/execution-constants.d.ts
3819
- /**
3820
- * ExecutionService owned events.
3821
- * Local event names only (no dots). Full names are composed at emit time.
3822
- */
3823
- declare const EXECUTION_EVENTS: {
3824
- readonly START: "start";
3825
- readonly COMPLETE: "complete";
3826
- readonly ERROR: "error";
3827
- readonly ASSISTANT_MESSAGE_START: "assistant_message_start";
3828
- readonly ASSISTANT_MESSAGE_COMPLETE: "assistant_message_complete";
3829
- readonly USER_MESSAGE: "user_message";
3830
- readonly TOOL_RESULTS_TO_LLM: "tool_results_to_llm";
3831
- readonly TOOL_RESULTS_READY: "tool_results_ready";
3832
- };
3833
- declare const EXECUTION_EVENT_PREFIX: "execution";
3834
- //#endregion
3835
- //#region src/core/robota-lifecycle.d.ts
3836
- /** Dependencies required by getStats. @internal */
3837
- interface IRobotaStatsDeps {
3838
- readonly name: string;
3839
- readonly version: string;
3840
- readonly conversationId: string;
3841
- readonly startTime: number;
3842
- readonly isFullyInitialized: boolean;
3843
- aiProviders: AIProviders;
3844
- tools: Tools;
3845
- getPluginNames(): string[];
3846
- getModuleNames(): string[];
3847
- getHistory(): TUniversalMessage[];
3848
- }
3849
- /** Build comprehensive agent statistics. @internal */
3850
- declare function buildAgentStats(deps: IRobotaStatsDeps): {
3851
- name: string;
3852
- version: string;
3853
- conversationId: string;
3854
- providers: string[];
3855
- currentProvider: string | null;
3856
- tools: string[];
3857
- plugins: string[];
3858
- modules: string[];
3859
- historyLength: number;
3860
- historyStats: TAgentStatsMetadata;
3861
- uptime: number;
3862
- };
3863
- //#endregion
3864
- //#region src/core/robota.d.ts
3865
- /** @public */
3866
- declare class Robota extends RobotaBase implements IAgent<IAgentConfig, IRunOptions, TUniversalMessage> {
3867
- readonly name: string;
3868
- readonly version: string;
3869
- private aiProviders;
3870
- private tools;
3871
- private agentFactory;
3872
- private conversationHistory;
3873
- private moduleRegistry;
3874
- private eventEmitter;
3875
- private executionService;
3876
- private eventService;
3877
- private agentEventService;
3878
- protected config: IAgentConfig;
3879
- private conversationId;
3880
- private logger;
3881
- private initializationPromise?;
3882
- private isFullyInitialized;
3883
- private startTime;
3884
- private configVersion;
3885
- private configUpdatedAt;
3886
- private configManager;
3887
- constructor(config: IAgentConfig);
3888
- /**
3889
- * Ensure the agent is fully initialized (providers registered, current provider set, execution
3890
- * service built) WITHOUT running a turn. Idempotent. Lets callers that mutate runtime
3891
- * configuration before the first `run()` (e.g. live preset/model switching on a fresh
3892
- * interactive session) bring the agent to a ready state first, instead of failing the
3893
- * "must be fully initialized" guard.
3894
- */
3895
- ensureReady(): Promise<void>;
3896
- run(input: string, options?: IRunOptions): Promise<string>;
3897
- runStream(input: string, options?: IRunOptions): AsyncGenerator<string, void, undefined>;
3898
- private executionDeps;
3899
- getHistory(): TUniversalMessage[];
3900
- getFullHistory(): IHistoryEntry[];
3901
- addHistoryEntry(entry: IHistoryEntry): void;
3902
- clearHistory(): void;
3903
- injectMessage(role: 'user' | 'assistant' | 'system' | 'tool', content: string, options?: {
3904
- toolCallId?: string;
3905
- name?: string;
3906
- }): void;
3907
- injectRawMessage(msg: TUniversalMessage): void;
3908
- updateTools(next: Array<IToolWithEventService>): Promise<{
3909
- version: number;
3910
- }>;
3911
- updateConfiguration(patch: Partial<IAgentConfig>): Promise<{
3912
- version: number;
3913
- }>;
3914
- getConfiguration(): Promise<IConfigurationSnapshot>;
3915
- setModel(mc: IModelConfig): void;
3916
- getModel(): IModelConfig;
3917
- registerTool(tool: AbstractTool): void;
3918
- unregisterTool(toolName: string): void;
3919
- getConfig(): IAgentConfig;
3920
- swapDefaultProvider(newProvider: IAIProvider, model: string): void;
3921
- getStats(): ReturnType<typeof buildAgentStats>;
3922
- destroy(): Promise<void>;
3923
- protected initialize(): Promise<void>;
3924
- private ensureFullyInitialized;
3925
- private doAsyncInit;
3926
- private emitAgentEvent;
3927
- }
3928
- //#endregion
3929
- //#region src/managers/agent-factory-helpers.d.ts
3930
- /**
3931
- * Configuration options for AgentFactory
3932
- */
3933
- interface IAgentFactoryOptions {
3934
- /** Default model to use if not specified in config */
3935
- defaultModel?: string;
3936
- /** Default provider to use if not specified in config */
3937
- defaultProvider?: string;
3938
- /** Maximum number of concurrent agents */
3939
- maxConcurrentAgents?: number;
3940
- /** Default system message for agents */
3941
- defaultSystemMessage?: string;
3942
- /** Enable strict configuration validation */
3943
- strictValidation?: boolean;
3944
- }
3945
- /**
3946
- * Agent creation statistics
3947
- */
3948
- interface IAgentCreationStats {
3949
- /** Total number of agents created */
3950
- totalCreated: number;
3951
- /** Number of currently active agents */
3952
- activeCount: number;
3953
- /** Number of agents created from templates */
3954
- fromTemplates: number;
3955
- /** Number of custom configured agents */
3956
- customConfigured: number;
3957
- /** Template vs custom creation ratio (fromTemplates / totalCreated) */
3958
- templateUsageRatio: number;
3959
- }
3960
- /**
3961
- * Agent lifecycle events
3962
- */
3963
- interface IAgentLifecycleEvents {
3964
- /** Called before agent creation */
3965
- beforeCreate?: (config: IAgentConfig) => Promise<void> | void;
3966
- /** Called after successful agent creation */
3967
- afterCreate?: (agent: IAgent<IAgentConfig>, config: IAgentConfig) => Promise<void> | void;
3968
- /** Called when agent creation fails */
3969
- onCreateError?: (error: Error, config: IAgentConfig) => Promise<void> | void;
3970
- /** Called when agent is destroyed */
3971
- onDestroy?: (agentId: string) => Promise<void> | void;
3972
- }
3973
- //#endregion
3974
- //#region src/managers/agent-templates.d.ts
3975
- /**
3976
- * Template application result
3977
- */
3978
- interface ITemplateApplicationResult {
3979
- /** Applied configuration */
3980
- config: IAgentConfig;
3981
- /** Template that was applied */
3982
- template: IAgentTemplate;
3983
- /** Any warnings during application */
3984
- warnings: string[];
3985
- /** Whether config was modified during application */
3986
- modified: boolean;
3987
- }
3988
- /**
3989
- * Agent Templates implementation
3990
- * Manages agent templates for AgentFactory
3991
- * Instance-based for isolated template management
3992
- */
3993
- declare class AgentTemplates {
3994
- private templates;
3995
- private logger;
3996
- constructor();
3997
- /**
3998
- * Register a template
3999
- */
4000
- registerTemplate(template: IAgentTemplate): void;
4001
- /**
4002
- * Unregister a template
4003
- */
4004
- unregisterTemplate(templateId: string): boolean;
4005
- /**
4006
- * Get all templates
4007
- */
4008
- getTemplates(): IAgentTemplate[];
4009
- /**
4010
- * Get template by ID
4011
- */
4012
- getTemplate(templateId: string): IAgentTemplate | undefined;
4013
- /**
4014
- * Find templates by criteria
4015
- */
4016
- findTemplates(criteria: {
4017
- category?: string;
4018
- tags?: string[];
4019
- provider?: string;
4020
- model?: string;
4021
- }): IAgentTemplate[];
4022
- /**
4023
- * Apply template to configuration
4024
- */
4025
- applyTemplate(template: IAgentTemplate, overrides?: Partial<IAgentConfig>): ITemplateApplicationResult;
4026
- /**
4027
- * Check if template exists
4028
- */
4029
- hasTemplate(templateId: string): boolean;
4030
- /**
4031
- * Get template count
4032
- */
4033
- getTemplateCount(): number;
4034
- /**
4035
- * Clear all templates
4036
- */
4037
- clearAll(): void;
4038
- /**
4039
- * Get template statistics
4040
- */
4041
- getStats(): {
4042
- totalTemplates: number;
4043
- categories: string[];
4044
- tags: string[];
4045
- providers: string[];
4046
- models: string[];
4047
- };
4048
- }
4049
- //#endregion
4050
- //#region src/managers/agent-factory.d.ts
4051
- /**
4052
- * Agent Factory for creating and managing agents
4053
- * Instance-based for isolated agent factory management
4054
- */
4055
- declare class AgentFactory {
4056
- private agentTemplates;
4057
- private initialized;
4058
- private logger;
4059
- private options;
4060
- private activeAgents;
4061
- private creationStats;
4062
- private lifecycleEvents;
4063
- constructor(options?: IAgentFactoryOptions, lifecycleEvents?: IAgentLifecycleEvents);
4064
- /**
4065
- * Initialize the factory
4066
- */
4067
- initialize(): Promise<void>;
4068
- /**
4069
- * Create a new agent instance
4070
- */
4071
- createAgent(AgentClass: new (config: IAgentConfig) => IAgent<IAgentConfig>, config: Partial<IAgentConfig>, fromTemplate?: boolean): Promise<IAgent<IAgentConfig>>;
4072
- /**
4073
- * Create agent from template
4074
- */
4075
- createFromTemplate(AgentClass: new (config: IAgentConfig) => IAgent<IAgentConfig>, templateId: string, overrides?: Partial<IAgentConfig>): Promise<IAgent<IAgentConfig>>;
4076
- /**
4077
- * Register a template
4078
- */
4079
- registerTemplate(template: IAgentTemplate): void;
4080
- /**
4081
- * Unregister a template
4082
- */
4083
- unregisterTemplate(templateId: string): boolean;
4084
- /**
4085
- * Get all templates
4086
- */
4087
- getTemplates(): IAgentTemplate[];
4088
- /**
4089
- * Get template by ID
4090
- */
4091
- getTemplate(templateId: string): IAgentTemplate | undefined;
4092
- /**
4093
- * Find templates by criteria
4094
- */
4095
- findTemplates(criteria: {
4096
- category?: string;
4097
- tags?: string[];
4098
- provider?: string;
4099
- model?: string;
4100
- }): IAgentTemplate[];
4101
- /**
4102
- * Apply template to configuration
4103
- */
4104
- applyTemplate(template: IAgentTemplate, overrides?: Partial<IAgentConfig>): ITemplateApplicationResult;
4105
- /**
4106
- * Destroy an agent
4107
- */
4108
- destroyAgent(agentId: string): Promise<boolean>;
4109
- /**
4110
- * Get creation statistics
4111
- */
4112
- getCreationStats(): IAgentCreationStats;
4113
- /**
4114
- * Get all active agents
4115
- */
4116
- getActiveAgents(): Map<string, IAgent<IAgentConfig>>;
4117
- /**
4118
- * Validate agent configuration
4119
- */
4120
- validateConfiguration(config: Partial<IAgentConfig>): {
4121
- isValid: boolean;
4122
- errors: string[];
4123
- };
4124
- }
4125
- //#endregion
4126
- //#region src/services/execution-usage.d.ts
4127
- interface IAssistantUsageMetadata {
4128
- inputTokens: number;
4129
- outputTokens: number;
4130
- usage: {
4131
- totalTokens: number;
4132
- inputTokens: number;
4133
- outputTokens: number;
4134
- };
4135
- }
4136
- declare function collectAssistantUsageMetadata(message: TUniversalMessage): IAssistantUsageMetadata | undefined;
4137
- //#endregion
4138
- //#region src/services/history-module.d.ts
4139
- declare class EventHistoryModule implements IEventHistoryModule {
4140
- private readonly store;
4141
- private readonly listener;
4142
- private sequenceId;
4143
- constructor(store: IEventHistoryModule, eventService: IEventService);
4144
- append(record: IEventHistoryRecord): void;
4145
- read(fromSequenceId: number, toSequenceId?: number): IEventHistoryRecord[];
4146
- readStream(fromSequenceId: number, toSequenceId?: number): AsyncIterable<IEventHistoryRecord>;
4147
- getSnapshot(): IEventHistorySnapshot | undefined;
4148
- detach(eventService: IEventService): void;
4149
- private nextSequenceId;
4150
- }
4151
- //#endregion
4152
- //#region src/services/tool-execution-service.d.ts
4153
- /**
4154
- * ToolExecutionService owned events
4155
- * Local event names only (no dots). Full names are composed at emit time.
4156
- */
4157
- declare const TOOL_EVENTS: {
4158
- readonly CALL_START: "call_start";
4159
- readonly CALL_COMPLETE: "call_complete";
4160
- readonly CALL_ERROR: "call_error";
4161
- readonly CALL_RESPONSE_READY: "call_response_ready";
4162
- };
4163
- declare const TOOL_EVENT_PREFIX: "tool";
4164
- //#endregion
4165
- //#region src/agents/constants.d.ts
4166
- /**
4167
- * Agent event constants
4168
- *
4169
- * Events emitted by Agent instances themselves.
4170
- * Event names are local (no dots) and must be used via constants (no string literals).
4171
- */
4172
- declare const AGENT_EVENTS: {
4173
- /** Agent instance has been created and initialized */readonly CREATED: "created"; /** Agent execution lifecycle - start */
4174
- readonly EXECUTION_START: "execution_start"; /** Agent execution lifecycle - complete */
4175
- readonly EXECUTION_COMPLETE: "execution_complete"; /** Agent execution lifecycle - error */
4176
- readonly EXECUTION_ERROR: "execution_error"; /** Agent aggregation process completed */
4177
- readonly AGGREGATION_COMPLETE: "aggregation_complete"; /** Agent configuration (e.g., tools) has been updated by the agent */
4178
- readonly CONFIG_UPDATED: "config_updated";
4179
- };
4180
- declare const AGENT_EVENT_PREFIX: "agent";
4181
- //#endregion
4182
- //#region src/interfaces/workflow-converter.d.ts
4183
- /**
4184
- * Workflow configuration - uses base type for cross-converter compatibility
4185
- * Step 1: ❌ Can't assign number/boolean to config value type directly (index signature conflict)
4186
- * Step 2: ✅ TConfigValue already includes primitive types (number, boolean)
4187
- * Step 3: ✅ Fix index signature to allow optional properties
4188
- * Step 4: ✅ Use proper intersection type for compatibility
4189
- */
4190
- interface IWorkflowConfig {
4191
- timeout?: number;
4192
- retries?: number;
4193
- validateInput?: boolean;
4194
- validateOutput?: boolean;
4195
- [key: string]: TConfigValue | undefined;
4196
- }
4197
- /**
4198
- * Workflow metadata - uses base type for cross-converter compatibility
4199
- * Step 1: ❌ Can't assign Date/number/string to metadata value type directly (index signature conflict)
4200
- * Step 2: ✅ TMetadataValue already includes Date, primitive types
4201
- * Step 3: ✅ Fix index signature to allow optional properties
4202
- * Step 4: ✅ Use proper intersection type for compatibility
4203
- */
4204
- interface IWorkflowMetadata {
4205
- convertedAt?: Date;
4206
- processingTime?: number;
4207
- executionId?: string;
4208
- [key: string]: TMetadataValue | undefined;
4209
- }
4210
- /**
4211
- * Base workflow data constraint with flexible typing
4212
- * All workflow data must extend this interface for type safety
4213
- */
4214
- interface IWorkflowData {
4215
- readonly __workflowType?: string;
4216
- [key: string]: TUniversalValue | undefined;
4217
- }
4218
- /**
4219
- * Conversion options for workflow transformations
4220
- * Step 1: ❌ Can't assign IWorkflowConversionOptions to metadata value type (missing index signature)
4221
- * Step 2: ✅ Add index signature to make it compatible with MetadataValue
4222
- * Step 3: ✅ Maintain type safety while allowing metadata storage
4223
- * Step 4: ✅ Use MetadataValue compatibility for dynamic properties
4224
- */
4225
- interface IWorkflowConversionOptions {
4226
- /** Include debug information in output */
4227
- includeDebug?: boolean;
4228
- /** Validate input before conversion */
4229
- validateInput?: boolean;
4230
- /** Validate output after conversion */
4231
- validateOutput?: boolean;
4232
- /** Custom logger for conversion process */
4233
- logger?: ILogger;
4234
- /** Additional metadata to include */
4235
- metadata?: IWorkflowMetadata;
4236
- /** Platform-specific options */
4237
- platformOptions?: IWorkflowConfig;
4238
- /** Additional dynamic options compatible with TUniversalValue */
4239
- [key: string]: TUniversalValue | ILogger | IWorkflowMetadata | IWorkflowConfig | undefined;
4240
- }
4241
- /**
4242
- * Conversion result with metadata and validation info
4243
- */
4244
- interface IWorkflowConversionResult<TOutput> {
4245
- /** Converted workflow data — present only when success is true. */
4246
- data?: TOutput;
4247
- /** Conversion success status */
4248
- success: boolean;
4249
- /** Validation errors (if any) */
4250
- errors: string[];
4251
- /** Validation warnings (if any) */
4252
- warnings: string[];
4253
- /** Conversion metadata */
4254
- metadata: IWorkflowConversionResultMetadata;
4255
- }
4256
- /**
4257
- * Workflow conversion metadata.
4258
- *
4259
- * IMPORTANT:
4260
- * - Do NOT intersect this object with `TMetadata`.
4261
- * - `TMetadata` has an index signature with a restricted value axis (`TMetadataValue`),
4262
- * which would force every property on this object to be assignable to `TMetadataValue`.
4263
- * - Keep structured fields here, and store additional key/value pairs under `extensions`.
4264
- */
4265
- interface IWorkflowConversionResultMetadata {
4266
- /** Conversion timestamp */
4267
- convertedAt: Date;
4268
- /** Processing time in milliseconds */
4269
- processingTime: number;
4270
- /** Input data statistics */
4271
- inputStats: {
4272
- nodeCount: number;
4273
- edgeCount: number;
4274
- };
4275
- /** Output data statistics */
4276
- outputStats: {
4277
- nodeCount: number;
4278
- edgeCount: number;
4279
- };
4280
- /** Converter name */
4281
- converter: string;
4282
- /** Converter version */
4283
- version: string;
4284
- /** Conversion options (optional, typically gated by includeDebug) */
4285
- options?: IWorkflowConversionOptions;
4286
- /**
4287
- * Additional key/value metadata (SSOT axis).
4288
- * Use this for dynamic metadata, not top-level ad-hoc fields.
4289
- */
4290
- extensions?: TMetadata;
4291
- }
4292
- /**
4293
- * Workflow Converter Interface
4294
- *
4295
- * Core interface for converting between different workflow representations.
4296
- * All workflow converters must implement this interface.
4297
- *
4298
- * @template TInput - Input workflow data type
4299
- * @template TOutput - Output workflow data type
4300
- */
4301
- interface IWorkflowConverter<TInput extends IWorkflowData, TOutput extends IWorkflowData> {
4302
- /** Converter name for identification */
4303
- readonly name: string;
4304
- /** Converter version */
4305
- readonly version: string;
4306
- /** Source format that this converter accepts */
4307
- readonly sourceFormat: string;
4308
- /** Target format that this converter produces */
4309
- readonly targetFormat: string;
4310
- /**
4311
- * Convert workflow data from input format to output format
4312
- *
4313
- * @param input - Input workflow data
4314
- * @param options - Conversion options
4315
- * @returns Promise resolving to conversion result
4316
- */
4317
- convert(input: TInput, options?: IWorkflowConversionOptions): Promise<IWorkflowConversionResult<TOutput>>;
4318
- /**
4319
- * Validate input data before conversion
4320
- *
4321
- * @param input - Input workflow data
4322
- * @returns Promise resolving to validation result
4323
- */
4324
- validateInput(input: TInput): Promise<{
4325
- isValid: boolean;
4326
- errors: string[];
4327
- warnings: string[];
4328
- }>;
4329
- /**
4330
- * Validate output data after conversion
4331
- *
4332
- * @param output - Output workflow data
4333
- * @returns Promise resolving to validation result
4334
- */
4335
- validateOutput(output: TOutput): Promise<{
4336
- isValid: boolean;
4337
- errors: string[];
4338
- warnings: string[];
4339
- }>;
4340
- /**
4341
- * Check if this converter supports the given input format
4342
- *
4343
- * @param input - Input data to check
4344
- * @returns True if converter can handle this input
4345
- */
4346
- canConvert(input: IWorkflowData): input is TInput;
4347
- /**
4348
- * Get conversion statistics and metrics
4349
- *
4350
- * @returns Converter performance metrics
4351
- */
4352
- getStats(): {
4353
- totalConversions: number;
4354
- successfulConversions: number;
4355
- failedConversions: number;
4356
- averageProcessingTime: number;
4357
- lastConversionAt?: Date;
4358
- };
4359
- /**
4360
- * Reset converter statistics
4361
- */
4362
- resetStats(): void;
4363
- }
4364
- //#endregion
4365
- //#region src/interfaces/workflow-validator.d.ts
4366
- /**
4367
- * Validation severity levels
4368
- */
4369
- declare enum ValidationSeverity {
4370
- ERROR = "error",
4371
- WARNING = "warning",
4372
- INFO = "info"
4373
- }
4374
- /**
4375
- * Individual validation issue
4376
- */
4377
- interface IValidationIssue {
4378
- /** Unique identifier for this issue */
4379
- id: string;
4380
- /** Issue severity level */
4381
- severity: ValidationSeverity;
4382
- /** Human-readable message */
4383
- message: string;
4384
- /** Technical details or suggestion */
4385
- details?: string;
4386
- /** Location where issue was found */
4387
- location?: {
4388
- nodeId?: string;
4389
- edgeId?: string;
4390
- field?: string;
4391
- line?: number;
4392
- column?: number;
4393
- };
4394
- /** Rule that triggered this issue */
4395
- rule: string;
4396
- /** Suggested fix (if available) */
4397
- suggestedFix?: {
4398
- description: string;
4399
- action: 'modify' | 'remove' | 'add';
4400
- target?: IWorkflowConfig;
4401
- };
4402
- /** Timestamp when issue was detected */
4403
- detectedAt: Date;
4404
- }
4405
- /**
4406
- * Validation options
4407
- */
4408
- interface IValidationOptions {
4409
- /** Validation strictness level */
4410
- strict?: boolean;
4411
- /** Skip specific validation rules */
4412
- skipRules?: string[];
4413
- /** Include only specific validation rules */
4414
- includeRules?: string[];
4415
- /** Maximum number of errors to collect */
4416
- maxErrors?: number;
4417
- /** Include warnings in results */
4418
- includeWarnings?: boolean;
4419
- /** Include info messages in results */
4420
- includeInfo?: boolean;
4421
- /** Custom logger for validation process */
4422
- logger?: ILogger;
4423
- /** Additional validation context */
4424
- context?: IWorkflowMetadata;
4425
- /** Enable auto-recovery suggestions */
4426
- enableAutoRecovery?: boolean;
4427
- }
4428
- /**
4429
- * Validation result
4430
- */
4431
- interface IValidationResult {
4432
- /** Overall validation success status */
4433
- isValid: boolean;
4434
- /** All validation issues found */
4435
- issues: IValidationIssue[];
4436
- /** Summary by severity */
4437
- summary: {
4438
- errorCount: number;
4439
- warningCount: number;
4440
- infoCount: number;
4441
- totalIssues: number;
4442
- };
4443
- /** Validation metadata */
4444
- metadata: {
4445
- /** Validation timestamp */validatedAt: Date; /** Processing time in milliseconds */
4446
- processingTime: number; /** Validator used */
4447
- validator: string; /** Validation rules applied */
4448
- rulesApplied: string[]; /** Data statistics */
4449
- dataStats: Record<string, string | number | boolean>; /** Version */
4450
- version?: string; /** Options */
4451
- options?: string | number | boolean | string[] | Date; /** Additional metrics */
4452
- [key: string]: string | number | boolean | Date | string[] | Record<string, string | number | boolean> | undefined;
4453
- };
4454
- /** Auto-recovery suggestions (if enabled) */
4455
- recoveryOptions?: Array<{
4456
- description: string;
4457
- confidence: number;
4458
- action: () => Promise<IWorkflowConfig>;
4459
- }>;
4460
- }
4461
- /**
4462
- * Workflow Validator Interface
4463
- *
4464
- * Core interface for validating workflow data structures.
4465
- * All workflow validators must implement this interface.
4466
- *
4467
- * @template TWorkflowData - Type of workflow data to validate
4468
- */
4469
- interface IWorkflowValidator<TWorkflowData extends IWorkflowData> {
4470
- /** Validator name for identification */
4471
- readonly name: string;
4472
- /** Validator version */
4473
- readonly version: string;
4474
- /** Data format that this validator handles */
4475
- readonly dataFormat: string;
4476
- /** Available validation rules */
4477
- readonly availableRules: string[];
4478
- /**
4479
- * Validate workflow data
4480
- *
4481
- * @param data - Workflow data to validate
4482
- * @param options - Validation options
4483
- * @returns Promise resolving to validation result
4484
- */
4485
- validate(data: TWorkflowData, options?: IValidationOptions): Promise<IValidationResult>;
4486
- /**
4487
- * Validate specific aspect of workflow data
4488
- *
4489
- * @param data - Workflow data to validate
4490
- * @param rule - Specific rule to apply
4491
- * @param options - Validation options
4492
- * @returns Promise resolving to validation result for this rule
4493
- */
4494
- validateRule(data: TWorkflowData, rule: string, options?: IValidationOptions): Promise<IValidationResult>;
4495
- /**
4496
- * Check if validator can handle the given data format
4497
- *
4498
- * @param data - Data to check
4499
- * @returns True if validator can handle this data
4500
- */
4501
- canValidate(data: IWorkflowData): data is TWorkflowData;
4502
- /**
4503
- * Get available validation rules with descriptions
4504
- *
4505
- * @returns Map of rule names to descriptions
4506
- */
4507
- getRuleDescriptions(): Map<string, {
4508
- description: string;
4509
- severity: ValidationSeverity;
4510
- category: string;
4511
- enabled: boolean;
4512
- }>;
4513
- /**
4514
- * Enable or disable specific validation rules
4515
- *
4516
- * @param rules - Map of rule names to enabled status
4517
- */
4518
- configureRules(rules: Map<string, boolean>): void;
4519
- /**
4520
- * Perform automatic recovery for validation issues
4521
- *
4522
- * @param data - Original workflow data
4523
- * @param issues - Validation issues to recover from
4524
- * @returns Promise resolving to recovered data and recovery result
4525
- */
4526
- autoRecover(data: TWorkflowData, issues: IValidationIssue[]): Promise<{
4527
- recoveredData: TWorkflowData;
4528
- recoveryResult: {
4529
- success: boolean;
4530
- issuesFixed: IValidationIssue[];
4531
- remainingIssues: IValidationIssue[];
4532
- appliedFixes: string[];
4533
- };
4534
- }>;
4535
- /**
4536
- * Get validator statistics and metrics
4537
- *
4538
- * @returns Validator performance metrics
4539
- */
4540
- getStats(): {
4541
- totalValidations: number;
4542
- successfulValidations: number;
4543
- failedValidations: number;
4544
- averageProcessingTime: number;
4545
- averageIssueCount: number;
4546
- mostCommonIssues: Array<{
4547
- rule: string;
4548
- count: number;
4549
- severity: ValidationSeverity;
4550
- }>;
4551
- lastValidationAt?: Date;
4552
- };
4553
- /**
4554
- * Reset validator statistics
4555
- */
4556
- resetStats(): void;
4557
- }
4558
- //#endregion
4559
- //#region src/utils/execution-proxy-types.d.ts
4560
- /**
4561
- * Configuration for execution proxy
4562
- */
4563
- interface IExecutionProxyConfig {
4564
- eventService: IEventService;
4565
- sourceType: 'agent' | 'tool';
4566
- sourceId: string;
4567
- enabledEvents?: {
4568
- execution?: boolean;
4569
- toolCall?: boolean;
4570
- task?: boolean;
4571
- };
4572
- }
4573
- /** Internal target shape for proxy interception */
4574
- type TExecutionProxyTarget = Record<string, TUniversalValue>;
4575
- /** Internal args shape for proxy interception */
4576
- type TExecutionProxyArgs = TUniversalValue[];
4577
- /**
4578
- * Metadata extractor function type
4579
- */
4580
- type TMetadataExtractor = (target: TExecutionProxyTarget, methodName: string, args: TExecutionProxyArgs) => Record<string, TUniversalValue>;
4581
- /**
4582
- * Method configuration for proxy
4583
- */
4584
- interface IMethodConfig {
4585
- startEvent?: string;
4586
- completeEvent?: string;
4587
- errorEvent?: string;
4588
- extractMetadata?: TMetadataExtractor;
4589
- extractResult?: (result: TUniversalValue) => Record<string, TUniversalValue>;
4590
- }
4591
- //#endregion
4592
- //#region src/utils/execution-proxy.d.ts
4593
- /**
4594
- * ExecutionProxy - Automatic event emission using Proxy pattern
4595
- *
4596
- * This class wraps target objects and automatically emits events
4597
- * around method execution without modifying business logic.
4598
- *
4599
- * Benefits:
4600
- * - Zero business logic pollution
4601
- * - Automatic event emission
4602
- * - Configurable per method
4603
- * - AOP (Aspect-Oriented Programming) pattern
4604
- */
4605
- declare class ExecutionProxy<T extends object = object> {
4606
- private config;
4607
- private methodConfigs;
4608
- constructor(config: IExecutionProxyConfig);
4609
- /**
4610
- * Configure specific methods for event emission
4611
- */
4612
- configureMethod(methodName: string, config: IMethodConfig): this;
4613
- /**
4614
- * Configure multiple methods with standard patterns
4615
- */
4616
- configureStandardMethods(): this;
4617
- /**
4618
- * Create a proxy wrapper around the target object
4619
- */
4620
- wrap(target: T): T;
4621
- /**
4622
- * Emit event with standard ServiceEventData format
4623
- */
4624
- private emitEvent;
4625
- /**
4626
- * Generate unique execution ID
4627
- */
4628
- private generateExecutionId;
4629
- }
4630
- /**
4631
- * Factory function to create execution proxy with standard configuration
4632
- */
4633
- declare function createExecutionProxy<T extends object>(target: T, config: IExecutionProxyConfig): T;
4634
- /**
4635
- * Decorator function for automatic event emission
4636
- * Usage: @withEventEmission(eventService, 'agent', 'agent-id')
4637
- */
4638
- declare function withEventEmission(eventService: IEventService, sourceType: 'agent' | 'tool', sourceId: string): <T extends object>(target: T) => T;
4639
- //#endregion
4640
- //#region src/permissions/types.d.ts
4641
- /**
4642
- * Permission system types — Claude Code compatible permission model.
4643
- */
4644
- /**
4645
- * Permission modes (Claude Code compatible)
4646
- * - plan: read-only tools only
4647
- * - default: reads auto, writes/bash need approval
4648
- * - acceptEdits: reads + writes auto, bash needs approval
4649
- * - bypassPermissions: all tools auto
4650
- */
4651
- type TPermissionMode = 'plan' | 'default' | 'acceptEdits' | 'bypassPermissions';
4652
- /**
4653
- * Friendly trust level aliases
4654
- * - safe → plan
4655
- * - moderate → default
4656
- * - full → acceptEdits
4657
- */
4658
- type TTrustLevel = 'safe' | 'moderate' | 'full';
4659
- declare const TRUST_TO_MODE: Record<TTrustLevel, TPermissionMode>;
4660
- /**
4661
- * Outcome of a permission evaluation
4662
- * - auto: proceed without prompting
4663
- * - approve: prompt user for approval
4664
- * - deny: block the action
4665
- */
4666
- type TPermissionDecision = 'auto' | 'approve' | 'deny';
4667
- //#endregion
4668
- //#region src/permissions/permission-gate.d.ts
4669
- /**
4670
- * Tool arguments passed from the LLM invocation.
4671
- * The values relevant to permission matching are strings.
4672
- */
4673
- type TToolArgs = Record<string, string | number | boolean | object>;
4674
- /**
4675
- * Permission list entries (allow / deny).
4676
- * Each entry is a pattern string such as "Bash(pnpm *)" or "Read(/src/**)".
4677
- */
4678
- interface IPermissionLists {
4679
- allow?: string[];
4680
- deny?: string[];
4681
- }
4682
- /**
4683
- * Evaluate whether a tool invocation should be auto-approved, require user approval, or be denied.
4684
- *
4685
- * @param toolName Name of the tool being invoked (e.g. "Bash", "Write")
4686
- * @param toolArgs Arguments provided by the LLM
4687
- * @param mode Active permission mode
4688
- * @param permissions Optional allow/deny lists from config
4689
- */
4690
- declare function evaluatePermission(toolName: string, toolArgs: TToolArgs, mode: TPermissionMode, permissions?: IPermissionLists): TPermissionDecision;
4691
- //#endregion
4692
- //#region src/permissions/permission-mode.d.ts
4693
- /**
4694
- * Tool names known to the permission system
4695
- */
4696
- type TKnownToolName = 'Bash' | 'Read' | 'Write' | 'Edit' | 'Glob' | 'Grep' | 'WebFetch' | 'WebSearch';
4697
- /**
4698
- * Permission mode → tool policy matrix
4699
- * Maps each mode to a decision for each known tool.
4700
- */
4701
- declare const MODE_POLICY: Record<TPermissionMode, Record<TKnownToolName, TPermissionDecision>>;
4702
- /**
4703
- * Fallback decision when a tool name is not in the policy matrix.
4704
- * Unknown tools are treated as requiring approval (fail-safe).
4705
- */
4706
- declare const UNKNOWN_TOOL_FALLBACK: Record<TPermissionMode, TPermissionDecision>;
4707
- //#endregion
4708
- //#region src/context/types.d.ts
4709
- /**
4710
- * Context window tracking types.
4711
- *
4712
- * These types are used by agent-sessions (and downstream packages) to
4713
- * track token usage and context window state across conversation turns.
4714
- */
4715
- /** Token usage from a single API call (Anthropic-style granularity) */
4716
- interface IContextTokenUsage {
4717
- inputTokens: number;
4718
- outputTokens: number;
4719
- cacheCreationTokens?: number;
4720
- cacheReadTokens?: number;
4721
- }
4722
- /** Context window state snapshot */
4723
- interface IContextWindowState {
4724
- /** Max tokens for the current model */
4725
- maxTokens: number;
4726
- /** Current estimated token usage (input + cache, excludes output) */
4727
- usedTokens: number;
4728
- /** Usage percentage (0-100) */
4729
- usedPercentage: number;
4730
- /** Remaining percentage (0-100) */
4731
- remainingPercentage: number;
4732
- }
4733
- //#endregion
4734
- //#region src/context/estimation.d.ts
4735
- declare const CONTEXT_ESTIMATE_CHARS_PER_TOKEN = 4;
4736
- interface IContextTokenEstimateOptions {
4737
- readonly usageFloorTokens?: number;
4738
- }
4739
- interface IContextTokenEstimate {
4740
- readonly usedTokens: number;
4741
- readonly serializedTokens: number;
4742
- readonly providerTokens?: number;
4743
- readonly usageFloorTokens?: number;
4744
- }
4745
- declare function estimateSerializedContextTokens(messages: readonly TUniversalMessage[]): number;
4746
- declare function estimateContextTokensFromMessages(messages: readonly TUniversalMessage[], options?: IContextTokenEstimateOptions): IContextTokenEstimate;
4747
- //#endregion
4748
- //#region src/context/token-usage.d.ts
4749
- interface IMessageTokenUsage {
4750
- readonly inputTokens: number;
4751
- readonly outputTokens: number;
4752
- readonly totalTokens?: number;
4753
- }
4754
- /** Read normalized provider usage from a universal message when present. */
4755
- declare function readTokenUsageFromMessage(message: TUniversalMessage): IMessageTokenUsage | undefined;
4756
- declare function readTokenUsageFromMetadata(metadata: TUniversalMessageMetadata | undefined): IMessageTokenUsage | undefined;
4757
- //#endregion
4758
- //#region src/context/models.d.ts
4759
- /**
4760
- * Claude model definitions — SSOT for model metadata.
4761
- * Source: https://platform.claude.com/docs/en/about-claude/models/overview
4762
- */
4763
- interface IModelDefinition {
4764
- /** Human-readable model name */
4765
- name: string;
4766
- /** API model identifier */
4767
- id: string;
4768
- /** Context window size in tokens */
4769
- contextWindow: number;
4770
- /** Maximum output tokens */
4771
- maxOutput: number;
4772
- }
4773
- /**
4774
- * Known Claude models (4.5+).
4775
- * Keyed by API model ID for fast lookup.
4776
- */
4777
- declare const CLAUDE_MODELS: Record<string, IModelDefinition>;
4778
- declare const DEFAULT_CONTEXT_WINDOW = 200000;
4779
- /** Get context window size for a model ID. Falls back to DEFAULT_CONTEXT_WINDOW. */
4780
- declare function getModelContextWindow(modelId: string): number;
4781
- declare const DEFAULT_MAX_OUTPUT = 16384;
4782
- /** Get max output tokens for a model ID. Falls back to DEFAULT_MAX_OUTPUT. */
4783
- declare function getModelMaxOutput(modelId: string): number;
4784
- /** Get human-readable model name for a model ID. Falls back to the ID itself. */
4785
- declare function getModelName(modelId: string): string;
4786
- /** Format token count as human-readable (e.g., 200K, 1M, 1.2M). Minimum unit is K. */
4787
- declare function formatTokenCount(tokens: number): string;
4788
- //#endregion
4789
- //#region src/context/model-pricing.d.ts
4790
- /**
4791
- * Model pricing — SSOT for per-model token cost.
4792
- *
4793
- * Sibling of `models.ts` (which owns context-window/output metadata). Consumers that need to
4794
- * compute or estimate cost (cost display, budget/rate limiting) must read from here rather than
4795
- * embedding their own price tables.
4796
- *
4797
- * Prices are USD per 1,000,000 tokens (as of May 2026 — update when providers change rates).
4798
- */
4799
- interface IModelPrice {
4800
- inputPerMillion: number;
4801
- outputPerMillion: number;
4802
- }
4803
- /** Exact per-model prices, keyed by API model ID. */
4804
- declare const MODEL_PRICES: Record<string, IModelPrice>;
4805
- /** Resolve a model's price by exact ID, then family pattern. Returns undefined if unknown. */
4806
- declare function lookupModelPrice(modelId: string): IModelPrice | undefined;
4807
- /** Exact USD cost for an input/output token split, or undefined if the model is unknown. */
4808
- declare function calculateModelCost(modelId: string, inputTokens: number, outputTokens: number): number | undefined;
4809
- /**
4810
- * Blended USD-per-1000-tokens rate for budget estimation when an input/output split is not
4811
- * available (e.g. rate limiting). Averages the input and output per-million prices. Returns
4812
- * undefined if the model is unknown so callers can apply their own fallback rate.
4813
- */
4814
- declare function estimateBlendedCostPer1000(modelId: string): number | undefined;
4815
- //#endregion
4816
- //#region src/hooks/types.d.ts
4817
- /**
4818
- * Hook system types — Claude Code compatible event/hook model.
4819
- */
4820
- /** Hook lifecycle events */
4821
- type THookEvent = 'PreToolUse' | 'PostToolUse' | 'SessionStart' | 'SessionEnd' | 'Stop' | 'StopFailure' | 'PreCompact' | 'PostCompact' | 'UserPromptSubmit' | 'SubagentStart' | 'SubagentStop' | 'WorktreeCreate' | 'WorktreeRemove';
4822
- /** Claude Code compatible session end reasons. */
4823
- type TSessionEndReason = 'clear' | 'resume' | 'logout' | 'prompt_input_exit' | 'bypass_permissions_disabled' | 'other';
4824
- /** Command hook — executes a shell command */
4825
- interface ICommandHookDefinition {
4826
- type: 'command';
4827
- command: string;
4828
- timeout?: number;
4829
- }
4830
- /** HTTP hook — sends an HTTP request */
4831
- interface IHttpHookDefinition {
4832
- type: 'http';
4833
- url: string;
4834
- headers?: Record<string, string>;
4835
- timeout?: number;
4836
- }
4837
- /** Prompt hook — evaluates a prompt via an AI model */
4838
- interface IPromptHookDefinition {
4839
- type: 'prompt';
4840
- prompt: string;
4841
- model?: string;
4842
- }
4843
- /** Agent hook — delegates to a sub-agent */
4844
- interface IAgentHookDefinition {
4845
- type: 'agent';
4846
- agent: string;
4847
- maxTurns?: number;
4848
- timeout?: number;
4849
- }
4850
- /** Discriminated union of all hook definition types */
4851
- type THookDefinition = ICommandHookDefinition | IHttpHookDefinition | IPromptHookDefinition | IAgentHookDefinition;
4852
- /** A hook group — matcher + array of hook definitions */
4853
- interface IHookGroup {
4854
- /** Regex pattern to match tool name (empty string = match all) */
4855
- matcher: string;
4856
- hooks: THookDefinition[];
4857
- /** Environment variables injected into hook child processes for this group */
4858
- env?: Record<string, string>;
4859
- }
4860
- /** Complete hooks configuration: event → array of hook groups */
4861
- type THooksConfig = Partial<Record<THookEvent, IHookGroup[]>>;
4862
- /** Input passed to hook commands via stdin */
4863
- interface IHookInput {
4864
- session_id: string;
4865
- cwd: string;
4866
- hook_event_name: THookEvent;
4867
- tool_name?: string;
4868
- tool_input?: Record<string, string | number | boolean | object>;
4869
- tool_output?: string;
4870
- /** Compaction trigger source (PreCompact/PostCompact only) */
4871
- trigger?: 'auto' | 'manual';
4872
- /** Compaction summary text (PostCompact only) */
4873
- compact_summary?: string;
4874
- /** User message text (UserPromptSubmit only) */
4875
- user_message?: string;
4876
- /** User prompt text — Claude Code compatible alias for user_message (UserPromptSubmit only) */
4877
- prompt?: string;
4878
- /** Assistant response text (Stop only) */
4879
- response?: string;
4880
- /** Last assistant message text (StopFailure only) */
4881
- last_assistant_message?: string;
4882
- /** Stop hook recursion guard (Stop/StopFailure only) */
4883
- stop_hook_active?: boolean;
4884
- /** Session end reason (SessionEnd only) */
4885
- reason?: TSessionEndReason | string;
4886
- /** Session transcript path when available (SessionEnd/SubagentStop only) */
4887
- transcript_path?: string;
4888
- /** Subagent identifier (SubagentStart/SubagentStop only) */
4889
- agent_id?: string;
4890
- /** Subagent type/name (SubagentStart/SubagentStop only) */
4891
- agent_type?: string;
4892
- /** Subagent transcript path when available (SubagentStop only) */
4893
- agent_transcript_path?: string;
4894
- /** Claude Code permission mode at time of event (e.g. "default", "plan", "acceptEdits", "bypassPermissions") */
4895
- permission_mode?: string;
4896
- /** Additional environment variables to pass to hook child processes */
4897
- env?: Record<string, string>;
4898
- }
4899
- /** Hook execution result */
4900
- interface IHookResult {
4901
- /** 0 = allow/proceed, 2 = block/deny, other = proceed with warning */
4902
- exitCode: number;
4903
- stdout: string;
4904
- stderr: string;
4905
- }
4906
- /** Strategy interface for hook type executors */
4907
- interface IHookTypeExecutor {
4908
- /** The hook type this executor handles */
4909
- type: THookDefinition['type'];
4910
- /** Execute a hook definition with the given input */
4911
- execute(definition: THookDefinition, input: IHookInput): Promise<IHookResult>;
4912
- }
4913
- //#endregion
4914
- //#region src/hooks/hook-runner.d.ts
4915
- /** Result of running hooks for an event. */
4916
- interface IRunHooksResult {
4917
- blocked: boolean;
4918
- reason?: string;
4919
- /** Collected stdout from all successful hooks (exit code 0). */
4920
- stdout: string;
4921
- /** Parsed updatedInput from PreToolUse hookSpecificOutput (PreToolUse only). */
4922
- updatedInput?: Record<string, unknown>;
4923
- /** Highest-priority permissionDecision from PreToolUse hooks (PreToolUse only). */
4924
- permissionDecision?: 'allow' | 'deny' | 'ask' | 'defer';
4925
- }
4926
- /**
4927
- * Run all hooks for a given event.
4928
- *
4929
- * For PreToolUse: if any hook returns exit code 2 or JSON deny, the tool call is blocked.
4930
- * JSON stdout responses are parsed and applied per Claude Code spec.
4931
- * Returns { blocked: true, reason } if blocked, otherwise { blocked: false, stdout }.
4932
- *
4933
- * @param config - Hooks configuration mapping events to hook groups
4934
- * @param event - The lifecycle event being fired
4935
- * @param input - Hook input data passed to executors
4936
- * @param executors - Optional array of hook type executors (defaults to command + http)
4937
- */
4938
- declare function runHooks(config: THooksConfig | undefined, event: THookEvent, input: IHookInput, executors?: IHookTypeExecutor[]): Promise<IRunHooksResult>;
4939
- //#endregion
4940
- export { AGENT_EVENTS, AGENT_EVENT_PREFIX, AbstractAIProvider, AbstractAgent, AbstractEventService, AbstractExecutor, AbstractManager, AbstractPlugin, AbstractTool, AgentFactory, AgentTemplates, AuthenticationError, CLAUDE_MODELS, CONTEXT_ESTIMATE_CHARS_PER_TOKEN, CacheIntegrityError, CircuitBreakerOpenError, ConfigurationError, ConsoleLogger, ConversationHistory, ConversationStore, DEFAULT_ABSTRACT_EVENT_SERVICE, DEFAULT_CONTEXT_WINDOW, DEFAULT_MAX_OUTPUT, DefaultEventService, ENV_REFERENCE_PREFIX, EVENT_EMITTER_EVENTS, EXECUTION_EVENTS, EXECUTION_EVENT_PREFIX, ErrorUtils, EventEmitterPlugin, EventHistoryModule, ExecutionProxy, type IAIProvider, type IAIProviderInstance, type IAIProviderManager, IAbstractTool, IAbstractToolOptions, type IAgent, type IAgentConfig, type IAgentCreationOptions, type IAgentCreationStats, type IAgentEventData, type IAgentFactory, type IAgentFactoryOptions, type IAgentHookDefinition, type IAgentLifecycleEvents, type IAgentTemplate, type IAssistantMessage, type IAssistantUsageMetadata, type IBaseEventData, type IBaseMessage, type ICacheEntry, type ICacheKey, type ICacheOptions, type ICacheStats, type ICacheStorage, type IChatExecutionRequest, type IChatOptions, type ICommandHookDefinition, type IConfigValidationResult, type IContextOptions, type IContextTokenEstimate, type IContextTokenEstimateOptions, type IContextTokenUsage, type IContextWindowState, type IConversationContext, type IConversationResponse, type IConversationService, type IConversationServiceOptions, type IDirent, type IEventContext, type IEventEmitterEventData, type IEventEmitterHierarchicalEventData, type IEventEmitterMetrics, type IEventEmitterMetricsSnapshot, type IEventEmitterPlugin, type IEventEmitterPluginOptions, type IEventHistoryModule, type IEventHistoryRecord, type IEventHistorySnapshot, type IEventObjectValue, type IEventService, type IEventServiceOwnerBinding, type IExecutionEventData, type IExecutionService, type IExecutionServiceOptions, type IExecutor, IExecutorAwareProviderConfig, type IFileSystem, type IFileSystemAsync, type IFunctionTool, type IHistoryEntry, type IHookGroup, type IHookInput, type IHookResult, type IHookTypeExecutor, type IHttpHookDefinition, type IImageComposeRequest, type IImageEditRequest, type IImageGenerationProvider, type IImageGenerationRequest, type IImageGenerationResult, type IInlineImageInputSource, type IInlineImageMessagePart, type ILocalExecutorConfig, ILogger, type IMCPToolConfig, type IMediaOutputRef, type IMessageTokenUsage, type IModelDefinition, type IModelPrice, type IOpenAPIToolConfig, type IOwnerPathSegment, type IParameterSchema, type IParameterValidationResult, type IPermissionLists, type IPlugin, type IPluginConfig, IPluginContext, type IPluginContract, type IPluginData, type IPluginErrorContext, type IPluginExecutionContext, type IPluginExecutionResult, type IPluginHooks, type IPluginOptions, type IPluginStats, type IProgressReportingTool, type IPromptHookDefinition, type IProviderCapabilities, IProviderConfig, type IProviderCredentialRequirement, type IProviderDefinition, type IProviderFunctionCallingCapability, type IProviderMediaError, type IProviderModelCatalog, type IProviderModelCatalogEntry, type IProviderModelCatalogRefreshOptions, type IProviderNativeRawPayloadEvent, type IProviderNativeWebToolCapabilities, type IProviderNativeWebToolCapability, type IProviderNativeWebToolRequest, type IProviderOptions, type IProviderProbeResult, type IProviderProfileConfig, type IProviderProfileDefaults, type IProviderRequest, type IProviderSetupHelpLink, type IProviderSetupStepDefinition, type IProviderSpecificOptions, type IRawProviderResponse, type IRemoteExecutorConfig, type IRunOptions, type ISession, ISimpleValidationResult, type ISpinner, type IStats, type IStreamExecutionRequest, type IStreamingChunk, type ISystemMessage, type ITemplateApplicationResult, type ITerminalOutput, type ITextMessagePart, type ITokenUsage, type ITool, type IToolCall, IToolContract, type IToolEventData, type IToolExecutionContext, type IToolExecutionRequest, type IToolExecutionResult, type IToolExecutionService, type IToolExecutionStep, type IToolFactory, type IToolManager, type IToolMessage, type IToolRegistry, type IToolResult, type IToolSchema, IToolWithEventService, IUniversalObjectValue, type IUriImageInputSource, type IUriImageMessagePart, type IUserMessage, IUtilLogEntry, type IValidationIssue, type IValidationOptions, type IValidationResult, type IVideoGenerationProvider, type IVideoGenerationRequest, type IVideoJobAccepted, type IVideoJobSnapshot, type IWorkflowConfig, type IWorkflowConversionOptions, type IWorkflowConversionResult, type IWorkflowConverter, type IWorkflowData, type IWorkflowMetadata, type IWorkflowValidator, InMemoryEventEmitterMetrics, LocalExecutor, MODEL_PRICES, MODE_POLICY, MessageConverter, ModelNotAvailableError, NetworkError, ObservableEventService, PluginCategory, PluginError, PluginPriority, ProviderError, RateLimitError, Robota, RobotaError, SilentLogger, StorageError, StructuredEventService, TASK_EVENTS, TASK_EVENT_PREFIX, type TAgentCreationMetadata, TComplexConfigValue, TConfigData, TConfigValue, TContextData, type TConversationContextMetadata, TErrorContextData, TErrorExternalInput, type TEventEmitterListener, type TEventExtensionValue, type TEventListener, type TEventLoggerData, type TEventName, type TEventUniversalValue, type TExecutionEventCallback, type TExecutionEventData, type TExecutionEventName, type TExecutionMetadata, type THookDefinition, type THookEvent, type THooksConfig, type TImageInputSource, type TJSONSchemaEnum, type TJSONSchemaKind, type TKnownToolName, TLoggerData, type TManagerToolParameters, TMessageConverterRegistry, TMessageFormatConverter, type TMessageState, TMetadata, TMetadataValue, type TModelEffort, TOOL_EVENTS, TOOL_EVENT_PREFIX, type TParameterDefaultValue, type TPermissionDecision, type TPermissionMode, TPrimitiveValue, type TProviderConfigValue, type TProviderCredentialField, TProviderLoggingData, type TProviderMediaResult, TProviderMessage, type TProviderModelCapability, type TProviderModelCatalogRefresh, type TProviderModelCatalogStatus, type TProviderModelLifecycle, type TProviderNativeRawPayload, type TProviderNativeRawPayloadCallback, type TProviderNativeRawPayloadKind, type TProviderOptionValueBase, type TProviderSetupField, type TProviderSetupHelpLinkKind, TRUST_TO_MODE, type TResponseMetadata, type TSessionEndReason, type TTextDeltaCallback, TTimerId, type TToolArgs, TToolExecutionFunction, type TToolExecutionParameters, type TToolExecutor, type TToolMetadata, TToolParameters, type TToolProgressCallback, type TTrustLevel, TUniversalArrayValue, type TUniversalMessage, type TUniversalMessageMetadata, type TUniversalMessagePart, type TUniversalMessageRole, TUniversalValue, type TUserEvent, TUtilLogLevel, ToolExecutionError, TypeUtils, UNKNOWN_TOOL_FALLBACK, USER_EVENTS, USER_EVENT_PREFIX, ValidationError, type ValidationSeverity, Validator, assertProviderNativeWebToolsAvailable, bindEventServiceOwner, bindWithOwnerPath, calculateModelCost, chatEntryToMessage, collectAssistantUsageMetadata, composeEventName, createAssistantMessage, createDefaultProviderCapabilities, createExecutionProxy, createLogger, createSystemMessage, createToolMessage, createUserMessage, estimateBlendedCostPer1000, estimateContextTokensFromMessages, estimateSerializedContextTokens, evaluatePermission, findProviderDefinition, formatEnvReference, formatSupportedProviderTypes, formatTokenCount, getGlobalLogLevel, getMessagesForAPI, getModelContextWindow, getModelMaxOutput, getModelName, getProviderCapabilities, getProviderCredentialRequirement, getToolEstimatedDuration, getToolExecutionSteps, hasUsableSecretReference, isAssistantMessage, isChatEntry, isDefaultEventService, isEnvReference, isImageGenerationProvider, isProgressReportingTool, isSystemMessage, isToolMessage, isUserMessage, isVideoGenerationProvider, logger, lookupModelPrice, messageToHistoryEntry, readTokenUsageFromMessage, readTokenUsageFromMetadata, resolveEnvReference, runHooks, setGlobalLogLevel, setToolProgressCallback, startPeriodicTask, stopPeriodicTask, validateAgentConfig, validateApiKey, validateModelName, validateProviderName, validateUserInput, withEventEmission };
4941
- //# sourceMappingURL=index.d.ts.map
1
+ import { $ as IWorkflowValidator, $a as IChatOptions, $i as PluginCategory, $n as IConversationResponse, $o as IHistoryEntry, $r as IProviderDefinition, $t as startPeriodicTask, A as CONTEXT_ESTIMATE_CHARS_PER_TOKEN, Aa as IExecutionEventData, Ai as parseStructuredResponseText, An as AbstractAIProvider, Ao as IUserInteraction, Ar as IAgentFactory, At as IEventEmitterMetricsSnapshot, B as IPermissionLists, Ba as SilentLogger, Bi as IToolWithEventService, Bn as ISession, Bo as TConfigData, Br as IInlineImageInputSource, Bt as createAssistantMessage, C as formatTokenCount, Ca as isDefaultEventService, Ci as TExecutionEventCallback, Cn as validateProviderName, Co as IProviderNativeWebToolRequest, Cr as selectAction, Ct as EXECUTION_EVENT_PREFIX, D as IMessageTokenUsage, Da as IEventObjectValue, Di as TStructuredOutputSchema, Dn as TMessageFormatConverter, Do as IActionDefault, Dr as IToolFactory, Dt as IEventEmitterHierarchicalEventData, E as getModelName, Ea as IEventContext, Ei as IStructuredOutputSpec, En as TMessageConverterRegistry, Eo as getProviderCapabilities, Er as IOpenAPIToolConfig, Et as EventEmitterPlugin, F as IContextTokenUsage, Fa as TEventLoggerData, Fi as IZodSchemaDef, Fn as AbstractAgent, Fo as ICacheStats, Fr as IImageComposeRequest, Ft as isEnvReference, G as TRUST_TO_MODE, Ga as setGlobalLogLevel, Gi as IPluginContract, Gn as IEventHistorySnapshot, Go as TMetadataValue, Gr as IVideoGenerationRequest, Gt as extractEnumValues, H as evaluatePermission, Ha as createLogger, Hi as AbstractPlugin, Hn as ITerminalOutput, Ho as TContextData, Hr as IProviderMediaError, Ht as createToolMessage, I as IContextWindowState, Ia as TEventUniversalValue, Ii as AbstractTool, In as IDirent, Io as ICacheStorage, Ir as IImageEditRequest, It as resolveEnvReference, J as createExecutionProxy, Ja as IEventEmitterPlugin, Ji as IPluginExecutionContext, Jn as ILocalExecutorConfig, Jo as TUniversalArrayValue, Jr as TImageInputSource, Jt as zodToJsonSchema, K as TTrustLevel, Ka as EVENT_EMITTER_EVENTS, Ki as IPluginData, Kn as IChatExecutionRequest, Ko as TPrimitiveValue, Kr as IVideoJobAccepted, Kt as getSchemaTypeName, L as MODE_POLICY, La as ConsoleLogger, Li as IAbstractTool, Ln as IFileSystem, Lo as IPluginContext, Lr as IImageGenerationProvider, Lt as IAIProviderInstance, M as IContextTokenEstimateOptions, Ma as IToolEventData, Mi as ISchemaConversionOptions, Mn as IProviderRuntimeConfig, Mo as ICacheEntry, Mr as IToolManager, Mt as ENV_REFERENCE_PREFIX, N as estimateContextTokensFromMessages, Na as TEventExtensionValue, Ni as IZodParseResult, Nn as TProviderLoggingData, No as ICacheKey, Nr as TAgentCreationMetadata, Nt as formatEnvReference, O as readTokenUsageFromMessage, Oa as IEventService, Oi as TStructuredOutputValidation, On as TProviderMessage, Oo as IActionOption, Or as IAIProviderManager, Ot as IEventEmitterPluginOptions, P as estimateSerializedContextTokens, Pa as TEventListener, Pi as IZodSchema, Pn as AbstractManager, Po as ICacheOptions, Pr as TManagerToolParameters, Pt as hasUsableSecretReference, Q as IValidationResult, Qa as IAIProvider, Qi as IPluginStats, Qn as IConversationContext, Qo as IBaseMessage, Qr as IProviderCredentialRequirement, Qt as resolvePlatformShell, R as TKnownToolName, Ra as ILogger, Ri as IAbstractToolOptions, Rn as IFileSystemAsync, Ro as IUniversalObjectValue, Rr as IImageGenerationRequest, Rt as LocalExecutor, S as IModelDefinition, Sa as composeEventName, Si as IRunOptions, Sn as validateModelName, So as IProviderNativeWebToolCapability, Sr as multiSelectAction, St as EXECUTION_EVENTS, T as getModelMaxOutput, Ta as IBaseEventData, Ti as IJsonSchemaOutput, Tn as MessageConverter, To as createDefaultProviderCapabilities, Tr as IMCPToolConfig, Tt as TOOL_EVENT_PREFIX, U as TPermissionDecision, Ua as getGlobalLogLevel, Ui as IPlugin, Un as IEventHistoryModule, Uo as TLoggerData, Ur as IUriImageInputSource, Ut as createUserMessage, V as TToolArgs, Va as TUtilLogLevel, Vi as TToolExecutionFunction, Vn as ISpinner, Vo as TConfigValue, Vr as IMediaOutputRef, Vt as createSystemMessage, W as TPermissionMode, Wa as logger, Wi as IPluginConfig, Wn as IEventHistoryRecord, Wo as TMetadata, Wr as IVideoGenerationProvider, Wt as ConversationStore, X as IValidationIssue, Xa as TEventName, Xi as IPluginHooks, Xn as IStreamExecutionRequest, Xo as TypeUtils, Xr as isImageGenerationProvider, Xt as IPlatformShell, Y as withEventEmission, Ya as TEventEmitterListener, Yi as IPluginExecutionResult, Yn as IRemoteExecutorConfig, Yo as TUniversalValue, Yr as TProviderMediaResult, Yt as TTimerId, Z as IValidationOptions, Za as TExecutionEventName, Zi as IPluginOptions, Zn as IContextOptions, Zo as IAssistantMessage, Zr as isVideoGenerationProvider, Zt as TShellKind, _ as estimateBlendedCostPer1000, _a as DefaultEventService, _i as formatSupportedProviderTypes, _n as ValidationError, _o as TTextDeltaCallback, _r as setToolProgressCallback, _s as isToolMessage, _t as IAgentCreationStats, a as IHookInput, aa as IToolExecutionResult, ai as IProviderProfileConfig, an as ErrorUtils, ao as IRawProviderResponse, ar as IToolExecutionRequest, as as IUriImageMessagePart, at as IWorkflowData, b as DEFAULT_CONTEXT_WINDOW, ba as bindEventServiceOwner, bi as IAgentConfig, bn as validateAgentConfig, bo as IProviderFunctionCallingCapability, br as confirmAction, bt as Robota, c as IHttpHookDefinition, ca as TToolExecutor, ci as IProviderSetupStepDefinition, cn as PluginError, co as TJSONSchemaEnum, cr as TExecutionMetadata, cs as TUniversalMessage, ct as AGENT_EVENT_PREFIX, d as THookEvent, da as USER_EVENTS, di as TProviderModelCatalogRefresh, dn as RobotaError, do as TParameterDefaultValue, dr as IProgressReportingTool, ds as TUniversalMessageRole, dt as ISessionUsageTotals, ea as PluginPriority, ei as IProviderDefinitionConfig, en as stopPeriodicTask, eo as IParameterSchema, er as IConversationService, es as IInlineImageMessagePart, et as ValidationSeverity, f as THooksConfig, fa as USER_EVENT_PREFIX, fi as TProviderModelCatalogStatus, fn as StorageError, fo as TProviderConfigValue, fr as IToolExecutionStep, fs as chatEntryToMessage, ft as collectAssistantUsageMetadata, g as calculateModelCost, ga as DEFAULT_ABSTRACT_EVENT_SERVICE, gi as findProviderDefinition, gn as ToolExecutionError, go as TProviderOptionValueBase, gr as isProgressReportingTool, gs as isSystemMessage, gt as ITemplateApplicationResult, h as MODEL_PRICES, ha as AbstractEventService, hi as TProviderSetupHelpLinkKind, hn as TErrorExternalInput, ho as TProviderNativeRawPayloadKind, hr as getToolExecutionSteps, hs as isChatEntry, ht as AgentTemplates, i as IHookGroup, ia as IToolExecutionContext, ii as IProviderProbeResult, in as ConfigurationError, io as IProviderSpecificOptions, ir as IStreamingChunk, is as IToolMessage, it as IWorkflowConverter, j as IContextTokenEstimate, ja as IOwnerPathSegment, ji as validateAgainstJsonSchema, jn as IExecutorAwareProviderConfig, jo as TActionResponse, jr as IConfigValidationResult, jt as InMemoryEventEmitterMetrics, k as readTokenUsageFromMetadata, ka as IEventServiceOwnerBinding, ki as normalizeStructuredOutput, kn as AbstractExecutor, ko as IActionRequest, kr as IAgentCreationOptions, kt as IEventEmitterMetrics, l as IPromptHookDefinition, la as TToolMetadata, li as TProviderCredentialField, ln as ProviderError, lo as TJSONSchemaKind, lr as TResponseMetadata, ls as TUniversalMessageMetadata, lt as EventHistoryModule, m as IModelPrice, ma as TASK_EVENT_PREFIX, mi as TProviderSetupField, mn as TErrorContextData, mo as TProviderNativeRawPayloadCallback, mr as getToolEstimatedDuration, ms as isAssistantMessage, mt as AgentFactory, n as IAgentHookDefinition, na as IParameterValidationResult, ni as IProviderModelCatalogEntry, nn as CacheIntegrityError, no as IProviderOptions, nr as IExecutionService, ns as ITextMessagePart, nt as IWorkflowConversionOptions, o as IHookResult, oa as IToolRegistry, oi as IProviderProfileDefaults, on as ModelNotAvailableError, oo as ITokenUsage, or as IToolExecutionService, os as IUserMessage, ot as IWorkflowMetadata, p as TSessionEndReason, pa as TASK_EVENTS, pi as TProviderModelLifecycle, pn as StructuredOutputError, po as TProviderNativeRawPayload, pr as TToolProgressCallback, ps as getMessagesForAPI, pt as sumHistoryUsage, q as ExecutionProxy, qa as IEventEmitterEventData, qi as IPluginErrorContext, qn as IExecutor, qo as TToolParameters, qr as IVideoJobSnapshot, qt as hasValidationConstraints, r as ICommandHookDefinition, ra as ITool, ri as IProviderModelCatalogRefreshOptions, rn as CircuitBreakerOpenError, ro as IProviderRequest, rr as IExecutionServiceOptions, rs as IToolCall, rt as IWorkflowConversionResult, s as IHookTypeExecutor, sa as IToolResult, si as IProviderSetupHelpLink, sn as NetworkError, so as IToolSchema, sr as TConversationContextMetadata, ss as TMessageState, st as AGENT_EVENTS, t as runHooks, ta as IFunctionTool, ti as IProviderModelCatalog, tn as AuthenticationError, to as IProviderNativeRawPayloadEvent, tr as IConversationServiceOptions, ts as ISystemMessage, tt as IWorkflowConfig, u as THookDefinition, ua as TUserEvent, ui as TProviderModelCapability, un as RateLimitError, uo as TModelEffort, ur as TToolExecutionParameters, us as TUniversalMessagePart, ut as IAssistantUsageMetadata, v as lookupModelPrice, va as ObservableEventService, vi as getProviderCredentialRequirement, vn as ISimpleValidationResult, vo as TToolChoice, vr as CONFIRM_NO, vs as isUserMessage, vt as IAgentFactoryOptions, w as getModelContextWindow, wa as IAgentEventData, wi as TExecutionEventData, wn as validateUserInput, wo as assertProviderNativeWebToolsAvailable, wr as textAction, wt as TOOL_EVENTS, x as DEFAULT_MAX_OUTPUT, xa as bindWithOwnerPath, xi as IAgentTemplate, xn as validateApiKey, xo as IProviderNativeWebToolCapabilities, xr as isConfirmed, xt as IDestroyResult, y as CLAUDE_MODELS, ya as StructuredEventService, yi as IAgent, yn as Validator, yo as IProviderCapabilities, yr as CONFIRM_YES, ys as messageToHistoryEntry, yt as IAgentLifecycleEvents, z as UNKNOWN_TOOL_FALLBACK, za as IUtilLogEntry, zi as IToolContract, zn as IStats, zo as TComplexConfigValue, zr as IImageGenerationResult, zt as ConversationHistory } from "./index-BKIUt9pk.js";
2
+ export { AGENT_EVENTS, AGENT_EVENT_PREFIX, AbstractAIProvider, AbstractAgent, AbstractEventService, AbstractExecutor, AbstractManager, AbstractPlugin, AbstractTool, AgentFactory, AgentTemplates, AuthenticationError, CLAUDE_MODELS, CONFIRM_NO, CONFIRM_YES, CONTEXT_ESTIMATE_CHARS_PER_TOKEN, CacheIntegrityError, CircuitBreakerOpenError, ConfigurationError, ConsoleLogger, ConversationHistory, ConversationStore, DEFAULT_ABSTRACT_EVENT_SERVICE, DEFAULT_CONTEXT_WINDOW, DEFAULT_MAX_OUTPUT, DefaultEventService, ENV_REFERENCE_PREFIX, EVENT_EMITTER_EVENTS, EXECUTION_EVENTS, EXECUTION_EVENT_PREFIX, ErrorUtils, EventEmitterPlugin, EventHistoryModule, ExecutionProxy, type IAIProvider, type IAIProviderInstance, type IAIProviderManager, IAbstractTool, IAbstractToolOptions, type IActionDefault, type IActionOption, type IActionRequest, type IAgent, type IAgentConfig, type IAgentCreationOptions, type IAgentCreationStats, type IAgentEventData, type IAgentFactory, type IAgentFactoryOptions, type IAgentHookDefinition, type IAgentLifecycleEvents, type IAgentTemplate, type IAssistantMessage, type IAssistantUsageMetadata, type IBaseEventData, type IBaseMessage, type ICacheEntry, type ICacheKey, type ICacheOptions, type ICacheStats, type ICacheStorage, type IChatExecutionRequest, type IChatOptions, type ICommandHookDefinition, type IConfigValidationResult, type IContextOptions, type IContextTokenEstimate, type IContextTokenEstimateOptions, type IContextTokenUsage, type IContextWindowState, type IConversationContext, type IConversationResponse, type IConversationService, type IConversationServiceOptions, type IDestroyResult, type IDirent, type IEventContext, type IEventEmitterEventData, type IEventEmitterHierarchicalEventData, type IEventEmitterMetrics, type IEventEmitterMetricsSnapshot, type IEventEmitterPlugin, type IEventEmitterPluginOptions, type IEventHistoryModule, type IEventHistoryRecord, type IEventHistorySnapshot, type IEventObjectValue, type IEventService, type IEventServiceOwnerBinding, type IExecutionEventData, type IExecutionService, type IExecutionServiceOptions, type IExecutor, IExecutorAwareProviderConfig, type IFileSystem, type IFileSystemAsync, type IFunctionTool, type IHistoryEntry, type IHookGroup, type IHookInput, type IHookResult, type IHookTypeExecutor, type IHttpHookDefinition, type IImageComposeRequest, type IImageEditRequest, type IImageGenerationProvider, type IImageGenerationRequest, type IImageGenerationResult, type IInlineImageInputSource, type IInlineImageMessagePart, type IJsonSchemaOutput, type ILocalExecutorConfig, ILogger, type IMCPToolConfig, type IMediaOutputRef, type IMessageTokenUsage, type IModelDefinition, type IModelPrice, type IOpenAPIToolConfig, type IOwnerPathSegment, type IParameterSchema, type IParameterValidationResult, type IPermissionLists, IPlatformShell, type IPlugin, type IPluginConfig, IPluginContext, type IPluginContract, type IPluginData, type IPluginErrorContext, type IPluginExecutionContext, type IPluginExecutionResult, type IPluginHooks, type IPluginOptions, type IPluginStats, type IProgressReportingTool, type IPromptHookDefinition, type IProviderCapabilities, type IProviderCredentialRequirement, type IProviderDefinition, type IProviderDefinitionConfig, type IProviderFunctionCallingCapability, type IProviderMediaError, type IProviderModelCatalog, type IProviderModelCatalogEntry, type IProviderModelCatalogRefreshOptions, type IProviderNativeRawPayloadEvent, type IProviderNativeWebToolCapabilities, type IProviderNativeWebToolCapability, type IProviderNativeWebToolRequest, type IProviderOptions, type IProviderProbeResult, type IProviderProfileConfig, type IProviderProfileDefaults, type IProviderRequest, IProviderRuntimeConfig, type IProviderSetupHelpLink, type IProviderSetupStepDefinition, type IProviderSpecificOptions, type IRawProviderResponse, type IRemoteExecutorConfig, type IRunOptions, type ISchemaConversionOptions, type ISession, type ISessionUsageTotals, ISimpleValidationResult, type ISpinner, type IStats, type IStreamExecutionRequest, type IStreamingChunk, type IStructuredOutputSpec, type ISystemMessage, type ITemplateApplicationResult, type ITerminalOutput, type ITextMessagePart, type ITokenUsage, type ITool, type IToolCall, IToolContract, type IToolEventData, type IToolExecutionContext, type IToolExecutionRequest, type IToolExecutionResult, type IToolExecutionService, type IToolExecutionStep, type IToolFactory, type IToolManager, type IToolMessage, type IToolRegistry, type IToolResult, type IToolSchema, IToolWithEventService, IUniversalObjectValue, type IUriImageInputSource, type IUriImageMessagePart, type IUserInteraction, type IUserMessage, IUtilLogEntry, type IValidationIssue, type IValidationOptions, type IValidationResult, type IVideoGenerationProvider, type IVideoGenerationRequest, type IVideoJobAccepted, type IVideoJobSnapshot, type IWorkflowConfig, type IWorkflowConversionOptions, type IWorkflowConversionResult, type IWorkflowConverter, type IWorkflowData, type IWorkflowMetadata, type IWorkflowValidator, type IZodParseResult, type IZodSchema, type IZodSchemaDef, InMemoryEventEmitterMetrics, LocalExecutor, MODEL_PRICES, MODE_POLICY, MessageConverter, ModelNotAvailableError, NetworkError, ObservableEventService, PluginCategory, PluginError, PluginPriority, ProviderError, RateLimitError, Robota, RobotaError, SilentLogger, StorageError, StructuredEventService, StructuredOutputError, TASK_EVENTS, TASK_EVENT_PREFIX, type TActionResponse, type TAgentCreationMetadata, TComplexConfigValue, TConfigData, TConfigValue, TContextData, type TConversationContextMetadata, TErrorContextData, TErrorExternalInput, type TEventEmitterListener, type TEventExtensionValue, type TEventListener, type TEventLoggerData, type TEventName, type TEventUniversalValue, type TExecutionEventCallback, type TExecutionEventData, type TExecutionEventName, type TExecutionMetadata, type THookDefinition, type THookEvent, type THooksConfig, type TImageInputSource, type TJSONSchemaEnum, type TJSONSchemaKind, type TKnownToolName, TLoggerData, type TManagerToolParameters, TMessageConverterRegistry, TMessageFormatConverter, type TMessageState, TMetadata, TMetadataValue, type TModelEffort, TOOL_EVENTS, TOOL_EVENT_PREFIX, type TParameterDefaultValue, type TPermissionDecision, type TPermissionMode, TPrimitiveValue, type TProviderConfigValue, type TProviderCredentialField, TProviderLoggingData, type TProviderMediaResult, TProviderMessage, type TProviderModelCapability, type TProviderModelCatalogRefresh, type TProviderModelCatalogStatus, type TProviderModelLifecycle, type TProviderNativeRawPayload, type TProviderNativeRawPayloadCallback, type TProviderNativeRawPayloadKind, type TProviderOptionValueBase, type TProviderSetupField, type TProviderSetupHelpLinkKind, TRUST_TO_MODE, type TResponseMetadata, type TSessionEndReason, TShellKind, type TStructuredOutputSchema, type TStructuredOutputValidation, type TTextDeltaCallback, TTimerId, type TToolArgs, type TToolChoice, TToolExecutionFunction, type TToolExecutionParameters, type TToolExecutor, type TToolMetadata, TToolParameters, type TToolProgressCallback, type TTrustLevel, TUniversalArrayValue, type TUniversalMessage, type TUniversalMessageMetadata, type TUniversalMessagePart, type TUniversalMessageRole, TUniversalValue, type TUserEvent, TUtilLogLevel, ToolExecutionError, TypeUtils, UNKNOWN_TOOL_FALLBACK, USER_EVENTS, USER_EVENT_PREFIX, ValidationError, type ValidationSeverity, Validator, assertProviderNativeWebToolsAvailable, bindEventServiceOwner, bindWithOwnerPath, calculateModelCost, chatEntryToMessage, collectAssistantUsageMetadata, composeEventName, confirmAction, createAssistantMessage, createDefaultProviderCapabilities, createExecutionProxy, createLogger, createSystemMessage, createToolMessage, createUserMessage, estimateBlendedCostPer1000, estimateContextTokensFromMessages, estimateSerializedContextTokens, evaluatePermission, extractEnumValues, findProviderDefinition, formatEnvReference, formatSupportedProviderTypes, formatTokenCount, getGlobalLogLevel, getMessagesForAPI, getModelContextWindow, getModelMaxOutput, getModelName, getProviderCapabilities, getProviderCredentialRequirement, getSchemaTypeName, getToolEstimatedDuration, getToolExecutionSteps, hasUsableSecretReference, hasValidationConstraints, isAssistantMessage, isChatEntry, isConfirmed, isDefaultEventService, isEnvReference, isImageGenerationProvider, isProgressReportingTool, isSystemMessage, isToolMessage, isUserMessage, isVideoGenerationProvider, logger, lookupModelPrice, messageToHistoryEntry, multiSelectAction, normalizeStructuredOutput, parseStructuredResponseText, readTokenUsageFromMessage, readTokenUsageFromMetadata, resolveEnvReference, resolvePlatformShell, runHooks, selectAction, setGlobalLogLevel, setToolProgressCallback, startPeriodicTask, stopPeriodicTask, sumHistoryUsage, textAction, validateAgainstJsonSchema, validateAgentConfig, validateApiKey, validateModelName, validateProviderName, validateUserInput, withEventEmission, zodToJsonSchema };