@sarkar-ai/deskmate 0.2.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/.env.example ADDED
@@ -0,0 +1,49 @@
1
+ # ===========================================
2
+ # Deskmate Configuration
3
+ # ===========================================
4
+ # Run `deskmate init` for interactive setup, or copy this file to .env and edit.
5
+ # Alternative: ./install.sh
6
+
7
+ # Telegram Bot Token (get from @BotFather)
8
+ # https://t.me/BotFather → /newbot → copy token
9
+ TELEGRAM_BOT_TOKEN=your_bot_token_here
10
+
11
+ # Your Telegram User ID (get from @userinfobot)
12
+ # https://t.me/userinfobot → send any message → copy Id
13
+ # Only this user can interact with the bot
14
+ ALLOWED_USER_ID=your_user_id_here
15
+
16
+ # Multi-client allowed users (for gateway mode)
17
+ # Format: clientType:userId, comma-separated
18
+ # Example: telegram:123456,discord:987654321,slack:U12345
19
+ ALLOWED_USERS=telegram:your_user_id_here
20
+
21
+ # Anthropic API Key
22
+ # https://console.anthropic.com/
23
+ ANTHROPIC_API_KEY=your_anthropic_key_here
24
+
25
+ # ===========================================
26
+ # Optional Configuration
27
+ # ===========================================
28
+
29
+ # Agent provider (only claude-code is supported)
30
+ AGENT_PROVIDER=claude-code
31
+
32
+ # Working directory for command execution (defaults to $HOME)
33
+ # WORKING_DIR defaults to $HOME if not set
34
+ WORKING_DIR=
35
+
36
+ # Log level: debug | info | warn | error | silent (defaults to info)
37
+ LOG_LEVEL=info
38
+
39
+ # Bot display name (defaults to "Deskmate")
40
+ BOT_NAME=Deskmate
41
+
42
+ # Folders the agent is allowed to access (colon-separated)
43
+ # The installer will configure this automatically based on your choices
44
+ # Example: /Users/yourname/Desktop:/Users/yourname/Documents:/Users/yourname/Downloads
45
+ ALLOWED_FOLDERS=
46
+
47
+ # Require Telegram approval for ALL operations (default: false)
48
+ # When true, even safe commands like 'ls' will require approval
49
+ REQUIRE_APPROVAL_FOR_ALL=false
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025-present Deskmate Contributors
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,360 @@
1
+ # Deskmate
2
+
3
+ Control your Local Machine from anywhere using natural language.
4
+
5
+ <p align="center">
6
+ <a href="LICENSE"><img src="https://img.shields.io/badge/License-MIT-blue.svg?style=for-the-badge" alt="MIT License"></a>
7
+ <a href="#requirements"><img src="https://img.shields.io/badge/platform-macOS%20%7C%20Linux%20%7C%20WSL2-lightgrey.svg?style=for-the-badge" alt="Platform"></a>
8
+ <a href="#requirements"><img src="https://img.shields.io/badge/node-%3E%3D18-green.svg?style=for-the-badge" alt="Node"></a>
9
+ </p>
10
+
11
+ Deskmate is a personal AI assistant that runs on your personal machine and talks to you on the channels you already use. Send a Telegram message from your phone, and it executes on your machine. Powered by the [Claude Agent SDK](https://docs.anthropic.com/en/docs/claude-code/agent-sdk) with full local tool access — no sandboxed command set, no artificial limits.
12
+
13
+ A passion project developed, born from a simple goal: staying in creative and developer flow even when I'm not sitting at my desk. Inspired by [gen-shell](https://github.com/sarkarsaurabh27/gen-shell).
14
+
15
+ [Getting Started](#quick-start) · [Gateway Mode](#gateway-mode) · [Architecture](#architecture) · [Contributing](#contributing)
16
+
17
+ ---
18
+
19
+ ## Demo
20
+
21
+ | Telegram Conversation | Installation |
22
+ |:---:|:---:|
23
+ | ![Telegram Demo](assets/deskmate-tg.gif) | ![Installation Demo](assets/deskmate-install.gif) |
24
+
25
+ ## How it works
26
+
27
+ ```
28
+ Telegram / Discord* / Slack* / ...
29
+ |
30
+ v
31
+ +-------------------+
32
+ | Gateway | auth, sessions, approval routing
33
+ | (control plane) |
34
+ +--------+----------+
35
+ |
36
+ v
37
+ +-------------------+
38
+ | Claude Code | full local tool access (Bash, Read, Write, Edit, ...)
39
+ | Agent (SDK) |
40
+ +-------------------+
41
+ |
42
+ v
43
+ Your Machine
44
+ (executes tasks)
45
+ ```
46
+ *Discord and Slack adapters are planned — see [Adding a new client](#adding-a-new-client).
47
+
48
+ The Gateway is the control plane. Each messaging platform is a thin I/O adapter. The agent has unrestricted access to your machine (approve-by-default), with optional approval gating for protected folders.
49
+
50
+ ## Highlights
51
+
52
+ - **Full local access** — the agent can run any command, read/write any file, take screenshots. No artificial 6-tool sandbox.
53
+ - **Multi-channel gateway** — Telegram today, Discord/Slack/WhatsApp tomorrow. One Gateway, many clients.
54
+ - **Conversation memory** — session continuity across messages. Ask follow-up questions naturally.
55
+ - **Extensible model layer** — Claude Code agent supports any provider that speaks the Anthropic Messages API (including [Ollama](https://ollama.com) for local models). See [Claude Code docs](https://docs.anthropic.com/en/docs/claude-code) for model configuration.
56
+ - **Approve-by-default** — safe commands auto-approve. Protected folders (Desktop, Documents, etc.) prompt for confirmation via inline buttons.
57
+ - **MCP server** — expose your machine as a tool server for Claude Desktop or any MCP client.
58
+ - **Runs as service** — launchd (macOS) or systemd (Linux) integration, starts on boot, restarts on crash.
59
+ - **Extensible agent layer** — ships with Claude Code agent. Bring your own via `registerProvider()`.
60
+
61
+ ## Requirements
62
+
63
+ - **macOS** (tested on Ventura, Sonoma, Sequoia) or **Linux** (with systemd)
64
+ - Windows via [WSL2](https://learn.microsoft.com/en-us/windows/wsl/install)
65
+ - Node.js 18+
66
+ - [Claude Code CLI](https://docs.anthropic.com/en/docs/claude-code) installed (`which claude`)
67
+ - Telegram account (for Telegram mode)
68
+ - Anthropic API key (or configure Claude Code CLI for [alternative providers](https://docs.anthropic.com/en/docs/claude-code))
69
+
70
+ ### Linux Prerequisites
71
+
72
+ - **Screenshots:** Install [ImageMagick](https://imagemagick.org/) (`sudo apt install imagemagick`) for screenshot support
73
+ - **Service:** systemd with user session support (`systemctl --user`)
74
+
75
+ ### macOS Permissions
76
+
77
+ The installer guides you through these (macOS only). You can also configure them manually in **System Settings > Privacy & Security**.
78
+
79
+ | Permission | Purpose |
80
+ |------------|---------|
81
+ | **Screen Recording** | Take screenshots when requested |
82
+ | **Accessibility** | Control system functions |
83
+ | **Full Disk Access** | Read/write files in protected locations |
84
+ | **Automation** | Control other applications via AppleScript |
85
+ | **Background Items** | Run as a background service at login |
86
+ | **Folder Access** | Access to Desktop, Documents, Downloads, etc. |
87
+
88
+ ## Quick Start
89
+
90
+ ### Install from npm (recommended for users)
91
+
92
+ ```bash
93
+ npm install -g deskmate
94
+ deskmate init
95
+ ```
96
+
97
+ The wizard walks you through everything: API keys, Telegram credentials,
98
+ platform permissions, and background service setup.
99
+
100
+ ### Install from source (for contributors)
101
+
102
+ ```bash
103
+ git clone https://github.com/sarkar-ai-taken/deskmate.git
104
+ cd deskmate
105
+ npm install --legacy-peer-deps
106
+ cp .env.example .env # edit with your credentials
107
+ npm run build
108
+ ./install.sh # or: npx deskmate init
109
+ ```
110
+
111
+ To reconfigure later: `deskmate init`
112
+
113
+ ## Running Modes
114
+
115
+ | Mode | Command | Description |
116
+ |------|---------|-------------|
117
+ | Telegram | `deskmate telegram` | Standalone Telegram bot (legacy) |
118
+ | Gateway | `deskmate gateway` | Multi-client gateway (recommended for new setups) |
119
+ | MCP | `deskmate mcp` | MCP server for Claude Desktop |
120
+ | Both | `deskmate both` | Telegram + MCP simultaneously |
121
+
122
+ ## Gateway Mode
123
+
124
+ The gateway is the recommended way to run Deskmate. It separates platform I/O from agent logic, so adding a new messaging client doesn't require touching auth, sessions, or the agent layer.
125
+
126
+ ```bash
127
+ # Configure multi-client auth
128
+ ALLOWED_USERS=telegram:123456,discord:987654321
129
+
130
+ # Start
131
+ deskmate gateway
132
+ ```
133
+
134
+ The gateway auto-registers clients based on available env vars. If `TELEGRAM_BOT_TOKEN` is set, Telegram is active. Future clients (Discord, Slack) follow the same pattern.
135
+
136
+ ### Gateway vs Telegram mode
137
+
138
+ - **`deskmate telegram`** — original standalone bot. Simple, self-contained, no gateway overhead. Good for single-user Telegram-only setups.
139
+ - **`deskmate gateway`** — centralized architecture. Auth, sessions, and agent orchestration are shared. Required for multi-client setups and recommended for new installations.
140
+
141
+ ## Bot Commands
142
+
143
+ | Command | Description |
144
+ |---------|-------------|
145
+ | `/start` | Show welcome message |
146
+ | `/screenshot` | Take a screenshot and send it |
147
+ | `/status` | Show system info and session status |
148
+ | `/reset` | Clear conversation memory and start fresh |
149
+
150
+ ## Usage Examples
151
+
152
+ **System management** — "Show disk usage", "What processes are using the most CPU?", "List all running Docker containers"
153
+
154
+ **File operations** — "Show me the contents of package.json", "Find all TypeScript files in src/", "Create a new file called notes.txt with today's date"
155
+
156
+ **Development** — "Run the tests", "What's the git status?", "Show me recent commits"
157
+
158
+ **Troubleshooting** — "What's using port 8080?", "Show me the last 50 lines of the error log", "Check if nginx is running"
159
+
160
+ **Visual** — "Take a screenshot", "Show me what's on the screen"
161
+
162
+ | Taking a Screenshot | Opening Google Meet |
163
+ |:---:|:---:|
164
+ | ![Screenshot Demo](assets/deskmate-screenshot.jpeg) | ![Google Meet Demo](assets/deskmate-video-call.jpeg) |
165
+
166
+ ## MCP Server
167
+
168
+ The MCP server exposes your machine as a tool server for Claude Desktop or any MCP client.
169
+
170
+ ### Setup with Claude Desktop
171
+
172
+ Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
173
+
174
+ ```json
175
+ {
176
+ "mcpServers": {
177
+ "deskmate": {
178
+ "command": "node",
179
+ "args": ["/path/to/deskmate/dist/index.js", "mcp"],
180
+ "env": {
181
+ "WORKING_DIR": "/Users/yourname"
182
+ }
183
+ }
184
+ }
185
+ }
186
+ ```
187
+
188
+ Restart Claude Desktop. You can now ask Claude to interact with your local machine.
189
+
190
+ ### Combined Mode (MCP + Telegram)
191
+
192
+ Run both with `deskmate both`. MCP handles Claude Desktop requests; Telegram sends approval notifications to your phone so you can approve sensitive operations from anywhere.
193
+
194
+ ## Security
195
+
196
+ > **Important**: The agent can execute arbitrary commands on your machine. This is by design — the strategy is approve-by-default for read-only operations, with approval gating for protected folders and write operations.
197
+
198
+ **Built-in protections:**
199
+
200
+ | Layer | What it does |
201
+ |-------|-------------|
202
+ | **User authentication** | Only allowlisted user IDs can interact (per-client) |
203
+ | **Folder protection** | Desktop, Documents, Downloads, etc. require explicit approval |
204
+ | **No sudo by default** | The agent won't use sudo unless you explicitly ask |
205
+ | **No open ports** | The bot polls Telegram's servers, doesn't expose any ports |
206
+ | **Structured logging** | All actions are logged with timestamps for audit |
207
+ | **Session isolation** | Gateway sessions are keyed by `clientType:channelId` |
208
+
209
+ **Recommendations:**
210
+ - Set `WORKING_DIR` to limit default command scope
211
+ - Use `ALLOWED_USERS` (gateway mode) for multi-client allowlisting
212
+ - Review logs regularly (`logs/stdout.log`)
213
+ - Keep `.env` secure and never commit it
214
+ - Use `REQUIRE_APPROVAL_FOR_ALL=true` if you want to approve every operation
215
+
216
+ ## Architecture
217
+
218
+ ```
219
+ src/
220
+ ├── core/
221
+ │ ├── agent/
222
+ │ │ ├── types.ts # AgentProvider interface
223
+ │ │ ├── factory.ts # Provider factory + registerProvider()
224
+ │ │ └── providers/
225
+ │ │ └── claude-code.ts # Claude Code SDK (default)
226
+ │ ├── approval.ts # Approval manager (auto-approve + manual)
227
+ │ ├── executor.ts # Command execution, file I/O, screenshots
228
+ │ └── logger.ts # Structured logging
229
+ ├── gateway/
230
+ │ ├── types.ts # MessagingClient, MessageHandler interfaces
231
+ │ ├── gateway.ts # Central coordinator
232
+ │ ├── security.ts # Multi-client allowlist auth
233
+ │ └── session.ts # Session manager (composite keys, idle pruning)
234
+ ├── clients/
235
+ │ └── telegram.ts # Telegram adapter (grammY)
236
+ ├── telegram/
237
+ │ └── bot.ts # Legacy standalone Telegram bot
238
+ └── mcp/
239
+ └── server.ts # MCP server
240
+ ```
241
+
242
+ **Agent layer** — ships with Claude Code (`@anthropic-ai/claude-agent-sdk`). Full built-in tool access: Bash, Read, Write, Edit, Glob, Grep. Custom agent providers can be registered via `registerProvider()`.
243
+
244
+ **Gateway layer** — central coordinator handling auth (`SecurityManager`), sessions (`SessionManager`), agent orchestration, approval routing, and screenshot delivery. Platform adapters implement the `MessagingClient` interface and do only I/O.
245
+
246
+ ### Adding a new client
247
+
248
+ 1. Create `src/clients/discord.ts` implementing `MessagingClient` (see `src/gateway/types.ts`)
249
+ 2. Add `DISCORD_BOT_TOKEN` to `.env`
250
+ 3. Add `discord:userId` to `ALLOWED_USERS`
251
+ 4. Register in the gateway startup: `gateway.registerClient(new DiscordClient(token))`
252
+
253
+ No changes to Gateway, SecurityManager, SessionManager, or the agent layer.
254
+
255
+ ### Bringing your own agent
256
+
257
+ ```typescript
258
+ import { AgentProvider, registerProvider } from "./core/agent";
259
+
260
+ class MyAgent implements AgentProvider {
261
+ readonly name = "my-agent";
262
+ readonly version = "1.0.0";
263
+ // implement query(), queryStream(), isAvailable()
264
+ }
265
+
266
+ registerProvider("my-agent", MyAgent);
267
+ // then set AGENT_PROVIDER=my-agent in .env
268
+ ```
269
+
270
+ ## Service Management
271
+
272
+ ### macOS (launchd)
273
+
274
+ ```bash
275
+ # View logs
276
+ tail -f logs/stdout.log
277
+ tail -f logs/stderr.log
278
+
279
+ # Stop the service
280
+ launchctl unload ~/Library/LaunchAgents/com.deskmate.service.plist
281
+
282
+ # Start the service
283
+ launchctl load ~/Library/LaunchAgents/com.deskmate.service.plist
284
+
285
+ # Check status
286
+ launchctl list | grep deskmate
287
+ ```
288
+
289
+ ### Linux (systemd)
290
+
291
+ ```bash
292
+ # View logs
293
+ tail -f logs/stdout.log
294
+ journalctl --user -u deskmate.service -f
295
+
296
+ # Stop / start / restart
297
+ systemctl --user stop deskmate.service
298
+ systemctl --user start deskmate.service
299
+ systemctl --user restart deskmate.service
300
+
301
+ # Check status
302
+ systemctl --user status deskmate.service
303
+ ```
304
+
305
+ ### Uninstall
306
+
307
+ ```bash
308
+ ./uninstall.sh
309
+ ```
310
+
311
+ ## Troubleshooting
312
+
313
+ **Bot not responding?**
314
+ 1. Check logs: `tail -f logs/stderr.log`
315
+ 2. Verify your `ALLOWED_USER_ID` matches your Telegram ID
316
+ 3. Ensure Claude Code CLI is installed: `which claude`
317
+
318
+ **Commands timing out?**
319
+ - Default timeout is 2 minutes
320
+ - Long-running commands may need adjustment
321
+
322
+ **Machine going to sleep?**
323
+ - macOS: Run `./install.sh` to configure sleep prevention, or manually: `sudo pmset -c sleep 0`
324
+ - Linux: The systemd service uses idle inhibitor. Check your desktop environment's power settings.
325
+
326
+ **Permission denied errors? (macOS)**
327
+ - Re-run `./install.sh` and go through the permissions setup
328
+ - Or manually grant permissions in System Settings > Privacy & Security
329
+
330
+ **Screenshots not working?**
331
+ - macOS: Grant Screen Recording permission in System Settings > Privacy & Security > Screen Recording
332
+ - Linux: Install ImageMagick (`sudo apt install imagemagick`)
333
+ - Restart the service after making changes
334
+
335
+ ## Future Work / Help Wanted
336
+
337
+ **Additional messaging clients** — the gateway architecture is ready. We'd welcome:
338
+ - `discord` — Discord bot via discord.js
339
+ - `slack` — Slack app via Bolt SDK
340
+ - `whatsapp` — WhatsApp via the Business API
341
+
342
+ **Background job handling** — the current `launchd` (macOS) + `systemd` (Linux) approach works but could be improved for different device types (always-on Mac Mini vs MacBook, headless Linux servers).
343
+
344
+ Open an issue to discuss your approach.
345
+
346
+ ## Contributing
347
+
348
+ We welcome contributions! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
349
+
350
+ See [DEVELOPMENT.md](DEVELOPMENT.md) for architecture details and local setup.
351
+
352
+ ## License
353
+
354
+ MIT License — see [LICENSE](LICENSE) for details.
355
+
356
+ ## Acknowledgments
357
+
358
+ - [Claude Agent SDK](https://docs.anthropic.com/en/docs/claude-code/agent-sdk) — agent runtime
359
+ - [grammY](https://grammy.dev/) — Telegram bot framework
360
+ - [@modelcontextprotocol/sdk](https://github.com/modelcontextprotocol/sdk) — MCP support