Skip to content

Commit 6aead27

Browse files
authored
Merge pull request #4 from tyom/bot-refactor
Refactor bot system with simplified template and multi-bot support
2 parents bd852f0 + 92bfa87 commit 6aead27

File tree

103 files changed

+5314
-3086
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+5314
-3086
lines changed

.github/workflows/ci.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
ci:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- uses: oven-sh/setup-bun@v2
17+
with:
18+
bun-version: latest
19+
20+
- name: Install dependencies
21+
run: bun install --frozen-lockfile
22+
23+
- name: Check formatting
24+
run: bun run format:check
25+
26+
- name: Lint
27+
run: bun run lint
28+
29+
- name: Typecheck
30+
run: bun run typecheck
31+
32+
- name: Test
33+
run: bun run test

.prettierignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
tmp/
2+
packages/create-bot/templates/

apps/electron/README.md

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# Botarium Electron App
2+
3+
Desktop application that bundles the Slack emulator and optionally pre-compiled bots.
4+
5+
## Bot Configuration
6+
7+
Bots are configured in `bots.json`:
8+
9+
```json
10+
{
11+
"bots": [
12+
"../../bot1",
13+
"../../bot2",
14+
{ "source": "../../custom-bot", "name": "renamed", "entry": "src/main.ts" }
15+
]
16+
}
17+
```
18+
19+
### Entry formats
20+
21+
**Simple** - just the path to bot directory:
22+
23+
```json
24+
"../../my-bot"
25+
```
26+
27+
The bot name is read from the bot's `config.yaml` (`simulator.id` field).
28+
29+
**Advanced** - object with overrides:
30+
31+
```json
32+
{
33+
"source": "../../my-bot",
34+
"name": "custom-name", // optional - overrides simulator.id
35+
"entry": "src/custom.ts" // optional - defaults to src/app.ts
36+
}
37+
```
38+
39+
## Build Process
40+
41+
### Scripts
42+
43+
| Script | Description |
44+
| ----------------- | --------------------------------------- |
45+
| `bun run dev` | Development mode with Vite hot reload |
46+
| `bun run build` | Build everything (preload + bots + UI) |
47+
| `bun run package` | Build and package with electron-builder |
48+
49+
### How bot compilation works
50+
51+
1. `scripts/compile-bots.ts` reads `bots.json`
52+
2. For each entry, resolves the bot name from `config.yaml` (or uses override)
53+
3. Compiles each bot to a standalone binary in `dist/bots/{name}`
54+
4. Generates `dist/bots/manifest.json` listing compiled bots
55+
56+
```
57+
dist/bots/
58+
├── manifest.json # Generated manifest
59+
├── my-bot # Compiled binary
60+
└── simple # Compiled binary
61+
```
62+
63+
### Manifest format
64+
65+
```json
66+
{
67+
"bots": [{ "name": "bot1" }, { "name": "bot2" }]
68+
}
69+
```
70+
71+
## Runtime Modes
72+
73+
### Bundled bots (recommended for distribution)
74+
75+
When `dist/bots/manifest.json` exists, the app launches pre-compiled bot binaries. This is the mode used for packaged releases.
76+
77+
```
78+
bun run build # Compiles bots and generates manifest
79+
bun run package # Creates distributable app
80+
```
81+
82+
### Discovery mode (development without bundled bots)
83+
84+
When no manifest exists, the app runs in discovery mode - it starts only the emulator and waits for external bots to connect. Useful for development when running bots separately.
85+
86+
```
87+
# Terminal 1: Run Electron (no bots)
88+
bun run dev
89+
90+
# Terminal 2: Run bot separately
91+
cd ../my-bot && bun run dev
92+
```
93+
94+
## Packaging
95+
96+
The packaged app includes:
97+
98+
- Electron runtime
99+
- Preload script (`dist/preload.cjs`)
100+
- UI (`dist/` from @botarium/ui)
101+
- Slack emulator binary (`dist/slack-emulator`)
102+
- Compiled bots and manifest (`dist/bots/`)
103+
104+
Configured in `package.json` under the `build` key (electron-builder config).

apps/electron/bots.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"bots": []
3+
}

apps/electron/bots.yaml

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)