@bytespell/amux-client 0.0.19
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.
- package/dist/accumulator.d.ts +77 -0
- package/dist/accumulator.d.ts.map +1 -0
- package/dist/accumulator.js +285 -0
- package/dist/accumulator.js.map +1 -0
- package/dist/client.d.ts +155 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +364 -0
- package/dist/client.js.map +1 -0
- package/dist/connection.d.ts +81 -0
- package/dist/connection.d.ts.map +1 -0
- package/dist/connection.js +143 -0
- package/dist/connection.js.map +1 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +34 -0
- package/dist/index.js.map +1 -0
- package/dist/react/context.d.ts +60 -0
- package/dist/react/context.d.ts.map +1 -0
- package/dist/react/context.js +138 -0
- package/dist/react/context.js.map +1 -0
- package/dist/react/hooks.d.ts +153 -0
- package/dist/react/hooks.d.ts.map +1 -0
- package/dist/react/hooks.js +156 -0
- package/dist/react/hooks.js.map +1 -0
- package/dist/react/index.d.ts +29 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +27 -0
- package/dist/react/index.js.map +1 -0
- package/dist/types.d.ts +166 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +48 -0
- package/src/accumulator.ts +307 -0
- package/src/client.ts +445 -0
- package/src/connection.ts +194 -0
- package/src/index.ts +59 -0
- package/src/react/context.tsx +200 -0
- package/src/react/hooks.ts +208 -0
- package/src/react/index.ts +37 -0
- package/src/types.ts +120 -0
- package/tsconfig.json +14 -0
- package/tsconfig.tsbuildinfo +1 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @bytespell/amux-client
|
|
3
|
+
*
|
|
4
|
+
* Client library for consuming amux over WebSocket.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import { AmuxClient } from '@bytespell/amux-client';
|
|
9
|
+
*
|
|
10
|
+
* const client = new AmuxClient({ url: 'ws://localhost:3000/ws' });
|
|
11
|
+
*
|
|
12
|
+
* client.on('ready', (data) => {
|
|
13
|
+
* console.log('Ready:', data.cwd);
|
|
14
|
+
* });
|
|
15
|
+
*
|
|
16
|
+
* client.on('update', (update) => {
|
|
17
|
+
* console.log('Update:', update);
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* client.connect();
|
|
21
|
+
* client.prompt('Hello!');
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* For React integration, use:
|
|
25
|
+
* ```typescript
|
|
26
|
+
* import { AmuxProvider, useAmux } from '@bytespell/amux-client/react';
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
// Main client
|
|
30
|
+
export { AmuxClient } from './client.js';
|
|
31
|
+
// Supporting classes
|
|
32
|
+
export { Connection } from './connection.js';
|
|
33
|
+
export { Accumulator } from './accumulator.js';
|
|
34
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,cAAc;AACd,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,qBAAqB;AACrB,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG7C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { AmuxClient } from '../client.js';
|
|
3
|
+
import type { AmuxClientOptions, ConnectionStatus, Message, Turn, PermissionOptionData } from '../types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Amux context value
|
|
6
|
+
*/
|
|
7
|
+
export interface AmuxContextValue {
|
|
8
|
+
client: AmuxClient;
|
|
9
|
+
connectionStatus: ConnectionStatus;
|
|
10
|
+
isConnected: boolean;
|
|
11
|
+
isReady: boolean;
|
|
12
|
+
cwd: string | null;
|
|
13
|
+
sessionId: string | null;
|
|
14
|
+
agent: {
|
|
15
|
+
type: string;
|
|
16
|
+
name: string;
|
|
17
|
+
} | null;
|
|
18
|
+
availableAgents: Array<{
|
|
19
|
+
id: string;
|
|
20
|
+
name: string;
|
|
21
|
+
}>;
|
|
22
|
+
isProcessing: boolean;
|
|
23
|
+
isStreaming: boolean;
|
|
24
|
+
isAwaitingPermission: boolean;
|
|
25
|
+
pendingPermission: {
|
|
26
|
+
requestId: string;
|
|
27
|
+
toolCall?: unknown;
|
|
28
|
+
options: PermissionOptionData[];
|
|
29
|
+
} | null;
|
|
30
|
+
messages: Message[];
|
|
31
|
+
turns: Turn[];
|
|
32
|
+
currentTurn: Turn | null;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Props for AmuxProvider
|
|
36
|
+
*/
|
|
37
|
+
export interface AmuxProviderProps extends AmuxClientOptions {
|
|
38
|
+
children: React.ReactNode;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* AmuxProvider - Provides AmuxClient to React components
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```tsx
|
|
45
|
+
* function App() {
|
|
46
|
+
* return (
|
|
47
|
+
* <AmuxProvider url="ws://localhost:3000/ws" autoConnect>
|
|
48
|
+
* <Chat />
|
|
49
|
+
* </AmuxProvider>
|
|
50
|
+
* );
|
|
51
|
+
* }
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export declare function AmuxProvider({ children, ...options }: AmuxProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
55
|
+
/**
|
|
56
|
+
* Get the Amux context value
|
|
57
|
+
* @throws Error if used outside AmuxProvider
|
|
58
|
+
*/
|
|
59
|
+
export declare function useAmuxContext(): AmuxContextValue;
|
|
60
|
+
//# sourceMapping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,CAAC;CAC3B;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CAAC,EAAE,QAAQ,EAAE,GAAG,OAAO,EAAE,EAAE,iBAAiB,2CAmIvE;AAED;;;GAGG;AACH,wBAAgB,cAAc,IAAI,gBAAgB,CAMjD"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext, useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { AmuxClient } from '../client.js';
|
|
4
|
+
const AmuxContext = createContext(null);
|
|
5
|
+
/**
|
|
6
|
+
* AmuxProvider - Provides AmuxClient to React components
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```tsx
|
|
10
|
+
* function App() {
|
|
11
|
+
* return (
|
|
12
|
+
* <AmuxProvider url="ws://localhost:3000/ws" autoConnect>
|
|
13
|
+
* <Chat />
|
|
14
|
+
* </AmuxProvider>
|
|
15
|
+
* );
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export function AmuxProvider({ children, ...options }) {
|
|
20
|
+
const clientRef = useRef(null);
|
|
21
|
+
// Initialize client once
|
|
22
|
+
if (!clientRef.current) {
|
|
23
|
+
clientRef.current = new AmuxClient(options);
|
|
24
|
+
}
|
|
25
|
+
const client = clientRef.current;
|
|
26
|
+
// State that triggers re-renders
|
|
27
|
+
const [connectionStatus, setConnectionStatus] = useState(client.connectionStatus);
|
|
28
|
+
const [isReady, setIsReady] = useState(client.isReady);
|
|
29
|
+
const [cwd, setCwd] = useState(client.cwd);
|
|
30
|
+
const [sessionId, setSessionId] = useState(client.sessionId);
|
|
31
|
+
const [agent, setAgent] = useState(client.agent);
|
|
32
|
+
const [availableAgents, setAvailableAgents] = useState(client.availableAgents);
|
|
33
|
+
const [isProcessing, setIsProcessing] = useState(client.isProcessing);
|
|
34
|
+
const [pendingPermission, setPendingPermission] = useState(client.pendingPermission);
|
|
35
|
+
const [messages, setMessages] = useState([]);
|
|
36
|
+
const [turns, setTurns] = useState([]);
|
|
37
|
+
// Subscribe to client events
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
const handleConnectionStatus = ({ status }) => {
|
|
40
|
+
setConnectionStatus(status);
|
|
41
|
+
};
|
|
42
|
+
const handleReady = (data) => {
|
|
43
|
+
setIsReady(true);
|
|
44
|
+
setCwd(data.cwd);
|
|
45
|
+
setSessionId(data.sessionId);
|
|
46
|
+
setAgent(data.agent);
|
|
47
|
+
setAvailableAgents(data.availableAgents);
|
|
48
|
+
};
|
|
49
|
+
const handleConnecting = () => {
|
|
50
|
+
setIsReady(false);
|
|
51
|
+
};
|
|
52
|
+
const handleTurnStart = () => {
|
|
53
|
+
setIsProcessing(true);
|
|
54
|
+
};
|
|
55
|
+
const handleTurnEnd = () => {
|
|
56
|
+
setIsProcessing(false);
|
|
57
|
+
};
|
|
58
|
+
const handlePermissionRequest = (data) => {
|
|
59
|
+
setPendingPermission(data);
|
|
60
|
+
};
|
|
61
|
+
const handleSessionCreated = (data) => {
|
|
62
|
+
setSessionId(data.sessionId);
|
|
63
|
+
};
|
|
64
|
+
const handleSessionSwitched = (data) => {
|
|
65
|
+
setSessionId(data.sessionId);
|
|
66
|
+
};
|
|
67
|
+
const handleMessagesUpdated = ({ messages: msgs }) => {
|
|
68
|
+
setMessages([...msgs]);
|
|
69
|
+
};
|
|
70
|
+
const handleTurnsUpdated = ({ turns: t }) => {
|
|
71
|
+
setTurns([...t]);
|
|
72
|
+
};
|
|
73
|
+
const handleAgentExit = () => {
|
|
74
|
+
setIsReady(false);
|
|
75
|
+
setIsProcessing(false);
|
|
76
|
+
};
|
|
77
|
+
client.on('connection_status', handleConnectionStatus);
|
|
78
|
+
client.on('ready', handleReady);
|
|
79
|
+
client.on('connecting', handleConnecting);
|
|
80
|
+
client.on('turn_start', handleTurnStart);
|
|
81
|
+
client.on('turn_end', handleTurnEnd);
|
|
82
|
+
client.on('permission_request', handlePermissionRequest);
|
|
83
|
+
client.on('session_created', handleSessionCreated);
|
|
84
|
+
client.on('session_switched', handleSessionSwitched);
|
|
85
|
+
client.on('messages_updated', handleMessagesUpdated);
|
|
86
|
+
client.on('turns_updated', handleTurnsUpdated);
|
|
87
|
+
client.on('agent_exit', handleAgentExit);
|
|
88
|
+
return () => {
|
|
89
|
+
client.off('connection_status', handleConnectionStatus);
|
|
90
|
+
client.off('ready', handleReady);
|
|
91
|
+
client.off('connecting', handleConnecting);
|
|
92
|
+
client.off('turn_start', handleTurnStart);
|
|
93
|
+
client.off('turn_end', handleTurnEnd);
|
|
94
|
+
client.off('permission_request', handlePermissionRequest);
|
|
95
|
+
client.off('session_created', handleSessionCreated);
|
|
96
|
+
client.off('session_switched', handleSessionSwitched);
|
|
97
|
+
client.off('messages_updated', handleMessagesUpdated);
|
|
98
|
+
client.off('turns_updated', handleTurnsUpdated);
|
|
99
|
+
client.off('agent_exit', handleAgentExit);
|
|
100
|
+
};
|
|
101
|
+
}, [client]);
|
|
102
|
+
// Cleanup on unmount
|
|
103
|
+
useEffect(() => {
|
|
104
|
+
return () => {
|
|
105
|
+
client.disconnect();
|
|
106
|
+
};
|
|
107
|
+
}, [client]);
|
|
108
|
+
const value = {
|
|
109
|
+
client,
|
|
110
|
+
connectionStatus,
|
|
111
|
+
isConnected: connectionStatus === 'connected' || connectionStatus === 'ready',
|
|
112
|
+
isReady,
|
|
113
|
+
cwd,
|
|
114
|
+
sessionId,
|
|
115
|
+
agent,
|
|
116
|
+
availableAgents,
|
|
117
|
+
isProcessing,
|
|
118
|
+
isStreaming: client.isStreaming,
|
|
119
|
+
isAwaitingPermission: pendingPermission !== null,
|
|
120
|
+
pendingPermission,
|
|
121
|
+
messages,
|
|
122
|
+
turns,
|
|
123
|
+
currentTurn: client.currentTurn,
|
|
124
|
+
};
|
|
125
|
+
return _jsx(AmuxContext.Provider, { value: value, children: children });
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Get the Amux context value
|
|
129
|
+
* @throws Error if used outside AmuxProvider
|
|
130
|
+
*/
|
|
131
|
+
export function useAmuxContext() {
|
|
132
|
+
const context = useContext(AmuxContext);
|
|
133
|
+
if (!context) {
|
|
134
|
+
throw new Error('useAmuxContext must be used within an AmuxProvider');
|
|
135
|
+
}
|
|
136
|
+
return context;
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/react/context.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtF,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAgC1C,MAAM,WAAW,GAAG,aAAa,CAA0B,IAAI,CAAC,CAAC;AASjE;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,YAAY,CAAC,EAAE,QAAQ,EAAE,GAAG,OAAO,EAAqB;IACtE,MAAM,SAAS,GAAG,MAAM,CAAoB,IAAI,CAAC,CAAC;IAElD,yBAAyB;IACzB,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;QACvB,SAAS,CAAC,OAAO,GAAG,IAAI,UAAU,CAAC,OAAO,CAAC,CAAC;IAC9C,CAAC;IAED,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC;IAEjC,iCAAiC;IACjC,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,QAAQ,CAAmB,MAAM,CAAC,gBAAgB,CAAC,CAAC;IACpG,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACvD,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC3C,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ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AC;IACJ,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAEb,MAAM,KAAK,GAAqB;QAC9B,MAAM;QACN,gBAAgB;QAChB,WAAW,EAAE,gBAAgB,KAAK,WAAW,IAAI,gBAAgB,KAAK,OAAO;QAC7E,OAAO;QACP,GAAG;QACH,SAAS;QACT,KAAK;QACL,eAAe;QACf,YAAY;QACZ,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,oBAAoB,EAAE,iBAAiB,KAAK,IAAI;QAChD,iBAAiB;QACjB,QAAQ;QACR,KAAK;QACL,WAAW,EAAE,MAAM,CAAC,WAAW;KAChC,CAAC;IAEF,OAAO,KAAC,WAAW,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YAAG,QAAQ,GAAwB,CAAC;AAC/E,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc;IAC5B,MAAM,OAAO,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;IACxC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;IACxE,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,153 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/react/hooks.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,OAAO,EAAE,IAAI,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAC3G,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,OAAO,IAAI,UAAU,CAGpC;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,WAAW,EAAE,OAAO,CAAC;IACrB,OAAO,EAAE,OAAO,CAAC;IACjB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,KAAK,EAAE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xContext } from './context.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 function useAmux() {
|
|
20
|
+
const { client } = useAmuxContext();
|
|
21
|
+
return client;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Get reactive session state
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```tsx
|
|
28
|
+
* function StatusBar() {
|
|
29
|
+
* const { isConnected, isReady, cwd, agent } = useAmuxState();
|
|
30
|
+
*
|
|
31
|
+
* return (
|
|
32
|
+
* <div>
|
|
33
|
+
* {isReady ? `${agent?.name} @ ${cwd}` : 'Connecting...'}
|
|
34
|
+
* </div>
|
|
35
|
+
* );
|
|
36
|
+
* }
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export function useAmuxState() {
|
|
40
|
+
const { connectionStatus, isConnected, isReady, cwd, sessionId, agent, availableAgents } = useAmuxContext();
|
|
41
|
+
return {
|
|
42
|
+
connectionStatus,
|
|
43
|
+
isConnected,
|
|
44
|
+
isReady,
|
|
45
|
+
cwd,
|
|
46
|
+
sessionId,
|
|
47
|
+
agent,
|
|
48
|
+
availableAgents,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Get reactive processing status
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```tsx
|
|
56
|
+
* function ChatInput() {
|
|
57
|
+
* const { isProcessing, isAwaitingPermission } = useAmuxStatus();
|
|
58
|
+
* const disabled = isProcessing || isAwaitingPermission;
|
|
59
|
+
*
|
|
60
|
+
* return <input disabled={disabled} ... />;
|
|
61
|
+
* }
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
export function useAmuxStatus() {
|
|
65
|
+
const { isProcessing, isStreaming, isAwaitingPermission, pendingPermission } = useAmuxContext();
|
|
66
|
+
return {
|
|
67
|
+
isProcessing,
|
|
68
|
+
isStreaming,
|
|
69
|
+
isAwaitingPermission,
|
|
70
|
+
pendingPermission,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Get reactive messages and turns
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```tsx
|
|
78
|
+
* function MessageList() {
|
|
79
|
+
* const { messages, currentTurn } = useAmuxMessages();
|
|
80
|
+
*
|
|
81
|
+
* return (
|
|
82
|
+
* <>
|
|
83
|
+
* {messages.map(msg => <MessageBubble key={msg.id} message={msg} />)}
|
|
84
|
+
* {currentTurn?.status === 'streaming' && <StreamingIndicator />}
|
|
85
|
+
* </>
|
|
86
|
+
* );
|
|
87
|
+
* }
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
export function useAmuxMessages() {
|
|
91
|
+
const { messages, turns, currentTurn } = useAmuxContext();
|
|
92
|
+
return {
|
|
93
|
+
messages,
|
|
94
|
+
turns,
|
|
95
|
+
currentTurn,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Subscribe to specific client events
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```tsx
|
|
103
|
+
* function PermissionDialog() {
|
|
104
|
+
* const [pending, setPending] = useState<PermissionRequest | null>(null);
|
|
105
|
+
* const client = useAmux();
|
|
106
|
+
*
|
|
107
|
+
* useAmuxEvent('permission_request', (req) => {
|
|
108
|
+
* setPending(req);
|
|
109
|
+
* });
|
|
110
|
+
*
|
|
111
|
+
* const handleResponse = (optionId: string) => {
|
|
112
|
+
* if (pending) {
|
|
113
|
+
* client.respondToPermission(pending.requestId, optionId);
|
|
114
|
+
* setPending(null);
|
|
115
|
+
* }
|
|
116
|
+
* };
|
|
117
|
+
*
|
|
118
|
+
* if (!pending) return null;
|
|
119
|
+
* return <Dialog options={pending.options} onSelect={handleResponse} />;
|
|
120
|
+
* }
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
export function useAmuxEvent(event, handler) {
|
|
124
|
+
const { client } = useAmuxContext();
|
|
125
|
+
// Wrap handler in useCallback to maintain stable reference
|
|
126
|
+
const stableHandler = useCallback(handler, [handler]);
|
|
127
|
+
useEffect(() => {
|
|
128
|
+
client.on(event, stableHandler);
|
|
129
|
+
return () => {
|
|
130
|
+
client.off(event, stableHandler);
|
|
131
|
+
};
|
|
132
|
+
}, [client, event, stableHandler]);
|
|
133
|
+
}
|
|
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 function useAmuxPrompt() {
|
|
153
|
+
const { client } = useAmuxContext();
|
|
154
|
+
return useCallback((message) => client.prompt(message), [client]);
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../src/react/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,OAAO,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AC,KAAK,EAAE,aAAa,CAAC,CAAC;QAChC,OAAO,GAAG,EAAE;YACV,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;QACnC,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC;AACrC,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,aAAa;IAC3B,MAAM,EAAE,MAAM,EAAE,GAAG,cAAc,EAAE,CAAC;IACpC,OAAO,WAAW,CAAC,CAAC,OAAe,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;AAC5E,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC5D,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAExE,OAAO,EACL,OAAO,EACP,YAAY,EACZ,aAAa,EACb,eAAe,EACf,YAAY,EACZ,aAAa,GACd,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
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 { useAmux, useAmuxState, useAmuxStatus, useAmuxMessages, useAmuxEvent, useAmuxPrompt, } from './hooks.js';
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAG5D,OAAO,EACL,OAAO,EACP,YAAY,EACZ,aAAa,EACb,eAAe,EACf,YAAY,EACZ,aAAa,GACd,MAAM,YAAY,CAAC"}
|