booths 1.0.0 → 1.2.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.
- package/dist/index.d.ts +77 -6
- package/dist/index.js +371 -239
- package/package.json +2 -1
package/dist/index.d.ts
CHANGED
|
@@ -191,6 +191,15 @@ export declare class BoothPluginRegistry {
|
|
|
191
191
|
* @returns The plugin instance if found, undefined otherwise
|
|
192
192
|
*/
|
|
193
193
|
getPluginById(pluginId: string): BoothPlugin | undefined;
|
|
194
|
+
/**
|
|
195
|
+
* Finds and returns multiple plugins by their IDs.
|
|
196
|
+
* Throws an error if any plugin ID is not found.
|
|
197
|
+
*
|
|
198
|
+
* @param pluginIds - Array of unique identifiers of the plugins to retrieve
|
|
199
|
+
* @returns Array of plugin instances
|
|
200
|
+
* @throws Error if any plugin ID is not registered
|
|
201
|
+
*/
|
|
202
|
+
getPluginsByIds(pluginIds: string[]): BoothPlugin[];
|
|
194
203
|
/**
|
|
195
204
|
* Removes a plugin from the registry by its ID.
|
|
196
205
|
* Throws an error if the plugin doesn't exist.
|
|
@@ -305,6 +314,23 @@ export declare class BoothRegistry {
|
|
|
305
314
|
* @private
|
|
306
315
|
*/
|
|
307
316
|
private currentContextId;
|
|
317
|
+
/**
|
|
318
|
+
* Tracks whether the orchestrator booth is currently registered.
|
|
319
|
+
* @private
|
|
320
|
+
*/
|
|
321
|
+
private hasOrchestrator;
|
|
322
|
+
/**
|
|
323
|
+
* Optional callback function that gets called when multi-booth mode is enabled.
|
|
324
|
+
* Used to coordinate external actions like tool registration.
|
|
325
|
+
* @private
|
|
326
|
+
*/
|
|
327
|
+
private onMultiBoothModeEnabled?;
|
|
328
|
+
/**
|
|
329
|
+
* Optional callback function that gets called when multi-booth mode is disabled.
|
|
330
|
+
* Used to coordinate external actions like tool unregistration.
|
|
331
|
+
* @private
|
|
332
|
+
*/
|
|
333
|
+
private onMultiBoothModeDisabled?;
|
|
308
334
|
/**
|
|
309
335
|
* Creates a new booth registry with a specified base booth configuration.
|
|
310
336
|
*
|
|
@@ -367,6 +393,15 @@ export declare class BoothRegistry {
|
|
|
367
393
|
* @returns The booth configuration if found, undefined otherwise
|
|
368
394
|
*/
|
|
369
395
|
getBoothById(boothId: string): BoothConfig | undefined;
|
|
396
|
+
/**
|
|
397
|
+
* Finds and returns multiple booth configurations by their IDs.
|
|
398
|
+
* Throws an error if any booth ID is not found.
|
|
399
|
+
*
|
|
400
|
+
* @param boothIds - Array of unique identifiers of the booths to retrieve
|
|
401
|
+
* @returns Array of booth configurations
|
|
402
|
+
* @throws Error if any booth ID is not registered
|
|
403
|
+
*/
|
|
404
|
+
getBoothsByIds(boothIds: string[]): BoothConfig[];
|
|
370
405
|
/**
|
|
371
406
|
* Returns all registered booth configurations.
|
|
372
407
|
*
|
|
@@ -375,9 +410,23 @@ export declare class BoothRegistry {
|
|
|
375
410
|
getAllBooths(): Record<string, BoothConfig>;
|
|
376
411
|
toArray(): BoothConfig[];
|
|
377
412
|
/**
|
|
378
|
-
*
|
|
379
|
-
* @
|
|
413
|
+
* Enables multi-booth mode by registering the orchestrator and setting it as current context.
|
|
414
|
+
* @private
|
|
415
|
+
*/
|
|
416
|
+
private enableMultiBoothMode;
|
|
417
|
+
/**
|
|
418
|
+
* Disables multi-booth mode by unregistering the orchestrator and resetting context to base booth.
|
|
419
|
+
* @private
|
|
380
420
|
*/
|
|
421
|
+
private disableMultiBoothMode;
|
|
422
|
+
/**
|
|
423
|
+
* Sets callback functions for when multi-booth mode is enabled/disabled.
|
|
424
|
+
* Used to coordinate external actions like tool registration/unregistration.
|
|
425
|
+
*
|
|
426
|
+
* @param onEnabled - Callback for when multi-booth mode is enabled
|
|
427
|
+
* @param onDisabled - Callback for when multi-booth mode is disabled
|
|
428
|
+
*/
|
|
429
|
+
setMultiBoothModeCallbacks(onEnabled?: () => void, onDisabled?: () => void): void;
|
|
381
430
|
get isMultiBoothMode(): boolean;
|
|
382
431
|
/**
|
|
383
432
|
* Removes a booth configuration from the registry by its ID.
|
|
@@ -388,6 +437,12 @@ export declare class BoothRegistry {
|
|
|
388
437
|
unregisterBooth(boothId: string): void;
|
|
389
438
|
}
|
|
390
439
|
|
|
440
|
+
export declare type BoothResponseInput = BoothResponseInputItem[];
|
|
441
|
+
|
|
442
|
+
export declare type BoothResponseInputItem = (ResponseInputItem & {
|
|
443
|
+
bmId: string;
|
|
444
|
+
}) | string;
|
|
445
|
+
|
|
391
446
|
/**
|
|
392
447
|
* The ContextProviderPlugin provides contextual information to booths during interaction loops.
|
|
393
448
|
*
|
|
@@ -480,12 +535,19 @@ export declare class ConversationHistoryPlugin implements BoothPlugin {
|
|
|
480
535
|
*/
|
|
481
536
|
private responseContainsBoothChange;
|
|
482
537
|
/**
|
|
483
|
-
* Constructs a new instance with
|
|
538
|
+
* Constructs a new instance with an optional session history.
|
|
484
539
|
*
|
|
485
|
-
* @param {ResponseInput} [sessionHistory=[]] - An
|
|
486
|
-
* @return {void}
|
|
540
|
+
* @param {ResponseInput[]} [sessionHistory=[]] - An array representing the session history. Defaults to an empty array if not provided.
|
|
487
541
|
*/
|
|
488
542
|
constructor(sessionHistory?: ResponseInput);
|
|
543
|
+
/**
|
|
544
|
+
* Retrieves the session history.
|
|
545
|
+
*
|
|
546
|
+
* @return {Array} The history of the current session.
|
|
547
|
+
*/
|
|
548
|
+
get history(): (ResponseInputItem & {
|
|
549
|
+
bmId?: string;
|
|
550
|
+
})[];
|
|
489
551
|
/**
|
|
490
552
|
* Returns the plugin's unique identifier.
|
|
491
553
|
*/
|
|
@@ -517,7 +579,7 @@ export declare class ConversationHistoryPlugin implements BoothPlugin {
|
|
|
517
579
|
* @returns Unmodified response parameters
|
|
518
580
|
*/
|
|
519
581
|
onResponseReceived(utilities: RepositoryUtilities, responseParams: ResponseCreateParamsNonStreaming, response: Response_2): Promise<{
|
|
520
|
-
input: (
|
|
582
|
+
input: ( EasyInputMessage | ResponseOutputMessage | ResponseFileSearchToolCall | ResponseComputerToolCall | ResponseInputItem.ComputerCallOutput | ResponseFunctionWebSearch | ResponseFunctionToolCall | ResponseInputItem.FunctionCallOutput | ResponseReasoningItem | ResponseInputItem.ImageGenerationCall | ResponseCodeInterpreterToolCall | ResponseInputItem.LocalShellCall | ResponseInputItem.LocalShellCallOutput | ResponseInputItem.McpListTools | ResponseInputItem.McpApprovalRequest | ResponseInputItem.McpApprovalResponse | ResponseInputItem.McpCall | ResponseInputItem.ItemReference)[];
|
|
521
583
|
stream?: false | null;
|
|
522
584
|
background?: boolean | null;
|
|
523
585
|
include?: Array< ResponseIncludable> | null;
|
|
@@ -942,6 +1004,15 @@ export declare class ToolRegistry {
|
|
|
942
1004
|
* @returns The tool instance if found, undefined otherwise
|
|
943
1005
|
*/
|
|
944
1006
|
getTool(toolName: string): ToolModule;
|
|
1007
|
+
/**
|
|
1008
|
+
* Finds and returns multiple tools by their names.
|
|
1009
|
+
* Throws an error if any tool name is not found (via getTool method).
|
|
1010
|
+
*
|
|
1011
|
+
* @param toolNames - Array of unique names of the tools to retrieve
|
|
1012
|
+
* @returns Array of tool instances
|
|
1013
|
+
* @throws Error if any tool name is not registered
|
|
1014
|
+
*/
|
|
1015
|
+
getToolsByNames(toolNames: string[]): ToolModule[];
|
|
945
1016
|
getGlobalTools(): ToolModule[];
|
|
946
1017
|
/**
|
|
947
1018
|
* Returns all registered tools as an array.
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* Collection of registered plugins.
|
|
8
|
-
* @private
|
|
9
|
-
*/
|
|
10
|
-
n(this, "plugins", []);
|
|
11
|
-
}
|
|
1
|
+
class p {
|
|
2
|
+
/**
|
|
3
|
+
* Collection of registered plugins.
|
|
4
|
+
* @private
|
|
5
|
+
*/
|
|
6
|
+
plugins = [];
|
|
12
7
|
/**
|
|
13
8
|
* Registers a single plugin in the registry.
|
|
14
9
|
* Throws an error if a plugin with the same ID already exists.
|
|
@@ -46,6 +41,24 @@ class d {
|
|
|
46
41
|
getPluginById(t) {
|
|
47
42
|
return this.plugins.find((o) => o.id === t);
|
|
48
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* Finds and returns multiple plugins by their IDs.
|
|
46
|
+
* Throws an error if any plugin ID is not found.
|
|
47
|
+
*
|
|
48
|
+
* @param pluginIds - Array of unique identifiers of the plugins to retrieve
|
|
49
|
+
* @returns Array of plugin instances
|
|
50
|
+
* @throws Error if any plugin ID is not registered
|
|
51
|
+
*/
|
|
52
|
+
getPluginsByIds(t) {
|
|
53
|
+
const o = [];
|
|
54
|
+
for (const e of t) {
|
|
55
|
+
const r = this.getPluginById(e);
|
|
56
|
+
if (!r)
|
|
57
|
+
throw new Error(`Plugin with ID ${e} is not registered.`);
|
|
58
|
+
o.push(r);
|
|
59
|
+
}
|
|
60
|
+
return o;
|
|
61
|
+
}
|
|
49
62
|
/**
|
|
50
63
|
* Removes a plugin from the registry by its ID.
|
|
51
64
|
* Throws an error if the plugin doesn't exist.
|
|
@@ -167,8 +180,8 @@ class d {
|
|
|
167
180
|
*/
|
|
168
181
|
async runAfterToolCall(t, o, e, r) {
|
|
169
182
|
let s = e;
|
|
170
|
-
for (const
|
|
171
|
-
|
|
183
|
+
for (const l of this.plugins)
|
|
184
|
+
l.onAfterToolCall && (s = await l.onAfterToolCall(t, o, s, r));
|
|
172
185
|
return s;
|
|
173
186
|
}
|
|
174
187
|
/**
|
|
@@ -184,12 +197,47 @@ class d {
|
|
|
184
197
|
*/
|
|
185
198
|
async runToolCallError(t, o, e, r) {
|
|
186
199
|
let s = `Error: ${e.message}`;
|
|
187
|
-
for (const
|
|
188
|
-
|
|
200
|
+
for (const l of this.plugins)
|
|
201
|
+
l.onToolCallError && (s = await l.onToolCallError(t, o, e, r));
|
|
189
202
|
return s;
|
|
190
203
|
}
|
|
191
204
|
}
|
|
192
|
-
|
|
205
|
+
const u = {
|
|
206
|
+
id: "orchestrator",
|
|
207
|
+
role: `
|
|
208
|
+
This booth serves as the orchestration layer that analyzes user intent and routes
|
|
209
|
+
conversations to the most appropriate specialized booth configuration.
|
|
210
|
+
`,
|
|
211
|
+
description: `
|
|
212
|
+
You are the orchestration layer responsible for determining which booth configuration
|
|
213
|
+
should be active based on user needs. Focus exclusively on routing - do not answer
|
|
214
|
+
questions or provide information directly to users.
|
|
215
|
+
|
|
216
|
+
[ROUTING STRATEGY]
|
|
217
|
+
- Analyze user request and route to the most appropriate specialized booth immediately
|
|
218
|
+
- This booth is only active for initial routing or when explicitly routed back to
|
|
219
|
+
- Once routed, the target booth handles the conversation until completion or re-routing
|
|
220
|
+
|
|
221
|
+
[ROUTING TARGETS]
|
|
222
|
+
- Ambiguous requests → Ask for clarification, then route appropriately
|
|
223
|
+
|
|
224
|
+
[CORE PRINCIPLES]
|
|
225
|
+
- Maintain illusion of single, continuous assistant
|
|
226
|
+
- Never reference booths, tools, or system mechanics to users
|
|
227
|
+
- Silent routing is preferred when intent is clear
|
|
228
|
+
- Only speak to users when clarification is absolutely necessary
|
|
229
|
+
|
|
230
|
+
[ROUTING BEHAVIOR]
|
|
231
|
+
- Clear intent: Route silently using route_to_booth() - do NOT respond to user
|
|
232
|
+
- Ambiguous intent: Ask user for clarification, then route once clarified
|
|
233
|
+
- Never respond to user AND route - it's either respond OR route, not both
|
|
234
|
+
|
|
235
|
+
[BEHAVIOR EXAMPLES]
|
|
236
|
+
- User: "How do I test my number?" → route_to_booth({ targetBooth: 'page-router-booth' })
|
|
237
|
+
- User: "I need help" → "What specifically would you like help with?" → then route based on response
|
|
238
|
+
`
|
|
239
|
+
};
|
|
240
|
+
class R {
|
|
193
241
|
/**
|
|
194
242
|
* Creates a new booth registry with a specified base booth configuration.
|
|
195
243
|
*
|
|
@@ -197,18 +245,35 @@ class v {
|
|
|
197
245
|
* @param currentContextId - The initial current context booth ID (default is 'orchestrator')
|
|
198
246
|
*/
|
|
199
247
|
constructor(t, o) {
|
|
200
|
-
/**
|
|
201
|
-
* Collection of registered booth configurations, indexed by their IDs.
|
|
202
|
-
* @private
|
|
203
|
-
*/
|
|
204
|
-
n(this, "booths", {});
|
|
205
|
-
/**
|
|
206
|
-
* The current context booth ID, defaulting to the orchestrator context.
|
|
207
|
-
* @private
|
|
208
|
-
*/
|
|
209
|
-
n(this, "currentContextId");
|
|
210
248
|
this.baseBooth = t, this.registerBooth(t), this.currentContextId = o || t.id;
|
|
211
249
|
}
|
|
250
|
+
/**
|
|
251
|
+
* Collection of registered booth configurations, indexed by their IDs.
|
|
252
|
+
* @private
|
|
253
|
+
*/
|
|
254
|
+
booths = {};
|
|
255
|
+
/**
|
|
256
|
+
* The current context booth ID, defaulting to the orchestrator context.
|
|
257
|
+
* @private
|
|
258
|
+
*/
|
|
259
|
+
currentContextId;
|
|
260
|
+
/**
|
|
261
|
+
* Tracks whether the orchestrator booth is currently registered.
|
|
262
|
+
* @private
|
|
263
|
+
*/
|
|
264
|
+
hasOrchestrator = !1;
|
|
265
|
+
/**
|
|
266
|
+
* Optional callback function that gets called when multi-booth mode is enabled.
|
|
267
|
+
* Used to coordinate external actions like tool registration.
|
|
268
|
+
* @private
|
|
269
|
+
*/
|
|
270
|
+
onMultiBoothModeEnabled;
|
|
271
|
+
/**
|
|
272
|
+
* Optional callback function that gets called when multi-booth mode is disabled.
|
|
273
|
+
* Used to coordinate external actions like tool unregistration.
|
|
274
|
+
* @private
|
|
275
|
+
*/
|
|
276
|
+
onMultiBoothModeDisabled;
|
|
212
277
|
/**
|
|
213
278
|
* Gets the current context booth ID.
|
|
214
279
|
*
|
|
@@ -247,7 +312,11 @@ class v {
|
|
|
247
312
|
* @param boothConfig - The booth configuration to register
|
|
248
313
|
*/
|
|
249
314
|
registerBooth(t) {
|
|
250
|
-
|
|
315
|
+
if (this.booths[t.id])
|
|
316
|
+
return;
|
|
317
|
+
this.booths[t.id] = t, Object.keys(this.booths).filter(
|
|
318
|
+
(e) => e !== u.id
|
|
319
|
+
).length > 1 && !this.hasOrchestrator && this.enableMultiBoothMode();
|
|
251
320
|
}
|
|
252
321
|
/**
|
|
253
322
|
* Returns the base booth configuration that was provided during initialization.
|
|
@@ -289,6 +358,24 @@ class v {
|
|
|
289
358
|
getBoothById(t) {
|
|
290
359
|
return this.booths[t];
|
|
291
360
|
}
|
|
361
|
+
/**
|
|
362
|
+
* Finds and returns multiple booth configurations by their IDs.
|
|
363
|
+
* Throws an error if any booth ID is not found.
|
|
364
|
+
*
|
|
365
|
+
* @param boothIds - Array of unique identifiers of the booths to retrieve
|
|
366
|
+
* @returns Array of booth configurations
|
|
367
|
+
* @throws Error if any booth ID is not registered
|
|
368
|
+
*/
|
|
369
|
+
getBoothsByIds(t) {
|
|
370
|
+
const o = [];
|
|
371
|
+
for (const e of t) {
|
|
372
|
+
const r = this.getBoothById(e);
|
|
373
|
+
if (!r)
|
|
374
|
+
throw new Error(`Booth with ID ${e} is not registered.`);
|
|
375
|
+
o.push(r);
|
|
376
|
+
}
|
|
377
|
+
return o;
|
|
378
|
+
}
|
|
292
379
|
/**
|
|
293
380
|
* Returns all registered booth configurations.
|
|
294
381
|
*
|
|
@@ -301,11 +388,33 @@ class v {
|
|
|
301
388
|
return Object.values(this.booths);
|
|
302
389
|
}
|
|
303
390
|
/**
|
|
304
|
-
*
|
|
305
|
-
* @
|
|
391
|
+
* Enables multi-booth mode by registering the orchestrator and setting it as current context.
|
|
392
|
+
* @private
|
|
393
|
+
*/
|
|
394
|
+
enableMultiBoothMode() {
|
|
395
|
+
this.hasOrchestrator || (this.booths[u.id] = u, this.hasOrchestrator = !0, this.currentContextId = u.id, this.onMultiBoothModeEnabled?.());
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Disables multi-booth mode by unregistering the orchestrator and resetting context to base booth.
|
|
399
|
+
* @private
|
|
400
|
+
*/
|
|
401
|
+
disableMultiBoothMode() {
|
|
402
|
+
this.hasOrchestrator && (delete this.booths[u.id], this.hasOrchestrator = !1, this.currentContextId = this.baseBooth.id, this.onMultiBoothModeDisabled?.());
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* Sets callback functions for when multi-booth mode is enabled/disabled.
|
|
406
|
+
* Used to coordinate external actions like tool registration/unregistration.
|
|
407
|
+
*
|
|
408
|
+
* @param onEnabled - Callback for when multi-booth mode is enabled
|
|
409
|
+
* @param onDisabled - Callback for when multi-booth mode is disabled
|
|
306
410
|
*/
|
|
411
|
+
setMultiBoothModeCallbacks(t, o) {
|
|
412
|
+
this.onMultiBoothModeEnabled = t, this.onMultiBoothModeDisabled = o;
|
|
413
|
+
}
|
|
307
414
|
get isMultiBoothMode() {
|
|
308
|
-
return Object.keys(this.booths).
|
|
415
|
+
return Object.keys(this.booths).filter(
|
|
416
|
+
(o) => o !== u.id
|
|
417
|
+
).length > 1;
|
|
309
418
|
}
|
|
310
419
|
/**
|
|
311
420
|
* Removes a booth configuration from the registry by its ID.
|
|
@@ -316,10 +425,16 @@ class v {
|
|
|
316
425
|
unregisterBooth(t) {
|
|
317
426
|
if (!this.booths[t])
|
|
318
427
|
throw new Error(`Booth with ID ${t} does not exist.`);
|
|
319
|
-
|
|
428
|
+
if (t === u.id)
|
|
429
|
+
throw new Error(
|
|
430
|
+
"Cannot unregister orchestrator booth directly. It will be automatically managed based on booth count."
|
|
431
|
+
);
|
|
432
|
+
delete this.booths[t], Object.keys(this.booths).filter(
|
|
433
|
+
(e) => e !== u.id
|
|
434
|
+
).length <= 1 && this.hasOrchestrator && this.disableMultiBoothMode();
|
|
320
435
|
}
|
|
321
436
|
}
|
|
322
|
-
class
|
|
437
|
+
class B {
|
|
323
438
|
/**
|
|
324
439
|
* Creates an instance of InteractionProcessor.
|
|
325
440
|
* @param boothRegistry - The registry for booth configurations.
|
|
@@ -328,9 +443,9 @@ class E {
|
|
|
328
443
|
* @param llmAdapter - The adapter for interacting with the LLM.
|
|
329
444
|
*/
|
|
330
445
|
constructor(t, o, e, r) {
|
|
331
|
-
n(this, "loopLimit", 10);
|
|
332
446
|
this.boothRegistry = t, this.boothPlugins = o, this.toolRegistry = e, this.llmAdapter = r;
|
|
333
447
|
}
|
|
448
|
+
loopLimit = 10;
|
|
334
449
|
/**
|
|
335
450
|
* Creates a synthetic error response with proper structure and error details.
|
|
336
451
|
* @param error - The error that occurred
|
|
@@ -473,13 +588,13 @@ class E {
|
|
|
473
588
|
), r;
|
|
474
589
|
}
|
|
475
590
|
}
|
|
476
|
-
const
|
|
591
|
+
const T = {
|
|
477
592
|
id: "summarizer",
|
|
478
593
|
role: 'You are a highly skilled summarization AI. Your task is to read a conversation history and provide a concise, neutral, and objective summary. The summary should capture the key points, decisions made, and any unresolved questions. It must be written from a third-person perspective and should be clear enough for another AI assistant to understand the full context and continue the conversation seamlessly without needing the original transcript. Do not add any conversational fluff or introductory phrases like "Here is the summary:".',
|
|
479
594
|
description: "A specialized booth for summarizing conversation histories."
|
|
480
|
-
},
|
|
481
|
-
function
|
|
482
|
-
const t =
|
|
595
|
+
}, f = "route_to_booth";
|
|
596
|
+
function y(n) {
|
|
597
|
+
const t = n.getAllBooths(), o = Object.values(t).map(
|
|
483
598
|
(r) => `- ${r.id}: ${r.role}
|
|
484
599
|
Examples:
|
|
485
600
|
${(r.examples || []).map((s) => ` - "${s}"`).join(`
|
|
@@ -488,7 +603,7 @@ ${(r.examples || []).map((s) => ` - "${s}"`).join(`
|
|
|
488
603
|
`), e = Object.keys(t);
|
|
489
604
|
return {
|
|
490
605
|
type: "function",
|
|
491
|
-
name:
|
|
606
|
+
name: f,
|
|
492
607
|
description: `
|
|
493
608
|
Routes the conversation to a specialized booth based on the user's needs. Each booth has a
|
|
494
609
|
specific role and set of capabilities.
|
|
@@ -518,7 +633,7 @@ ${o}
|
|
|
518
633
|
*/
|
|
519
634
|
execute: async function({ targetBooth: r }) {
|
|
520
635
|
try {
|
|
521
|
-
return
|
|
636
|
+
return n.setCurrentContextId(r), {
|
|
522
637
|
content: `Routed to booth ${r}`
|
|
523
638
|
};
|
|
524
639
|
} catch (s) {
|
|
@@ -529,36 +644,27 @@ ${o}
|
|
|
529
644
|
}
|
|
530
645
|
};
|
|
531
646
|
}
|
|
532
|
-
class
|
|
647
|
+
class v {
|
|
533
648
|
/**
|
|
534
|
-
*
|
|
535
|
-
*
|
|
536
|
-
* @param {ResponseInput} [sessionHistory=[]] - An optional array representing the session history. Defaults to an empty array if not provided.
|
|
537
|
-
* @return {void}
|
|
649
|
+
* The sessionHistory variable stores the conversation history between the user and the booth system.
|
|
650
|
+
* It is initialized as an empty array and will be populated with messages exchanged during the interaction.
|
|
538
651
|
*/
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
/**
|
|
556
|
-
* Brief description of the plugin's purpose and functionality.
|
|
557
|
-
* @private
|
|
558
|
-
*/
|
|
559
|
-
n(this, "plugin_description", "A plugin to manage conversation history in booths.");
|
|
560
|
-
this.sessionHistory = t;
|
|
561
|
-
}
|
|
652
|
+
sessionHistory = [];
|
|
653
|
+
/**
|
|
654
|
+
* Unique identifier for this plugin instance.
|
|
655
|
+
* @private
|
|
656
|
+
*/
|
|
657
|
+
plugin_id = "conversation-history";
|
|
658
|
+
/**
|
|
659
|
+
* Display name for this plugin.
|
|
660
|
+
* @private
|
|
661
|
+
*/
|
|
662
|
+
plugin_name = "Conversation History Plugin";
|
|
663
|
+
/**
|
|
664
|
+
* Brief description of the plugin's purpose and functionality.
|
|
665
|
+
* @private
|
|
666
|
+
*/
|
|
667
|
+
plugin_description = "A plugin to manage conversation history in booths.";
|
|
562
668
|
/**
|
|
563
669
|
* Checks if the given response contains a booth change.
|
|
564
670
|
*
|
|
@@ -569,10 +675,26 @@ class I {
|
|
|
569
675
|
* @return A boolean indicating whether a booth change is present in the response.
|
|
570
676
|
*/
|
|
571
677
|
responseContainsBoothChange(t) {
|
|
572
|
-
return t.output ? t.output.some((o) => o.type === "function_call" ? o.name ===
|
|
573
|
-
(e) => e.type === "function" && e.function.name ===
|
|
678
|
+
return t.output ? t.output.some((o) => o.type === "function_call" ? o.name === f : o.type === "message" && "tool_calls" in o && Array.isArray(o.tool_calls) ? o.tool_calls.some(
|
|
679
|
+
(e) => e.type === "function" && e.function.name === f
|
|
574
680
|
) : !1) : !1;
|
|
575
681
|
}
|
|
682
|
+
/**
|
|
683
|
+
* Constructs a new instance with an optional session history.
|
|
684
|
+
*
|
|
685
|
+
* @param {ResponseInput[]} [sessionHistory=[]] - An array representing the session history. Defaults to an empty array if not provided.
|
|
686
|
+
*/
|
|
687
|
+
constructor(t = []) {
|
|
688
|
+
this.sessionHistory = t;
|
|
689
|
+
}
|
|
690
|
+
/**
|
|
691
|
+
* Retrieves the session history.
|
|
692
|
+
*
|
|
693
|
+
* @return {Array} The history of the current session.
|
|
694
|
+
*/
|
|
695
|
+
get history() {
|
|
696
|
+
return this.sessionHistory;
|
|
697
|
+
}
|
|
576
698
|
/**
|
|
577
699
|
* Returns the plugin's unique identifier.
|
|
578
700
|
*/
|
|
@@ -616,17 +738,15 @@ class I {
|
|
|
616
738
|
* @returns Unmodified response parameters
|
|
617
739
|
*/
|
|
618
740
|
async onResponseReceived(t, o, e) {
|
|
619
|
-
let s = [...o.input, ...
|
|
741
|
+
let s = [...o.input, ...e?.output ?? []];
|
|
620
742
|
if (this.responseContainsBoothChange(e)) {
|
|
621
|
-
const
|
|
743
|
+
const i = `Please summarize the following conversation history:
|
|
622
744
|
|
|
623
|
-
${JSON.stringify(this.sessionHistory)}`,
|
|
745
|
+
${JSON.stringify(this.sessionHistory)}`, d = (await P(t.llmAdapter, T).callProcessor.send(i)).output_text, g = s.filter((h) => "role" in h && h.role === "user").pop(), b = {
|
|
624
746
|
role: "developer",
|
|
625
|
-
content: `A conversation summary up to this point: ${
|
|
626
|
-
},
|
|
627
|
-
|
|
628
|
-
);
|
|
629
|
-
this.sessionHistory = f ? [...b, m, f] : [...b, m], s = this.sessionHistory;
|
|
747
|
+
content: `A conversation summary up to this point: ${d}`
|
|
748
|
+
}, w = s.filter((h) => !("role" in h && h.role === "user" || "type" in h && h.type === "message"));
|
|
749
|
+
this.sessionHistory = g ? [...w, b, g] : [...w, b], s = this.sessionHistory;
|
|
630
750
|
} else
|
|
631
751
|
this.sessionHistory = s;
|
|
632
752
|
return {
|
|
@@ -644,24 +764,22 @@ ${JSON.stringify(this.sessionHistory)}`, c = (await L(t.llmAdapter, C).callProce
|
|
|
644
764
|
return !1;
|
|
645
765
|
}
|
|
646
766
|
}
|
|
647
|
-
class
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
n(this, "plugin_description", "A plugin to provide context to booths.");
|
|
664
|
-
}
|
|
767
|
+
class E {
|
|
768
|
+
/**
|
|
769
|
+
* Unique identifier for this plugin instance.
|
|
770
|
+
* @private
|
|
771
|
+
*/
|
|
772
|
+
plugin_id = "context-provider";
|
|
773
|
+
/**
|
|
774
|
+
* Display the name for this plugin.
|
|
775
|
+
* @private
|
|
776
|
+
*/
|
|
777
|
+
plugin_name = "Context Provider Plugin";
|
|
778
|
+
/**
|
|
779
|
+
* Brief description of the plugin's purpose and functionality.
|
|
780
|
+
* @private
|
|
781
|
+
*/
|
|
782
|
+
plugin_description = "A plugin to provide context to booths.";
|
|
665
783
|
/**
|
|
666
784
|
* Returns the plugin's unique identifier.
|
|
667
785
|
*/
|
|
@@ -692,12 +810,12 @@ class A {
|
|
|
692
810
|
const e = t.boothRegistry;
|
|
693
811
|
let s = e.baseBoothConfig.description;
|
|
694
812
|
if (e.isMultiBoothMode) {
|
|
695
|
-
const
|
|
813
|
+
const l = e.orchestratorBoothConfig, i = e.currentContextBoothConfig;
|
|
696
814
|
s += `
|
|
697
815
|
|
|
698
|
-
${
|
|
816
|
+
${l.description}`, i.id !== l.id && (s += `
|
|
699
817
|
|
|
700
|
-
${
|
|
818
|
+
${i.description}`);
|
|
701
819
|
}
|
|
702
820
|
return { ...o, instructions: s };
|
|
703
821
|
}
|
|
@@ -712,11 +830,11 @@ class A {
|
|
|
712
830
|
}
|
|
713
831
|
}
|
|
714
832
|
class _ {
|
|
833
|
+
tools;
|
|
715
834
|
/**
|
|
716
835
|
* Initializes an empty Map to store tools.
|
|
717
836
|
*/
|
|
718
837
|
constructor() {
|
|
719
|
-
n(this, "tools");
|
|
720
838
|
this.tools = /* @__PURE__ */ new Map();
|
|
721
839
|
}
|
|
722
840
|
registerTools(t) {
|
|
@@ -749,6 +867,22 @@ class _ {
|
|
|
749
867
|
throw new Error(`Tool with name ${t} is not registered.`);
|
|
750
868
|
return o;
|
|
751
869
|
}
|
|
870
|
+
/**
|
|
871
|
+
* Finds and returns multiple tools by their names.
|
|
872
|
+
* Throws an error if any tool name is not found (via getTool method).
|
|
873
|
+
*
|
|
874
|
+
* @param toolNames - Array of unique names of the tools to retrieve
|
|
875
|
+
* @returns Array of tool instances
|
|
876
|
+
* @throws Error if any tool name is not registered
|
|
877
|
+
*/
|
|
878
|
+
getToolsByNames(t) {
|
|
879
|
+
const o = [];
|
|
880
|
+
for (const e of t) {
|
|
881
|
+
const r = this.getTool(e);
|
|
882
|
+
o.push(r);
|
|
883
|
+
}
|
|
884
|
+
return o;
|
|
885
|
+
}
|
|
752
886
|
getGlobalTools() {
|
|
753
887
|
return Array.from(this.tools.values()).filter((t) => t.global);
|
|
754
888
|
}
|
|
@@ -791,12 +925,41 @@ class _ {
|
|
|
791
925
|
this.tools.delete(t);
|
|
792
926
|
}
|
|
793
927
|
}
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
928
|
+
function I(n) {
|
|
929
|
+
switch (n.type) {
|
|
930
|
+
case "function":
|
|
931
|
+
return `function:${n.name}`;
|
|
932
|
+
case "mcp":
|
|
933
|
+
return `mcp:${n.server_label}`;
|
|
934
|
+
case "file_search":
|
|
935
|
+
return `file_search:${n.vector_store_ids.join(",")}`;
|
|
936
|
+
case "web_search_preview":
|
|
937
|
+
case "web_search_preview_2025_03_11":
|
|
938
|
+
return `web_search:${n.type}`;
|
|
939
|
+
case "computer_use_preview":
|
|
940
|
+
return `computer:${n.environment}:${n.display_width}x${n.display_height}`;
|
|
941
|
+
case "code_interpreter":
|
|
942
|
+
return `code_interpreter:${typeof n.container == "string" ? n.container : "auto"}`;
|
|
943
|
+
case "image_generation":
|
|
944
|
+
return `image_generation:${n.model || "gpt-image-1"}`;
|
|
945
|
+
case "local_shell":
|
|
946
|
+
return "local_shell";
|
|
947
|
+
default:
|
|
948
|
+
return `${n.type}:${JSON.stringify(n)}`;
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
function C(n) {
|
|
952
|
+
const t = /* @__PURE__ */ new Set(), o = [];
|
|
953
|
+
for (const e of n) {
|
|
954
|
+
const r = I(e);
|
|
955
|
+
t.has(r) || (t.add(r), o.push(e));
|
|
799
956
|
}
|
|
957
|
+
return o;
|
|
958
|
+
}
|
|
959
|
+
class x {
|
|
960
|
+
description = "A plugin to aggregate and provide tools from base and context booths.";
|
|
961
|
+
id = "tool-provider";
|
|
962
|
+
name = "Tool Provider Plugin";
|
|
800
963
|
/**
|
|
801
964
|
* Before a message is sent, this hook gathers the tool keys from both the base and context booths,
|
|
802
965
|
* retrieves the corresponding tool definitions from the `toolRegistry`, and adds them to the
|
|
@@ -806,16 +969,18 @@ class x {
|
|
|
806
969
|
* @returns The updated response parameters with the aggregated list of tools.
|
|
807
970
|
*/
|
|
808
971
|
async onBeforeMessageSend(t, o) {
|
|
809
|
-
const e = t.boothRegistry.baseBoothConfig, r = t.boothRegistry.currentContextBoothConfig,
|
|
810
|
-
(
|
|
972
|
+
const e = t.boothRegistry.baseBoothConfig, r = t.boothRegistry.currentContextBoothConfig, i = [...e.tools || [], ...r?.tools || []].filter((a, d, g) => g.indexOf(a) === d).map(
|
|
973
|
+
(a) => t.toolRegistry.getTool(a)
|
|
811
974
|
);
|
|
812
|
-
if (e.mcp &&
|
|
813
|
-
const
|
|
814
|
-
|
|
975
|
+
if (e.mcp && i.push(...e.mcp), r?.mcp && i.push(...r.mcp), t.boothRegistry.isMultiBoothMode) {
|
|
976
|
+
const a = y(t.boothRegistry);
|
|
977
|
+
i.push(a);
|
|
815
978
|
}
|
|
816
|
-
|
|
979
|
+
i.push(...t.toolRegistry.getGlobalTools());
|
|
980
|
+
const c = C(i);
|
|
981
|
+
return {
|
|
817
982
|
...o,
|
|
818
|
-
tools:
|
|
983
|
+
tools: c
|
|
819
984
|
};
|
|
820
985
|
}
|
|
821
986
|
/**
|
|
@@ -827,12 +992,10 @@ class x {
|
|
|
827
992
|
return !1;
|
|
828
993
|
}
|
|
829
994
|
}
|
|
830
|
-
class
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
n(this, "description", "Checks for tool calls in the response, executes them, and adds the results to the message history.");
|
|
835
|
-
}
|
|
995
|
+
class m {
|
|
996
|
+
id = "tool-executor";
|
|
997
|
+
name = "Tool Executor";
|
|
998
|
+
description = "Checks for tool calls in the response, executes them, and adds the results to the message history.";
|
|
836
999
|
/**
|
|
837
1000
|
* Executes a single tool call with proper hook integration.
|
|
838
1001
|
* @param utilities - Repository utilities for accessing registries.
|
|
@@ -860,16 +1023,16 @@ class y {
|
|
|
860
1023
|
call_id: r.call_id,
|
|
861
1024
|
output: `Error: Tool '${r.name}' does not have an 'execute' method.`
|
|
862
1025
|
};
|
|
863
|
-
const
|
|
1026
|
+
const l = await s.execute(JSON.parse(r.arguments)), i = await t.pluginRegistry.runAfterToolCall(
|
|
864
1027
|
t,
|
|
865
1028
|
r,
|
|
866
|
-
|
|
1029
|
+
l,
|
|
867
1030
|
e
|
|
868
1031
|
);
|
|
869
1032
|
return {
|
|
870
1033
|
type: "function_call_output",
|
|
871
1034
|
call_id: r.call_id,
|
|
872
|
-
output: JSON.stringify(
|
|
1035
|
+
output: JSON.stringify(i)
|
|
873
1036
|
};
|
|
874
1037
|
} catch (r) {
|
|
875
1038
|
console.error(`Error executing tool ${o.name}:`, r);
|
|
@@ -901,25 +1064,25 @@ class y {
|
|
|
901
1064
|
* @returns The updated response parameters, potentially with tool call outputs added to the input.
|
|
902
1065
|
*/
|
|
903
1066
|
async onResponseReceived(t, o, e) {
|
|
904
|
-
const r =
|
|
1067
|
+
const r = e?.output ?? [], s = m.extractFunctionCalls(r);
|
|
905
1068
|
if (!s.length)
|
|
906
1069
|
return o;
|
|
907
|
-
const
|
|
908
|
-
for (let
|
|
909
|
-
const
|
|
910
|
-
if (t.toolRegistry.isLocalTool(
|
|
1070
|
+
const l = [];
|
|
1071
|
+
for (let i = 0; i < s.length; i++) {
|
|
1072
|
+
const c = s[i];
|
|
1073
|
+
if (t.toolRegistry.isLocalTool(c.name))
|
|
911
1074
|
continue;
|
|
912
|
-
const
|
|
1075
|
+
const a = {
|
|
913
1076
|
responseParams: o,
|
|
914
1077
|
response: e,
|
|
915
|
-
toolCallIndex:
|
|
1078
|
+
toolCallIndex: i,
|
|
916
1079
|
totalToolCalls: s.length
|
|
917
|
-
},
|
|
918
|
-
|
|
1080
|
+
}, d = await this.executeToolCall(t, c, a);
|
|
1081
|
+
l.push(d);
|
|
919
1082
|
}
|
|
920
1083
|
return {
|
|
921
1084
|
...o,
|
|
922
|
-
input: [...o.input, ...
|
|
1085
|
+
input: [...o.input, ...l]
|
|
923
1086
|
};
|
|
924
1087
|
}
|
|
925
1088
|
/**
|
|
@@ -931,12 +1094,10 @@ class y {
|
|
|
931
1094
|
return !1;
|
|
932
1095
|
}
|
|
933
1096
|
}
|
|
934
|
-
class
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
n(this, "name", "Finish Turn Plugin");
|
|
939
|
-
}
|
|
1097
|
+
class M {
|
|
1098
|
+
description = "A plugin to ensure the interaction loop can be finished.";
|
|
1099
|
+
id = "finish-turn-plugin";
|
|
1100
|
+
name = "Finish Turn Plugin";
|
|
940
1101
|
/**
|
|
941
1102
|
* Before sending a message, this hook adds an instruction to the LLM to include a
|
|
942
1103
|
* specific marker (`__awaiting_user_response__`) when it expects a user response.
|
|
@@ -990,51 +1151,60 @@ class P {
|
|
|
990
1151
|
return o;
|
|
991
1152
|
}
|
|
992
1153
|
}
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
conversations to the most appropriate specialized booth configuration.
|
|
998
|
-
`,
|
|
999
|
-
description: `
|
|
1000
|
-
You are the orchestration layer responsible for determining which booth configuration
|
|
1001
|
-
should be active based on user needs. Focus exclusively on routing - do not answer
|
|
1002
|
-
questions or provide information directly to users.
|
|
1003
|
-
|
|
1004
|
-
[ROUTING STRATEGY]
|
|
1005
|
-
- Analyze user request and route to the most appropriate specialized booth immediately
|
|
1006
|
-
- This booth is only active for initial routing or when explicitly routed back to
|
|
1007
|
-
- Once routed, the target booth handles the conversation until completion or re-routing
|
|
1008
|
-
|
|
1009
|
-
[ROUTING TARGETS]
|
|
1010
|
-
- Ambiguous requests → Ask for clarification, then route appropriately
|
|
1011
|
-
|
|
1012
|
-
[CORE PRINCIPLES]
|
|
1013
|
-
- Maintain illusion of single, continuous assistant
|
|
1014
|
-
- Never reference booths, tools, or system mechanics to users
|
|
1015
|
-
- Silent routing is preferred when intent is clear
|
|
1016
|
-
- Only speak to users when clarification is absolutely necessary
|
|
1017
|
-
|
|
1018
|
-
[ROUTING BEHAVIOR]
|
|
1019
|
-
- Clear intent: Route silently using route_to_booth() - do NOT respond to user
|
|
1020
|
-
- Ambiguous intent: Ask user for clarification, then route once clarified
|
|
1021
|
-
- Never respond to user AND route - it's either respond OR route, not both
|
|
1022
|
-
|
|
1023
|
-
[BEHAVIOR EXAMPLES]
|
|
1024
|
-
- User: "How do I test my number?" → route_to_booth({ targetBooth: 'page-router-booth' })
|
|
1025
|
-
- User: "I need help" → "What specifically would you like help with?" → then route based on response
|
|
1026
|
-
`
|
|
1027
|
-
};
|
|
1028
|
-
function L(i, t) {
|
|
1029
|
-
const o = new v(t), e = new _(), r = new d();
|
|
1030
|
-
return new S({
|
|
1031
|
-
llmAdapter: i,
|
|
1154
|
+
function P(n, t) {
|
|
1155
|
+
const o = new R(t), e = new _(), r = new p();
|
|
1156
|
+
return new A({
|
|
1157
|
+
llmAdapter: n,
|
|
1032
1158
|
booths: o,
|
|
1033
1159
|
tools: e,
|
|
1034
1160
|
boothPlugins: r
|
|
1035
1161
|
});
|
|
1036
1162
|
}
|
|
1037
|
-
class
|
|
1163
|
+
class A {
|
|
1164
|
+
/**
|
|
1165
|
+
* Represents a registry that maintains a collection of plugins for a booth system.
|
|
1166
|
+
* The boothPluginRegistry is used to manage and access plugins that enhance
|
|
1167
|
+
* or extend the booth's behavior or features.
|
|
1168
|
+
*
|
|
1169
|
+
* This variable is intended to provide a central location for plugin registration,
|
|
1170
|
+
* retrieval, and management.
|
|
1171
|
+
*
|
|
1172
|
+
* @type {BoothPluginRegistry}
|
|
1173
|
+
*/
|
|
1174
|
+
boothPluginRegistry;
|
|
1175
|
+
/**
|
|
1176
|
+
* Registry for managing booth configurations across the system.
|
|
1177
|
+
* This registry maintains a collection of booth definitions that can be
|
|
1178
|
+
* accessed by their unique identifiers.
|
|
1179
|
+
*
|
|
1180
|
+
* @type {BoothRegistry}
|
|
1181
|
+
*/
|
|
1182
|
+
boothRegistry;
|
|
1183
|
+
/**
|
|
1184
|
+
* Primary processor for handling interactions between users and the booth system.
|
|
1185
|
+
* Responsible for sending messages to the LLM, processing responses, and managing
|
|
1186
|
+
* the interaction loop through plugins.
|
|
1187
|
+
*
|
|
1188
|
+
* @type {InteractionProcessor}
|
|
1189
|
+
*/
|
|
1190
|
+
callProcessor;
|
|
1191
|
+
/**
|
|
1192
|
+
* Registry dedicated to system-level plugins that are always available.
|
|
1193
|
+
* This includes core functionality plugins like conversation history and context providers,
|
|
1194
|
+
* as well as any user-defined plugins from the boothPluginRegistry.
|
|
1195
|
+
*
|
|
1196
|
+
* @type {BoothPluginRegistry}
|
|
1197
|
+
*/
|
|
1198
|
+
systemPluginsRegistry;
|
|
1199
|
+
/**
|
|
1200
|
+
* A variable that represents a registry for managing and maintaining a collection of tools.
|
|
1201
|
+
* `toolRegistry` is an instance of the `ToolRegistry` class, which provides functionalities
|
|
1202
|
+
* for adding, removing, and retrieving tools.
|
|
1203
|
+
*
|
|
1204
|
+
* The `ToolRegistry` class typically serves as a centralized storage or management
|
|
1205
|
+
* solution for tools that are used in a specific context or application.
|
|
1206
|
+
*/
|
|
1207
|
+
toolRegistry;
|
|
1038
1208
|
/**
|
|
1039
1209
|
* Initializes a new instance of the CoreBooth class.
|
|
1040
1210
|
* Sets up the plugin registries, system plugins, and interaction processor.
|
|
@@ -1045,62 +1215,24 @@ class S {
|
|
|
1045
1215
|
* @param {ToolRegistry} options.tools - Registry containing tool configurations
|
|
1046
1216
|
*/
|
|
1047
1217
|
constructor(t) {
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
*/
|
|
1058
|
-
n(this, "boothPluginRegistry");
|
|
1059
|
-
/**
|
|
1060
|
-
* Registry for managing booth configurations across the system.
|
|
1061
|
-
* This registry maintains a collection of booth definitions that can be
|
|
1062
|
-
* accessed by their unique identifiers.
|
|
1063
|
-
*
|
|
1064
|
-
* @type {BoothRegistry}
|
|
1065
|
-
*/
|
|
1066
|
-
n(this, "boothRegistry");
|
|
1067
|
-
/**
|
|
1068
|
-
* Primary processor for handling interactions between users and the booth system.
|
|
1069
|
-
* Responsible for sending messages to the LLM, processing responses, and managing
|
|
1070
|
-
* the interaction loop through plugins.
|
|
1071
|
-
*
|
|
1072
|
-
* @type {InteractionProcessor}
|
|
1073
|
-
*/
|
|
1074
|
-
n(this, "callProcessor");
|
|
1075
|
-
/**
|
|
1076
|
-
* Registry dedicated to system-level plugins that are always available.
|
|
1077
|
-
* This includes core functionality plugins like conversation history and context providers,
|
|
1078
|
-
* as well as any user-defined plugins from the boothPluginRegistry.
|
|
1079
|
-
*
|
|
1080
|
-
* @type {BoothPluginRegistry}
|
|
1081
|
-
*/
|
|
1082
|
-
n(this, "systemPluginsRegistry");
|
|
1083
|
-
/**
|
|
1084
|
-
* A variable that represents a registry for managing and maintaining a collection of tools.
|
|
1085
|
-
* `toolRegistry` is an instance of the `ToolRegistry` class, which provides functionalities
|
|
1086
|
-
* for adding, removing, and retrieving tools.
|
|
1087
|
-
*
|
|
1088
|
-
* The `ToolRegistry` class typically serves as a centralized storage or management
|
|
1089
|
-
* solution for tools that are used in a specific context or application.
|
|
1090
|
-
*/
|
|
1091
|
-
n(this, "toolRegistry");
|
|
1092
|
-
if (this.boothPluginRegistry = (t == null ? void 0 : t.boothPlugins) ?? new d(), this.boothRegistry = t.booths, this.toolRegistry = (t == null ? void 0 : t.tools) ?? new _(), this.boothRegistry.isMultiBoothMode) {
|
|
1093
|
-
this.boothRegistry.registerBooth(R), this.boothRegistry.setCurrentContextId(R.id);
|
|
1094
|
-
const o = w(this.boothRegistry);
|
|
1218
|
+
if (this.boothPluginRegistry = t?.boothPlugins ?? new p(), this.boothRegistry = t.booths, this.toolRegistry = t?.tools ?? new _(), this.boothRegistry.setMultiBoothModeCallbacks(
|
|
1219
|
+
() => {
|
|
1220
|
+
const o = y(this.boothRegistry);
|
|
1221
|
+
this.toolRegistry.registerTools([o]);
|
|
1222
|
+
},
|
|
1223
|
+
() => {
|
|
1224
|
+
}
|
|
1225
|
+
), this.boothRegistry.isMultiBoothMode) {
|
|
1226
|
+
const o = y(this.boothRegistry);
|
|
1095
1227
|
this.toolRegistry.registerTools([o]);
|
|
1096
1228
|
}
|
|
1097
|
-
this.systemPluginsRegistry = new
|
|
1098
|
-
new
|
|
1099
|
-
new
|
|
1229
|
+
this.systemPluginsRegistry = new p(), this.systemPluginsRegistry.registerPlugins([
|
|
1230
|
+
new v(t.sessionHistory),
|
|
1231
|
+
new E(),
|
|
1100
1232
|
new x(),
|
|
1101
|
-
new
|
|
1102
|
-
new
|
|
1103
|
-
]), this.systemPluginsRegistry.registerPlugins(this.boothPluginRegistry.getPlugins()), this.callProcessor = new
|
|
1233
|
+
new m(),
|
|
1234
|
+
new M()
|
|
1235
|
+
]), this.systemPluginsRegistry.registerPlugins(this.boothPluginRegistry.getPlugins()), this.callProcessor = new B(
|
|
1104
1236
|
this.boothRegistry,
|
|
1105
1237
|
this.systemPluginsRegistry,
|
|
1106
1238
|
this.toolRegistry,
|
|
@@ -1109,16 +1241,16 @@ class S {
|
|
|
1109
1241
|
}
|
|
1110
1242
|
}
|
|
1111
1243
|
export {
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1244
|
+
p as BoothPluginRegistry,
|
|
1245
|
+
R as BoothRegistry,
|
|
1246
|
+
E as ContextProviderPlugin,
|
|
1247
|
+
v as ConversationHistoryPlugin,
|
|
1248
|
+
A as CoreBooth,
|
|
1249
|
+
M as FinishTurnPlugin,
|
|
1250
|
+
B as InteractionProcessor,
|
|
1251
|
+
m as ToolExecutorPlugin,
|
|
1120
1252
|
x as ToolProviderPlugin,
|
|
1121
1253
|
_ as ToolRegistry,
|
|
1122
|
-
|
|
1123
|
-
|
|
1254
|
+
P as createCoreBooth,
|
|
1255
|
+
y as createRouteToBoothTool
|
|
1124
1256
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "booths",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.js",
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
18
|
"scripts": {
|
|
19
|
+
"build:pack": "npm install --package-lock-only && npm run build && npm pack",
|
|
19
20
|
"build": "tsc && vite build",
|
|
20
21
|
"format": "prettier --write \"src/**/*.{js,ts,json,css,scss,md}\"",
|
|
21
22
|
"typecheck": "tsc --noEmit"
|