natureco-cli 5.13.0 → 5.14.1
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 +1 -1
- package/src/commands/repl.js +91 -37
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "natureco-cli",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.14.1",
|
|
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
|
@@ -1016,10 +1016,10 @@ async function startRepl(args) {
|
|
|
1016
1016
|
process.stdout.write('Merhaba! Ben ' + displayName + '. ');
|
|
1017
1017
|
}
|
|
1018
1018
|
|
|
1019
|
-
// AI cevabı
|
|
1019
|
+
// AI cevabı — v5.13.0: workflow orchestrator ALWAYS first
|
|
1020
1020
|
process.stdout.write(tui.styled('\n AI ', { color: tui.PALETTE.secondary, bold: true }));
|
|
1021
1021
|
try {
|
|
1022
|
-
// Per-turn: rebuild volatile tier with current memory snapshot
|
|
1022
|
+
// Per-turn: rebuild volatile tier with current memory snapshot
|
|
1023
1023
|
guardrails.reset();
|
|
1024
1024
|
memory = loadMemory(cfg.userName);
|
|
1025
1025
|
memoryStore.load();
|
|
@@ -1027,8 +1027,58 @@ async function startRepl(args) {
|
|
|
1027
1027
|
promptOpts.memoryFacts = memory.facts || [];
|
|
1028
1028
|
systemPrompt = rebuildSystemPrompt(promptOpts);
|
|
1029
1029
|
messages[0] = { role: 'system', content: systemPrompt, _internal: true };
|
|
1030
|
-
|
|
1031
|
-
|
|
1030
|
+
|
|
1031
|
+
// v5.13.0: Run workflow FIRST for every request
|
|
1032
|
+
process.stdout.write(tui.styled('\r 🔧 workflow... ', { color: tui.PALETTE.muted }));
|
|
1033
|
+
const wfToolDefs = getToolDefs();
|
|
1034
|
+
const wfResult = await executeTool('workflow', { action: 'run', task: line }, wfToolDefs);
|
|
1035
|
+
const wf = wfResult?.result || {};
|
|
1036
|
+
if (wf.success !== false) {
|
|
1037
|
+
process.stdout.write(tui.styled(' ✓ workflow\n', { color: tui.PALETTE.success }));
|
|
1038
|
+
} else {
|
|
1039
|
+
process.stdout.write(tui.styled(' ✗ workflow\n', { color: tui.PALETTE.danger }));
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
if (wf.passthrough && wf.reply) {
|
|
1043
|
+
// Simple chat — workflow handled it directly
|
|
1044
|
+
const fullReply = String(wf.reply);
|
|
1045
|
+
const displayBotName = memory.botName || 'Asistan';
|
|
1046
|
+
let fixedReply = String(fullReply);
|
|
1047
|
+
fixedReply = fixedReply.replace(/\bMiniMax[-\s\w\.\d]*/gi, displayBotName);
|
|
1048
|
+
fixedReply = fixedReply.replace(/\bM2\.5[-\s\w\.\d]*/gi, displayBotName);
|
|
1049
|
+
fixedReply = fixedReply.replace(/\bM2[\s\-\.\w\d]*/gi, displayBotName);
|
|
1050
|
+
fixedReply = fixedReply.replace(/\bClaude[-\s\w\.\d]*/gi, displayBotName);
|
|
1051
|
+
fixedReply = fixedReply.replace(/\bGPT[-\s\w\.\d]*/gi, displayBotName);
|
|
1052
|
+
fixedReply = fixedReply.replace(/\bChatGPT\b/g, displayBotName);
|
|
1053
|
+
fixedReply = fixedReply.replace(/NatureCo\s+CLI(\s*'in|'nin)?/gi, displayBotName);
|
|
1054
|
+
fixedReply = fixedReply.replace(/Ben\s+MiniMax[^.!?,;:\n]*/gi, 'Ben ' + displayBotName);
|
|
1055
|
+
fixedReply = fixedReply.replace(/Ben\s+Claude[^.!?,;:\n]*/gi, 'Ben ' + displayBotName);
|
|
1056
|
+
fixedReply = fixedReply.replace(/Ben\s+GPT[^.!?,;:\n]*/gi, 'Ben ' + displayBotName);
|
|
1057
|
+
fixedReply = fixedReply.replace(/Ben\s+Asistan[\s\w\.]*/gi, 'Ben ' + displayBotName);
|
|
1058
|
+
fixedReply = fixedReply.replace(/\*\*(?:MiniMax|Claude|GPT|M2\.5|M2)[^\*]*\*\*/gi, '**' + displayBotName + '**');
|
|
1059
|
+
process.stdout.write('\n' + fixedReply + '\n');
|
|
1060
|
+
messages.push({ role: 'assistant', content: fixedReply });
|
|
1061
|
+
totalInputTokens += Math.ceil(line.length / 4);
|
|
1062
|
+
totalOutputTokens += Math.ceil(fullReply.length / 4);
|
|
1063
|
+
} else if (wf.status === 'completed' || (wf.results && wf.results.length > 0)) {
|
|
1064
|
+
// Complex task — inject workflow report as context, then LLM crafts final reply
|
|
1065
|
+
const workflowSteps = wf.results || [];
|
|
1066
|
+
const report = workflowSteps.map(r => {
|
|
1067
|
+
const t = r.tool || r.name || '?';
|
|
1068
|
+
const s = r.status === 'done' ? '✓' : '✗';
|
|
1069
|
+
let summary = '';
|
|
1070
|
+
if (r.result) {
|
|
1071
|
+
try { summary = typeof r.result === 'string' ? r.result.slice(0, 400) : JSON.stringify(r.result).slice(0, 400); } catch {}
|
|
1072
|
+
}
|
|
1073
|
+
return ` ${s} ${t}: ${summary}`;
|
|
1074
|
+
}).join('\n');
|
|
1075
|
+
messages.push({
|
|
1076
|
+
role: 'system',
|
|
1077
|
+
content: `=== WORKFLOW SONUCLARI ===\nSu araclar calisti:\n${report}\n\nKullaniciya bu sonuclari anlamli bir sekilde ozetle.\n=== SONUC BITTI ===`,
|
|
1078
|
+
_internal: true
|
|
1079
|
+
});
|
|
1080
|
+
const apiMessages = messages.filter(m => !m._internal);
|
|
1081
|
+
const reply = await sendStreaming(
|
|
1032
1082
|
providerUrl,
|
|
1033
1083
|
providerApiKey,
|
|
1034
1084
|
apiMessages,
|
|
@@ -1049,41 +1099,45 @@ async function startRepl(args) {
|
|
|
1049
1099
|
}
|
|
1050
1100
|
})
|
|
1051
1101
|
);
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
const existingLen = messages.filter(m => !m._internal).length;
|
|
1078
|
-
const toolCallHistory = apiMessages.slice(existingLen);
|
|
1079
|
-
for (const m of toolCallHistory) {
|
|
1080
|
-
if (m.role === 'assistant' || m.role === 'tool') {
|
|
1081
|
-
messages.push(m);
|
|
1102
|
+
// v5.6.12: Tam metin 'reply' olarak zaten geldi (non-stream mode)
|
|
1103
|
+
const fullReply = String(reply || '');
|
|
1104
|
+
// Bot adini al
|
|
1105
|
+
const displayBotName = memory.botName || 'Asistan';
|
|
1106
|
+
// v5.6.9: Tum model adlarini ve varyasyonlari temizle
|
|
1107
|
+
let fixedReply = String(fullReply);
|
|
1108
|
+
fixedReply = fixedReply.replace(/\bMiniMax[-\s\w\.\d]*/gi, displayBotName);
|
|
1109
|
+
fixedReply = fixedReply.replace(/\bM2\.5[-\s\w\.\d]*/gi, displayBotName);
|
|
1110
|
+
fixedReply = fixedReply.replace(/\bM2[\s\-\.\w\d]*/gi, displayBotName);
|
|
1111
|
+
fixedReply = fixedReply.replace(/\bClaude[-\s\w\.\d]*/gi, displayBotName);
|
|
1112
|
+
fixedReply = fixedReply.replace(/\bGPT[-\s\w\.\d]*/gi, displayBotName);
|
|
1113
|
+
fixedReply = fixedReply.replace(/\bChatGPT\b/g, displayBotName);
|
|
1114
|
+
fixedReply = fixedReply.replace(/NatureCo\s+CLI(\s*'in|'nin)?/gi, displayBotName);
|
|
1115
|
+
fixedReply = fixedReply.replace(/Ben\s+MiniMax[^.!?,;:\n]*/gi, 'Ben ' + displayBotName);
|
|
1116
|
+
fixedReply = fixedReply.replace(/Ben\s+Claude[^.!?,;:\n]*/gi, 'Ben ' + displayBotName);
|
|
1117
|
+
fixedReply = fixedReply.replace(/Ben\s+GPT[^.!?,;:\n]*/gi, 'Ben ' + displayBotName);
|
|
1118
|
+
fixedReply = fixedReply.replace(/Ben\s+Asistan[\s\w\.]*/gi, 'Ben ' + displayBotName);
|
|
1119
|
+
fixedReply = fixedReply.replace(/\*\*(?:MiniMax|Claude|GPT|M2\.5|M2)[^\*]*\*\*/gi, '**' + displayBotName + '**');
|
|
1120
|
+
process.stdout.write('\n' + fixedReply + '\n');
|
|
1121
|
+
const existingLen = messages.filter(m => !m._internal).length;
|
|
1122
|
+
const toolCallHistory = apiMessages.slice(existingLen);
|
|
1123
|
+
for (const m of toolCallHistory) {
|
|
1124
|
+
if (m.role === 'assistant' || m.role === 'tool') {
|
|
1125
|
+
messages.push(m);
|
|
1126
|
+
}
|
|
1082
1127
|
}
|
|
1128
|
+
messages.push({ role: 'assistant', content: fixedReply });
|
|
1129
|
+
totalInputTokens += apiMessages.reduce((s, m) => s + Math.ceil((m.content || '').length / 4), 0);
|
|
1130
|
+
totalOutputTokens += Math.ceil((fullReply || '').length / 4);
|
|
1131
|
+
} else {
|
|
1132
|
+
// Workflow failed or returned unexpected format
|
|
1133
|
+
const fullReply = wf.error || JSON.stringify(wf).slice(0, 400) || 'Workflow islenemedi.';
|
|
1134
|
+
const displayBotName = memory.botName || 'Asistan';
|
|
1135
|
+
let fixedReply = fullReply.replace(/\bMiniMax[-\s\w\.\d]*/gi, displayBotName);
|
|
1136
|
+
process.stdout.write('\n' + fixedReply + '\n');
|
|
1137
|
+
messages.push({ role: 'assistant', content: fixedReply });
|
|
1138
|
+
totalInputTokens += Math.ceil(line.length / 4);
|
|
1139
|
+
totalOutputTokens += Math.ceil(fixedReply.length / 4);
|
|
1083
1140
|
}
|
|
1084
|
-
messages.push({ role: 'assistant', content: fixedReply });
|
|
1085
|
-
totalInputTokens += apiMessages.reduce((s, m) => s + Math.ceil((m.content || '').length / 4), 0);
|
|
1086
|
-
totalOutputTokens += Math.ceil((fullReply || '').length / 4);
|
|
1087
1141
|
} catch (err) {
|
|
1088
1142
|
process.stdout.write('\n');
|
|
1089
1143
|
console.log(chalk.red(' ❌ ' + err.message));
|