@everworker/oneringai 0.4.2 → 0.4.4

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,1397 +0,0 @@
1
- import { I as IConnectorRegistry, e as IProvider } from './IProvider-B6hqVVq8.js';
2
- import { EventEmitter } from 'eventemitter3';
3
-
4
- /**
5
- * Content types based on OpenAI Responses API format
6
- */
7
- declare enum ContentType {
8
- INPUT_TEXT = "input_text",
9
- INPUT_IMAGE_URL = "input_image_url",
10
- INPUT_FILE = "input_file",
11
- OUTPUT_TEXT = "output_text",
12
- TOOL_USE = "tool_use",
13
- TOOL_RESULT = "tool_result",
14
- THINKING = "thinking"
15
- }
16
- interface BaseContent {
17
- type: ContentType;
18
- }
19
- interface InputTextContent extends BaseContent {
20
- type: ContentType.INPUT_TEXT;
21
- text: string;
22
- }
23
- interface InputImageContent extends BaseContent {
24
- type: ContentType.INPUT_IMAGE_URL;
25
- image_url: {
26
- url: string;
27
- detail?: 'auto' | 'low' | 'high';
28
- };
29
- }
30
- interface InputFileContent extends BaseContent {
31
- type: ContentType.INPUT_FILE;
32
- file_id: string;
33
- }
34
- interface OutputTextContent extends BaseContent {
35
- type: ContentType.OUTPUT_TEXT;
36
- text: string;
37
- annotations?: any[];
38
- }
39
- interface ToolUseContent extends BaseContent {
40
- type: ContentType.TOOL_USE;
41
- id: string;
42
- name: string;
43
- arguments: string;
44
- }
45
- interface ToolResultContent extends BaseContent {
46
- type: ContentType.TOOL_RESULT;
47
- tool_use_id: string;
48
- content: string | any;
49
- error?: string;
50
- /**
51
- * Images extracted from tool results via the __images convention.
52
- * Stored separately from `content` so they don't inflate text-based token counts.
53
- * Provider converters read this field to inject native multimodal image blocks.
54
- */
55
- __images?: Array<{
56
- base64: string;
57
- mediaType: string;
58
- }>;
59
- }
60
- interface ThinkingContent extends BaseContent {
61
- type: ContentType.THINKING;
62
- thinking: string;
63
- /** Anthropic's opaque signature for round-tripping thinking blocks */
64
- signature?: string;
65
- /** Whether this thinking block should be persisted in conversation history.
66
- * Anthropic requires it (true), OpenAI/Google do not (false). */
67
- persistInHistory: boolean;
68
- }
69
- type Content = InputTextContent | InputImageContent | InputFileContent | OutputTextContent | ToolUseContent | ToolResultContent | ThinkingContent;
70
-
71
- /**
72
- * Message entity based on OpenAI Responses API format
73
- */
74
-
75
- declare enum MessageRole {
76
- USER = "user",
77
- ASSISTANT = "assistant",
78
- DEVELOPER = "developer"
79
- }
80
- interface Message {
81
- type: 'message';
82
- id?: string;
83
- role: MessageRole;
84
- content: Content[];
85
- }
86
- interface CompactionItem {
87
- type: 'compaction';
88
- id: string;
89
- encrypted_content: string;
90
- }
91
- interface ReasoningItem {
92
- type: 'reasoning';
93
- id: string;
94
- effort?: 'low' | 'medium' | 'high';
95
- summary?: string;
96
- encrypted_content?: string;
97
- }
98
- type InputItem = Message | CompactionItem;
99
- type OutputItem = Message | CompactionItem | ReasoningItem;
100
-
101
- /**
102
- * Memory entities for WorkingMemory
103
- *
104
- * This module provides a GENERIC memory system that works across all agent types:
105
- * - Basic Agent: Simple session/persistent scoping with static priority
106
- * - TaskAgent: Task-aware scoping with dynamic priority based on task states
107
- * - UniversalAgent: Mode-aware, switches strategy based on current mode
108
- *
109
- * The key abstraction is PriorityCalculator - a pluggable strategy that
110
- * determines entry priority for eviction decisions.
111
- */
112
- /**
113
- * Simple scope for basic agents - just a lifecycle label
114
- */
115
- type SimpleScope = 'session' | 'persistent';
116
- /**
117
- * Task-aware scope for TaskAgent/UniversalAgent
118
- */
119
- type TaskAwareScope = {
120
- type: 'task';
121
- taskIds: string[];
122
- } | {
123
- type: 'plan';
124
- } | {
125
- type: 'persistent';
126
- };
127
- /**
128
- * Union type - memory system accepts both
129
- */
130
- type MemoryScope = SimpleScope | TaskAwareScope;
131
- /**
132
- * Type guard: is this a task-aware scope?
133
- */
134
- declare function isTaskAwareScope(scope: MemoryScope): scope is TaskAwareScope;
135
- /**
136
- * Type guard: is this a simple scope?
137
- */
138
- declare function isSimpleScope(scope: MemoryScope): scope is SimpleScope;
139
- /**
140
- * Compare two scopes for equality
141
- * Handles both simple scopes (string comparison) and task-aware scopes (deep comparison)
142
- */
143
- declare function scopeEquals(a: MemoryScope, b: MemoryScope): boolean;
144
- /**
145
- * Check if a scope matches a filter scope
146
- * More flexible than scopeEquals - supports partial matching for task scopes
147
- */
148
- declare function scopeMatches(entryScope: MemoryScope, filterScope: MemoryScope): boolean;
149
- /**
150
- * Priority determines eviction order (lower priority evicted first)
151
- *
152
- * - critical: Never evicted (pinned, or actively in use)
153
- * - high: Important data, evicted only when necessary
154
- * - normal: Default priority
155
- * - low: Candidate for eviction (stale data, completed task data)
156
- */
157
- type MemoryPriority = 'critical' | 'high' | 'normal' | 'low';
158
- /**
159
- * Priority values for comparison (higher = more important, less likely to evict)
160
- */
161
- declare const MEMORY_PRIORITY_VALUES: Record<MemoryPriority, number>;
162
- /**
163
- * Memory tier for hierarchical data management
164
- *
165
- * The tier system provides a structured approach to managing research/analysis data:
166
- * - raw: Original data, low priority, first to be evicted
167
- * - summary: Processed summaries, normal priority
168
- * - findings: Final conclusions/insights, high priority, kept longest
169
- *
170
- * Workflow: raw → summary → findings (data gets more refined, priority increases)
171
- */
172
- type MemoryTier = 'raw' | 'summary' | 'findings';
173
- /**
174
- * Context passed to priority calculator - varies by agent type
175
- */
176
- interface PriorityContext {
177
- /** For TaskAgent: map of taskId → current status */
178
- taskStates?: Map<string, TaskStatusForMemory>;
179
- /** For UniversalAgent: current mode */
180
- mode?: 'interactive' | 'planning' | 'executing';
181
- /** Custom context for extensions */
182
- [key: string]: unknown;
183
- }
184
- /**
185
- * Task status values for priority calculation
186
- */
187
- type TaskStatusForMemory = 'pending' | 'in_progress' | 'completed' | 'failed' | 'skipped' | 'cancelled';
188
- /**
189
- * Check if a task status is terminal (task will not progress further)
190
- */
191
- declare function isTerminalMemoryStatus(status: TaskStatusForMemory): boolean;
192
- /**
193
- * Priority calculator function type.
194
- * Given an entry and optional context, returns the effective priority.
195
- */
196
- type PriorityCalculator = (entry: MemoryEntry, context?: PriorityContext) => MemoryPriority;
197
- /**
198
- * Reason why an entry became stale
199
- */
200
- type StaleReason = 'task_completed' | 'task_failed' | 'unused' | 'scope_cleared';
201
- /**
202
- * Information about a stale entry for LLM notification
203
- */
204
- interface StaleEntryInfo {
205
- key: string;
206
- description: string;
207
- reason: StaleReason;
208
- previousPriority: MemoryPriority;
209
- newPriority: MemoryPriority;
210
- taskIds?: string[];
211
- }
212
- /**
213
- * Single memory entry stored in working memory
214
- */
215
- interface MemoryEntry {
216
- key: string;
217
- description: string;
218
- value: unknown;
219
- sizeBytes: number;
220
- scope: MemoryScope;
221
- basePriority: MemoryPriority;
222
- pinned: boolean;
223
- createdAt: number;
224
- lastAccessedAt: number;
225
- accessCount: number;
226
- }
227
- /**
228
- * Index entry (lightweight, always in context)
229
- */
230
- interface MemoryIndexEntry {
231
- key: string;
232
- description: string;
233
- size: string;
234
- scope: MemoryScope;
235
- effectivePriority: MemoryPriority;
236
- pinned: boolean;
237
- }
238
- /**
239
- * Full memory index with metadata
240
- */
241
- interface MemoryIndex {
242
- entries: MemoryIndexEntry[];
243
- totalSizeBytes: number;
244
- totalSizeHuman: string;
245
- limitBytes: number;
246
- limitHuman: string;
247
- utilizationPercent: number;
248
- /** Total entry count (before any truncation for display) */
249
- totalEntryCount: number;
250
- /** Number of entries omitted from display due to maxIndexEntries limit */
251
- omittedCount: number;
252
- }
253
- /**
254
- * Configuration for working memory
255
- */
256
- interface WorkingMemoryConfig {
257
- /** Max memory size in bytes. If not set, calculated from model context */
258
- maxSizeBytes?: number;
259
- /** Max number of entries in the memory index. Excess entries are auto-evicted via LRU. Default: 30 */
260
- maxIndexEntries?: number;
261
- /** Max description length */
262
- descriptionMaxLength: number;
263
- /** Percentage at which to warn agent */
264
- softLimitPercent: number;
265
- /** Percentage of model context to allocate to memory */
266
- contextAllocationPercent: number;
267
- }
268
- /**
269
- * Input for creating a memory entry
270
- */
271
- interface MemoryEntryInput {
272
- key: string;
273
- description: string;
274
- value: unknown;
275
- /** Scope - defaults to 'session' for basic agents */
276
- scope?: MemoryScope;
277
- /** Base priority - may be overridden by dynamic calculation */
278
- priority?: MemoryPriority;
279
- /** If true, entry is never evicted */
280
- pinned?: boolean;
281
- }
282
- /**
283
- * Create a task-scoped memory entry input
284
- */
285
- declare function forTasks(key: string, description: string, value: unknown, taskIds: string[], options?: {
286
- priority?: MemoryPriority;
287
- pinned?: boolean;
288
- }): MemoryEntryInput;
289
- /**
290
- * Create a plan-scoped memory entry input
291
- */
292
- declare function forPlan(key: string, description: string, value: unknown, options?: {
293
- priority?: MemoryPriority;
294
- pinned?: boolean;
295
- }): MemoryEntryInput;
296
- /**
297
- * Default configuration values
298
- */
299
- declare const DEFAULT_MEMORY_CONFIG: WorkingMemoryConfig;
300
- /**
301
- * Calculate the size of a value in bytes (JSON serialization)
302
- * Uses Buffer.byteLength for accurate UTF-8 byte count
303
- */
304
- declare function calculateEntrySize(value: unknown): number;
305
-
306
- /**
307
- * Tool context interface - passed to tools during execution
308
- *
309
- * This is a SIMPLE interface. Tools receive only what they need:
310
- * - agentId: For logging/tracing
311
- * - taskId: For task-aware operations
312
- * - memory: For storing/retrieving data
313
- * - signal: For cancellation
314
- *
315
- * Plugins and context management are NOT exposed to tools.
316
- * Tools should be self-contained and not depend on framework internals.
317
- */
318
-
319
- /**
320
- * Limited memory access for tools
321
- *
322
- * This interface is designed to work with all agent types:
323
- * - Basic agents: Use simple scopes ('session', 'persistent')
324
- * - TaskAgent: Use task-aware scopes ({ type: 'task', taskIds: [...] })
325
- * - UniversalAgent: Switches between simple and task-aware based on mode
326
- */
327
- interface WorkingMemoryAccess {
328
- get(key: string): Promise<unknown>;
329
- /**
330
- * Store a value in memory
331
- *
332
- * @param key - Unique key for the entry
333
- * @param description - Short description (max 150 chars)
334
- * @param value - Data to store
335
- * @param options - Optional scope, priority, and pinning
336
- */
337
- set(key: string, description: string, value: unknown, options?: {
338
- /** Scope determines lifecycle - defaults to 'session' */
339
- scope?: MemoryScope;
340
- /** Base priority for eviction ordering */
341
- priority?: MemoryPriority;
342
- /** If true, entry is never evicted */
343
- pinned?: boolean;
344
- }): Promise<void>;
345
- delete(key: string): Promise<void>;
346
- has(key: string): Promise<boolean>;
347
- /**
348
- * List all memory entries
349
- * Returns key, description, and computed priority info
350
- */
351
- list(): Promise<Array<{
352
- key: string;
353
- description: string;
354
- effectivePriority?: MemoryPriority;
355
- pinned?: boolean;
356
- }>>;
357
- }
358
- /**
359
- * Context passed to tool execute function
360
- *
361
- * Simple and clean - only what tools actually need.
362
- */
363
- interface ToolContext {
364
- /** Agent ID (for logging/tracing) */
365
- agentId?: string;
366
- /** Task ID (if running in TaskAgent) */
367
- taskId?: string;
368
- /** User ID — auto-populated from Agent config (userId). Also settable manually via agent.tools.setToolContext(). */
369
- userId?: string;
370
- /** Connector registry scoped to this agent's allowed connectors and userId */
371
- connectorRegistry?: IConnectorRegistry;
372
- /** Working memory access (if agent has memory feature enabled) */
373
- memory?: WorkingMemoryAccess;
374
- /** Abort signal for cancellation */
375
- signal?: AbortSignal;
376
- }
377
-
378
- /**
379
- * Tool entities with blocking/non-blocking execution support
380
- */
381
-
382
- interface JSONSchema {
383
- type: string;
384
- properties?: Record<string, any>;
385
- required?: string[];
386
- [key: string]: any;
387
- }
388
- interface FunctionToolDefinition {
389
- type: 'function';
390
- function: {
391
- name: string;
392
- description?: string;
393
- parameters?: JSONSchema;
394
- strict?: boolean;
395
- };
396
- blocking?: boolean;
397
- timeout?: number;
398
- }
399
- interface BuiltInTool {
400
- type: 'web_search' | 'file_search' | 'computer_use' | 'code_interpreter';
401
- blocking?: boolean;
402
- }
403
- type Tool = FunctionToolDefinition | BuiltInTool;
404
- declare enum ToolCallState {
405
- PENDING = "pending",// Tool call identified, not yet executed
406
- EXECUTING = "executing",// Currently executing
407
- COMPLETED = "completed",// Successfully completed
408
- FAILED = "failed",// Execution failed
409
- TIMEOUT = "timeout"
410
- }
411
- interface ToolCall {
412
- id: string;
413
- type: 'function';
414
- function: {
415
- name: string;
416
- arguments: string;
417
- };
418
- blocking: boolean;
419
- state: ToolCallState;
420
- startTime?: Date;
421
- endTime?: Date;
422
- error?: string;
423
- }
424
- interface ToolResult {
425
- tool_use_id: string;
426
- tool_name?: string;
427
- tool_args?: Record<string, unknown>;
428
- content: any;
429
- error?: string;
430
- executionTime?: number;
431
- state: ToolCallState;
432
- }
433
- /**
434
- * Tool execution context - tracks all tool calls in a generation
435
- */
436
- interface ToolExecutionContext {
437
- executionId: string;
438
- toolCalls: Map<string, ToolCall>;
439
- pendingNonBlocking: Set<string>;
440
- completedResults: Map<string, ToolResult>;
441
- }
442
- /**
443
- * Output handling hints for context management
444
- */
445
- interface ToolOutputHints {
446
- expectedSize?: 'small' | 'medium' | 'large' | 'variable';
447
- summarize?: (output: unknown) => string;
448
- }
449
- /**
450
- * Idempotency configuration for tool caching
451
- */
452
- interface ToolIdempotency {
453
- /**
454
- * @deprecated Use 'cacheable' instead. Will be removed in a future version.
455
- * If true, tool is naturally idempotent (e.g., read-only) and doesn't need caching.
456
- * If false, tool results should be cached based on arguments.
457
- */
458
- safe?: boolean;
459
- /**
460
- * If true, tool results can be cached based on arguments.
461
- * Use this for tools that return deterministic results for the same inputs.
462
- * Takes precedence over the deprecated 'safe' field.
463
- * @default false
464
- */
465
- cacheable?: boolean;
466
- keyFn?: (args: Record<string, unknown>) => string;
467
- ttlMs?: number;
468
- }
469
- /**
470
- * Permission configuration for a tool
471
- *
472
- * Controls when approval is required for tool execution.
473
- * Used by the ToolPermissionManager.
474
- */
475
- interface ToolPermissionConfig {
476
- /**
477
- * When approval is required.
478
- * - 'once' - Require approval for each call
479
- * - 'session' - Approve once per session
480
- * - 'always' - Auto-approve (no prompts)
481
- * - 'never' - Always blocked
482
- * @default 'once'
483
- */
484
- scope?: 'once' | 'session' | 'always' | 'never';
485
- /**
486
- * Risk level classification.
487
- * @default 'low'
488
- */
489
- riskLevel?: 'low' | 'medium' | 'high' | 'critical';
490
- /**
491
- * Custom message shown in approval UI.
492
- */
493
- approvalMessage?: string;
494
- /**
495
- * Argument names that should be highlighted as sensitive.
496
- */
497
- sensitiveArgs?: string[];
498
- /**
499
- * TTL for session approvals (milliseconds).
500
- */
501
- sessionTTLMs?: number;
502
- }
503
- /**
504
- * User-provided tool function
505
- */
506
- interface ToolFunction<TArgs = any, TResult = any> {
507
- definition: FunctionToolDefinition;
508
- execute: (args: TArgs, context?: ToolContext) => Promise<TResult>;
509
- idempotency?: ToolIdempotency;
510
- output?: ToolOutputHints;
511
- /** Permission settings for this tool. If not set, defaults are used. */
512
- permission?: ToolPermissionConfig;
513
- /**
514
- * Dynamic description generator for the tool.
515
- * If provided, this function is called when tool definitions are serialized for the LLM,
516
- * allowing the description to reflect current state (e.g., available connectors).
517
- *
518
- * The returned string replaces definition.function.description when sending to LLM.
519
- * The static description in definition.function.description serves as a fallback.
520
- *
521
- * @param context - Current ToolContext (includes userId, agentId, etc.)
522
- * @returns The current tool description
523
- *
524
- * @example
525
- * // Tool with dynamic connector list scoped to current user:
526
- * descriptionFactory: (context) => {
527
- * const connectors = getConnectorsForUser(context?.userId);
528
- * return `Execute API calls. Available connectors: ${connectors.map(c => c.name).join(', ')}`;
529
- * }
530
- */
531
- descriptionFactory?: (context?: ToolContext) => string;
532
- /**
533
- * Returns a human-readable description of a tool call.
534
- * Used for logging, UI display, and debugging.
535
- *
536
- * @param args - The arguments passed to the tool
537
- * @returns A concise description (e.g., "reading /path/to/file.ts")
538
- *
539
- * If not implemented, use `defaultDescribeCall()` as a fallback.
540
- *
541
- * @example
542
- * // For read_file tool:
543
- * describeCall: (args) => args.file_path
544
- *
545
- * @example
546
- * // For bash tool:
547
- * describeCall: (args) => args.command.length > 50
548
- * ? args.command.slice(0, 47) + '...'
549
- * : args.command
550
- */
551
- describeCall?: (args: TArgs) => string;
552
- }
553
- /**
554
- * Default implementation for describeCall.
555
- * Shows the first meaningful argument value.
556
- *
557
- * @param args - Tool arguments object
558
- * @param maxLength - Maximum length before truncation (default: 60)
559
- * @returns Human-readable description
560
- *
561
- * @example
562
- * defaultDescribeCall({ file_path: '/path/to/file.ts' })
563
- * // Returns: '/path/to/file.ts'
564
- *
565
- * @example
566
- * defaultDescribeCall({ query: 'search term', limit: 10 })
567
- * // Returns: 'search term'
568
- */
569
- declare function defaultDescribeCall(args: Record<string, unknown>, maxLength?: number): string;
570
- /**
571
- * Get a human-readable description of a tool call.
572
- * Uses the tool's describeCall method if available, otherwise falls back to default.
573
- *
574
- * @param tool - The tool function
575
- * @param args - The arguments passed to the tool
576
- * @returns Human-readable description
577
- */
578
- declare function getToolCallDescription<TArgs>(tool: ToolFunction<TArgs>, args: TArgs): string;
579
-
580
- /**
581
- * LLM Response entity based on OpenAI Responses API format
582
- */
583
-
584
- /**
585
- * Token usage statistics
586
- */
587
- interface TokenUsage {
588
- input_tokens: number;
589
- output_tokens: number;
590
- total_tokens: number;
591
- output_tokens_details?: {
592
- reasoning_tokens: number;
593
- };
594
- }
595
- interface LLMResponse {
596
- id: string;
597
- object: 'response';
598
- created_at: number;
599
- status: 'completed' | 'failed' | 'in_progress' | 'cancelled' | 'queued' | 'incomplete';
600
- model: string;
601
- output: OutputItem[];
602
- output_text?: string;
603
- thinking?: string;
604
- usage: TokenUsage;
605
- error?: {
606
- type: string;
607
- message: string;
608
- };
609
- metadata?: Record<string, string>;
610
- }
611
- type AgentResponse = LLMResponse;
612
-
613
- /**
614
- * Streaming event types for real-time LLM responses
615
- * Based on OpenAI Responses API event format as the internal standard
616
- */
617
-
618
- /**
619
- * Stream event type enum
620
- */
621
- declare enum StreamEventType {
622
- RESPONSE_CREATED = "response.created",
623
- RESPONSE_IN_PROGRESS = "response.in_progress",
624
- OUTPUT_TEXT_DELTA = "response.output_text.delta",
625
- OUTPUT_TEXT_DONE = "response.output_text.done",
626
- TOOL_CALL_START = "response.tool_call.start",
627
- TOOL_CALL_ARGUMENTS_DELTA = "response.tool_call_arguments.delta",
628
- TOOL_CALL_ARGUMENTS_DONE = "response.tool_call_arguments.done",
629
- TOOL_EXECUTION_START = "response.tool_execution.start",
630
- TOOL_EXECUTION_DONE = "response.tool_execution.done",
631
- ITERATION_COMPLETE = "response.iteration.complete",
632
- REASONING_DELTA = "response.reasoning.delta",
633
- REASONING_DONE = "response.reasoning.done",
634
- RESPONSE_COMPLETE = "response.complete",
635
- ERROR = "response.error"
636
- }
637
- /**
638
- * Base interface for all stream events
639
- */
640
- interface BaseStreamEvent {
641
- type: StreamEventType;
642
- response_id: string;
643
- }
644
- /**
645
- * Response created - first event in stream
646
- */
647
- interface ResponseCreatedEvent extends BaseStreamEvent {
648
- type: StreamEventType.RESPONSE_CREATED;
649
- model: string;
650
- created_at: number;
651
- }
652
- /**
653
- * Response in progress
654
- */
655
- interface ResponseInProgressEvent extends BaseStreamEvent {
656
- type: StreamEventType.RESPONSE_IN_PROGRESS;
657
- }
658
- /**
659
- * Text delta - incremental text output
660
- */
661
- interface OutputTextDeltaEvent extends BaseStreamEvent {
662
- type: StreamEventType.OUTPUT_TEXT_DELTA;
663
- item_id: string;
664
- output_index: number;
665
- content_index: number;
666
- delta: string;
667
- sequence_number: number;
668
- }
669
- /**
670
- * Text output complete for this item
671
- */
672
- interface OutputTextDoneEvent extends BaseStreamEvent {
673
- type: StreamEventType.OUTPUT_TEXT_DONE;
674
- item_id: string;
675
- output_index: number;
676
- text: string;
677
- }
678
- /**
679
- * Tool call detected and starting
680
- */
681
- interface ToolCallStartEvent extends BaseStreamEvent {
682
- type: StreamEventType.TOOL_CALL_START;
683
- item_id: string;
684
- tool_call_id: string;
685
- tool_name: string;
686
- }
687
- /**
688
- * Tool call arguments delta - incremental JSON
689
- */
690
- interface ToolCallArgumentsDeltaEvent extends BaseStreamEvent {
691
- type: StreamEventType.TOOL_CALL_ARGUMENTS_DELTA;
692
- item_id: string;
693
- tool_call_id: string;
694
- tool_name: string;
695
- delta: string;
696
- sequence_number: number;
697
- }
698
- /**
699
- * Tool call arguments complete
700
- */
701
- interface ToolCallArgumentsDoneEvent extends BaseStreamEvent {
702
- type: StreamEventType.TOOL_CALL_ARGUMENTS_DONE;
703
- tool_call_id: string;
704
- tool_name: string;
705
- arguments: string;
706
- incomplete?: boolean;
707
- }
708
- /**
709
- * Tool execution starting
710
- */
711
- interface ToolExecutionStartEvent extends BaseStreamEvent {
712
- type: StreamEventType.TOOL_EXECUTION_START;
713
- tool_call_id: string;
714
- tool_name: string;
715
- arguments: any;
716
- }
717
- /**
718
- * Tool execution complete
719
- */
720
- interface ToolExecutionDoneEvent extends BaseStreamEvent {
721
- type: StreamEventType.TOOL_EXECUTION_DONE;
722
- tool_call_id: string;
723
- tool_name: string;
724
- result: any;
725
- execution_time_ms: number;
726
- error?: string;
727
- }
728
- /**
729
- * Iteration complete - end of agentic loop iteration
730
- */
731
- interface IterationCompleteEvent$1 extends BaseStreamEvent {
732
- type: StreamEventType.ITERATION_COMPLETE;
733
- iteration: number;
734
- tool_calls_count: number;
735
- has_more_iterations: boolean;
736
- }
737
- /**
738
- * Response complete - final event
739
- */
740
- interface ResponseCompleteEvent extends BaseStreamEvent {
741
- type: StreamEventType.RESPONSE_COMPLETE;
742
- status: 'completed' | 'incomplete' | 'failed';
743
- usage: TokenUsage;
744
- iterations: number;
745
- duration_ms?: number;
746
- }
747
- /**
748
- * Reasoning/thinking delta - incremental reasoning output
749
- */
750
- interface ReasoningDeltaEvent extends BaseStreamEvent {
751
- type: StreamEventType.REASONING_DELTA;
752
- item_id: string;
753
- delta: string;
754
- sequence_number: number;
755
- }
756
- /**
757
- * Reasoning/thinking complete for this item
758
- */
759
- interface ReasoningDoneEvent extends BaseStreamEvent {
760
- type: StreamEventType.REASONING_DONE;
761
- item_id: string;
762
- thinking: string;
763
- }
764
- /**
765
- * Error event
766
- */
767
- interface ErrorEvent extends BaseStreamEvent {
768
- type: StreamEventType.ERROR;
769
- error: {
770
- type: string;
771
- message: string;
772
- code?: string;
773
- };
774
- recoverable: boolean;
775
- }
776
- /**
777
- * Union type of all stream events
778
- * Discriminated by 'type' field for type narrowing
779
- */
780
- type StreamEvent = ResponseCreatedEvent | ResponseInProgressEvent | OutputTextDeltaEvent | OutputTextDoneEvent | ReasoningDeltaEvent | ReasoningDoneEvent | ToolCallStartEvent | ToolCallArgumentsDeltaEvent | ToolCallArgumentsDoneEvent | ToolExecutionStartEvent | ToolExecutionDoneEvent | IterationCompleteEvent$1 | ResponseCompleteEvent | ErrorEvent;
781
- /**
782
- * Type guard to check if event is a specific type
783
- */
784
- declare function isStreamEvent<T extends StreamEvent>(event: StreamEvent, type: StreamEventType): event is T;
785
- /**
786
- * Type guards for specific events
787
- */
788
- declare function isOutputTextDelta(event: StreamEvent): event is OutputTextDeltaEvent;
789
- declare function isToolCallStart(event: StreamEvent): event is ToolCallStartEvent;
790
- declare function isToolCallArgumentsDelta(event: StreamEvent): event is ToolCallArgumentsDeltaEvent;
791
- declare function isToolCallArgumentsDone(event: StreamEvent): event is ToolCallArgumentsDoneEvent;
792
- declare function isReasoningDelta(event: StreamEvent): event is ReasoningDeltaEvent;
793
- declare function isReasoningDone(event: StreamEvent): event is ReasoningDoneEvent;
794
- declare function isResponseComplete(event: StreamEvent): event is ResponseCompleteEvent;
795
- declare function isErrorEvent(event: StreamEvent): event is ErrorEvent;
796
-
797
- /**
798
- * Text generation provider interface
799
- */
800
-
801
- interface TextGenerateOptions {
802
- model: string;
803
- input: string | InputItem[];
804
- instructions?: string;
805
- tools?: Tool[];
806
- tool_choice?: 'auto' | 'required' | {
807
- type: 'function';
808
- function: {
809
- name: string;
810
- };
811
- };
812
- temperature?: number;
813
- max_output_tokens?: number;
814
- response_format?: {
815
- type: 'text' | 'json_object' | 'json_schema';
816
- json_schema?: any;
817
- };
818
- parallel_tool_calls?: boolean;
819
- previous_response_id?: string;
820
- metadata?: Record<string, string>;
821
- /** Vendor-agnostic thinking/reasoning configuration */
822
- thinking?: {
823
- enabled: boolean;
824
- /** Budget in tokens for thinking (Anthropic & Google) */
825
- budgetTokens?: number;
826
- /** Reasoning effort level (OpenAI) */
827
- effort?: 'low' | 'medium' | 'high';
828
- };
829
- /** Vendor-specific options (e.g., Google's thinkingLevel, OpenAI's reasoning_effort) */
830
- vendorOptions?: Record<string, any>;
831
- }
832
- interface ModelCapabilities {
833
- supportsTools: boolean;
834
- supportsVision: boolean;
835
- supportsJSON: boolean;
836
- supportsJSONSchema: boolean;
837
- maxTokens: number;
838
- maxInputTokens?: number;
839
- maxOutputTokens?: number;
840
- }
841
- interface ITextProvider extends IProvider {
842
- /**
843
- * Generate text response
844
- */
845
- generate(options: TextGenerateOptions): Promise<LLMResponse>;
846
- /**
847
- * Stream text response with real-time events
848
- * Returns an async iterator of streaming events
849
- */
850
- streamGenerate(options: TextGenerateOptions): AsyncIterableIterator<StreamEvent>;
851
- /**
852
- * Get model capabilities
853
- */
854
- getModelCapabilities(model: string): ModelCapabilities;
855
- /**
856
- * List available models from the provider's API
857
- */
858
- listModels(): Promise<string[]>;
859
- }
860
-
861
- /**
862
- * Execution context - tracks state, metrics, and history for agent execution
863
- * Includes memory safety (circular buffers) and resource limits
864
- */
865
-
866
- type HistoryMode = 'none' | 'summary' | 'full';
867
- interface ExecutionContextConfig {
868
- maxHistorySize?: number;
869
- historyMode?: HistoryMode;
870
- maxAuditTrailSize?: number;
871
- }
872
- interface IterationRecord {
873
- iteration: number;
874
- request: TextGenerateOptions;
875
- response: AgentResponse;
876
- toolCalls: ToolCall[];
877
- toolResults: ToolResult[];
878
- startTime: Date;
879
- endTime: Date;
880
- }
881
- interface IterationSummary {
882
- iteration: number;
883
- tokens: number;
884
- toolCount: number;
885
- duration: number;
886
- timestamp: Date;
887
- }
888
- interface ExecutionMetrics {
889
- totalDuration: number;
890
- llmDuration: number;
891
- toolDuration: number;
892
- hookDuration: number;
893
- iterationCount: number;
894
- toolCallCount: number;
895
- toolSuccessCount: number;
896
- toolFailureCount: number;
897
- toolTimeoutCount: number;
898
- inputTokens: number;
899
- outputTokens: number;
900
- totalTokens: number;
901
- errors: Array<{
902
- type: string;
903
- message: string;
904
- timestamp: Date;
905
- }>;
906
- }
907
- interface AuditEntry {
908
- timestamp: Date;
909
- type: 'hook_executed' | 'tool_modified' | 'tool_skipped' | 'execution_paused' | 'execution_resumed' | 'tool_approved' | 'tool_rejected' | 'tool_blocked' | 'tool_permission_approved';
910
- hookName?: string;
911
- toolName?: string;
912
- details: any;
913
- }
914
- declare class ExecutionContext {
915
- readonly executionId: string;
916
- readonly startTime: Date;
917
- iteration: number;
918
- readonly toolCalls: Map<string, ToolCall>;
919
- readonly toolResults: Map<string, ToolResult>;
920
- paused: boolean;
921
- pauseReason?: string;
922
- cancelled: boolean;
923
- cancelReason?: string;
924
- readonly metadata: Map<string, any>;
925
- private readonly config;
926
- private readonly iterations;
927
- private readonly iterationSummaries;
928
- readonly metrics: ExecutionMetrics;
929
- private readonly auditTrail;
930
- constructor(executionId: string, config?: ExecutionContextConfig);
931
- /**
932
- * Add iteration to history (memory-safe)
933
- */
934
- addIteration(record: IterationRecord): void;
935
- /**
936
- * Get iteration history
937
- */
938
- getHistory(): IterationRecord[] | IterationSummary[];
939
- /**
940
- * Add audit entry
941
- */
942
- audit(type: AuditEntry['type'], details: any, hookName?: string, toolName?: string): void;
943
- /**
944
- * Get audit trail
945
- */
946
- getAuditTrail(): readonly AuditEntry[];
947
- /**
948
- * Update metrics
949
- */
950
- updateMetrics(update: Partial<ExecutionMetrics>): void;
951
- /**
952
- * Add tool call to tracking
953
- */
954
- addToolCall(toolCall: ToolCall): void;
955
- /**
956
- * Add tool result to tracking
957
- */
958
- addToolResult(result: ToolResult): void;
959
- /**
960
- * Check resource limits
961
- */
962
- checkLimits(limits?: {
963
- maxExecutionTime?: number;
964
- maxToolCalls?: number;
965
- maxContextSize?: number;
966
- }): void;
967
- /**
968
- * Estimate memory usage (rough approximation)
969
- */
970
- private estimateSize;
971
- /**
972
- * Cleanup resources and release memory
973
- * Clears all internal arrays and maps to allow garbage collection
974
- */
975
- cleanup(): void;
976
- /**
977
- * Get execution summary
978
- */
979
- getSummary(): {
980
- executionId: string;
981
- startTime: Date;
982
- currentIteration: number;
983
- paused: boolean;
984
- cancelled: boolean;
985
- metrics: {
986
- totalDuration: number;
987
- llmDuration: number;
988
- toolDuration: number;
989
- hookDuration: number;
990
- iterationCount: number;
991
- toolCallCount: number;
992
- toolSuccessCount: number;
993
- toolFailureCount: number;
994
- toolTimeoutCount: number;
995
- inputTokens: number;
996
- outputTokens: number;
997
- totalTokens: number;
998
- errors: Array<{
999
- type: string;
1000
- message: string;
1001
- timestamp: Date;
1002
- }>;
1003
- };
1004
- totalDuration: number;
1005
- };
1006
- }
1007
-
1008
- /**
1009
- * Event types for agent execution
1010
- * These events are emitted asynchronously for notifications (UI updates, logging, etc.)
1011
- */
1012
-
1013
- /**
1014
- * Minimal config type for execution start events.
1015
- * This captures the essential info without importing full AgentConfig.
1016
- */
1017
- interface ExecutionConfig {
1018
- model: string;
1019
- instructions?: string;
1020
- temperature?: number;
1021
- maxIterations?: number;
1022
- }
1023
- interface ExecutionStartEvent {
1024
- executionId: string;
1025
- config: ExecutionConfig;
1026
- timestamp: Date;
1027
- }
1028
- interface ExecutionCompleteEvent {
1029
- executionId: string;
1030
- response: AgentResponse;
1031
- timestamp: Date;
1032
- duration: number;
1033
- }
1034
- interface ExecutionErrorEvent {
1035
- executionId: string;
1036
- error: Error;
1037
- timestamp: Date;
1038
- }
1039
- interface ExecutionPausedEvent {
1040
- executionId: string;
1041
- reason?: string;
1042
- timestamp: Date;
1043
- }
1044
- interface ExecutionResumedEvent {
1045
- executionId: string;
1046
- timestamp: Date;
1047
- }
1048
- interface ExecutionCancelledEvent {
1049
- executionId: string;
1050
- reason?: string;
1051
- timestamp: Date;
1052
- }
1053
- interface ExecutionMaxIterationsEvent {
1054
- executionId: string;
1055
- iteration: number;
1056
- maxIterations: number;
1057
- timestamp: Date;
1058
- }
1059
- interface IterationStartEvent {
1060
- executionId: string;
1061
- iteration: number;
1062
- timestamp: Date;
1063
- }
1064
- interface IterationCompleteEvent {
1065
- executionId: string;
1066
- iteration: number;
1067
- response: AgentResponse;
1068
- timestamp: Date;
1069
- duration: number;
1070
- }
1071
- interface LLMRequestEvent {
1072
- executionId: string;
1073
- iteration: number;
1074
- options: TextGenerateOptions;
1075
- timestamp: Date;
1076
- }
1077
- interface LLMResponseEvent {
1078
- executionId: string;
1079
- iteration: number;
1080
- response: AgentResponse;
1081
- timestamp: Date;
1082
- duration: number;
1083
- }
1084
- interface LLMErrorEvent {
1085
- executionId: string;
1086
- iteration: number;
1087
- error: Error;
1088
- timestamp: Date;
1089
- }
1090
- interface ToolDetectedEvent {
1091
- executionId: string;
1092
- iteration: number;
1093
- toolCalls: ToolCall[];
1094
- timestamp: Date;
1095
- }
1096
- interface ToolStartEvent {
1097
- executionId: string;
1098
- iteration: number;
1099
- toolCall: ToolCall;
1100
- timestamp: Date;
1101
- }
1102
- interface ToolCompleteEvent {
1103
- executionId: string;
1104
- iteration: number;
1105
- toolCall: ToolCall;
1106
- result: ToolResult;
1107
- timestamp: Date;
1108
- }
1109
- interface ToolErrorEvent {
1110
- executionId: string;
1111
- iteration: number;
1112
- toolCall: ToolCall;
1113
- error: Error;
1114
- timestamp: Date;
1115
- }
1116
- interface ToolTimeoutEvent {
1117
- executionId: string;
1118
- iteration: number;
1119
- toolCall: ToolCall;
1120
- timeout: number;
1121
- timestamp: Date;
1122
- }
1123
- interface HookErrorEvent {
1124
- executionId: string;
1125
- hookName: string;
1126
- error: Error;
1127
- timestamp: Date;
1128
- }
1129
- interface CircuitOpenedEvent {
1130
- executionId: string;
1131
- breakerName: string;
1132
- failureCount: number;
1133
- lastError: string;
1134
- nextRetryTime: number;
1135
- timestamp: Date;
1136
- }
1137
- interface CircuitHalfOpenEvent {
1138
- executionId: string;
1139
- breakerName: string;
1140
- timestamp: Date;
1141
- }
1142
- interface CircuitClosedEvent {
1143
- executionId: string;
1144
- breakerName: string;
1145
- successCount: number;
1146
- timestamp: Date;
1147
- }
1148
- /**
1149
- * Map of all event names to their payload types
1150
- */
1151
- interface AgenticLoopEvents {
1152
- 'execution:start': ExecutionStartEvent;
1153
- 'execution:complete': ExecutionCompleteEvent;
1154
- 'execution:error': ExecutionErrorEvent;
1155
- 'execution:paused': ExecutionPausedEvent;
1156
- 'execution:resumed': ExecutionResumedEvent;
1157
- 'execution:cancelled': ExecutionCancelledEvent;
1158
- 'execution:maxIterations': ExecutionMaxIterationsEvent;
1159
- 'iteration:start': IterationStartEvent;
1160
- 'iteration:complete': IterationCompleteEvent;
1161
- 'llm:request': LLMRequestEvent;
1162
- 'llm:response': LLMResponseEvent;
1163
- 'llm:error': LLMErrorEvent;
1164
- 'tool:detected': ToolDetectedEvent;
1165
- 'tool:start': ToolStartEvent;
1166
- 'tool:complete': ToolCompleteEvent;
1167
- 'tool:error': ToolErrorEvent;
1168
- 'tool:timeout': ToolTimeoutEvent;
1169
- 'hook:error': HookErrorEvent;
1170
- 'circuit:opened': CircuitOpenedEvent;
1171
- 'circuit:half-open': CircuitHalfOpenEvent;
1172
- 'circuit:closed': CircuitClosedEvent;
1173
- }
1174
- type AgenticLoopEventName = keyof AgenticLoopEvents;
1175
- /**
1176
- * Agent events - alias for AgenticLoopEvents for cleaner API
1177
- * This is the preferred export name going forward.
1178
- */
1179
- type AgentEvents = AgenticLoopEvents;
1180
- type AgentEventName = AgenticLoopEventName;
1181
-
1182
- /**
1183
- * Hook types for agent execution
1184
- * Hooks can modify execution flow synchronously or asynchronously
1185
- */
1186
-
1187
- /**
1188
- * Base hook function type
1189
- */
1190
- type Hook<TContext, TResult = any> = (context: TContext) => TResult | Promise<TResult>;
1191
- /**
1192
- * Hook that can modify data
1193
- */
1194
- type ModifyingHook<TContext, TModification> = Hook<TContext, TModification>;
1195
- interface BeforeExecutionContext {
1196
- executionId: string;
1197
- config: ExecutionConfig;
1198
- timestamp: Date;
1199
- }
1200
- interface AfterExecutionContext {
1201
- executionId: string;
1202
- response: AgentResponse;
1203
- context: ExecutionContext;
1204
- timestamp: Date;
1205
- duration: number;
1206
- }
1207
- interface BeforeLLMContext {
1208
- executionId: string;
1209
- iteration: number;
1210
- options: TextGenerateOptions;
1211
- context: ExecutionContext;
1212
- timestamp: Date;
1213
- }
1214
- interface AfterLLMContext {
1215
- executionId: string;
1216
- iteration: number;
1217
- response: AgentResponse;
1218
- context: ExecutionContext;
1219
- timestamp: Date;
1220
- duration: number;
1221
- }
1222
- interface BeforeToolContext {
1223
- executionId: string;
1224
- iteration: number;
1225
- toolCall: ToolCall;
1226
- context: ExecutionContext;
1227
- timestamp: Date;
1228
- }
1229
- interface AfterToolContext {
1230
- executionId: string;
1231
- iteration: number;
1232
- toolCall: ToolCall;
1233
- result: ToolResult;
1234
- context: ExecutionContext;
1235
- timestamp: Date;
1236
- }
1237
- interface ApproveToolContext {
1238
- executionId: string;
1239
- iteration: number;
1240
- toolCall: ToolCall;
1241
- context: ExecutionContext;
1242
- timestamp: Date;
1243
- }
1244
- interface PauseCheckContext {
1245
- executionId: string;
1246
- iteration: number;
1247
- context: ExecutionContext;
1248
- timestamp: Date;
1249
- }
1250
- interface LLMModification {
1251
- modified?: Partial<TextGenerateOptions>;
1252
- skip?: boolean;
1253
- reason?: string;
1254
- }
1255
- interface ToolModification {
1256
- modified?: Partial<ToolCall>;
1257
- skip?: boolean;
1258
- mockResult?: any;
1259
- reason?: string;
1260
- }
1261
- interface ToolResultModification {
1262
- modified?: Partial<ToolResult>;
1263
- retry?: boolean;
1264
- reason?: string;
1265
- }
1266
- interface ApprovalResult {
1267
- approved: boolean;
1268
- reason?: string;
1269
- modifiedArgs?: any;
1270
- }
1271
- interface PauseDecision {
1272
- shouldPause: boolean;
1273
- reason?: string;
1274
- }
1275
- interface HookConfig {
1276
- 'before:execution'?: Hook<BeforeExecutionContext, void>;
1277
- 'after:execution'?: Hook<AfterExecutionContext, void>;
1278
- 'before:llm'?: ModifyingHook<BeforeLLMContext, LLMModification>;
1279
- 'after:llm'?: ModifyingHook<AfterLLMContext, {}>;
1280
- 'before:tool'?: ModifyingHook<BeforeToolContext, ToolModification>;
1281
- 'after:tool'?: ModifyingHook<AfterToolContext, ToolResultModification>;
1282
- 'approve:tool'?: Hook<ApproveToolContext, ApprovalResult>;
1283
- 'pause:check'?: Hook<PauseCheckContext, PauseDecision>;
1284
- hookTimeout?: number;
1285
- parallelHooks?: boolean;
1286
- }
1287
- type HookName = keyof Omit<HookConfig, 'hookTimeout' | 'parallelHooks'>;
1288
- /**
1289
- * Map of hook names to their context and result types
1290
- */
1291
- interface HookSignatures {
1292
- 'before:execution': {
1293
- context: BeforeExecutionContext;
1294
- result: void;
1295
- };
1296
- 'after:execution': {
1297
- context: AfterExecutionContext;
1298
- result: void;
1299
- };
1300
- 'before:llm': {
1301
- context: BeforeLLMContext;
1302
- result: LLMModification;
1303
- };
1304
- 'after:llm': {
1305
- context: AfterLLMContext;
1306
- result: {};
1307
- };
1308
- 'before:tool': {
1309
- context: BeforeToolContext;
1310
- result: ToolModification;
1311
- };
1312
- 'after:tool': {
1313
- context: AfterToolContext;
1314
- result: ToolResultModification;
1315
- };
1316
- 'approve:tool': {
1317
- context: ApproveToolContext;
1318
- result: ApprovalResult;
1319
- };
1320
- 'pause:check': {
1321
- context: PauseCheckContext;
1322
- result: PauseDecision;
1323
- };
1324
- }
1325
-
1326
- /**
1327
- * Hook manager - handles hook registration and execution
1328
- * Includes error isolation, timeouts, and optional parallel execution
1329
- */
1330
-
1331
- declare class HookManager {
1332
- private hooks;
1333
- private timeout;
1334
- private parallel;
1335
- private hookErrorCounts;
1336
- private disabledHooks;
1337
- private maxConsecutiveErrors;
1338
- private emitter;
1339
- constructor(config: HookConfig | undefined, emitter: EventEmitter, errorHandling?: {
1340
- maxConsecutiveErrors?: number;
1341
- });
1342
- /**
1343
- * Register hooks from configuration
1344
- */
1345
- private registerFromConfig;
1346
- /**
1347
- * Register a hook
1348
- */
1349
- register(name: HookName, hook: Hook<any, any>): void;
1350
- /**
1351
- * Unregister a specific hook function by reference.
1352
- * Returns true if the hook was found and removed.
1353
- */
1354
- unregister(name: HookName, hook: Hook<any, any>): boolean;
1355
- /**
1356
- * Execute hooks for a given name
1357
- */
1358
- executeHooks<K extends HookName>(name: K, context: HookSignatures[K]['context'], defaultResult: HookSignatures[K]['result']): Promise<HookSignatures[K]['result']>;
1359
- /**
1360
- * Execute hooks sequentially
1361
- */
1362
- private executeHooksSequential;
1363
- /**
1364
- * Execute hooks in parallel
1365
- */
1366
- private executeHooksParallel;
1367
- /**
1368
- * Generate unique key for a hook
1369
- */
1370
- private getHookKey;
1371
- /**
1372
- * Execute single hook with error isolation and timeout (with per-hook error tracking)
1373
- */
1374
- private executeHookSafely;
1375
- /**
1376
- * Check if there are any hooks registered
1377
- */
1378
- hasHooks(name: HookName): boolean;
1379
- /**
1380
- * Get hook count
1381
- */
1382
- getHookCount(name?: HookName): number;
1383
- /**
1384
- * Clear all hooks and reset error tracking
1385
- */
1386
- clear(): void;
1387
- /**
1388
- * Re-enable a disabled hook
1389
- */
1390
- enableHook(hookKey: string): void;
1391
- /**
1392
- * Get list of disabled hooks
1393
- */
1394
- getDisabledHooks(): string[];
1395
- }
1396
-
1397
- export { type InputTextContent as $, type AgentEvents as A, type AgenticLoopEventName as B, type Content as C, type AgenticLoopEvents as D, ExecutionContext as E, type FunctionToolDefinition as F, type ApprovalResult as G, type HookConfig as H, type InputItem as I, type ApproveToolContext as J, type BeforeToolContext as K, type LLMResponse as L, type MemoryEntry as M, type BuiltInTool as N, type OutputItem as O, type PriorityCalculator as P, type CompactionItem as Q, ContentType as R, type StreamEvent as S, type ToolFunction as T, DEFAULT_MEMORY_CONFIG as U, type ErrorEvent as V, type WorkingMemoryConfig as W, type ExecutionConfig as X, type Hook as Y, HookManager as Z, type InputImageContent as _, type MemoryScope as a, type IterationCompleteEvent$1 as a0, type JSONSchema as a1, MEMORY_PRIORITY_VALUES as a2, type MemoryEntryInput as a3, type MemoryIndexEntry as a4, type Message as a5, type ModifyingHook as a6, type OutputTextContent as a7, type OutputTextDeltaEvent as a8, type OutputTextDoneEvent as a9, isReasoningDelta as aA, isReasoningDone as aB, isResponseComplete as aC, isSimpleScope as aD, isStreamEvent as aE, isTaskAwareScope as aF, isTerminalMemoryStatus as aG, isToolCallArgumentsDelta as aH, isToolCallArgumentsDone as aI, isToolCallStart as aJ, scopeEquals as aK, scopeMatches as aL, type ExecutionCompleteEvent as aM, type ExecutionStartEvent as aN, type LLMRequestEvent as aO, type LLMResponseEvent as aP, type ToolCompleteEvent as aQ, type ToolStartEvent as aR, type ReasoningDeltaEvent as aa, type ReasoningDoneEvent as ab, type ReasoningItem as ac, type ResponseCompleteEvent as ad, type ResponseCreatedEvent as ae, type ResponseInProgressEvent as af, type SimpleScope as ag, type TaskAwareScope as ah, type ThinkingContent as ai, type ToolCallArgumentsDeltaEvent as aj, type ToolCallArgumentsDoneEvent as ak, type ToolCallStartEvent as al, ToolCallState as am, type ToolExecutionContext as an, type ToolExecutionDoneEvent as ao, type ToolExecutionStartEvent as ap, type ToolModification as aq, type ToolResultContent as ar, type ToolUseContent as as, calculateEntrySize as at, defaultDescribeCall as au, forPlan as av, forTasks as aw, getToolCallDescription as ax, isErrorEvent as ay, isOutputTextDelta as az, type Tool as b, type ToolContext as c, type ToolPermissionConfig as d, type ToolCall as e, type MemoryPriority as f, type MemoryTier as g, type ToolResult as h, type ITextProvider as i, type HistoryMode as j, type AgentResponse as k, type ExecutionMetrics as l, type AuditEntry as m, type HookName as n, type StaleEntryInfo as o, type PriorityContext as p, type MemoryIndex as q, type TaskStatusForMemory as r, type WorkingMemoryAccess as s, type TokenUsage as t, StreamEventType as u, type TextGenerateOptions as v, type ModelCapabilities as w, MessageRole as x, type AfterToolContext as y, type AgentEventName as z };