ghostykit 0.0.0-stage → 0.2.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.
@@ -0,0 +1,84 @@
1
+ import { type CSSProperties, type ReactNode } from "react";
2
+ import { type ToolVerbs } from "../core/steps";
3
+ import type { Attachment, Reference, Turn } from "../core/types";
4
+ import type { PilotTransport } from "../transport";
5
+ import { type UploadResult } from "./Composer";
6
+ import { type MarkdownOptions, type PilotIcon, type PilotTheme } from "./context";
7
+ import { type PilotStrings } from "./strings";
8
+ import { type PermissionHandler, type Pilot, type UsePilotOptions } from "./usePilot";
9
+ export interface PilotoFeatures {
10
+ /** Botones de adjuntar. Default: sí si hay `upload`. */
11
+ attachments?: boolean;
12
+ /** «Reintentar» en la última respuesta. Default: sí. */
13
+ retry?: boolean;
14
+ /** «Copiar» en las burbujas. Default: sí. */
15
+ copy?: boolean;
16
+ /** Tokens y costo bajo cada respuesta. Default: sí. */
17
+ usage?: boolean;
18
+ /** Selector de modelo (si el agente ofrece varios). Default: sí. */
19
+ models?: boolean;
20
+ /** Las opciones finales de la última respuesta como botones. Default: sí. */
21
+ replyOptions?: boolean;
22
+ /** «· 12 s» junto a la frase de espera. Default: sí. */
23
+ duration?: boolean;
24
+ }
25
+ export interface PilotoSlots {
26
+ /** Las entregas de cada respuesta (archivos, páginas, tarjetas propias). */
27
+ renderDeliveries?: (turn: Turn, live: boolean) => ReactNode;
28
+ /** Botones propios en la barra del composer. */
29
+ composerExtras?: ReactNode;
30
+ /** Lo que se ve con el hilo vacío (en lugar del saludo de casa). */
31
+ emptyState?: ReactNode;
32
+ /** Arriba a la derecha, sobre el hilo (compartir, abrir en grande…). */
33
+ headerActions?: ReactNode;
34
+ /** Pegado arriba del composer (un aviso, un banner). */
35
+ aboveComposer?: ReactNode;
36
+ }
37
+ export interface PilotoProps extends UsePilotOptions {
38
+ transport: PilotTransport | null;
39
+ /** Si la app ya usa `usePilot` (para leer el estado afuera), pásalo aquí. */
40
+ pilot?: Pilot;
41
+ agentName?: string;
42
+ locale?: "es" | "en";
43
+ strings?: Partial<PilotStrings>;
44
+ theme?: PilotTheme;
45
+ /** La piel: `ghosty` (default), `easybits`, `neutral`, o el nombre de una propia (`[data-skin]`). */
46
+ skin?: string;
47
+ className?: string;
48
+ style?: CSSProperties;
49
+ toolVerbs?: ToolVerbs;
50
+ toolIcons?: Record<string, PilotIcon>;
51
+ /** El texto del usuario como se pinta (quita la fontanería que la app pega al prompt). */
52
+ formatUserText?: (text: string) => string;
53
+ markdown?: MarkdownOptions;
54
+ /** Saludo del hilo vacío. */
55
+ welcome?: ReactNode;
56
+ avatar?: ReactNode;
57
+ placeholder?: string;
58
+ suggestions?: string[];
59
+ upload?: (file: File) => Promise<UploadResult>;
60
+ transcribe?: (audio: Blob) => Promise<string>;
61
+ voiceNoteText?: (transcript: string) => string;
62
+ features?: PilotoFeatures;
63
+ /**
64
+ * Contestar un permiso (p. ej. el POST de aprobación de la app, con su sesión). Default:
65
+ * `transport.respondPermission`. Devuelve `{resolved:false}` si ya no estaba abierto.
66
+ */
67
+ onPermission?: PermissionHandler;
68
+ /** Referencias controladas (si no, Piloto las guarda; agrégalas con `ref.addReference`). */
69
+ references?: Reference[];
70
+ onReferencesChange?: (refs: Reference[]) => void;
71
+ /** Clic en un chip de referencia (resaltar la tarjeta en la app). */
72
+ onReferenceClick?: (ref: Reference) => void;
73
+ slots?: PilotoSlots;
74
+ }
75
+ /** Lo que la app puede hacer desde afuera (`<Piloto ref={…} />`). */
76
+ export interface PilotoHandle {
77
+ send: (text: string, attachments?: Attachment[]) => void;
78
+ addReference: (ref: Reference) => void;
79
+ /** Escribe en la caja sin mandar. */
80
+ setDraft: (text: string) => void;
81
+ focus: () => void;
82
+ }
83
+ export declare const Piloto: import("react").ForwardRefExoticComponent<PilotoProps & import("react").RefAttributes<PilotoHandle>>;
84
+ export default Piloto;
@@ -0,0 +1,19 @@
1
+ import { type ReactNode } from "react";
2
+ import type { ConnectPhase } from "../core/types";
3
+ /** Los tres puntos de «escribiendo». Color y animación por CSS (`.piloto-typing`). */
4
+ export declare function TypingDots(): import("react").JSX.Element;
5
+ export declare function WaitLabel({ phase, since, elsewhere, onLost, showDuration, }: {
6
+ phase: ConnectPhase;
7
+ /** Desde que se MANDÓ el mensaje (no desde que se montó la etiqueta). */
8
+ since?: number | null;
9
+ elsewhere?: boolean;
10
+ onLost?: () => void;
11
+ showDuration?: boolean;
12
+ }): import("react").JSX.Element;
13
+ /** Lo que ocupa el hilo mientras se conecta: tres pasos reales en vez de un «Conectando…» mudo. */
14
+ export declare function ConnectingState({ phase, error, avatar, onRetry }: {
15
+ phase: ConnectPhase;
16
+ error: string | null;
17
+ avatar?: ReactNode;
18
+ onRetry?: () => void;
19
+ }): import("react").JSX.Element;
@@ -0,0 +1,22 @@
1
+ import { type ReactNode } from "react";
2
+ import type { ToolEntry } from "../core/types";
3
+ import { type PilotIcon } from "./context";
4
+ /** La garra de máquina de peluches: el ícono de «usó una herramienta» que no tiene clase propia. */
5
+ export declare function ClawIcon({ className }: {
6
+ className?: string;
7
+ }): import("react").JSX.Element;
8
+ /** Íconos de casa por `kind`. Lo desconocido cae en la garra. */
9
+ export declare const DEFAULT_TOOL_ICONS: Record<string, PilotIcon>;
10
+ export declare function AgentSteps({ tools, live }: {
11
+ tools: ToolEntry[];
12
+ live: boolean;
13
+ }): import("react").JSX.Element;
14
+ /** El detalle de un paso (lista desplegada): rótulo, detalle y ruta. */
15
+ export declare function ToolRow({ tool }: {
16
+ tool: ToolEntry;
17
+ }): import("react").JSX.Element;
18
+ /** La narración del agente como avance: una palomita por lo que ya dijo que hacía. */
19
+ export declare function Narration({ steps, children }: {
20
+ steps: string[];
21
+ children?: ReactNode;
22
+ }): import("react").JSX.Element;
@@ -0,0 +1,29 @@
1
+ import { type BlockProps } from "streamdown";
2
+ /** 400 ms lineal, como claude.ai. */
3
+ export declare const CHUNK_MS = 400;
4
+ /**
5
+ * Cuánto del texto se enseña ya. Sólo anima si el turno estaba VIVO al montar.
6
+ * `whole`: llegó completo de una vez (el remate de los subagentes): se escribe tramo a tramo hasta
7
+ * el final, sin la regla de «quieto 600 ms = suelta el resto».
8
+ */
9
+ export declare function useTextAtPace(text: string, live: boolean, whole?: boolean): {
10
+ visible: string;
11
+ animate: boolean;
12
+ };
13
+ type Chunk = {
14
+ start: number;
15
+ t: number;
16
+ };
17
+ type Registry = Map<string, {
18
+ chunks: Chunk[];
19
+ total: number;
20
+ }>;
21
+ export declare const ChunksContext: import("react").Context<{
22
+ registry: Registry;
23
+ part: number;
24
+ } | null>;
25
+ /** Un registro por respuesta: vive lo que viva la burbuja. */
26
+ export declare function useChunkRegistry(): Registry;
27
+ /** El bloque de Streamdown con sus tramos. Sólo cambia de plugin cuando cambia su texto. */
28
+ export declare const ChunkedBlock: import("react").NamedExoticComponent<BlockProps>;
29
+ export {};
@@ -0,0 +1,34 @@
1
+ import { type ComponentType } from "react";
2
+ import { type ToolVerbs } from "../core/steps";
3
+ import { type PilotStrings } from "./strings";
4
+ /** Un ícono: cualquier componente que acepte `className` (los de lucide-react sirven tal cual). */
5
+ export type PilotIcon = ComponentType<{
6
+ className?: string;
7
+ }>;
8
+ export type PilotTheme = "light" | "dark" | "auto";
9
+ /** Ajustes del markdown de las respuestas. */
10
+ export interface MarkdownOptions {
11
+ /** Reescribe el markdown antes de pintarlo (p. ej. `#12` → `[#12](#folio-12)`). */
12
+ transform?: (md: string) => string;
13
+ /** Un clic en un enlace. Devuelve `true` si la app lo manejó (no se abre el aviso de salida). */
14
+ onLinkClick?: (href: string, event: MouseEvent) => boolean;
15
+ }
16
+ export interface PilotoConfig {
17
+ strings: PilotStrings;
18
+ toolVerbs: ToolVerbs;
19
+ /** Ícono por `kind` de paso o por NOMBRE de herramienta. */
20
+ toolIcons: Record<string, PilotIcon>;
21
+ formatUserText: (text: string) => string;
22
+ theme: PilotTheme;
23
+ /** La piel: `ghosty` (default), `easybits`, `neutral` o una propia (`data-skin`). */
24
+ skin: string;
25
+ markdown: MarkdownOptions;
26
+ }
27
+ export declare const PilotoContext: import("react").Context<PilotoConfig>;
28
+ export declare const usePiloto: () => PilotoConfig;
29
+ /** Las clases de la raíz: el alcance de los estilos y el tema. Lo usan también los portales. */
30
+ export declare function rootProps(theme: PilotTheme, skin?: string): {
31
+ className: string;
32
+ "data-theme": PilotTheme;
33
+ "data-skin": string;
34
+ };
@@ -0,0 +1,14 @@
1
+ export { Piloto, Piloto as default, type PilotoFeatures, type PilotoHandle, type PilotoProps, type PilotoSlots } from "./Piloto";
2
+ export { usePilot, useSseTransport, type PermissionAnswer, type PermissionHandler, type Pilot, type SendOptions, type TurnDoneInfo, type UsePilotOptions } from "./usePilot";
3
+ export { AgentBubble, CopyUserMessage, DeliveryChips, ReplyOptionButtons, TurnFooter, UsageStats, UserBubble, type AgentBubbleProps } from "./Bubble";
4
+ export { AgentSteps, ClawIcon, DEFAULT_TOOL_ICONS, Narration, ToolRow } from "./Steps";
5
+ export { LinkSafetyModal, Markdown } from "./Markdown";
6
+ export { useTextAtPace } from "./TextAtPace";
7
+ export { Composer, ModelPicker, mimeOf, type ComposerProps, type UploadResult } from "./Composer";
8
+ export { ConfirmCard, DecisionLines } from "./ConfirmCard";
9
+ export { ReferenceChips, Suggestions } from "./Chips";
10
+ export { ConnectingState, TypingDots, WaitLabel } from "./Status";
11
+ export { PilotoContext, usePiloto, type MarkdownOptions, type PilotIcon, type PilotoConfig, type PilotTheme } from "./context";
12
+ export { STRINGS_EN, STRINGS_ES, type PilotStrings } from "./strings";
13
+ export * from "../core";
14
+ export { PilotHttpError, createPostStreamTransport, createSseTransport, readSse, type PilotListener, type PilotTransport, type PostStreamTransportOptions, type SseTransportOptions, type SubscribeOptions, } from "../transport";