@4via6/relay 1.0.0 → 1.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.
Files changed (66) hide show
  1. package/README.md +89 -47
  2. package/dist/auth.d.ts +1 -0
  3. package/dist/auth.js +6 -3
  4. package/dist/auth.js.map +1 -1
  5. package/dist/bot.js +2 -1
  6. package/dist/bot.js.map +1 -1
  7. package/dist/cli.d.ts +1 -1
  8. package/dist/cli.js +110 -1
  9. package/dist/cli.js.map +1 -1
  10. package/dist/commands/admin.js +134 -29
  11. package/dist/commands/admin.js.map +1 -1
  12. package/dist/commands/media.js +10 -7
  13. package/dist/commands/media.js.map +1 -1
  14. package/dist/config/index.d.ts +7 -0
  15. package/dist/config/index.js +16 -0
  16. package/dist/config/index.js.map +1 -0
  17. package/dist/config/loader.d.ts +11 -0
  18. package/dist/config/loader.js +235 -0
  19. package/dist/config/loader.js.map +1 -0
  20. package/dist/config/schema.d.ts +32 -0
  21. package/dist/config/schema.js +32 -0
  22. package/dist/config/schema.js.map +1 -0
  23. package/dist/config/setup.d.ts +3 -0
  24. package/dist/config/setup.js +142 -0
  25. package/dist/config/setup.js.map +1 -0
  26. package/dist/daemon.d.ts +5 -0
  27. package/dist/daemon.js +215 -0
  28. package/dist/daemon.js.map +1 -0
  29. package/dist/index.js +23 -25
  30. package/dist/index.js.map +1 -1
  31. package/dist/providers/claude.js +31 -30
  32. package/dist/providers/claude.js.map +1 -1
  33. package/dist/providers/codex.js +29 -28
  34. package/dist/providers/codex.js.map +1 -1
  35. package/dist/providers/index.js +2 -1
  36. package/dist/providers/index.js.map +1 -1
  37. package/dist/providers/opencode.js +8 -5
  38. package/dist/providers/opencode.js.map +1 -1
  39. package/dist/session.js +3 -2
  40. package/dist/session.js.map +1 -1
  41. package/dist/update.d.ts +1 -0
  42. package/dist/update.js +132 -0
  43. package/dist/update.js.map +1 -0
  44. package/dist/utils/files.js +2 -1
  45. package/dist/utils/files.js.map +1 -1
  46. package/dist/utils/logger.d.ts +8 -0
  47. package/dist/utils/logger.js +16 -0
  48. package/dist/utils/logger.js.map +1 -0
  49. package/dist/utils/store.js +1 -0
  50. package/dist/utils/store.js.map +1 -1
  51. package/dist/utils/stream.js +6 -3
  52. package/dist/utils/stream.js.map +1 -1
  53. package/dist/utils/stt.js +27 -16
  54. package/dist/utils/stt.js.map +1 -1
  55. package/dist/utils/system-prompt.js +16 -5
  56. package/dist/utils/system-prompt.js.map +1 -1
  57. package/dist/utils/timeout.js +2 -3
  58. package/dist/utils/timeout.js.map +1 -1
  59. package/docs/commands.md +7 -15
  60. package/docs/configuration.md +124 -108
  61. package/docs/features.md +70 -36
  62. package/docs/getting-started.md +63 -30
  63. package/docs/providers.md +18 -32
  64. package/docs/troubleshooting.md +108 -63
  65. package/package.json +4 -3
  66. package/.env.example +0 -50
package/docs/features.md CHANGED
@@ -24,13 +24,21 @@ Relay streams AI responses in real time. As the AI generates text, the Telegram
24
24
 
25
25
  ### Configuration
26
26
 
27
- Streaming is enabled by default. To disable it:
27
+ Streaming is configured during `relay onboard`, or via CLI flag:
28
28
 
29
- ```env
30
- STREAMING=false
29
+ ```bash
30
+ relay --streaming-enabled=true
31
31
  ```
32
32
 
33
- When disabled, the bot waits for the complete response before sending a single message.
33
+ Or set it in `.relay/config.json`:
34
+
35
+ ```json
36
+ {
37
+ "streamingEnabled": true
38
+ }
39
+ ```
40
+
41
+ When disabled (default), the bot waits for the complete response before sending a single message.
34
42
 
35
43
  ---
36
44
 
@@ -68,12 +76,14 @@ Send voice notes to the bot and they'll be transcribed and processed as text inp
68
76
 
69
77
  ### Setup
70
78
 
71
- Configure at least one speech-to-text provider:
79
+ Configure at least one speech-to-text provider during `relay onboard`, or set keys in `.relay/config.json`:
72
80
 
73
- ```env
74
- GROQ_API_KEY=gsk_... # Groq Whisper (fastest, has free tier)
75
- OPENAI_API_KEY=sk-... # OpenAI Whisper
76
- ASSEMBLYAI_API_KEY=... # AssemblyAI
81
+ ```json
82
+ {
83
+ "groqApiKey": "gsk_...",
84
+ "openaiSttApiKey": "sk-...",
85
+ "assemblyaiApiKey": "..."
86
+ }
77
87
  ```
78
88
 
79
89
  If multiple providers are configured, the cheapest available one is selected automatically.
@@ -194,25 +204,17 @@ Relay supports switching between AI models at runtime.
194
204
 
195
205
  ### Listing available models
196
206
 
197
- Use `/models` to see all configured models:
207
+ Use `/models` to see all available models as an interactive inline keyboard. Models are grouped by provider, with capability badges shown next to each name. The currently active model is marked with a `✓` prefix.
198
208
 
199
- ```
200
- Available Models
209
+ Tap any model button to switch to it instantly — no need to type a command.
201
210
 
202
- anthropic
203
- claude-sonnet-4-20250514 [reasoning] [active]
204
- claude-opus-4-20250514 [reasoning]
205
- claude-haiku-4-20250514
206
-
207
- openrouter
208
- deepseek/deepseek-r1 [reasoning]
209
- ```
211
+ If there are more than 8 models, pagination buttons (`« Prev` / `Next »`) appear at the bottom.
210
212
 
211
213
  ### Capability badges
212
214
 
213
215
  - `[reasoning]` — The model supports extended thinking/reasoning
214
216
  - `[vision]` — The model accepts image input
215
- - `[active]` — Currently selected model
217
+ - `✓` prefix — Currently selected model
216
218
 
217
219
  ### Switching models
218
220
 
@@ -236,8 +238,10 @@ Capabilities: reasoning, vision
236
238
  ### Provider behavior
237
239
 
238
240
  - **OpenCode**: Lists all models from all configured providers dynamically
239
- - **Claude**: Fetches available models dynamically from the Anthropic API (`GET /v1/models`)
240
- - **Codex**: Fetches available models dynamically from the OpenAI API (`GET /v1/models`)
241
+ - **Claude**: Fetches available models dynamically from the Anthropic API — requires `ANTHROPIC_API_KEY` in the environment
242
+ - **Codex**: Fetches available models dynamically from the OpenAI API — requires `CODEX_API_KEY` or `OPENAI_API_KEY` in the environment
243
+
244
+ If the provider API key is not set or the API call fails, no models are listed.
241
245
 
242
246
  ---
243
247
 
@@ -247,14 +251,26 @@ Customize the AI's behavior with a system prompt file.
247
251
 
248
252
  ### Default behavior
249
253
 
250
- The bot loads a system prompt from `skill.md` in the project root. If the file doesn't exist, a built-in default prompt is used.
254
+ The bot looks for a system prompt in this order:
255
+ 1. Explicit path from `systemPromptFile` in config
256
+ 2. `.relay/SKILL.md` if it exists
257
+ 3. `./SKILL.md` in the current directory (backward compatibility)
258
+ 4. Built-in default prompt
251
259
 
252
260
  ### Custom prompt file
253
261
 
254
- Set a custom path:
262
+ Set a custom path in `.relay/config.json`:
255
263
 
256
- ```env
257
- SYSTEM_PROMPT_FILE=prompts/my-prompt.md
264
+ ```json
265
+ {
266
+ "systemPromptFile": "prompts/my-prompt.md"
267
+ }
268
+ ```
269
+
270
+ Or via CLI flag:
271
+
272
+ ```bash
273
+ relay --system-prompt-file=prompts/my-prompt.md
258
274
  ```
259
275
 
260
276
  ### Hot reload
@@ -397,10 +413,18 @@ Relay automatically persists critical state to disk so it survives bot restarts
397
413
 
398
414
  ### Configuration
399
415
 
400
- Override the data directory:
416
+ Override the data directory in `.relay/config.json`:
417
+
418
+ ```json
419
+ {
420
+ "dataDir": "/path/to/custom/data"
421
+ }
422
+ ```
423
+
424
+ Or via CLI flag:
401
425
 
402
- ```env
403
- RELAY_DATA_DIR=/path/to/custom/data
426
+ ```bash
427
+ relay --data-dir=/path/to/custom/data
404
428
  ```
405
429
 
406
430
  Default: `.relay/` in the project root.
@@ -413,11 +437,21 @@ For production deployments, you can run Relay in webhook mode instead of long-po
413
437
 
414
438
  ### Setup
415
439
 
416
- ```env
417
- BOT_MODE=webhook
418
- WEBHOOK_URL=https://your-server.com/bot
419
- WEBHOOK_PORT=3000
420
- WEBHOOK_SECRET=your-random-secret
440
+ Configure webhook mode during `relay onboard`, or set it in `.relay/config.json`:
441
+
442
+ ```json
443
+ {
444
+ "botMode": "webhook",
445
+ "webhookUrl": "https://your-server.com/bot",
446
+ "webhookPort": 3000,
447
+ "webhookSecret": "your-random-secret"
448
+ }
449
+ ```
450
+
451
+ Or via CLI flags:
452
+
453
+ ```bash
454
+ relay --bot-mode=webhook --webhook-url=https://your-server.com/bot --webhook-port=3000
421
455
  ```
422
456
 
423
457
  ### Requirements
@@ -434,7 +468,7 @@ WEBHOOK_SECRET=your-random-secret
434
468
 
435
469
  ### Switching back to polling
436
470
 
437
- Set `BOT_MODE=polling` (or remove the variable). The bot will clear any stale webhook before starting long-polling.
471
+ Set `botMode` to `polling` in your config (or remove it — polling is the default). The bot will clear any stale webhook before starting long-polling.
438
472
 
439
473
  ### Benefits over polling
440
474
 
@@ -13,43 +13,56 @@ This guide walks you through setting up Relay from scratch.
13
13
 
14
14
  ### From npm (recommended)
15
15
 
16
+ Relay is published as [`@4via6/relay`](https://www.npmjs.com/package/@4via6/relay) on npm:
17
+
18
+ ```bash
19
+ npm install -g @4via6/relay
20
+ ```
21
+
22
+ Or run directly without installing:
23
+
16
24
  ```bash
17
- npm install -g relay
25
+ npx @4via6/relay
18
26
  ```
19
27
 
20
28
  ### From source
21
29
 
22
30
  ```bash
23
- git clone https://github.com/Harsh-2002/relay.git
24
- cd relay
31
+ git clone https://github.com/Harsh-2002/Relay.git
32
+ cd Relay
25
33
  npm install
26
34
  npm run build
27
35
  ```
28
36
 
29
37
  ## Configuration
30
38
 
31
- Copy the example environment file and edit it:
39
+ Run the interactive setup wizard:
32
40
 
33
41
  ```bash
34
- cp .env.example .env
42
+ relay onboard
35
43
  ```
36
44
 
37
- Open `.env` and set the required values:
45
+ The wizard will ask for:
46
+ 1. Your Telegram bot token
47
+ 2. Your Telegram user ID
48
+ 3. Your preferred AI provider (OpenCode, Claude Code, or Codex)
49
+ 4. Provider-specific settings
50
+ 5. Optional voice transcription (STT) keys
51
+ 6. Streaming and logging preferences
52
+
53
+ Config is saved to `.relay/config.json`.
38
54
 
39
- ```env
40
- # Required for all providers
41
- BOT_TOKEN=your-telegram-bot-token
42
- ALLOWED_USER_ID=your-telegram-user-id
55
+ You can also pass settings as CLI flags:
43
56
 
44
- # Select your provider
45
- PROVIDER=opencode
57
+ ```bash
58
+ relay --bot-token=xxx --allowed-user-id=123 --provider=opencode
46
59
  ```
47
60
 
48
- Then configure your chosen provider. See [Providers](providers.md) for detailed setup instructions.
61
+ See [Configuration](configuration.md) for all available options.
49
62
 
50
63
  ## Running the Bot
51
64
 
52
- Start the bot:
65
+ ### Foreground (default)
53
66
 
54
67
  ```bash
55
68
  # If installed globally
@@ -59,15 +72,30 @@ relay
59
72
  npm start
60
73
  ```
61
74
 
62
- You should see output like:
75
+ On first run with no config, the setup wizard starts automatically.
76
+
77
+ ### Background (daemon mode)
63
78
 
79
+ Run the bot as a background service that survives terminal closure:
80
+
81
+ ```bash
82
+ relay start # Start as background daemon
83
+ relay status # Check if running (PID, uptime, memory)
84
+ relay logs # Tail daemon logs (Ctrl+C to exit)
85
+ relay restart # Restart the daemon
86
+ relay stop # Stop the daemon
64
87
  ```
65
- Initializing opencode provider...
66
- opencode provider ready.
67
- Starting Telegram bot (long polling)...
68
- Bot @YourBotName is running!
88
+
89
+ pm2 is auto-installed on first `relay start`. CLI flags are forwarded — e.g. `relay start --provider=claude`.
90
+
91
+ ### Updating
92
+
93
+ ```bash
94
+ relay update
69
95
  ```
70
96
 
97
+ Auto-detects your install method (npm or git source) and updates to the latest version. Restarts the daemon automatically if it's running.
98
+
71
99
  ## First Steps
72
100
 
73
101
  1. Open your bot in Telegram
@@ -80,22 +108,27 @@ Bot @YourBotName is running!
80
108
 
81
109
  ```
82
110
  relay/
83
- .env.example -- Template for environment variables
84
- package.json -- Dependencies and scripts
111
+ .relay/ -- Config and persisted state (auto-created)
112
+ config.json -- Your configuration
113
+ session.json -- Active session state
114
+ SKILL.md -- Custom system prompt (optional)
115
+ package.json -- Dependencies and scripts
85
116
  src/
86
- index.ts -- Entry point
87
- bot.ts -- Bot setup and middleware
88
- auth.ts -- User authentication
89
- session.ts -- Session state management
90
- providers/ -- Provider implementations
91
- commands/ -- Telegram command handlers
92
- utils/ -- Shared utilities
93
- docs/ -- This documentation
117
+ cli.ts -- CLI entry point (onboard, --help, --version)
118
+ index.ts -- Bot startup
119
+ bot.ts -- Bot setup and middleware
120
+ auth.ts -- User authentication
121
+ session.ts -- Session state management
122
+ config/ -- Config schema, loader, setup wizard
123
+ providers/ -- Provider implementations
124
+ commands/ -- Telegram command handlers
125
+ utils/ -- Shared utilities (logger, store, stream, etc.)
126
+ docs/ -- This documentation
94
127
  ```
95
128
 
96
129
  ## Next Steps
97
130
 
98
- - [Configuration Reference](configuration.md) -- All environment variables
131
+ - [Configuration Reference](configuration.md) -- All config options and CLI flags
99
132
  - [Provider Setup](providers.md) -- Detailed provider configuration
100
133
  - [Commands](commands.md) -- Full command reference
101
134
  - [Features](features.md) -- File attachments, streaming, MCP, voice
package/docs/providers.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Provider Setup
2
2
 
3
- Relay supports three coding agent backends. Each provider connects the bot to a different AI coding tool. Set `PROVIDER` in your `.env` file to choose one.
3
+ Relay supports three coding agent backends. Each provider connects the bot to a different AI coding tool. Select your provider during `relay onboard` or pass `--provider=<name>`.
4
4
 
5
5
  ## OpenCode
6
6
 
@@ -16,24 +16,11 @@ There are two modes of operation:
16
16
 
17
17
  #### Mode 1: Start (recommended)
18
18
 
19
- Relay spawns and manages the OpenCode server automatically.
20
-
21
- ```env
22
- PROVIDER=opencode
23
- OPENCODE_MODE=start
24
- OPENCODE_HOSTNAME=127.0.0.1
25
- OPENCODE_PORT=4096
26
- ```
19
+ Relay spawns and manages the OpenCode server automatically. This is the default.
27
20
 
28
21
  #### Mode 2: Connect
29
22
 
30
- Connect to an already-running OpenCode server. Use this when the server is running on a different machine or managed separately.
31
-
32
- ```env
33
- PROVIDER=opencode
34
- OPENCODE_MODE=connect
35
- OPENCODE_URL=http://localhost:4096
36
- ```
23
+ Connect to an already-running OpenCode server. Use this when the server is running on a different machine or managed separately. Pass `--opencode-mode=connect --opencode-url=http://your-server:4096`.
37
24
 
38
25
  If you connect to a remote server over HTTP, the bot will show a warning. Use HTTPS for production deployments.
39
26
 
@@ -88,17 +75,15 @@ npm install @anthropic-ai/claude-code
88
75
 
89
76
  ### Configuration
90
77
 
91
- ```env
92
- PROVIDER=claude
93
- ANTHROPIC_API_KEY=sk-ant-api03-...
94
- CLAUDE_MODEL=sonnet
95
- CLAUDE_PERMISSION_MODE=acceptEdits
96
- CLAUDE_CWD=/path/to/your/project
78
+ Select Claude during `relay onboard`, or pass:
79
+
80
+ ```bash
81
+ relay --provider=claude --claude-model=sonnet
97
82
  ```
98
83
 
99
84
  ### API Key
100
85
 
101
- Get your API key from the [Anthropic Console](https://console.anthropic.com/). The key must have access to the Claude Code API.
86
+ Your `ANTHROPIC_API_KEY` must be set in the environment where Claude Code runs — this is the coding agent's responsibility, not Relay's. Get your API key from the [Anthropic Console](https://console.anthropic.com/).
102
87
 
103
88
  ### Models
104
89
 
@@ -165,14 +150,15 @@ npm install @openai/codex
165
150
 
166
151
  ### Configuration
167
152
 
168
- ```env
169
- PROVIDER=codex
170
- CODEX_API_KEY=sk-...
171
- CODEX_MODEL=o3
172
- CODEX_CWD=/path/to/your/project
153
+ Select Codex during `relay onboard`, or pass:
154
+
155
+ ```bash
156
+ relay --provider=codex --codex-model=o3
173
157
  ```
174
158
 
175
- You can use either `CODEX_API_KEY` or `OPENAI_API_KEY`. If both are set, `CODEX_API_KEY` takes priority.
159
+ ### API Key
160
+
161
+ Your `CODEX_API_KEY` or `OPENAI_API_KEY` must be set in the environment where Codex runs — this is the coding agent's responsibility, not Relay's.
176
162
 
177
163
  ### Models
178
164
 
@@ -227,10 +213,10 @@ Set `CODEX_CWD` to the project directory. Defaults to the directory where Relay
227
213
 
228
214
  ## Switching Providers
229
215
 
230
- To switch providers, update the `PROVIDER` variable in `.env` and restart the bot:
216
+ To switch providers, run `relay onboard` and select a different provider, or pass `--provider=<name>`:
231
217
 
232
- ```env
233
- PROVIDER=claude # or opencode, codex
218
+ ```bash
219
+ relay --provider=claude
234
220
  ```
235
221
 
236
222
  Sessions are provider-specific and not shared between providers. Switching providers starts fresh.