@sprucelabs/sprucebot-llm 18.1.4 → 18.1.5

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.
@@ -136,8 +136,12 @@ function extractCallbackSpans(message) {
136
136
  closeParen = j;
137
137
  }
138
138
  else {
139
- re.lastIndex = openParen + 1;
140
- continue;
139
+ closeParen = message.indexOf(')', i);
140
+ if (closeParen === -1) {
141
+ re.lastIndex = openParen + 1;
142
+ continue;
143
+ }
144
+ argsJson = message.slice(i, closeParen);
141
145
  }
142
146
  let end = closeParen + 1;
143
147
  // Include trailing newline after the call when present (common LLM layout)
@@ -247,6 +251,16 @@ export default class ResponseParserV2 {
247
251
  });
248
252
  continue;
249
253
  }
254
+ if (options !== undefined &&
255
+ (options === null ||
256
+ Array.isArray(options) ||
257
+ typeof options !== 'object')) {
258
+ callbackResults += this.renderCallbackResults({
259
+ name,
260
+ error: 'Arguments not valid JSON',
261
+ });
262
+ continue;
263
+ }
250
264
  const callback = callbacks === null || callbacks === void 0 ? void 0 : callbacks[name];
251
265
  if (!callback) {
252
266
  callbackResults += this.renderCallbackResults({
@@ -133,8 +133,12 @@ function extractCallbackSpans(message) {
133
133
  closeParen = j;
134
134
  }
135
135
  else {
136
- re.lastIndex = openParen + 1;
137
- continue;
136
+ closeParen = message.indexOf(')', i);
137
+ if (closeParen === -1) {
138
+ re.lastIndex = openParen + 1;
139
+ continue;
140
+ }
141
+ argsJson = message.slice(i, closeParen);
138
142
  }
139
143
  let end = closeParen + 1;
140
144
  // Include trailing newline after the call when present (common LLM layout)
@@ -240,6 +244,16 @@ class ResponseParserV2 {
240
244
  });
241
245
  continue;
242
246
  }
247
+ if (options !== undefined &&
248
+ (options === null ||
249
+ Array.isArray(options) ||
250
+ typeof options !== 'object')) {
251
+ callbackResults += this.renderCallbackResults({
252
+ name,
253
+ error: 'Arguments not valid JSON',
254
+ });
255
+ continue;
256
+ }
243
257
  const callback = callbacks?.[name];
244
258
  if (!callback) {
245
259
  callbackResults += this.renderCallbackResults({
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "eta"
9
9
  ]
10
10
  },
11
- "version": "18.1.4",
11
+ "version": "18.1.5",
12
12
  "files": [
13
13
  "build"
14
14
  ],