@aeye/cletus 0.2.0 → 0.3.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 +175 -360
- package/dist/embed-worker.js +100 -0
- package/dist/index.js +26723 -8913
- package/package.json +114 -104
package/README.md
CHANGED
|
@@ -9,28 +9,74 @@ Cletus is a terminal-based AI assistant built with the @aeye library that demons
|
|
|
9
9
|
|
|
10
10
|
## Features
|
|
11
11
|
|
|
12
|
-
###
|
|
12
|
+
### Adaptive Tooling
|
|
13
13
|
|
|
14
|
-
Cletus
|
|
14
|
+
Cletus uses an intelligent tool selection system that automatically picks the most relevant tools based on your conversation context. Instead of having access to all 50+ tools at once (which can overwhelm the AI), Cletus:
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
- **
|
|
23
|
-
- **
|
|
16
|
+
1. **Analyzes your recent messages** - Uses embeddings to understand what you're asking about
|
|
17
|
+
2. **Selects relevant tools** - Picks the top 15-20 most semantically similar tools for the task
|
|
18
|
+
3. **Adapts over time** - As your conversation evolves, the available tools adjust automatically
|
|
19
|
+
|
|
20
|
+
You can also manually switch between specialized **toolsets** to focus on specific domains:
|
|
21
|
+
|
|
22
|
+
- **planner** - Task management and todo operations
|
|
23
|
+
- **librarian** - Knowledge base and semantic search
|
|
24
|
+
- **clerk** - File system operations and shell commands
|
|
25
|
+
- **secretary** - User memories and assistant management
|
|
26
|
+
- **architect** - Custom data type definitions and schema management
|
|
27
|
+
- **artist** - Image generation, editing, and analysis
|
|
28
|
+
- **internet** - Web search and API operations
|
|
29
|
+
- **dba** - Data record management and querying
|
|
30
|
+
|
|
31
|
+
Use the `retool` tool to switch between adaptive mode and specific toolsets
|
|
32
|
+
|
|
33
|
+
### Examples
|
|
34
|
+
|
|
35
|
+
Here are some examples of what you can do with Cletus:
|
|
36
|
+
|
|
37
|
+
**File Operations:**
|
|
38
|
+
- "Search for all TypeScript files in the src directory"
|
|
39
|
+
- "Read package.json and tell me what dependencies are outdated"
|
|
40
|
+
- "Create a new file called README.md with a project description"
|
|
41
|
+
- "Find all files containing the word 'TODO' and summarize them"
|
|
42
|
+
|
|
43
|
+
**Data Management:**
|
|
44
|
+
- "Create a 'Recipe' type with fields for ingredients, instructions, and cooking time"
|
|
45
|
+
- "Add a new recipe for chocolate chip cookies"
|
|
46
|
+
- "Find all recipes that contain chocolate"
|
|
47
|
+
|
|
48
|
+
**Task Planning:**
|
|
49
|
+
- "Add a todo to implement user authentication"
|
|
50
|
+
- "Show me all my pending todos"
|
|
51
|
+
- "Mark the first todo as done"
|
|
52
|
+
|
|
53
|
+
**Image Operations:**
|
|
54
|
+
- "Generate an image of a sunset over mountains"
|
|
55
|
+
- "Find all images I've generated that contain trees"
|
|
56
|
+
- "Analyze this screenshot and describe what you see"
|
|
57
|
+
|
|
58
|
+
**Web Research:**
|
|
59
|
+
- "Search the web for the latest TypeScript features"
|
|
60
|
+
- "Get the content from https://example.com and summarize it"
|
|
61
|
+
|
|
62
|
+
**Knowledge Base:**
|
|
63
|
+
- "Remember that I prefer tabs over spaces"
|
|
64
|
+
- "Index all files in my project for semantic search"
|
|
65
|
+
- "Search my knowledge base for information about authentication"
|
|
66
|
+
|
|
67
|
+
**Shell Commands:**
|
|
68
|
+
- "Run npm test and show me the results"
|
|
69
|
+
- "Execute git status and tell me what files have changed"
|
|
24
70
|
|
|
25
71
|
### 🎨 Interactive Terminal UI
|
|
26
72
|
|
|
27
73
|
- Beautiful React/Ink-based interface
|
|
28
|
-
- Automatic light/dark mode theme detection for optimal color visibility
|
|
29
74
|
- Chat history management
|
|
30
75
|
- Real-time streaming responses
|
|
31
|
-
-
|
|
76
|
+
- Markdown rendering
|
|
32
77
|
- Operation approval/rejection system
|
|
33
78
|
- Settings configuration wizard
|
|
79
|
+
- Automatic light/dark mode theme detection for optimal color visibility
|
|
34
80
|
|
|
35
81
|
### 💾 Persistent Storage
|
|
36
82
|
|
|
@@ -76,16 +122,6 @@ npm link
|
|
|
76
122
|
cletus
|
|
77
123
|
```
|
|
78
124
|
|
|
79
|
-
### Development Mode
|
|
80
|
-
|
|
81
|
-
```bash
|
|
82
|
-
# Watch mode with hot reload
|
|
83
|
-
npm run dev
|
|
84
|
-
|
|
85
|
-
# Or run directly with tsx
|
|
86
|
-
npm start
|
|
87
|
-
```
|
|
88
|
-
|
|
89
125
|
## Quick Start
|
|
90
126
|
|
|
91
127
|
### First Launch
|
|
@@ -104,9 +140,6 @@ The configuration is saved to `~/.cletus/config.json` and can be modified later
|
|
|
104
140
|
# Start Cletus
|
|
105
141
|
cletus
|
|
106
142
|
|
|
107
|
-
# Start Cletus with split view settings menu
|
|
108
|
-
cletus --split-settings
|
|
109
|
-
|
|
110
143
|
# The main menu provides options to:
|
|
111
144
|
# - Start a new chat
|
|
112
145
|
# - Continue existing chats
|
|
@@ -116,7 +149,6 @@ cletus --split-settings
|
|
|
116
149
|
|
|
117
150
|
### Command Line Arguments
|
|
118
151
|
|
|
119
|
-
- `--split-settings` - Use split view settings interface instead of nested menu (keeps all settings on one screen)
|
|
120
152
|
- `--profile=NAME` or `--profile NAME` - Use a specific configuration profile
|
|
121
153
|
|
|
122
154
|
### Creating a Chat
|
|
@@ -126,6 +158,93 @@ cletus --split-settings
|
|
|
126
158
|
3. Optionally provide a custom system prompt
|
|
127
159
|
4. Start chatting!
|
|
128
160
|
|
|
161
|
+
## Tools
|
|
162
|
+
|
|
163
|
+
Cletus provides 50+ tools organized into specialized toolsets. Here's what each toolset offers:
|
|
164
|
+
|
|
165
|
+
### 🗂️ Planner (`planner`)
|
|
166
|
+
Task management and todo operations:
|
|
167
|
+
- `todosList` - View all todos
|
|
168
|
+
- `todosAdd` - Add a new todo
|
|
169
|
+
- `todosDone` - Mark a todo as complete
|
|
170
|
+
- `todosGet` - Get a specific todo by ID
|
|
171
|
+
- `todosRemove` - Remove a todo
|
|
172
|
+
- `todosReplace` - Replace/update a todo
|
|
173
|
+
- `todosClear` - Clear all todos
|
|
174
|
+
|
|
175
|
+
### 📚 Librarian (`librarian`)
|
|
176
|
+
Knowledge base with semantic search:
|
|
177
|
+
- `knowledgeSearch` - Search knowledge base semantically
|
|
178
|
+
- `knowledgeSources` - List all knowledge sources
|
|
179
|
+
- `knowledgeAdd` - Add user memories to knowledge base
|
|
180
|
+
- `knowledgeDelete` - Delete knowledge source
|
|
181
|
+
|
|
182
|
+
### 📁 Clerk (`clerk`)
|
|
183
|
+
File system operations and shell commands:
|
|
184
|
+
- `fileSearch` - Search files by glob pattern
|
|
185
|
+
- `fileSummary` - Get AI summary of file content
|
|
186
|
+
- `fileIndex` - Index files into knowledge base
|
|
187
|
+
- `fileRead` - Read file contents
|
|
188
|
+
- `fileEdit` - Edit file with find/replace
|
|
189
|
+
- `fileCreate` - Create new file
|
|
190
|
+
- `fileCopy` - Copy file
|
|
191
|
+
- `fileMove` - Move/rename file
|
|
192
|
+
- `fileDelete` - Delete file
|
|
193
|
+
- `fileStats` - Get file metadata
|
|
194
|
+
- `fileAttach` - Attach file to message
|
|
195
|
+
- `textSearch` - Search file contents with regex
|
|
196
|
+
- `dirCreate` - Create directory
|
|
197
|
+
- `dirSummary` - Summarize directory contents
|
|
198
|
+
- `shell` - Execute shell commands
|
|
199
|
+
|
|
200
|
+
### 👤 Secretary (`secretary`)
|
|
201
|
+
User preferences and assistant management:
|
|
202
|
+
- `assistantSwitch` - Switch to different assistant
|
|
203
|
+
- `assistantUpdate` - Update assistant prompt
|
|
204
|
+
- `assistantAdd` - Create new assistant
|
|
205
|
+
- `memoryList` - List user memories
|
|
206
|
+
- `memoryUpdate` - Update user memories
|
|
207
|
+
|
|
208
|
+
### 🏗️ Architect (`architect`)
|
|
209
|
+
Custom data type system:
|
|
210
|
+
- `typeList` - List all custom types
|
|
211
|
+
- `typeInfo` - Get type definition
|
|
212
|
+
- `typeCreate` - Define new data type
|
|
213
|
+
- `typeUpdate` - Update type definition
|
|
214
|
+
- `typeDelete` - Delete type
|
|
215
|
+
- `typeImport` - Import type from JSON schema
|
|
216
|
+
|
|
217
|
+
### 🎨 Artist (`artist`)
|
|
218
|
+
Image generation and analysis:
|
|
219
|
+
- `imageGenerate` - Generate images from text
|
|
220
|
+
- `imageEdit` - Edit existing images
|
|
221
|
+
- `imageAnalyze` - Analyze image with vision AI
|
|
222
|
+
- `imageDescribe` - Get detailed image description
|
|
223
|
+
- `imageFind` - Search generated images
|
|
224
|
+
- `imageAttach` - Attach image to message
|
|
225
|
+
|
|
226
|
+
### 🌐 Internet (`internet`)
|
|
227
|
+
Web operations:
|
|
228
|
+
- `webSearch` - Search the web (via Tavily)
|
|
229
|
+
- `webGetPage` - Fetch and extract page content
|
|
230
|
+
- `webApiCall` - Make HTTP API requests
|
|
231
|
+
|
|
232
|
+
### 💾 DBA (`dba`)
|
|
233
|
+
Data record management:
|
|
234
|
+
- `dataIndex` - Index data records into knowledge base
|
|
235
|
+
- `dataImport` - Import data from files
|
|
236
|
+
- `dataSearch` - Semantic search over data records
|
|
237
|
+
- `dataGet` - Get specific data record
|
|
238
|
+
- `dbaQuery` - Query data with filters and sorting
|
|
239
|
+
|
|
240
|
+
### 🔧 Utility (always available)
|
|
241
|
+
Core system tools:
|
|
242
|
+
- `getOperationOutput` - Retrieve truncated operation output
|
|
243
|
+
- `about` - Information about Cletus
|
|
244
|
+
- `retool` - Switch toolsets or enable adaptive mode
|
|
245
|
+
- `hypothetical` - Switch to restrictive mode for exploration
|
|
246
|
+
- `ask` - Ask user multiple-choice questions with special UI
|
|
247
|
+
|
|
129
248
|
## Configuration
|
|
130
249
|
|
|
131
250
|
Cletus stores its data in `~/.cletus/`:
|
|
@@ -146,277 +265,21 @@ Cletus stores its data in `~/.cletus/`:
|
|
|
146
265
|
### Provider Configuration
|
|
147
266
|
|
|
148
267
|
Cletus supports multiple AI providers:
|
|
268
|
+
- OpenAI (For all model types)
|
|
269
|
+
- OpenRouter (For chat models)
|
|
270
|
+
- Replicate (For image generation & editing primarily)
|
|
271
|
+
- AWS (For chat models)
|
|
272
|
+
- Tavily (For web search)
|
|
149
273
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
```json
|
|
153
|
-
{
|
|
154
|
-
"providers": {
|
|
155
|
-
"openai": {
|
|
156
|
-
"apiKey": "sk-...",
|
|
157
|
-
"organization": "org-...", // Optional
|
|
158
|
-
"project": "proj_...", // Optional
|
|
159
|
-
"defaultModels": {
|
|
160
|
-
"chat": "gpt-4o",
|
|
161
|
-
"imageGenerate": "dall-e-3",
|
|
162
|
-
"transcription": "whisper-1",
|
|
163
|
-
"embedding": "text-embedding-3-large"
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
#### OpenRouter
|
|
171
|
-
|
|
172
|
-
```json
|
|
173
|
-
{
|
|
174
|
-
"providers": {
|
|
175
|
-
"openrouter": {
|
|
176
|
-
"apiKey": "sk-or-...",
|
|
177
|
-
"defaultParams": {
|
|
178
|
-
"siteUrl": "https://yoursite.com",
|
|
179
|
-
"appName": "Cletus",
|
|
180
|
-
"providers": {
|
|
181
|
-
"order": ["openai", "anthropic"],
|
|
182
|
-
"allowFallbacks": true
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
#### Replicate
|
|
191
|
-
|
|
192
|
-
```json
|
|
193
|
-
{
|
|
194
|
-
"providers": {
|
|
195
|
-
"replicate": {
|
|
196
|
-
"apiKey": "r8_..."
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
```
|
|
201
|
-
|
|
202
|
-
#### AWS Bedrock
|
|
203
|
-
|
|
204
|
-
Access to Claude, Llama, Mistral, and other models via AWS Bedrock. Supports credential auto-discovery from environment variables or IAM roles.
|
|
205
|
-
|
|
206
|
-
```json
|
|
207
|
-
{
|
|
208
|
-
"providers": {
|
|
209
|
-
"aws": {
|
|
210
|
-
"region": "us-east-1",
|
|
211
|
-
"credentials": {
|
|
212
|
-
"accessKeyId": "AKIA...",
|
|
213
|
-
"secretAccessKey": "..."
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
Alternatively, set environment variables (recommended):
|
|
221
|
-
```bash
|
|
222
|
-
export AWS_REGION=us-east-1
|
|
223
|
-
export AWS_ACCESS_KEY_ID=AKIA...
|
|
224
|
-
export AWS_SECRET_ACCESS_KEY=...
|
|
225
|
-
```
|
|
226
|
-
|
|
227
|
-
#### Tavily (Web Search)
|
|
228
|
-
|
|
229
|
-
```json
|
|
230
|
-
{
|
|
231
|
-
"tavily": {
|
|
232
|
-
"apiKey": "tvly-..."
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
```
|
|
274
|
+
Common environment variables & AWS profiles are auto-detected
|
|
236
275
|
|
|
237
276
|
### Model Selection
|
|
238
277
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
```json
|
|
242
|
-
{
|
|
243
|
-
"user": {
|
|
244
|
-
"models": {
|
|
245
|
-
"chat": "gpt-4o-mini",
|
|
246
|
-
"imageGenerate": "dall-e-3",
|
|
247
|
-
"imageAnalyze": "gpt-4o",
|
|
248
|
-
"embedding": "text-embedding-3-small",
|
|
249
|
-
"summary": "gpt-4o-mini"
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
```
|
|
278
|
+
In the settings you can configure what models you want to use for each behavior.
|
|
254
279
|
|
|
255
280
|
### Autonomous Mode
|
|
256
281
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
```json
|
|
260
|
-
{
|
|
261
|
-
"user": {
|
|
262
|
-
"autonomous": {
|
|
263
|
-
"maxIterations": 10, // Max tool calls without approval
|
|
264
|
-
"timeout": 300000 // 5 minutes in milliseconds
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
```
|
|
269
|
-
|
|
270
|
-
## Tool Categories
|
|
271
|
-
|
|
272
|
-
### Architect Tools
|
|
273
|
-
|
|
274
|
-
Manage custom data type definitions:
|
|
275
|
-
|
|
276
|
-
- `type_info` - View type schema and fields
|
|
277
|
-
- `type_create` - Create new type definitions
|
|
278
|
-
- `type_update` - Update types (backwards compatible)
|
|
279
|
-
|
|
280
|
-
### Artist Tools
|
|
281
|
-
|
|
282
|
-
Image operations:
|
|
283
|
-
|
|
284
|
-
- `image_generate` - Generate images from prompts
|
|
285
|
-
- `image_edit` - Edit existing images
|
|
286
|
-
- `image_analyze` - Ask questions about images
|
|
287
|
-
- `image_describe` - Get detailed image descriptions
|
|
288
|
-
- `image_find` - Semantic search over images
|
|
289
|
-
|
|
290
|
-
### Clerk Tools
|
|
291
|
-
|
|
292
|
-
File management:
|
|
293
|
-
|
|
294
|
-
- `file_search` - Find files with glob patterns
|
|
295
|
-
- `file_summary` - AI-generated file summaries
|
|
296
|
-
- `file_index` - Index files for semantic search
|
|
297
|
-
- `file_create` - Create new files
|
|
298
|
-
- `file_read` - Read file contents
|
|
299
|
-
- `file_edit` - Edit file contents
|
|
300
|
-
- `file_copy` - Copy files
|
|
301
|
-
- `file_move` - Move/rename files
|
|
302
|
-
- `file_delete` - Delete files
|
|
303
|
-
- `file_stats` - Get file metadata
|
|
304
|
-
- `text_search` - Search text content with regex
|
|
305
|
-
- `dir_create` - Create directories
|
|
306
|
-
|
|
307
|
-
### DBA Tools
|
|
308
|
-
|
|
309
|
-
Data operations (dynamically generated for each custom type):
|
|
310
|
-
|
|
311
|
-
- `data_create` - Create new records
|
|
312
|
-
- `data_update` - Update records by ID
|
|
313
|
-
- `data_delete` - Delete records by ID
|
|
314
|
-
- `data_select` - Query records with filters
|
|
315
|
-
- `data_update_many` - Bulk update operations
|
|
316
|
-
- `data_delete_many` - Bulk delete operations
|
|
317
|
-
- `data_aggregate` - Count and aggregate data
|
|
318
|
-
- `data_index` - Reindex knowledge base
|
|
319
|
-
- `data_import` - Import from files (CSV, JSON, etc.)
|
|
320
|
-
- `data_search` - Semantic search over records
|
|
321
|
-
|
|
322
|
-
### Internet Tools
|
|
323
|
-
|
|
324
|
-
Web operations:
|
|
325
|
-
|
|
326
|
-
- `web_search` - Search the web (via Tavily)
|
|
327
|
-
- `web_get_page` - Scrape web pages
|
|
328
|
-
- `web_api_call` - Make REST API requests
|
|
329
|
-
|
|
330
|
-
### Librarian Tools
|
|
331
|
-
|
|
332
|
-
Knowledge base management:
|
|
333
|
-
|
|
334
|
-
- `knowledge_search` - Semantic search
|
|
335
|
-
- `knowledge_sources` - List knowledge sources
|
|
336
|
-
- `knowledge_add` - Add user memories
|
|
337
|
-
- `knowledge_delete` - Remove knowledge entries
|
|
338
|
-
|
|
339
|
-
### Planner Tools
|
|
340
|
-
|
|
341
|
-
Task management:
|
|
342
|
-
|
|
343
|
-
- `todos_list` - List all todos
|
|
344
|
-
- `todos_add` - Add new todo
|
|
345
|
-
- `todos_done` - Mark todo complete
|
|
346
|
-
- `todos_get` - Get todo details
|
|
347
|
-
- `todos_remove` - Delete todo
|
|
348
|
-
- `todos_clear` - Clear all todos
|
|
349
|
-
- `todos_replace` - Replace entire todo list
|
|
350
|
-
|
|
351
|
-
### Secretary Tools
|
|
352
|
-
|
|
353
|
-
Assistant and memory management:
|
|
354
|
-
|
|
355
|
-
- `assistant_switch` - Change assistant persona
|
|
356
|
-
- `assistant_update` - Modify assistant prompt
|
|
357
|
-
- `assistant_add` - Create new assistant
|
|
358
|
-
- `memory_list` - View user memories
|
|
359
|
-
- `memory_update` - Add/update memories
|
|
360
|
-
|
|
361
|
-
## Examples
|
|
362
|
-
|
|
363
|
-
### File Operations
|
|
364
|
-
|
|
365
|
-
```
|
|
366
|
-
You: Summarize all TypeScript files in the src directory
|
|
367
|
-
|
|
368
|
-
Cletus: I'll search for TypeScript files and summarize them...
|
|
369
|
-
[Uses file_search and file_summary tools]
|
|
370
|
-
```
|
|
371
|
-
|
|
372
|
-
### Data Management
|
|
373
|
-
|
|
374
|
-
```
|
|
375
|
-
You: Create a new type for tracking books with title, author, and year
|
|
376
|
-
|
|
377
|
-
Cletus: I'll create a book type definition...
|
|
378
|
-
[Uses type_create tool]
|
|
379
|
-
|
|
380
|
-
You: Add "1984" by George Orwell published in 1949
|
|
381
|
-
|
|
382
|
-
Cletus: I'll create a new book record...
|
|
383
|
-
[Uses data_create tool with the book type]
|
|
384
|
-
```
|
|
385
|
-
|
|
386
|
-
### Image Generation
|
|
387
|
-
|
|
388
|
-
```
|
|
389
|
-
You: Generate an image of a sunset over mountains
|
|
390
|
-
|
|
391
|
-
Cletus: I'll generate that image for you...
|
|
392
|
-
[Uses image_generate tool, saves to .cletus/images/]
|
|
393
|
-
[Generated image: sunset_mountains_abc123.png](~/.cletus/images/sunset_mountains_abc123.png)
|
|
394
|
-
```
|
|
395
|
-
|
|
396
|
-
### Web Research
|
|
397
|
-
|
|
398
|
-
```
|
|
399
|
-
You: Search for recent TypeScript 5.0 features and summarize them
|
|
400
|
-
|
|
401
|
-
Cletus: Let me search for that information...
|
|
402
|
-
[Uses web_search tool]
|
|
403
|
-
[Summarizes findings from multiple sources]
|
|
404
|
-
```
|
|
405
|
-
|
|
406
|
-
### Knowledge Base
|
|
407
|
-
|
|
408
|
-
```
|
|
409
|
-
You: Remember that I prefer using async/await over promises
|
|
410
|
-
|
|
411
|
-
Cletus: I'll add that to your memories...
|
|
412
|
-
[Uses knowledge_add tool]
|
|
413
|
-
|
|
414
|
-
You: What are my coding preferences?
|
|
415
|
-
|
|
416
|
-
Cletus: Let me search your memories...
|
|
417
|
-
[Uses knowledge_search tool]
|
|
418
|
-
You prefer using async/await over promises...
|
|
419
|
-
```
|
|
282
|
+
You choose how autonomous Cletus is - either automatically performing certain operations or asking for approval.
|
|
420
283
|
|
|
421
284
|
## Custom Assistants
|
|
422
285
|
|
|
@@ -451,38 +314,6 @@ Cletus: Switching assistant...
|
|
|
451
314
|
|
|
452
315
|
Define structured data with validation:
|
|
453
316
|
|
|
454
|
-
```typescript
|
|
455
|
-
// Example type definition
|
|
456
|
-
{
|
|
457
|
-
name: "project",
|
|
458
|
-
friendlyName: "Project",
|
|
459
|
-
description: "Software project tracking",
|
|
460
|
-
knowledgeTemplate: "Project: {{name}}\nStatus: {{status}}\n{{#if description}}Description: {{description}}{{/if}}",
|
|
461
|
-
fields: [
|
|
462
|
-
{
|
|
463
|
-
name: "name",
|
|
464
|
-
friendlyName: "Name",
|
|
465
|
-
type: "string",
|
|
466
|
-
required: true
|
|
467
|
-
},
|
|
468
|
-
{
|
|
469
|
-
name: "status",
|
|
470
|
-
friendlyName: "Status",
|
|
471
|
-
type: "enum",
|
|
472
|
-
enumOptions: ["planning", "active", "completed"],
|
|
473
|
-
required: true,
|
|
474
|
-
default: "planning"
|
|
475
|
-
},
|
|
476
|
-
{
|
|
477
|
-
name: "description",
|
|
478
|
-
friendlyName: "Description",
|
|
479
|
-
type: "string",
|
|
480
|
-
required: false
|
|
481
|
-
}
|
|
482
|
-
]
|
|
483
|
-
}
|
|
484
|
-
```
|
|
485
|
-
|
|
486
317
|
### Semantic Search
|
|
487
318
|
|
|
488
319
|
Files, data records, and user memories are automatically embedded and searchable:
|
|
@@ -508,40 +339,6 @@ Operations:
|
|
|
508
339
|
- OCR for images in documents
|
|
509
340
|
- Image description and analysis
|
|
510
341
|
|
|
511
|
-
## Settings Interface
|
|
512
|
-
|
|
513
|
-
Cletus provides two interfaces for managing settings:
|
|
514
|
-
|
|
515
|
-
### Traditional Settings Menu (default)
|
|
516
|
-
- Navigate through nested menus with deep navigation
|
|
517
|
-
- Each setting category is accessed by drilling down through screens
|
|
518
|
-
- Good for focused, sequential configuration
|
|
519
|
-
|
|
520
|
-
### Split View Settings (use `--split-settings` flag)
|
|
521
|
-
- All settings accessible from a single screen
|
|
522
|
-
- Left panel shows categories, right panel shows configuration
|
|
523
|
-
- Reduced navigation and screen transitions
|
|
524
|
-
- Ideal for quick settings adjustments
|
|
525
|
-
|
|
526
|
-
Both interfaces provide the same functionality:
|
|
527
|
-
- User profile (name, pronouns, global prompt)
|
|
528
|
-
- Prompt file management
|
|
529
|
-
- Memory management
|
|
530
|
-
- Provider configuration (OpenAI, OpenRouter, Replicate, AWS)
|
|
531
|
-
- Tavily web search setup
|
|
532
|
-
- Model selection for different capabilities
|
|
533
|
-
- Autonomous operation settings
|
|
534
|
-
- Debug mode toggle
|
|
535
|
-
|
|
536
|
-
## Keyboard Shortcuts
|
|
537
|
-
|
|
538
|
-
- **Ctrl+C** - Exit current view (returns to main menu)
|
|
539
|
-
- **Arrow Keys** - Navigate menus
|
|
540
|
-
- **Enter** - Select menu item
|
|
541
|
-
- **Type** - In chat view, type messages
|
|
542
|
-
|
|
543
|
-
## Troubleshooting
|
|
544
|
-
|
|
545
342
|
### "No provider configured"
|
|
546
343
|
|
|
547
344
|
Add at least one provider in settings or edit `~/.cletus/config.json` to include API keys.
|
|
@@ -616,10 +413,28 @@ const myNewTool = ai.tool({
|
|
|
616
413
|
});
|
|
617
414
|
|
|
618
415
|
// 3. operations/clerk.tsx
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
416
|
+
export const myNewTool = operationOf<
|
|
417
|
+
{ input: string },
|
|
418
|
+
{ result: string }
|
|
419
|
+
>({
|
|
420
|
+
mode: 'read',
|
|
421
|
+
signature: 'my_new_tool(input: string)',
|
|
422
|
+
status: (input) => `Processing: ${input.input}`,
|
|
423
|
+
analyze: async ({ input }, { cwd }) => ({
|
|
424
|
+
analysis: `This will process: ${input.input}`,
|
|
425
|
+
doable: true,
|
|
426
|
+
}),
|
|
427
|
+
do: async ({ input }, ctx) => {
|
|
428
|
+
const result = await doSomething(input.input);
|
|
429
|
+
return { result };
|
|
430
|
+
},
|
|
431
|
+
render: (op, ai, showInput, showOutput) => renderOperation(
|
|
432
|
+
op,
|
|
433
|
+
`MyNewTool("${op.input.input}")`,
|
|
434
|
+
(op) => op.output ? `Result: ${op.output.result}` : null,
|
|
435
|
+
showInput, showOutput
|
|
436
|
+
),
|
|
437
|
+
});
|
|
623
438
|
```
|
|
624
439
|
|
|
625
440
|
### Building
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
|
|
2
|
+
import { createRequire as __createRequire } from 'module';
|
|
3
|
+
import { fileURLToPath as __fileURLToPath } from 'url';
|
|
4
|
+
import { dirname as __dirname_func } from 'path';
|
|
5
|
+
const __filename = __fileURLToPath(import.meta.url);
|
|
6
|
+
const __dirname = __dirname_func(__filename);
|
|
7
|
+
const require = __createRequire(import.meta.url);
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
// src/embed-worker.ts
|
|
11
|
+
import { parentPort, workerData } from "worker_threads";
|
|
12
|
+
import { EmbeddingModel, FlagEmbedding } from "fastembed";
|
|
13
|
+
var embeddingModel = null;
|
|
14
|
+
var initPromise = null;
|
|
15
|
+
async function initModel(cacheDir) {
|
|
16
|
+
if (!initPromise) {
|
|
17
|
+
initPromise = (async () => {
|
|
18
|
+
try {
|
|
19
|
+
return await FlagEmbedding.init({
|
|
20
|
+
model: EmbeddingModel.BGEBaseENV15,
|
|
21
|
+
cacheDir
|
|
22
|
+
});
|
|
23
|
+
} catch (err) {
|
|
24
|
+
console.error("Worker: Failed to load embedding model:", err);
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
})();
|
|
28
|
+
}
|
|
29
|
+
return initPromise;
|
|
30
|
+
}
|
|
31
|
+
async function handleMessage(message) {
|
|
32
|
+
const { type, id } = message;
|
|
33
|
+
try {
|
|
34
|
+
switch (type) {
|
|
35
|
+
case "init": {
|
|
36
|
+
embeddingModel = await initModel(message.cacheDir);
|
|
37
|
+
return {
|
|
38
|
+
type: "init",
|
|
39
|
+
id,
|
|
40
|
+
success: embeddingModel !== null,
|
|
41
|
+
result: embeddingModel !== null
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
case "canEmbed": {
|
|
45
|
+
return {
|
|
46
|
+
type: "canEmbed",
|
|
47
|
+
id,
|
|
48
|
+
success: true,
|
|
49
|
+
result: embeddingModel !== null
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
case "embed": {
|
|
53
|
+
if (!embeddingModel) {
|
|
54
|
+
return {
|
|
55
|
+
type: "embed",
|
|
56
|
+
id,
|
|
57
|
+
success: false,
|
|
58
|
+
error: "Embedding model not initialized"
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
const batches = embeddingModel.embed(message.texts);
|
|
62
|
+
const results = [];
|
|
63
|
+
for await (const batch of batches) {
|
|
64
|
+
results.push(...batch.map((x) => Array.prototype.slice.call(x)));
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
type: "embed",
|
|
68
|
+
id,
|
|
69
|
+
success: true,
|
|
70
|
+
result: results
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
default:
|
|
74
|
+
return {
|
|
75
|
+
type,
|
|
76
|
+
id,
|
|
77
|
+
success: false,
|
|
78
|
+
error: `Unknown message type: ${type}`
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
} catch (error) {
|
|
82
|
+
return {
|
|
83
|
+
type,
|
|
84
|
+
id,
|
|
85
|
+
success: false,
|
|
86
|
+
error: error.message
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (parentPort) {
|
|
91
|
+
parentPort.on("message", async (message) => {
|
|
92
|
+
const response = await handleMessage(message);
|
|
93
|
+
parentPort.postMessage(response);
|
|
94
|
+
});
|
|
95
|
+
if (workerData?.cacheDir) {
|
|
96
|
+
initModel(workerData.cacheDir).then((model) => {
|
|
97
|
+
embeddingModel = model;
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|