wormclaude 1.0.127 → 1.0.128
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 +125 -2
- package/dist/theme.js +1 -1
- package/package.json +1 -1
package/dist/inlinetools.js
CHANGED
|
@@ -10,6 +10,97 @@ const ARG_KEYS = ['arguments', 'parameters', 'input', 'args', 'params'];
|
|
|
10
10
|
// Model araç adını JSON DIŞINA koyabiliyor: `Bash {"command":...}` / `Write {"file_path":...}`.
|
|
11
11
|
const _TOOLS = 'Bash|PowerShell|Read|Write|Edit|Glob|Grep|WebFetch|WebSearch|Sleep|TaskOutput';
|
|
12
12
|
const TOOL_PREFIX_RE = new RegExp('(?:^|[\\n>*`\\s])(' + _TOOLS + ')\\s*\\{');
|
|
13
|
+
// Fonksiyon-çağrı pseudo-syntax'i: `Write(file_path="...", content="""...""")`.
|
|
14
|
+
const TOOL_PAREN_RE = new RegExp('(' + _TOOLS + ')\\s*\\(');
|
|
15
|
+
// `key="val"` / `key='val'` / `key="""val"""` argümanlarını çözer (content çok-satırlı olabilir).
|
|
16
|
+
function _parseKwCall(s) {
|
|
17
|
+
const unesc = (str) => str.replace(/\\(["'\\/nrt])/g, (_m, c) => (c === 'n' ? '\n' : c === 'r' ? '\r' : c === 't' ? '\t' : c));
|
|
18
|
+
const args = {};
|
|
19
|
+
let i = 0;
|
|
20
|
+
const n = s.length;
|
|
21
|
+
let guard = 0;
|
|
22
|
+
while (i < n && guard++ < 20) {
|
|
23
|
+
while (i < n && /[\s,]/.test(s[i]))
|
|
24
|
+
i++;
|
|
25
|
+
if (i >= n || s[i] === ')')
|
|
26
|
+
break;
|
|
27
|
+
const km = /^([a-zA-Z_]\w*)\s*[:=]\s*/.exec(s.slice(i));
|
|
28
|
+
if (!km)
|
|
29
|
+
break;
|
|
30
|
+
i += km[0].length;
|
|
31
|
+
const key = km[1];
|
|
32
|
+
if (s.startsWith('"""', i)) {
|
|
33
|
+
const e = s.indexOf('"""', i + 3);
|
|
34
|
+
if (e < 0)
|
|
35
|
+
break;
|
|
36
|
+
args[key] = s.slice(i + 3, e);
|
|
37
|
+
i = e + 3;
|
|
38
|
+
}
|
|
39
|
+
else if (s.startsWith("'''", i)) {
|
|
40
|
+
const e = s.indexOf("'''", i + 3);
|
|
41
|
+
if (e < 0)
|
|
42
|
+
break;
|
|
43
|
+
args[key] = s.slice(i + 3, e);
|
|
44
|
+
i = e + 3;
|
|
45
|
+
}
|
|
46
|
+
else if (s[i] === '"' || s[i] === "'") {
|
|
47
|
+
const q = s[i];
|
|
48
|
+
i++;
|
|
49
|
+
let v = '';
|
|
50
|
+
while (i < n && s[i] !== q) {
|
|
51
|
+
if (s[i] === '\\' && i + 1 < n) {
|
|
52
|
+
v += s.slice(i, i + 2);
|
|
53
|
+
i += 2;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
v += s[i];
|
|
57
|
+
i++;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
i++;
|
|
61
|
+
args[key] = unesc(v);
|
|
62
|
+
}
|
|
63
|
+
else
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
return Object.keys(args).length ? args : null;
|
|
67
|
+
}
|
|
68
|
+
// `ToolName(` açılışından eşleşen `)`'ye kadar (string/triple-quote duyarlı) bitiş indexi.
|
|
69
|
+
function _findCallEnd(s, open) {
|
|
70
|
+
let depth = 0, i = open;
|
|
71
|
+
while (i < s.length) {
|
|
72
|
+
if (s.startsWith('"""', i)) {
|
|
73
|
+
const e = s.indexOf('"""', i + 3);
|
|
74
|
+
i = e < 0 ? s.length : e + 3;
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
if (s.startsWith("'''", i)) {
|
|
78
|
+
const e = s.indexOf("'''", i + 3);
|
|
79
|
+
i = e < 0 ? s.length : e + 3;
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
const c = s[i];
|
|
83
|
+
if (c === '"' || c === "'") {
|
|
84
|
+
i++;
|
|
85
|
+
while (i < s.length && s[i] !== c) {
|
|
86
|
+
if (s[i] === '\\')
|
|
87
|
+
i++;
|
|
88
|
+
i++;
|
|
89
|
+
}
|
|
90
|
+
i++;
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
if (c === '(')
|
|
94
|
+
depth++;
|
|
95
|
+
else if (c === ')') {
|
|
96
|
+
depth--;
|
|
97
|
+
if (depth === 0)
|
|
98
|
+
return i + 1;
|
|
99
|
+
}
|
|
100
|
+
i++;
|
|
101
|
+
}
|
|
102
|
+
return -1;
|
|
103
|
+
}
|
|
13
104
|
function toToolCall(obj, i) {
|
|
14
105
|
if (!obj || typeof obj !== 'object')
|
|
15
106
|
return null;
|
|
@@ -76,8 +167,8 @@ function extractTopLevelJsonObjects(text) {
|
|
|
76
167
|
* (<tool_call>, ```json) veya mesajın TAMAMI tek JSON çağrısıysa onu alır. */
|
|
77
168
|
export function recoverInlineToolCalls(text) {
|
|
78
169
|
const t = (text || '').trim();
|
|
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)))
|
|
170
|
+
// JSON/prose/ToolName{…}/ToolName(…) çağrısı yoksa erken çık.
|
|
171
|
+
if (!t || (!t.includes('"name"') && !t.includes('"tool"') && !t.includes('"function"') && !/AskUserQuestion/i.test(t) && !TOOL_PREFIX_RE.test(t) && !TOOL_PAREN_RE.test(t)))
|
|
81
172
|
return [];
|
|
82
173
|
const out = [];
|
|
83
174
|
const seen = new Set();
|
|
@@ -143,6 +234,22 @@ export function recoverInlineToolCalls(text) {
|
|
|
143
234
|
}
|
|
144
235
|
}
|
|
145
236
|
}
|
|
237
|
+
// 6) "ToolName(key=...)" fonksiyon-çağrı pseudo-syntax'i (Write(file_path="...", content="""...""")).
|
|
238
|
+
if (!out.length) {
|
|
239
|
+
const re = new RegExp('(' + _TOOLS + ')\\s*\\(', 'g');
|
|
240
|
+
let mm;
|
|
241
|
+
while ((mm = re.exec(t)) !== null) {
|
|
242
|
+
const open = mm.index + mm[0].length - 1; // '(' konumu
|
|
243
|
+
const end = _findCallEnd(t, open);
|
|
244
|
+
if (end < 0)
|
|
245
|
+
continue;
|
|
246
|
+
const args = _parseKwCall(t.slice(open + 1, end - 1));
|
|
247
|
+
if (args) {
|
|
248
|
+
push({ name: mm[1], arguments: args });
|
|
249
|
+
re.lastIndex = end;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
146
253
|
return out;
|
|
147
254
|
}
|
|
148
255
|
/** Modelin komut/çıktıyı TEKRAR yazdığı kod-bloklarını siler (```plaintext/bash/http/console…).
|
|
@@ -207,5 +314,21 @@ export function stripInlineToolCalls(text) {
|
|
|
207
314
|
for (let i = spans.length - 1; i >= 0; i--)
|
|
208
315
|
s = s.slice(0, spans[i][0]) + s.slice(spans[i][1]);
|
|
209
316
|
}
|
|
317
|
+
// ToolName(…) biçimi (Write(file_path="...", content="""...""")) — adı + () bloğunu sil.
|
|
318
|
+
{
|
|
319
|
+
const re = new RegExp('(' + _TOOLS + ')\\s*\\(', 'g');
|
|
320
|
+
let mm;
|
|
321
|
+
const spans = [];
|
|
322
|
+
while ((mm = re.exec(s)) !== null) {
|
|
323
|
+
const open = mm.index + mm[0].length - 1;
|
|
324
|
+
const end = _findCallEnd(s, open);
|
|
325
|
+
if (end > 0) {
|
|
326
|
+
spans.push([mm.index, end]);
|
|
327
|
+
re.lastIndex = end;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
for (let i = spans.length - 1; i >= 0; i--)
|
|
331
|
+
s = s.slice(0, spans[i][0]) + s.slice(spans[i][1]);
|
|
332
|
+
}
|
|
210
333
|
return s.trim();
|
|
211
334
|
}
|
package/dist/theme.js
CHANGED