wormclaude 1.0.124 → 1.0.125
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/dist/inlinetools.js +55 -2
- package/dist/theme.js +1 -1
- package/package.json +1 -1
package/dist/inlinetools.js
CHANGED
|
@@ -7,6 +7,9 @@
|
|
|
7
7
|
// Bu modül o gömülü çağrıları kurtarır — upstream yapısal tool_call vermediğinde YEDEK.
|
|
8
8
|
import { safeJsonParse } from './safejson.js';
|
|
9
9
|
const ARG_KEYS = ['arguments', 'parameters', 'input', 'args', 'params'];
|
|
10
|
+
// Model araç adını JSON DIŞINA koyabiliyor: `Bash {"command":...}` / `Write {"file_path":...}`.
|
|
11
|
+
const _TOOLS = 'Bash|PowerShell|Read|Write|Edit|Glob|Grep|WebFetch|WebSearch|Sleep|TaskOutput';
|
|
12
|
+
const TOOL_PREFIX_RE = new RegExp('(?:^|[\\n>*`\\s])(' + _TOOLS + ')\\s*\\{');
|
|
10
13
|
function toToolCall(obj, i) {
|
|
11
14
|
if (!obj || typeof obj !== 'object')
|
|
12
15
|
return null;
|
|
@@ -73,8 +76,8 @@ function extractTopLevelJsonObjects(text) {
|
|
|
73
76
|
* (<tool_call>, ```json) veya mesajın TAMAMI tek JSON çağrısıysa onu alır. */
|
|
74
77
|
export function recoverInlineToolCalls(text) {
|
|
75
78
|
const t = (text || '').trim();
|
|
76
|
-
// JSON
|
|
77
|
-
if (!t || (!t.includes('"name"') && !t.includes('"tool"') && !t.includes('"function"') && !/AskUserQuestion/i.test(t)))
|
|
79
|
+
// JSON/prose/ToolName{…} çağrısı yoksa erken çık.
|
|
80
|
+
if (!t || (!t.includes('"name"') && !t.includes('"tool"') && !t.includes('"function"') && !/AskUserQuestion/i.test(t) && !TOOL_PREFIX_RE.test(t)))
|
|
78
81
|
return [];
|
|
79
82
|
const out = [];
|
|
80
83
|
const seen = new Set();
|
|
@@ -126,6 +129,20 @@ export function recoverInlineToolCalls(text) {
|
|
|
126
129
|
push({ name: 'AskUserQuestion', arguments: { question, options } });
|
|
127
130
|
}
|
|
128
131
|
}
|
|
132
|
+
// 5) "ToolName { ...args... }" — model araç adını JSON DIŞINA koyuyor (Bash {"command":...}).
|
|
133
|
+
// Args doğrudan obje (arguments sarmalı yok) → {name: ToolName, arguments: {...}}.
|
|
134
|
+
if (!out.length) {
|
|
135
|
+
const re = new RegExp('(' + _TOOLS + ')\\s*(\\{)', 'g');
|
|
136
|
+
let mm;
|
|
137
|
+
while ((mm = re.exec(t)) !== null) {
|
|
138
|
+
const objs = extractTopLevelJsonObjects(t.slice(mm.index + mm[1].length));
|
|
139
|
+
if (objs.length) {
|
|
140
|
+
const args = safeJsonParse(objs[0], null);
|
|
141
|
+
if (args && typeof args === 'object' && !Array.isArray(args))
|
|
142
|
+
push({ name: mm[1], arguments: args });
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
129
146
|
return out;
|
|
130
147
|
}
|
|
131
148
|
/** Modelin komut/çıktıyı TEKRAR yazdığı kod-bloklarını siler (```plaintext/bash/http/console…).
|
|
@@ -154,5 +171,41 @@ export function stripInlineToolCalls(text) {
|
|
|
154
171
|
}
|
|
155
172
|
// AskUserQuestion prose biçimi (interaktif seçiciye çevrildi → metni gizle).
|
|
156
173
|
s = s.replace(/AskUserQuestion[\s\S]*?\[[^\]]*\]\s*/gi, '');
|
|
174
|
+
// ToolName {…} biçimi (Bash {"command":...}) — adı + ardından gelen dengeli {…} bloğunu sil.
|
|
175
|
+
{
|
|
176
|
+
const re = new RegExp('(' + _TOOLS + ')\\s*\\{', 'g');
|
|
177
|
+
let mm;
|
|
178
|
+
const spans = [];
|
|
179
|
+
while ((mm = re.exec(s)) !== null) {
|
|
180
|
+
let depth = 0, inStr = false, esc = false, end = -1;
|
|
181
|
+
for (let i = mm.index + mm[0].length - 1; i < s.length; i++) {
|
|
182
|
+
const c = s[i];
|
|
183
|
+
if (inStr) {
|
|
184
|
+
if (esc)
|
|
185
|
+
esc = false;
|
|
186
|
+
else if (c === '\\')
|
|
187
|
+
esc = true;
|
|
188
|
+
else if (c === '"')
|
|
189
|
+
inStr = false;
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
if (c === '"')
|
|
193
|
+
inStr = true;
|
|
194
|
+
else if (c === '{')
|
|
195
|
+
depth++;
|
|
196
|
+
else if (c === '}') {
|
|
197
|
+
depth--;
|
|
198
|
+
if (depth === 0) {
|
|
199
|
+
end = i + 1;
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
if (end > 0)
|
|
205
|
+
spans.push([mm.index, end]);
|
|
206
|
+
}
|
|
207
|
+
for (let i = spans.length - 1; i >= 0; i--)
|
|
208
|
+
s = s.slice(0, spans[i][0]) + s.slice(spans[i][1]);
|
|
209
|
+
}
|
|
157
210
|
return s.trim();
|
|
158
211
|
}
|
package/dist/theme.js
CHANGED