booths 1.1.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 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.
@@ -384,6 +393,15 @@ export declare class BoothRegistry {
384
393
  * @returns The booth configuration if found, undefined otherwise
385
394
  */
386
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[];
387
405
  /**
388
406
  * Returns all registered booth configurations.
389
407
  *
@@ -986,6 +1004,15 @@ export declare class ToolRegistry {
986
1004
  * @returns The tool instance if found, undefined otherwise
987
1005
  */
988
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[];
989
1016
  getGlobalTools(): ToolModule[];
990
1017
  /**
991
1018
  * Returns all registered tools as an array.
package/dist/index.js CHANGED
@@ -41,6 +41,24 @@ class p {
41
41
  getPluginById(t) {
42
42
  return this.plugins.find((o) => o.id === t);
43
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
+ }
44
62
  /**
45
63
  * Removes a plugin from the registry by its ID.
46
64
  * Throws an error if the plugin doesn't exist.
@@ -340,6 +358,24 @@ class R {
340
358
  getBoothById(t) {
341
359
  return this.booths[t];
342
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
+ }
343
379
  /**
344
380
  * Returns all registered booth configurations.
345
381
  *
@@ -706,11 +742,11 @@ class v {
706
742
  if (this.responseContainsBoothChange(e)) {
707
743
  const i = `Please summarize the following conversation history:
708
744
 
709
- ${JSON.stringify(this.sessionHistory)}`, d = (await A(t.llmAdapter, T).callProcessor.send(i)).output_text, g = s.filter((h) => "role" in h && h.role === "user").pop(), b = {
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 = {
710
746
  role: "developer",
711
747
  content: `A conversation summary up to this point: ${d}`
712
- }, _ = s.filter((h) => !("role" in h && h.role === "user" || "type" in h && h.type === "message"));
713
- this.sessionHistory = g ? [..._, b, g] : [..._, b], s = this.sessionHistory;
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;
714
750
  } else
715
751
  this.sessionHistory = s;
716
752
  return {
@@ -793,7 +829,7 @@ class E {
793
829
  return !1;
794
830
  }
795
831
  }
796
- class w {
832
+ class _ {
797
833
  tools;
798
834
  /**
799
835
  * Initializes an empty Map to store tools.
@@ -831,6 +867,22 @@ class w {
831
867
  throw new Error(`Tool with name ${t} is not registered.`);
832
868
  return o;
833
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
+ }
834
886
  getGlobalTools() {
835
887
  return Array.from(this.tools.values()).filter((t) => t.global);
836
888
  }
@@ -873,7 +925,7 @@ class w {
873
925
  this.tools.delete(t);
874
926
  }
875
927
  }
876
- function C(n) {
928
+ function I(n) {
877
929
  switch (n.type) {
878
930
  case "function":
879
931
  return `function:${n.name}`;
@@ -896,10 +948,10 @@ function C(n) {
896
948
  return `${n.type}:${JSON.stringify(n)}`;
897
949
  }
898
950
  }
899
- function I(n) {
951
+ function C(n) {
900
952
  const t = /* @__PURE__ */ new Set(), o = [];
901
953
  for (const e of n) {
902
- const r = C(e);
954
+ const r = I(e);
903
955
  t.has(r) || (t.add(r), o.push(e));
904
956
  }
905
957
  return o;
@@ -925,7 +977,7 @@ class x {
925
977
  i.push(a);
926
978
  }
927
979
  i.push(...t.toolRegistry.getGlobalTools());
928
- const c = I(i);
980
+ const c = C(i);
929
981
  return {
930
982
  ...o,
931
983
  tools: c
@@ -1099,16 +1151,16 @@ class M {
1099
1151
  return o;
1100
1152
  }
1101
1153
  }
1102
- function A(n, t) {
1103
- const o = new R(t), e = new w(), r = new p();
1104
- return new P({
1154
+ function P(n, t) {
1155
+ const o = new R(t), e = new _(), r = new p();
1156
+ return new A({
1105
1157
  llmAdapter: n,
1106
1158
  booths: o,
1107
1159
  tools: e,
1108
1160
  boothPlugins: r
1109
1161
  });
1110
1162
  }
1111
- class P {
1163
+ class A {
1112
1164
  /**
1113
1165
  * Represents a registry that maintains a collection of plugins for a booth system.
1114
1166
  * The boothPluginRegistry is used to manage and access plugins that enhance
@@ -1163,7 +1215,7 @@ class P {
1163
1215
  * @param {ToolRegistry} options.tools - Registry containing tool configurations
1164
1216
  */
1165
1217
  constructor(t) {
1166
- if (this.boothPluginRegistry = t?.boothPlugins ?? new p(), this.boothRegistry = t.booths, this.toolRegistry = t?.tools ?? new w(), this.boothRegistry.setMultiBoothModeCallbacks(
1218
+ if (this.boothPluginRegistry = t?.boothPlugins ?? new p(), this.boothRegistry = t.booths, this.toolRegistry = t?.tools ?? new _(), this.boothRegistry.setMultiBoothModeCallbacks(
1167
1219
  () => {
1168
1220
  const o = y(this.boothRegistry);
1169
1221
  this.toolRegistry.registerTools([o]);
@@ -1193,12 +1245,12 @@ export {
1193
1245
  R as BoothRegistry,
1194
1246
  E as ContextProviderPlugin,
1195
1247
  v as ConversationHistoryPlugin,
1196
- P as CoreBooth,
1248
+ A as CoreBooth,
1197
1249
  M as FinishTurnPlugin,
1198
1250
  B as InteractionProcessor,
1199
1251
  m as ToolExecutorPlugin,
1200
1252
  x as ToolProviderPlugin,
1201
- w as ToolRegistry,
1202
- A as createCoreBooth,
1253
+ _ as ToolRegistry,
1254
+ P as createCoreBooth,
1203
1255
  y as createRouteToBoothTool
1204
1256
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "booths",
3
3
  "private": false,
4
- "version": "1.1.0",
4
+ "version": "1.2.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.js",
@@ -16,7 +16,7 @@
16
16
  }
17
17
  },
18
18
  "scripts": {
19
- "build-pack": "npm install --package-lock-only && npm run build && npm pack",
19
+ "build:pack": "npm install --package-lock-only && npm run build && npm pack",
20
20
  "build": "tsc && vite build",
21
21
  "format": "prettier --write \"src/**/*.{js,ts,json,css,scss,md}\"",
22
22
  "typecheck": "tsc --noEmit"