mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-24 00:50:44 +00:00
Security: - Fix command injection in 15+ shell interpolation sites with shellQuote() - Add token-based authentication to MCP TCP server - Fix heredoc delimiter collision in SFTP write fallbacks - Add case-insensitive flag to mcpServerBridge command blocklist - Add exhaustive default case to createModelFromConfig Architecture: - Split aiBridge.cjs (1971→1483 lines) into 4 modules: shellUtils, codexHelpers, claudeHelpers, ptyExec - Split SettingsAITab.tsx (1480→520 lines) into 10 sub-components - Extract shared processCattyStream from AIChatSidePanel.tsx (-168 lines) - Consolidate duplicate PTY execution logic into shared ptyExec.cjs - Consolidate duplicate stripAnsi/toUnpackedAsarPath utilities Code quality: - Remove ~33 debug console.log statements from production code - Remove dead code: terminal_read_output stub, checkToolPermission, isCommandAllowed, READ_ONLY_TOOLS - Unify bridge type accessor in useAIState.ts (eliminate 15 unsafe casts) - Add localStorage session pruning (50 sessions / 200 messages cap) - Fix ModelSelector onBlur race condition (setTimeout → preventDefault) - Fix duplicate getShellEnv() calls in Codex helpers - Remove unused _config param from claudeAgentAdapter - Type claudeAgentAdapter bridge parameter directly as ClaudeBridge Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
96 lines
3.3 KiB
TypeScript
96 lines
3.3 KiB
TypeScript
import React from "react";
|
|
import { Pencil, Trash2 } from "lucide-react";
|
|
import type { ProviderConfig } from "../../../../infrastructure/ai/types";
|
|
import { useI18n } from "../../../../application/i18n/I18nProvider";
|
|
import { Toggle } from "../../settings-ui";
|
|
import { cn } from "../../../../lib/utils";
|
|
import { ProviderIconBadge } from "./ProviderIconBadge";
|
|
import { ProviderConfigForm } from "./ProviderConfigForm";
|
|
|
|
export const ProviderCard: React.FC<{
|
|
provider: ProviderConfig;
|
|
isActive: boolean;
|
|
onToggleEnabled: (enabled: boolean) => void;
|
|
onEdit: () => void;
|
|
onRemove: () => void;
|
|
onUpdate: (updates: Partial<ProviderConfig>) => void;
|
|
isEditing: boolean;
|
|
onCancelEdit: () => void;
|
|
}> = ({ provider, isActive, onToggleEnabled, onEdit, onRemove, onUpdate, isEditing, onCancelEdit }) => {
|
|
const { t } = useI18n();
|
|
const hasApiKey = !!provider.apiKey;
|
|
|
|
return (
|
|
<div
|
|
className={cn(
|
|
"rounded-lg border p-4 transition-colors",
|
|
isActive ? "border-primary/50 bg-primary/5" : "border-border/60 bg-muted/20",
|
|
)}
|
|
>
|
|
<div className="flex items-center gap-3">
|
|
{/* Provider icon */}
|
|
<ProviderIconBadge providerId={provider.providerId} />
|
|
|
|
{/* Info */}
|
|
<div className="flex-1 min-w-0">
|
|
<div className="flex items-center gap-2">
|
|
<span className="text-sm font-medium truncate">{provider.name}</span>
|
|
{isActive && (
|
|
<span className="text-[10px] px-1.5 py-0.5 rounded-full bg-primary/20 text-primary font-medium">
|
|
{t('ai.providers.active')}
|
|
</span>
|
|
)}
|
|
</div>
|
|
<div className="flex items-center gap-2 mt-0.5">
|
|
<span
|
|
className={cn(
|
|
"text-xs",
|
|
hasApiKey ? "text-emerald-500" : "text-muted-foreground",
|
|
)}
|
|
>
|
|
{hasApiKey ? t('ai.providers.apiKeyConfigured') : t('ai.providers.noApiKey')}
|
|
</span>
|
|
{provider.defaultModel && (
|
|
<>
|
|
<span className="text-muted-foreground text-xs">|</span>
|
|
<span className="text-xs text-muted-foreground truncate">{provider.defaultModel}</span>
|
|
</>
|
|
)}
|
|
</div>
|
|
</div>
|
|
|
|
{/* Actions */}
|
|
<div className="flex items-center gap-1 shrink-0">
|
|
<button
|
|
onClick={onEdit}
|
|
className="p-1.5 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted transition-colors"
|
|
title={t('ai.providers.configure')}
|
|
>
|
|
<Pencil size={14} />
|
|
</button>
|
|
<button
|
|
onClick={onRemove}
|
|
className="p-1.5 rounded-md text-muted-foreground hover:text-destructive hover:bg-destructive/10 transition-colors"
|
|
title={t('ai.providers.remove')}
|
|
>
|
|
<Trash2 size={14} />
|
|
</button>
|
|
<Toggle checked={provider.enabled} onChange={onToggleEnabled} />
|
|
</div>
|
|
</div>
|
|
|
|
{/* Expandable config form */}
|
|
{isEditing && (
|
|
<ProviderConfigForm
|
|
provider={provider}
|
|
onSave={(updates) => {
|
|
onUpdate(updates);
|
|
onCancelEdit();
|
|
}}
|
|
onCancel={onCancelEdit}
|
|
/>
|
|
)}
|
|
</div>
|
|
);
|
|
};
|