btcp-browser-agent 0.1.14 → 0.1.17

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,73 @@
1
+ /**
2
+ * Transport abstraction for the client API
3
+ *
4
+ * This module defines the transport interface that allows the client to use
5
+ * different communication mechanisms (Chrome extension messaging, HTTP, WebSocket, etc.)
6
+ */
7
+ import type { Command, Response } from '../types.js';
8
+ /**
9
+ * Transport connection state
10
+ */
11
+ export type TransportState = 'disconnected' | 'connecting' | 'connected' | 'error';
12
+ /**
13
+ * Events emitted by transports
14
+ */
15
+ export interface TransportEvents {
16
+ /** Transport connected successfully */
17
+ connected: () => void;
18
+ /** Transport disconnected */
19
+ disconnected: (reason?: string) => void;
20
+ /** Transport encountered an error */
21
+ error: (error: Error) => void;
22
+ /** Transport state changed */
23
+ stateChange: (state: TransportState) => void;
24
+ }
25
+ /**
26
+ * Base transport options shared by all transports
27
+ */
28
+ export interface TransportOptions {
29
+ /** Enable debug logging */
30
+ debug?: boolean;
31
+ }
32
+ /**
33
+ * Transport interface for sending commands to the backend
34
+ *
35
+ * Transports handle the communication layer between the client and the
36
+ * command execution backend (background script, HTTP server, etc.)
37
+ */
38
+ export interface Transport {
39
+ /**
40
+ * Human-readable name for this transport (e.g., 'chrome-extension', 'http')
41
+ */
42
+ readonly name: string;
43
+ /**
44
+ * Send a command and wait for the response
45
+ */
46
+ send(command: Command): Promise<Response>;
47
+ /**
48
+ * Connect the transport (if applicable)
49
+ * Some transports may be stateless and not require connection
50
+ */
51
+ connect(): Promise<void>;
52
+ /**
53
+ * Disconnect the transport and clean up resources
54
+ */
55
+ disconnect(): void;
56
+ /**
57
+ * Get the current connection state
58
+ */
59
+ getState(): TransportState;
60
+ /**
61
+ * Check if the transport is currently connected
62
+ */
63
+ isConnected(): boolean;
64
+ /**
65
+ * Register an event handler
66
+ */
67
+ on<K extends keyof TransportEvents>(event: K, handler: TransportEvents[K]): void;
68
+ /**
69
+ * Unregister an event handler
70
+ */
71
+ off<K extends keyof TransportEvents>(event: K, handler: TransportEvents[K]): void;
72
+ }
73
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Transport abstraction for the client API
3
+ *
4
+ * This module defines the transport interface that allows the client to use
5
+ * different communication mechanisms (Chrome extension messaging, HTTP, WebSocket, etc.)
6
+ */
7
+ export {};
8
+ //# sourceMappingURL=types.js.map