@sprucelabs/sprucebot-llm 15.1.9 → 15.1.11

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.
@@ -25,8 +25,10 @@ export default class ResponseParserV2 {
25
25
  }
26
26
  const hasState = response.includes('@updateState');
27
27
  if (hasState && message) {
28
- const stateMatch = message.match(/@updateState\s+({[\s\S]*?})\n?/);
29
- if (stateMatch && stateMatch[1]) {
28
+ const stateMatches = [
29
+ ...message.matchAll(/@updateState\s+({[\s\S]*?})\n?/g),
30
+ ];
31
+ for (const stateMatch of stateMatches) {
30
32
  try {
31
33
  state = JSON.parse(stateMatch[1]);
32
34
  }
@@ -103,6 +105,7 @@ export default class ResponseParserV2 {
103
105
  return `Updating state works similar to all function calls. Use the following syntax:
104
106
  @updateState { "field1": "value1", "field2": "value2" }
105
107
  Make sure to json encode only the fields you want to change. You can update state once and do it at the end of any messages you send. IMPORTANT: JSON must be on a single line. Do NOT use multi-line or formatted JSON.
108
+ Your user-facing message is always sent to the user, even if @updateState fails. If @updateState fails later, do not repeat the same message. Only send the specific @updateState needed to fix the missing state change.
106
109
  Good example:
107
110
  @updateState { "favoriteColor": "blue", "firstName": "Taylor" }
108
111
  Bad examples:
@@ -117,6 +120,7 @@ Bad examples:
117
120
  return `A function call is done using the following syntax:
118
121
  @callback { "name": "callbackName", "options": {} }
119
122
  Make sure to json encode the options and include the name of the callback you want to call. You can call as many callbacks as you want in a single response by including multiple @callback lines. IMPORTANT: JSON must be on a single line. Do NOT use multi-line or formatted JSON. Also, do NOT call something like @myCallback. You would call it like this: @callback { "name": "myCallback", "options": {} }
123
+ Your user-facing message is always sent to the user, even if a callback fails. Successful callbacks have already run successfully. If a callback fails later, do not repeat the same message and do not repeat successful callbacks. Only call the specific callback needed to fix the failed gap.
120
124
  Good example:
121
125
  @callback { "name": "lookupWeather", "options": { "zip": "80524" } }
122
126
  Bad examples:
@@ -20,8 +20,10 @@ class ResponseParserV2 {
20
20
  }
21
21
  const hasState = response.includes('@updateState');
22
22
  if (hasState && message) {
23
- const stateMatch = message.match(/@updateState\s+({[\s\S]*?})\n?/);
24
- if (stateMatch && stateMatch[1]) {
23
+ const stateMatches = [
24
+ ...message.matchAll(/@updateState\s+({[\s\S]*?})\n?/g),
25
+ ];
26
+ for (const stateMatch of stateMatches) {
25
27
  try {
26
28
  state = JSON.parse(stateMatch[1]);
27
29
  }
@@ -95,6 +97,7 @@ class ResponseParserV2 {
95
97
  return `Updating state works similar to all function calls. Use the following syntax:
96
98
  @updateState { "field1": "value1", "field2": "value2" }
97
99
  Make sure to json encode only the fields you want to change. You can update state once and do it at the end of any messages you send. IMPORTANT: JSON must be on a single line. Do NOT use multi-line or formatted JSON.
100
+ Your user-facing message is always sent to the user, even if @updateState fails. If @updateState fails later, do not repeat the same message. Only send the specific @updateState needed to fix the missing state change.
98
101
  Good example:
99
102
  @updateState { "favoriteColor": "blue", "firstName": "Taylor" }
100
103
  Bad examples:
@@ -109,6 +112,7 @@ Bad examples:
109
112
  return `A function call is done using the following syntax:
110
113
  @callback { "name": "callbackName", "options": {} }
111
114
  Make sure to json encode the options and include the name of the callback you want to call. You can call as many callbacks as you want in a single response by including multiple @callback lines. IMPORTANT: JSON must be on a single line. Do NOT use multi-line or formatted JSON. Also, do NOT call something like @myCallback. You would call it like this: @callback { "name": "myCallback", "options": {} }
115
+ Your user-facing message is always sent to the user, even if a callback fails. Successful callbacks have already run successfully. If a callback fails later, do not repeat the same message and do not repeat successful callbacks. Only call the specific callback needed to fix the failed gap.
112
116
  Good example:
113
117
  @callback { "name": "lookupWeather", "options": { "zip": "80524" } }
114
118
  Bad examples:
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "eta"
9
9
  ]
10
10
  },
11
- "version": "15.1.9",
11
+ "version": "15.1.11",
12
12
  "files": [
13
13
  "build"
14
14
  ],