wingbot 3.73.3 → 3.73.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wingbot",
3
- "version": "3.73.3",
3
+ "version": "3.73.4",
4
4
  "description": "Enterprise Messaging Bot Conversation Engine",
5
5
  "main": "index.js",
6
6
  "type": "commonjs",
package/src/Plugins.js CHANGED
@@ -131,9 +131,22 @@ class Plugins {
131
131
  name,
132
132
  paramsData = {},
133
133
  items = new Map(),
134
- context = { isLastIndex: true, configuration: {} }
134
+ context = {}
135
135
  ) {
136
136
  let useItems = items;
137
+ const {
138
+ isLastIndex = true,
139
+ configuration = {},
140
+ router = new Router(),
141
+ ...rest
142
+ } = context;
143
+
144
+ const ctx = {
145
+ isLastIndex,
146
+ configuration,
147
+ router,
148
+ ...rest
149
+ };
137
150
 
138
151
  if (!(items instanceof Map)) {
139
152
  // @ts-ignore
@@ -156,15 +169,15 @@ class Plugins {
156
169
  );
157
170
  }
158
171
 
159
- const cleanParams = Object.entries(paramsData)
160
- .filter(([, e]) => e !== null && e !== undefined)
161
- .map(([k, e]) => ({ [k]: e }))
162
- .reduce(Object.assign, {});
172
+ const cleanParams = Object.fromEntries(
173
+ Object.entries(paramsData)
174
+ .filter(([, e]) => e !== null && e !== undefined)
175
+ );
163
176
 
164
177
  const customFn = this.getPluginFactory(
165
178
  name,
166
179
  cleanParams,
167
- context.configuration,
180
+ configuration,
168
181
  context.defaultPlugin
169
182
  );
170
183
 
@@ -174,9 +187,7 @@ class Plugins {
174
187
  return new RouterWrap(customFn, useItems, cleanParams);
175
188
  }
176
189
 
177
- const { router = new Router() } = context;
178
-
179
- return wrapPluginFunction(customFn, cleanParams, useItems, context, router);
190
+ return wrapPluginFunction(customFn, cleanParams, useItems, ctx, router);
180
191
  }
181
192
 
182
193
  code (name, factoryFn = null) {
package/src/Tester.js CHANGED
@@ -651,8 +651,13 @@ class Tester {
651
651
  debug (full = false, showPrivateKeys = false) {
652
652
  // eslint-disable-next-line no-console
653
653
  console.log(
654
- '\n===== actions =====\n',
655
- this._actionsDebug(true),
654
+ '\n====== state ======\n',
655
+ Object.fromEntries(
656
+ Object.entries(this.getState().state)
657
+ .filter((e) => showPrivateKeys || !e[0].startsWith('_'))
658
+ ),
659
+ '\n------- LLM -------\n',
660
+ ...PromptAssert.debug(this.prompts, full, true),
656
661
  '\n---- responses ----\n',
657
662
  inspect(
658
663
  this.responses.map(({ messaging_type: m, recipient, ...o }) => o),
@@ -660,13 +665,8 @@ class Tester {
660
665
  null,
661
666
  true
662
667
  ),
663
- '\n------ state ------\n',
664
- Object.fromEntries(
665
- Object.entries(this.getState().state)
666
- .filter((e) => showPrivateKeys || !e[0].startsWith('_'))
667
- ),
668
- '\n------- LLM -------\n',
669
- ...PromptAssert.debug(this.prompts, full, true),
668
+ '\n----- actions -----\n',
669
+ this._actionsDebug(true),
670
670
  '\n===================\n'
671
671
  );
672
672
  }
@@ -13,6 +13,8 @@
13
13
  /**
14
14
  * @typedef {object} StateCondition
15
15
  * @prop {string} [search]
16
+ * @prop {string[]} [senderIds]
17
+ * @prop {string} [pageId]
16
18
  */
17
19
 
18
20
  /**
@@ -114,13 +116,22 @@ class MemoryStateStorage {
114
116
  // const matches = conditionKeys
115
117
  // .every(k => state[k] === condition[k]);
116
118
 
117
- const matches = !condition.search
118
- || condition.search === state.senderId;
119
+ let matches = true;
119
120
 
120
- if (!matches) {
121
- return false;
121
+ if (condition.search) {
122
+ matches = matches && condition.search === state.senderId;
123
+ }
124
+
125
+ if (Array.isArray(condition.senderIds)) {
126
+ matches = matches && condition.senderIds.includes(state.senderId);
122
127
  }
123
128
 
129
+ if (typeof condition.pageId === 'string') {
130
+ matches = matches && condition.pageId === state.pageId;
131
+ }
132
+
133
+ if (!matches) return false;
134
+
124
135
  if (limit !== null && filtered >= limit) {
125
136
  hasNext = true;
126
137
  return false;