@sprucelabs/sprucebot-llm 11.3.1 → 11.3.3

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.
@@ -65,9 +65,9 @@ class ResponseParser {
65
65
  matchedCallback,
66
66
  });
67
67
  }
68
- const { match, fullMatch } = this.parseState(message);
69
- if (match && fullMatch) {
70
- message = message.replace(fullMatch, '').trim();
68
+ const { match, regex } = this.parseState(message);
69
+ if (match && regex) {
70
+ message = message.replace(regex, '').trim();
71
71
  state = JSON.parse(match);
72
72
  }
73
73
  return {
@@ -97,10 +97,10 @@ class ResponseParser {
97
97
  }
98
98
  parseState(message) {
99
99
  const ESCAPED_BOUNDARY = STATE_BOUNDARY.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
100
- const searchRegex = new RegExp(`${ESCAPED_BOUNDARY}(.*?)${ESCAPED_BOUNDARY}`);
101
- const stateMatches = message.match(searchRegex);
102
- const match = stateMatches === null || stateMatches === void 0 ? void 0 : stateMatches[1];
103
- return { match, fullMatch: stateMatches === null || stateMatches === void 0 ? void 0 : stateMatches[0] };
100
+ const searchRegex = new RegExp(`((?:\\r?\\n)+)?${ESCAPED_BOUNDARY}\\s*(.*?)\\s*${ESCAPED_BOUNDARY}((?:\\r?\\n)+)?`, 's');
101
+ const stateMatches = searchRegex.exec(message);
102
+ const match = stateMatches === null || stateMatches === void 0 ? void 0 : stateMatches[2];
103
+ return { match, regex: match ? searchRegex : undefined };
104
104
  }
105
105
  assertAtMostOneCallback(invocations) {
106
106
  if (invocations > 1) {
@@ -59,9 +59,9 @@ class ResponseParser {
59
59
  matchedCallback,
60
60
  });
61
61
  }
62
- const { match, fullMatch } = this.parseState(message);
63
- if (match && fullMatch) {
64
- message = message.replace(fullMatch, '').trim();
62
+ const { match, regex } = this.parseState(message);
63
+ if (match && regex) {
64
+ message = message.replace(regex, '').trim();
65
65
  state = JSON.parse(match);
66
66
  }
67
67
  return {
@@ -87,10 +87,10 @@ class ResponseParser {
87
87
  }
88
88
  parseState(message) {
89
89
  const ESCAPED_BOUNDARY = templates_1.STATE_BOUNDARY.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
90
- const searchRegex = new RegExp(`${ESCAPED_BOUNDARY}(.*?)${ESCAPED_BOUNDARY}`);
91
- const stateMatches = message.match(searchRegex);
92
- const match = stateMatches?.[1];
93
- return { match, fullMatch: stateMatches?.[0] };
90
+ const searchRegex = new RegExp(`((?:\\r?\\n)+)?${ESCAPED_BOUNDARY}\\s*(.*?)\\s*${ESCAPED_BOUNDARY}((?:\\r?\\n)+)?`, 's');
91
+ const stateMatches = searchRegex.exec(message);
92
+ const match = stateMatches?.[2];
93
+ return { match, regex: match ? searchRegex : undefined };
94
94
  }
95
95
  assertAtMostOneCallback(invocations) {
96
96
  if (invocations > 1) {
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "eta"
9
9
  ]
10
10
  },
11
- "version": "11.3.1",
11
+ "version": "11.3.3",
12
12
  "files": [
13
13
  "build"
14
14
  ],