booths 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,917 @@
1
+ import { ChatCompletionMessageParam } from 'openai/resources/chat/completions';
2
+ import { EasyInputMessage } from 'openai/resources/responses/responses';
3
+ import { FunctionTool } from 'openai/resources/responses/responses';
4
+ import { Metadata } from 'openai/resources/shared.mjs';
5
+ import { Reasoning } from 'openai/resources/shared.mjs';
6
+ import { Response as Response_2 } from 'openai/resources/responses/responses';
7
+ import { ResponseCodeInterpreterToolCall } from 'openai/resources/responses/responses';
8
+ import { ResponseComputerToolCall } from 'openai/resources/responses/responses';
9
+ import { ResponseCreateParamsNonStreaming } from 'openai/resources/responses/responses';
10
+ import { ResponseFileSearchToolCall } from 'openai/resources/responses/responses';
11
+ import { ResponseFunctionToolCall } from 'openai/resources/responses/responses';
12
+ import { ResponseFunctionWebSearch } from 'openai/resources/responses/responses';
13
+ import { ResponseIncludable } from 'openai/resources/responses/responses';
14
+ import { ResponseInput } from 'openai/resources/responses/responses';
15
+ import { ResponseInputItem } from 'openai/resources/responses/responses';
16
+ import { ResponseOutputMessage } from 'openai/resources/responses/responses';
17
+ import { ResponsePrompt } from 'openai/resources/responses/responses';
18
+ import { ResponseReasoningItem } from 'openai/resources/responses/responses';
19
+ import { ResponsesModel } from 'openai/resources/shared.mjs';
20
+ import { ResponseTextConfig } from 'openai/resources/responses/responses';
21
+ import { Tool } from 'openai/resources/responses/responses';
22
+ import { ToolChoiceFunction } from 'openai/resources/responses/responses';
23
+ import { ToolChoiceOptions } from 'openai/resources/responses/responses';
24
+ import { ToolChoiceTypes } from 'openai/resources/responses/responses';
25
+
26
+ /**
27
+ * Defines the configuration for a booth. Each booth must have a unique ID,
28
+ * a defined role, and a set of capabilities.
29
+ */
30
+ export declare interface BoothConfig {
31
+ /** A unique identifier for the booth. */
32
+ id: string;
33
+ /** The role or persona of the booth (e.g., "Customer Support Agent"). */
34
+ role: string;
35
+ /** A description of the booth's purpose and capabilities. */
36
+ description: string;
37
+ /** The developer or team responsible for the booth. */
38
+ developer?: string;
39
+ /** A list of tool names that this booth is authorized to use. */
40
+ tools: string[];
41
+ /**
42
+ * A list of tools in the format expected by the Multi-Category Peppercorn (MCP) system.
43
+ * This is likely for more complex tool definitions.
44
+ */
45
+ mcp?: Tool[];
46
+ /** An optional flow definition for orchestrating complex, multi-step behaviors. */
47
+ flow?: string;
48
+ /**
49
+ * Specifies the formatting rules and provides examples for the booth's responses.
50
+ * This can help ensure consistent and parsable output.
51
+ */
52
+ responseFormat?: string;
53
+ /** A list of example queries or inputs that the booth is designed to handle. */
54
+ examples: string[];
55
+ /**
56
+ * Defines fallback behavior for when the booth receives a query that is out of scope.
57
+ */
58
+ fallback?: {
59
+ /**
60
+ * Specifies the action to take when the booth is out of scope.
61
+ * Currently, the only supported action is to route to another booth.
62
+ */
63
+ onOutOfScope: {
64
+ action: 'route_to_booth';
65
+ target: string;
66
+ };
67
+ };
68
+ }
69
+
70
+ /**
71
+ * Defines the structure of a booth plugin, which can hook into various stages
72
+ * of the interaction lifecycle to extend or modify the behavior of the booth engine.
73
+ */
74
+ export declare interface BoothPlugin {
75
+ /** A unique identifier for the plugin. */
76
+ id: string;
77
+ /** The name of the plugin. */
78
+ name: string;
79
+ /** A description of what the plugin does. */
80
+ description: string;
81
+ /**
82
+ * Called before the interaction loop starts. This can be used for setup tasks
83
+ * or to modify the initial request parameters.
84
+ * @param prepareInitialMessagesArgs - Utilities for accessing repositories.
85
+ * @param responseParams - The initial parameters for the response creation.
86
+ * @returns The potentially modified response parameters.
87
+ */
88
+ onBeforeInteractionLoopStart?: (prepareInitialMessagesArgs: RepositoryUtilities, responseParams: ResponseCreateParamsNonStreaming, initialInput: string) => Promise<ResponseCreateParamsNonStreaming>;
89
+ /**
90
+ * Called before a message is sent to the AI. This allows for modification
91
+ * of the message or its parameters.
92
+ * @param prepareInitialMessagesArgs - Utilities for accessing repositories.
93
+ * @param responseParams - The parameters for the response creation.
94
+ * @returns The potentially modified response parameters.
95
+ */
96
+ onBeforeMessageSend?: (prepareInitialMessagesArgs: RepositoryUtilities, responseParams: ResponseCreateParamsNonStreaming) => Promise<ResponseCreateParamsNonStreaming>;
97
+ /**
98
+ * Called after a response is received from the AI. This can be used to process
99
+ * the response or to decide on further actions.
100
+ * @param messageReceivedArgs - Utilities for accessing repositories.
101
+ * @param responseParams - The parameters used for the response creation.
102
+ * @param response - The response received from the AI.
103
+ * @returns The potentially modified response parameters.
104
+ */
105
+ onResponseReceived?: (messageReceivedArgs: RepositoryUtilities, responseParams: ResponseCreateParamsNonStreaming, response: Response_2) => Promise<ResponseCreateParamsNonStreaming>;
106
+ /**
107
+ * Called before an individual tool call is executed. This allows for modification
108
+ * of the tool call parameters or early termination.
109
+ * @param utilities - Utilities for accessing repositories.
110
+ * @param toolCall - The tool call that is about to be executed.
111
+ * @param context - Context information about the tool call execution.
112
+ * @returns The potentially modified tool call.
113
+ */
114
+ onBeforeToolCall?: (utilities: RepositoryUtilities, toolCall: ResponseFunctionToolCall, context: ToolCallContext) => Promise<ResponseFunctionToolCall>;
115
+ /**
116
+ * Called after an individual tool call is successfully executed. This allows for
117
+ * processing or modifying the tool call result.
118
+ * @param utilities - Utilities for accessing repositories.
119
+ * @param toolCall - The tool call that was executed.
120
+ * @param result - The result returned by the tool execution.
121
+ * @param context - Context information about the tool call execution.
122
+ * @returns The potentially modified tool call result.
123
+ */
124
+ onAfterToolCall?: (utilities: RepositoryUtilities, toolCall: ResponseFunctionToolCall, result: any, context: ToolCallContext) => Promise<any>;
125
+ /**
126
+ * Called when an individual tool call encounters an error during execution.
127
+ * This allows for custom error handling or recovery.
128
+ * @param utilities - Utilities for accessing repositories.
129
+ * @param toolCall - The tool call that failed.
130
+ * @param error - The error that occurred during tool execution.
131
+ * @param context - Context information about the tool call execution.
132
+ * @returns The error result or a recovery value to use instead.
133
+ */
134
+ onToolCallError?: (utilities: RepositoryUtilities, toolCall: ResponseFunctionToolCall, error: Error, context: ToolCallContext) => Promise<any>;
135
+ /**
136
+ * Determines whether the interaction loop should end. This is a mandatory method
137
+ * for all plugins.
138
+ * @param prepareInitialMessagesArgs - Utilities for accessing repositories.
139
+ * @param responseParams - The parameters for the response creation.
140
+ * @param response - The latest response from the AI.
141
+ * @returns A boolean indicating whether to end the interaction loop.
142
+ */
143
+ shouldEndInteractionLoop: (prepareInitialMessagesArgs: RepositoryUtilities, responseParams: ResponseCreateParamsNonStreaming, response: Response_2) => Promise<boolean>;
144
+ /**
145
+ * Called after the interaction loop has ended. This can be used for cleanup
146
+ * or to perform final actions.
147
+ * @param interactionLoopEndArgs - Utilities for accessing repositories.
148
+ * @param response - The final response from the AI.
149
+ * @returns The potentially modified final response.
150
+ */
151
+ onAfterInteractionLoopEnd?: (interactionLoopEndArgs: RepositoryUtilities, response: Response_2) => Promise<Response_2>;
152
+ }
153
+
154
+ /**
155
+ * The BoothPluginRegistry manages the collection of plugins within the booth system.
156
+ *
157
+ * This registry is responsible for maintaining the set of available plugins, providing
158
+ * methods for registering, retrieving, and managing plugins. It also orchestrates the
159
+ * execution of plugin hooks at various stages of the interaction lifecycle.
160
+ */
161
+ export declare class BoothPluginRegistry {
162
+ /**
163
+ * Collection of registered plugins.
164
+ * @private
165
+ */
166
+ private plugins;
167
+ /**
168
+ * Registers a single plugin in the registry.
169
+ * Throws an error if a plugin with the same ID already exists.
170
+ *
171
+ * @param plugin - The plugin instance to register
172
+ */
173
+ registerPlugin(plugin: BoothPlugin): void;
174
+ /**
175
+ * Returns all registered plugins.
176
+ *
177
+ * @returns Array of registered plugin instances
178
+ */
179
+ getPlugins(): BoothPlugin[];
180
+ /**
181
+ * Registers multiple plugins at once.
182
+ *
183
+ * @param plugins - Array of plugin instances to register
184
+ */
185
+ registerPlugins(plugins: BoothPlugin[]): void;
186
+ /**
187
+ * Finds and returns a plugin by its ID.
188
+ *
189
+ * @param pluginId - The unique identifier of the plugin to retrieve
190
+ * @returns The plugin instance if found, undefined otherwise
191
+ */
192
+ getPluginById(pluginId: string): BoothPlugin | undefined;
193
+ /**
194
+ * Removes a plugin from the registry by its ID.
195
+ * Throws an error if the plugin doesn't exist.
196
+ *
197
+ * @param pluginId - The unique identifier of the plugin to remove
198
+ */
199
+ unregisterPlugin(pluginId: string): void;
200
+ /**
201
+ * Sequentially invokes every plugin's onBeforeInteractionLoopStart hook.
202
+ * Each plugin receives the accumulated response parameters from previous plugins,
203
+ * allowing them to build upon each other's modifications.
204
+ *
205
+ * @param prepareArgs - Context information including booth registry and current booth ID
206
+ * @param initialParams - Initial response parameters to be modified by plugins
207
+ * @param initialInput
208
+ * @returns Modified response parameters after all plugins have processed them
209
+ */
210
+ runBeforeInteractionLoopStart(prepareArgs: RepositoryUtilities, initialParams: ResponseCreateParamsNonStreaming, initialInput: string): Promise<ResponseCreateParamsNonStreaming>;
211
+ /**
212
+ * Sequentially invokes every plugin's onBeforeMessageSend hook.
213
+ * This is called immediately before sending a message to the LLM,
214
+ * allowing plugins to modify the request parameters.
215
+ *
216
+ * @param prepareArgs - Context information including booth registry and current booth ID
217
+ * @param initialParams - Response parameters to be modified before sending to LLM
218
+ * @returns Modified response parameters after all plugins have processed them
219
+ */
220
+ runBeforeMessageSend(prepareArgs: RepositoryUtilities, initialParams: ResponseCreateParamsNonStreaming): Promise<ResponseCreateParamsNonStreaming>;
221
+ /**
222
+ * Sequentially invokes every plugin's onResponseReceived hook.
223
+ * This is called after receiving a response from the LLM,
224
+ * allowing plugins to process or modify the response.
225
+ *
226
+ * @param messageArgs - Context information including the LLM response, booth registry, and current booth ID
227
+ * @param initialParams - Response parameters to be potentially modified based on the received response
228
+ * @param response - The actual response received from the LLM
229
+ * @returns Modified response parameters after all plugins have processed them
230
+ */
231
+ runResponseReceived(messageArgs: RepositoryUtilities, initialParams: ResponseCreateParamsNonStreaming, response: Response_2): Promise<ResponseCreateParamsNonStreaming>;
232
+ /**
233
+ * Checks if any plugin wants to end the interaction loop.
234
+ * Returns true as soon as any plugin indicates the loop should end.
235
+ *
236
+ * @param prepareArgs - Context information including booth registry and current booth ID
237
+ * @param responseParams - Current response parameters
238
+ * @param response - The response received from the LLM
239
+ * @returns True if any plugin indicates the loop should end, false otherwise
240
+ */
241
+ runShouldEndInteractionLoop(prepareArgs: RepositoryUtilities, responseParams: ResponseCreateParamsNonStreaming, response: Response_2): Promise<boolean>;
242
+ /**
243
+ * Sequentially invokes every plugin's onAfterInteractionLoopEnd hook.
244
+ * This is called when the interaction loop has completed,
245
+ * allowing plugins to perform cleanup or final processing.
246
+ *
247
+ * @param endArgs - Context information including booth registry and current booth ID
248
+ * @param finalResponse - The final response from the LLM
249
+ */
250
+ runAfterInteractionLoopEnd(endArgs: RepositoryUtilities, finalResponse: Response_2): Promise<Response_2>;
251
+ /**
252
+ * Sequentially invokes every plugin's onBeforeToolCall hook.
253
+ * This is called before executing an individual tool call,
254
+ * allowing plugins to modify the tool call parameters.
255
+ *
256
+ * @param utilities - Context information including booth and tool registries
257
+ * @param toolCall - The tool call that is about to be executed
258
+ * @param context - Context information about the tool call execution
259
+ * @returns Modified tool call after all plugins have processed it
260
+ */
261
+ runBeforeToolCall(utilities: RepositoryUtilities, toolCall: ResponseFunctionToolCall, context: ToolCallContext): Promise<ResponseFunctionToolCall>;
262
+ /**
263
+ * Sequentially invokes every plugin's onAfterToolCall hook.
264
+ * This is called after successfully executing an individual tool call,
265
+ * allowing plugins to process or modify the tool call result.
266
+ *
267
+ * @param utilities - Context information including booth and tool registries
268
+ * @param toolCall - The tool call that was executed
269
+ * @param result - The result returned by the tool execution
270
+ * @param context - Context information about the tool call execution
271
+ * @returns Modified result after all plugins have processed it
272
+ */
273
+ runAfterToolCall(utilities: RepositoryUtilities, toolCall: ResponseFunctionToolCall, result: any, context: ToolCallContext): Promise<any>;
274
+ /**
275
+ * Sequentially invokes every plugin's onToolCallError hook.
276
+ * This is called when an individual tool call encounters an error during execution,
277
+ * allowing plugins to handle or recover from the error.
278
+ *
279
+ * @param utilities - Context information including booth and tool registries
280
+ * @param toolCall - The tool call that failed
281
+ * @param error - The error that occurred during tool execution
282
+ * @param context - Context information about the tool call execution
283
+ * @returns Error result or recovery value after all plugins have processed it
284
+ */
285
+ runToolCallError(utilities: RepositoryUtilities, toolCall: ResponseFunctionToolCall, error: Error, context: ToolCallContext): Promise<any>;
286
+ }
287
+
288
+ /**
289
+ * The BoothRegistry manages the collection of booth configurations within the system.
290
+ *
291
+ * This registry maintains a catalog of available booths and provides methods for
292
+ * registering, retrieving, and managing booth configurations. It also maintains
293
+ * a reference to the base booth configuration that all other booths extend from.
294
+ */
295
+ export declare class BoothRegistry {
296
+ private baseBooth;
297
+ /**
298
+ * Collection of registered booth configurations, indexed by their IDs.
299
+ * @private
300
+ */
301
+ private booths;
302
+ /**
303
+ * The current context booth ID, defaulting to the orchestrator context.
304
+ * @private
305
+ */
306
+ private currentContextId;
307
+ /**
308
+ * Creates a new booth registry with a specified base booth configuration.
309
+ *
310
+ * @param baseBooth - The base booth configuration that all other booths extend from
311
+ * @param currentContextId - The initial current context booth ID (default is 'orchestrator')
312
+ */
313
+ constructor(baseBooth: BoothConfig, currentContextId?: string);
314
+ /**
315
+ * Gets the current context booth ID.
316
+ *
317
+ * @returns The current context ID.
318
+ */
319
+ getCurrentContextId(): string;
320
+ /**
321
+ * Sets the current context booth ID.
322
+ * Throws an error if the provided ID is not registered.
323
+ *
324
+ * @param contextId - The booth ID to set as current context.
325
+ */
326
+ setCurrentContextId(contextId: string): void;
327
+ /**
328
+ * Returns the current context booth configuration.
329
+ * Throws an error if the current context booth is not registered.
330
+ *
331
+ * @returns The current context booth configuration.
332
+ */
333
+ get currentContextBoothConfig(): BoothConfig;
334
+ /**
335
+ * Registers a single booth configuration in the registry.
336
+ * Throws an error if a booth with the same ID already exists.
337
+ *
338
+ * @param boothConfig - The booth configuration to register
339
+ */
340
+ registerBooth(boothConfig: BoothConfig): void;
341
+ /**
342
+ * Returns the base booth configuration that was provided during initialization.
343
+ * This configuration serves as the foundation for all booth interactions.
344
+ *
345
+ * @returns The base booth configuration
346
+ */
347
+ get baseBoothConfig(): BoothConfig;
348
+ /**
349
+ * Returns the orchestrator booth configuration.
350
+ * The orchestrator booth is responsible for managing booth routing and coordination.
351
+ * Throws an error if the orchestrator booth is not registered.
352
+ *
353
+ * @returns The orchestrator booth configuration
354
+ */
355
+ get orchestratorBoothConfig(): BoothConfig;
356
+ /**
357
+ * Registers multiple booth configurations at once.
358
+ *
359
+ * @param boothConfigs - Array of booth configurations to register
360
+ */
361
+ registerBooths(boothConfigs: BoothConfig[]): void;
362
+ /**
363
+ * Finds and returns a booth configuration by its ID.
364
+ *
365
+ * @param boothId - The unique identifier of the booth to retrieve
366
+ * @returns The booth configuration if found, undefined otherwise
367
+ */
368
+ getBoothById(boothId: string): BoothConfig | undefined;
369
+ /**
370
+ * Returns all registered booth configurations.
371
+ *
372
+ * @returns Record of all booth configurations indexed by their IDs
373
+ */
374
+ getAllBooths(): Record<string, BoothConfig>;
375
+ /**
376
+ * Removes a booth configuration from the registry by its ID.
377
+ * Throws an error if the booth doesn't exist.
378
+ *
379
+ * @param boothId - The unique identifier of the booth to remove
380
+ */
381
+ unregisterBooth(boothId: string): void;
382
+ }
383
+
384
+ /**
385
+ * The ContextProviderPlugin provides contextual information to booths during interaction loops.
386
+ *
387
+ * This plugin enriches the interaction by adding booth-specific context from both the base booth
388
+ * and the current context booth. It ensures that LLM responses are appropriately informed by
389
+ * the specific booth context the user is interacting with.
390
+ */
391
+ export declare class ContextProviderPlugin implements BoothPlugin {
392
+ /**
393
+ * Unique identifier for this plugin instance.
394
+ * @private
395
+ */
396
+ private readonly plugin_id;
397
+ /**
398
+ * Display the name for this plugin.
399
+ * @private
400
+ */
401
+ private readonly plugin_name;
402
+ /**
403
+ * Brief description of the plugin's purpose and functionality.
404
+ * @private
405
+ */
406
+ private readonly plugin_description;
407
+ /**
408
+ * Returns the plugin's unique identifier.
409
+ */
410
+ get id(): string;
411
+ /**
412
+ * Returns the plugin's display name.
413
+ */
414
+ get name(): string;
415
+ /**
416
+ * Returns the plugin's description.
417
+ */
418
+ get description(): string;
419
+ /**
420
+ * Executes before the interaction loop starts, adding context from both the base booth
421
+ * and the current context booth to the response parameters.
422
+ *
423
+ * @param prepareInitialMessagesArgs - Object containing the booth registry and current context booth ID
424
+ * @param responseParams - Current parameters for the LLM response creation
425
+ * @returns Updated response parameters with added instructions containing booth context
426
+ */
427
+ onBeforeMessageSend(prepareInitialMessagesArgs: RepositoryUtilities, responseParams: ResponseCreateParamsNonStreaming): Promise<ResponseCreateParamsNonStreaming>;
428
+ /**
429
+ * Determines whether the interaction loop should end.
430
+ * This implementation always returns false, indicating the loop should continue.
431
+ *
432
+ * @returns A promise resolving to false, indicating the interaction should continue
433
+ */
434
+ shouldEndInteractionLoop(): Promise<boolean>;
435
+ }
436
+
437
+ /**
438
+ * The ConversationHistoryPlugin manages the conversation history between users and the booth system.
439
+ *
440
+ * This plugin is responsible for maintaining a continuous conversation context by tracking
441
+ * and preserving all messages exchanged between the user and the LLM. It ensures that each new
442
+ * interaction has access to the full conversation history, enabling contextual responses.
443
+ */
444
+ export declare class ConversationHistoryPlugin implements BoothPlugin {
445
+ /**
446
+ * Unique identifier for this plugin instance.
447
+ * @private
448
+ */
449
+ private readonly plugin_id;
450
+ /**
451
+ * Display name for this plugin.
452
+ * @private
453
+ */
454
+ private readonly plugin_name;
455
+ /**
456
+ * Brief description of the plugin's purpose and functionality.
457
+ * @private
458
+ */
459
+ private readonly plugin_description;
460
+ /**
461
+ * Returns the plugin's unique identifier.
462
+ */
463
+ get id(): string;
464
+ /**
465
+ * Returns the plugin's display name.
466
+ */
467
+ get name(): string;
468
+ /**
469
+ * Returns the plugin's description.
470
+ */
471
+ get description(): string;
472
+ /**
473
+ * Executes before the interaction loop starts, adding the current user input to the
474
+ * conversation history and updating the response parameters with the complete history.
475
+ *
476
+ * @param _ - Object containing the booth registry and context booth ID (unused in this method)
477
+ * @param responseParams - Current parameters for the LLM response creation
478
+ * @returns Updated response parameters with the complete conversation history
479
+ */
480
+ onBeforeInteractionLoopStart(_: RepositoryUtilities, responseParams: ResponseCreateParamsNonStreaming): Promise<ResponseCreateParamsNonStreaming>;
481
+ /**
482
+ * Executes after receiving a response from the LLM, adding the response content
483
+ * to the conversation history for future reference.
484
+ *
485
+ * @param _
486
+ * @param responseParams - Current parameters for the LLM response creation
487
+ * @param response
488
+ * @returns Unmodified response parameters
489
+ */
490
+ onResponseReceived(_: RepositoryUtilities, responseParams: ResponseCreateParamsNonStreaming, response: Response_2): Promise<{
491
+ input: ( ResponseFunctionToolCall | EasyInputMessage | ResponseOutputMessage | ResponseFileSearchToolCall | ResponseComputerToolCall | ResponseInputItem.ComputerCallOutput | ResponseFunctionWebSearch | ResponseInputItem.FunctionCallOutput | ResponseReasoningItem | ResponseInputItem.ImageGenerationCall | ResponseCodeInterpreterToolCall | ResponseInputItem.LocalShellCall | ResponseInputItem.LocalShellCallOutput | ResponseInputItem.McpListTools | ResponseInputItem.McpApprovalRequest | ResponseInputItem.McpApprovalResponse | ResponseInputItem.McpCall | ResponseInputItem.ItemReference)[];
492
+ stream?: false | null;
493
+ background?: boolean | null;
494
+ include?: Array< ResponseIncludable> | null;
495
+ instructions?: string | null;
496
+ max_output_tokens?: number | null;
497
+ metadata?: Metadata | null;
498
+ model?: ResponsesModel;
499
+ parallel_tool_calls?: boolean | null;
500
+ previous_response_id?: string | null;
501
+ prompt?: ResponsePrompt | null;
502
+ reasoning?: Reasoning | null;
503
+ service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
504
+ store?: boolean | null;
505
+ temperature?: number | null;
506
+ text?: ResponseTextConfig;
507
+ tool_choice?: ToolChoiceOptions | ToolChoiceTypes | ToolChoiceFunction;
508
+ tools?: Array< Tool>;
509
+ top_p?: number | null;
510
+ truncation?: "auto" | "disabled" | null;
511
+ user?: string;
512
+ }>;
513
+ /**
514
+ * Determines whether the interaction loop should end.
515
+ * This implementation always returns false, indicating the loop should continue.
516
+ *
517
+ * @returns A promise resolving to false, indicating the interaction should continue
518
+ */
519
+ shouldEndInteractionLoop(): Promise<boolean>;
520
+ }
521
+
522
+ /**
523
+ * CoreBooth is a class that serves as the central manager for a booth system,
524
+ * handling the integration of plugins, the registration of booth instances,
525
+ * and the processing of interactions using the configured plugins.
526
+ */
527
+ export declare class CoreBooth<T> {
528
+ /**
529
+ * Represents a registry that maintains a collection of plugins for a booth system.
530
+ * The boothPluginRegistry is used to manage and access plugins that enhance
531
+ * or extend the booth's behavior or features.
532
+ *
533
+ * This variable is intended to provide a central location for plugin registration,
534
+ * retrieval, and management.
535
+ *
536
+ * @type {BoothPluginRegistry}
537
+ */
538
+ private boothPluginRegistry;
539
+ /**
540
+ * Registry for managing booth configurations across the system.
541
+ * This registry maintains a collection of booth definitions that can be
542
+ * accessed by their unique identifiers.
543
+ *
544
+ * @type {BoothRegistry}
545
+ */
546
+ private readonly boothRegistry;
547
+ /**
548
+ * Primary processor for handling interactions between users and the booth system.
549
+ * Responsible for sending messages to the LLM, processing responses, and managing
550
+ * the interaction loop through plugins.
551
+ *
552
+ * @type {InteractionProcessor}
553
+ */
554
+ callProcessor: InteractionProcessor<T>;
555
+ /**
556
+ * Registry dedicated to system-level plugins that are always available.
557
+ * This includes core functionality plugins like conversation history and context providers,
558
+ * as well as any user-defined plugins from the boothPluginRegistry.
559
+ *
560
+ * @type {BoothPluginRegistry}
561
+ */
562
+ private readonly systemPluginsRegistry;
563
+ /**
564
+ * A variable that represents a registry for managing and maintaining a collection of tools.
565
+ * `toolRegistry` is an instance of the `ToolRegistry` class, which provides functionalities
566
+ * for adding, removing, and retrieving tools.
567
+ *
568
+ * The `ToolRegistry` class typically serves as a centralized storage or management
569
+ * solution for tools that are used in a specific context or application.
570
+ */
571
+ private readonly toolRegistry;
572
+ /**
573
+ * Initializes a new instance of the CoreBooth class.
574
+ * Sets up the plugin registries, system plugins, and interaction processor.
575
+ *
576
+ * @param {Object} options - Configuration options for the CoreBooth
577
+ * @param {BoothPluginRegistry} options.boothPlugins - Registry containing user-defined plugins
578
+ * @param {BoothRegistry} options.booths - Registry containing booth configurations
579
+ * @param {ToolRegistry} options.tools - Registry containing tool configurations
580
+ */
581
+ constructor(options: {
582
+ boothPlugins: BoothPluginRegistry;
583
+ booths: BoothRegistry;
584
+ tools: ToolRegistry;
585
+ llmAdapter: LLMAdapter<T>;
586
+ });
587
+ }
588
+
589
+ /**
590
+ * Creates a `route_to_booth` tool module that can be used by the LLM to switch the conversation
591
+ * context to a different booth. The tool's definition is dynamically generated based on the
592
+ * available booths in the provided `boothRegistry`.
593
+ *
594
+ * @param boothRegistry - The registry containing all available booth configurations.
595
+ * @returns A `ToolModule` definition for the `route_to_booth` tool.
596
+ */
597
+ export declare function createRouteToBoothTool(boothRegistry: BoothRegistry): ToolModule;
598
+
599
+ /**
600
+ * The FinishTurnPlugin manages the end of a conversational turn by checking for a specific marker
601
+ * in the LLM's response. It also cleans up this marker before the final output is returned.
602
+ */
603
+ export declare class FinishTurnPlugin implements BoothPlugin {
604
+ description: string;
605
+ id: string;
606
+ name: string;
607
+ /**
608
+ * Before sending a message, this hook adds an instruction to the LLM to include a
609
+ * specific marker (`__awaiting_user_response__`) when it expects a user response.
610
+ * @param _ - Unused repository utilities.
611
+ * @param responseParams - The parameters for the response creation.
612
+ * @returns The updated response parameters with the added instruction.
613
+ */
614
+ onBeforeMessageSend(_: RepositoryUtilities, responseParams: ResponseCreateParamsNonStreaming): Promise<{
615
+ instructions: string;
616
+ stream?: false | null;
617
+ background?: boolean | null;
618
+ include?: Array< ResponseIncludable> | null;
619
+ input?: string | ResponseInput;
620
+ max_output_tokens?: number | null;
621
+ metadata?: Metadata | null;
622
+ model?: ResponsesModel;
623
+ parallel_tool_calls?: boolean | null;
624
+ previous_response_id?: string | null;
625
+ prompt?: ResponsePrompt | null;
626
+ reasoning?: Reasoning | null;
627
+ service_tier?: "auto" | "default" | "flex" | "scale" | "priority" | null;
628
+ store?: boolean | null;
629
+ temperature?: number | null;
630
+ text?: ResponseTextConfig;
631
+ tool_choice?: ToolChoiceOptions | ToolChoiceTypes | ToolChoiceFunction;
632
+ tools?: Array< Tool>;
633
+ top_p?: number | null;
634
+ truncation?: "auto" | "disabled" | null;
635
+ user?: string;
636
+ }>;
637
+ /**
638
+ * Determines whether the interaction loop should end by checking for the presence of the
639
+ * `__awaiting_user_response__` marker in the response text or if there's an error response.
640
+ * @param _ - Unused repository utilities.
641
+ * @param __ - Unused response parameters.
642
+ * @param response - The response from the LLM.
643
+ * @returns A boolean indicating whether the loop should end.
644
+ */
645
+ shouldEndInteractionLoop(_: RepositoryUtilities, __: ResponseCreateParamsNonStreaming, response: Response_2): Promise<boolean>;
646
+ /**
647
+ * After the interaction loop ends, this hook removes the `__awaiting_user_response__` marker
648
+ * from the final response before it is returned.
649
+ * @param _ - Unused repository utilities.
650
+ * @param response - The final response from the LLM.
651
+ * @returns The cleaned response.
652
+ */
653
+ onAfterInteractionLoopEnd(_: RepositoryUtilities, response: Response_2): Promise<Response_2>;
654
+ }
655
+
656
+ /**
657
+ * The InteractionProcessor class orchestrates the conversation with the LLM,
658
+ * managing the interaction loop, plugin execution, and message passing.
659
+ */
660
+ export declare class InteractionProcessor<T> {
661
+ private boothRegistry;
662
+ private boothPlugins;
663
+ private toolRegistry;
664
+ private llmAdapter;
665
+ private loopLimit;
666
+ /**
667
+ * Creates a synthetic error response with proper structure and error details.
668
+ * @param error - The error that occurred
669
+ * @param responseCreateParams - The original request parameters
670
+ * @returns A properly structured Response object representing the error
671
+ * @private
672
+ */
673
+ private createErrorResponse;
674
+ /**
675
+ * Calls the LLM with the given parameters.
676
+ * @param responseCreateParams - The parameters for creating the response.
677
+ * @returns A promise that resolves with the LLM's response.
678
+ * @private
679
+ */
680
+ private callLLM;
681
+ /**
682
+ * Runs the main interaction loop, sending messages to the LLM and processing
683
+ * the responses through the registered plugins.
684
+ * @param initialResponseParams - The initial parameters for the response.
685
+ * @returns A promise that resolves with the final response from the LLM.
686
+ * @private
687
+ */
688
+ private runInteractionLoop;
689
+ /**
690
+ * Creates an instance of InteractionProcessor.
691
+ * @param boothRegistry - The registry for booth configurations.
692
+ * @param boothPlugins - The registry for booth plugins.
693
+ * @param toolRegistry - The registry for available tools.
694
+ * @param openAIClient - The OpenAI client instance.
695
+ */
696
+ constructor(boothRegistry: BoothRegistry, boothPlugins: BoothPluginRegistry, toolRegistry: ToolRegistry, llmAdapter: LLMAdapter<T>);
697
+ /**
698
+ * Sends a message to the LLM and processes the response through the interaction loop.
699
+ * This involves running pre-loop, pre-send, response-received, and post-loop plugin hooks.
700
+ * @param input The input message to send.
701
+ * @returns The processed response from the LLM.
702
+ */
703
+ send(input: string): Promise<Response_2>;
704
+ }
705
+
706
+ export declare interface LLMAdapter<LLMResponse> {
707
+ invoke: (responseParams: ResponseCreateParamsNonStreaming) => Promise<LLMResponse>;
708
+ interpret: (response: LLMResponse) => Promise<Response_2>;
709
+ }
710
+
711
+ /**
712
+ * Defines the unique identifier for the orchestrator booth, which is responsible
713
+ * for routing and coordinating other booths.
714
+ */
715
+ export declare type ORCHESTRATOR_BOOTH_ID = 'orchestrator';
716
+
717
+ /**
718
+ * Provides a collection of repository utilities that can be used by plugins
719
+ * to access shared resources like booth and tool registries.
720
+ */
721
+ export declare type RepositoryUtilities = {
722
+ /** An instance of the BoothRegistry for managing booth configurations. */
723
+ boothRegistry: BoothRegistry;
724
+ /** An instance of the ToolRegistry for managing available tools. */
725
+ toolRegistry: ToolRegistry;
726
+ /** An instance of the BoothPluginRegistry for managing and coordinating plugins. */
727
+ pluginRegistry: BoothPluginRegistry;
728
+ };
729
+
730
+ export { ResponseCreateParamsNonStreaming }
731
+
732
+ /**
733
+ * Represents the result of processing a single tool call.
734
+ */
735
+ export declare type SingleToolProcessingResult = {
736
+ /**
737
+ * If set, indicates that the tool processing should exit early and return a specific value.
738
+ */
739
+ earlyExit?: {
740
+ returnValue: any;
741
+ };
742
+ /**
743
+ * An optional new message to be added to the chat history as a result of the tool execution.
744
+ */
745
+ newMessage?: ChatCompletionMessageParam;
746
+ /**
747
+ * A boolean indicating whether the tool was successfully executed.
748
+ */
749
+ toolExecuted: boolean;
750
+ };
751
+
752
+ /**
753
+ * Context information provided during tool call execution.
754
+ */
755
+ export declare type ToolCallContext = {
756
+ /** The current response parameters being processed. */
757
+ responseParams: ResponseCreateParamsNonStreaming;
758
+ /** The response from the LLM that contained this tool call. */
759
+ response: Response_2;
760
+ /** Index of this tool call in the current batch of tool calls. */
761
+ toolCallIndex: number;
762
+ /** Total number of tool calls in the current batch. */
763
+ totalToolCalls: number;
764
+ };
765
+
766
+ /**
767
+ * The ToolExecutorPlugin checks LLM responses for tool call requests, executes the corresponding
768
+ * tools, and appends the results to the message history for the next interaction loop.
769
+ */
770
+ export declare class ToolExecutorPlugin implements BoothPlugin {
771
+ id: string;
772
+ name: string;
773
+ description: string;
774
+ /**
775
+ * Executes a single tool call with proper hook integration.
776
+ * @param utilities - Repository utilities for accessing registries.
777
+ * @param toolCall - The tool call to execute.
778
+ * @param context - Context information about the tool call execution.
779
+ * @returns The function call output item for the response.
780
+ * @private
781
+ */
782
+ private executeToolCall;
783
+ /**
784
+ * After a response is received from the LLM, this hook checks for tool calls. If any are found,
785
+ * it executes them using the `toolRegistry` and appends their outputs to the response parameters'
786
+ * input history.
787
+ * @param utilities - The repository utilities containing available tools.
788
+ * @param responseParams - The parameters for the response creation.
789
+ * @param response - The response from the LLM.
790
+ * @returns The updated response parameters, potentially with tool call outputs added to the input.
791
+ */
792
+ onResponseReceived(utilities: RepositoryUtilities, responseParams: ResponseCreateParamsNonStreaming, response: Response_2): Promise<ResponseCreateParamsNonStreaming>;
793
+ /**
794
+ * Determines whether the interaction loop should end. This plugin always returns false,
795
+ * as tool execution is part of an ongoing conversation.
796
+ * @returns A boolean indicating that the loop should not end.
797
+ */
798
+ shouldEndInteractionLoop(): Promise<boolean>;
799
+ }
800
+
801
+ /**
802
+ * Represents a tool module, extending the OpenAI `FunctionTool` with an `execute` method.
803
+ * This allows for a consistent interface for executing tools.
804
+ */
805
+ export declare type ToolModule = FunctionTool & {
806
+ /**
807
+ * The function to be executed when the tool is called.
808
+ * @param input - The input parameters for the tool, typically parsed from a JSON string.
809
+ * @returns A promise that resolves with the result of the tool's execution.
810
+ */
811
+ execute: (input: any) => Promise<any>;
812
+ };
813
+
814
+ /**
815
+ * Represents the result of processing a tool, including whether to return a value,
816
+ * the updated messages, and which tool was executed.
817
+ */
818
+ export declare type ToolProcessingResult = {
819
+ /**
820
+ * If true, indicates that the interaction loop should terminate and return `returnValue`.
821
+ */
822
+ shouldReturn?: boolean;
823
+ /**
824
+ * The value to be returned if `shouldReturn` is true.
825
+ */
826
+ returnValue?: any;
827
+ /**
828
+ * A boolean indicating whether the tool was executed.
829
+ */
830
+ toolExecuted: boolean;
831
+ /**
832
+ * The list of chat messages updated after the tool execution.
833
+ */
834
+ updatedMessages: ChatCompletionMessageParam[];
835
+ /**
836
+ * The unique identifier of the tool that was executed.
837
+ */
838
+ toolId: string;
839
+ };
840
+
841
+ /**
842
+ * The ToolProviderPlugin collects tool definitions from the base and current context booths,
843
+ * ensuring that the LLM has access to the correct set of tools for the current interaction.
844
+ */
845
+ export declare class ToolProviderPlugin implements BoothPlugin {
846
+ description: string;
847
+ id: string;
848
+ name: string;
849
+ /**
850
+ * Before a message is sent, this hook gathers the tool keys from both the base and context booths,
851
+ * retrieves the corresponding tool definitions from the `toolRegistry`, and adds them to the
852
+ * response parameters. It also checks for duplicate tool keys.
853
+ * @param prepareInitialMessagesArgs - Utilities for accessing booth and tool registries.
854
+ * @param responseParams - The parameters for the response creation.
855
+ * @returns The updated response parameters with the aggregated list of tools.
856
+ */
857
+ onBeforeMessageSend(prepareInitialMessagesArgs: RepositoryUtilities, responseParams: ResponseCreateParamsNonStreaming): Promise<ResponseCreateParamsNonStreaming>;
858
+ /**
859
+ * Determines whether the interaction loop should end. This plugin always returns false,
860
+ * as providing tools is part of setting up the interaction, not concluding it.
861
+ * @returns A boolean indicating that the loop should not end.
862
+ */
863
+ shouldEndInteractionLoop(): Promise<boolean>;
864
+ }
865
+
866
+ /**
867
+ * The ToolRegistry manages the collection of OpenAI tools within the booth system.
868
+ *
869
+ * It provides methods for registering, retrieving, and managing
870
+ * tools that can be used by OpenAI's APIs during interactions.
871
+ *
872
+ * @example
873
+ * // Create an instance
874
+ * const toolRegistry = new ToolRegistry();
875
+ *
876
+ * // Register a tool
877
+ * toolRegistry.registerTool('calculator', calculatorTool);
878
+ */
879
+ export declare class ToolRegistry {
880
+ private tools;
881
+ /**
882
+ * Initializes an empty Map to store tools.
883
+ */
884
+ constructor();
885
+ registerTools(tools: ToolModule[]): void;
886
+ /**
887
+ * Registers a single tool in the registry.
888
+ * Throws an error if a tool with the same ID already exists.
889
+ *
890
+ * @param tool - The OpenAI Tool instance to register
891
+ * @throws Error if a tool with the same ID is already registered
892
+ */
893
+ registerTool(tool: ToolModule): void;
894
+ /**
895
+ * Finds and returns a tool by its ID.
896
+ *
897
+ * @param toolName - The unique identifier of the tool to retrieve
898
+ * @returns The tool instance if found, undefined otherwise
899
+ */
900
+ getTool(toolName: string): ToolModule;
901
+ /**
902
+ * Returns all registered tools as an array.
903
+ *
904
+ * @returns Array of all registered Tool instances
905
+ */
906
+ getAllTools(): ToolModule[];
907
+ /**
908
+ * Removes a tool from the registry by its ID.
909
+ * Throws an error if the tool doesn't exist.
910
+ *
911
+ * @param toolName - The unique identifier of the tool to remove
912
+ * @throws Error if the tool with the specified ID does not exist
913
+ */
914
+ unregisterTool(toolName: string): void;
915
+ }
916
+
917
+ export { }