natureco-cli 5.18.3 → 5.20.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/CHANGELOG.md +32 -0
- package/package.json +1 -1
- package/skills/a-b-testing/SKILL.md +34 -0
- package/skills/accessibility-audit/SKILL.md +34 -0
- package/skills/agent-memory/SKILL.md +34 -0
- package/skills/agent-orchestration/SKILL.md +34 -0
- package/skills/airunway-aks-setup/SKILL.md +73 -0
- package/skills/algorithmic-art/SKILL.md +405 -0
- package/skills/analytics-setup/SKILL.md +34 -0
- package/skills/api-design/SKILL.md +34 -0
- package/skills/api-versioning/SKILL.md +34 -0
- package/skills/appinsights-instrumentation/SKILL.md +76 -0
- package/skills/audio-transcription/SKILL.md +34 -0
- package/skills/authentication-patterns/SKILL.md +34 -0
- package/skills/authorization-rbac/SKILL.md +34 -0
- package/skills/azure-ai/SKILL.md +71 -0
- package/skills/azure-aigateway/SKILL.md +129 -0
- package/skills/azure-cloud-migrate/SKILL.md +52 -0
- package/skills/azure-compliance/SKILL.md +108 -0
- package/skills/azure-compute/SKILL.md +46 -0
- package/skills/azure-cost/SKILL.md +45 -0
- package/skills/azure-deploy/SKILL.md +97 -0
- package/skills/azure-diagnostics/SKILL.md +151 -0
- package/skills/azure-enterprise-infra-planner/SKILL.md +54 -0
- package/skills/azure-hosted-copilot-sdk/SKILL.md +89 -0
- package/skills/azure-kubernetes/SKILL.md +153 -0
- package/skills/azure-kusto/SKILL.md +231 -0
- package/skills/azure-messaging/SKILL.md +57 -0
- package/skills/azure-prepare/SKILL.md +165 -0
- package/skills/azure-quotas/SKILL.md +276 -0
- package/skills/azure-rbac/SKILL.md +17 -0
- package/skills/azure-reliability/SKILL.md +387 -0
- package/skills/azure-resource-lookup/SKILL.md +108 -0
- package/skills/azure-resource-visualizer/SKILL.md +183 -0
- package/skills/azure-storage/SKILL.md +100 -0
- package/skills/azure-upgrade/SKILL.md +91 -0
- package/skills/azure-validate/SKILL.md +72 -0
- package/skills/backup-strategy/SKILL.md +34 -0
- package/skills/bash-scripting/SKILL.md +34 -0
- package/skills/batch-api-calls/SKILL.md +34 -0
- package/skills/batch-processing/SKILL.md +34 -0
- package/skills/brainstorming/SKILL.md +159 -0
- package/skills/brand-guidelines/SKILL.md +73 -0
- package/skills/brandkit/SKILL.md +798 -0
- package/skills/brutalist-skill/SKILL.md +92 -0
- package/skills/bulk-file-operations/SKILL.md +34 -0
- package/skills/cache-responses/SKILL.md +34 -0
- package/skills/caching-strategy/SKILL.md +34 -0
- package/skills/calendar-optimization/SKILL.md +34 -0
- package/skills/canvas-design/SKILL.md +130 -0
- package/skills/cavecrew/SKILL.md +82 -0
- package/skills/caveman-commit/SKILL.md +65 -0
- package/skills/caveman-help/SKILL.md +63 -0
- package/skills/caveman-review/SKILL.md +55 -0
- package/skills/caveman-stats/SKILL.md +10 -0
- package/skills/changelog-generation/SKILL.md +34 -0
- package/skills/chat-bot-design/SKILL.md +34 -0
- package/skills/chunking-strategy/SKILL.md +34 -0
- package/skills/ci-cd-pipeline/SKILL.md +34 -0
- package/skills/classification-pipeline/SKILL.md +34 -0
- package/skills/claude-api/SKILL.md +356 -0
- package/skills/clipboard-master/SKILL.md +34 -0
- package/skills/code-explanation/SKILL.md +34 -0
- package/skills/code-generation/SKILL.md +34 -0
- package/skills/code-migration/SKILL.md +34 -0
- package/skills/code-review-checklist/SKILL.md +34 -0
- package/skills/composition-patterns/SKILL.md +89 -0
- package/skills/contact-management/SKILL.md +34 -0
- package/skills/content-generation/SKILL.md +34 -0
- package/skills/context-pruning/SKILL.md +34 -0
- package/skills/context-window-management/SKILL.md +34 -0
- package/skills/continuous-improvement/SKILL.md +34 -0
- package/skills/cron-scheduling/SKILL.md +34 -0
- package/skills/cross-platform-compat/SKILL.md +34 -0
- package/skills/csv-processing/SKILL.md +34 -0
- package/skills/daily-journal/SKILL.md +34 -0
- package/skills/data-analysis/SKILL.md +34 -0
- package/skills/data-backup/SKILL.md +34 -0
- package/skills/data-cleaning/SKILL.md +34 -0
- package/skills/data-extraction/SKILL.md +34 -0
- package/skills/data-validation/SKILL.md +34 -0
- package/skills/database-migrations/SKILL.md +34 -0
- package/skills/database-schema-design/SKILL.md +34 -0
- package/skills/decision-mapping/SKILL.md +84 -0
- package/skills/decision-matrix/SKILL.md +34 -0
- package/skills/dependency-management/SKILL.md +34 -0
- package/skills/deploy-to-vercel/SKILL.md +296 -0
- package/skills/design-an-interface/SKILL.md +94 -0
- package/skills/design-doc-mermaid/SKILL.md +498 -0
- package/skills/dev-environment-setup/SKILL.md +34 -0
- package/skills/develop-userscripts/SKILL.md +84 -0
- package/skills/distraction-blocker/SKILL.md +34 -0
- package/skills/doc-coauthoring/SKILL.md +375 -0
- package/skills/docker-optimization/SKILL.md +34 -0
- package/skills/document-template/SKILL.md +34 -0
- package/skills/documentation/SKILL.md +109 -0
- package/skills/documentation-gen/SKILL.md +34 -0
- package/skills/docx/SKILL.md +590 -0
- package/skills/edit-article/SKILL.md +15 -0
- package/skills/efficient-formatting/SKILL.md +34 -0
- package/skills/email-management/SKILL.md +34 -0
- package/skills/email-service/SKILL.md +34 -0
- package/skills/embedding-generation/SKILL.md +34 -0
- package/skills/entity-extraction/SKILL.md +34 -0
- package/skills/entra-agent-id/SKILL.md +356 -0
- package/skills/entra-app-registration/SKILL.md +191 -0
- package/skills/environment-config/SKILL.md +34 -0
- package/skills/error-handling/SKILL.md +34 -0
- package/skills/estimation-techniques/SKILL.md +34 -0
- package/skills/event-driven-architecture/SKILL.md +34 -0
- package/skills/excel-automation/SKILL.md +34 -0
- package/skills/execution-monitoring/SKILL.md +34 -0
- package/skills/expense-tracking/SKILL.md +34 -0
- package/skills/faceless-explainer/SKILL.md +202 -0
- package/skills/fastify/SKILL.md +75 -0
- package/skills/feature-engineering/SKILL.md +34 -0
- package/skills/feature-flags/SKILL.md +34 -0
- package/skills/file-conversion/SKILL.md +34 -0
- package/skills/file-upload-handling/SKILL.md +34 -0
- package/skills/fine-tuning-prep/SKILL.md +34 -0
- package/skills/focus-mode/SKILL.md +34 -0
- package/skills/form-validation/SKILL.md +34 -0
- package/skills/function-calling/SKILL.md +34 -0
- package/skills/general-video/SKILL.md +143 -0
- package/skills/git-guardrails-claude-code/SKILL.md +95 -0
- package/skills/git-workflow/SKILL.md +34 -0
- package/skills/github-actions-docs/SKILL.md +98 -0
- package/skills/goal-setting/SKILL.md +34 -0
- package/skills/gpt-tasteskill/SKILL.md +74 -0
- package/skills/graphql-design/SKILL.md +34 -0
- package/skills/grill-me/SKILL.md +7 -0
- package/skills/grilling/SKILL.md +10 -0
- package/skills/habit-tracker/SKILL.md +34 -0
- package/skills/hallucination-detection/SKILL.md +34 -0
- package/skills/handoff/SKILL.md +16 -0
- package/skills/hyperframes/SKILL.md +152 -0
- package/skills/hyperframes-animation/SKILL.md +82 -0
- package/skills/hyperframes-cli/SKILL.md +109 -0
- package/skills/hyperframes-core/SKILL.md +78 -0
- package/skills/hyperframes-creative/SKILL.md +68 -0
- package/skills/hyperframes-media/SKILL.md +97 -0
- package/skills/image-processing/SKILL.md +34 -0
- package/skills/image-to-code-skill/SKILL.md +1228 -0
- package/skills/imagegen-frontend-mobile/SKILL.md +1465 -0
- package/skills/imagegen-frontend-web/SKILL.md +987 -0
- package/skills/implement/SKILL.md +15 -0
- package/skills/init/SKILL.md +91 -0
- package/skills/internal-comms/SKILL.md +32 -0
- package/skills/json-transformation/SKILL.md +34 -0
- package/skills/keyboard-shortcuts/SKILL.md +34 -0
- package/skills/knowledge-base/SKILL.md +34 -0
- package/skills/knowledge-graph/SKILL.md +34 -0
- package/skills/kubernetes-deployment/SKILL.md +34 -0
- package/skills/language-translation/SKILL.md +34 -0
- package/skills/lark-approval/SKILL.md +56 -0
- package/skills/lark-base/SKILL.md +157 -0
- package/skills/lark-doc/SKILL.md +81 -0
- package/skills/lark-shared/SKILL.md +168 -0
- package/skills/lark-workflow-meeting-summary/SKILL.md +122 -0
- package/skills/linting-neostandard-eslint9/SKILL.md +64 -0
- package/skills/llm-chaining/SKILL.md +34 -0
- package/skills/localization-i18n/SKILL.md +34 -0
- package/skills/logging-best-practices/SKILL.md +34 -0
- package/skills/loop-me/SKILL.md +32 -0
- package/skills/machine-learning-pipeline/SKILL.md +34 -0
- package/skills/meeting-notes/SKILL.md +34 -0
- package/skills/meeting-scheduler/SKILL.md +34 -0
- package/skills/message-queues/SKILL.md +34 -0
- package/skills/message-summarization/SKILL.md +34 -0
- package/skills/microservices-architecture/SKILL.md +34 -0
- package/skills/microsoft-foundry/SKILL.md +262 -0
- package/skills/migrate-to-shoehorn/SKILL.md +118 -0
- package/skills/milestone-tracking/SKILL.md +34 -0
- package/skills/minimalist-skill/SKILL.md +85 -0
- package/skills/model-deployment/SKILL.md +34 -0
- package/skills/model-evaluation/SKILL.md +34 -0
- package/skills/monitoring-setup/SKILL.md +34 -0
- package/skills/monorepo-setup/SKILL.md +34 -0
- package/skills/motion-graphics/SKILL.md +170 -0
- package/skills/multi-agent-systems/SKILL.md +34 -0
- package/skills/music-to-video/SKILL.md +197 -0
- package/skills/network-troubleshooting/SKILL.md +34 -0
- package/skills/node/SKILL.md +94 -0
- package/skills/nodejs-core/SKILL.md +156 -0
- package/skills/note-organization/SKILL.md +34 -0
- package/skills/oauth/SKILL.md +186 -0
- package/skills/obsidian-vault/SKILL.md +59 -0
- package/skills/octocat/SKILL.md +93 -0
- package/skills/openclaw-secure-linux-cloud/SKILL.md +157 -0
- package/skills/opensource-guide-coach/SKILL.md +218 -0
- package/skills/output-skill/SKILL.md +49 -0
- package/skills/package-publishing/SKILL.md +34 -0
- package/skills/password-generator/SKILL.md +34 -0
- package/skills/pdf/SKILL.md +314 -0
- package/skills/pdf-processing/SKILL.md +34 -0
- package/skills/performance-optimization/SKILL.md +34 -0
- package/skills/pomodoro-timer/SKILL.md +34 -0
- package/skills/powershell-automation/SKILL.md +34 -0
- package/skills/pptx/SKILL.md +232 -0
- package/skills/pr-to-video/SKILL.md +235 -0
- package/skills/priority-filtering/SKILL.md +34 -0
- package/skills/product-launch-video/SKILL.md +205 -0
- package/skills/project-tracking/SKILL.md +34 -0
- package/skills/prompt-compression/SKILL.md +34 -0
- package/skills/prompt-engineering/SKILL.md +34 -0
- package/skills/push-notifications/SKILL.md +34 -0
- package/skills/python-appservice-deploy/SKILL.md +36 -0
- package/skills/qa/SKILL.md +130 -0
- package/skills/rag-implementation/SKILL.md +34 -0
- package/skills/rate-limiting/SKILL.md +34 -0
- package/skills/react-best-practices/SKILL.md +149 -0
- package/skills/react-native-skills/SKILL.md +121 -0
- package/skills/react-view-transitions/SKILL.md +320 -0
- package/skills/readme-i18n/SKILL.md +176 -0
- package/skills/real-time-communication/SKILL.md +34 -0
- package/skills/redesign-skill/SKILL.md +178 -0
- package/skills/refactoring-strategy/SKILL.md +34 -0
- package/skills/regex-mastery/SKILL.md +34 -0
- package/skills/remotion/SKILL.md +364 -0
- package/skills/report-generation/SKILL.md +34 -0
- package/skills/request-refactor-plan/SKILL.md +68 -0
- package/skills/research-compiler/SKILL.md +34 -0
- package/skills/resolving-merge-conflicts/SKILL.md +14 -0
- package/skills/responsive-design/SKILL.md +34 -0
- package/skills/rest-api-patterns/SKILL.md +34 -0
- package/skills/retrospectives/SKILL.md +34 -0
- package/skills/risk-assessment/SKILL.md +34 -0
- package/skills/roadmap-creation/SKILL.md +34 -0
- package/skills/running-claude-code-via-litellm-copilot/SKILL.md +263 -0
- package/skills/scaffold-exercises/SKILL.md +106 -0
- package/skills/search-implementation/SKILL.md +34 -0
- package/skills/secrets-management/SKILL.md +34 -0
- package/skills/secure-linux-web-hosting/SKILL.md +162 -0
- package/skills/security-audit/SKILL.md +34 -0
- package/skills/selective-memory/SKILL.md +34 -0
- package/skills/semantic-search/SKILL.md +34 -0
- package/skills/semantic-versioning/SKILL.md +34 -0
- package/skills/sentiment-analysis/SKILL.md +34 -0
- package/skills/seo-optimization/SKILL.md +34 -0
- package/skills/setup-pre-commit/SKILL.md +91 -0
- package/skills/shadcn/SKILL.md +267 -0
- package/skills/simple/SKILL.md +52 -0
- package/skills/skill-creator/SKILL.md +485 -0
- package/skills/skill-optimizer/SKILL.md +47 -0
- package/skills/skills-cli/SKILL.md +281 -0
- package/skills/slack-gif-creator/SKILL.md +254 -0
- package/skills/snipgrapher/SKILL.md +58 -0
- package/skills/snippet-manager/SKILL.md +34 -0
- package/skills/soft-skill/SKILL.md +98 -0
- package/skills/sprint-planning/SKILL.md +34 -0
- package/skills/sql-query-optimization/SKILL.md +34 -0
- package/skills/stakeholder-communication/SKILL.md +34 -0
- package/skills/state-management/SKILL.md +34 -0
- package/skills/statistical-analysis/SKILL.md +34 -0
- package/skills/stitch-skill/SKILL.md +184 -0
- package/skills/streaming-responses/SKILL.md +34 -0
- package/skills/structured-output/SKILL.md +34 -0
- package/skills/summarization-techniques/SKILL.md +34 -0
- package/skills/supabase/SKILL.md +135 -0
- package/skills/supabase-postgres-best-practices/SKILL.md +64 -0
- package/skills/system-diagnostics/SKILL.md +34 -0
- package/skills/systematic-debugging/SKILL.md +296 -0
- package/skills/talking-head-recut/SKILL.md +1191 -0
- package/skills/task-decomposition/SKILL.md +34 -0
- package/skills/task-prioritization/SKILL.md +34 -0
- package/skills/taste-skill/SKILL.md +1206 -0
- package/skills/taste-skill-v1/SKILL.md +226 -0
- package/skills/tdd/SKILL.md +108 -0
- package/skills/teach/SKILL.md +140 -0
- package/skills/template-library/SKILL.md +34 -0
- package/skills/test-driven-development/SKILL.md +371 -0
- package/skills/test-generation/SKILL.md +34 -0
- package/skills/testing-strategy/SKILL.md +34 -0
- package/skills/text-expansion/SKILL.md +34 -0
- package/skills/theme-factory/SKILL.md +59 -0
- package/skills/time-blocking/SKILL.md +34 -0
- package/skills/to-prd/SKILL.md +75 -0
- package/skills/token-budgeting/SKILL.md +34 -0
- package/skills/token-optimization/SKILL.md +34 -0
- package/skills/tool-calling-patterns/SKILL.md +34 -0
- package/skills/typescript-magician/SKILL.md +117 -0
- package/skills/tzst/SKILL.md +68 -0
- package/skills/ubiquitous-language/SKILL.md +93 -0
- package/skills/use-my-browser/SKILL.md +110 -0
- package/skills/using-superpowers/SKILL.md +121 -0
- package/skills/vector-database-setup/SKILL.md +34 -0
- package/skills/vercel-cli-with-tokens/SKILL.md +353 -0
- package/skills/vercel-optimize/SKILL.md +322 -0
- package/skills/video-editing/SKILL.md +34 -0
- package/skills/viral-instagram-reels/SKILL.md +180 -0
- package/skills/viral-short-form/SKILL.md +147 -0
- package/skills/viral-short-form-ideas/SKILL.md +184 -0
- package/skills/viral-tiktok-content/SKILL.md +180 -0
- package/skills/visualization-creation/SKILL.md +34 -0
- package/skills/web-artifacts-builder/SKILL.md +74 -0
- package/skills/web-design-guidelines/SKILL.md +39 -0
- package/skills/web-scraping/SKILL.md +34 -0
- package/skills/webapp-testing/SKILL.md +96 -0
- package/skills/webhook-handling/SKILL.md +34 -0
- package/skills/website-to-video/SKILL.md +145 -0
- package/skills/weekly-review/SKILL.md +34 -0
- package/skills/workflow-automation/SKILL.md +34 -0
- package/skills/writing-beats/SKILL.md +67 -0
- package/skills/writing-fragments/SKILL.md +79 -0
- package/skills/writing-great-skills/SKILL.md +82 -0
- package/skills/writing-guidelines/SKILL.md +39 -0
- package/skills/writing-plans/SKILL.md +174 -0
- package/skills/writing-shape/SKILL.md +79 -0
- package/skills/xdrop/SKILL.md +78 -0
- package/skills/xget/SKILL.md +87 -0
- package/skills/xlsx/SKILL.md +292 -0
- package/src/commands/code_v5.js +377 -73
- package/src/commands/repl.js +505 -86
- package/src/providers/model/anthropic.js +84 -0
- package/src/providers/model/gemini.js +49 -0
- package/src/providers/model/minimax.js +48 -0
- package/src/providers/model/ollama.js +42 -0
- package/src/providers/model/openai.js +49 -0
- package/src/providers/search/duckduckgo.js +45 -0
- package/src/providers/search/exa.js +52 -0
- package/src/providers/search/searxng.js +51 -0
- package/src/providers/search/tavily.js +47 -0
- package/src/tools/model_provider.js +71 -0
- package/src/tools/parallel_search.js +40 -49
- package/src/tools/search_provider.js +79 -0
- package/src/tools/skills_download.js +217 -0
- package/src/tools/web_search.js +42 -62
- package/src/tools/workflow.js +21 -9
- package/src/utils/cron.js +82 -126
- package/src/utils/effort-levels.js +42 -0
- package/src/utils/fallback-chain.js +72 -0
- package/src/utils/file-history.js +78 -0
- package/src/utils/model-provider.js +113 -0
- package/src/utils/permissions.js +147 -0
- package/src/utils/plan-mode.js +164 -0
- package/src/utils/provider-detect.js +7 -32
- package/src/utils/sandbox.js +60 -0
- package/src/utils/search-provider.js +62 -0
- package/src/utils/session-search.js +66 -0
- package/src/utils/structured-output.js +20 -0
- package/src/utils/system-prompt.js +28 -2
- package/src/utils/tasks.js +132 -0
- package/src/utils/tool-hooks.js +154 -0
- package/src/utils/tools.js +18 -2
- package/src/utils/ultra-review.js +59 -0
- package/src/utils/worktree.js +192 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
const { ModelProvider, registerProvider, DEFAULT_ANTHROPIC_SYSTEM } = require('../../utils/model-provider');
|
|
2
|
+
|
|
3
|
+
class AnthropicProvider extends ModelProvider {
|
|
4
|
+
constructor(config = {}) {
|
|
5
|
+
super(config);
|
|
6
|
+
this.name = 'anthropic';
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
getEndpoint() {
|
|
10
|
+
const base = (this.config.providerUrl || '').replace(/\/+$/, '');
|
|
11
|
+
return `${base}/v1/messages`;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
extractSystem(messages) {
|
|
15
|
+
const systemMsg = messages.find(m => m.role === 'system');
|
|
16
|
+
if (!systemMsg) return DEFAULT_ANTHROPIC_SYSTEM;
|
|
17
|
+
const content = systemMsg.content;
|
|
18
|
+
if (typeof content === 'string' && content.trim()) return content;
|
|
19
|
+
if (Array.isArray(content) && content.length > 0) return content;
|
|
20
|
+
return DEFAULT_ANTHROPIC_SYSTEM;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
buildRequest(messages, options = {}) {
|
|
24
|
+
const userMsgs = messages.filter(m => m.role !== 'system');
|
|
25
|
+
return {
|
|
26
|
+
model: this.config.providerModel || 'claude-3-5-haiku-20241022',
|
|
27
|
+
messages: userMsgs.map(m => ({ role: m.role, content: m.content })),
|
|
28
|
+
system: this.extractSystem(messages),
|
|
29
|
+
max_tokens: options.max_tokens || 4096,
|
|
30
|
+
temperature: options.temperature ?? 0.7,
|
|
31
|
+
stream: options.stream || false,
|
|
32
|
+
...(options.tools?.length > 0 ? { tools: options.tools } : {}),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
parseResponse(data) {
|
|
37
|
+
const textContent = data.content?.find(c => c.type === 'text')?.text || '';
|
|
38
|
+
const toolCalls = data.content
|
|
39
|
+
?.filter(c => c.type === 'tool_use')
|
|
40
|
+
?.map(c => ({
|
|
41
|
+
id: c.id,
|
|
42
|
+
type: 'function',
|
|
43
|
+
function: { name: c.name, arguments: JSON.stringify(c.input || {}) },
|
|
44
|
+
})) || [];
|
|
45
|
+
return {
|
|
46
|
+
role: 'assistant',
|
|
47
|
+
content: textContent,
|
|
48
|
+
tool_calls: toolCalls.length > 0 ? toolCalls : undefined,
|
|
49
|
+
usage: data.usage || undefined,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
normalizeTools(tools) {
|
|
54
|
+
return (tools || []).map(t => ({
|
|
55
|
+
name: t.name || t.function?.name,
|
|
56
|
+
description: t.description || t.function?.description || '',
|
|
57
|
+
input_schema: t.inputSchema || t.input_schema || t.function?.parameters || { type: 'object', properties: {} },
|
|
58
|
+
}));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
parseToolCalls(message) {
|
|
62
|
+
if (Array.isArray(message.content)) {
|
|
63
|
+
return message.content
|
|
64
|
+
.filter(c => c.type === 'tool_use')
|
|
65
|
+
.map(c => ({
|
|
66
|
+
id: c.id,
|
|
67
|
+
type: 'function',
|
|
68
|
+
function: { name: c.name, arguments: JSON.stringify(c.input || {}) },
|
|
69
|
+
}));
|
|
70
|
+
}
|
|
71
|
+
return [];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
getAuthHeaders() {
|
|
75
|
+
return {
|
|
76
|
+
'x-api-key': this.config.providerApiKey || '',
|
|
77
|
+
'anthropic-version': '2023-06-01',
|
|
78
|
+
'Content-Type': 'application/json',
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
registerProvider('anthropic', AnthropicProvider);
|
|
84
|
+
module.exports = AnthropicProvider;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
const { ModelProvider, registerProvider } = require('../../utils/model-provider');
|
|
2
|
+
|
|
3
|
+
class GeminiProvider extends ModelProvider {
|
|
4
|
+
constructor(config = {}) {
|
|
5
|
+
super(config);
|
|
6
|
+
this.name = 'gemini';
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
getEndpoint() {
|
|
10
|
+
const base = (this.config.providerUrl || '').replace(/\/+$/, '');
|
|
11
|
+
return `${base}/openai/chat/completions`;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
buildRequest(messages, options = {}) {
|
|
15
|
+
return {
|
|
16
|
+
model: this.config.providerModel || 'gemini-2.0-flash',
|
|
17
|
+
messages,
|
|
18
|
+
max_tokens: options.max_tokens || 4096,
|
|
19
|
+
temperature: options.temperature ?? 0.7,
|
|
20
|
+
stream: options.stream || false,
|
|
21
|
+
...(options.tools?.length > 0 ? { tools: options.tools, tool_choice: 'auto' } : {}),
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
parseResponse(data) {
|
|
26
|
+
const choice = data.choices?.[0];
|
|
27
|
+
if (!choice) return { role: 'assistant', content: '' };
|
|
28
|
+
return {
|
|
29
|
+
role: 'assistant',
|
|
30
|
+
content: choice.message?.content || choice.text || '',
|
|
31
|
+
tool_calls: choice.message?.tool_calls || undefined,
|
|
32
|
+
usage: data.usage || undefined,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
normalizeTools(tools) {
|
|
37
|
+
return (tools || []).map(t => ({
|
|
38
|
+
type: 'function',
|
|
39
|
+
function: {
|
|
40
|
+
name: t.name || t.function?.name,
|
|
41
|
+
description: t.description || t.function?.description || '',
|
|
42
|
+
parameters: t.inputSchema || t.input_schema || t.function?.parameters || { type: 'object', properties: {} },
|
|
43
|
+
},
|
|
44
|
+
}));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
registerProvider('gemini', GeminiProvider);
|
|
49
|
+
module.exports = GeminiProvider;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
const { ModelProvider, registerProvider } = require('../../utils/model-provider');
|
|
2
|
+
|
|
3
|
+
class MiniMaxProvider extends ModelProvider {
|
|
4
|
+
constructor(config = {}) {
|
|
5
|
+
super(config);
|
|
6
|
+
this.name = 'minimax';
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
getEndpoint() {
|
|
10
|
+
const base = (this.config.providerUrl || '').replace(/\/+$/, '');
|
|
11
|
+
return `${base}/v1/text/chatcompletion_v2`;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
buildRequest(messages, options = {}) {
|
|
15
|
+
return {
|
|
16
|
+
model: this.config.providerModel || 'minimax-m2.5',
|
|
17
|
+
messages,
|
|
18
|
+
max_tokens: options.max_tokens || 4096,
|
|
19
|
+
temperature: options.temperature ?? 0.7,
|
|
20
|
+
stream: options.stream || false,
|
|
21
|
+
...(options.tools?.length > 0 ? { tools: options.tools, tool_choice: 'auto' } : {}),
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
parseResponse(data) {
|
|
26
|
+
const choice = data.choices?.[0] || data.base_resp || {};
|
|
27
|
+
return {
|
|
28
|
+
role: 'assistant',
|
|
29
|
+
content: choice.message?.content || choice.text || data.reply || '',
|
|
30
|
+
tool_calls: choice.message?.tool_calls || undefined,
|
|
31
|
+
usage: data.usage || undefined,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
normalizeTools(tools) {
|
|
36
|
+
return (tools || []).map(t => ({
|
|
37
|
+
type: 'function',
|
|
38
|
+
function: {
|
|
39
|
+
name: t.name || t.function?.name,
|
|
40
|
+
description: t.description || t.function?.description || '',
|
|
41
|
+
parameters: t.inputSchema || t.input_schema || t.function?.parameters || { type: 'object', properties: {} },
|
|
42
|
+
},
|
|
43
|
+
}));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
registerProvider('minimax', MiniMaxProvider);
|
|
48
|
+
module.exports = MiniMaxProvider;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const { ModelProvider, registerProvider } = require('../../utils/model-provider');
|
|
2
|
+
|
|
3
|
+
class OllamaProvider extends ModelProvider {
|
|
4
|
+
constructor(config = {}) {
|
|
5
|
+
super(config);
|
|
6
|
+
this.name = 'ollama';
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
getEndpoint() {
|
|
10
|
+
const base = (this.config.providerUrl || '').replace(/\/+$/, '');
|
|
11
|
+
return `${base}/chat/completions`;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
buildRequest(messages, options = {}) {
|
|
15
|
+
return {
|
|
16
|
+
model: this.config.providerModel || 'llama3.2',
|
|
17
|
+
messages,
|
|
18
|
+
max_tokens: options.max_tokens || 4096,
|
|
19
|
+
temperature: options.temperature ?? 0.7,
|
|
20
|
+
stream: options.stream || false,
|
|
21
|
+
...(options.tools?.length > 0 ? { tools: options.tools, tool_choice: 'auto' } : {}),
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
parseResponse(data) {
|
|
26
|
+
const choice = data.choices?.[0];
|
|
27
|
+
if (!choice) return { role: 'assistant', content: data.response || '' };
|
|
28
|
+
return {
|
|
29
|
+
role: 'assistant',
|
|
30
|
+
content: choice.message?.content || choice.text || data.response || '',
|
|
31
|
+
tool_calls: choice.message?.tool_calls || undefined,
|
|
32
|
+
usage: data.usage || undefined,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
normalizeTools(tools) {
|
|
37
|
+
return [];
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
registerProvider('ollama', OllamaProvider);
|
|
42
|
+
module.exports = OllamaProvider;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
const { ModelProvider, registerProvider, DEFAULT_ANTHROPIC_SYSTEM } = require('../../utils/model-provider');
|
|
2
|
+
|
|
3
|
+
class OpenAIProvider extends ModelProvider {
|
|
4
|
+
constructor(config = {}) {
|
|
5
|
+
super(config);
|
|
6
|
+
this.name = 'openai';
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
getEndpoint() {
|
|
10
|
+
const base = (this.config.providerUrl || '').replace(/\/+$/, '');
|
|
11
|
+
return `${base}/chat/completions`;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
buildRequest(messages, options = {}) {
|
|
15
|
+
return {
|
|
16
|
+
model: this.config.providerModel || 'gpt-4o-mini',
|
|
17
|
+
messages,
|
|
18
|
+
max_tokens: options.max_tokens || 4096,
|
|
19
|
+
temperature: options.temperature ?? 0.7,
|
|
20
|
+
stream: options.stream || false,
|
|
21
|
+
...(options.tools?.length > 0 ? { tools: options.tools, tool_choice: 'auto' } : {}),
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
parseResponse(data) {
|
|
26
|
+
const choice = data.choices?.[0];
|
|
27
|
+
if (!choice) return { role: 'assistant', content: data.response || data.content || '' };
|
|
28
|
+
return {
|
|
29
|
+
role: 'assistant',
|
|
30
|
+
content: choice.message?.content || choice.text || '',
|
|
31
|
+
tool_calls: choice.message?.tool_calls || undefined,
|
|
32
|
+
usage: data.usage || undefined,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
normalizeTools(tools) {
|
|
37
|
+
return (tools || []).map(t => ({
|
|
38
|
+
type: 'function',
|
|
39
|
+
function: {
|
|
40
|
+
name: t.name || t.function?.name,
|
|
41
|
+
description: t.description || t.function?.description || '',
|
|
42
|
+
parameters: t.inputSchema || t.input_schema || t.function?.parameters || { type: 'object', properties: {} },
|
|
43
|
+
},
|
|
44
|
+
}));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
registerProvider('openai', OpenAIProvider);
|
|
49
|
+
module.exports = OpenAIProvider;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
const { SearchProvider, registerProvider } = require('../../utils/search-provider');
|
|
2
|
+
|
|
3
|
+
class DuckDuckGoProvider extends SearchProvider {
|
|
4
|
+
constructor(config = {}) {
|
|
5
|
+
super(config);
|
|
6
|
+
this.name = 'duckduckgo';
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
async search(query, options = {}) {
|
|
10
|
+
const maxResults = options.maxResults || 5;
|
|
11
|
+
const encoded = encodeURIComponent(query);
|
|
12
|
+
|
|
13
|
+
const response = await fetch(
|
|
14
|
+
`https://html.duckduckgo.com/html/?q=${encoded}`,
|
|
15
|
+
{ headers: { 'User-Agent': 'NatureCo-CLI/2.0' } }
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
if (!response.ok) {
|
|
19
|
+
return { success: false, error: `DuckDuckGo error: ${response.status}`, provider: this.name };
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const html = await response.text();
|
|
23
|
+
const results = [];
|
|
24
|
+
const resultRegex = /<a rel="nofollow" class="result__a" href="([^"]+)"[^>]*>([\s\S]*?)<\/a>[\s\S]*?<a class="result__snippet"[^>]*>([\s\S]*?)<\/a>/gi;
|
|
25
|
+
let match;
|
|
26
|
+
while ((match = resultRegex.exec(html)) !== null && results.length < maxResults) {
|
|
27
|
+
results.push({
|
|
28
|
+
title: match[2].replace(/<[^>]+>/g, '').trim(),
|
|
29
|
+
snippet: match[3].replace(/<[^>]+>/g, '').trim(),
|
|
30
|
+
url: match[1],
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
success: true,
|
|
36
|
+
query,
|
|
37
|
+
results,
|
|
38
|
+
count: results.length,
|
|
39
|
+
provider: this.name,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
registerProvider('duckduckgo', DuckDuckGoProvider);
|
|
45
|
+
module.exports = DuckDuckGoProvider;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
const { SearchProvider, registerProvider } = require('../../utils/search-provider');
|
|
2
|
+
|
|
3
|
+
class ExaProvider extends SearchProvider {
|
|
4
|
+
constructor(config = {}) {
|
|
5
|
+
super(config);
|
|
6
|
+
this.name = 'exa';
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
async search(query, options = {}) {
|
|
10
|
+
const apiKey = this.config.exaApiKey || process.env.EXA_API_KEY;
|
|
11
|
+
if (!apiKey) {
|
|
12
|
+
return { success: false, error: 'Exa API key gerekli. Kur: natureco config set exaApiKey <key>', provider: this.name };
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const response = await fetch('https://api.exa.ai/search', {
|
|
16
|
+
method: 'POST',
|
|
17
|
+
headers: { 'Content-Type': 'application/json', 'x-api-key': apiKey },
|
|
18
|
+
body: JSON.stringify({
|
|
19
|
+
query,
|
|
20
|
+
type: options.type || 'auto',
|
|
21
|
+
numResults: options.maxResults || 5,
|
|
22
|
+
includeTerms: options.includeTerms,
|
|
23
|
+
excludeTerms: options.excludeTerms,
|
|
24
|
+
}),
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
if (!response.ok) {
|
|
28
|
+
const err = await response.text().catch(() => '');
|
|
29
|
+
return { success: false, error: `Exa error ${response.status}: ${err}`, provider: this.name };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const data = await response.json();
|
|
33
|
+
const results = (data.results || []).map(r => ({
|
|
34
|
+
title: r.title,
|
|
35
|
+
snippet: r.text,
|
|
36
|
+
url: r.url,
|
|
37
|
+
score: r.score,
|
|
38
|
+
publishedDate: r.publishedDate,
|
|
39
|
+
}));
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
success: true,
|
|
43
|
+
query,
|
|
44
|
+
results,
|
|
45
|
+
count: results.length,
|
|
46
|
+
provider: this.name,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
registerProvider('exa', ExaProvider);
|
|
52
|
+
module.exports = ExaProvider;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
const { SearchProvider, registerProvider } = require('../../utils/search-provider');
|
|
2
|
+
|
|
3
|
+
class SearXNGProvider extends SearchProvider {
|
|
4
|
+
constructor(config = {}) {
|
|
5
|
+
super(config);
|
|
6
|
+
this.name = 'searxng';
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
async search(query, options = {}) {
|
|
10
|
+
const instanceUrl = (options.instanceUrl || this.config.searxngInstanceUrl || 'https://search.sapti.me').replace(/\/+$/, '');
|
|
11
|
+
const maxResults = options.maxResults || 5;
|
|
12
|
+
|
|
13
|
+
const searchParams = new URLSearchParams({
|
|
14
|
+
q: query,
|
|
15
|
+
format: 'json',
|
|
16
|
+
language: 'en',
|
|
17
|
+
categories: options.categories || 'general',
|
|
18
|
+
pageno: 1,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const response = await fetch(`${instanceUrl}/search?${searchParams}`, {
|
|
22
|
+
headers: { 'User-Agent': 'NatureCo-CLI/2.0', 'Accept': 'application/json' },
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
if (!response.ok) {
|
|
26
|
+
return { success: false, error: `SearXNG error: ${response.status}`, provider: this.name };
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const data = await response.json();
|
|
30
|
+
const raw = (data.results || []).slice(0, maxResults);
|
|
31
|
+
const results = raw.map(r => ({
|
|
32
|
+
title: r.title,
|
|
33
|
+
snippet: r.content,
|
|
34
|
+
url: r.url,
|
|
35
|
+
engine: r.engine,
|
|
36
|
+
category: r.category,
|
|
37
|
+
}));
|
|
38
|
+
|
|
39
|
+
return {
|
|
40
|
+
success: true,
|
|
41
|
+
query,
|
|
42
|
+
instance: instanceUrl,
|
|
43
|
+
results,
|
|
44
|
+
count: results.length,
|
|
45
|
+
provider: this.name,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
registerProvider('searxng', SearXNGProvider);
|
|
51
|
+
module.exports = SearXNGProvider;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
const { SearchProvider, registerProvider } = require('../../utils/search-provider');
|
|
2
|
+
|
|
3
|
+
class TavilyProvider extends SearchProvider {
|
|
4
|
+
constructor(config = {}) {
|
|
5
|
+
super(config);
|
|
6
|
+
this.name = 'tavily';
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
async search(query, options = {}) {
|
|
10
|
+
const apiKey = this.config.tavilyApiKey || process.env.TAVILY_API_KEY;
|
|
11
|
+
if (!apiKey) {
|
|
12
|
+
return { success: false, error: 'Tavily API key gerekli. Kur: natureco config set tavilyApiKey tvly_xxx', provider: this.name };
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const response = await fetch('https://api.tavily.com/search', {
|
|
16
|
+
method: 'POST',
|
|
17
|
+
headers: { 'Content-Type': 'application/json' },
|
|
18
|
+
body: JSON.stringify({
|
|
19
|
+
api_key: apiKey,
|
|
20
|
+
query,
|
|
21
|
+
search_depth: options.searchDepth || 'basic',
|
|
22
|
+
max_results: options.maxResults || 5,
|
|
23
|
+
}),
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
if (!response.ok) {
|
|
27
|
+
return { success: false, error: `Tavily API error: ${response.status}`, provider: this.name };
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const data = await response.json();
|
|
31
|
+
if (data.error) {
|
|
32
|
+
return { success: false, error: data.error, provider: this.name };
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const results = this.normalizeResults(data.results || []);
|
|
36
|
+
return {
|
|
37
|
+
success: true,
|
|
38
|
+
query,
|
|
39
|
+
results,
|
|
40
|
+
count: results.length,
|
|
41
|
+
provider: this.name,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
registerProvider('tavily', TavilyProvider);
|
|
47
|
+
module.exports = TavilyProvider;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
require('../providers/model/openai');
|
|
2
|
+
require('../providers/model/anthropic');
|
|
3
|
+
require('../providers/model/gemini');
|
|
4
|
+
require('../providers/model/minimax');
|
|
5
|
+
require('../providers/model/ollama');
|
|
6
|
+
|
|
7
|
+
const name = 'model_provider';
|
|
8
|
+
const description = 'Model provider management. status/switch/list — view or switch between model providers (openai, anthropic, gemini, minimax, ollama). Also supports model-specific queries.';
|
|
9
|
+
const parameters = {
|
|
10
|
+
type: 'object',
|
|
11
|
+
properties: {
|
|
12
|
+
action: {
|
|
13
|
+
type: 'string',
|
|
14
|
+
enum: ['status', 'list', 'switch'],
|
|
15
|
+
description: 'Operation: status, list, or switch',
|
|
16
|
+
},
|
|
17
|
+
provider: { type: 'string', description: '(switch) Provider name to switch to' },
|
|
18
|
+
model: { type: 'string', description: '(switch) Model to use with provider' },
|
|
19
|
+
},
|
|
20
|
+
required: ['action'],
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
async function execute(params) {
|
|
24
|
+
const fs = require('fs');
|
|
25
|
+
const path = require('path');
|
|
26
|
+
const os = require('os');
|
|
27
|
+
const cfg = (() => { try { return JSON.parse(fs.readFileSync(path.join(os.homedir(), '.natureco', 'config.json'), 'utf8')); } catch { return {}; } })();
|
|
28
|
+
const { getProviderNames, getProvider, resolveProviderConfig, detectFamily } = require('../utils/model-provider');
|
|
29
|
+
|
|
30
|
+
switch (params.action) {
|
|
31
|
+
case 'status': {
|
|
32
|
+
const active = resolveProviderConfig(cfg);
|
|
33
|
+
const family = detectFamily(cfg.providerUrl, cfg.providerModel);
|
|
34
|
+
const avail = getProviderNames().sort();
|
|
35
|
+
return {
|
|
36
|
+
activeProvider: active,
|
|
37
|
+
detectedFamily: family,
|
|
38
|
+
available: avail,
|
|
39
|
+
url: (cfg.providerUrl || '').replace(/\/\/.*@/, '//***@'),
|
|
40
|
+
model: cfg.providerModel || '(not set)',
|
|
41
|
+
env: process.env.NATURECO_MODEL_PROVIDER || '(not set)',
|
|
42
|
+
configValue: cfg.modelProvider || '(not set, using auto-detect)',
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
case 'list': {
|
|
47
|
+
const avail = getProviderNames().sort();
|
|
48
|
+
return {
|
|
49
|
+
success: true,
|
|
50
|
+
providers: avail.map(name => {
|
|
51
|
+
const Provider = getProvider(name);
|
|
52
|
+
const inst = new Provider(cfg);
|
|
53
|
+
return { name, endpoint: inst.getEndpoint() };
|
|
54
|
+
}),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
case 'switch': {
|
|
59
|
+
if (!params.provider) return { success: false, error: 'provider name gerekli' };
|
|
60
|
+
const { setConfigValue } = require('../utils/config');
|
|
61
|
+
setConfigValue('modelProvider', params.provider);
|
|
62
|
+
if (params.model) setConfigValue('providerModel', params.model);
|
|
63
|
+
return { success: true, message: `Model provider switched to: ${params.provider}${params.model ? ' (model: ' + params.model + ')' : ''}` };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
default:
|
|
67
|
+
return { success: false, error: `Unknown action: ${params.action}` };
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
module.exports = { name, description, parameters, execute };
|
|
@@ -1,77 +1,68 @@
|
|
|
1
1
|
const { getConfig } = require('../utils/config');
|
|
2
|
+
const { getProviderNames, getProvider } = require('../utils/search-provider');
|
|
3
|
+
require('../providers/search/tavily');
|
|
4
|
+
require('../providers/search/duckduckgo');
|
|
5
|
+
require('../providers/search/searxng');
|
|
6
|
+
require('../providers/search/exa');
|
|
2
7
|
|
|
3
8
|
module.exports = {
|
|
4
9
|
name: 'parallel_search',
|
|
5
|
-
description: '
|
|
10
|
+
description: 'Run search across multiple search providers in parallel and merge results. Uses configured providers (DuckDuckGo, SearXNG, Exa, Tavily).',
|
|
6
11
|
inputSchema: {
|
|
7
12
|
type: 'object',
|
|
8
13
|
properties: {
|
|
9
14
|
query: { type: 'string', description: 'Search query' },
|
|
10
|
-
maxResults: { type: 'number', description: 'Maximum results (default:
|
|
15
|
+
maxResults: { type: 'number', description: 'Maximum results per provider (default: 3)' },
|
|
16
|
+
providers: { type: 'array', items: { type: 'string' }, description: 'Providers to use (default: all available, except Tavily which needs API key)' },
|
|
11
17
|
},
|
|
12
|
-
required: ['query']
|
|
18
|
+
required: ['query'],
|
|
13
19
|
},
|
|
14
20
|
|
|
15
21
|
async execute(params) {
|
|
16
22
|
try {
|
|
17
|
-
const
|
|
18
|
-
const
|
|
23
|
+
const config = getConfig();
|
|
24
|
+
const query = params.query;
|
|
25
|
+
const maxResults = params.maxResults || 3;
|
|
26
|
+
const allProviders = getProviderNames();
|
|
19
27
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
{ headers: { 'User-Agent': 'NatureCo-CLI/2.0' } }
|
|
23
|
-
);
|
|
28
|
+
let providersToUse = params.providers || allProviders;
|
|
29
|
+
providersToUse = providersToUse.filter(name => allProviders.includes(name));
|
|
24
30
|
|
|
25
|
-
if (
|
|
26
|
-
return { success: false, error:
|
|
31
|
+
if (providersToUse.length === 0) {
|
|
32
|
+
return { success: false, error: 'Kullanilabilir search provider bulunamadi' };
|
|
27
33
|
}
|
|
28
34
|
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (data.Results && Array.isArray(data.Results)) {
|
|
41
|
-
for (const r of data.Results) {
|
|
42
|
-
if (results.length >= maxResults) break;
|
|
43
|
-
if (r.Text && r.FirstURL) {
|
|
44
|
-
results.push({ title: r.Text.split(' - ')[0] || r.Text, snippet: r.Text, url: r.FirstURL });
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
35
|
+
const results = await Promise.allSettled(
|
|
36
|
+
providersToUse.map(async (name) => {
|
|
37
|
+
const Provider = getProvider(name);
|
|
38
|
+
if (!Provider) throw new Error(`Provider bulunamadi: ${name}`);
|
|
39
|
+
const provider = new Provider(config);
|
|
40
|
+
const result = await provider.search(query, { maxResults });
|
|
41
|
+
return { provider: name, result };
|
|
42
|
+
})
|
|
43
|
+
);
|
|
48
44
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
if (results.length >= maxResults) break;
|
|
58
|
-
if (t.Text && t.FirstURL) {
|
|
59
|
-
results.push({ title: t.Text.split(' - ')[0] || t.Text, snippet: t.Text, url: t.FirstURL });
|
|
60
|
-
}
|
|
61
|
-
}
|
|
45
|
+
const merged = [];
|
|
46
|
+
for (const r of results) {
|
|
47
|
+
if (r.status === 'fulfilled' && r.value.result.success) {
|
|
48
|
+
for (const item of r.value.result.results || []) {
|
|
49
|
+
merged.push({
|
|
50
|
+
...item,
|
|
51
|
+
_provider: r.value.provider,
|
|
52
|
+
});
|
|
62
53
|
}
|
|
63
54
|
}
|
|
64
55
|
}
|
|
65
56
|
|
|
66
57
|
return {
|
|
67
58
|
success: true,
|
|
68
|
-
query
|
|
69
|
-
results,
|
|
70
|
-
count:
|
|
71
|
-
|
|
59
|
+
query,
|
|
60
|
+
results: merged.slice(0, maxResults * providersToUse.length),
|
|
61
|
+
count: merged.length,
|
|
62
|
+
providersUsed: providersToUse,
|
|
72
63
|
};
|
|
73
64
|
} catch (error) {
|
|
74
65
|
return { success: false, error: error.message };
|
|
75
66
|
}
|
|
76
|
-
}
|
|
77
|
-
};
|
|
67
|
+
},
|
|
68
|
+
};
|