@menasehk/sera 1.0.2

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 (123) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +376 -0
  3. package/dist/index.d.ts +3 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +2 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/managers/conversation.d.ts +24 -0
  8. package/dist/managers/conversation.d.ts.map +1 -0
  9. package/dist/managers/conversation.js +1 -0
  10. package/dist/managers/conversation.js.map +1 -0
  11. package/dist/managers/setup.d.ts +3 -0
  12. package/dist/managers/setup.d.ts.map +1 -0
  13. package/dist/managers/setup.js +1 -0
  14. package/dist/managers/setup.js.map +1 -0
  15. package/dist/providers/anthropic.d.ts +10 -0
  16. package/dist/providers/anthropic.d.ts.map +1 -0
  17. package/dist/providers/anthropic.js +1 -0
  18. package/dist/providers/anthropic.js.map +1 -0
  19. package/dist/providers/index.d.ts +12 -0
  20. package/dist/providers/index.d.ts.map +1 -0
  21. package/dist/providers/index.js +1 -0
  22. package/dist/providers/index.js.map +1 -0
  23. package/dist/providers/ollama.d.ts +9 -0
  24. package/dist/providers/ollama.d.ts.map +1 -0
  25. package/dist/providers/ollama.js +1 -0
  26. package/dist/providers/ollama.js.map +1 -0
  27. package/dist/providers/openai.d.ts +10 -0
  28. package/dist/providers/openai.d.ts.map +1 -0
  29. package/dist/providers/openai.js +1 -0
  30. package/dist/providers/openai.js.map +1 -0
  31. package/dist/storage/index.d.ts +6 -0
  32. package/dist/storage/index.d.ts.map +1 -0
  33. package/dist/storage/index.js +1 -0
  34. package/dist/storage/index.js.map +1 -0
  35. package/dist/storage/json-storage.d.ts +23 -0
  36. package/dist/storage/json-storage.d.ts.map +1 -0
  37. package/dist/storage/json-storage.js +1 -0
  38. package/dist/storage/json-storage.js.map +1 -0
  39. package/dist/storage/sqlite-storage.d.ts +22 -0
  40. package/dist/storage/sqlite-storage.d.ts.map +1 -0
  41. package/dist/storage/sqlite-storage.js +1 -0
  42. package/dist/storage/sqlite-storage.js.map +1 -0
  43. package/dist/tools/browser.d.ts +38 -0
  44. package/dist/tools/browser.d.ts.map +1 -0
  45. package/dist/tools/browser.js +1 -0
  46. package/dist/tools/browser.js.map +1 -0
  47. package/dist/tools/database.d.ts +47 -0
  48. package/dist/tools/database.d.ts.map +1 -0
  49. package/dist/tools/database.js +1 -0
  50. package/dist/tools/database.js.map +1 -0
  51. package/dist/tools/filesystem.d.ts +79 -0
  52. package/dist/tools/filesystem.d.ts.map +1 -0
  53. package/dist/tools/filesystem.js +1 -0
  54. package/dist/tools/filesystem.js.map +1 -0
  55. package/dist/tools/index.d.ts +18 -0
  56. package/dist/tools/index.d.ts.map +1 -0
  57. package/dist/tools/index.js +1 -0
  58. package/dist/tools/index.js.map +1 -0
  59. package/dist/tools/memory.d.ts +4 -0
  60. package/dist/tools/memory.d.ts.map +1 -0
  61. package/dist/tools/memory.js +1 -0
  62. package/dist/tools/memory.js.map +1 -0
  63. package/dist/tools/native.d.ts +6 -0
  64. package/dist/tools/native.d.ts.map +1 -0
  65. package/dist/tools/native.js +1 -0
  66. package/dist/tools/native.js.map +1 -0
  67. package/dist/tools/notification.d.ts +26 -0
  68. package/dist/tools/notification.d.ts.map +1 -0
  69. package/dist/tools/notification.js +1 -0
  70. package/dist/tools/notification.js.map +1 -0
  71. package/dist/tools/shell.d.ts +26 -0
  72. package/dist/tools/shell.d.ts.map +1 -0
  73. package/dist/tools/shell.js +1 -0
  74. package/dist/tools/shell.js.map +1 -0
  75. package/dist/tools/system.d.ts +47 -0
  76. package/dist/tools/system.d.ts.map +1 -0
  77. package/dist/tools/system.js +1 -0
  78. package/dist/tools/system.js.map +1 -0
  79. package/dist/tools/tasks.d.ts +20 -0
  80. package/dist/tools/tasks.d.ts.map +1 -0
  81. package/dist/tools/tasks.js +1 -0
  82. package/dist/tools/tasks.js.map +1 -0
  83. package/dist/types.d.ts +140 -0
  84. package/dist/types.d.ts.map +1 -0
  85. package/dist/types.js +1 -0
  86. package/dist/types.js.map +1 -0
  87. package/dist/utils/config.d.ts +17 -0
  88. package/dist/utils/config.d.ts.map +1 -0
  89. package/dist/utils/config.js +1 -0
  90. package/dist/utils/config.js.map +1 -0
  91. package/dist/utils/daemon.d.ts +18 -0
  92. package/dist/utils/daemon.d.ts.map +1 -0
  93. package/dist/utils/daemon.js +1 -0
  94. package/dist/utils/daemon.js.map +1 -0
  95. package/dist/utils/errors.d.ts +18 -0
  96. package/dist/utils/errors.d.ts.map +1 -0
  97. package/dist/utils/errors.js +1 -0
  98. package/dist/utils/errors.js.map +1 -0
  99. package/dist/utils/logger.d.ts +15 -0
  100. package/dist/utils/logger.d.ts.map +1 -0
  101. package/dist/utils/logger.js +1 -0
  102. package/dist/utils/logger.js.map +1 -0
  103. package/dist/utils/memory.d.ts +34 -0
  104. package/dist/utils/memory.d.ts.map +1 -0
  105. package/dist/utils/memory.js +1 -0
  106. package/dist/utils/memory.js.map +1 -0
  107. package/dist/utils/permissions.d.ts +16 -0
  108. package/dist/utils/permissions.d.ts.map +1 -0
  109. package/dist/utils/permissions.js +1 -0
  110. package/dist/utils/permissions.js.map +1 -0
  111. package/dist/utils/recurrence.d.ts +18 -0
  112. package/dist/utils/recurrence.d.ts.map +1 -0
  113. package/dist/utils/recurrence.js +1 -0
  114. package/dist/utils/recurrence.js.map +1 -0
  115. package/dist/utils/retry.d.ts +12 -0
  116. package/dist/utils/retry.d.ts.map +1 -0
  117. package/dist/utils/retry.js +1 -0
  118. package/dist/utils/retry.js.map +1 -0
  119. package/dist/utils/sanitize.d.ts +12 -0
  120. package/dist/utils/sanitize.d.ts.map +1 -0
  121. package/dist/utils/sanitize.js +1 -0
  122. package/dist/utils/sanitize.js.map +1 -0
  123. package/package.json +104 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 tagcodi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,376 @@
1
+ # SERA / ስራ — Your AI-Powered Work Command Center
2
+
3
+ > **ስራ** means *work* in Amharic. Manage tasks, appointments, notes, calendar, contacts, and system automation through natural language — directly from your terminal.
4
+
5
+ ```
6
+ ╔══════════════════════════════════════════════════╗
7
+ ║ ║
8
+ ║ ███████╗███████╗██████╗ █████╗ ║
9
+ ║ ██╔════╝██╔════╝██╔══██╗██╔══██╗ ║
10
+ ║ ██╔████║██║ ██║██║ ██║ ███████║ ║
11
+ ║ ██║╚███║██║ ██║╚██╗ ██╔╝ ██╔══██║ ║
12
+ ║ ██║ ╚██║╚██████╔╝ ╚████╔╝ ██║ ██║ ║
13
+ ║ ╚═╝ ╚═╝ ╚═════╝ ╚═══╝ ╚═╝ ╚═╝ ║
14
+ ║ ║
15
+ ║ Your AI-Powered Daily Command Center v1.0.0 ║
16
+ ╚═════════════════════════════════════════════════╝
17
+ ```
18
+
19
+ ---
20
+
21
+ ## What is SERA?
22
+
23
+ SERA is a CLI productivity assistant powered by your choice of AI model. You talk to it in plain English and it acts — creating tasks, scheduling appointments, running shell commands, querying your custom databases, and more. It runs entirely on your machine with full access to your filesystem, controlled by a granular permission system.
24
+
25
+ **Supported AI providers:** OpenAI · Anthropic (Claude) · Ollama (local) · Groq
26
+
27
+ ---
28
+
29
+ ## Installation
30
+
31
+ **Prerequisites:** Node.js 18 or higher
32
+
33
+ ```bash
34
+ # 1. Clone and enter the project
35
+ git clone <repo-url>
36
+ cd sera
37
+
38
+ # 2. Install dependencies
39
+ npm install
40
+
41
+ # 3. Build
42
+ npm run build
43
+
44
+ # 4. Install globally
45
+ npm install -g .
46
+ ```
47
+
48
+ After installation, run `sera` from any directory.
49
+
50
+ ---
51
+
52
+ ## Quick Start
53
+
54
+ ```bash
55
+ sera setup # Configure your AI provider and preferences (run this first)
56
+ sera # Launch interactive AI chat
57
+ sera today # See today's tasks and appointments
58
+ sera how # Full usage guide
59
+ ```
60
+
61
+ ---
62
+
63
+ ## Configuration
64
+
65
+ Run `sera setup` to configure SERA interactively. Settings are saved to `~/.sera/config.json`.
66
+
67
+ | Setting | Description |
68
+ |---|---|
69
+ | **AI Provider** | OpenAI, Anthropic, Ollama, or Groq |
70
+ | **Model** | e.g. `gpt-4o`, `claude-sonnet-4-20250514`, `llama3.1` |
71
+ | **API Key** | Your provider API key (not needed for Ollama) |
72
+ | **Storage** | JSON (default) or SQLite |
73
+ | **Permissions** | How strictly to ask before running tools |
74
+
75
+ ```bash
76
+ sera config # View current settings
77
+ sera config --reset # Reset and re-run setup
78
+ ```
79
+
80
+ ---
81
+
82
+ ## Commands
83
+
84
+ ### Core
85
+
86
+ | Command | Description |
87
+ |---|---|
88
+ | `sera` | Start interactive AI chat session |
89
+ | `sera setup` | Run the interactive setup wizard |
90
+ | `sera today` | Today's summary: tasks, appointments, overdue items |
91
+ | `sera how` | Full usage guide with examples |
92
+
93
+ ### Tasks
94
+
95
+ ```bash
96
+ sera add "Fix the login bug" # Quick-add (AI infers priority)
97
+ sera add "Submit report" -p high -d friday # With priority and due date
98
+ sera done "Fix the login bug" # Mark done by name
99
+ sera tasks # View active tasks
100
+ sera tasks --all # Include done & cancelled
101
+ sera tasks --priority urgent # Filter by priority
102
+ sera tasks --status in_progress # Filter by status
103
+ ```
104
+
105
+ **Priority levels:** `low` · `medium` · `high` · `urgent`
106
+
107
+ **In chat:**
108
+ ```
109
+ "Mark all overdue tasks as cancelled"
110
+ "Show me everything due this week"
111
+ "What's still in progress?"
112
+ ```
113
+
114
+ ### Appointments & Reminders
115
+
116
+ ```bash
117
+ sera cal # Upcoming appointments (next 7 days)
118
+ sera cal --days 30 # Next 30 days
119
+ sera remind 30 "Take meds" # Desktop notification in 30 minutes
120
+ ```
121
+
122
+ **In chat:**
123
+ ```
124
+ "Add dentist appointment next Tuesday 2pm"
125
+ "Reschedule my 3pm meeting to 4:30pm"
126
+ "Remind me to call mom at 6pm"
127
+ "What do I have this week?"
128
+ ```
129
+
130
+ ### Notes
131
+
132
+ ```bash
133
+ sera note "Buy oat milk" # Quick capture
134
+ sera note "Meeting notes" -t work,q2 # With tags
135
+ sera notes # View all notes
136
+ ```
137
+
138
+ **In chat:**
139
+ ```
140
+ "Search my notes for anything about the Q2 launch"
141
+ "Summarise my work notes from this week"
142
+ ```
143
+
144
+ ### Custom Database Collections
145
+
146
+ SERA can create and manage custom data collections for anything you want to track — expenses, contacts, gym logs, medications, habits, reading lists, and more.
147
+
148
+ ```bash
149
+ sera db # List all collections
150
+ sera db --show expenses # View records in a collection
151
+ sera db --schema expenses # View the schema (fields and types)
152
+ ```
153
+
154
+ **In chat:**
155
+ ```
156
+ "Create a collection to track my expenses with: amount, category, description, date"
157
+ "Add an expense: $45 lunch, category: food"
158
+ "Show all expenses over $100 this month"
159
+ "Add a 'notes' field to my expenses collection"
160
+ "Create a contacts table: name, email, phone, company"
161
+ "Delete the old habits collection"
162
+ "Back up all my data"
163
+ ```
164
+
165
+ **Field types:** `string` · `number` · `boolean` · `date` · `json`
166
+
167
+ ### AI Memory
168
+
169
+ SERA remembers facts about you across sessions — name, timezone, preferences, work context, goals, and more. No prompting needed; it picks things up naturally from your conversations.
170
+
171
+ ```bash
172
+ sera memory # View all stored memories
173
+ sera memory --category work # Filter by category
174
+ sera memory --forget "timezone" # Delete a specific memory
175
+ sera memory --forget-all # Clear everything
176
+ ```
177
+
178
+ **In chat:**
179
+ ```
180
+ "Remember that I prefer concise answers"
181
+ "My timezone is CET"
182
+ "Forget that I work at Acme"
183
+ ```
184
+ **Slash command (interactive mode):** `/memory`
185
+
186
+ **Categories:** `personal` · `work` · `preferences` · `health` · `goals` · `context`
187
+
188
+ ### Calendar & Contacts
189
+
190
+ SERA can add events to your calendar and contacts to your address book directly from chat.
191
+
192
+ **macOS** — uses Calendar.app and Contacts.app natively (no extra setup).
193
+ **Other platforms** — creates an `.ics` or `.vcf` file and opens it with your default app.
194
+
195
+ ```
196
+ "Add a dentist appointment on Friday at 3pm"
197
+ "Create an event: Team standup every Monday 9am"
198
+ "Add John Smith to my contacts, phone 555-1234, email john@acme.com"
199
+ "Look up Alice in my contacts"
200
+ "Add this to Google Calendar: product launch party, Saturday 7pm"
201
+ ```
202
+
203
+ SERA will always ask your permission before touching your calendar or contacts.
204
+
205
+ ### Background Daemon
206
+
207
+ The daemon runs quietly in the background and sends desktop notifications so you never miss anything — even when SERA isn't open.
208
+
209
+ ```bash
210
+ sera daemon start # Start the background monitor
211
+ sera daemon stop # Stop it
212
+ sera daemon restart # Restart
213
+ sera daemon status # Is it running?
214
+ sera daemon logs # View recent log output
215
+ sera daemon install # Auto-start at login (launchd on macOS, systemd on Linux)
216
+ ```
217
+
218
+ **What the daemon monitors:**
219
+ - Task overdue alerts — fires the moment a task deadline passes
220
+ - Appointment reminders — 15 minutes before + when it starts
221
+ - Morning briefing — 9 AM summary of the day's tasks and appointments
222
+
223
+ ### Backup & Export
224
+
225
+ ```bash
226
+ sera export # Export all data → ~/sera-backup-<date>.json
227
+ sera export -o ~/my-backup.json # Export to a specific path
228
+ sera import ~/my-backup.json # Restore from a backup file
229
+ ```
230
+
231
+ ### System Automation (in chat)
232
+
233
+ SERA can run shell commands, read/write files, and interact with your OS — subject to your permission settings.
234
+
235
+ ```
236
+ "Run my backup script at ~/scripts/backup.sh"
237
+ "List all PDF files in my Downloads folder"
238
+ "Create a folder called Projects on my Desktop"
239
+ "Open github.com in my browser"
240
+ "What's my current git branch?"
241
+ "Copy 'hello world' to my clipboard"
242
+ "Show me system memory usage"
243
+ ```
244
+
245
+ ---
246
+
247
+ ## In-Chat Slash Commands
248
+
249
+ While in an interactive session (`sera`), these commands are available:
250
+
251
+ | Command | Description |
252
+ |---|---|
253
+ | `/help` | Show this list |
254
+ | `/guide` | Full usage guide with examples |
255
+ | `/clear` | Clear the conversation and screen |
256
+ | `/history` | Recent chat messages |
257
+ | `/tools` | All available AI tools by category and risk level |
258
+ | `/perms` | Saved permission rules |
259
+ | `/config` | Current configuration |
260
+ | `/db` | Quick view of all custom collections |
261
+ | `/memory` | View stored memories about you |
262
+ | `/tokens` | Current conversation message count |
263
+ | `/quit` | Exit SERA |
264
+
265
+ ---
266
+
267
+ ## Permissions
268
+
269
+ SERA asks for confirmation before running tools that touch your system. You control how strict this is.
270
+
271
+ **Permission levels** (set during `sera setup`):
272
+
273
+ - `ask` — prompt for every tool call *(most secure)*
274
+ - `auto` — auto-approve low-risk tools, ask for high-risk
275
+ - `allow` — allow everything without asking *(fastest)*
276
+
277
+ When prompted, you can choose:
278
+ - **Allow once** — allow this single call
279
+ - **Always allow** — save a permanent rule for this tool
280
+ - **Allow this session** — allow until you exit
281
+ - **Deny** / **Deny always**
282
+
283
+ ```bash
284
+ sera perms # View saved rules
285
+ sera perms --clear # Reset all rules
286
+ ```
287
+
288
+ ---
289
+
290
+ ## Error Handling
291
+
292
+ SERA gives clear, actionable error messages. For example, if your API key doesn't have access to a model:
293
+
294
+ ```
295
+ ✖ Project does not have access to model gpt-4-turbo [model_not_found]
296
+
297
+ ◆ Run sera setup to pick a different model (e.g. gpt-4o-mini).
298
+ ```
299
+
300
+ SERA also automatically retries on rate limits (429) and transient server errors (5xx) with exponential backoff, so temporary blips don't interrupt your workflow.
301
+
302
+ ---
303
+
304
+ ## Data & Privacy
305
+
306
+ All your data lives locally on your machine:
307
+
308
+ | File | Contents |
309
+ |---|---|
310
+ | `~/.sera/config.json` | Configuration and permission rules |
311
+ | `~/.sera/data.json` | Tasks, appointments, and notes |
312
+ | `~/.sera/collections.json` | Custom database collections |
313
+
314
+ Your data is never sent anywhere other than your chosen AI provider's API for chat completions. SERA does not phone home.
315
+
316
+ ---
317
+
318
+ ## Development
319
+
320
+ ```bash
321
+ npm run build # Compile TypeScript → dist/
322
+ npm run dev # Run directly with ts-node (no build step)
323
+ npm test # Run the test suite
324
+ npm run test:watch # Watch mode
325
+ npm run test:coverage # With coverage report
326
+ ```
327
+
328
+ **Test suite covers:**
329
+ - Shell command sanitization (safe commands + 14 blocked dangerous patterns)
330
+ - Retry logic (rate limits, server errors, network failures, custom predicates)
331
+ - AI provider response parsing (OpenAI + Anthropic, including tool calls)
332
+ - Database CRUD, schema management, field validation, backup/restore
333
+
334
+ ### Project Structure
335
+
336
+ ```
337
+ src/
338
+ ├── index.ts # CLI commands, UI rendering, interactive loop
339
+ ├── types.ts # Shared TypeScript interfaces
340
+ ├── providers/ # AI provider adapters
341
+ │ ├── openai.ts # OpenAI & Groq (same API format)
342
+ │ ├── anthropic.ts # Anthropic Claude
343
+ │ ├── ollama.ts # Ollama (local models)
344
+ │ └── index.ts # Provider factory
345
+ ├── tools/ # AI-callable tools
346
+ │ ├── shell.ts # Shell command execution (with sanitization)
347
+ │ ├── filesystem.ts # File read/write/list/delete
348
+ │ ├── browser.ts # Open URL, web search
349
+ │ ├── system.ts # System info, datetime, clipboard
350
+ │ ├── notification.ts # Desktop notifications
351
+ │ ├── tasks.ts # Task, appointment & note tools
352
+ │ ├── database.ts # Custom collection manager + tools
353
+ │ └── index.ts # Tool registry
354
+ ├── managers/
355
+ │ ├── conversation.ts # Agentic AI loop with tool calling
356
+ │ └── setup.ts # Interactive setup wizard
357
+ ├── storage/ # Storage backends (JSON / SQLite)
358
+ ├── utils/
359
+ │ ├── config.ts # Config read/write
360
+ │ ├── permissions.ts # Permission prompt system
361
+ │ ├── retry.ts # Exponential backoff for API calls
362
+ │ ├── sanitize.ts # Shell command safety filter
363
+ │ ├── errors.ts # API error parsing & friendly messages
364
+ │ └── logger.ts # Debug logger
365
+ └── __tests__/ # Jest test suite
366
+ ├── sanitize.test.ts
367
+ ├── retry.test.ts
368
+ ├── providers.test.ts
369
+ └── database.test.ts
370
+ ```
371
+
372
+ ---
373
+
374
+ ## License
375
+
376
+ MIT
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}