@toothfairyai/cli 1.1.5 → 1.4.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 +352 -123
- package/bin/toothfairy.js +636 -72
- package/package.json +7 -5
- package/src/api.js +62 -15
- package/src/config.js +7 -3
package/README.md
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
# ToothFairyAI CLI (Node.js)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Command-line interface for interacting with ToothFairyAI agents.**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
**Quick access**: Use `toothfairy` command!
|
|
6
|
+
|
|
7
|
+
## 📦 Installation
|
|
6
8
|
|
|
7
9
|
### From NPM
|
|
8
10
|
```bash
|
|
@@ -17,9 +19,39 @@ npm install
|
|
|
17
19
|
npm link # Makes 'toothfairy' command available globally
|
|
18
20
|
```
|
|
19
21
|
|
|
20
|
-
##
|
|
22
|
+
## 🌍 Multi-Region Support
|
|
23
|
+
|
|
24
|
+
ToothFairyAI operates in multiple regions. Configure your CLI to connect to the appropriate region:
|
|
25
|
+
|
|
26
|
+
| Region | AI URL | API URL |
|
|
27
|
+
|--------|--------|---------|
|
|
28
|
+
| **Australia** (default) | https://ai.toothfairyai.com | https://api.toothfairyai.com |
|
|
29
|
+
| **United States** | https://ai.us.toothfairyai.com | https://api.us.toothfairyai.com |
|
|
30
|
+
| **Europe** | https://ai.eu.toothfairyai.com | https://api.eu.toothfairyai.com |
|
|
21
31
|
|
|
22
|
-
|
|
32
|
+
### Configure for your region:
|
|
33
|
+
```bash
|
|
34
|
+
# Australia (default - no URLs needed)
|
|
35
|
+
toothfairy configure --api-key YOUR_KEY --workspace-id YOUR_WORKSPACE
|
|
36
|
+
|
|
37
|
+
# United States
|
|
38
|
+
toothfairy configure \
|
|
39
|
+
--api-key YOUR_KEY \
|
|
40
|
+
--workspace-id YOUR_WORKSPACE \
|
|
41
|
+
--ai-url https://ai.us.toothfairyai.com \
|
|
42
|
+
--base-url https://api.us.toothfairyai.com
|
|
43
|
+
|
|
44
|
+
# Europe
|
|
45
|
+
toothfairy configure \
|
|
46
|
+
--api-key YOUR_KEY \
|
|
47
|
+
--workspace-id YOUR_WORKSPACE \
|
|
48
|
+
--ai-url https://ai.eu.toothfairyai.com \
|
|
49
|
+
--base-url https://api.eu.toothfairyai.com
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## 🚀 Quick Start
|
|
53
|
+
|
|
54
|
+
1. **Configure your credentials and region:**
|
|
23
55
|
```bash
|
|
24
56
|
toothfairy configure \
|
|
25
57
|
--api-key "your-api-key" \
|
|
@@ -42,28 +74,178 @@ toothfairy search "appointment scheduling help"
|
|
|
42
74
|
toothfairy chats
|
|
43
75
|
```
|
|
44
76
|
|
|
45
|
-
##
|
|
77
|
+
## ✨ Features
|
|
78
|
+
|
|
79
|
+
- **💬 Agent Communication**: Send messages to ToothFairyAI agents
|
|
80
|
+
- **🔍 Knowledge Hub Search**: Search documents with advanced filtering
|
|
81
|
+
- **📋 Chat Management**: List and view chat conversations
|
|
82
|
+
- **⚙️ Configuration**: Flexible credential and settings management
|
|
83
|
+
- **🎨 Rich Output**: Beautiful terminal interface with colors and tables
|
|
84
|
+
- **📊 Multiple Formats**: JSON and text output for both interactive and scripted use
|
|
85
|
+
- **🔐 Secure**: Safe credential storage and validation
|
|
86
|
+
- **📱 Cross-Platform**: Works on Windows, macOS, and Linux
|
|
87
|
+
- **🌍 Multi-Region**: Support for Australia, US, and EU regions
|
|
88
|
+
- **📦 SDK Included**: Use as a library in your Node.js applications
|
|
89
|
+
|
|
90
|
+
## 💬 Agent Communication Examples
|
|
91
|
+
|
|
92
|
+
| Use Case | Command |
|
|
93
|
+
|----------|---------|
|
|
94
|
+
| Simple message | `toothfairy send "What are your hours?" --agent-id "info-agent"` |
|
|
95
|
+
| With customer info | `toothfairy send "Schedule appointment" --agent-id "scheduler" --customer-info '{"name": "John"}'` |
|
|
96
|
+
| Verbose output | `toothfairy send "Hello" --agent-id "agent-123" --verbose` |
|
|
97
|
+
| JSON for scripting | `toothfairy send "Help" --agent-id "agent-123" --output json` |
|
|
98
|
+
|
|
99
|
+
### Advanced Agent Communication
|
|
100
|
+
```bash
|
|
101
|
+
# Send message with detailed customer information
|
|
102
|
+
toothfairy send "Check my insurance coverage" \
|
|
103
|
+
--agent-id "insurance-agent" \
|
|
104
|
+
--customer-info '{
|
|
105
|
+
"name": "Sarah Johnson",
|
|
106
|
+
"dateOfBirth": "1985-03-15",
|
|
107
|
+
"insurance": {
|
|
108
|
+
"provider": "BlueCross BlueShield",
|
|
109
|
+
"policyNumber": "BC123456789"
|
|
110
|
+
}
|
|
111
|
+
}'
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## 🔍 Knowledge Hub Search Examples
|
|
115
|
+
|
|
116
|
+
| Use Case | Command |
|
|
117
|
+
|----------|---------|
|
|
118
|
+
| Basic search | `toothfairy search "AI agent configuration"` |
|
|
119
|
+
| Filter by status | `toothfairy search "machine learning" --status published` |
|
|
120
|
+
| Limit results | `toothfairy search "troubleshooting" --top-k 3` |
|
|
121
|
+
| Topic filtering | `toothfairy search "automation" --topics "topic_123,topic_456"` |
|
|
122
|
+
| Specific document | `toothfairy search "settings" --document-id "doc_550..."` |
|
|
123
|
+
| Verbose details | `toothfairy search "deployment" --verbose` |
|
|
124
|
+
| JSON output | `toothfairy search "API docs" --output json` |
|
|
125
|
+
|
|
126
|
+
### Search Filtering Guide
|
|
127
|
+
|
|
128
|
+
Knowledge Hub search supports powerful filtering options:
|
|
129
|
+
|
|
130
|
+
- **`--status`**: Filter documents by 'published' or 'suspended' status
|
|
131
|
+
- **`--topics`**: Use topic IDs from ToothFairyAI (comma-separated)
|
|
132
|
+
- **`--document-id`**: Search within a specific document
|
|
133
|
+
- **`--top-k`**: Control number of results (1-50)
|
|
134
|
+
- **`--verbose`**: Show relevance scores and metadata
|
|
135
|
+
|
|
136
|
+
## 📋 Workspace Management Examples
|
|
137
|
+
|
|
138
|
+
| Use Case | Command |
|
|
139
|
+
|----------|---------|
|
|
140
|
+
| List all chats | `toothfairy chats` |
|
|
141
|
+
| View chat details | `toothfairy chat CHAT_ID` |
|
|
142
|
+
| Show config | `toothfairy config-show` |
|
|
143
|
+
| Detailed help | `toothfairy help-guide` |
|
|
144
|
+
|
|
145
|
+
## ⚙️ Configuration
|
|
146
|
+
|
|
147
|
+
The CLI supports multiple configuration methods (in order of priority):
|
|
148
|
+
|
|
149
|
+
### Configuration Methods
|
|
150
|
+
|
|
151
|
+
| Method | Description | Example |
|
|
152
|
+
|--------|-------------|---------|
|
|
153
|
+
| Environment | Set environment variables | `export TF_API_KEY=your_key` |
|
|
154
|
+
| Config file | Use ~/.toothfairy/config.yml | `api_key: your_key`<br/>`workspace_id: your_workspace` |
|
|
155
|
+
| CLI arguments | Pass config file path | `toothfairy --config /path/to/config.yml send ...` |
|
|
156
|
+
|
|
157
|
+
### Setting up configuration
|
|
158
|
+
|
|
159
|
+
#### Interactive Configuration
|
|
160
|
+
```bash
|
|
161
|
+
# Australia (default)
|
|
162
|
+
toothfairy configure \
|
|
163
|
+
--api-key "your-api-key" \
|
|
164
|
+
--workspace-id "your-workspace-id"
|
|
165
|
+
|
|
166
|
+
# United States
|
|
167
|
+
toothfairy configure \
|
|
168
|
+
--api-key "your-api-key" \
|
|
169
|
+
--workspace-id "your-workspace-id" \
|
|
170
|
+
--base-url "https://api.us.toothfairyai.com" \
|
|
171
|
+
--ai-url "https://ai.us.toothfairyai.com"
|
|
172
|
+
|
|
173
|
+
# Europe
|
|
174
|
+
toothfairy configure \
|
|
175
|
+
--api-key "your-api-key" \
|
|
176
|
+
--workspace-id "your-workspace-id" \
|
|
177
|
+
--base-url "https://api.eu.toothfairyai.com" \
|
|
178
|
+
--ai-url "https://ai.eu.toothfairyai.com"
|
|
179
|
+
|
|
180
|
+
# View current configuration
|
|
181
|
+
toothfairy config-show
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
#### Environment Variables
|
|
185
|
+
```bash
|
|
186
|
+
# Required
|
|
187
|
+
export TF_API_KEY="your-api-key"
|
|
188
|
+
export TF_WORKSPACE_ID="your-workspace-id"
|
|
189
|
+
|
|
190
|
+
# Optional - Region endpoints (defaults to Australia)
|
|
191
|
+
# For US:
|
|
192
|
+
export TF_BASE_URL="https://api.us.toothfairyai.com"
|
|
193
|
+
export TF_AI_URL="https://ai.us.toothfairyai.com"
|
|
194
|
+
|
|
195
|
+
# For EU:
|
|
196
|
+
export TF_BASE_URL="https://api.eu.toothfairyai.com"
|
|
197
|
+
export TF_AI_URL="https://ai.eu.toothfairyai.com"
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
#### Config File Format
|
|
201
|
+
Create `~/.toothfairy/config.yml`:
|
|
202
|
+
```yaml
|
|
203
|
+
# Required
|
|
204
|
+
api_key: "your-api-key"
|
|
205
|
+
workspace_id: "your-workspace-id"
|
|
206
|
+
|
|
207
|
+
# Optional - Region endpoints (defaults to Australia)
|
|
208
|
+
# For US:
|
|
209
|
+
base_url: "https://api.us.toothfairyai.com"
|
|
210
|
+
ai_url: "https://ai.us.toothfairyai.com"
|
|
211
|
+
|
|
212
|
+
# For EU:
|
|
213
|
+
# base_url: "https://api.eu.toothfairyai.com"
|
|
214
|
+
# ai_url: "https://ai.eu.toothfairyai.com"
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
## 📊 Output Formats
|
|
218
|
+
|
|
219
|
+
The CLI supports `--output` or `-o` flag:
|
|
220
|
+
|
|
221
|
+
- **`text`** (default): Pretty formatted tables and panels
|
|
222
|
+
- **`json`**: Raw JSON output for scripting
|
|
223
|
+
|
|
224
|
+
```bash
|
|
225
|
+
# Get JSON output for scripting
|
|
226
|
+
toothfairy send "Hello" --agent-id "agent-123" --output json | jq '.agentResponse.contents.content'
|
|
227
|
+
|
|
228
|
+
# Search with JSON output
|
|
229
|
+
toothfairy search "documentation" --output json | jq '.[].title'
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
## 🔧 Command Reference
|
|
46
233
|
|
|
47
234
|
### Global Options
|
|
48
|
-
- `-c
|
|
49
|
-
- `-v
|
|
235
|
+
- `--config`, `-c`: Path to configuration file
|
|
236
|
+
- `--verbose`, `-v`: Enable verbose logging and API debugging
|
|
50
237
|
|
|
51
238
|
### Commands
|
|
52
239
|
|
|
53
240
|
#### `configure`
|
|
54
|
-
|
|
241
|
+
Set up CLI credentials and configuration.
|
|
55
242
|
|
|
56
243
|
**Options:**
|
|
57
|
-
- `--api-key
|
|
58
|
-
- `--workspace-id
|
|
59
|
-
- `--base-url
|
|
60
|
-
- `--ai-url
|
|
61
|
-
- `--config-path
|
|
62
|
-
|
|
63
|
-
**Example:**
|
|
64
|
-
```bash
|
|
65
|
-
toothfairy configure --api-key "your-key" --workspace-id "your-workspace"
|
|
66
|
-
```
|
|
244
|
+
- `--api-key`: API key (required)
|
|
245
|
+
- `--workspace-id`: Workspace ID (required)
|
|
246
|
+
- `--base-url`: ToothFairy API base URL (optional)
|
|
247
|
+
- `--ai-url`: ToothFairyAI URL (optional)
|
|
248
|
+
- `--config-path`: Custom path to save config file
|
|
67
249
|
|
|
68
250
|
#### `send <message>`
|
|
69
251
|
Send a message to a ToothFairyAI agent.
|
|
@@ -72,27 +254,13 @@ Send a message to a ToothFairyAI agent.
|
|
|
72
254
|
- `message`: The message text to send
|
|
73
255
|
|
|
74
256
|
**Options:**
|
|
75
|
-
- `--agent-id
|
|
76
|
-
- `--phone-number
|
|
77
|
-
- `--customer-id
|
|
78
|
-
- `--provider-id
|
|
79
|
-
- `--customer-info
|
|
80
|
-
- `-o
|
|
81
|
-
- `-v
|
|
82
|
-
|
|
83
|
-
**Examples:**
|
|
84
|
-
```bash
|
|
85
|
-
# Simple message
|
|
86
|
-
toothfairy send "What are your hours?" --agent-id "info-agent"
|
|
87
|
-
|
|
88
|
-
# With customer information
|
|
89
|
-
toothfairy send "Schedule appointment" \
|
|
90
|
-
--agent-id "scheduler" \
|
|
91
|
-
--customer-info '{"name": "John", "phone": "+1234567890"}'
|
|
92
|
-
|
|
93
|
-
# With verbose output
|
|
94
|
-
toothfairy send "Hello" --agent-id "agent-123" --verbose
|
|
95
|
-
```
|
|
257
|
+
- `--agent-id`: Agent ID to send message to (required)
|
|
258
|
+
- `--phone-number`: Phone number for SMS channel (optional)
|
|
259
|
+
- `--customer-id`: Customer ID (optional)
|
|
260
|
+
- `--provider-id`: SMS provider ID (optional)
|
|
261
|
+
- `--customer-info`: Customer info as JSON string (optional)
|
|
262
|
+
- `--output`, `-o`: Output format (json|text)
|
|
263
|
+
- `--verbose`, `-v`: Show detailed response information
|
|
96
264
|
|
|
97
265
|
#### `search <query>`
|
|
98
266
|
Search for documents in the knowledge hub.
|
|
@@ -101,39 +269,18 @@ Search for documents in the knowledge hub.
|
|
|
101
269
|
- `query`: The search query text
|
|
102
270
|
|
|
103
271
|
**Options:**
|
|
104
|
-
-
|
|
105
|
-
- `--status
|
|
106
|
-
- `--document-id
|
|
107
|
-
- `--topics
|
|
108
|
-
- `-o
|
|
109
|
-
- `-v
|
|
110
|
-
|
|
111
|
-
**Examples:**
|
|
112
|
-
```bash
|
|
113
|
-
# Basic search
|
|
114
|
-
toothfairy search "AI agent configuration"
|
|
115
|
-
|
|
116
|
-
# Filter by status and limit results
|
|
117
|
-
toothfairy search "machine learning" --status published --top-k 5
|
|
118
|
-
|
|
119
|
-
# Search with topic filtering
|
|
120
|
-
toothfairy search "automation" --topics "topic_123,topic_456"
|
|
121
|
-
|
|
122
|
-
# Verbose search with JSON output
|
|
123
|
-
toothfairy search "deployment" --verbose --output json
|
|
124
|
-
```
|
|
272
|
+
- `--top-k`, `-k`: Number of documents to retrieve (1-50, default: 10)
|
|
273
|
+
- `--status`: Filter by document status (published|suspended)
|
|
274
|
+
- `--document-id`: Search within specific document ID
|
|
275
|
+
- `--topics`: Comma-separated topic IDs to filter by
|
|
276
|
+
- `--output`, `-o`: Output format (json|text)
|
|
277
|
+
- `--verbose`, `-v`: Show detailed search information
|
|
125
278
|
|
|
126
279
|
#### `chats`
|
|
127
280
|
List all chats in the workspace.
|
|
128
281
|
|
|
129
282
|
**Options:**
|
|
130
|
-
- `-o
|
|
131
|
-
|
|
132
|
-
**Example:**
|
|
133
|
-
```bash
|
|
134
|
-
toothfairy chats
|
|
135
|
-
toothfairy chats --output json
|
|
136
|
-
```
|
|
283
|
+
- `--output`, `-o`: Output format (json|text)
|
|
137
284
|
|
|
138
285
|
#### `chat <chat-id>`
|
|
139
286
|
Get details of a specific chat.
|
|
@@ -142,70 +289,56 @@ Get details of a specific chat.
|
|
|
142
289
|
- `chat-id`: The chat ID to retrieve
|
|
143
290
|
|
|
144
291
|
**Options:**
|
|
145
|
-
- `-o
|
|
146
|
-
|
|
147
|
-
**Example:**
|
|
148
|
-
```bash
|
|
149
|
-
toothfairy chat "chat-abc123"
|
|
150
|
-
```
|
|
292
|
+
- `--output`, `-o`: Output format (json|text)
|
|
151
293
|
|
|
152
294
|
#### `config-show`
|
|
153
295
|
Display current configuration (with masked API key).
|
|
154
296
|
|
|
155
|
-
**Example:**
|
|
156
|
-
```bash
|
|
157
|
-
toothfairy config-show
|
|
158
|
-
```
|
|
159
|
-
|
|
160
297
|
#### `help-guide`
|
|
161
298
|
Show detailed help with examples, common issues, and pro tips.
|
|
162
299
|
|
|
163
|
-
|
|
164
|
-
```bash
|
|
165
|
-
toothfairy help-guide
|
|
166
|
-
```
|
|
300
|
+
## 💡 Usage Examples
|
|
167
301
|
|
|
168
|
-
|
|
302
|
+
### Basic Workflow
|
|
303
|
+
```bash
|
|
304
|
+
# Configure once
|
|
305
|
+
toothfairy configure --api-key "tf-key-abc123" --workspace-id "workspace-456"
|
|
169
306
|
|
|
170
|
-
|
|
307
|
+
# Send messages to agents
|
|
308
|
+
toothfairy send "I'd like to schedule a session" --agent-id "my-scheduler"
|
|
171
309
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
export TF_API_KEY="your-api-key"
|
|
175
|
-
export TF_WORKSPACE_ID="your-workspace-id"
|
|
176
|
-
export TF_BASE_URL="https://api.toothfairyai.com" # optional
|
|
177
|
-
export TF_AI_URL="https://ai.toothfairyai.com" # optional
|
|
178
|
-
```
|
|
310
|
+
# Search for relevant information
|
|
311
|
+
toothfairy search "appointment scheduling help"
|
|
179
312
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
workspace_id: "your-workspace-id"
|
|
184
|
-
base_url: "https://api.toothfairyai.com" # optional
|
|
185
|
-
ai_url: "https://ai.toothfairyai.com" # optional
|
|
313
|
+
# Manage conversations
|
|
314
|
+
toothfairy chats
|
|
315
|
+
toothfairy chat chat-abc123
|
|
186
316
|
```
|
|
187
317
|
|
|
188
|
-
|
|
318
|
+
### Scripting Examples
|
|
189
319
|
```bash
|
|
190
|
-
|
|
191
|
-
```
|
|
320
|
+
#!/bin/bash
|
|
192
321
|
|
|
193
|
-
|
|
322
|
+
# Send message and extract agent response
|
|
323
|
+
RESPONSE=$(toothfairy send "What are your hours?" \
|
|
324
|
+
--agent-id "info-agent" \
|
|
325
|
+
--output json)
|
|
194
326
|
|
|
195
|
-
|
|
327
|
+
# Extract the agent's text response
|
|
328
|
+
AGENT_TEXT=$(echo "$RESPONSE" | jq -r '.agentResponse.contents.content')
|
|
329
|
+
echo "Agent said: $AGENT_TEXT"
|
|
196
330
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
# Get JSON output for scripting
|
|
202
|
-
toothfairy send "Hello" --agent-id "agent-123" --output json | jq '.agentResponse.contents.content'
|
|
331
|
+
# Search documents and extract relevant content
|
|
332
|
+
SEARCH_RESULTS=$(toothfairy search "office hours" --output json)
|
|
333
|
+
TOP_RESULT=$(echo "$SEARCH_RESULTS" | jq -r '.[0].raw_text')
|
|
334
|
+
echo "Found documentation: $TOP_RESULT"
|
|
203
335
|
|
|
204
|
-
#
|
|
205
|
-
|
|
336
|
+
# Get chat ID for follow-up
|
|
337
|
+
CHAT_ID=$(echo "$RESPONSE" | jq -r '.chatId')
|
|
338
|
+
echo "Chat ID: $CHAT_ID"
|
|
206
339
|
```
|
|
207
340
|
|
|
208
|
-
## SDK Usage
|
|
341
|
+
## 📦 SDK Usage
|
|
209
342
|
|
|
210
343
|
This package also provides a JavaScript SDK for programmatic access to ToothFairyAI.
|
|
211
344
|
|
|
@@ -214,6 +347,7 @@ This package also provides a JavaScript SDK for programmatic access to ToothFair
|
|
|
214
347
|
```javascript
|
|
215
348
|
const ToothFairyAPI = require('@toothfairyai/cli/src/api');
|
|
216
349
|
|
|
350
|
+
// Australia (default)
|
|
217
351
|
const api = new ToothFairyAPI(
|
|
218
352
|
'https://api.toothfairyai.com', // baseUrl
|
|
219
353
|
'https://ai.toothfairyai.com', // aiUrl
|
|
@@ -223,6 +357,26 @@ const api = new ToothFairyAPI(
|
|
|
223
357
|
false // verbose mode
|
|
224
358
|
);
|
|
225
359
|
|
|
360
|
+
// United States
|
|
361
|
+
const apiUS = new ToothFairyAPI(
|
|
362
|
+
'https://api.us.toothfairyai.com', // baseUrl
|
|
363
|
+
'https://ai.us.toothfairyai.com', // aiUrl
|
|
364
|
+
'https://stream.us.toothfairyai.com', // aiStreamUrl
|
|
365
|
+
'your-api-key',
|
|
366
|
+
'your-workspace-id',
|
|
367
|
+
false
|
|
368
|
+
);
|
|
369
|
+
|
|
370
|
+
// Europe
|
|
371
|
+
const apiEU = new ToothFairyAPI(
|
|
372
|
+
'https://api.eu.toothfairyai.com', // baseUrl
|
|
373
|
+
'https://ai.eu.toothfairyai.com', // aiUrl
|
|
374
|
+
'https://stream.eu.toothfairyai.com', // aiStreamUrl
|
|
375
|
+
'your-api-key',
|
|
376
|
+
'your-workspace-id',
|
|
377
|
+
false
|
|
378
|
+
);
|
|
379
|
+
|
|
226
380
|
// Send a message with streaming response
|
|
227
381
|
await api.sendMessageToAgentStream(
|
|
228
382
|
'Hello!',
|
|
@@ -237,16 +391,18 @@ await api.sendMessageToAgentStream(
|
|
|
237
391
|
);
|
|
238
392
|
```
|
|
239
393
|
|
|
240
|
-
###
|
|
394
|
+
### Advanced SDK Features
|
|
395
|
+
|
|
396
|
+
#### Show Progress Flag
|
|
241
397
|
|
|
242
|
-
The SDK
|
|
398
|
+
The SDK supports a `showProgress` flag that enables tracking of all events from the SSE endpoint:
|
|
243
399
|
|
|
244
400
|
```javascript
|
|
245
401
|
// Default behavior (standard events only)
|
|
246
402
|
await api.sendMessageToAgentStream(
|
|
247
|
-
'Hello!',
|
|
248
|
-
'agent-id',
|
|
249
|
-
null, null, null, {},
|
|
403
|
+
'Hello!',
|
|
404
|
+
'agent-id',
|
|
405
|
+
null, null, null, {},
|
|
250
406
|
(eventType, data) => {
|
|
251
407
|
// Receives: 'status', 'progress', 'data', 'complete', 'error', etc.
|
|
252
408
|
console.log(eventType, data);
|
|
@@ -255,9 +411,9 @@ await api.sendMessageToAgentStream(
|
|
|
255
411
|
|
|
256
412
|
// With showProgress enabled (all SSE events)
|
|
257
413
|
await api.sendMessageToAgentStream(
|
|
258
|
-
'Hello!',
|
|
259
|
-
'agent-id',
|
|
260
|
-
null, null, null, {},
|
|
414
|
+
'Hello!',
|
|
415
|
+
'agent-id',
|
|
416
|
+
null, null, null, {},
|
|
261
417
|
(eventType, data) => {
|
|
262
418
|
if (eventType === 'sse_event') {
|
|
263
419
|
// Raw SSE event with complete data from streaming endpoint
|
|
@@ -280,16 +436,89 @@ await api.sendMessageToAgentStream(
|
|
|
280
436
|
- `'error'`: Error events
|
|
281
437
|
- `'sse_event'`: All raw SSE events (when showProgress=true)
|
|
282
438
|
|
|
283
|
-
|
|
439
|
+
## ⚠️ Common Issues & Solutions
|
|
440
|
+
|
|
441
|
+
| Issue | Solution |
|
|
442
|
+
|-------|----------|
|
|
443
|
+
| Configuration incomplete | Run: `toothfairy configure --api-key YOUR_KEY --workspace-id YOUR_WORKSPACE` |
|
|
444
|
+
| No text response found | Use `--verbose` flag to see full response details |
|
|
445
|
+
| Agent not responding | Check agent-id is correct and agent is active |
|
|
446
|
+
| Network errors | Verify API endpoints are accessible and credentials are valid |
|
|
284
447
|
|
|
285
|
-
##
|
|
448
|
+
## 🐛 Troubleshooting
|
|
449
|
+
|
|
450
|
+
### Debug Mode
|
|
451
|
+
Use the `--verbose` flag to see detailed API request/response information:
|
|
286
452
|
|
|
287
453
|
```bash
|
|
454
|
+
toothfairy --verbose send "test message" --agent-id "agent-123"
|
|
455
|
+
toothfairy search "test" --verbose
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
### Configuration Issues
|
|
459
|
+
1. **Check current configuration:**
|
|
460
|
+
```bash
|
|
461
|
+
toothfairy config-show
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
2. **Verify credentials:**
|
|
465
|
+
```bash
|
|
466
|
+
toothfairy configure --api-key YOUR_KEY --workspace-id YOUR_WORKSPACE
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
3. **Test connection:**
|
|
470
|
+
```bash
|
|
471
|
+
toothfairy chats --verbose
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
## 📖 More Help
|
|
475
|
+
|
|
476
|
+
- **Command-specific help**: `toothfairy COMMAND --help`
|
|
477
|
+
- **Detailed examples**: `toothfairy help-guide`
|
|
478
|
+
- **Verbose debugging**: Use `--verbose` flag
|
|
479
|
+
- **JSON output**: Use `--output json` for machine-readable output
|
|
480
|
+
- **Configuration priority**: Environment variables → ~/.toothfairy/config.yml → CLI args
|
|
481
|
+
|
|
482
|
+
## ✨ Pro Tips
|
|
483
|
+
|
|
484
|
+
💾 **Save time**: Configure once with `toothfairy configure`, then just use `toothfairy send` and `toothfairy search`
|
|
485
|
+
|
|
486
|
+
🔍 **Debug issues**: Use `--verbose` to see full API responses and troubleshoot
|
|
487
|
+
|
|
488
|
+
📝 **Scripting**: Use `--output json` and tools like `jq` to parse responses
|
|
489
|
+
|
|
490
|
+
⚡ **Quick tests**: Only `--agent-id` is required for send, only query for search
|
|
491
|
+
|
|
492
|
+
🎯 **Better search**: Use `--status`, `--topics`, and `--document-id` for targeted results
|
|
493
|
+
|
|
494
|
+
🔧 **Multiple environments**: Use different config files with `--config` flag
|
|
495
|
+
|
|
496
|
+
🌍 **Regional performance**: Choose the region closest to you for best performance
|
|
497
|
+
|
|
498
|
+
📦 **Use as SDK**: Import the API class in your Node.js applications for programmatic access
|
|
499
|
+
|
|
500
|
+
## 👩💻 Development
|
|
501
|
+
|
|
502
|
+
```bash
|
|
503
|
+
# Install dependencies
|
|
288
504
|
npm install
|
|
505
|
+
|
|
506
|
+
# Run linter
|
|
289
507
|
npm run lint
|
|
508
|
+
|
|
509
|
+
# Run tests
|
|
290
510
|
npm test
|
|
511
|
+
|
|
512
|
+
# Link for local development
|
|
513
|
+
npm link
|
|
291
514
|
```
|
|
292
515
|
|
|
293
|
-
## License
|
|
516
|
+
## 📄 License
|
|
517
|
+
|
|
518
|
+
MIT License - see LICENSE file for details.
|
|
519
|
+
|
|
520
|
+
## 🔗 Links
|
|
294
521
|
|
|
295
|
-
|
|
522
|
+
- **Repository**: [ToothFairy CLI on Gitea](https://gitea.toothfairyai.com/ToothFairyAI/tooth-fairy-website/toothfairy-cli)
|
|
523
|
+
- **NPM Package**: [@toothfairyai/cli on npm](https://www.npmjs.com/package/@toothfairyai/cli)
|
|
524
|
+
- **Issues**: [Report bugs and feature requests](https://gitea.toothfairyai.com/ToothFairyAI/tooth-fairy-website/toothfairy-cli/issues)
|