natureco-cli 5.9.7 → 5.12.0
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 +32 -23
- package/src/tools/approval.js +55 -0
- package/src/tools/async_delegation.js +83 -0
- package/src/tools/blueprint.js +88 -0
- package/src/tools/checkpoint.js +66 -0
- package/src/tools/clarify.js +31 -0
- package/src/tools/computer_use.js +141 -0
- package/src/tools/discord.js +65 -0
- package/src/tools/file_state.js +73 -0
- package/src/tools/google_meet.js +71 -0
- package/src/tools/homeassistant.js +84 -0
- package/src/tools/microsoft_graph.js +103 -0
- package/src/tools/pii_redact.js +50 -0
- package/src/tools/send_message.js +39 -0
- package/src/tools/session_search.js +62 -0
- package/src/tools/spotify.js +93 -0
- package/src/tools/url_safety.js +65 -0
- package/src/tools/workflow.js +307 -0
- package/src/tools/x_search.js +51 -0
- package/src/utils/tools.js +19 -0
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
const https = require('https');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const os = require('os');
|
|
5
|
+
|
|
6
|
+
const WORKFLOW_DIR = path.join(os.homedir(), '.natureco', 'workflows');
|
|
7
|
+
const WORKFLOW_HISTORY = path.join(os.homedir(), '.natureco', 'workflow-history.json');
|
|
8
|
+
|
|
9
|
+
function ensureDir(dir) { try { fs.mkdirSync(dir, { recursive: true }); } catch {} }
|
|
10
|
+
function loadConfig() {
|
|
11
|
+
try { return JSON.parse(fs.readFileSync(path.join(os.homedir(), '.natureco', 'config.json'), 'utf8')); } catch { return {}; }
|
|
12
|
+
}
|
|
13
|
+
function isMiniMax(url) { return url && (url.includes('minimax.io') || url.includes('minimaxi.com') || url.includes('minimax.cn')); }
|
|
14
|
+
function isGemini(url) { return url && (url.includes('generativelanguage.googleapis.com') || url.includes('gemini')); }
|
|
15
|
+
|
|
16
|
+
function allToolNames() {
|
|
17
|
+
try {
|
|
18
|
+
const toolsDir = path.join(__dirname, '..', 'tools');
|
|
19
|
+
return fs.readdirSync(toolsDir).filter(f => f.endsWith('.js')).map(f => path.basename(f, '.js'));
|
|
20
|
+
} catch { return []; }
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function apiCall(providerUrl, apiKey, body) {
|
|
24
|
+
return new Promise((resolve, reject) => {
|
|
25
|
+
const base = providerUrl.replace(/\/+$/, '');
|
|
26
|
+
const endpoint = isMiniMax(base)
|
|
27
|
+
? base + '/v1/text/chatcompletion_v2'
|
|
28
|
+
: isGemini(base)
|
|
29
|
+
? base + '/openai/chat/completions'
|
|
30
|
+
: base + '/chat/completions';
|
|
31
|
+
const req = https.request(endpoint, {
|
|
32
|
+
method: 'POST',
|
|
33
|
+
headers: { 'Authorization': 'Bearer ' + apiKey, 'Content-Type': 'application/json' },
|
|
34
|
+
timeout: 120000,
|
|
35
|
+
}, (res) => {
|
|
36
|
+
let data = '';
|
|
37
|
+
res.on('data', c => data += c);
|
|
38
|
+
res.on('end', () => {
|
|
39
|
+
if (res.statusCode >= 200 && res.statusCode < 300) {
|
|
40
|
+
try { resolve(JSON.parse(data)); } catch { reject(new Error('Parse hatasi')); }
|
|
41
|
+
} else if (res.statusCode === 429) {
|
|
42
|
+
reject(new Error('429: API rate limit. Bekleyip tekrar deneyin.'));
|
|
43
|
+
} else {
|
|
44
|
+
reject(new Error('HTTP ' + res.statusCode + ': ' + data.slice(0, 300)));
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
req.on('error', reject);
|
|
49
|
+
req.on('timeout', () => { req.destroy(); reject(new Error('Timeout')); });
|
|
50
|
+
req.write(JSON.stringify(body));
|
|
51
|
+
req.end();
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async function workflow(params) {
|
|
56
|
+
const { action, task, steps, name, workflowId, regenerateStep } = params;
|
|
57
|
+
const cfg = loadConfig();
|
|
58
|
+
const tools = allToolNames();
|
|
59
|
+
ensureDir(WORKFLOW_DIR);
|
|
60
|
+
|
|
61
|
+
const providerUrl = cfg.providerUrl;
|
|
62
|
+
const providerApiKey = cfg.providerApiKey;
|
|
63
|
+
const model = cfg.providerModel || 'default';
|
|
64
|
+
|
|
65
|
+
if (!providerUrl || !providerApiKey) {
|
|
66
|
+
return { success: false, error: 'Provider ayarli degil. Once: natureco setup' };
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// ── RUN: Execute a complete workflow ──────────────────────────────────
|
|
70
|
+
if (action === 'run') {
|
|
71
|
+
if (!task) return { success: false, error: 'task gerekli' };
|
|
72
|
+
|
|
73
|
+
// Phase 1: LLM plans the workflow
|
|
74
|
+
const planPrompt = {
|
|
75
|
+
role: 'system',
|
|
76
|
+
content: 'Sen bir workflow planlama asistanisin. Verilen gorev icin hangi tool\'larin kullanilacagini ve hangi sirayla calisacagini belirle. SADECE JSON formatinda yanit ver, baska bir sey yazma.\n\nKullanilabilir tool\'lar:\n' +
|
|
77
|
+
tools.map(t => '- ' + t).join('\n') +
|
|
78
|
+
'\n\nJSON format:\n{\n "workflowName": "...",\n "description": "...",\n "steps": [\n { "step": 1, "tool": "tool_name", "purpose": "...", "params": { ... } }\n ]\n}\n\nHer adim icin params kismina tool\'un gerektirdigi parametreleri ekle. Adimlar birbirine bagimli olabilir, onceki adimin outputu sonraki adimin inputu olarak kullanilabilir.'
|
|
79
|
+
};
|
|
80
|
+
const planBody = {
|
|
81
|
+
model, stream: false,
|
|
82
|
+
messages: [planPrompt, { role: 'user', content: 'Gorev: ' + task }],
|
|
83
|
+
temperature: 0.3, max_tokens: 4000,
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
let planResult;
|
|
87
|
+
try {
|
|
88
|
+
planResult = await apiCall(providerUrl, providerApiKey, planBody);
|
|
89
|
+
} catch (e) {
|
|
90
|
+
return { success: false, error: 'Plan olusturulamadi: ' + e.message, phase: 'planning' };
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
let plan;
|
|
94
|
+
try {
|
|
95
|
+
const content = planResult.choices?.[0]?.message?.content || '';
|
|
96
|
+
const jsonMatch = content.match(/\{[\s\S]*\}/);
|
|
97
|
+
plan = JSON.parse(jsonMatch ? jsonMatch[0] : content);
|
|
98
|
+
if (!plan.steps || !Array.isArray(plan.steps)) throw new Error('Steps bulunamadi');
|
|
99
|
+
} catch (e) {
|
|
100
|
+
return { success: false, error: 'Plan cozumlenemedi: ' + e.message, raw: planResult.choices?.[0]?.message?.content?.slice(0, 500) };
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Save plan
|
|
104
|
+
const wfId = workflowId || 'wf_' + Date.now().toString(36);
|
|
105
|
+
const wfFile = path.join(WORKFLOW_DIR, wfId + '.json');
|
|
106
|
+
const wfEntry = { id: wfId, task, name: plan.workflowName || task.slice(0, 50), description: plan.description || '', steps: plan.steps, status: 'running', startedAt: new Date().toISOString(), results: [] };
|
|
107
|
+
fs.writeFileSync(wfFile, JSON.stringify(wfEntry, null, 2));
|
|
108
|
+
|
|
109
|
+
// Phase 2: Execute steps sequentially
|
|
110
|
+
const stepResults = [];
|
|
111
|
+
let failed = false;
|
|
112
|
+
|
|
113
|
+
for (const step of plan.steps) {
|
|
114
|
+
if (failed) {
|
|
115
|
+
stepResults.push({ step: step.step, tool: step.tool, status: 'skipped', reason: 'Onceki adim basarisiz' });
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Check if tool is valid
|
|
120
|
+
if (!tools.includes(step.tool)) {
|
|
121
|
+
stepResults.push({ step: step.step, tool: step.tool, status: 'error', error: 'Bilinmeyen tool: ' + step.tool + '. Kullanilabilir: ' + tools.slice(0, 10).join(', ') + '...' });
|
|
122
|
+
failed = true;
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Build the execute prompt — we use LLM to call the tool with correct params
|
|
127
|
+
const executePrompt = {
|
|
128
|
+
role: 'system',
|
|
129
|
+
content: 'Bir sonraki adimi calistiriyorsun. Sana verilen tool\'u ve parametreleri kullanarak islemi gerceklestir. Tool cagrisini dogru formatta yap.\n\nTool: ' + step.tool + '\nAmac: ' + (step.purpose || '') + '\nPlanlanan parametreler: ' + JSON.stringify(step.params || {}) +
|
|
130
|
+
'\n\nOnceki adim sonuclari:\n' + stepResults.map(r => 'Adim ' + r.step + ' (' + r.tool + '): ' + (r.status === 'done' ? JSON.stringify(r.result).slice(0, 300) : r.status)).join('\n') +
|
|
131
|
+
'\n\nTek bir tool cagrisi yap ve sonucu bekle. Tool cagrisi yaparken Onceki adim sonuclarindaki gerekli verileri parametre olarak kullan.'
|
|
132
|
+
};
|
|
133
|
+
const executeBody = {
|
|
134
|
+
model, stream: false,
|
|
135
|
+
messages: [executePrompt, { role: 'user', content: 'Adim ' + step.step + ': ' + step.tool + ' ile ' + (step.purpose || 'islem') + ' yap.' }],
|
|
136
|
+
temperature: 0.2, max_tokens: 2000,
|
|
137
|
+
tools: [{ type: 'function', function: { name: step.tool, description: step.purpose || '', parameters: {} } }],
|
|
138
|
+
tool_choice: { type: 'function', function: { name: step.tool } },
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
let execResult;
|
|
142
|
+
try {
|
|
143
|
+
execResult = await apiCall(providerUrl, providerApiKey, executeBody);
|
|
144
|
+
const msg = execResult.choices?.[0]?.message || {};
|
|
145
|
+
const tc = msg.tool_calls?.[0];
|
|
146
|
+
|
|
147
|
+
if (tc && tc.function) {
|
|
148
|
+
const args = JSON.parse(tc.function.arguments || '{}');
|
|
149
|
+
const toolMod = require(path.join(__dirname, '..', 'tools', step.tool + '.js'));
|
|
150
|
+
const fn = toolMod.execute || (toolMod.default && toolMod.default.execute);
|
|
151
|
+
if (!fn) { throw new Error(step.tool + ' toolunda execute fonksiyonu bulunamadi'); }
|
|
152
|
+
const toolResult = await fn(args);
|
|
153
|
+
stepResults.push({ step: step.step, tool: step.tool, status: 'done', args, result: toolResult });
|
|
154
|
+
} else if (msg.content) {
|
|
155
|
+
stepResults.push({ step: step.step, tool: step.tool, status: 'done', note: 'Tool cagrilmadi, model dogrudan yanit verdi', content: msg.content.slice(0, 500) });
|
|
156
|
+
} else {
|
|
157
|
+
stepResults.push({ step: step.step, tool: step.tool, status: 'error', error: 'Tool cagrisi yapilmadi' });
|
|
158
|
+
failed = true;
|
|
159
|
+
}
|
|
160
|
+
} catch (e) {
|
|
161
|
+
stepResults.push({ step: step.step, tool: step.tool, status: 'error', error: e.message });
|
|
162
|
+
failed = true;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// Update workflow file
|
|
167
|
+
wfEntry.status = failed ? 'completed_with_errors' : 'completed';
|
|
168
|
+
wfEntry.completedAt = new Date().toISOString();
|
|
169
|
+
wfEntry.results = stepResults;
|
|
170
|
+
fs.writeFileSync(wfFile, JSON.stringify(wfEntry, null, 2));
|
|
171
|
+
|
|
172
|
+
// Save to history
|
|
173
|
+
ensureDir(path.dirname(WORKFLOW_HISTORY));
|
|
174
|
+
let history = [];
|
|
175
|
+
try { history = JSON.parse(fs.readFileSync(WORKFLOW_HISTORY, 'utf8')); } catch {}
|
|
176
|
+
history.unshift({ id: wfId, name: plan.workflowName || task.slice(0, 50), task, status: wfEntry.status, steps: plan.steps.length, completedAt: wfEntry.completedAt });
|
|
177
|
+
fs.writeFileSync(WORKFLOW_HISTORY, JSON.stringify(history.slice(0, 50), null, 2));
|
|
178
|
+
|
|
179
|
+
return {
|
|
180
|
+
success: true,
|
|
181
|
+
workflowId: wfId,
|
|
182
|
+
name: plan.workflowName || '',
|
|
183
|
+
description: plan.description || '',
|
|
184
|
+
totalSteps: plan.steps.length,
|
|
185
|
+
completedSteps: stepResults.filter(r => r.status === 'done').length,
|
|
186
|
+
failedSteps: stepResults.filter(r => r.status === 'error' || r.status === 'skipped').length,
|
|
187
|
+
status: wfEntry.status,
|
|
188
|
+
plan: plan.steps.map(s => ({ step: s.step, tool: s.tool, purpose: s.purpose })),
|
|
189
|
+
results: stepResults.map(r => ({
|
|
190
|
+
step: r.step, tool: r.tool, status: r.status,
|
|
191
|
+
result: r.status === 'done' ? r.result : undefined,
|
|
192
|
+
error: r.error, note: r.note,
|
|
193
|
+
})),
|
|
194
|
+
workflowFile: wfFile,
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// ── PLAN_ONLY: Just generate the plan without executing ──────────────
|
|
199
|
+
if (action === 'plan') {
|
|
200
|
+
if (!task) return { success: false, error: 'task gerekli' };
|
|
201
|
+
const planPrompt = {
|
|
202
|
+
role: 'system',
|
|
203
|
+
content: 'Kullanilabilir tool\'lar:\n' + tools.map(t => '- ' + t).join('\n') +
|
|
204
|
+
'\n\nGorev icin bir workflow plani JSON formatinda olustur. JSON disinda hicbir sey yazma.\nFormat: { "workflowName": "...", "description": "...", "estimatedSteps": N, "steps": [{ "step": 1, "tool": "...", "purpose": "...", "params": {...}, "expectedOutput": "..." }] }'
|
|
205
|
+
};
|
|
206
|
+
const planBody = {
|
|
207
|
+
model, stream: false,
|
|
208
|
+
messages: [planPrompt, { role: 'user', content: 'Gorev: ' + task }],
|
|
209
|
+
temperature: 0.3, max_tokens: 4000,
|
|
210
|
+
};
|
|
211
|
+
try {
|
|
212
|
+
const result = await apiCall(providerUrl, providerApiKey, planBody);
|
|
213
|
+
const content = result.choices?.[0]?.message?.content || '';
|
|
214
|
+
const jsonMatch = content.match(/\{[\s\S]*\}/);
|
|
215
|
+
const plan = JSON.parse(jsonMatch ? jsonMatch[0] : content);
|
|
216
|
+
return { success: true, plan, raw: content.slice(0, 1000) };
|
|
217
|
+
} catch (e) {
|
|
218
|
+
return { success: false, error: 'Plan olusturulamadi: ' + e.message };
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// ── SAVE / LOAD / LIST / DELETE ───────────────────────────────────────
|
|
223
|
+
if (action === 'save') {
|
|
224
|
+
if (!name || !steps) return { success: false, error: 'name ve steps gerekli' };
|
|
225
|
+
const wfId = 'wf_' + name.replace(/[^a-zA-Z0-9_-]/g, '_');
|
|
226
|
+
const wf = { id: wfId, name, description: params.description || '', steps, status: 'saved', createdAt: new Date().toISOString() };
|
|
227
|
+
fs.writeFileSync(path.join(WORKFLOW_DIR, wfId + '.json'), JSON.stringify(wf, null, 2));
|
|
228
|
+
return { success: true, workflowId: wfId, message: name + ' kaydedildi' };
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
if (action === 'load') {
|
|
232
|
+
const wfId = workflowId || name;
|
|
233
|
+
if (!wfId) return { success: false, error: 'workflowId gerekli' };
|
|
234
|
+
const wfFile = path.join(WORKFLOW_DIR, wfId + '.json');
|
|
235
|
+
if (!fs.existsSync(wfFile)) {
|
|
236
|
+
// Try to find by name
|
|
237
|
+
const files = fs.readdirSync(WORKFLOW_DIR).filter(f => f.endsWith('.json'));
|
|
238
|
+
for (const f of files) {
|
|
239
|
+
try {
|
|
240
|
+
const data = JSON.parse(fs.readFileSync(path.join(WORKFLOW_DIR, f), 'utf8'));
|
|
241
|
+
if (data.name === wfId || data.id === wfId) {
|
|
242
|
+
return { success: true, workflow: data };
|
|
243
|
+
}
|
|
244
|
+
} catch {}
|
|
245
|
+
}
|
|
246
|
+
return { success: false, error: 'Workflow bulunamadi: ' + wfId };
|
|
247
|
+
}
|
|
248
|
+
const data = JSON.parse(fs.readFileSync(wfFile, 'utf8'));
|
|
249
|
+
return { success: true, workflow: data };
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
if (action === 'list') {
|
|
253
|
+
const files = fs.readdirSync(WORKFLOW_DIR).filter(f => f.endsWith('.json'));
|
|
254
|
+
const list = files.map(f => {
|
|
255
|
+
try {
|
|
256
|
+
const data = JSON.parse(fs.readFileSync(path.join(WORKFLOW_DIR, f), 'utf8'));
|
|
257
|
+
return { id: data.id, name: data.name, status: data.status, steps: data.steps?.length || 0, createdAt: data.createdAt || data.startedAt };
|
|
258
|
+
} catch { return null; }
|
|
259
|
+
}).filter(Boolean);
|
|
260
|
+
return { success: true, workflows: list };
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
if (action === 'delete') {
|
|
264
|
+
const wfId = workflowId || name;
|
|
265
|
+
if (!wfId) return { success: false, error: 'workflowId gerekli' };
|
|
266
|
+
const wfFile = path.join(WORKFLOW_DIR, wfId + '.json');
|
|
267
|
+
if (fs.existsSync(wfFile)) fs.unlinkSync(wfFile);
|
|
268
|
+
return { success: true, message: wfId + ' silindi' };
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// ── RETRY: Regenerate and rerun a specific step ──────────────────────
|
|
272
|
+
if (action === 'retry') {
|
|
273
|
+
const wfId = workflowId;
|
|
274
|
+
if (!wfId) return { success: false, error: 'workflowId gerekli' };
|
|
275
|
+
if (typeof regenerateStep !== 'number') return { success: false, error: 'regenerateStep (step numarasi) gerekli' };
|
|
276
|
+
const wfFile = path.join(WORKFLOW_DIR, wfId + '.json');
|
|
277
|
+
if (!fs.existsSync(wfFile)) return { success: false, error: 'Workflow bulunamadi: ' + wfId };
|
|
278
|
+
const wf = JSON.parse(fs.readFileSync(wfFile, 'utf8'));
|
|
279
|
+
const step = wf.steps?.find(s => s.step === regenerateStep);
|
|
280
|
+
if (!step) return { success: false, error: 'Adim bulunamadi: ' + regenerateStep };
|
|
281
|
+
step.params = params.newParams || step.params;
|
|
282
|
+
fs.writeFileSync(wfFile, JSON.stringify(wf, null, 2));
|
|
283
|
+
return { success: true, message: 'Adim ' + regenerateStep + ' yeniden calistirilmak uzere isaretlendi. Tekrar run yapin.', step };
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
return { success: false, error: 'Gecersiz action: ' + action + ' (run, plan, save, load, list, delete, retry)' };
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
module.exports = {
|
|
290
|
+
name: 'workflow',
|
|
291
|
+
description: '[ORCHESTRATOR] Cok adimli is akisi: gorev ver, AI en uygun tool\'lari secer ve sirayla calistirir. Plan/run/save/load/list/delete/retry.',
|
|
292
|
+
inputSchema: {
|
|
293
|
+
type: 'object',
|
|
294
|
+
properties: {
|
|
295
|
+
action: { type: 'string', description: 'run (tam otomatik), plan (sadece plan), save, load, list, delete, retry', enum: ['run', 'plan', 'save', 'load', 'list', 'delete', 'retry'] },
|
|
296
|
+
task: { type: 'string', description: '(run/plan) Yapilacak gorev — dogal dil ile anlat' },
|
|
297
|
+
steps: { type: 'array', description: '(save) Kaydedilecek adimlar', items: { type: 'object' } },
|
|
298
|
+
name: { type: 'string', description: '(save/load) Workflow adi' },
|
|
299
|
+
workflowId: { type: 'string', description: '(load/delete/retry) Workflow ID' },
|
|
300
|
+
regenerateStep: { type: 'number', description: '(retry) Yeniden calistirilacak adim numarasi' },
|
|
301
|
+
newParams: { type: 'object', description: '(retry) Yeni parametreler' },
|
|
302
|
+
description: { type: 'string', description: 'Aciklama' },
|
|
303
|
+
},
|
|
304
|
+
required: ['action'],
|
|
305
|
+
},
|
|
306
|
+
async execute(params) { return await workflow(params); },
|
|
307
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
const https = require('https');
|
|
2
|
+
|
|
3
|
+
async function xSearch(params) {
|
|
4
|
+
const { query, maxResults = 5, apiKey } = params;
|
|
5
|
+
if (!query) return { success: false, error: 'query gerekli' };
|
|
6
|
+
const key = apiKey || process.env.X_API_KEY || process.env.TWITTER_API_KEY;
|
|
7
|
+
if (!key) return { success: false, error: 'X API anahtari gerekli (X_API_KEY veya TWITTER_API_KEY ortam degiskeni)' };
|
|
8
|
+
|
|
9
|
+
return new Promise((resolve) => {
|
|
10
|
+
const encoded = encodeURIComponent(query);
|
|
11
|
+
const url = `https://api.twitter.com/2/tweets/search/recent?query=${encoded}&max_results=${Math.min(maxResults, 100)}&tweet.fields=created_at,public_metrics`;
|
|
12
|
+
const req = https.get(url, {
|
|
13
|
+
headers: { 'Authorization': `Bearer ${key}` },
|
|
14
|
+
timeout: 15000,
|
|
15
|
+
}, (res) => {
|
|
16
|
+
let data = '';
|
|
17
|
+
res.on('data', c => data += c);
|
|
18
|
+
res.on('end', () => {
|
|
19
|
+
if (res.statusCode !== 200) {
|
|
20
|
+
resolve({ success: false, error: `HTTP ${res.statusCode}: ${data.slice(0, 200)}` });
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
const parsed = JSON.parse(data);
|
|
25
|
+
const tweets = (parsed.data || []).map(t => ({
|
|
26
|
+
id: t.id, text: t.text, createdAt: t.created_at,
|
|
27
|
+
likes: t.public_metrics?.like_count || 0, retweets: t.public_metrics?.retweet_count || 0,
|
|
28
|
+
}));
|
|
29
|
+
resolve({ success: true, query, count: tweets.length, tweets, meta: parsed.meta });
|
|
30
|
+
} catch { resolve({ success: false, error: 'Yanit cozumlenemedi' }); }
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
req.on('error', (e) => resolve({ success: false, error: e.message }));
|
|
34
|
+
req.on('timeout', () => { req.destroy(); resolve({ success: false, error: 'Timeout' }); });
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
module.exports = {
|
|
39
|
+
name: 'x_search',
|
|
40
|
+
description: 'X/Twitter API v2 ile tweet aramasi. X_API_KEY veya TWITTER_API_KEY ortam degiskeni gerekli.',
|
|
41
|
+
inputSchema: {
|
|
42
|
+
type: 'object',
|
|
43
|
+
properties: {
|
|
44
|
+
query: { type: 'string', description: 'Arama sorgusu' },
|
|
45
|
+
maxResults: { type: 'number', description: 'Maksimum tweet sayisi (default: 5, max: 100)' },
|
|
46
|
+
apiKey: { type: 'string', description: 'Opsiyonel: API anahtari (default: X_API_KEY env)' },
|
|
47
|
+
},
|
|
48
|
+
required: ['query'],
|
|
49
|
+
},
|
|
50
|
+
async execute(params) { return await xSearch(params); },
|
|
51
|
+
};
|
package/src/utils/tools.js
CHANGED
|
@@ -60,6 +60,14 @@ const EMOJI_MAP = {
|
|
|
60
60
|
code_execution: '⚡',
|
|
61
61
|
// Cross-session
|
|
62
62
|
cross_session_memory: '🔗',
|
|
63
|
+
// v5.10.0: New tools
|
|
64
|
+
url_safety: '🛡️', approval: '✅', checkpoint: '💾', file_state: '🔍',
|
|
65
|
+
pii_redact: '🔒', clarify: '❓', session_search: '🔎', x_search: '🐦',
|
|
66
|
+
discord: '💬', send_message: '📨', async_delegation: '⏳', blueprint: '📐',
|
|
67
|
+
spotify: '🎧', homeassistant: '🏠', microsoft_graph: '📊', computer_use: '🖱️',
|
|
68
|
+
google_meet: '📹',
|
|
69
|
+
// Orchestrator
|
|
70
|
+
workflow: '⚙️',
|
|
63
71
|
};
|
|
64
72
|
|
|
65
73
|
// ── Toolset grouping ─────────────────────────────────────────────────────
|
|
@@ -105,6 +113,15 @@ const TOOLSET_MAP = {
|
|
|
105
113
|
kanban: 'planning',
|
|
106
114
|
cron_create: 'cron', thread_ownership: 'threads', code_execution: 'sandbox',
|
|
107
115
|
cross_session_memory: 'memory',
|
|
116
|
+
// v5.10.0: New tools
|
|
117
|
+
url_safety: 'security', approval: 'security', pii_redact: 'security',
|
|
118
|
+
checkpoint: 'system', file_state: 'system',
|
|
119
|
+
clarify: 'agent',
|
|
120
|
+
session_search: 'memory',
|
|
121
|
+
x_search: 'web', discord: 'communication', send_message: 'communication',
|
|
122
|
+
async_delegation: 'agent', blueprint: 'planning', workflow: 'orchestrator',
|
|
123
|
+
spotify: 'media', homeassistant: 'iot', microsoft_graph: 'office',
|
|
124
|
+
computer_use: 'automation', google_meet: 'communication',
|
|
108
125
|
};
|
|
109
126
|
|
|
110
127
|
// ── check_fn'ler (tool availability kontrolleri) ────────────────────────
|
|
@@ -132,6 +149,8 @@ const CHECK_FN_MAP = {
|
|
|
132
149
|
macos_screenshot: _checkMacOSTools,
|
|
133
150
|
phone_control: _checkMacOSTools,
|
|
134
151
|
phone_control_enhanced: _checkMacOSTools,
|
|
152
|
+
// v5.10.0: google_meet create macOS-only; computer_use partial cross-platform
|
|
153
|
+
google_meet: () => process.platform === 'darwin' || true, // only 'create' is macOS-only, 'open' cross-platform
|
|
135
154
|
};
|
|
136
155
|
|
|
137
156
|
// ── Provider filtering ───────────────────────────────────────────────────
|