@iqai/adk 0.0.1

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.
@@ -0,0 +1,3368 @@
1
+ import { AxiosInstance } from 'axios';
2
+ import OpenAI from 'openai';
3
+ import * as drizzle_orm_pg_core from 'drizzle-orm/pg-core';
4
+ import { NodePgDatabase } from 'drizzle-orm/node-postgres';
5
+ import { PgliteDatabase } from 'drizzle-orm/pglite';
6
+
7
+ /**
8
+ * Function call result from LLM
9
+ */
10
+ interface FunctionCall {
11
+ /**
12
+ * Name of the function to call
13
+ */
14
+ name: string;
15
+ /**
16
+ * Arguments for the function, serialized as a JSON string
17
+ */
18
+ arguments: string;
19
+ }
20
+ /**
21
+ * Tool call result from LLM
22
+ */
23
+ interface ToolCall {
24
+ /**
25
+ * Unique ID for the tool call
26
+ */
27
+ id: string;
28
+ /**
29
+ * Function call details
30
+ */
31
+ function: FunctionCall;
32
+ }
33
+ /**
34
+ * Response from an LLM
35
+ */
36
+ declare class LLMResponse {
37
+ /**
38
+ * Content of the response
39
+ */
40
+ content?: string | null;
41
+ /**
42
+ * Function calls in the response
43
+ */
44
+ function_call?: FunctionCall;
45
+ /**
46
+ * Tool calls in the response
47
+ */
48
+ tool_calls?: ToolCall[];
49
+ /**
50
+ * Role of the message (usually 'assistant')
51
+ */
52
+ role: string;
53
+ /**
54
+ * Whether this is a partial response in a stream
55
+ */
56
+ is_partial?: boolean;
57
+ /**
58
+ * Raw provider response
59
+ */
60
+ raw_response?: any;
61
+ constructor(data: {
62
+ content?: string | null;
63
+ function_call?: FunctionCall;
64
+ tool_calls?: ToolCall[];
65
+ role?: string;
66
+ is_partial?: boolean;
67
+ raw_response?: any;
68
+ });
69
+ }
70
+
71
+ /**
72
+ * Message role types for conversation history
73
+ */
74
+ type MessageRole = "user" | "assistant" | "system" | "function" | "tool" | "model";
75
+ /**
76
+ * Text content type
77
+ */
78
+ interface TextContent {
79
+ type: "text";
80
+ text: string;
81
+ }
82
+ /**
83
+ * Image content type
84
+ */
85
+ interface ImageContent {
86
+ type: "image";
87
+ image_url: {
88
+ url: string;
89
+ };
90
+ }
91
+ /**
92
+ * Message content types
93
+ */
94
+ type MessageContent = string | TextContent | ImageContent | Array<TextContent | ImageContent>;
95
+ /**
96
+ * Represents a message in the conversation
97
+ */
98
+ interface Message {
99
+ role: MessageRole;
100
+ content: MessageContent;
101
+ name?: string;
102
+ function_call?: {
103
+ name: string;
104
+ arguments: string;
105
+ };
106
+ tool_calls?: ToolCall[];
107
+ tool_call_id?: string;
108
+ }
109
+ /**
110
+ * Configuration for LLM requests
111
+ */
112
+ interface LLMRequestConfig {
113
+ temperature?: number;
114
+ max_tokens?: number;
115
+ top_p?: number;
116
+ frequency_penalty?: number;
117
+ presence_penalty?: number;
118
+ functions?: FunctionDeclaration[];
119
+ stream?: boolean;
120
+ }
121
+ /**
122
+ * Represents a request to an LLM
123
+ */
124
+ declare class LLMRequest {
125
+ /**
126
+ * The conversation history
127
+ */
128
+ messages: Message[];
129
+ /**
130
+ * LLM configuration parameters
131
+ */
132
+ config: LLMRequestConfig;
133
+ constructor(data: {
134
+ messages: Message[];
135
+ config?: LLMRequestConfig;
136
+ });
137
+ }
138
+
139
+ /**
140
+ * Streaming mode options for agent execution
141
+ */
142
+ declare enum StreamingMode {
143
+ /**
144
+ * No streaming
145
+ */
146
+ NONE = "NONE",
147
+ /**
148
+ * Server-Sent Events streaming
149
+ */
150
+ SSE = "SSE",
151
+ /**
152
+ * Bidirectional streaming
153
+ */
154
+ BIDI = "BIDI"
155
+ }
156
+ /**
157
+ * Speech configuration for live agents
158
+ */
159
+ interface SpeechConfig {
160
+ /**
161
+ * Voice to use for speech
162
+ */
163
+ voice?: string;
164
+ /**
165
+ * Language code
166
+ */
167
+ language?: string;
168
+ }
169
+ /**
170
+ * Audio transcription configuration
171
+ */
172
+ interface AudioTranscriptionConfig {
173
+ /**
174
+ * Whether to enable audio transcription
175
+ */
176
+ enabled: boolean;
177
+ /**
178
+ * Language code for transcription
179
+ */
180
+ language?: string;
181
+ }
182
+ /**
183
+ * Configs for runtime behavior of agents
184
+ */
185
+ declare class RunConfig {
186
+ /**
187
+ * Speech configuration for the live agent
188
+ */
189
+ speechConfig?: SpeechConfig;
190
+ /**
191
+ * The output modalities
192
+ */
193
+ responseModalities?: string[];
194
+ /**
195
+ * Whether to save input blobs as artifacts
196
+ */
197
+ saveInputBlobsAsArtifacts: boolean;
198
+ /**
199
+ * Whether to support Compositional Function Calling
200
+ * Only applicable for StreamingMode.SSE
201
+ */
202
+ supportCFC: boolean;
203
+ /**
204
+ * Streaming mode
205
+ */
206
+ streamingMode: StreamingMode;
207
+ /**
208
+ * Whether to stream the response
209
+ * This is derived from streamingMode and used by LLM implementations
210
+ */
211
+ stream: boolean;
212
+ /**
213
+ * Output audio transcription configuration
214
+ */
215
+ outputAudioTranscription?: AudioTranscriptionConfig;
216
+ constructor(config?: Partial<RunConfig>);
217
+ }
218
+
219
+ /**
220
+ * Base class for all agents in the Agent Development Kit
221
+ */
222
+ declare abstract class BaseAgent {
223
+ /**
224
+ * The agent's name
225
+ * Agent name must be a unique identifier within the agent tree
226
+ */
227
+ name: string;
228
+ /**
229
+ * Description about the agent's capability
230
+ * The LLM uses this to determine whether to delegate control to the agent
231
+ */
232
+ description: string;
233
+ /**
234
+ * The parent agent of this agent
235
+ * Note that an agent can ONLY be added as sub-agent once
236
+ */
237
+ parentAgent?: BaseAgent;
238
+ /**
239
+ * The sub-agents of this agent
240
+ */
241
+ subAgents: BaseAgent[];
242
+ /**
243
+ * Constructs a new BaseAgent
244
+ */
245
+ constructor(config: {
246
+ name: string;
247
+ description: string;
248
+ });
249
+ /**
250
+ * Gets the root agent of the agent tree
251
+ */
252
+ get rootAgent(): BaseAgent;
253
+ /**
254
+ * Adds a sub-agent to this agent
255
+ */
256
+ addSubAgent(agent: BaseAgent): BaseAgent;
257
+ /**
258
+ * Finds a sub-agent by name
259
+ */
260
+ findSubAgent(name: string): BaseAgent | undefined;
261
+ /**
262
+ * Finds an agent in the agent tree by name
263
+ */
264
+ findAgent(name: string): BaseAgent | undefined;
265
+ /**
266
+ * Runs the agent with the given messages and configuration
267
+ */
268
+ abstract run(options: {
269
+ messages: Message[];
270
+ config?: RunConfig;
271
+ sessionId?: string;
272
+ }): Promise<any>;
273
+ /**
274
+ * Runs the agent with streaming support
275
+ */
276
+ abstract runStreaming(options: {
277
+ messages: Message[];
278
+ config?: RunConfig;
279
+ sessionId?: string;
280
+ }): AsyncIterable<any>;
281
+ }
282
+
283
+ /**
284
+ * JSON Schema type for function parameters
285
+ */
286
+ interface JSONSchema {
287
+ type: string;
288
+ properties?: Record<string, JSONSchema>;
289
+ items?: JSONSchema;
290
+ required?: string[];
291
+ enum?: string[];
292
+ description?: string;
293
+ format?: string;
294
+ pattern?: string;
295
+ minimum?: number;
296
+ maximum?: number;
297
+ default?: any;
298
+ [key: string]: any;
299
+ }
300
+ /**
301
+ * Represents a function declaration for the LLM
302
+ */
303
+ interface FunctionDeclaration {
304
+ /**
305
+ * Name of the function
306
+ */
307
+ name: string;
308
+ /**
309
+ * Description of what the function does
310
+ */
311
+ description: string;
312
+ /**
313
+ * Parameters schema in JSON Schema format
314
+ */
315
+ parameters: JSONSchema;
316
+ }
317
+
318
+ /**
319
+ * Base class for LLM connections
320
+ */
321
+ declare abstract class BaseLLMConnection {
322
+ /**
323
+ * Whether the connection is active
324
+ */
325
+ private _isActive;
326
+ /**
327
+ * Gets whether the connection is active
328
+ */
329
+ get isActive(): boolean;
330
+ /**
331
+ * Sends a message to the LLM
332
+ *
333
+ * @param message The message to send
334
+ */
335
+ abstract send(message: string): void;
336
+ /**
337
+ * Handles responses from the LLM
338
+ *
339
+ * @param callback The callback to handle responses
340
+ */
341
+ abstract onResponse(callback: (response: LLMResponse) => void): void;
342
+ /**
343
+ * Handles errors from the LLM
344
+ *
345
+ * @param callback The callback to handle errors
346
+ */
347
+ abstract onError(callback: (error: Error) => void): void;
348
+ /**
349
+ * Handles the end of the connection
350
+ *
351
+ * @param callback The callback to handle the end
352
+ */
353
+ abstract onEnd(callback: () => void): void;
354
+ /**
355
+ * Closes the connection
356
+ */
357
+ close(): void;
358
+ }
359
+
360
+ /**
361
+ * Base class for all LLM implementations
362
+ */
363
+ declare abstract class BaseLLM {
364
+ /**
365
+ * The name of the LLM model
366
+ */
367
+ model: string;
368
+ /**
369
+ * Constructor for BaseLLM
370
+ */
371
+ constructor(model: string);
372
+ /**
373
+ * Returns a list of supported models in regex for LLMRegistry
374
+ */
375
+ static supportedModels(): string[];
376
+ /**
377
+ * Generates content from the given request
378
+ *
379
+ * @param llmRequest The request to send to the LLM
380
+ * @param stream Whether to do streaming call
381
+ * @returns A generator of LLMResponses
382
+ */
383
+ abstract generateContentAsync(llmRequest: LLMRequest, stream?: boolean): AsyncGenerator<LLMResponse, void, unknown>;
384
+ /**
385
+ * Creates a live connection to the LLM
386
+ *
387
+ * @param llmRequest The request to send to the LLM
388
+ * @returns BaseLLMConnection, the connection to the LLM
389
+ */
390
+ connect(llmRequest: LLMRequest): BaseLLMConnection;
391
+ }
392
+
393
+ /**
394
+ * Configuration for Anthropic LLM
395
+ */
396
+ interface AnthropicLLMConfig {
397
+ /**
398
+ * Anthropic API key (can be provided via process.env.ANTHROPIC_API_KEY)
399
+ */
400
+ apiKey?: string;
401
+ /**
402
+ * Anthropic base URL override
403
+ */
404
+ baseURL?: string;
405
+ /**
406
+ * Default model parameters
407
+ */
408
+ defaultParams?: {
409
+ /**
410
+ * Temperature for generation
411
+ */
412
+ temperature?: number;
413
+ /**
414
+ * Top-p for generation
415
+ */
416
+ top_p?: number;
417
+ /**
418
+ * Maximum tokens to generate
419
+ */
420
+ max_tokens?: number;
421
+ };
422
+ }
423
+ /**
424
+ * Anthropic LLM implementation for Claude models
425
+ * Uses direct API calls instead of the SDK for better control
426
+ */
427
+ declare class AnthropicLLM extends BaseLLM {
428
+ /**
429
+ * Anthropic API key
430
+ */
431
+ private apiKey;
432
+ /**
433
+ * Anthropic API base URL
434
+ */
435
+ private baseURL;
436
+ /**
437
+ * Default parameters for requests
438
+ */
439
+ private defaultParams;
440
+ /**
441
+ * Constructor for AnthropicLLM
442
+ */
443
+ constructor(model: string, config?: AnthropicLLMConfig);
444
+ /**
445
+ * Returns a list of supported models in regex for LLMRegistry
446
+ */
447
+ static supportedModels(): string[];
448
+ /**
449
+ * Convert ADK messages to Anthropic message format
450
+ */
451
+ private convertMessages;
452
+ /**
453
+ * Extract the system message from messages array
454
+ */
455
+ private extractSystemMessage;
456
+ /**
457
+ * Filter out system messages as they are handled separately
458
+ */
459
+ private filterSystemMessages;
460
+ /**
461
+ * Convert ADK function declarations to Anthropic tool format
462
+ */
463
+ private convertFunctionsToTools;
464
+ /**
465
+ * Convert Anthropic tool calls to ADK tool calls
466
+ */
467
+ private convertToolUses;
468
+ /**
469
+ * Extract tool uses from response content
470
+ */
471
+ private extractToolUses;
472
+ /**
473
+ * Make a direct API call to Anthropic
474
+ */
475
+ private callAnthropicAPI;
476
+ /**
477
+ * Generates content from the given request
478
+ */
479
+ generateContentAsync(llmRequest: LLMRequest, stream?: boolean): AsyncGenerator<LLMResponse, void, unknown>;
480
+ /**
481
+ * Creates a live connection to the LLM
482
+ */
483
+ connect(llmRequest: LLMRequest): BaseLLMConnection;
484
+ }
485
+
486
+ /**
487
+ * Anthropic LLM Connection for live chat with Claude models
488
+ */
489
+ declare class AnthropicLLMConnection extends BaseLLMConnection {
490
+ /**
491
+ * Axios instance for API calls
492
+ */
493
+ private client;
494
+ /**
495
+ * Current model to use
496
+ */
497
+ private model;
498
+ /**
499
+ * Current messages in the conversation
500
+ */
501
+ private messages;
502
+ /**
503
+ * System message if present
504
+ */
505
+ private systemMessage?;
506
+ /**
507
+ * Default parameters for requests
508
+ */
509
+ private defaultParams;
510
+ /**
511
+ * Callbacks for handling responses, errors, and connection end
512
+ */
513
+ private responseCallback?;
514
+ private errorCallback?;
515
+ private endCallback?;
516
+ /**
517
+ * Constructor
518
+ */
519
+ constructor(client: AxiosInstance, model: string, initialRequest: LLMRequest, defaultParams: Record<string, any>);
520
+ /**
521
+ * Extract the system message from messages array
522
+ */
523
+ private extractSystemMessage;
524
+ /**
525
+ * Filter out system messages as they are handled separately in Anthropic API
526
+ */
527
+ private filterSystemMessages;
528
+ /**
529
+ * Converts an ADK message to an Anthropic message
530
+ */
531
+ private convertMessages;
532
+ /**
533
+ * Convert Anthropic tool calls to ADK tool calls
534
+ */
535
+ private convertToolCalls;
536
+ /**
537
+ * Extract tool uses from response content
538
+ */
539
+ private extractToolUses;
540
+ /**
541
+ * Sends a message to the LLM
542
+ * Implements BaseLLMConnection.send
543
+ *
544
+ * @param message The message to send
545
+ */
546
+ send(message: string): void;
547
+ /**
548
+ * Handles responses from the LLM
549
+ * Implements BaseLLMConnection.onResponse
550
+ *
551
+ * @param callback The callback to handle responses
552
+ */
553
+ onResponse(callback: (response: LLMResponse) => void): void;
554
+ /**
555
+ * Handles errors from the LLM
556
+ * Implements BaseLLMConnection.onError
557
+ *
558
+ * @param callback The callback to handle errors
559
+ */
560
+ onError(callback: (error: Error) => void): void;
561
+ /**
562
+ * Handles the end of the connection
563
+ * Implements BaseLLMConnection.onEnd
564
+ *
565
+ * @param callback The callback to handle the end
566
+ */
567
+ onEnd(callback: () => void): void;
568
+ /**
569
+ * Triggers an error through the error callback
570
+ */
571
+ private triggerError;
572
+ /**
573
+ * Sends the message to the LLM and returns the response
574
+ */
575
+ private sendMessageAsync;
576
+ }
577
+
578
+ /**
579
+ * Google Gemini LLM configuration
580
+ */
581
+ interface GoogleLLMConfig {
582
+ /**
583
+ * Google Cloud Project ID (can be provided via GOOGLE_CLOUD_PROJECT env var)
584
+ */
585
+ projectId?: string;
586
+ /**
587
+ * Google Cloud location (can be provided via GOOGLE_CLOUD_LOCATION env var)
588
+ */
589
+ location?: string;
590
+ /**
591
+ * Default model parameters
592
+ */
593
+ defaultParams?: {
594
+ /**
595
+ * Temperature for generation
596
+ */
597
+ temperature?: number;
598
+ /**
599
+ * Top-p for generation
600
+ */
601
+ top_p?: number;
602
+ /**
603
+ * Maximum tokens to generate
604
+ */
605
+ maxOutputTokens?: number;
606
+ };
607
+ }
608
+ /**
609
+ * Google Gemini LLM implementation
610
+ */
611
+ declare class GoogleLLM extends BaseLLM {
612
+ /**
613
+ * Generative model instance
614
+ */
615
+ private ai;
616
+ /**
617
+ * Default parameters for requests
618
+ */
619
+ private defaultParams;
620
+ /**
621
+ * Constructor for GoogleLLM
622
+ */
623
+ constructor(model: string, config?: GoogleLLMConfig);
624
+ /**
625
+ * Returns a list of supported models in regex for LLMRegistry
626
+ */
627
+ static supportedModels(): string[];
628
+ /**
629
+ * Convert a message to Google Vertex AI format
630
+ */
631
+ private convertMessage;
632
+ /**
633
+ * Map ADK role to Google role
634
+ */
635
+ private mapRole;
636
+ /**
637
+ * Extract system message from messages array
638
+ */
639
+ private extractSystemMessage;
640
+ /**
641
+ * Convert functions to Google function declarations
642
+ */
643
+ private convertFunctionsToTools;
644
+ /**
645
+ * Convert parameter types to Google Gemini format (uppercase types)
646
+ */
647
+ private convertParametersToGoogleFormat;
648
+ /**
649
+ * Convert Google response to LLMResponse
650
+ */
651
+ private convertResponse;
652
+ /**
653
+ * Generates content from the given request
654
+ */
655
+ generateContentAsync(llmRequest: LLMRequest, stream?: boolean): AsyncGenerator<LLMResponse, void, unknown>;
656
+ }
657
+
658
+ /**
659
+ * Configuration for OpenAI LLM
660
+ */
661
+ interface OpenAILLMConfig {
662
+ /**
663
+ * OpenAI API key (can be provided via process.env.OPENAI_API_KEY)
664
+ */
665
+ apiKey?: string;
666
+ /**
667
+ * OpenAI base URL override
668
+ */
669
+ baseURL?: string;
670
+ /**
671
+ * OpenAI organization ID
672
+ */
673
+ organization?: string;
674
+ /**
675
+ * Default model parameters
676
+ */
677
+ defaultParams?: {
678
+ /**
679
+ * Temperature for generation
680
+ */
681
+ temperature?: number;
682
+ /**
683
+ * Top-p for generation
684
+ */
685
+ top_p?: number;
686
+ /**
687
+ * Maximum tokens to generate
688
+ */
689
+ max_tokens?: number;
690
+ /**
691
+ * Frequency penalty
692
+ */
693
+ frequency_penalty?: number;
694
+ /**
695
+ * Presence penalty
696
+ */
697
+ presence_penalty?: number;
698
+ };
699
+ }
700
+ /**
701
+ * OpenAI LLM implementation
702
+ */
703
+ declare class OpenAILLM extends BaseLLM {
704
+ /**
705
+ * OpenAI client instance
706
+ */
707
+ private client;
708
+ /**
709
+ * Default parameters for requests
710
+ */
711
+ private defaultParams;
712
+ /**
713
+ * Constructor for OpenAILLM
714
+ */
715
+ constructor(model: string, config?: OpenAILLMConfig);
716
+ /**
717
+ * Returns a list of supported models in regex for LLMRegistry
718
+ */
719
+ static supportedModels(): string[];
720
+ /**
721
+ * Converts an ADK message to an OpenAI message
722
+ */
723
+ private convertMessage;
724
+ /**
725
+ * Converts functions to OpenAI tools
726
+ */
727
+ private convertFunctionsToTools;
728
+ /**
729
+ * Convert OpenAI response to LLMResponse
730
+ */
731
+ private convertResponse;
732
+ /**
733
+ * Convert OpenAI streaming chunk to LLMResponse
734
+ */
735
+ private convertChunk;
736
+ /**
737
+ * Generates content from the given request
738
+ */
739
+ generateContentAsync(llmRequest: LLMRequest, stream?: boolean): AsyncGenerator<LLMResponse, void, unknown>;
740
+ /**
741
+ * Creates a live connection to the LLM
742
+ */
743
+ connect(llmRequest: LLMRequest): BaseLLMConnection;
744
+ }
745
+
746
+ /**
747
+ * OpenAI LLM Connection
748
+ */
749
+ declare class OpenAILLMConnection extends BaseLLMConnection {
750
+ /**
751
+ * OpenAI client
752
+ */
753
+ private client;
754
+ /**
755
+ * The model name
756
+ */
757
+ private model;
758
+ /**
759
+ * The initial request
760
+ */
761
+ private initialRequest;
762
+ /**
763
+ * Default parameters
764
+ */
765
+ private defaultParams;
766
+ /**
767
+ * Response callback
768
+ */
769
+ private responseCallback?;
770
+ /**
771
+ * Error callback
772
+ */
773
+ private errorCallback?;
774
+ /**
775
+ * End callback
776
+ */
777
+ private endCallback?;
778
+ /**
779
+ * Ongoing chat history
780
+ */
781
+ private messages;
782
+ /**
783
+ * Constructor for OpenAILLMConnection
784
+ */
785
+ constructor(client: OpenAI, model: string, initialRequest: LLMRequest, defaultParams: Record<string, any>);
786
+ /**
787
+ * Adds a tool/function result message to the conversation history
788
+ * This method ensures we don't duplicate tool_call_id values
789
+ */
790
+ private addToolResultMessage;
791
+ /**
792
+ * Sends a message to the OpenAI model
793
+ */
794
+ send(message: string): Promise<void>;
795
+ /**
796
+ * Registers a response handler
797
+ */
798
+ onResponse(callback: (response: LLMResponse) => void): void;
799
+ /**
800
+ * Registers an error handler
801
+ */
802
+ onError(callback: (error: Error) => void): void;
803
+ /**
804
+ * Registers an end handler
805
+ */
806
+ onEnd(callback: () => void): void;
807
+ }
808
+
809
+ /**
810
+ * Type for LLM constructor with static methods
811
+ */
812
+ interface LLMClass {
813
+ new (model: string): BaseLLM;
814
+ supportedModels(): string[];
815
+ }
816
+ /**
817
+ * Registry for LLMs
818
+ */
819
+ declare class LLMRegistry {
820
+ /**
821
+ * Map of model name regex to LLM class
822
+ */
823
+ private static llmRegistry;
824
+ /**
825
+ * Creates a new LLM instance
826
+ *
827
+ * @param model The model name
828
+ * @returns The LLM instance
829
+ */
830
+ static newLLM(model: string): BaseLLM;
831
+ /**
832
+ * Resolves the LLM class from the model name
833
+ *
834
+ * @param model The model name
835
+ * @returns The LLM class
836
+ */
837
+ static resolve(model: string): LLMClass | null;
838
+ /**
839
+ * Registers a new LLM class
840
+ *
841
+ * @param modelNameRegex The regex to match model names
842
+ * @param llmClass The LLM class
843
+ */
844
+ static register(modelNameRegex: string, llmClass: LLMClass): void;
845
+ /**
846
+ * Registers all model patterns from an LLM class
847
+ *
848
+ * @param llmClass The LLM class
849
+ */
850
+ static registerLLM(llmClass: LLMClass): void;
851
+ /**
852
+ * Logs all registered models for debugging
853
+ */
854
+ static logRegisteredModels(): void;
855
+ }
856
+
857
+ /**
858
+ * Register all LLM providers
859
+ */
860
+ declare function registerProviders(): void;
861
+
862
+ /**
863
+ * Authentication scheme types
864
+ */
865
+ declare enum AuthSchemeType {
866
+ APIKEY = "apiKey",
867
+ HTTP = "http",
868
+ OAUTH2 = "oauth2",
869
+ OPENID_CONNECT = "openIdConnect"
870
+ }
871
+ /**
872
+ * Base class for authentication schemes
873
+ */
874
+ declare abstract class AuthScheme {
875
+ /**
876
+ * The type of authentication scheme
877
+ */
878
+ type: AuthSchemeType;
879
+ constructor(type: AuthSchemeType);
880
+ }
881
+ /**
882
+ * API Key authentication scheme
883
+ */
884
+ declare class ApiKeyScheme extends AuthScheme {
885
+ /**
886
+ * Where the API key is sent
887
+ */
888
+ in: "query" | "header" | "cookie";
889
+ /**
890
+ * Name of the parameter
891
+ */
892
+ name: string;
893
+ /**
894
+ * Description of the API key
895
+ */
896
+ description?: string;
897
+ /**
898
+ * Constructor for ApiKeyScheme
899
+ */
900
+ constructor(config: {
901
+ in: "query" | "header" | "cookie";
902
+ name: string;
903
+ description?: string;
904
+ });
905
+ }
906
+ /**
907
+ * HTTP authentication scheme
908
+ */
909
+ declare class HttpScheme extends AuthScheme {
910
+ /**
911
+ * The HTTP authentication scheme
912
+ */
913
+ scheme: "basic" | "bearer" | "digest" | "other";
914
+ /**
915
+ * Bearer format when scheme is 'bearer'
916
+ */
917
+ bearerFormat?: string;
918
+ /**
919
+ * Description of the scheme
920
+ */
921
+ description?: string;
922
+ /**
923
+ * Constructor for HttpScheme
924
+ */
925
+ constructor(config: {
926
+ scheme: "basic" | "bearer" | "digest" | "other";
927
+ bearerFormat?: string;
928
+ description?: string;
929
+ });
930
+ }
931
+ /**
932
+ * OAuth flow configuration
933
+ */
934
+ interface OAuthFlow {
935
+ authorizationUrl?: string;
936
+ tokenUrl?: string;
937
+ refreshUrl?: string;
938
+ scopes: Record<string, string>;
939
+ }
940
+ /**
941
+ * OAuth flows configuration
942
+ */
943
+ interface OAuthFlows {
944
+ implicit?: OAuthFlow;
945
+ password?: OAuthFlow;
946
+ clientCredentials?: OAuthFlow;
947
+ authorizationCode?: OAuthFlow;
948
+ }
949
+ /**
950
+ * OAuth2 authentication scheme
951
+ */
952
+ declare class OAuth2Scheme extends AuthScheme {
953
+ /**
954
+ * OAuth flows
955
+ */
956
+ flows: OAuthFlows;
957
+ /**
958
+ * Description of the scheme
959
+ */
960
+ description?: string;
961
+ /**
962
+ * Constructor for OAuth2Scheme
963
+ */
964
+ constructor(config: {
965
+ flows: OAuthFlows;
966
+ description?: string;
967
+ });
968
+ }
969
+ /**
970
+ * OpenID Connect authentication scheme
971
+ */
972
+ declare class OpenIdConnectScheme extends AuthScheme {
973
+ /**
974
+ * OpenID Connect URL
975
+ */
976
+ openIdConnectUrl: string;
977
+ /**
978
+ * Description of the scheme
979
+ */
980
+ description?: string;
981
+ /**
982
+ * Constructor for OpenIdConnectScheme
983
+ */
984
+ constructor(config: {
985
+ openIdConnectUrl: string;
986
+ description?: string;
987
+ });
988
+ }
989
+
990
+ /**
991
+ * Authentication configuration for tools
992
+ */
993
+ declare class AuthConfig {
994
+ /**
995
+ * The authentication scheme
996
+ */
997
+ authScheme: AuthScheme;
998
+ /**
999
+ * Additional context properties
1000
+ */
1001
+ context?: Record<string, any>;
1002
+ /**
1003
+ * Constructor for AuthConfig
1004
+ */
1005
+ constructor(config: {
1006
+ authScheme: AuthScheme;
1007
+ context?: Record<string, any>;
1008
+ });
1009
+ }
1010
+
1011
+ /**
1012
+ * Handler for authentication in tools
1013
+ */
1014
+ declare class AuthHandler {
1015
+ /**
1016
+ * The authentication configuration
1017
+ */
1018
+ authConfig: AuthConfig;
1019
+ /**
1020
+ * The authentication credential
1021
+ */
1022
+ credential?: AuthCredential;
1023
+ /**
1024
+ * Constructor for AuthHandler
1025
+ */
1026
+ constructor(config: {
1027
+ authConfig: AuthConfig;
1028
+ credential?: AuthCredential;
1029
+ });
1030
+ /**
1031
+ * Gets the authentication token
1032
+ */
1033
+ getToken(): string | undefined;
1034
+ /**
1035
+ * Gets headers for HTTP requests
1036
+ */
1037
+ getHeaders(): Record<string, string>;
1038
+ /**
1039
+ * Refreshes the token if necessary
1040
+ */
1041
+ refreshToken(): Promise<void>;
1042
+ }
1043
+
1044
+ /**
1045
+ * Types of authentication credentials
1046
+ */
1047
+ declare enum AuthCredentialType {
1048
+ API_KEY = "api_key",
1049
+ BASIC = "basic",
1050
+ BEARER = "bearer",
1051
+ OAUTH2 = "oauth2",
1052
+ CUSTOM = "custom"
1053
+ }
1054
+ /**
1055
+ * Base class for authentication credentials
1056
+ */
1057
+ declare abstract class AuthCredential {
1058
+ /**
1059
+ * Type of credential
1060
+ */
1061
+ type: AuthCredentialType;
1062
+ /**
1063
+ * Constructor for AuthCredential
1064
+ */
1065
+ constructor(type: AuthCredentialType);
1066
+ /**
1067
+ * Gets the authentication token
1068
+ */
1069
+ abstract getToken(): string | undefined;
1070
+ /**
1071
+ * Gets headers for HTTP requests
1072
+ */
1073
+ abstract getHeaders(config: AuthConfig): Record<string, string>;
1074
+ /**
1075
+ * Whether the token can be refreshed
1076
+ */
1077
+ canRefresh(): boolean;
1078
+ /**
1079
+ * Refreshes the token
1080
+ */
1081
+ refresh(): Promise<void>;
1082
+ }
1083
+ /**
1084
+ * API Key credential
1085
+ */
1086
+ declare class ApiKeyCredential extends AuthCredential {
1087
+ /**
1088
+ * The API key
1089
+ */
1090
+ apiKey: string;
1091
+ /**
1092
+ * Constructor for ApiKeyCredential
1093
+ */
1094
+ constructor(apiKey: string);
1095
+ /**
1096
+ * Gets the API key as the token
1097
+ */
1098
+ getToken(): string;
1099
+ /**
1100
+ * Gets headers for HTTP requests
1101
+ */
1102
+ getHeaders(config: AuthConfig): Record<string, string>;
1103
+ }
1104
+ /**
1105
+ * Basic authentication credential
1106
+ */
1107
+ declare class BasicAuthCredential extends AuthCredential {
1108
+ /**
1109
+ * The username
1110
+ */
1111
+ username: string;
1112
+ /**
1113
+ * The password
1114
+ */
1115
+ password: string;
1116
+ /**
1117
+ * Constructor for BasicAuthCredential
1118
+ */
1119
+ constructor(username: string, password: string);
1120
+ /**
1121
+ * Gets the encoded basic auth token
1122
+ */
1123
+ getToken(): string;
1124
+ /**
1125
+ * Gets headers for HTTP requests
1126
+ */
1127
+ getHeaders(): Record<string, string>;
1128
+ }
1129
+ /**
1130
+ * Bearer token credential
1131
+ */
1132
+ declare class BearerTokenCredential extends AuthCredential {
1133
+ /**
1134
+ * The bearer token
1135
+ */
1136
+ token: string;
1137
+ /**
1138
+ * Constructor for BearerTokenCredential
1139
+ */
1140
+ constructor(token: string);
1141
+ /**
1142
+ * Gets the bearer token
1143
+ */
1144
+ getToken(): string;
1145
+ /**
1146
+ * Gets headers for HTTP requests
1147
+ */
1148
+ getHeaders(): Record<string, string>;
1149
+ }
1150
+ /**
1151
+ * OAuth2 token credential with refresh capability
1152
+ */
1153
+ declare class OAuth2Credential extends AuthCredential {
1154
+ /**
1155
+ * The access token
1156
+ */
1157
+ accessToken: string;
1158
+ /**
1159
+ * The refresh token
1160
+ */
1161
+ refreshToken?: string;
1162
+ /**
1163
+ * When the token expires
1164
+ */
1165
+ expiresAt?: Date;
1166
+ /**
1167
+ * Function to refresh the token
1168
+ */
1169
+ private refreshFunction?;
1170
+ /**
1171
+ * Constructor for OAuth2Credential
1172
+ */
1173
+ constructor(config: {
1174
+ accessToken: string;
1175
+ refreshToken?: string;
1176
+ expiresIn?: number;
1177
+ refreshFunction?: (refreshToken: string) => Promise<{
1178
+ accessToken: string;
1179
+ refreshToken?: string;
1180
+ expiresIn?: number;
1181
+ }>;
1182
+ });
1183
+ /**
1184
+ * Gets the access token
1185
+ */
1186
+ getToken(): string;
1187
+ /**
1188
+ * Gets headers for HTTP requests
1189
+ */
1190
+ getHeaders(): Record<string, string>;
1191
+ /**
1192
+ * Whether the token can be refreshed
1193
+ */
1194
+ canRefresh(): boolean;
1195
+ /**
1196
+ * Whether the token is expired
1197
+ */
1198
+ isExpired(): boolean;
1199
+ /**
1200
+ * Refreshes the token
1201
+ */
1202
+ refresh(): Promise<void>;
1203
+ }
1204
+
1205
+ /**
1206
+ * Represents the actions attached to an event.
1207
+ */
1208
+ declare class EventActions {
1209
+ /**
1210
+ * If true, it won't call model to summarize function response.
1211
+ * Only used for function_response event.
1212
+ */
1213
+ skipSummarization?: boolean;
1214
+ /**
1215
+ * Indicates that the event is updating the state with the given delta.
1216
+ */
1217
+ stateDelta: Record<string, any>;
1218
+ /**
1219
+ * Indicates that the event is updating an artifact. key is the filename,
1220
+ * value is the version.
1221
+ */
1222
+ artifactDelta: Record<string, number>;
1223
+ /**
1224
+ * If set, the event transfers to the specified agent.
1225
+ */
1226
+ transferToAgent?: string;
1227
+ /**
1228
+ * The agent is escalating to a higher level agent.
1229
+ */
1230
+ escalate?: boolean;
1231
+ /**
1232
+ * Constructor for EventActions
1233
+ */
1234
+ constructor(options?: {
1235
+ skipSummarization?: boolean;
1236
+ stateDelta?: Record<string, any>;
1237
+ artifactDelta?: Record<string, number>;
1238
+ transferToAgent?: string;
1239
+ escalate?: boolean;
1240
+ });
1241
+ }
1242
+
1243
+ /**
1244
+ * Represents an event in a conversation between agents and users.
1245
+ * It is used to store the content of the conversation, as well as the actions
1246
+ * taken by the agents like function calls, etc.
1247
+ */
1248
+ declare class Event extends LLMResponse {
1249
+ /**
1250
+ * The invocation ID of the event.
1251
+ */
1252
+ invocationId: string;
1253
+ /**
1254
+ * 'user' or the name of the agent, indicating who appended the event to the session.
1255
+ */
1256
+ author: string;
1257
+ /**
1258
+ * The actions taken by the agent.
1259
+ */
1260
+ actions: EventActions;
1261
+ /**
1262
+ * Set of ids of the long running function calls.
1263
+ * Agent client will know from this field about which function call is long running.
1264
+ * Only valid for function call event.
1265
+ */
1266
+ longRunningToolIds?: Set<string>;
1267
+ /**
1268
+ * The branch of the event.
1269
+ * The format is like agent_1.agent_2.agent_3, where agent_1 is the parent of
1270
+ * agent_2, and agent_2 is the parent of agent_3.
1271
+ * Branch is used when multiple sub-agent shouldn't see their peer agents'
1272
+ * conversation history.
1273
+ */
1274
+ branch?: string;
1275
+ /**
1276
+ * The unique identifier of the event.
1277
+ */
1278
+ id: string;
1279
+ /**
1280
+ * The timestamp of the event.
1281
+ */
1282
+ timestamp: number;
1283
+ /**
1284
+ * Constructor for Event
1285
+ */
1286
+ constructor({ invocationId, author, content, function_call, tool_calls, role, actions, longRunningToolIds, branch, id, timestamp, partial, raw_response, }: {
1287
+ invocationId?: string;
1288
+ author: string;
1289
+ content?: string | null;
1290
+ function_call?: FunctionCall;
1291
+ tool_calls?: ToolCall[];
1292
+ role?: string;
1293
+ actions?: EventActions;
1294
+ longRunningToolIds?: Set<string>;
1295
+ branch?: string;
1296
+ id?: string;
1297
+ timestamp?: number;
1298
+ partial?: boolean;
1299
+ raw_response?: any;
1300
+ });
1301
+ /**
1302
+ * Returns whether the event is the final response of the agent.
1303
+ */
1304
+ isFinalResponse(): boolean;
1305
+ /**
1306
+ * Returns whether the event has meaningful content.
1307
+ * Used to filter out empty or meaningless streaming chunks.
1308
+ */
1309
+ hasContent(): boolean;
1310
+ /**
1311
+ * Generates a new random ID for an event.
1312
+ */
1313
+ static newId(): string;
1314
+ }
1315
+
1316
+ /**
1317
+ * Represents the state of a session
1318
+ */
1319
+ declare class SessionState {
1320
+ private state;
1321
+ private dirty;
1322
+ constructor();
1323
+ /**
1324
+ * Sets a value in the state
1325
+ * @param key The key to set
1326
+ * @param value The value to set
1327
+ */
1328
+ set(key: string, value: any): void;
1329
+ /**
1330
+ * Gets a value from the state
1331
+ * @param key The key to get
1332
+ * @returns The value or undefined if not present
1333
+ */
1334
+ get<T>(key: string): T | undefined;
1335
+ /**
1336
+ * Checks if the state has a key
1337
+ * @param key The key to check
1338
+ * @returns Whether the key exists
1339
+ */
1340
+ has(key: string): boolean;
1341
+ /**
1342
+ * Deletes a key from the state
1343
+ * @param key The key to delete
1344
+ * @returns Whether the key was deleted
1345
+ */
1346
+ delete(key: string): boolean;
1347
+ /**
1348
+ * Checks if state has changed since last save
1349
+ * @returns Whether the state has been modified
1350
+ */
1351
+ hasDelta(): boolean;
1352
+ /**
1353
+ * Clears the dirty state
1354
+ */
1355
+ clearDelta(): void;
1356
+ /**
1357
+ * Converts the state to a plain object
1358
+ */
1359
+ toObject(): Record<string, any>;
1360
+ /**
1361
+ * Creates a state from a plain object
1362
+ * @param obj The object to load
1363
+ */
1364
+ static fromObject(obj: Record<string, any>): SessionState;
1365
+ }
1366
+
1367
+ /**
1368
+ * Represents a conversation session
1369
+ */
1370
+ interface Session {
1371
+ /**
1372
+ * Unique session identifier
1373
+ */
1374
+ id: string;
1375
+ /**
1376
+ * User identifier associated with the session
1377
+ */
1378
+ userId: string;
1379
+ /**
1380
+ * Conversation history
1381
+ */
1382
+ messages: Message[];
1383
+ /**
1384
+ * Additional session metadata
1385
+ */
1386
+ metadata: Record<string, any>;
1387
+ /**
1388
+ * Session creation timestamp
1389
+ */
1390
+ createdAt: Date;
1391
+ /**
1392
+ * Last update timestamp
1393
+ */
1394
+ updatedAt: Date;
1395
+ /**
1396
+ * Session state for storing arbitrary data
1397
+ */
1398
+ state: SessionState;
1399
+ /**
1400
+ * Session events
1401
+ */
1402
+ events?: Event[];
1403
+ }
1404
+ /**
1405
+ * Options for listing sessions
1406
+ */
1407
+ interface ListSessionOptions {
1408
+ /**
1409
+ * Maximum number of sessions to return
1410
+ */
1411
+ limit?: number;
1412
+ /**
1413
+ * Only include sessions created after this time
1414
+ */
1415
+ createdAfter?: Date;
1416
+ /**
1417
+ * Only include sessions updated after this time
1418
+ */
1419
+ updatedAfter?: Date;
1420
+ /**
1421
+ * Filter sessions by metadata
1422
+ */
1423
+ metadataFilter?: Record<string, any>;
1424
+ }
1425
+
1426
+ /**
1427
+ * Models module exports - consolidated to match Python structure
1428
+ */
1429
+
1430
+ type index$4_AnthropicLLM = AnthropicLLM;
1431
+ declare const index$4_AnthropicLLM: typeof AnthropicLLM;
1432
+ type index$4_AnthropicLLMConfig = AnthropicLLMConfig;
1433
+ type index$4_AnthropicLLMConnection = AnthropicLLMConnection;
1434
+ declare const index$4_AnthropicLLMConnection: typeof AnthropicLLMConnection;
1435
+ type index$4_ApiKeyCredential = ApiKeyCredential;
1436
+ declare const index$4_ApiKeyCredential: typeof ApiKeyCredential;
1437
+ type index$4_ApiKeyScheme = ApiKeyScheme;
1438
+ declare const index$4_ApiKeyScheme: typeof ApiKeyScheme;
1439
+ type index$4_AuthConfig = AuthConfig;
1440
+ declare const index$4_AuthConfig: typeof AuthConfig;
1441
+ type index$4_AuthCredential = AuthCredential;
1442
+ declare const index$4_AuthCredential: typeof AuthCredential;
1443
+ type index$4_AuthCredentialType = AuthCredentialType;
1444
+ declare const index$4_AuthCredentialType: typeof AuthCredentialType;
1445
+ type index$4_AuthHandler = AuthHandler;
1446
+ declare const index$4_AuthHandler: typeof AuthHandler;
1447
+ type index$4_AuthScheme = AuthScheme;
1448
+ declare const index$4_AuthScheme: typeof AuthScheme;
1449
+ type index$4_AuthSchemeType = AuthSchemeType;
1450
+ declare const index$4_AuthSchemeType: typeof AuthSchemeType;
1451
+ type index$4_BaseLLM = BaseLLM;
1452
+ declare const index$4_BaseLLM: typeof BaseLLM;
1453
+ type index$4_BaseLLMConnection = BaseLLMConnection;
1454
+ declare const index$4_BaseLLMConnection: typeof BaseLLMConnection;
1455
+ type index$4_BaseMemoryService = BaseMemoryService;
1456
+ type index$4_BasicAuthCredential = BasicAuthCredential;
1457
+ declare const index$4_BasicAuthCredential: typeof BasicAuthCredential;
1458
+ type index$4_BearerTokenCredential = BearerTokenCredential;
1459
+ declare const index$4_BearerTokenCredential: typeof BearerTokenCredential;
1460
+ type index$4_FunctionCall = FunctionCall;
1461
+ type index$4_FunctionDeclaration = FunctionDeclaration;
1462
+ type index$4_GoogleLLM = GoogleLLM;
1463
+ declare const index$4_GoogleLLM: typeof GoogleLLM;
1464
+ type index$4_GoogleLLMConfig = GoogleLLMConfig;
1465
+ type index$4_HttpScheme = HttpScheme;
1466
+ declare const index$4_HttpScheme: typeof HttpScheme;
1467
+ type index$4_ImageContent = ImageContent;
1468
+ type index$4_JSONSchema = JSONSchema;
1469
+ type index$4_LLMRegistry = LLMRegistry;
1470
+ declare const index$4_LLMRegistry: typeof LLMRegistry;
1471
+ type index$4_LLMRequest = LLMRequest;
1472
+ declare const index$4_LLMRequest: typeof LLMRequest;
1473
+ type index$4_LLMRequestConfig = LLMRequestConfig;
1474
+ type index$4_LLMResponse = LLMResponse;
1475
+ declare const index$4_LLMResponse: typeof LLMResponse;
1476
+ type index$4_ListSessionOptions = ListSessionOptions;
1477
+ type index$4_MemoryResult = MemoryResult;
1478
+ type index$4_Message = Message;
1479
+ type index$4_MessageContent = MessageContent;
1480
+ type index$4_MessageRole = MessageRole;
1481
+ type index$4_OAuth2Credential = OAuth2Credential;
1482
+ declare const index$4_OAuth2Credential: typeof OAuth2Credential;
1483
+ type index$4_OAuth2Scheme = OAuth2Scheme;
1484
+ declare const index$4_OAuth2Scheme: typeof OAuth2Scheme;
1485
+ type index$4_OAuthFlow = OAuthFlow;
1486
+ type index$4_OAuthFlows = OAuthFlows;
1487
+ type index$4_OpenAILLM = OpenAILLM;
1488
+ declare const index$4_OpenAILLM: typeof OpenAILLM;
1489
+ type index$4_OpenAILLMConfig = OpenAILLMConfig;
1490
+ type index$4_OpenAILLMConnection = OpenAILLMConnection;
1491
+ declare const index$4_OpenAILLMConnection: typeof OpenAILLMConnection;
1492
+ type index$4_OpenIdConnectScheme = OpenIdConnectScheme;
1493
+ declare const index$4_OpenIdConnectScheme: typeof OpenIdConnectScheme;
1494
+ type index$4_SearchMemoryOptions = SearchMemoryOptions;
1495
+ type index$4_SearchMemoryResponse = SearchMemoryResponse;
1496
+ type index$4_Session = Session;
1497
+ type index$4_SessionState = SessionState;
1498
+ declare const index$4_SessionState: typeof SessionState;
1499
+ type index$4_TextContent = TextContent;
1500
+ type index$4_ToolCall = ToolCall;
1501
+ declare const index$4_registerProviders: typeof registerProviders;
1502
+ declare namespace index$4 {
1503
+ export { index$4_AnthropicLLM as AnthropicLLM, type index$4_AnthropicLLMConfig as AnthropicLLMConfig, index$4_AnthropicLLMConnection as AnthropicLLMConnection, index$4_ApiKeyCredential as ApiKeyCredential, index$4_ApiKeyScheme as ApiKeyScheme, index$4_AuthConfig as AuthConfig, index$4_AuthCredential as AuthCredential, index$4_AuthCredentialType as AuthCredentialType, index$4_AuthHandler as AuthHandler, index$4_AuthScheme as AuthScheme, index$4_AuthSchemeType as AuthSchemeType, index$4_BaseLLM as BaseLLM, index$4_BaseLLMConnection as BaseLLMConnection, type index$4_BaseMemoryService as BaseMemoryService, index$4_BasicAuthCredential as BasicAuthCredential, index$4_BearerTokenCredential as BearerTokenCredential, type index$4_FunctionCall as FunctionCall, type index$4_FunctionDeclaration as FunctionDeclaration, index$4_GoogleLLM as GoogleLLM, type index$4_GoogleLLMConfig as GoogleLLMConfig, index$4_HttpScheme as HttpScheme, type index$4_ImageContent as ImageContent, type index$4_JSONSchema as JSONSchema, index$4_LLMRegistry as LLMRegistry, index$4_LLMRequest as LLMRequest, type index$4_LLMRequestConfig as LLMRequestConfig, index$4_LLMResponse as LLMResponse, type index$4_ListSessionOptions as ListSessionOptions, type index$4_MemoryResult as MemoryResult, type index$4_Message as Message, type index$4_MessageContent as MessageContent, type index$4_MessageRole as MessageRole, index$4_OAuth2Credential as OAuth2Credential, index$4_OAuth2Scheme as OAuth2Scheme, type index$4_OAuthFlow as OAuthFlow, type index$4_OAuthFlows as OAuthFlows, index$4_OpenAILLM as OpenAILLM, type index$4_OpenAILLMConfig as OpenAILLMConfig, index$4_OpenAILLMConnection as OpenAILLMConnection, index$4_OpenIdConnectScheme as OpenIdConnectScheme, type index$4_SearchMemoryOptions as SearchMemoryOptions, type index$4_SearchMemoryResponse as SearchMemoryResponse, type index$4_Session as Session, index$4_SessionState as SessionState, type index$4_TextContent as TextContent, type index$4_ToolCall as ToolCall, index$4_registerProviders as registerProviders };
1504
+ }
1505
+
1506
+ /**
1507
+ * Represents a single memory retrieval result
1508
+ */
1509
+ interface MemoryResult {
1510
+ /**
1511
+ * The session ID associated with the memory
1512
+ */
1513
+ sessionId: string;
1514
+ /**
1515
+ * Array of events/messages from the session
1516
+ */
1517
+ events: any[];
1518
+ /**
1519
+ * Score indicating relevance to query (0-1)
1520
+ */
1521
+ relevanceScore?: number;
1522
+ }
1523
+ /**
1524
+ * Represents the response from a memory search
1525
+ */
1526
+ interface SearchMemoryResponse {
1527
+ /**
1528
+ * List of memory results matching the search query
1529
+ */
1530
+ memories: MemoryResult[];
1531
+ }
1532
+ /**
1533
+ * Options for memory search
1534
+ */
1535
+ interface SearchMemoryOptions {
1536
+ /**
1537
+ * Session ID to search within (null for all sessions)
1538
+ */
1539
+ sessionId?: string;
1540
+ /**
1541
+ * Maximum number of results to return
1542
+ */
1543
+ limit?: number;
1544
+ /**
1545
+ * Minimum relevance score (0-1)
1546
+ */
1547
+ threshold?: number;
1548
+ /**
1549
+ * Additional filter criteria
1550
+ */
1551
+ filter?: Record<string, any>;
1552
+ }
1553
+ /**
1554
+ * Base interface for memory services
1555
+ */
1556
+ interface BaseMemoryService {
1557
+ /**
1558
+ * Adds a session to the memory service
1559
+ * @param session The session to add
1560
+ */
1561
+ addSessionToMemory(session: Session): Promise<void>;
1562
+ /**
1563
+ * Searches memory for relevant information
1564
+ * @param query The search query
1565
+ * @param options Search options
1566
+ * @returns Search results
1567
+ */
1568
+ searchMemory(query: string, options?: SearchMemoryOptions): Promise<SearchMemoryResponse>;
1569
+ }
1570
+
1571
+ /**
1572
+ * Service for managing sessions
1573
+ */
1574
+ interface SessionService {
1575
+ /**
1576
+ * Creates a new session
1577
+ * @param userId User identifier
1578
+ * @param metadata Optional session metadata
1579
+ * @returns The created session
1580
+ */
1581
+ createSession(userId: string, metadata?: Record<string, any>): Promise<Session>;
1582
+ /**
1583
+ * Gets a session by ID
1584
+ * @param sessionId Session identifier
1585
+ * @returns The session or undefined if not found
1586
+ */
1587
+ getSession(sessionId: string): Promise<Session | undefined>;
1588
+ /**
1589
+ * Updates an existing session
1590
+ * @param session The session to update
1591
+ */
1592
+ updateSession(session: Session): Promise<void>;
1593
+ /**
1594
+ * Lists sessions for a user
1595
+ * @param userId User identifier
1596
+ * @param options Optional filtering options
1597
+ * @returns Array of matching sessions
1598
+ */
1599
+ listSessions(userId: string, options?: ListSessionOptions): Promise<Session[]>;
1600
+ /**
1601
+ * Deletes a session
1602
+ * @param sessionId Session identifier
1603
+ */
1604
+ deleteSession(sessionId: string): Promise<void>;
1605
+ /**
1606
+ * Appends an event to a session object
1607
+ * @param session The session to append the event to
1608
+ * @param event The event to append
1609
+ * @returns The appended event
1610
+ */
1611
+ appendEvent(session: Session, event: Event): Promise<Event>;
1612
+ }
1613
+
1614
+ /**
1615
+ * Contextual data for a specific agent invocation
1616
+ */
1617
+ declare class InvocationContext {
1618
+ /**
1619
+ * Unique session ID for the current conversation
1620
+ */
1621
+ sessionId: string;
1622
+ /**
1623
+ * Current conversation history
1624
+ */
1625
+ messages: Message[];
1626
+ /**
1627
+ * Run configuration
1628
+ */
1629
+ config: RunConfig;
1630
+ /**
1631
+ * User identifier associated with the session
1632
+ */
1633
+ userId?: string;
1634
+ /**
1635
+ * Application name (for multi-app environments)
1636
+ */
1637
+ appName?: string;
1638
+ /**
1639
+ * Memory service for long-term storage
1640
+ */
1641
+ memoryService?: BaseMemoryService;
1642
+ /**
1643
+ * Session service for session management
1644
+ */
1645
+ sessionService?: SessionService;
1646
+ /**
1647
+ * Additional context metadata
1648
+ */
1649
+ metadata: Record<string, any>;
1650
+ /**
1651
+ * Variables stored in the context
1652
+ */
1653
+ private variables;
1654
+ /**
1655
+ * In-memory storage for node execution results
1656
+ */
1657
+ memory: Map<string, any>;
1658
+ /**
1659
+ * Constructor for InvocationContext
1660
+ */
1661
+ constructor(options?: {
1662
+ sessionId?: string;
1663
+ messages?: Message[];
1664
+ config?: RunConfig;
1665
+ userId?: string;
1666
+ appName?: string;
1667
+ memoryService?: BaseMemoryService;
1668
+ sessionService?: SessionService;
1669
+ metadata?: Record<string, any>;
1670
+ });
1671
+ /**
1672
+ * Generates a unique session ID
1673
+ */
1674
+ private generateSessionId;
1675
+ /**
1676
+ * Sets a variable in the context
1677
+ */
1678
+ setVariable(name: string, value: any): void;
1679
+ /**
1680
+ * Gets a variable from the context
1681
+ */
1682
+ getVariable<T>(name: string, defaultValue?: T): T | undefined;
1683
+ /**
1684
+ * Adds a message to the conversation history
1685
+ */
1686
+ addMessage(message: Message): void;
1687
+ /**
1688
+ * Creates a new context with the same configuration but empty message history
1689
+ */
1690
+ createChildContext(): InvocationContext;
1691
+ /**
1692
+ * Loads a session from the session service
1693
+ * @returns The loaded session or undefined if not found
1694
+ */
1695
+ loadSession(): Promise<Session | undefined>;
1696
+ /**
1697
+ * Saves the current conversation to a session
1698
+ * @returns The saved session
1699
+ */
1700
+ saveSession(): Promise<Session | undefined>;
1701
+ /**
1702
+ * Searches memory for relevant information
1703
+ * @param query The search query
1704
+ * @param options Search options
1705
+ * @returns Search results or empty response if no memory service
1706
+ */
1707
+ searchMemory(query: string, options?: SearchMemoryOptions): Promise<SearchMemoryResponse>;
1708
+ }
1709
+
1710
+ /**
1711
+ * Context for tool execution
1712
+ */
1713
+ interface IToolContext {
1714
+ /**
1715
+ * Name of the tool being executed
1716
+ */
1717
+ toolName: string;
1718
+ /**
1719
+ * ID of the tool call
1720
+ */
1721
+ toolId: string;
1722
+ /**
1723
+ * Additional parameters for the tool
1724
+ */
1725
+ parameters: Record<string, any>;
1726
+ /**
1727
+ * Gets a parameter value
1728
+ */
1729
+ getParameter<T>(name: string, defaultValue?: T): T | undefined;
1730
+ /**
1731
+ * Sets a parameter value
1732
+ */
1733
+ setParameter(name: string, value: any): void;
1734
+ }
1735
+ /**
1736
+ * Context for tool execution
1737
+ */
1738
+ declare class ToolContext implements IToolContext {
1739
+ /**
1740
+ * The parent invocation context
1741
+ */
1742
+ private invocationContext;
1743
+ /**
1744
+ * Authentication handler for the tool
1745
+ */
1746
+ auth?: AuthHandler;
1747
+ /**
1748
+ * Additional parameters for the tool
1749
+ */
1750
+ parameters: Record<string, any>;
1751
+ /**
1752
+ * Tool name
1753
+ */
1754
+ toolName: string;
1755
+ /**
1756
+ * Tool ID
1757
+ */
1758
+ toolId: string;
1759
+ /**
1760
+ * Variables stored in the context
1761
+ */
1762
+ private _variables;
1763
+ /**
1764
+ * Constructor for ToolContext
1765
+ */
1766
+ constructor(options: {
1767
+ invocationContext: InvocationContext;
1768
+ auth?: AuthHandler;
1769
+ parameters?: Record<string, any>;
1770
+ });
1771
+ /**
1772
+ * Gets a parameter value
1773
+ */
1774
+ getParameter<T>(name: string, defaultValue?: T): T | undefined;
1775
+ /**
1776
+ * Sets a parameter value
1777
+ */
1778
+ setParameter(name: string, value: any): void;
1779
+ get sessionId(): string;
1780
+ get messages(): Message[];
1781
+ get config(): RunConfig;
1782
+ get userId(): string | undefined;
1783
+ get appName(): string | undefined;
1784
+ get memoryService(): BaseMemoryService | undefined;
1785
+ get sessionService(): SessionService | undefined;
1786
+ get metadata(): Record<string, any>;
1787
+ get variables(): Map<string, any>;
1788
+ setVariable(name: string, value: any): void;
1789
+ getVariable<T>(name: string, defaultValue?: T): T | undefined;
1790
+ addMessage(message: Message): void;
1791
+ loadSession(): Promise<Session | undefined>;
1792
+ saveSession(): Promise<Session | undefined>;
1793
+ searchMemory(query: string, options?: SearchMemoryOptions): Promise<SearchMemoryResponse>;
1794
+ }
1795
+
1796
+ /**
1797
+ * Configuration for tool initialization
1798
+ */
1799
+ interface ToolConfig {
1800
+ /**
1801
+ * Name of the tool
1802
+ */
1803
+ name: string;
1804
+ /**
1805
+ * Description of the tool
1806
+ */
1807
+ description: string;
1808
+ /**
1809
+ * Whether the tool is a long running operation
1810
+ */
1811
+ isLongRunning?: boolean;
1812
+ /**
1813
+ * Whether the tool execution should be retried on failure
1814
+ */
1815
+ shouldRetryOnFailure?: boolean;
1816
+ /**
1817
+ * Maximum retry attempts
1818
+ */
1819
+ maxRetryAttempts?: number;
1820
+ }
1821
+ /**
1822
+ * The base class for all tools
1823
+ */
1824
+ declare abstract class BaseTool {
1825
+ /**
1826
+ * Name of the tool
1827
+ */
1828
+ name: string;
1829
+ /**
1830
+ * Description of the tool
1831
+ */
1832
+ description: string;
1833
+ /**
1834
+ * Whether the tool is a long running operation
1835
+ */
1836
+ isLongRunning: boolean;
1837
+ /**
1838
+ * Whether the tool execution should be retried on failure
1839
+ */
1840
+ shouldRetryOnFailure: boolean;
1841
+ /**
1842
+ * Maximum retry attempts
1843
+ */
1844
+ maxRetryAttempts: number;
1845
+ /**
1846
+ * Base delay for retry in ms (will be used with exponential backoff)
1847
+ */
1848
+ baseRetryDelay: number;
1849
+ /**
1850
+ * Maximum delay for retry in ms
1851
+ */
1852
+ maxRetryDelay: number;
1853
+ /**
1854
+ * Constructor for BaseTool
1855
+ */
1856
+ constructor(config: ToolConfig);
1857
+ /**
1858
+ * Gets the OpenAPI specification of this tool in the form of a FunctionDeclaration
1859
+ */
1860
+ abstract getDeclaration(): FunctionDeclaration;
1861
+ /**
1862
+ * Validates the arguments against the schema in the function declaration
1863
+ * @param args Arguments to validate
1864
+ * @returns True if arguments are valid
1865
+ */
1866
+ validateArguments(args: Record<string, any>): boolean;
1867
+ /**
1868
+ * Runs the tool with the given arguments and context
1869
+ * This method must be implemented by subclasses
1870
+ *
1871
+ * @param args Arguments for the tool
1872
+ * @param context Tool execution context
1873
+ * @returns Result of the tool execution
1874
+ */
1875
+ abstract runAsync(args: Record<string, any>, context: ToolContext): Promise<any>;
1876
+ /**
1877
+ * Executes the tool with error handling and retries
1878
+ *
1879
+ * @param args Arguments for the tool
1880
+ * @param context Tool execution context
1881
+ * @returns Result of the tool execution or error information
1882
+ */
1883
+ safeExecute(args: Record<string, any>, context: ToolContext): Promise<any>;
1884
+ }
1885
+
1886
+ /**
1887
+ * Configuration for Agent
1888
+ */
1889
+ interface AgentConfig {
1890
+ /**
1891
+ * Name of the agent
1892
+ */
1893
+ name: string;
1894
+ /**
1895
+ * Description of the agent
1896
+ */
1897
+ description: string;
1898
+ /**
1899
+ * The LLM model to use
1900
+ */
1901
+ model: string;
1902
+ /**
1903
+ * Instructions for the agent
1904
+ */
1905
+ instructions?: string;
1906
+ /**
1907
+ * Tools available to the agent
1908
+ */
1909
+ tools?: BaseTool[];
1910
+ /**
1911
+ * Maximum number of tool execution steps
1912
+ */
1913
+ maxToolExecutionSteps?: number;
1914
+ /**
1915
+ * Memory service for long-term storage and retrieval
1916
+ */
1917
+ memoryService?: BaseMemoryService;
1918
+ /**
1919
+ * Session service for managing conversations
1920
+ */
1921
+ sessionService?: SessionService;
1922
+ /**
1923
+ * User ID for the session (required for session persistence)
1924
+ */
1925
+ userId?: string;
1926
+ /**
1927
+ * Application name (for multi-app environments)
1928
+ */
1929
+ appName?: string;
1930
+ /**
1931
+ * Whether to automatically augment prompts with relevant memory
1932
+ */
1933
+ useMemoryAugmentation?: boolean;
1934
+ /**
1935
+ * The maximum number of memory items to include in augmentation
1936
+ */
1937
+ maxMemoryItems?: number;
1938
+ /**
1939
+ * The minimum relevance score for memory augmentation (0-1)
1940
+ */
1941
+ memoryRelevanceThreshold?: number;
1942
+ }
1943
+ /**
1944
+ * Standard Agent implementation that uses an LLM
1945
+ */
1946
+ declare class Agent extends BaseAgent {
1947
+ /**
1948
+ * The LLM model to use
1949
+ */
1950
+ private model;
1951
+ /**
1952
+ * The LLM instance
1953
+ */
1954
+ private llm;
1955
+ /**
1956
+ * Instructions for the agent
1957
+ */
1958
+ private instructions?;
1959
+ /**
1960
+ * Tools available to the agent
1961
+ */
1962
+ private tools;
1963
+ /**
1964
+ * Maximum number of tool execution steps to prevent infinite loops
1965
+ */
1966
+ private maxToolExecutionSteps;
1967
+ /**
1968
+ * Memory service for long-term storage and retrieval
1969
+ */
1970
+ private memoryService?;
1971
+ /**
1972
+ * Session service for managing conversations
1973
+ */
1974
+ private sessionService?;
1975
+ /**
1976
+ * User ID for the session
1977
+ */
1978
+ private userId?;
1979
+ /**
1980
+ * Application name
1981
+ */
1982
+ private appName?;
1983
+ /**
1984
+ * Whether to automatically augment prompts with relevant memory
1985
+ */
1986
+ private useMemoryAugmentation;
1987
+ /**
1988
+ * The maximum number of memory items to include in augmentation
1989
+ */
1990
+ private maxMemoryItems;
1991
+ /**
1992
+ * The minimum relevance score for memory augmentation (0-1)
1993
+ */
1994
+ private memoryRelevanceThreshold;
1995
+ /**
1996
+ * Constructor for Agent
1997
+ */
1998
+ constructor(config: AgentConfig);
1999
+ /**
2000
+ * Finds a tool by name
2001
+ */
2002
+ private findTool;
2003
+ /**
2004
+ * Executes a tool call and returns the result
2005
+ */
2006
+ private executeTool;
2007
+ /**
2008
+ * Execute multiple tools in parallel
2009
+ */
2010
+ private executeTools;
2011
+ /**
2012
+ * Augments context with relevant memory
2013
+ */
2014
+ private augmentWithMemory;
2015
+ /**
2016
+ * Saves the session to memory
2017
+ */
2018
+ private saveToMemory;
2019
+ /**
2020
+ * Generates a unique session ID
2021
+ */
2022
+ private generateSessionId;
2023
+ /**
2024
+ * Runs the agent with the given messages and configuration
2025
+ */
2026
+ run(options: {
2027
+ messages: Message[];
2028
+ config?: RunConfig;
2029
+ sessionId?: string;
2030
+ }): Promise<LLMResponse>;
2031
+ /**
2032
+ * Runs the agent with streaming support
2033
+ */
2034
+ runStreaming(options: {
2035
+ messages: Message[];
2036
+ config?: RunConfig;
2037
+ sessionId?: string;
2038
+ }): AsyncGenerator<LLMResponse>;
2039
+ }
2040
+
2041
+ /**
2042
+ * Configuration for SequentialAgent
2043
+ */
2044
+ interface SequentialAgentConfig {
2045
+ /**
2046
+ * Name of the agent
2047
+ */
2048
+ name: string;
2049
+ /**
2050
+ * Description of the agent
2051
+ */
2052
+ description: string;
2053
+ /**
2054
+ * Sub-agents to execute in sequence
2055
+ */
2056
+ agents?: BaseAgent[];
2057
+ }
2058
+ /**
2059
+ * Extended LLMResponse interface that includes metadata
2060
+ */
2061
+ interface EnhancedLLMResponse extends LLMResponse {
2062
+ metadata?: Record<string, any>;
2063
+ }
2064
+ /**
2065
+ * Sequential Agent that executes sub-agents in sequence
2066
+ * Each sub-agent's output becomes input to the next agent
2067
+ */
2068
+ declare class SequentialAgent extends BaseAgent {
2069
+ /**
2070
+ * Constructor for SequentialAgent
2071
+ */
2072
+ constructor(config: SequentialAgentConfig);
2073
+ /**
2074
+ * Runs the agent with the given messages and configuration
2075
+ * Executes sub-agents sequentially, passing output from one to the next
2076
+ */
2077
+ run(options: {
2078
+ messages: Message[];
2079
+ config?: RunConfig;
2080
+ }): Promise<EnhancedLLMResponse>;
2081
+ /**
2082
+ * Runs the agent with streaming support
2083
+ * Streams responses from each sub-agent in sequence
2084
+ */
2085
+ runStreaming(options: {
2086
+ messages: Message[];
2087
+ config?: RunConfig;
2088
+ }): AsyncIterable<EnhancedLLMResponse>;
2089
+ }
2090
+
2091
+ /**
2092
+ * Configuration for ParallelAgent
2093
+ */
2094
+ interface ParallelAgentConfig {
2095
+ /**
2096
+ * Name of the agent
2097
+ */
2098
+ name: string;
2099
+ /**
2100
+ * Description of the agent
2101
+ */
2102
+ description: string;
2103
+ /**
2104
+ * Sub-agents to execute in parallel
2105
+ */
2106
+ agents?: BaseAgent[];
2107
+ }
2108
+ /**
2109
+ * Parallel Agent that executes sub-agents in parallel
2110
+ * All sub-agents execute independently with the same input
2111
+ */
2112
+ declare class ParallelAgent extends BaseAgent {
2113
+ /**
2114
+ * Constructor for ParallelAgent
2115
+ */
2116
+ constructor(config: ParallelAgentConfig);
2117
+ /**
2118
+ * Runs the agent with the given messages and configuration
2119
+ * Executes all sub-agents in parallel
2120
+ */
2121
+ run(options: {
2122
+ messages: Message[];
2123
+ config?: RunConfig;
2124
+ }): Promise<LLMResponse>;
2125
+ /**
2126
+ * Runs the agent with streaming support
2127
+ * Collects streaming responses from all sub-agents
2128
+ */
2129
+ runStreaming(options: {
2130
+ messages: Message[];
2131
+ config?: RunConfig;
2132
+ }): AsyncIterable<LLMResponse>;
2133
+ }
2134
+
2135
+ /**
2136
+ * Configuration for LoopAgent
2137
+ */
2138
+ interface LoopAgentConfig {
2139
+ /**
2140
+ * Name of the agent
2141
+ */
2142
+ name: string;
2143
+ /**
2144
+ * Description of the agent
2145
+ */
2146
+ description: string;
2147
+ /**
2148
+ * Sub-agent to execute in a loop
2149
+ */
2150
+ agent?: BaseAgent;
2151
+ /**
2152
+ * Maximum number of iterations
2153
+ */
2154
+ maxIterations?: number;
2155
+ /**
2156
+ * Agent that decides whether to continue the loop
2157
+ */
2158
+ conditionAgent?: BaseAgent;
2159
+ /**
2160
+ * Custom condition check function
2161
+ */
2162
+ conditionCheck?: (response: LLMResponse) => boolean | Promise<boolean>;
2163
+ }
2164
+ /**
2165
+ * Loop Agent that executes sub-agents in a loop
2166
+ * Repeatedly executes a sub-agent until a condition is met
2167
+ */
2168
+ declare class LoopAgent extends BaseAgent {
2169
+ /**
2170
+ * Maximum number of iterations to prevent infinite loops
2171
+ */
2172
+ private maxIterations;
2173
+ /**
2174
+ * Agent that decides whether to continue the loop
2175
+ */
2176
+ private conditionAgent?;
2177
+ /**
2178
+ * Custom condition check function
2179
+ */
2180
+ private conditionCheck?;
2181
+ /**
2182
+ * Constructor for LoopAgent
2183
+ */
2184
+ constructor(config: LoopAgentConfig);
2185
+ /**
2186
+ * Default condition check that always returns true
2187
+ * to continue the loop until maxIterations is reached
2188
+ */
2189
+ private defaultConditionCheck;
2190
+ /**
2191
+ * Check if the loop should continue
2192
+ */
2193
+ private shouldContinue;
2194
+ /**
2195
+ * Runs the agent with the given messages and configuration
2196
+ * Executes the sub-agent in a loop until the condition is met
2197
+ */
2198
+ run(options: {
2199
+ messages: Message[];
2200
+ config?: RunConfig;
2201
+ }): Promise<LLMResponse>;
2202
+ /**
2203
+ * Runs the agent with streaming support
2204
+ */
2205
+ runStreaming(options: {
2206
+ messages: Message[];
2207
+ config?: RunConfig;
2208
+ }): AsyncIterable<LLMResponse>;
2209
+ }
2210
+
2211
+ /**
2212
+ * Represents a node in a LangGraph workflow
2213
+ */
2214
+ interface LangGraphNode {
2215
+ /**
2216
+ * Name of the node
2217
+ */
2218
+ name: string;
2219
+ /**
2220
+ * Agent associated with this node
2221
+ */
2222
+ agent: BaseAgent;
2223
+ /**
2224
+ * Target nodes to execute after this node
2225
+ */
2226
+ targets?: string[];
2227
+ /**
2228
+ * Condition function to determine if this node should execute
2229
+ */
2230
+ condition?: (result: LLMResponse, context: InvocationContext) => boolean | Promise<boolean>;
2231
+ }
2232
+ /**
2233
+ * Configuration for LangGraphAgent
2234
+ */
2235
+ interface LangGraphAgentConfig {
2236
+ /**
2237
+ * Name of the agent
2238
+ */
2239
+ name: string;
2240
+ /**
2241
+ * Description of the agent
2242
+ */
2243
+ description: string;
2244
+ /**
2245
+ * Graph nodes (agents and their connections)
2246
+ */
2247
+ nodes: LangGraphNode[];
2248
+ /**
2249
+ * Root node to start execution from
2250
+ */
2251
+ rootNode: string;
2252
+ /**
2253
+ * Maximum number of steps to prevent infinite loops
2254
+ */
2255
+ maxSteps?: number;
2256
+ }
2257
+ /**
2258
+ * LangGraphAgent that implements a directed graph of agents
2259
+ * Allows complex workflows with conditional branching
2260
+ */
2261
+ declare class LangGraphAgent extends BaseAgent {
2262
+ /**
2263
+ * Graph nodes (agents and their connections)
2264
+ */
2265
+ private nodes;
2266
+ /**
2267
+ * Root node to start execution from
2268
+ */
2269
+ private rootNode;
2270
+ /**
2271
+ * Maximum number of steps to prevent infinite loops
2272
+ */
2273
+ private maxSteps;
2274
+ /**
2275
+ * Results from node executions
2276
+ */
2277
+ private results;
2278
+ /**
2279
+ * Constructor for LangGraphAgent
2280
+ */
2281
+ constructor(config: LangGraphAgentConfig);
2282
+ /**
2283
+ * Validates the graph for potential issues
2284
+ */
2285
+ private validateGraph;
2286
+ /**
2287
+ * Check if a value is an LLMResponse
2288
+ */
2289
+ private isLLMResponse;
2290
+ /**
2291
+ * Extracts text from MessageContent
2292
+ */
2293
+ private extractTextContent;
2294
+ /**
2295
+ * Gets the next nodes to execute based on the current node and its result
2296
+ */
2297
+ private getNextNodes;
2298
+ /**
2299
+ * Conditionally execute the next node if the condition is met
2300
+ */
2301
+ private executeConditionalNode;
2302
+ /**
2303
+ * Runs the agent with the given messages and configuration
2304
+ * Executes the graph by traversing nodes based on conditions
2305
+ */
2306
+ run(options: {
2307
+ messages: Message[];
2308
+ config?: RunConfig;
2309
+ }): Promise<LLMResponse>;
2310
+ /**
2311
+ * Runs the agent with streaming support
2312
+ */
2313
+ runStreaming(options: {
2314
+ messages: Message[];
2315
+ config?: RunConfig;
2316
+ }): AsyncIterable<LLMResponse>;
2317
+ }
2318
+
2319
+ type index$3_Agent = Agent;
2320
+ declare const index$3_Agent: typeof Agent;
2321
+ type index$3_AgentConfig = AgentConfig;
2322
+ type index$3_AudioTranscriptionConfig = AudioTranscriptionConfig;
2323
+ type index$3_BaseAgent = BaseAgent;
2324
+ declare const index$3_BaseAgent: typeof BaseAgent;
2325
+ type index$3_InvocationContext = InvocationContext;
2326
+ declare const index$3_InvocationContext: typeof InvocationContext;
2327
+ type index$3_LangGraphAgent = LangGraphAgent;
2328
+ declare const index$3_LangGraphAgent: typeof LangGraphAgent;
2329
+ type index$3_LangGraphAgentConfig = LangGraphAgentConfig;
2330
+ type index$3_LangGraphNode = LangGraphNode;
2331
+ type index$3_LoopAgent = LoopAgent;
2332
+ declare const index$3_LoopAgent: typeof LoopAgent;
2333
+ type index$3_LoopAgentConfig = LoopAgentConfig;
2334
+ type index$3_ParallelAgent = ParallelAgent;
2335
+ declare const index$3_ParallelAgent: typeof ParallelAgent;
2336
+ type index$3_ParallelAgentConfig = ParallelAgentConfig;
2337
+ type index$3_RunConfig = RunConfig;
2338
+ declare const index$3_RunConfig: typeof RunConfig;
2339
+ type index$3_SequentialAgent = SequentialAgent;
2340
+ declare const index$3_SequentialAgent: typeof SequentialAgent;
2341
+ type index$3_SequentialAgentConfig = SequentialAgentConfig;
2342
+ type index$3_SpeechConfig = SpeechConfig;
2343
+ type index$3_StreamingMode = StreamingMode;
2344
+ declare const index$3_StreamingMode: typeof StreamingMode;
2345
+ declare namespace index$3 {
2346
+ export { index$3_Agent as Agent, type index$3_AgentConfig as AgentConfig, type index$3_AudioTranscriptionConfig as AudioTranscriptionConfig, index$3_BaseAgent as BaseAgent, index$3_InvocationContext as InvocationContext, index$3_LangGraphAgent as LangGraphAgent, type index$3_LangGraphAgentConfig as LangGraphAgentConfig, type index$3_LangGraphNode as LangGraphNode, index$3_LoopAgent as LoopAgent, type index$3_LoopAgentConfig as LoopAgentConfig, index$3_ParallelAgent as ParallelAgent, type index$3_ParallelAgentConfig as ParallelAgentConfig, index$3_RunConfig as RunConfig, index$3_SequentialAgent as SequentialAgent, type index$3_SequentialAgentConfig as SequentialAgentConfig, type index$3_SpeechConfig as SpeechConfig, index$3_StreamingMode as StreamingMode };
2347
+ }
2348
+
2349
+ /**
2350
+ * A tool that wraps a user-defined TypeScript function.
2351
+ *
2352
+ * This tool automatically generates a function declaration from the function's
2353
+ * signature and documentation, making it easy to expose functions to agents.
2354
+ */
2355
+ declare class FunctionTool<T extends Record<string, any>> extends BaseTool {
2356
+ private func;
2357
+ private mandatoryArgs;
2358
+ /**
2359
+ * Creates a new FunctionTool wrapping the provided function.
2360
+ *
2361
+ * @param func The function to wrap
2362
+ * @param options Optional configuration for the tool
2363
+ */
2364
+ constructor(func: (...args: any[]) => any, options?: {
2365
+ name?: string;
2366
+ description?: string;
2367
+ isLongRunning?: boolean;
2368
+ shouldRetryOnFailure?: boolean;
2369
+ maxRetryAttempts?: number;
2370
+ });
2371
+ /**
2372
+ * Executes the wrapped function with the provided arguments.
2373
+ */
2374
+ runAsync(args: T, context: ToolContext): Promise<any>;
2375
+ /**
2376
+ * Returns the function declaration for this tool.
2377
+ */
2378
+ getDeclaration(): FunctionDeclaration;
2379
+ /**
2380
+ * Checks if the wrapped function accepts a toolContext parameter.
2381
+ */
2382
+ private functionAcceptsToolContext;
2383
+ /**
2384
+ * Checks if the wrapped function is async.
2385
+ */
2386
+ private isAsyncFunction;
2387
+ /**
2388
+ * Extracts the mandatory arguments from a function.
2389
+ * In TypeScript, we can't easily inspect parameter defaults at runtime,
2390
+ * so this is a best-effort approach.
2391
+ */
2392
+ private getMandatoryArgs;
2393
+ /**
2394
+ * Checks which mandatory arguments are missing from the provided args.
2395
+ */
2396
+ private getMissingMandatoryArgs;
2397
+ }
2398
+
2399
+ /**
2400
+ * Options for building a function declaration
2401
+ */
2402
+ interface BuildFunctionDeclarationOptions {
2403
+ name?: string;
2404
+ description?: string;
2405
+ ignoreParams?: string[];
2406
+ }
2407
+ /**
2408
+ * Builds a function declaration from a TypeScript function.
2409
+ *
2410
+ * This utility analyzes the function signature and JSDoc comments to create
2411
+ * a FunctionDeclaration object that can be used with LLMs.
2412
+ *
2413
+ * @param func The function to analyze
2414
+ * @param options Options for customizing the declaration
2415
+ * @returns A FunctionDeclaration representing the function
2416
+ */
2417
+ declare function buildFunctionDeclaration(func: (...args: any[]) => any, options?: BuildFunctionDeclarationOptions): FunctionDeclaration;
2418
+
2419
+ /**
2420
+ * Creates a new FunctionTool that wraps a function.
2421
+ * This is a convenience function for creating a new FunctionTool.
2422
+ *
2423
+ * @param func The function to wrap
2424
+ * @param options Optional configuration for the tool
2425
+ * @returns A new FunctionTool wrapping the function
2426
+ */
2427
+ declare function createFunctionTool(func: (...args: any[]) => any, options?: {
2428
+ name?: string;
2429
+ description?: string;
2430
+ isLongRunning?: boolean;
2431
+ shouldRetryOnFailure?: boolean;
2432
+ maxRetryAttempts?: number;
2433
+ }): any;
2434
+
2435
+ /**
2436
+ * Simple GoogleSearch tool implementation
2437
+ */
2438
+ declare class GoogleSearch extends BaseTool {
2439
+ /**
2440
+ * Constructor for GoogleSearch
2441
+ */
2442
+ constructor();
2443
+ /**
2444
+ * Get the function declaration for the tool
2445
+ */
2446
+ getDeclaration(): FunctionDeclaration;
2447
+ /**
2448
+ * Execute the search
2449
+ * This is a simplified implementation that doesn't actually search, just returns mock results
2450
+ */
2451
+ runAsync(args: {
2452
+ query: string;
2453
+ num_results?: number;
2454
+ }, _context: ToolContext): Promise<any>;
2455
+ }
2456
+
2457
+ interface HttpRequestResult {
2458
+ statusCode: number;
2459
+ headers: Record<string, string>;
2460
+ body: string;
2461
+ error?: string;
2462
+ }
2463
+ /**
2464
+ * Tool for making HTTP requests to external APIs and web services
2465
+ */
2466
+ declare class HttpRequestTool extends BaseTool {
2467
+ constructor();
2468
+ /**
2469
+ * Get the function declaration for the tool
2470
+ */
2471
+ getDeclaration(): FunctionDeclaration;
2472
+ /**
2473
+ * Execute the HTTP request
2474
+ */
2475
+ runAsync(args: {
2476
+ url: string;
2477
+ method?: string;
2478
+ headers?: Record<string, string>;
2479
+ body?: string;
2480
+ params?: Record<string, string>;
2481
+ timeout?: number;
2482
+ }, _context: ToolContext): Promise<HttpRequestResult>;
2483
+ /**
2484
+ * Check if a string is valid JSON
2485
+ */
2486
+ private isValidJson;
2487
+ }
2488
+
2489
+ interface FileOperationResult {
2490
+ success: boolean;
2491
+ data?: any;
2492
+ error?: string;
2493
+ }
2494
+ /**
2495
+ * Tool for performing file system operations
2496
+ */
2497
+ declare class FileOperationsTool extends BaseTool {
2498
+ private basePath;
2499
+ constructor(options?: {
2500
+ basePath?: string;
2501
+ });
2502
+ /**
2503
+ * Get the function declaration for the tool
2504
+ */
2505
+ getDeclaration(): FunctionDeclaration;
2506
+ /**
2507
+ * Execute the file operation
2508
+ */
2509
+ runAsync(args: {
2510
+ operation: "read" | "write" | "append" | "delete" | "exists" | "list" | "mkdir";
2511
+ filepath: string;
2512
+ content?: string;
2513
+ encoding?: BufferEncoding;
2514
+ }, _context: ToolContext): Promise<FileOperationResult>;
2515
+ /**
2516
+ * Resolve a file path relative to the base path
2517
+ */
2518
+ private resolvePath;
2519
+ /**
2520
+ * Validate that a path is within the base path for security
2521
+ */
2522
+ private validatePath;
2523
+ /**
2524
+ * Read a file
2525
+ */
2526
+ private readFile;
2527
+ /**
2528
+ * Write to a file
2529
+ */
2530
+ private writeFile;
2531
+ /**
2532
+ * Append to a file
2533
+ */
2534
+ private appendFile;
2535
+ /**
2536
+ * Delete a file
2537
+ */
2538
+ private deleteFile;
2539
+ /**
2540
+ * Check if a file exists
2541
+ */
2542
+ private fileExists;
2543
+ /**
2544
+ * List directory contents
2545
+ */
2546
+ private listDirectory;
2547
+ /**
2548
+ * Create a directory
2549
+ */
2550
+ private makeDirectory;
2551
+ }
2552
+
2553
+ interface UserInteractionResult {
2554
+ success: boolean;
2555
+ userInput?: string;
2556
+ error?: string;
2557
+ }
2558
+ /**
2559
+ * Tool for prompting the user for input
2560
+ */
2561
+ declare class UserInteractionTool extends BaseTool {
2562
+ constructor();
2563
+ /**
2564
+ * Get the function declaration for the tool
2565
+ */
2566
+ getDeclaration(): FunctionDeclaration;
2567
+ /**
2568
+ * Execute the user interaction
2569
+ */
2570
+ runAsync(args: {
2571
+ prompt: string;
2572
+ options?: string[];
2573
+ defaultValue?: string;
2574
+ }, context: ToolContext): Promise<UserInteractionResult>;
2575
+ }
2576
+
2577
+ declare module "./tool-context" {
2578
+ interface ToolContext {
2579
+ actions?: {
2580
+ escalate?: boolean;
2581
+ skip_summarization?: boolean;
2582
+ transfer_to_agent?: string;
2583
+ };
2584
+ }
2585
+ }
2586
+
2587
+ /**
2588
+ * Tool that allows an agent to exit the current execution loop
2589
+ */
2590
+ declare class ExitLoopTool extends BaseTool {
2591
+ /**
2592
+ * Constructor for ExitLoopTool
2593
+ */
2594
+ constructor();
2595
+ /**
2596
+ * Get the function declaration for the tool
2597
+ */
2598
+ getDeclaration(): FunctionDeclaration;
2599
+ /**
2600
+ * Execute the exit loop action
2601
+ */
2602
+ runAsync(_args: Record<string, any>, context: ToolContext): Promise<any>;
2603
+ }
2604
+
2605
+ /**
2606
+ * Tool that allows an agent to get a choice from the user
2607
+ */
2608
+ declare class GetUserChoiceTool extends BaseTool {
2609
+ /**
2610
+ * Constructor for GetUserChoiceTool
2611
+ */
2612
+ constructor();
2613
+ /**
2614
+ * Get the function declaration for the tool
2615
+ */
2616
+ getDeclaration(): FunctionDeclaration;
2617
+ /**
2618
+ * Execute the user choice action
2619
+ * This is a long running operation that will return null initially
2620
+ * and the actual choice will be provided asynchronously
2621
+ */
2622
+ runAsync(args: {
2623
+ options: string[];
2624
+ question?: string;
2625
+ }, context: ToolContext): Promise<any>;
2626
+ }
2627
+
2628
+ /**
2629
+ * Tool that allows an agent to transfer control to another agent
2630
+ */
2631
+ declare class TransferToAgentTool extends BaseTool {
2632
+ /**
2633
+ * Constructor for TransferToAgentTool
2634
+ */
2635
+ constructor();
2636
+ /**
2637
+ * Get the function declaration for the tool
2638
+ */
2639
+ getDeclaration(): FunctionDeclaration;
2640
+ /**
2641
+ * Execute the transfer to agent action
2642
+ */
2643
+ runAsync(args: {
2644
+ agent_name: string;
2645
+ }, context: ToolContext): Promise<any>;
2646
+ }
2647
+
2648
+ /**
2649
+ * Tool that allows an agent to load memories relevant to a query
2650
+ */
2651
+ declare class LoadMemoryTool extends BaseTool {
2652
+ /**
2653
+ * Constructor for LoadMemoryTool
2654
+ */
2655
+ constructor();
2656
+ /**
2657
+ * Get the function declaration for the tool
2658
+ */
2659
+ getDeclaration(): FunctionDeclaration;
2660
+ /**
2661
+ * Execute the memory loading action
2662
+ */
2663
+ runAsync(args: {
2664
+ query: string;
2665
+ }, context: ToolContext): Promise<any>;
2666
+ }
2667
+
2668
+ /**
2669
+ * Tools module exports
2670
+ */
2671
+
2672
+ type index$2_BaseTool = BaseTool;
2673
+ declare const index$2_BaseTool: typeof BaseTool;
2674
+ type index$2_BuildFunctionDeclarationOptions = BuildFunctionDeclarationOptions;
2675
+ type index$2_ExitLoopTool = ExitLoopTool;
2676
+ declare const index$2_ExitLoopTool: typeof ExitLoopTool;
2677
+ type index$2_FileOperationsTool = FileOperationsTool;
2678
+ declare const index$2_FileOperationsTool: typeof FileOperationsTool;
2679
+ type index$2_FunctionTool<T extends Record<string, any>> = FunctionTool<T>;
2680
+ declare const index$2_FunctionTool: typeof FunctionTool;
2681
+ type index$2_GetUserChoiceTool = GetUserChoiceTool;
2682
+ declare const index$2_GetUserChoiceTool: typeof GetUserChoiceTool;
2683
+ type index$2_GoogleSearch = GoogleSearch;
2684
+ declare const index$2_GoogleSearch: typeof GoogleSearch;
2685
+ type index$2_HttpRequestTool = HttpRequestTool;
2686
+ declare const index$2_HttpRequestTool: typeof HttpRequestTool;
2687
+ type index$2_IToolContext = IToolContext;
2688
+ type index$2_LoadMemoryTool = LoadMemoryTool;
2689
+ declare const index$2_LoadMemoryTool: typeof LoadMemoryTool;
2690
+ type index$2_ToolConfig = ToolConfig;
2691
+ type index$2_ToolContext = ToolContext;
2692
+ declare const index$2_ToolContext: typeof ToolContext;
2693
+ type index$2_TransferToAgentTool = TransferToAgentTool;
2694
+ declare const index$2_TransferToAgentTool: typeof TransferToAgentTool;
2695
+ type index$2_UserInteractionTool = UserInteractionTool;
2696
+ declare const index$2_UserInteractionTool: typeof UserInteractionTool;
2697
+ declare const index$2_buildFunctionDeclaration: typeof buildFunctionDeclaration;
2698
+ declare const index$2_createFunctionTool: typeof createFunctionTool;
2699
+ declare namespace index$2 {
2700
+ export { index$2_BaseTool as BaseTool, type index$2_BuildFunctionDeclarationOptions as BuildFunctionDeclarationOptions, index$2_ExitLoopTool as ExitLoopTool, index$2_FileOperationsTool as FileOperationsTool, index$2_FunctionTool as FunctionTool, index$2_GetUserChoiceTool as GetUserChoiceTool, index$2_GoogleSearch as GoogleSearch, index$2_HttpRequestTool as HttpRequestTool, type index$2_IToolContext as IToolContext, index$2_LoadMemoryTool as LoadMemoryTool, type index$2_ToolConfig as ToolConfig, index$2_ToolContext as ToolContext, index$2_TransferToAgentTool as TransferToAgentTool, index$2_UserInteractionTool as UserInteractionTool, index$2_buildFunctionDeclaration as buildFunctionDeclaration, index$2_createFunctionTool as createFunctionTool };
2701
+ }
2702
+
2703
+ /**
2704
+ * An in-memory memory service for development and testing
2705
+ * Stores sessions and conversations in memory without persistence
2706
+ */
2707
+ declare class InMemoryMemoryService implements BaseMemoryService {
2708
+ /**
2709
+ * Map of sessions by ID
2710
+ */
2711
+ private sessions;
2712
+ /**
2713
+ * Constructor for InMemoryMemoryService
2714
+ */
2715
+ constructor();
2716
+ /**
2717
+ * Adds a session to the memory service
2718
+ * @param session The session to add
2719
+ */
2720
+ addSessionToMemory(session: Session): Promise<void>;
2721
+ /**
2722
+ * Searches memory for relevant information
2723
+ * @param query The search query
2724
+ * @param options Search options
2725
+ * @returns Search results
2726
+ */
2727
+ searchMemory(query: string, options?: SearchMemoryOptions): Promise<SearchMemoryResponse>;
2728
+ /**
2729
+ * Gets all sessions in the memory service
2730
+ * @returns All sessions
2731
+ */
2732
+ getAllSessions(): Session[];
2733
+ /**
2734
+ * Gets a session by ID
2735
+ * @param sessionId The session ID
2736
+ * @returns The session or undefined if not found
2737
+ */
2738
+ getSession(sessionId: string): Session | undefined;
2739
+ /**
2740
+ * Clears all sessions from memory
2741
+ */
2742
+ clear(): void;
2743
+ }
2744
+
2745
+ /**
2746
+ * Configuration for PersistentMemoryService
2747
+ */
2748
+ interface PersistentMemoryServiceConfig {
2749
+ /**
2750
+ * Directory where memory files will be stored
2751
+ */
2752
+ storageDir: string;
2753
+ /**
2754
+ * Whether to create the storage directory if it doesn't exist
2755
+ */
2756
+ createDir?: boolean;
2757
+ /**
2758
+ * File prefix for memory files
2759
+ */
2760
+ filePrefix?: string;
2761
+ }
2762
+ /**
2763
+ * A file-based implementation of memory service that persists data to disk
2764
+ * This provides durability across application restarts
2765
+ */
2766
+ declare class PersistentMemoryService implements BaseMemoryService {
2767
+ /**
2768
+ * In-memory service used for search operations
2769
+ */
2770
+ private inMemoryService;
2771
+ /**
2772
+ * Directory where memory files will be stored
2773
+ */
2774
+ private storageDir;
2775
+ /**
2776
+ * File prefix for memory files
2777
+ */
2778
+ private filePrefix;
2779
+ /**
2780
+ * Constructor for PersistentMemoryService
2781
+ */
2782
+ constructor(config: PersistentMemoryServiceConfig);
2783
+ /**
2784
+ * Adds a session to memory and persists to disk
2785
+ * @param session The session to add
2786
+ */
2787
+ addSessionToMemory(session: Session): Promise<void>;
2788
+ /**
2789
+ * Searches memory for relevant information
2790
+ * @param query The search query
2791
+ * @param options Search options
2792
+ * @returns Search results
2793
+ */
2794
+ searchMemory(query: string, options?: SearchMemoryOptions): Promise<SearchMemoryResponse>;
2795
+ /**
2796
+ * Persists a session to disk
2797
+ * @param session The session to save
2798
+ */
2799
+ private saveSessionToDisk;
2800
+ /**
2801
+ * Gets the file path for a session
2802
+ * @param sessionId The session ID
2803
+ * @returns The file path
2804
+ */
2805
+ private getSessionFilePath;
2806
+ /**
2807
+ * Loads all memory files from disk
2808
+ */
2809
+ private loadMemoryFiles;
2810
+ /**
2811
+ * Gets all sessions in memory
2812
+ * @returns Array of sessions
2813
+ */
2814
+ getAllSessions(): Session[];
2815
+ /**
2816
+ * Gets a session by ID
2817
+ * @param sessionId Session ID
2818
+ * @returns The session or undefined if not found
2819
+ */
2820
+ getSession(sessionId: string): Session | undefined;
2821
+ /**
2822
+ * Deletes a session from memory and disk
2823
+ * @param sessionId Session ID to delete
2824
+ */
2825
+ deleteSession(sessionId: string): Promise<void>;
2826
+ /**
2827
+ * Clears all sessions from memory and disk
2828
+ */
2829
+ clear(): Promise<void>;
2830
+ }
2831
+
2832
+ /**
2833
+ * Memory Services for the Agent Development Kit
2834
+ */
2835
+
2836
+ type index$1_InMemoryMemoryService = InMemoryMemoryService;
2837
+ declare const index$1_InMemoryMemoryService: typeof InMemoryMemoryService;
2838
+ type index$1_PersistentMemoryService = PersistentMemoryService;
2839
+ declare const index$1_PersistentMemoryService: typeof PersistentMemoryService;
2840
+ declare namespace index$1 {
2841
+ export { index$1_InMemoryMemoryService as InMemoryMemoryService, index$1_PersistentMemoryService as PersistentMemoryService };
2842
+ }
2843
+
2844
+ /**
2845
+ * In-memory implementation of SessionService
2846
+ */
2847
+ declare class InMemorySessionService implements SessionService {
2848
+ /**
2849
+ * Map of sessions by ID
2850
+ */
2851
+ private sessions;
2852
+ /**
2853
+ * Constructor for InMemorySessionService
2854
+ */
2855
+ constructor();
2856
+ /**
2857
+ * Creates a new session
2858
+ * @param userId User identifier
2859
+ * @param metadata Optional session metadata
2860
+ * @returns The created session
2861
+ */
2862
+ createSession(userId: string, metadata?: Record<string, any>): Promise<Session>;
2863
+ /**
2864
+ * Gets a session by ID
2865
+ * @param sessionId Session identifier
2866
+ * @returns The session or undefined if not found
2867
+ */
2868
+ getSession(sessionId: string): Promise<Session | undefined>;
2869
+ /**
2870
+ * Updates an existing session
2871
+ * @param session The session to update
2872
+ */
2873
+ updateSession(session: Session): Promise<void>;
2874
+ /**
2875
+ * Lists sessions for a user
2876
+ * @param userId User identifier
2877
+ * @param options Optional filtering options
2878
+ * @returns Array of matching sessions
2879
+ */
2880
+ listSessions(userId: string, options?: ListSessionOptions): Promise<Session[]>;
2881
+ /**
2882
+ * Deletes a session
2883
+ * @param sessionId Session identifier
2884
+ */
2885
+ deleteSession(sessionId: string): Promise<void>;
2886
+ /**
2887
+ * Clears all sessions
2888
+ */
2889
+ clear(): void;
2890
+ /**
2891
+ * Generates a unique session ID
2892
+ * @returns A unique session ID
2893
+ */
2894
+ private generateSessionId;
2895
+ /**
2896
+ * Appends an event to a session object
2897
+ * @param session The session to append the event to
2898
+ * @param event The event to append
2899
+ * @returns The appended event
2900
+ */
2901
+ appendEvent(session: Session, event: Event): Promise<Event>;
2902
+ }
2903
+
2904
+ declare const sessionsSchema$1: drizzle_orm_pg_core.PgTableWithColumns<{
2905
+ name: "sessions";
2906
+ schema: undefined;
2907
+ columns: {
2908
+ id: drizzle_orm_pg_core.PgColumn<{
2909
+ name: "id";
2910
+ tableName: "sessions";
2911
+ dataType: "string";
2912
+ columnType: "PgVarchar";
2913
+ data: string;
2914
+ driverParam: string;
2915
+ notNull: true;
2916
+ hasDefault: false;
2917
+ isPrimaryKey: true;
2918
+ isAutoincrement: false;
2919
+ hasRuntimeDefault: false;
2920
+ enumValues: [string, ...string[]];
2921
+ baseColumn: never;
2922
+ identity: undefined;
2923
+ generated: undefined;
2924
+ }, {}, {
2925
+ length: 255;
2926
+ }>;
2927
+ userId: drizzle_orm_pg_core.PgColumn<{
2928
+ name: "user_id";
2929
+ tableName: "sessions";
2930
+ dataType: "string";
2931
+ columnType: "PgVarchar";
2932
+ data: string;
2933
+ driverParam: string;
2934
+ notNull: true;
2935
+ hasDefault: false;
2936
+ isPrimaryKey: false;
2937
+ isAutoincrement: false;
2938
+ hasRuntimeDefault: false;
2939
+ enumValues: [string, ...string[]];
2940
+ baseColumn: never;
2941
+ identity: undefined;
2942
+ generated: undefined;
2943
+ }, {}, {
2944
+ length: 255;
2945
+ }>;
2946
+ messages: drizzle_orm_pg_core.PgColumn<{
2947
+ name: "messages";
2948
+ tableName: "sessions";
2949
+ dataType: "json";
2950
+ columnType: "PgJsonb";
2951
+ data: Message[];
2952
+ driverParam: unknown;
2953
+ notNull: false;
2954
+ hasDefault: true;
2955
+ isPrimaryKey: false;
2956
+ isAutoincrement: false;
2957
+ hasRuntimeDefault: false;
2958
+ enumValues: undefined;
2959
+ baseColumn: never;
2960
+ identity: undefined;
2961
+ generated: undefined;
2962
+ }, {}, {
2963
+ $type: Message[];
2964
+ }>;
2965
+ metadata: drizzle_orm_pg_core.PgColumn<{
2966
+ name: "metadata";
2967
+ tableName: "sessions";
2968
+ dataType: "json";
2969
+ columnType: "PgJsonb";
2970
+ data: Record<string, any>;
2971
+ driverParam: unknown;
2972
+ notNull: false;
2973
+ hasDefault: true;
2974
+ isPrimaryKey: false;
2975
+ isAutoincrement: false;
2976
+ hasRuntimeDefault: false;
2977
+ enumValues: undefined;
2978
+ baseColumn: never;
2979
+ identity: undefined;
2980
+ generated: undefined;
2981
+ }, {}, {
2982
+ $type: Record<string, any>;
2983
+ }>;
2984
+ createdAt: drizzle_orm_pg_core.PgColumn<{
2985
+ name: "created_at";
2986
+ tableName: "sessions";
2987
+ dataType: "date";
2988
+ columnType: "PgTimestamp";
2989
+ data: Date;
2990
+ driverParam: string;
2991
+ notNull: true;
2992
+ hasDefault: true;
2993
+ isPrimaryKey: false;
2994
+ isAutoincrement: false;
2995
+ hasRuntimeDefault: false;
2996
+ enumValues: undefined;
2997
+ baseColumn: never;
2998
+ identity: undefined;
2999
+ generated: undefined;
3000
+ }, {}, {}>;
3001
+ updatedAt: drizzle_orm_pg_core.PgColumn<{
3002
+ name: "updated_at";
3003
+ tableName: "sessions";
3004
+ dataType: "date";
3005
+ columnType: "PgTimestamp";
3006
+ data: Date;
3007
+ driverParam: string;
3008
+ notNull: true;
3009
+ hasDefault: true;
3010
+ isPrimaryKey: false;
3011
+ isAutoincrement: false;
3012
+ hasRuntimeDefault: false;
3013
+ enumValues: undefined;
3014
+ baseColumn: never;
3015
+ identity: undefined;
3016
+ generated: undefined;
3017
+ }, {}, {}>;
3018
+ state: drizzle_orm_pg_core.PgColumn<{
3019
+ name: "state";
3020
+ tableName: "sessions";
3021
+ dataType: "json";
3022
+ columnType: "PgJsonb";
3023
+ data: Record<string, any>;
3024
+ driverParam: unknown;
3025
+ notNull: false;
3026
+ hasDefault: true;
3027
+ isPrimaryKey: false;
3028
+ isAutoincrement: false;
3029
+ hasRuntimeDefault: false;
3030
+ enumValues: undefined;
3031
+ baseColumn: never;
3032
+ identity: undefined;
3033
+ generated: undefined;
3034
+ }, {}, {
3035
+ $type: Record<string, any>;
3036
+ }>;
3037
+ };
3038
+ dialect: "pg";
3039
+ }>;
3040
+ type SessionsTable$1 = typeof sessionsSchema$1;
3041
+ /**
3042
+ * Configuration for DatabaseSessionService with Drizzle
3043
+ */
3044
+ interface DatabaseSessionServiceConfig$1 {
3045
+ /**
3046
+ * An initialized Drizzle ORM database client instance.
3047
+ * Example: drizzle(new Pool({ connectionString: '...' }), { schema: { sessions: sessionsSchema } })
3048
+ */
3049
+ db: NodePgDatabase<{
3050
+ sessions: SessionsTable$1;
3051
+ }>;
3052
+ /**
3053
+ * Optional: Pass the sessions schema table directly if not attached to db client's schema property
3054
+ */
3055
+ sessionsTable?: SessionsTable$1;
3056
+ }
3057
+ declare class PostgresSessionService implements SessionService {
3058
+ private db;
3059
+ private sessionsTable;
3060
+ constructor(config: DatabaseSessionServiceConfig$1);
3061
+ private generateSessionId;
3062
+ createSession(userId: string, metadata?: Record<string, any>): Promise<Session>;
3063
+ getSession(sessionId: string): Promise<Session | undefined>;
3064
+ updateSession(session: Session): Promise<void>;
3065
+ listSessions(userId: string, options?: ListSessionOptions): Promise<Session[]>;
3066
+ deleteSession(sessionId: string): Promise<void>;
3067
+ /**
3068
+ * Appends an event to a session object
3069
+ * @param session The session to append the event to
3070
+ * @param event The event to append
3071
+ * @returns The appended event
3072
+ */
3073
+ appendEvent(session: Session, event: Event): Promise<Event>;
3074
+ }
3075
+
3076
+ declare const sessionsSchema: drizzle_orm_pg_core.PgTableWithColumns<{
3077
+ name: "sessions";
3078
+ schema: undefined;
3079
+ columns: {
3080
+ id: drizzle_orm_pg_core.PgColumn<{
3081
+ name: "id";
3082
+ tableName: "sessions";
3083
+ dataType: "string";
3084
+ columnType: "PgVarchar";
3085
+ data: string;
3086
+ driverParam: string;
3087
+ notNull: true;
3088
+ hasDefault: false;
3089
+ isPrimaryKey: true;
3090
+ isAutoincrement: false;
3091
+ hasRuntimeDefault: false;
3092
+ enumValues: [string, ...string[]];
3093
+ baseColumn: never;
3094
+ identity: undefined;
3095
+ generated: undefined;
3096
+ }, {}, {
3097
+ length: 255;
3098
+ }>;
3099
+ userId: drizzle_orm_pg_core.PgColumn<{
3100
+ name: "user_id";
3101
+ tableName: "sessions";
3102
+ dataType: "string";
3103
+ columnType: "PgVarchar";
3104
+ data: string;
3105
+ driverParam: string;
3106
+ notNull: true;
3107
+ hasDefault: false;
3108
+ isPrimaryKey: false;
3109
+ isAutoincrement: false;
3110
+ hasRuntimeDefault: false;
3111
+ enumValues: [string, ...string[]];
3112
+ baseColumn: never;
3113
+ identity: undefined;
3114
+ generated: undefined;
3115
+ }, {}, {
3116
+ length: 255;
3117
+ }>;
3118
+ messages: drizzle_orm_pg_core.PgColumn<{
3119
+ name: "messages";
3120
+ tableName: "sessions";
3121
+ dataType: "json";
3122
+ columnType: "PgJsonb";
3123
+ data: Message[];
3124
+ driverParam: unknown;
3125
+ notNull: false;
3126
+ hasDefault: true;
3127
+ isPrimaryKey: false;
3128
+ isAutoincrement: false;
3129
+ hasRuntimeDefault: false;
3130
+ enumValues: undefined;
3131
+ baseColumn: never;
3132
+ identity: undefined;
3133
+ generated: undefined;
3134
+ }, {}, {
3135
+ $type: Message[];
3136
+ }>;
3137
+ metadata: drizzle_orm_pg_core.PgColumn<{
3138
+ name: "metadata";
3139
+ tableName: "sessions";
3140
+ dataType: "json";
3141
+ columnType: "PgJsonb";
3142
+ data: Record<string, any>;
3143
+ driverParam: unknown;
3144
+ notNull: false;
3145
+ hasDefault: true;
3146
+ isPrimaryKey: false;
3147
+ isAutoincrement: false;
3148
+ hasRuntimeDefault: false;
3149
+ enumValues: undefined;
3150
+ baseColumn: never;
3151
+ identity: undefined;
3152
+ generated: undefined;
3153
+ }, {}, {
3154
+ $type: Record<string, any>;
3155
+ }>;
3156
+ createdAt: drizzle_orm_pg_core.PgColumn<{
3157
+ name: "created_at";
3158
+ tableName: "sessions";
3159
+ dataType: "date";
3160
+ columnType: "PgTimestamp";
3161
+ data: Date;
3162
+ driverParam: string;
3163
+ notNull: true;
3164
+ hasDefault: true;
3165
+ isPrimaryKey: false;
3166
+ isAutoincrement: false;
3167
+ hasRuntimeDefault: false;
3168
+ enumValues: undefined;
3169
+ baseColumn: never;
3170
+ identity: undefined;
3171
+ generated: undefined;
3172
+ }, {}, {}>;
3173
+ updatedAt: drizzle_orm_pg_core.PgColumn<{
3174
+ name: "updated_at";
3175
+ tableName: "sessions";
3176
+ dataType: "date";
3177
+ columnType: "PgTimestamp";
3178
+ data: Date;
3179
+ driverParam: string;
3180
+ notNull: true;
3181
+ hasDefault: true;
3182
+ isPrimaryKey: false;
3183
+ isAutoincrement: false;
3184
+ hasRuntimeDefault: false;
3185
+ enumValues: undefined;
3186
+ baseColumn: never;
3187
+ identity: undefined;
3188
+ generated: undefined;
3189
+ }, {}, {}>;
3190
+ state: drizzle_orm_pg_core.PgColumn<{
3191
+ name: "state";
3192
+ tableName: "sessions";
3193
+ dataType: "json";
3194
+ columnType: "PgJsonb";
3195
+ data: Record<string, any>;
3196
+ driverParam: unknown;
3197
+ notNull: false;
3198
+ hasDefault: true;
3199
+ isPrimaryKey: false;
3200
+ isAutoincrement: false;
3201
+ hasRuntimeDefault: false;
3202
+ enumValues: undefined;
3203
+ baseColumn: never;
3204
+ identity: undefined;
3205
+ generated: undefined;
3206
+ }, {}, {
3207
+ $type: Record<string, any>;
3208
+ }>;
3209
+ };
3210
+ dialect: "pg";
3211
+ }>;
3212
+ type SessionsTable = typeof sessionsSchema;
3213
+ /**
3214
+ * Configuration for DatabaseSessionService with Drizzle and PGlite
3215
+ */
3216
+ interface DatabaseSessionServiceConfig {
3217
+ /**
3218
+ * An initialized Drizzle ORM database client instance with PGlite.
3219
+ * Example: drizzle(new PGlite(), { schema: { sessions: sessionsSchema } })
3220
+ */
3221
+ db: PgliteDatabase<{
3222
+ sessions: SessionsTable;
3223
+ }>;
3224
+ /**
3225
+ * Optional: Pass the sessions schema table directly if not attached to db client's schema property
3226
+ */
3227
+ sessionsTable?: SessionsTable;
3228
+ /**
3229
+ * Optional: Skip automatic table creation if you handle migrations externally
3230
+ */
3231
+ skipTableCreation?: boolean;
3232
+ }
3233
+ declare class PgLiteSessionService implements SessionService {
3234
+ private db;
3235
+ private sessionsTable;
3236
+ private initialized;
3237
+ constructor(config: DatabaseSessionServiceConfig);
3238
+ /**
3239
+ * Initialize the database by creating required tables if they don't exist
3240
+ */
3241
+ private initializeDatabase;
3242
+ /**
3243
+ * Ensure database is initialized before any operation
3244
+ */
3245
+ private ensureInitialized;
3246
+ private generateSessionId;
3247
+ createSession(userId: string, metadata?: Record<string, any>): Promise<Session>;
3248
+ getSession(sessionId: string): Promise<Session | undefined>;
3249
+ updateSession(session: Session): Promise<void>;
3250
+ listSessions(userId: string, options?: ListSessionOptions): Promise<Session[]>;
3251
+ deleteSession(sessionId: string): Promise<void>;
3252
+ /**
3253
+ * Appends an event to a session object
3254
+ * @param session The session to append the event to
3255
+ * @param event The event to append
3256
+ * @returns The appended event
3257
+ */
3258
+ appendEvent(session: Session, event: Event): Promise<Event>;
3259
+ }
3260
+
3261
+ /**
3262
+ * Utility functions for working with sessions
3263
+ */
3264
+
3265
+ /**
3266
+ * Generates a unique session ID
3267
+ * @returns A unique session ID
3268
+ */
3269
+ declare function generateSessionId(): string;
3270
+ /**
3271
+ * Validates a session object
3272
+ * @param session The session to validate
3273
+ * @throws Error if session is invalid
3274
+ */
3275
+ declare function validateSession(session: Session): void;
3276
+ /**
3277
+ * Deep clones a session object
3278
+ * @param session The session to clone
3279
+ * @returns A deep clone of the session
3280
+ */
3281
+ declare function cloneSession(session: Session): Session;
3282
+
3283
+ /**
3284
+ * Sessions module exports
3285
+ */
3286
+
3287
+ type index_InMemorySessionService = InMemorySessionService;
3288
+ declare const index_InMemorySessionService: typeof InMemorySessionService;
3289
+ type index_ListSessionOptions = ListSessionOptions;
3290
+ type index_PgLiteSessionService = PgLiteSessionService;
3291
+ declare const index_PgLiteSessionService: typeof PgLiteSessionService;
3292
+ type index_PostgresSessionService = PostgresSessionService;
3293
+ declare const index_PostgresSessionService: typeof PostgresSessionService;
3294
+ type index_Session = Session;
3295
+ type index_SessionService = SessionService;
3296
+ type index_SessionState = SessionState;
3297
+ declare const index_SessionState: typeof SessionState;
3298
+ declare const index_cloneSession: typeof cloneSession;
3299
+ declare const index_generateSessionId: typeof generateSessionId;
3300
+ declare const index_validateSession: typeof validateSession;
3301
+ declare namespace index {
3302
+ export { index_InMemorySessionService as InMemorySessionService, type index_ListSessionOptions as ListSessionOptions, index_PgLiteSessionService as PgLiteSessionService, index_PostgresSessionService as PostgresSessionService, type index_Session as Session, type index_SessionService as SessionService, index_SessionState as SessionState, index_cloneSession as cloneSession, index_generateSessionId as generateSessionId, index_validateSession as validateSession };
3303
+ }
3304
+
3305
+ /**
3306
+ * The Runner class is used to run agents.
3307
+ * It manages the execution of an agent within a session, handling message
3308
+ * processing, event generation, and interaction with various services.
3309
+ */
3310
+ declare class Runner {
3311
+ /**
3312
+ * The app name of the runner.
3313
+ */
3314
+ appName: string;
3315
+ /**
3316
+ * The root agent to run.
3317
+ */
3318
+ agent: BaseAgent;
3319
+ /**
3320
+ * The session service for the runner.
3321
+ */
3322
+ sessionService: SessionService;
3323
+ /**
3324
+ * The memory service for the runner.
3325
+ */
3326
+ memoryService?: BaseMemoryService;
3327
+ /**
3328
+ * Initializes the Runner.
3329
+ */
3330
+ constructor({ appName, agent, sessionService, memoryService, }: {
3331
+ appName: string;
3332
+ agent: BaseAgent;
3333
+ sessionService: SessionService;
3334
+ memoryService?: BaseMemoryService;
3335
+ });
3336
+ /**
3337
+ * Main entry method to run the agent in this runner.
3338
+ */
3339
+ runAsync({ userId, sessionId, newMessage, runConfig, }: {
3340
+ userId: string;
3341
+ sessionId: string;
3342
+ newMessage: Message;
3343
+ runConfig?: RunConfig;
3344
+ }): AsyncGenerator<Event, void, unknown>;
3345
+ /**
3346
+ * Appends a new message to the session.
3347
+ */
3348
+ private _appendNewMessageToSession;
3349
+ /**
3350
+ * Creates a new invocation context.
3351
+ */
3352
+ private _newInvocationContext;
3353
+ }
3354
+ /**
3355
+ * An in-memory Runner for testing and development.
3356
+ */
3357
+ declare class InMemoryRunner extends Runner {
3358
+ /**
3359
+ * Initializes the InMemoryRunner.
3360
+ */
3361
+ constructor(agent: BaseAgent, { appName }?: {
3362
+ appName?: string;
3363
+ });
3364
+ }
3365
+
3366
+ declare const VERSION = "0.1.0";
3367
+
3368
+ export { Agent, type AgentConfig, index$3 as Agents, AnthropicLLM, type AnthropicLLMConfig, AnthropicLLMConnection, ApiKeyCredential, ApiKeyScheme, type AudioTranscriptionConfig, AuthConfig, AuthCredential, AuthCredentialType, AuthHandler, AuthScheme, AuthSchemeType, BaseAgent, BaseLLM, BaseLLMConnection, type BaseMemoryService, BaseTool, BasicAuthCredential, BearerTokenCredential, type BuildFunctionDeclarationOptions, ExitLoopTool, FileOperationsTool, type FunctionCall, type FunctionDeclaration, FunctionTool, GetUserChoiceTool, GoogleLLM, type GoogleLLMConfig, GoogleSearch, HttpRequestTool, HttpScheme, type IToolContext, type ImageContent, InMemoryMemoryService, InMemoryRunner, InMemorySessionService, InvocationContext, type JSONSchema, LLMRegistry, LLMRequest, type LLMRequestConfig, LLMResponse, LangGraphAgent, type LangGraphAgentConfig, type LangGraphNode, type ListSessionOptions, LoadMemoryTool, LoopAgent, type LoopAgentConfig, index$1 as Memory, type MemoryResult, type Message, type MessageContent, type MessageRole, index$4 as Models, OAuth2Credential, OAuth2Scheme, type OAuthFlow, type OAuthFlows, OpenAILLM, type OpenAILLMConfig, OpenAILLMConnection, OpenIdConnectScheme, ParallelAgent, type ParallelAgentConfig, PersistentMemoryService, PgLiteSessionService, PostgresSessionService, RunConfig, Runner, type SearchMemoryOptions, type SearchMemoryResponse, SequentialAgent, type SequentialAgentConfig, type Session, type SessionService, SessionState, index as Sessions, type SpeechConfig, StreamingMode, type TextContent, type ToolCall, type ToolConfig, ToolContext, index$2 as Tools, TransferToAgentTool, UserInteractionTool, VERSION, buildFunctionDeclaration, cloneSession, createFunctionTool, generateSessionId, registerProviders, validateSession };