prior-cli 1.6.4 → 1.6.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.
Files changed (2) hide show
  1. package/lib/agent.js +19 -0
  2. package/package.json +1 -1
package/lib/agent.js CHANGED
@@ -77,6 +77,21 @@ function parseToolCalls(text) {
77
77
  } catch { /* skip */ }
78
78
  }
79
79
 
80
+ // Fallback: unclosed <tool>{...} (no closing </tool> — some models omit it)
81
+ const reUnclosed = /<tool>(\{[\s\S]*?\})\s*(?=$|\n|<)/g;
82
+ while ((m = reUnclosed.exec(text)) !== null) {
83
+ const alreadyCaptured = calls.some(c => m.index >= c.offset && m.index < c.offset + c.raw.length);
84
+ if (alreadyCaptured) continue;
85
+ try {
86
+ const fixed = fixJsonLiterals(m[1].trim());
87
+ const parsed = JSON.parse(fixed);
88
+ if (parsed && typeof parsed.name === 'string') {
89
+ const { name, args, ...rest } = parsed;
90
+ calls.push({ raw: m[0], offset: m.index, name, args: args || (Object.keys(rest).length > 0 ? rest : {}) });
91
+ }
92
+ } catch { /* skip */ }
93
+ }
94
+
80
95
  // Primary variant: <tool name="X">{"args"}</tool> (name as attribute — used by some models)
81
96
  const reAttr = /<tool\s+name="([^"]+)"[^>]*>([\s\S]*?)<\/tool>/g;
82
97
  while ((m = reAttr.exec(text)) !== null) {
@@ -188,6 +203,10 @@ function truncateAtFakeTurn(text) {
188
203
  function stripToolTags(text) {
189
204
  // <tool>...</tool>
190
205
  let out = text.replace(/<tool>[\s\S]*?<\/tool>/gi, '');
206
+ // Unclosed <tool>{...} (no closing tag)
207
+ out = out.replace(/<tool>\{[\s\S]*?\}\s*/gi, '');
208
+ // Bare <tool> with no content following
209
+ out = out.replace(/<\/?tool>/gi, '');
191
210
  const namesPattern = TOOL_NAMES.join('|');
192
211
  // <tool_name ...>...</tool_name> (with or without attributes/JSON)
193
212
  out = out.replace(new RegExp(`<(?:${namesPattern})[^>]*>[\\s\\S]*?<\\/(?:${namesPattern})>`, 'gi'), '');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prior-cli",
3
- "version": "1.6.4",
3
+ "version": "1.6.5",
4
4
  "description": "Prior Network AI — command-line interface",
5
5
  "bin": {
6
6
  "prior": "bin/prior.js"