mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-16 20:11:08 +00:00
Add a comprehensive AI assistant feature to netcatty, enabling AI-powered terminal automation and multi-host orchestration. Core features: - AI chat side panel (Zed-style) with agent selector, session history, conversation export (Markdown/JSON/TXT), and streaming responses - Catty Agent: built-in terminal assistant with 9 tools (terminal exec, SFTP read/write, multi-host orchestration) using zod schemas - BYOK provider support: OpenAI, Anthropic, Google, Ollama, OpenRouter, and custom OpenAI-compatible endpoints - Three-tier permission model: Observer / Confirm / Autonomous - Command safety: blocklist patterns, doom loop detection, abort support - External agent support: ACP protocol (JSON-RPC over stdio) for Claude Agent, Codex CLI, Gemini CLI, and custom agents Tech stack: - Vercel AI SDK (ai, @ai-sdk/openai, @ai-sdk/anthropic, @ai-sdk/google) with streamText + fullStream for streaming tool-call loops - AI Elements: adapted conversation (use-stick-to-bottom), message (streamdown markdown), prompt-input (InputGroup) components - Custom bridge fetch adapter routing all API calls through Electron main process IPC to avoid CORS - zod for tool parameter schemas UI components: - AIChatSidePanel, AgentSelector, ChatInput, ChatMessageList - PermissionDialog, ExecutionPlan, ConversationExport - AI Elements: conversation, message, tool-call, prompt-input - New UI primitives: InputGroup, Spinner - Settings AI tab for BYOK configuration and safety settings Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
92 lines
3.4 KiB
TypeScript
92 lines
3.4 KiB
TypeScript
import { cn } from '../../lib/utils';
|
|
import type { ComponentProps, HTMLAttributes } from 'react';
|
|
import { forwardRef } from 'react';
|
|
|
|
export type InputGroupProps = HTMLAttributes<HTMLDivElement>;
|
|
|
|
export const InputGroup = forwardRef<HTMLDivElement, InputGroupProps>(
|
|
({ className, ...props }, ref) => (
|
|
<div
|
|
ref={ref}
|
|
className={cn(
|
|
'flex flex-col rounded-[22px] border border-border/65 bg-background/92 shadow-[0_18px_42px_rgba(0,0,0,0.34),inset_0_1px_0_rgba(255,255,255,0.04)] transition-[border-color,background-color,box-shadow]',
|
|
'supports-[backdrop-filter]:backdrop-blur-sm',
|
|
'focus-within:border-primary/45 focus-within:bg-background focus-within:ring-1 focus-within:ring-primary/20',
|
|
'overflow-hidden',
|
|
className,
|
|
)}
|
|
{...props}
|
|
/>
|
|
),
|
|
);
|
|
InputGroup.displayName = 'InputGroup';
|
|
|
|
export type InputGroupTextareaProps = ComponentProps<'textarea'>;
|
|
|
|
export const InputGroupTextarea = forwardRef<HTMLTextAreaElement, InputGroupTextareaProps>(
|
|
({ className, ...props }, ref) => (
|
|
<textarea
|
|
ref={ref}
|
|
className={cn(
|
|
'w-full resize-none bg-transparent text-[13px] text-foreground/92 selection:bg-primary/25',
|
|
'placeholder:text-muted-foreground/62 placeholder:font-medium placeholder:text-[13px]',
|
|
'focus:outline-none disabled:opacity-40 disabled:cursor-not-allowed',
|
|
'px-4 pt-3.5 pb-2 leading-[20px]',
|
|
'field-sizing-content min-h-[82px] max-h-52',
|
|
className,
|
|
)}
|
|
{...props}
|
|
/>
|
|
),
|
|
);
|
|
InputGroupTextarea.displayName = 'InputGroupTextarea';
|
|
|
|
export type InputGroupAddonProps = HTMLAttributes<HTMLDivElement> & {
|
|
align?: 'block-start' | 'block-end';
|
|
};
|
|
|
|
export const InputGroupAddon = forwardRef<HTMLDivElement, InputGroupAddonProps>(
|
|
({ className, align = 'block-end', ...props }, ref) => (
|
|
<div
|
|
ref={ref}
|
|
className={cn(
|
|
'flex items-center px-2.5 py-1.5',
|
|
align === 'block-start' && 'border-b border-border/35 bg-muted/8',
|
|
align === 'block-end' && 'border-t border-border/60 bg-muted/10',
|
|
className,
|
|
)}
|
|
{...props}
|
|
/>
|
|
),
|
|
);
|
|
InputGroupAddon.displayName = 'InputGroupAddon';
|
|
|
|
export type InputGroupButtonProps = ComponentProps<'button'> & {
|
|
variant?: 'default' | 'ghost' | 'outline' | 'destructive';
|
|
size?: 'sm' | 'icon-sm' | 'default';
|
|
};
|
|
|
|
export const InputGroupButton = forwardRef<HTMLButtonElement, InputGroupButtonProps>(
|
|
({ className, variant = 'ghost', size = 'icon-sm', disabled, ...props }, ref) => (
|
|
<button
|
|
ref={ref}
|
|
type="button"
|
|
disabled={disabled}
|
|
className={cn(
|
|
'inline-flex items-center justify-center rounded-md transition-colors cursor-pointer',
|
|
'disabled:opacity-30 disabled:cursor-default',
|
|
size === 'icon-sm' && 'h-7 w-7',
|
|
size === 'sm' && 'h-7 px-2 text-[12px] gap-1',
|
|
size === 'default' && 'h-8 px-3 text-[13px] gap-1.5',
|
|
variant === 'ghost' && 'text-muted-foreground/78 hover:text-foreground hover:bg-muted/45',
|
|
variant === 'default' && 'bg-primary/80 text-primary-foreground hover:bg-primary',
|
|
variant === 'outline' && 'border border-border/40 text-muted-foreground/85 hover:text-foreground hover:bg-muted/35',
|
|
variant === 'destructive' && 'text-destructive/70 hover:text-destructive hover:bg-destructive/10',
|
|
className,
|
|
)}
|
|
{...props}
|
|
/>
|
|
),
|
|
);
|
|
InputGroupButton.displayName = 'InputGroupButton';
|