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,89 @@
1
+ import type { ConnectPhase } from "../core/types";
2
+ export interface PilotStrings {
3
+ /** Para formatear números y moneda. */
4
+ numberLocale: string;
5
+ placeholder: (agentName: string) => string;
6
+ /** Sin `agentName`. */
7
+ placeholderDefault: string;
8
+ placeholderConnecting: string;
9
+ send: string;
10
+ stop: string;
11
+ uploading: string;
12
+ uploadingN: (n: number) => string;
13
+ attachImage: string;
14
+ attachFile: string;
15
+ noImages: string;
16
+ removeAttachment: string;
17
+ removeReference: string;
18
+ dropFiles: string;
19
+ dropHint: string;
20
+ tooBig: (name: string, mb: number) => string;
21
+ tooMany: (max: number) => string;
22
+ cantSeeImage: (name: string) => string;
23
+ cantUpload: (name: string) => string;
24
+ uploadFailed: string;
25
+ recordVoice: string;
26
+ voiceNote: string;
27
+ cancelVoice: string;
28
+ stopAndSendVoice: string;
29
+ micDenied: string;
30
+ voiceEmpty: string;
31
+ voiceFailed: string;
32
+ model: string;
33
+ thinking: string;
34
+ steered: string;
35
+ /** Lo que se ve mientras conecta, por fase (en primera persona: habla el agente). */
36
+ waitPhase: Record<ConnectPhase, string>;
37
+ /** Qué dice el agente de un turno del que sólo sabe cuánto lleva. */
38
+ howItGoes: (seconds: number) => string;
39
+ /** Frases propias mientras piensa (rotan cada 4 s en lugar de `howItGoes`). */
40
+ thinkingPhrases?: string[];
41
+ stillWorking: string;
42
+ cantStart: string;
43
+ retry: string;
44
+ resume: string;
45
+ /** Con `interrupted.canContinue`: el servidor continúa ESE turno. */
46
+ continueTurn: string;
47
+ interrupted: (reason: string) => string;
48
+ interruptedOurFault: string;
49
+ copy: string;
50
+ copied: string;
51
+ copyMessage: string;
52
+ worked: (seconds: number) => string;
53
+ stepsExpand: string;
54
+ stepsCollapse: string;
55
+ earlierSteps: (n: number) => string;
56
+ withProblems: (n: number) => string;
57
+ running: string;
58
+ done: string;
59
+ failed: string;
60
+ step: string;
61
+ replyOptions: string;
62
+ connectSteps: {
63
+ label: string;
64
+ hint: string;
65
+ }[];
66
+ connectRetry: string;
67
+ linkTitle: string;
68
+ linkCopy: string;
69
+ linkCopied: string;
70
+ linkOpen: string;
71
+ close: string;
72
+ goToLatest: string;
73
+ confirmTitle: string;
74
+ approve: string;
75
+ reject: string;
76
+ confirmExpired: string;
77
+ confirmFailed: string;
78
+ /** «Vence en 14:32». */
79
+ expiresIn: (mmss: string) => string;
80
+ expiredNow: string;
81
+ decisionApproved: string;
82
+ decisionRejected: string;
83
+ decisionExpired: string;
84
+ stampApproved: string;
85
+ stampRejected: string;
86
+ stampExpired: string;
87
+ }
88
+ export declare const STRINGS_ES: PilotStrings;
89
+ export declare const STRINGS_EN: PilotStrings;
@@ -0,0 +1,67 @@
1
+ import type { Attachment, Interrupted, PermissionRequest, PilotState, Reference, SendInput, Turn } from "../core/types";
2
+ import { type PilotTransport, type SseTransportOptions } from "../transport";
3
+ export interface TurnDoneInfo {
4
+ /** El texto final de la respuesta. */
5
+ text: string;
6
+ turnId?: string;
7
+ /** Cuánto tardó (sólo si lo encargó este cliente). */
8
+ seconds?: number;
9
+ /** Se cortó por falla del servidor (el chat ofrece Retomar). */
10
+ interrupted?: Interrupted;
11
+ }
12
+ export interface UsePilotOptions {
13
+ /** El hilo guardado. Si cambia (la app volvió a leerlo), se reconcilia en reposo. */
14
+ initialTurns?: Turn[];
15
+ /** Lo que el usuario ve en pantalla: viaja con CADA turno. Una función se evalúa al mandar. */
16
+ context?: unknown | (() => unknown);
17
+ onTurnStart?: () => void;
18
+ /** Fin de turno con su texto: aquí la app re-lee datos, repinta efectos, avisa. */
19
+ onTurnDone?: (info: TurnDoneInfo) => void;
20
+ /** El servidor bautizó el hilo. */
21
+ onTitle?: (title?: string) => void;
22
+ /** El servidor pide cuenta (cupo sin cuenta agotado). */
23
+ onNeedsLogin?: () => void;
24
+ /** El stream se cerró (el hilo sigue en el servidor y se puede reabrir). */
25
+ onDisconnected?: () => void;
26
+ /** Cada evento crudo, antes del reductor (analítica, efectos propios). */
27
+ onEvent?: (name: string, data: unknown) => void;
28
+ /** Cada mensaje que sale (analítica: «primer mensaje»). */
29
+ onSend?: (input: SendInput) => void;
30
+ }
31
+ export interface SendOptions {
32
+ resume?: boolean;
33
+ resumeTurnId?: string;
34
+ references?: Reference[];
35
+ }
36
+ export interface Pilot {
37
+ state: PilotState;
38
+ send: (text: string, attachments?: Attachment[], opts?: SendOptions) => Promise<void>;
39
+ stop: () => void;
40
+ /** Reintenta el último mensaje (quita la respuesta anterior). */
41
+ retry: () => void;
42
+ /** Turno PERDIDO (no arrancó): se abandona y se reenvía. */
43
+ abandonAndRetry: () => void;
44
+ /** «Retomar» un turno cortado por el servidor. */
45
+ resume: () => void;
46
+ setModel: (value: string) => void;
47
+ /**
48
+ * Contesta una tarjeta. `via` = cómo la contesta la app (p. ej. su ruta de aprobación con la
49
+ * sesión); sin él, `transport.respondPermission`. La decisión queda anotada en la respuesta.
50
+ */
51
+ respondPermission: (id: string, optionId: string, via?: PermissionHandler) => Promise<PermissionAnswer>;
52
+ /** Anota lo que ya contestó la app (sin volver a contestar): la tarjeta sale y queda la decisión. */
53
+ recordDecision: (id: string, optionId: string, answer: PermissionAnswer, asked?: PermissionRequest) => void;
54
+ /** Una tarjeta que venció sin contestarse: sale de las abiertas como «venció». */
55
+ expirePermission: (id: string) => void;
56
+ /** Un mensaje del agente que llegó fuera de un turno: espera a que cierre el turno vivo. */
57
+ appendAgentMessage: (text: string) => void;
58
+ }
59
+ /** Lo que contesta la app al resolver una tarjeta. `resolved: false` = ya no estaba abierta. */
60
+ export type PermissionAnswer = {
61
+ resolved: boolean;
62
+ detail?: string;
63
+ } | void;
64
+ export type PermissionHandler = (id: string, optionId: string) => Promise<PermissionAnswer> | PermissionAnswer;
65
+ export declare function usePilot(transport: PilotTransport | null, opts?: UsePilotOptions): Pilot;
66
+ /** Un transporte SSE estable por `base` (crearlo en cada render reabriría el stream). */
67
+ export declare function useSseTransport(base: string | null | undefined, opts?: SseTransportOptions): PilotTransport | null;