@usecrow/client 0.1.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.
package/README.md ADDED
@@ -0,0 +1,167 @@
1
+ # @usecrow/client
2
+
3
+ Headless client for [Crow](https://usecrow.ai) AI agents. Framework-agnostic TypeScript client with streaming, authentication, tool calling, and conversation management.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @usecrow/client
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```typescript
14
+ import { CrowClient } from '@usecrow/client';
15
+
16
+ const client = new CrowClient({
17
+ productId: 'YOUR_PRODUCT_ID',
18
+ apiUrl: 'https://api.usecrow.org',
19
+ });
20
+
21
+ // Send message and stream response
22
+ for await (const event of client.sendMessage('Hello!')) {
23
+ if (event.type === 'content') {
24
+ console.log(event.text);
25
+ }
26
+ }
27
+ ```
28
+
29
+ ## Features
30
+
31
+ ### Identity / Authentication
32
+
33
+ ```typescript
34
+ // Identify user with JWT from your backend
35
+ client.identify({
36
+ token: 'jwt-from-your-backend',
37
+ name: 'John Doe',
38
+ email: 'john@example.com',
39
+ });
40
+
41
+ // Reset on logout
42
+ client.resetUser();
43
+ ```
44
+
45
+ ### Client-Side Tools
46
+
47
+ Register tools that execute in the browser with results flowing back to the agent:
48
+
49
+ ```typescript
50
+ client.registerTools({
51
+ addToCart: async ({ productId, quantity }) => {
52
+ await cartApi.add(productId, quantity);
53
+ return { status: 'success', data: { cartCount: 3 } };
54
+ },
55
+
56
+ getCurrentPage: async () => {
57
+ return { status: 'success', data: { path: window.location.pathname } };
58
+ },
59
+ });
60
+ ```
61
+
62
+ ### Streaming Events
63
+
64
+ ```typescript
65
+ for await (const event of client.sendMessage('Help me checkout')) {
66
+ switch (event.type) {
67
+ case 'content':
68
+ // Text content chunk
69
+ updateUI(event.accumulated);
70
+ break;
71
+ case 'thinking':
72
+ // Reasoning/thinking trace
73
+ showReasoning(event.content);
74
+ break;
75
+ case 'tool_call_start':
76
+ // Server-side tool started
77
+ showToolStatus(event.toolName);
78
+ break;
79
+ case 'client_tool_call':
80
+ // Client-side tool requested
81
+ // (automatically executed if registered)
82
+ break;
83
+ case 'done':
84
+ // Stream complete
85
+ break;
86
+ }
87
+ }
88
+ ```
89
+
90
+ ### Conversation Management
91
+
92
+ ```typescript
93
+ // Get conversation history (for verified users)
94
+ const conversations = await client.getConversations();
95
+
96
+ // Load and switch to a conversation
97
+ await client.switchConversation(conversationId);
98
+
99
+ // Start new conversation
100
+ client.clearMessages();
101
+ ```
102
+
103
+ ### Context
104
+
105
+ ```typescript
106
+ // Set context data sent with messages
107
+ client.setContext({
108
+ page: '/checkout',
109
+ cartTotal: 99.99,
110
+ });
111
+ ```
112
+
113
+ ## API Reference
114
+
115
+ ### `CrowClient`
116
+
117
+ #### Constructor Options
118
+
119
+ | Option | Type | Required | Description |
120
+ |--------|------|----------|-------------|
121
+ | `productId` | `string` | Yes | Your Crow product ID |
122
+ | `apiUrl` | `string` | No | API URL (default: `https://api.usecrow.org`) |
123
+ | `model` | `string` | No | Default model to use |
124
+
125
+ #### Methods
126
+
127
+ | Method | Description |
128
+ |--------|-------------|
129
+ | `sendMessage(content)` | Send message, returns async generator of events |
130
+ | `send(content)` | Send message and wait for complete response |
131
+ | `stop()` | Stop current generation |
132
+ | `identify(options)` | Identify user with JWT |
133
+ | `resetUser()` | Reset user identity |
134
+ | `registerTools(handlers)` | Register client-side tools |
135
+ | `setContext(data)` | Set context data |
136
+ | `clearMessages()` | Clear messages, start new conversation |
137
+ | `getConversations()` | Get conversation list (verified users) |
138
+ | `loadHistory(id)` | Load conversation history |
139
+ | `switchConversation(id)` | Switch to different conversation |
140
+ | `destroy()` | Clean up resources |
141
+
142
+ #### Properties
143
+
144
+ | Property | Type | Description |
145
+ |----------|------|-------------|
146
+ | `messages` | `Message[]` | Current messages |
147
+ | `isLoading` | `boolean` | Whether currently streaming |
148
+ | `conversationId` | `string \| null` | Current conversation ID |
149
+
150
+ ## TypeScript Support
151
+
152
+ Full TypeScript support with exported types:
153
+
154
+ ```typescript
155
+ import type {
156
+ CrowClientConfig,
157
+ Message,
158
+ StreamEvent,
159
+ ToolHandler,
160
+ ToolResult,
161
+ } from '@usecrow/client';
162
+ ```
163
+
164
+ ## License
165
+
166
+ MIT
167
+