@emblemvault/hustle-react 1.0.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.
Files changed (38) hide show
  1. package/README.md +225 -0
  2. package/dist/browser/hustle-react.js +14705 -0
  3. package/dist/browser/hustle-react.js.map +1 -0
  4. package/dist/components/index.cjs +3170 -0
  5. package/dist/components/index.cjs.map +1 -0
  6. package/dist/components/index.d.cts +58 -0
  7. package/dist/components/index.d.ts +58 -0
  8. package/dist/components/index.js +3143 -0
  9. package/dist/components/index.js.map +1 -0
  10. package/dist/hooks/index.cjs +695 -0
  11. package/dist/hooks/index.cjs.map +1 -0
  12. package/dist/hooks/index.d.cts +46 -0
  13. package/dist/hooks/index.d.ts +46 -0
  14. package/dist/hooks/index.js +691 -0
  15. package/dist/hooks/index.js.map +1 -0
  16. package/dist/hustle-S48t4lTZ.d.cts +222 -0
  17. package/dist/hustle-S48t4lTZ.d.ts +222 -0
  18. package/dist/index.cjs +3588 -0
  19. package/dist/index.cjs.map +1 -0
  20. package/dist/index.d.cts +229 -0
  21. package/dist/index.d.ts +229 -0
  22. package/dist/index.js +3547 -0
  23. package/dist/index.js.map +1 -0
  24. package/dist/plugin-BUg7vMxe.d.cts +172 -0
  25. package/dist/plugin-BUg7vMxe.d.ts +172 -0
  26. package/dist/plugins/index.cjs +1235 -0
  27. package/dist/plugins/index.cjs.map +1 -0
  28. package/dist/plugins/index.d.cts +192 -0
  29. package/dist/plugins/index.d.ts +192 -0
  30. package/dist/plugins/index.js +1225 -0
  31. package/dist/plugins/index.js.map +1 -0
  32. package/dist/providers/index.cjs +694 -0
  33. package/dist/providers/index.cjs.map +1 -0
  34. package/dist/providers/index.d.cts +46 -0
  35. package/dist/providers/index.d.ts +46 -0
  36. package/dist/providers/index.js +691 -0
  37. package/dist/providers/index.js.map +1 -0
  38. package/package.json +87 -0
package/README.md ADDED
@@ -0,0 +1,225 @@
1
+ # @emblemvault/hustle-react
2
+
3
+ React hooks and components for AI chat using the Hustle Incognito SDK.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @emblemvault/hustle-react
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ### With Auth SDK (Recommended)
14
+
15
+ ```tsx
16
+ import { EmblemAuthProvider, ConnectButton } from '@emblemvault/emblem-auth-react';
17
+ import { HustleProvider, HustleChat } from '@emblemvault/hustle-react';
18
+
19
+ function App() {
20
+ return (
21
+ <EmblemAuthProvider appId="your-app-id">
22
+ <HustleProvider>
23
+ <ConnectButton />
24
+ <HustleChat showSettings />
25
+ </HustleProvider>
26
+ </EmblemAuthProvider>
27
+ );
28
+ }
29
+ ```
30
+
31
+ ### With API Key (Standalone)
32
+
33
+ ```tsx
34
+ import { HustleProvider, HustleChat } from '@emblemvault/hustle-react';
35
+
36
+ function App() {
37
+ return (
38
+ <HustleProvider apiKey="your-key" vaultId="your-vault">
39
+ <HustleChat showSettings />
40
+ </HustleProvider>
41
+ );
42
+ }
43
+ ```
44
+
45
+ ## API Reference
46
+
47
+ ### HustleProvider
48
+
49
+ Provides chat context to your app.
50
+
51
+ ```tsx
52
+ <HustleProvider
53
+ // With auth SDK (default) - uses EmblemAuthProvider context
54
+ hustleApiUrl="https://agenthustle.ai" // optional
55
+
56
+ // OR with API key (standalone)
57
+ apiKey="your-key"
58
+ vaultId="your-vault"
59
+
60
+ // Multi-instance support
61
+ instanceId="unique-id" // Scopes settings per instance
62
+ >
63
+ {children}
64
+ </HustleProvider>
65
+ ```
66
+
67
+ ### useHustle
68
+
69
+ Access chat state and methods.
70
+
71
+ ```tsx
72
+ const {
73
+ // State
74
+ isReady, // boolean - client ready to chat
75
+ isLoading, // boolean
76
+ error, // Error | null
77
+ models, // Model[] - available AI models
78
+ client, // HustleIncognitoClient | null
79
+
80
+ // Chat methods
81
+ chat, // (options) => Promise<ChatResponse>
82
+ chatStream, // (options) => AsyncIterable<StreamChunk>
83
+ uploadFile, // (file) => Promise<Attachment>
84
+ loadModels, // () => Promise<Model[]>
85
+
86
+ // Settings (persisted to localStorage)
87
+ selectedModel, // string
88
+ setSelectedModel, // (model: string) => void
89
+ systemPrompt, // string
90
+ setSystemPrompt, // (prompt: string) => void
91
+ skipServerPrompt, // boolean
92
+ setSkipServerPrompt, // (skip: boolean) => void
93
+ } = useHustle();
94
+ ```
95
+
96
+ ### HustleChat
97
+
98
+ Complete chat UI component.
99
+
100
+ ```tsx
101
+ <HustleChat
102
+ showSettings // Show settings modal button
103
+ showDebug // Show tool call debug info
104
+ placeholder="Message" // Input placeholder
105
+ initialSystemPrompt="" // Initial system prompt
106
+
107
+ // Callbacks
108
+ onMessage={(msg) => {}} // When user sends message
109
+ onToolCall={(tool) => {}} // When AI calls a tool
110
+ onResponse={(content) => {}} // When AI responds
111
+ />
112
+ ```
113
+
114
+ ## Plugins
115
+
116
+ Extend the AI with custom tools.
117
+
118
+ ### Using Built-in Plugins
119
+
120
+ ```tsx
121
+ import { usePlugins, availablePlugins } from '@emblemvault/hustle-react';
122
+
123
+ function PluginManager() {
124
+ const { plugins, registerPlugin, enablePlugin, disablePlugin } = usePlugins();
125
+
126
+ return (
127
+ <div>
128
+ {availablePlugins.map(plugin => (
129
+ <button onClick={() => registerPlugin(plugin)}>
130
+ Install {plugin.name}
131
+ </button>
132
+ ))}
133
+ </div>
134
+ );
135
+ }
136
+ ```
137
+
138
+ ### Creating Custom Plugins
139
+
140
+ ```tsx
141
+ import type { HustlePlugin } from '@emblemvault/hustle-react';
142
+
143
+ const weatherPlugin: HustlePlugin = {
144
+ name: 'weather',
145
+ version: '1.0.0',
146
+ description: 'Get weather information',
147
+ enabled: true,
148
+ tools: [{
149
+ name: 'get_weather',
150
+ description: 'Get weather for a city',
151
+ parameters: {
152
+ type: 'object',
153
+ properties: {
154
+ city: { type: 'string', description: 'City name' },
155
+ },
156
+ required: ['city'],
157
+ },
158
+ }],
159
+ executors: {
160
+ get_weather: async ({ city }) => {
161
+ const response = await fetch(`/api/weather?city=${city}`);
162
+ return response.json();
163
+ },
164
+ },
165
+ };
166
+
167
+ // Register it
168
+ const { registerPlugin } = usePlugins();
169
+ registerPlugin(weatherPlugin);
170
+ ```
171
+
172
+ ### Plugin Hooks
173
+
174
+ ```tsx
175
+ const plugin: HustlePlugin = {
176
+ // ... name, tools, executors
177
+
178
+ // Modify messages before sending
179
+ beforeRequest: (messages) => {
180
+ return messages.map(m => ({
181
+ ...m,
182
+ content: m.content.replace(/secret/gi, '[REDACTED]'),
183
+ }));
184
+ },
185
+
186
+ // Modify response after receiving
187
+ afterResponse: (response) => {
188
+ return {
189
+ ...response,
190
+ content: response.content + '\n\n---\nPowered by MyPlugin',
191
+ };
192
+ },
193
+ };
194
+ ```
195
+
196
+ ## Multi-Instance Support
197
+
198
+ Run multiple isolated chat instances:
199
+
200
+ ```tsx
201
+ <HustleProvider instanceId="trading-bot">
202
+ <HustleChat />
203
+ </HustleProvider>
204
+
205
+ <HustleProvider instanceId="support-bot">
206
+ <HustleChat />
207
+ </HustleProvider>
208
+ ```
209
+
210
+ Each instance has separate settings and plugins stored under its ID.
211
+
212
+ ## Underlying SDK
213
+
214
+ This package wraps [hustle-incognito](https://github.com/nicktaylor-/hustle-incognito) for React. The SDK handles:
215
+
216
+ - Chat API communication
217
+ - Streaming responses
218
+ - Tool execution
219
+ - Model selection
220
+
221
+ For advanced usage, access the client directly via `useHustle().client`.
222
+
223
+ ## License
224
+
225
+ MIT