natureco-cli 5.7.9 → 5.7.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.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "natureco-cli",
|
|
3
|
-
"version": "5.7.
|
|
3
|
+
"version": "5.7.11",
|
|
4
4
|
"description": "OpenClaw'dan daha güvenli, daha hızlı, daha ucuz AI agent CLI. Multi-agent, self-evolving skills, audit log, maliyet optimizasyonu ve NatureCo platform-native.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"natureco": "bin/natureco.js"
|
package/src/commands/repl.js
CHANGED
|
@@ -24,7 +24,7 @@ const chalk = require('chalk');
|
|
|
24
24
|
const tui = require('../utils/tui');
|
|
25
25
|
const { loadToolDefinitions, toOpenAIFormat, executeTool } = require('../utils/tools');
|
|
26
26
|
const { accumulateToolCallDeltas, finalizeToolCalls } = require('../utils/streaming-tools');
|
|
27
|
-
const { createPasteSafeInput, createOutputFilter, enableBracketedPaste, disableBracketedPaste, restoreNewlines } = require('../utils/paste-safe-input');
|
|
27
|
+
const { createPasteSafeInput, createOutputFilter, enableBracketedPaste, disableBracketedPaste, restoreNewlines, clearPasteContext } = require('../utils/paste-safe-input');
|
|
28
28
|
|
|
29
29
|
// v5.4.6: Model adi sizintisini engelle — global'e ata, callback'lerden erisebilir olsun
|
|
30
30
|
const MODEL_NAMES_TO_HIDE = ['MiniMax-M2.5', 'MiniMaxM2.5', 'minimaxm25', 'Claude-3', 'GPT-4', 'ChatGPT'];
|
|
@@ -728,13 +728,8 @@ async function startRepl(args) {
|
|
|
728
728
|
const line = restoreNewlines(input).trim();
|
|
729
729
|
if (!line) { rl.prompt(); return; }
|
|
730
730
|
|
|
731
|
-
// Çok satırlı paste:
|
|
732
|
-
|
|
733
|
-
// yerine özet yaz.
|
|
734
|
-
const newlineCount = (line.match(/\n/g) || []).length;
|
|
735
|
-
if (newlineCount > 0) {
|
|
736
|
-
process.stdout.write(`\x1b[1A\x1b[J[Pasted ~${newlineCount + 1} lines]\n`);
|
|
737
|
-
}
|
|
731
|
+
// Çok satırlı paste: output filter'a echo'yu durdurma sinyalini ver
|
|
732
|
+
clearPasteContext();
|
|
738
733
|
|
|
739
734
|
// Slash komutlar
|
|
740
735
|
if (line.startsWith('/')) {
|
|
@@ -38,6 +38,12 @@ const { PassThrough } = require('stream');
|
|
|
38
38
|
const PASTE_START = '\x1b[200~';
|
|
39
39
|
const PASTE_END = '\x1b[201~';
|
|
40
40
|
|
|
41
|
+
// Input proxy ile output filter arasında paste durumunu paylaşır.
|
|
42
|
+
// escapeEmbeddedNewlines paste algıladığında bu context'i set eder,
|
|
43
|
+
// output filter tüm ekoyu yutar (terminalde hiçbir şey gözükmez),
|
|
44
|
+
// repl.js line handler'ı context'i temizler.
|
|
45
|
+
let _pasteContext = null; // { lineCount } or null
|
|
46
|
+
|
|
41
47
|
// Yapıştırılan içindeki satır sonlarını gizlemek için kullanılan placeholder.
|
|
42
48
|
// Gerçek kullanıcı girdisinde pratikte hiç geçmeyecek bir dizi.
|
|
43
49
|
const NEWLINE_PLACEHOLDER = '\u2424\u2424LINEBREAK\u2424\u2424';
|
|
@@ -87,14 +93,26 @@ function escapeEmbeddedNewlines(str) {
|
|
|
87
93
|
// (Tek istisna: test ortamında PassThrough kullanılır, orada da
|
|
88
94
|
// testler karakter-karakter yazacak şekilde güncellenmiştir.)
|
|
89
95
|
if (newlineCount === 0) return str;
|
|
96
|
+
|
|
97
|
+
// Paste algılandı — output filter'a sinyal ver ve summary yaz
|
|
98
|
+
onPasteDetected(str);
|
|
99
|
+
|
|
90
100
|
return str.replace(/\r\n|\r|\n/g, NEWLINE_PLACEHOLDER);
|
|
91
101
|
}
|
|
92
102
|
|
|
103
|
+
function onPasteDetected(pasteStr) {
|
|
104
|
+
const newlineCount = (pasteStr.match(/\r\n|\r|\n/g) || []).length;
|
|
105
|
+
const lineCount = newlineCount + 1;
|
|
106
|
+
_pasteContext = { lineCount };
|
|
107
|
+
process.stdout.write(`[Pasted ~${lineCount} lines]\n`);
|
|
108
|
+
}
|
|
109
|
+
|
|
93
110
|
function createPasteSafeInput(source = process.stdin) {
|
|
94
111
|
const proxy = new PassThrough();
|
|
95
112
|
|
|
96
113
|
let inPaste = false;
|
|
97
114
|
let carry = ''; // marker'ın chunk sınırında bölünmesine karşı tampon
|
|
115
|
+
let pasteBuffer = ''; // onPasteDetected için biriken paste içeriği
|
|
98
116
|
|
|
99
117
|
const onData = (chunk) => {
|
|
100
118
|
let str = carry + chunk.toString('utf8');
|
|
@@ -107,14 +125,19 @@ function createPasteSafeInput(source = process.stdin) {
|
|
|
107
125
|
if (endIdx === -1) {
|
|
108
126
|
const keepLen = trailingMarkerPrefixLen(str, PASTE_END);
|
|
109
127
|
const flushLen = str.length - keepLen;
|
|
110
|
-
|
|
128
|
+
const segment = str.slice(0, flushLen);
|
|
129
|
+
pasteBuffer += segment;
|
|
130
|
+
out += segment.replace(/\r\n|\r|\n/g, NEWLINE_PLACEHOLDER);
|
|
111
131
|
carry = str.slice(flushLen);
|
|
112
132
|
str = '';
|
|
113
133
|
break;
|
|
114
134
|
}
|
|
115
135
|
const pasted = str.slice(0, endIdx);
|
|
136
|
+
pasteBuffer += pasted;
|
|
116
137
|
out += pasted.replace(/\r\n|\r|\n/g, NEWLINE_PLACEHOLDER);
|
|
117
138
|
inPaste = false;
|
|
139
|
+
onPasteDetected(pasteBuffer);
|
|
140
|
+
pasteBuffer = '';
|
|
118
141
|
str = str.slice(endIdx + PASTE_END.length);
|
|
119
142
|
continue;
|
|
120
143
|
}
|
|
@@ -207,35 +230,56 @@ function createOutputFilter(output = process.stdout) {
|
|
|
207
230
|
|
|
208
231
|
const filter = {
|
|
209
232
|
write(data) {
|
|
233
|
+
// Paste aktifken tüm ekoyu yut — terminalde hiçbir şey gözükmez
|
|
234
|
+
if (_pasteContext !== null) {
|
|
235
|
+
// Placeholder state machine'i çalıştır (sonraki write'lar için
|
|
236
|
+
// partial buffer temiz kalsın) ama output'a hiçbir şey yazma.
|
|
237
|
+
const str = data.toString('utf8');
|
|
238
|
+
let i = 0;
|
|
239
|
+
while (i < str.length) {
|
|
240
|
+
if (partial.length > 0) {
|
|
241
|
+
const expected = NEWLINE_PLACEHOLDER[partial.length];
|
|
242
|
+
const ch = str[i];
|
|
243
|
+
if (ch === expected) {
|
|
244
|
+
partial += ch;
|
|
245
|
+
i++;
|
|
246
|
+
if (partial === NEWLINE_PLACEHOLDER) partial = '';
|
|
247
|
+
} else {
|
|
248
|
+
partial = '';
|
|
249
|
+
}
|
|
250
|
+
} else {
|
|
251
|
+
if (str[i] === NEWLINE_PLACEHOLDER[0]) {
|
|
252
|
+
partial = str[i];
|
|
253
|
+
}
|
|
254
|
+
i++;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
return true;
|
|
258
|
+
}
|
|
259
|
+
|
|
210
260
|
const str = data.toString('utf8');
|
|
211
261
|
let result = '';
|
|
212
262
|
let i = 0;
|
|
213
263
|
|
|
214
264
|
while (i < str.length) {
|
|
215
265
|
if (partial.length > 0) {
|
|
216
|
-
// Kısmi eşleşme var — devamını bekle
|
|
217
266
|
const expected = NEWLINE_PLACEHOLDER[partial.length];
|
|
218
267
|
const ch = str[i];
|
|
219
268
|
if (ch === expected) {
|
|
220
269
|
partial += ch;
|
|
221
270
|
i++;
|
|
222
271
|
if (partial === NEWLINE_PLACEHOLDER) {
|
|
223
|
-
// Placeholder'ı terminalde gösterme — output'tan tamamen çıkar
|
|
224
272
|
partial = '';
|
|
225
273
|
}
|
|
226
274
|
} else {
|
|
227
|
-
// Eşleşme bozuldu — partial buffer'ı boşalt
|
|
228
275
|
result += partial;
|
|
229
276
|
partial = '';
|
|
230
|
-
// ch'i tekrar dene (yeni placeholder başlangıcı olabilir)
|
|
231
|
-
// continue ile aynı i değerinde else-if'e düş
|
|
232
277
|
}
|
|
233
278
|
} else {
|
|
234
279
|
const ch = str[i];
|
|
235
280
|
if (ch === NEWLINE_PLACEHOLDER[0]) {
|
|
236
281
|
partial = ch;
|
|
237
282
|
i++;
|
|
238
|
-
// Tek karakterlik placeholder değil, bekle
|
|
239
283
|
} else {
|
|
240
284
|
result += ch;
|
|
241
285
|
i++;
|
|
@@ -274,6 +318,9 @@ function createOutputFilter(output = process.stdout) {
|
|
|
274
318
|
return filter;
|
|
275
319
|
}
|
|
276
320
|
|
|
321
|
+
function setPasteContext(ctx) { _pasteContext = ctx; }
|
|
322
|
+
function clearPasteContext() { _pasteContext = null; }
|
|
323
|
+
|
|
277
324
|
module.exports = {
|
|
278
325
|
createPasteSafeInput,
|
|
279
326
|
createOutputFilter,
|
|
@@ -281,4 +328,6 @@ module.exports = {
|
|
|
281
328
|
disableBracketedPaste,
|
|
282
329
|
restoreNewlines,
|
|
283
330
|
NEWLINE_PLACEHOLDER,
|
|
331
|
+
setPasteContext,
|
|
332
|
+
clearPasteContext,
|
|
284
333
|
};
|