@bytespell/amux-client 0.0.19 → 0.0.22

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.
@@ -1,153 +0,0 @@
1
- import type { AmuxClientEvents, ConnectionStatus, Message, Turn, PermissionOptionData } from '../types.js';
2
- import type { AmuxClient } from '../client.js';
3
- /**
4
- * Get the AmuxClient instance
5
- *
6
- * @example
7
- * ```tsx
8
- * function Chat() {
9
- * const client = useAmux();
10
- *
11
- * const handleSubmit = (message: string) => {
12
- * client.prompt(message);
13
- * };
14
- *
15
- * return <ChatUI onSubmit={handleSubmit} />;
16
- * }
17
- * ```
18
- */
19
- export declare function useAmux(): AmuxClient;
20
- /**
21
- * State returned by useAmuxState
22
- */
23
- export interface AmuxState {
24
- connectionStatus: ConnectionStatus;
25
- isConnected: boolean;
26
- isReady: boolean;
27
- cwd: string | null;
28
- sessionId: string | null;
29
- agent: {
30
- type: string;
31
- name: string;
32
- } | null;
33
- availableAgents: Array<{
34
- id: string;
35
- name: string;
36
- }>;
37
- }
38
- /**
39
- * Get reactive session state
40
- *
41
- * @example
42
- * ```tsx
43
- * function StatusBar() {
44
- * const { isConnected, isReady, cwd, agent } = useAmuxState();
45
- *
46
- * return (
47
- * <div>
48
- * {isReady ? `${agent?.name} @ ${cwd}` : 'Connecting...'}
49
- * </div>
50
- * );
51
- * }
52
- * ```
53
- */
54
- export declare function useAmuxState(): AmuxState;
55
- /**
56
- * Status returned by useAmuxStatus
57
- */
58
- export interface AmuxStatus {
59
- isProcessing: boolean;
60
- isStreaming: boolean;
61
- isAwaitingPermission: boolean;
62
- pendingPermission: {
63
- requestId: string;
64
- toolCall?: unknown;
65
- options: PermissionOptionData[];
66
- } | null;
67
- }
68
- /**
69
- * Get reactive processing status
70
- *
71
- * @example
72
- * ```tsx
73
- * function ChatInput() {
74
- * const { isProcessing, isAwaitingPermission } = useAmuxStatus();
75
- * const disabled = isProcessing || isAwaitingPermission;
76
- *
77
- * return <input disabled={disabled} ... />;
78
- * }
79
- * ```
80
- */
81
- export declare function useAmuxStatus(): AmuxStatus;
82
- /**
83
- * Messages state returned by useAmuxMessages
84
- */
85
- export interface AmuxMessages {
86
- messages: Message[];
87
- turns: Turn[];
88
- currentTurn: Turn | null;
89
- }
90
- /**
91
- * Get reactive messages and turns
92
- *
93
- * @example
94
- * ```tsx
95
- * function MessageList() {
96
- * const { messages, currentTurn } = useAmuxMessages();
97
- *
98
- * return (
99
- * <>
100
- * {messages.map(msg => <MessageBubble key={msg.id} message={msg} />)}
101
- * {currentTurn?.status === 'streaming' && <StreamingIndicator />}
102
- * </>
103
- * );
104
- * }
105
- * ```
106
- */
107
- export declare function useAmuxMessages(): AmuxMessages;
108
- /**
109
- * Subscribe to specific client events
110
- *
111
- * @example
112
- * ```tsx
113
- * function PermissionDialog() {
114
- * const [pending, setPending] = useState<PermissionRequest | null>(null);
115
- * const client = useAmux();
116
- *
117
- * useAmuxEvent('permission_request', (req) => {
118
- * setPending(req);
119
- * });
120
- *
121
- * const handleResponse = (optionId: string) => {
122
- * if (pending) {
123
- * client.respondToPermission(pending.requestId, optionId);
124
- * setPending(null);
125
- * }
126
- * };
127
- *
128
- * if (!pending) return null;
129
- * return <Dialog options={pending.options} onSelect={handleResponse} />;
130
- * }
131
- * ```
132
- */
133
- export declare function useAmuxEvent<K extends keyof AmuxClientEvents>(event: K, handler: (data: AmuxClientEvents[K]) => void): void;
134
- /**
135
- * Get a function to send prompts
136
- *
137
- * @example
138
- * ```tsx
139
- * function ChatInput() {
140
- * const sendPrompt = useAmuxPrompt();
141
- * const [message, setMessage] = useState('');
142
- *
143
- * const handleSubmit = () => {
144
- * sendPrompt(message);
145
- * setMessage('');
146
- * };
147
- *
148
- * return <input value={message} onChange={e => setMessage(e.target.value)} onSubmit={handleSubmit} />;
149
- * }
150
- * ```
151
- */
152
- export declare function useAmuxPrompt(): (message: string) => void;
153
- //# sourceMappingURL=hooks.d.ts.map
@@ -1,29 +0,0 @@
1
- /**
2
- * React integration for @bytespell/amux-client
3
- *
4
- * @example
5
- * ```tsx
6
- * import { AmuxProvider, useAmux, useAmuxState, useAmuxMessages } from '@bytespell/amux-client/react';
7
- *
8
- * function App() {
9
- * return (
10
- * <AmuxProvider url="ws://localhost:3000/ws" autoConnect>
11
- * <Chat />
12
- * </AmuxProvider>
13
- * );
14
- * }
15
- *
16
- * function Chat() {
17
- * const client = useAmux();
18
- * const { isReady, cwd, agent } = useAmuxState();
19
- * const { messages, currentTurn } = useAmuxMessages();
20
- *
21
- * // ...
22
- * }
23
- * ```
24
- */
25
- export { AmuxProvider, useAmuxContext } from './context.js';
26
- export type { AmuxContextValue, AmuxProviderProps } from './context.js';
27
- export { useAmux, useAmuxState, useAmuxStatus, useAmuxMessages, useAmuxEvent, useAmuxPrompt, } from './hooks.js';
28
- export type { AmuxState, AmuxStatus, AmuxMessages } from './hooks.js';
29
- //# sourceMappingURL=index.d.ts.map
package/dist/types.d.ts DELETED
@@ -1,166 +0,0 @@
1
- import type { SessionUpdate } from '@bytespell/amux-types';
2
- export type { SessionUpdate };
3
- /**
4
- * Content block types for accumulated messages
5
- */
6
- export type ContentBlock = {
7
- type: 'text';
8
- text: string;
9
- } | {
10
- type: 'thinking';
11
- text: string;
12
- } | {
13
- type: 'tool_use';
14
- id: string;
15
- name: string;
16
- input: unknown;
17
- } | {
18
- type: 'tool_result';
19
- toolUseId: string;
20
- content: unknown;
21
- isError?: boolean;
22
- } | {
23
- type: 'diff';
24
- path: string;
25
- oldText: string;
26
- newText: string;
27
- } | {
28
- type: 'image';
29
- source: {
30
- type: 'base64';
31
- mediaType: string;
32
- data: string;
33
- };
34
- };
35
- /**
36
- * Accumulated message
37
- */
38
- export interface Message {
39
- id: string;
40
- role: 'user' | 'assistant';
41
- content: ContentBlock[];
42
- status: 'streaming' | 'complete';
43
- timestamp: number;
44
- }
45
- /**
46
- * Tool call state tracking
47
- */
48
- export interface ToolCallState {
49
- id: string;
50
- name: string;
51
- input: unknown;
52
- status: 'pending' | 'running' | 'complete' | 'error';
53
- result?: unknown;
54
- error?: string;
55
- }
56
- /**
57
- * Turn state - groups user message and assistant response
58
- */
59
- export interface Turn {
60
- id: string;
61
- userMessage: Message | null;
62
- assistantMessage: Message | null;
63
- toolCalls: ToolCallState[];
64
- status: 'idle' | 'streaming' | 'awaiting_permission' | 'complete';
65
- }
66
- /**
67
- * Connection status
68
- */
69
- export type ConnectionStatus = 'disconnected' | 'connecting' | 'connected' | 'ready';
70
- /**
71
- * Permission option (from server)
72
- */
73
- export interface PermissionOptionData {
74
- id?: string;
75
- optionId?: string;
76
- label?: string;
77
- title?: string;
78
- description?: string;
79
- }
80
- /**
81
- * Client event types
82
- */
83
- export interface AmuxClientEvents {
84
- ready: {
85
- cwd: string;
86
- sessionId: string | null;
87
- capabilities: unknown;
88
- agent: {
89
- type: string;
90
- name: string;
91
- };
92
- availableAgents: Array<{
93
- id: string;
94
- name: string;
95
- }>;
96
- availableModels?: Array<{
97
- id: string;
98
- name: string;
99
- provider?: string;
100
- supportsThinking?: boolean;
101
- }>;
102
- currentModelId?: string;
103
- };
104
- connecting: Record<string, never>;
105
- update: SessionUpdate;
106
- turn_start: Record<string, never>;
107
- turn_end: Record<string, never>;
108
- permission_request: {
109
- requestId: string;
110
- toolCall?: unknown;
111
- options: PermissionOptionData[];
112
- };
113
- prompt_complete: {
114
- stopReason?: string;
115
- };
116
- session_created: {
117
- sessionId: string | null;
118
- };
119
- session_switched: {
120
- sessionId: string;
121
- };
122
- history_replay: {
123
- previousSessionId: string;
124
- events: unknown[];
125
- eventCount: number;
126
- };
127
- history: {
128
- events: unknown[];
129
- sessionId: string | null;
130
- };
131
- sessions: {
132
- sessions: unknown[];
133
- };
134
- error: {
135
- message: string;
136
- };
137
- agent_exit: {
138
- code: number | null;
139
- signal: string | null;
140
- };
141
- connection_status: {
142
- status: ConnectionStatus;
143
- };
144
- messages_updated: {
145
- messages: Message[];
146
- };
147
- turns_updated: {
148
- turns: Turn[];
149
- };
150
- }
151
- /**
152
- * Options for creating an AmuxClient
153
- */
154
- export interface AmuxClientOptions {
155
- /** WebSocket URL to connect to */
156
- url: string;
157
- /** Auto-connect on creation (default: true) */
158
- autoConnect?: boolean;
159
- /** Auto-reconnect on disconnect (default: true) */
160
- reconnect?: boolean;
161
- /** Reconnect interval in ms (default: 1000) */
162
- reconnectInterval?: number;
163
- /** Max reconnect attempts (default: Infinity) */
164
- maxReconnectAttempts?: number;
165
- }
166
- //# sourceMappingURL=types.d.ts.map