hi-puter 0.1.0__tar.gz
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.
- hi_puter-0.1.0/.gitignore +60 -0
- hi_puter-0.1.0/PKG-INFO +216 -0
- hi_puter-0.1.0/README.md +163 -0
- hi_puter-0.1.0/pyproject.toml +77 -0
- hi_puter-0.1.0/src/hi_puter/__init__.py +1 -0
- hi_puter-0.1.0/src/hi_puter/__main__.py +4 -0
- hi_puter-0.1.0/src/hi_puter/actions/__init__.py +0 -0
- hi_puter-0.1.0/src/hi_puter/actions/base.py +18 -0
- hi_puter-0.1.0/src/hi_puter/actions/registry.py +81 -0
- hi_puter-0.1.0/src/hi_puter/adapters/__init__.py +0 -0
- hi_puter-0.1.0/src/hi_puter/adapters/base.py +20 -0
- hi_puter-0.1.0/src/hi_puter/adapters/factory.py +16 -0
- hi_puter-0.1.0/src/hi_puter/adapters/linux/__init__.py +0 -0
- hi_puter-0.1.0/src/hi_puter/adapters/linux/adapter.py +194 -0
- hi_puter-0.1.0/src/hi_puter/adapters/linux/mpris.py +100 -0
- hi_puter-0.1.0/src/hi_puter/adapters/linux/screen.py +177 -0
- hi_puter-0.1.0/src/hi_puter/adapters/processes.py +105 -0
- hi_puter-0.1.0/src/hi_puter/adapters/runner.py +35 -0
- hi_puter-0.1.0/src/hi_puter/adapters/windows/__init__.py +0 -0
- hi_puter-0.1.0/src/hi_puter/adapters/windows/adapter.py +45 -0
- hi_puter-0.1.0/src/hi_puter/audio/__init__.py +0 -0
- hi_puter-0.1.0/src/hi_puter/audio/capture.py +30 -0
- hi_puter-0.1.0/src/hi_puter/audio/cue.py +24 -0
- hi_puter-0.1.0/src/hi_puter/audio/devices.py +8 -0
- hi_puter-0.1.0/src/hi_puter/audio/listener.py +74 -0
- hi_puter-0.1.0/src/hi_puter/audio/ring_buffer.py +12 -0
- hi_puter-0.1.0/src/hi_puter/audio/segmenter.py +69 -0
- hi_puter-0.1.0/src/hi_puter/audio/vad.py +8 -0
- hi_puter-0.1.0/src/hi_puter/brain/__init__.py +0 -0
- hi_puter-0.1.0/src/hi_puter/brain/assistant.py +439 -0
- hi_puter-0.1.0/src/hi_puter/brain/llm.py +215 -0
- hi_puter-0.1.0/src/hi_puter/brain/tools.py +469 -0
- hi_puter-0.1.0/src/hi_puter/brain/writer.py +240 -0
- hi_puter-0.1.0/src/hi_puter/cli/__init__.py +0 -0
- hi_puter-0.1.0/src/hi_puter/cli/app.py +52 -0
- hi_puter-0.1.0/src/hi_puter/cli/commands/__init__.py +0 -0
- hi_puter-0.1.0/src/hi_puter/cli/commands/chat.py +80 -0
- hi_puter-0.1.0/src/hi_puter/cli/commands/doctor.py +104 -0
- hi_puter-0.1.0/src/hi_puter/cli/commands/lifecycle.py +45 -0
- hi_puter-0.1.0/src/hi_puter/cli/commands/model.py +56 -0
- hi_puter-0.1.0/src/hi_puter/cli/commands/rename.py +20 -0
- hi_puter-0.1.0/src/hi_puter/cli/commands/setup.py +18 -0
- hi_puter-0.1.0/src/hi_puter/core/__init__.py +0 -0
- hi_puter-0.1.0/src/hi_puter/core/config.py +238 -0
- hi_puter-0.1.0/src/hi_puter/core/errors.py +26 -0
- hi_puter-0.1.0/src/hi_puter/core/logging.py +15 -0
- hi_puter-0.1.0/src/hi_puter/core/paths.py +44 -0
- hi_puter-0.1.0/src/hi_puter/core/responses.py +3 -0
- hi_puter-0.1.0/src/hi_puter/nlu/__init__.py +0 -0
- hi_puter-0.1.0/src/hi_puter/nlu/catalog.py +195 -0
- hi_puter-0.1.0/src/hi_puter/nlu/matcher.py +16 -0
- hi_puter-0.1.0/src/hi_puter/nlu/normalize.py +12 -0
- hi_puter-0.1.0/src/hi_puter/runtime/__init__.py +0 -0
- hi_puter-0.1.0/src/hi_puter/runtime/assemble.py +104 -0
- hi_puter-0.1.0/src/hi_puter/runtime/daemon.py +116 -0
- hi_puter-0.1.0/src/hi_puter/runtime/lifecycle.py +69 -0
- hi_puter-0.1.0/src/hi_puter/runtime/states.py +34 -0
- hi_puter-0.1.0/src/hi_puter/runtime/voice_loop.py +198 -0
- hi_puter-0.1.0/src/hi_puter/speech/__init__.py +0 -0
- hi_puter-0.1.0/src/hi_puter/speech/models.py +21 -0
- hi_puter-0.1.0/src/hi_puter/speech/stt.py +44 -0
- hi_puter-0.1.0/src/hi_puter/speech/tts.py +88 -0
- hi_puter-0.1.0/src/hi_puter/speech/vocab.py +9 -0
- hi_puter-0.1.0/src/hi_puter/speech/wake.py +55 -0
- hi_puter-0.1.0/tests/unit/fakes.py +125 -0
- hi_puter-0.1.0/tests/unit/test_assistant.py +296 -0
- hi_puter-0.1.0/tests/unit/test_audio_and_wake.py +54 -0
- hi_puter-0.1.0/tests/unit/test_close_and_media.py +221 -0
- hi_puter-0.1.0/tests/unit/test_config.py +17 -0
- hi_puter-0.1.0/tests/unit/test_documents_and_screen.py +284 -0
- hi_puter-0.1.0/tests/unit/test_llm.py +156 -0
- hi_puter-0.1.0/tests/unit/test_model_command.py +42 -0
- hi_puter-0.1.0/tests/unit/test_nlu.py +51 -0
- hi_puter-0.1.0/tests/unit/test_states.py +12 -0
- hi_puter-0.1.0/tests/unit/test_tools_and_config.py +127 -0
- hi_puter-0.1.0/tests/unit/test_voice_loop.py +141 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
|
2
|
+
|
|
3
|
+
# dependencies
|
|
4
|
+
/node_modules
|
|
5
|
+
/.venv/
|
|
6
|
+
/.pnp
|
|
7
|
+
.pnp.*
|
|
8
|
+
.yarn/*
|
|
9
|
+
!.yarn/patches
|
|
10
|
+
!.yarn/plugins
|
|
11
|
+
!.yarn/releases
|
|
12
|
+
!.yarn/versions
|
|
13
|
+
|
|
14
|
+
# testing
|
|
15
|
+
/coverage
|
|
16
|
+
|
|
17
|
+
# next.js
|
|
18
|
+
/.next/
|
|
19
|
+
/out/
|
|
20
|
+
|
|
21
|
+
# production
|
|
22
|
+
/build
|
|
23
|
+
|
|
24
|
+
# misc
|
|
25
|
+
.DS_Store
|
|
26
|
+
*.pem
|
|
27
|
+
|
|
28
|
+
# debug
|
|
29
|
+
npm-debug.log*
|
|
30
|
+
yarn-debug.log*
|
|
31
|
+
yarn-error.log*
|
|
32
|
+
.pnpm-debug.log*
|
|
33
|
+
|
|
34
|
+
# env files (can opt-in for committing if needed)
|
|
35
|
+
.env*
|
|
36
|
+
|
|
37
|
+
# vercel
|
|
38
|
+
.vercel
|
|
39
|
+
|
|
40
|
+
# typescript
|
|
41
|
+
*.tsbuildinfo
|
|
42
|
+
next-env.d.ts
|
|
43
|
+
|
|
44
|
+
# Python agent
|
|
45
|
+
agent/.venv/
|
|
46
|
+
agent/**/__pycache__/
|
|
47
|
+
agent/dist/
|
|
48
|
+
agent/*.egg-info/
|
|
49
|
+
agent/.pytest_cache/
|
|
50
|
+
agent/.ruff_cache/
|
|
51
|
+
agent/.mypy_cache/
|
|
52
|
+
.venv
|
|
53
|
+
|
|
54
|
+
# AI coding-agent files: kept on this machine, never in the repo
|
|
55
|
+
/.agents/
|
|
56
|
+
/.claude/
|
|
57
|
+
/.codex/
|
|
58
|
+
/AGENTS.md
|
|
59
|
+
/CLAUDE.md
|
|
60
|
+
/.aws/
|
hi_puter-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: hi-puter
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Offline-first local voice assistant for Windows and Linux
|
|
5
|
+
Project-URL: Homepage, https://hi-puter.vercel.app
|
|
6
|
+
Project-URL: Repository, https://github.com/prosperceed/hi-puter
|
|
7
|
+
Project-URL: Issues, https://github.com/prosperceed/hi-puter/issues
|
|
8
|
+
Author: Prosper Success
|
|
9
|
+
Keywords: desktop automation,local llm,ollama,speech,voice assistant,whisper
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Environment :: Console
|
|
12
|
+
Classifier: Intended Audience :: End Users/Desktop
|
|
13
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
14
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: Desktop Environment
|
|
22
|
+
Classifier: Topic :: Multimedia :: Sound/Audio :: Speech
|
|
23
|
+
Classifier: Topic :: Utilities
|
|
24
|
+
Requires-Python: >=3.10
|
|
25
|
+
Requires-Dist: jeepney<1,>=0.8; sys_platform == 'linux'
|
|
26
|
+
Requires-Dist: platformdirs<5,>=4
|
|
27
|
+
Requires-Dist: psutil<8,>=5.9
|
|
28
|
+
Requires-Dist: tomli-w<3,>=1
|
|
29
|
+
Requires-Dist: tomli<3,>=2; python_version < '3.11'
|
|
30
|
+
Requires-Dist: typer<1,>=0.12
|
|
31
|
+
Provides-Extra: audio
|
|
32
|
+
Requires-Dist: numpy>=1.24; extra == 'audio'
|
|
33
|
+
Requires-Dist: sounddevice<1,>=0.4; extra == 'audio'
|
|
34
|
+
Provides-Extra: dev
|
|
35
|
+
Requires-Dist: build>=1.2; extra == 'dev'
|
|
36
|
+
Requires-Dist: mypy<2,>=1.11; extra == 'dev'
|
|
37
|
+
Requires-Dist: pip-audit<3,>=2.7; extra == 'dev'
|
|
38
|
+
Requires-Dist: pytest-cov<7,>=5; extra == 'dev'
|
|
39
|
+
Requires-Dist: pytest<9,>=8; extra == 'dev'
|
|
40
|
+
Requires-Dist: ruff<1,>=0.6; extra == 'dev'
|
|
41
|
+
Requires-Dist: twine>=5; extra == 'dev'
|
|
42
|
+
Provides-Extra: speech
|
|
43
|
+
Requires-Dist: faster-whisper<2,>=1; extra == 'speech'
|
|
44
|
+
Requires-Dist: pyttsx3<3,>=2.90; extra == 'speech'
|
|
45
|
+
Requires-Dist: vosk<1,>=0.3; extra == 'speech'
|
|
46
|
+
Requires-Dist: webrtcvad-wheels<3,>=2.0; extra == 'speech'
|
|
47
|
+
Provides-Extra: windows
|
|
48
|
+
Requires-Dist: comtypes>=1.2; (sys_platform == 'win32') and extra == 'windows'
|
|
49
|
+
Requires-Dist: mss>=9; (sys_platform == 'win32') and extra == 'windows'
|
|
50
|
+
Requires-Dist: pycaw>=20230407; (sys_platform == 'win32') and extra == 'windows'
|
|
51
|
+
Requires-Dist: pywin32>=306; (sys_platform == 'win32') and extra == 'windows'
|
|
52
|
+
Description-Content-Type: text/markdown
|
|
53
|
+
|
|
54
|
+
# Hi-Puter agent
|
|
55
|
+
|
|
56
|
+
An offline-first voice assistant daemon for Windows and Linux. Say its name, it answers "Listening.", you say what you want, and it does it and tells you what happened. Simple commands run instantly; anything more involved goes to a local language model that can chain several actions. Audio and transcripts never leave the machine.
|
|
57
|
+
|
|
58
|
+
## How a conversation works
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
"Nova" -> chime, "Listening."
|
|
62
|
+
"Open Firefox, search for local-first apps and turn the volume down to 30"
|
|
63
|
+
-> "On it." (opens Firefox, runs the search, sets the volume)
|
|
64
|
+
-> "Firefox is open with your search, and the volume is at 30 percent."
|
|
65
|
+
"and mute it" -> follow-up within 6 s, no wake name needed -> "Muted."
|
|
66
|
+
(silence) -> back to waiting for "Nova"
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
- **One breath:** "Nova, lock the screen" skips the "Listening." step.
|
|
70
|
+
- **Risky actions** (shut down, restart, suspend) are always read back as a question and only run after a spoken "yes".
|
|
71
|
+
- **"Stop listening"** ends the conversation; memory of it is cleared.
|
|
72
|
+
|
|
73
|
+
## Install
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
pipx install "hi-puter[audio,speech]" # or: pip install "hi-puter[audio,speech]"
|
|
77
|
+
hi-puter setup # pick a wake name
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
The `audio` and `speech` extras add the microphone, voice detection and speech recognition. On Linux, replies are spoken with `espeak-ng` (`sudo apt install espeak-ng`). The commands below are written as `hi-puter ...`; from a source checkout, use `.venv/bin/hi-puter ...`.
|
|
81
|
+
|
|
82
|
+
### From source
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
git clone https://github.com/prosperceed/hi-puter.git
|
|
86
|
+
cd hi-puter/agent
|
|
87
|
+
python3 -m venv .venv
|
|
88
|
+
.venv/bin/pip install -e '.[dev,audio,speech]'
|
|
89
|
+
.venv/bin/hi-puter setup
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Language model (for anything beyond simple commands)
|
|
93
|
+
|
|
94
|
+
The assistant uses [Ollama](https://ollama.com) to run a model locally. Install it, then pull a model:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
ollama pull qwen3.5:4b # default
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
| Model | Download | Use when |
|
|
101
|
+
| --- | --- | --- |
|
|
102
|
+
| `qwen3.5:4b` (default) | ~3.4 GB | Best small model for tool calling; needs ~5 GB of free RAM on CPU. |
|
|
103
|
+
| `qwen3.5:2b` | smaller | Laptops with 8 GB RAM or less, or when replies feel slow. |
|
|
104
|
+
| `qwen3.5:9b` | larger | A GPU or 16 GB+ RAM; noticeably smarter on multi-step requests. |
|
|
105
|
+
|
|
106
|
+
You can keep several models downloaded and switch between them at any time:
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
hi-puter model # current model and everything Ollama has downloaded
|
|
110
|
+
hi-puter model qwen3.5:4b # switch (restart Hi-Puter to apply)
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Without Ollama the assistant still handles simple commands and says so when a request needs the model.
|
|
114
|
+
|
|
115
|
+
### Check everything
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
hi-puter doctor
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
It reports the speech packages, microphones, voice, whether Ollama is running and whether the model is downloaded.
|
|
122
|
+
|
|
123
|
+
## Running
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
hi-puter start --foreground # see logs in the terminal
|
|
127
|
+
hi-puter start # run in the background
|
|
128
|
+
hi-puter status
|
|
129
|
+
hi-puter stop
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Try the assistant without a microphone:
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
hi-puter chat --dry-run # type requests; actions are printed, not performed
|
|
136
|
+
hi-puter chat --speak # real actions, replies spoken aloud
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## What it can do
|
|
140
|
+
|
|
141
|
+
Open and close apps ("close Spotify", "quit VS Code"), open websites, search the web, play, pause, skip or go back in music and video apps ("pause Spotify", "next song", "go back a song"), set/raise/lower/mute the volume, lock the screen, take screenshots, report battery/CPU/memory/disk, tell the time, save notes (to `notes.md` in the data folder), and shut down/restart/suspend with confirmation. The model can combine these ("open YouTube and set the volume to 20") and answer general questions from its own knowledge.
|
|
142
|
+
|
|
143
|
+
- **Closing** asks the app to quit normally, like clicking its close button; it never force-kills, never touches system processes, and won't close the terminal Hi-Puter runs in. The model can only close apps you actually named, so "close all my apps" gets a "which app?" instead.
|
|
144
|
+
- **Media control** works with any app that supports MPRIS (Spotify, VLC, Rhythmbox, browsers playing media). Name the app, or leave it out to control whatever is playing.
|
|
145
|
+
- **Screenshots**: "take a screenshot" saves the whole screen to `~/Pictures/Screenshots`; "screenshot of a window" (or an area) opens the desktop's screenshot tool so you pick. On GNOME, a silent capture needs a one-time permission; if it's refused, the screenshot tool opens instead.
|
|
146
|
+
- **Screen recording**: "start recording" / "record my screen for 30 seconds" / "bring up the screen recorder", then "stop recording". Uses GNOME's built-in recorder and saves to `~/Videos/Screencasts` (recordings stop after an hour if forgotten).
|
|
147
|
+
- **Writing documents**: "write a letter to my landlord about the roof", "help me draft an email", or just "write a document". Then explain what you want in your own words, as long as you need, and say "done" (or pause for 10 seconds). Hi-Puter writes it up properly: it keeps every point, fact and name you gave, fixes misheard words and self-corrections, follows the form (letter, email, report, essay...) and never invents details, using `[placeholders]` for anything missing. It saves Markdown to `~/Documents/Hi-Puter` and opens it. Then say "make it shorter", "more formal" or "add a closing paragraph" to revise it, or "open the document". Writing takes about a minute and a half on a laptop CPU; if it fails, what you said is saved so nothing is lost.
|
|
148
|
+
- **Start Hi-Puter from a normal terminal.** Apps installed as snaps (Spotify, Firefox) only accept media controls from regular programs; started from inside a sandboxed tool, Hi-Puter will say the app blocked the request.
|
|
149
|
+
|
|
150
|
+
## Configuration
|
|
151
|
+
|
|
152
|
+
`config.toml` lives in the platform config folder (`~/.config/hi-puter/` on Linux). Every key is optional.
|
|
153
|
+
|
|
154
|
+
```toml
|
|
155
|
+
[wake]
|
|
156
|
+
name = "nova"
|
|
157
|
+
threshold = 0.8 # how closely speech must match the name (0-1)
|
|
158
|
+
|
|
159
|
+
[stt]
|
|
160
|
+
model = "base.en" # faster-whisper: tiny.en (fastest), base.en, small.en (most accurate)
|
|
161
|
+
|
|
162
|
+
[tts]
|
|
163
|
+
engine = "auto" # auto | espeak | pyttsx3 | console
|
|
164
|
+
rate = 175
|
|
165
|
+
|
|
166
|
+
[voice]
|
|
167
|
+
listening_phrase = "Listening."
|
|
168
|
+
working_phrase = "On it." # said before requests that need the model; "" to disable
|
|
169
|
+
chime = true
|
|
170
|
+
followup_seconds = 6.0 # 0 to require the wake name every time
|
|
171
|
+
prompt_timeout_seconds = 8.0
|
|
172
|
+
end_silence_ms = 700 # pause that ends your request
|
|
173
|
+
|
|
174
|
+
[llm]
|
|
175
|
+
enabled = true
|
|
176
|
+
model = "qwen3.5:4b"
|
|
177
|
+
host = "http://127.0.0.1:11434"
|
|
178
|
+
max_steps = 5 # most tool calls per request
|
|
179
|
+
temperature = 0.2
|
|
180
|
+
allow_remote = false # must be true to use a model server on another machine
|
|
181
|
+
|
|
182
|
+
[documents]
|
|
183
|
+
folder = "~/Documents/Hi-Puter"
|
|
184
|
+
open_after_writing = true
|
|
185
|
+
pause_seconds = 10.0 # silence that ends a dictation
|
|
186
|
+
model = "" # e.g. "qwen3.5:4b" for better writing (needs more RAM)
|
|
187
|
+
|
|
188
|
+
[apps.aliases]
|
|
189
|
+
browser = "firefox"
|
|
190
|
+
editor = "code"
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
## Privacy
|
|
194
|
+
|
|
195
|
+
- Audio is processed in memory and never written to disk or sent anywhere.
|
|
196
|
+
- Transcripts go only to the model host, which must be `localhost` unless `llm.allow_remote = true`.
|
|
197
|
+
- Transcripts are not logged unless `logging.log_transcripts = true`.
|
|
198
|
+
|
|
199
|
+
## Releasing
|
|
200
|
+
|
|
201
|
+
A GitHub workflow (`.github/workflows/agent.yml`) tests, builds and publishes the package to PyPI when a version tag is pushed:
|
|
202
|
+
|
|
203
|
+
1. Bump `__version__` in `src/hi_puter/__init__.py` and commit it.
|
|
204
|
+
2. Tag and push: `git tag v0.1.1 && git push origin v0.1.1`.
|
|
205
|
+
|
|
206
|
+
The workflow refuses to publish if the tag doesn't match `__version__`. It can also be run by hand from the Actions tab to publish to TestPyPI first.
|
|
207
|
+
|
|
208
|
+
## Development
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
.venv/bin/pytest
|
|
212
|
+
.venv/bin/ruff check src tests
|
|
213
|
+
.venv/bin/mypy
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
The voice loop, assistant, tools and Ollama client are tested with fakes, so the suite needs no microphone, speech models or Ollama. Real microphone, speaker and Windows behavior are not covered by the tests.
|
hi_puter-0.1.0/README.md
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# Hi-Puter agent
|
|
2
|
+
|
|
3
|
+
An offline-first voice assistant daemon for Windows and Linux. Say its name, it answers "Listening.", you say what you want, and it does it and tells you what happened. Simple commands run instantly; anything more involved goes to a local language model that can chain several actions. Audio and transcripts never leave the machine.
|
|
4
|
+
|
|
5
|
+
## How a conversation works
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
"Nova" -> chime, "Listening."
|
|
9
|
+
"Open Firefox, search for local-first apps and turn the volume down to 30"
|
|
10
|
+
-> "On it." (opens Firefox, runs the search, sets the volume)
|
|
11
|
+
-> "Firefox is open with your search, and the volume is at 30 percent."
|
|
12
|
+
"and mute it" -> follow-up within 6 s, no wake name needed -> "Muted."
|
|
13
|
+
(silence) -> back to waiting for "Nova"
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
- **One breath:** "Nova, lock the screen" skips the "Listening." step.
|
|
17
|
+
- **Risky actions** (shut down, restart, suspend) are always read back as a question and only run after a spoken "yes".
|
|
18
|
+
- **"Stop listening"** ends the conversation; memory of it is cleared.
|
|
19
|
+
|
|
20
|
+
## Install
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pipx install "hi-puter[audio,speech]" # or: pip install "hi-puter[audio,speech]"
|
|
24
|
+
hi-puter setup # pick a wake name
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
The `audio` and `speech` extras add the microphone, voice detection and speech recognition. On Linux, replies are spoken with `espeak-ng` (`sudo apt install espeak-ng`). The commands below are written as `hi-puter ...`; from a source checkout, use `.venv/bin/hi-puter ...`.
|
|
28
|
+
|
|
29
|
+
### From source
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
git clone https://github.com/prosperceed/hi-puter.git
|
|
33
|
+
cd hi-puter/agent
|
|
34
|
+
python3 -m venv .venv
|
|
35
|
+
.venv/bin/pip install -e '.[dev,audio,speech]'
|
|
36
|
+
.venv/bin/hi-puter setup
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Language model (for anything beyond simple commands)
|
|
40
|
+
|
|
41
|
+
The assistant uses [Ollama](https://ollama.com) to run a model locally. Install it, then pull a model:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
ollama pull qwen3.5:4b # default
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
| Model | Download | Use when |
|
|
48
|
+
| --- | --- | --- |
|
|
49
|
+
| `qwen3.5:4b` (default) | ~3.4 GB | Best small model for tool calling; needs ~5 GB of free RAM on CPU. |
|
|
50
|
+
| `qwen3.5:2b` | smaller | Laptops with 8 GB RAM or less, or when replies feel slow. |
|
|
51
|
+
| `qwen3.5:9b` | larger | A GPU or 16 GB+ RAM; noticeably smarter on multi-step requests. |
|
|
52
|
+
|
|
53
|
+
You can keep several models downloaded and switch between them at any time:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
hi-puter model # current model and everything Ollama has downloaded
|
|
57
|
+
hi-puter model qwen3.5:4b # switch (restart Hi-Puter to apply)
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Without Ollama the assistant still handles simple commands and says so when a request needs the model.
|
|
61
|
+
|
|
62
|
+
### Check everything
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
hi-puter doctor
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
It reports the speech packages, microphones, voice, whether Ollama is running and whether the model is downloaded.
|
|
69
|
+
|
|
70
|
+
## Running
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
hi-puter start --foreground # see logs in the terminal
|
|
74
|
+
hi-puter start # run in the background
|
|
75
|
+
hi-puter status
|
|
76
|
+
hi-puter stop
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Try the assistant without a microphone:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
hi-puter chat --dry-run # type requests; actions are printed, not performed
|
|
83
|
+
hi-puter chat --speak # real actions, replies spoken aloud
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## What it can do
|
|
87
|
+
|
|
88
|
+
Open and close apps ("close Spotify", "quit VS Code"), open websites, search the web, play, pause, skip or go back in music and video apps ("pause Spotify", "next song", "go back a song"), set/raise/lower/mute the volume, lock the screen, take screenshots, report battery/CPU/memory/disk, tell the time, save notes (to `notes.md` in the data folder), and shut down/restart/suspend with confirmation. The model can combine these ("open YouTube and set the volume to 20") and answer general questions from its own knowledge.
|
|
89
|
+
|
|
90
|
+
- **Closing** asks the app to quit normally, like clicking its close button; it never force-kills, never touches system processes, and won't close the terminal Hi-Puter runs in. The model can only close apps you actually named, so "close all my apps" gets a "which app?" instead.
|
|
91
|
+
- **Media control** works with any app that supports MPRIS (Spotify, VLC, Rhythmbox, browsers playing media). Name the app, or leave it out to control whatever is playing.
|
|
92
|
+
- **Screenshots**: "take a screenshot" saves the whole screen to `~/Pictures/Screenshots`; "screenshot of a window" (or an area) opens the desktop's screenshot tool so you pick. On GNOME, a silent capture needs a one-time permission; if it's refused, the screenshot tool opens instead.
|
|
93
|
+
- **Screen recording**: "start recording" / "record my screen for 30 seconds" / "bring up the screen recorder", then "stop recording". Uses GNOME's built-in recorder and saves to `~/Videos/Screencasts` (recordings stop after an hour if forgotten).
|
|
94
|
+
- **Writing documents**: "write a letter to my landlord about the roof", "help me draft an email", or just "write a document". Then explain what you want in your own words, as long as you need, and say "done" (or pause for 10 seconds). Hi-Puter writes it up properly: it keeps every point, fact and name you gave, fixes misheard words and self-corrections, follows the form (letter, email, report, essay...) and never invents details, using `[placeholders]` for anything missing. It saves Markdown to `~/Documents/Hi-Puter` and opens it. Then say "make it shorter", "more formal" or "add a closing paragraph" to revise it, or "open the document". Writing takes about a minute and a half on a laptop CPU; if it fails, what you said is saved so nothing is lost.
|
|
95
|
+
- **Start Hi-Puter from a normal terminal.** Apps installed as snaps (Spotify, Firefox) only accept media controls from regular programs; started from inside a sandboxed tool, Hi-Puter will say the app blocked the request.
|
|
96
|
+
|
|
97
|
+
## Configuration
|
|
98
|
+
|
|
99
|
+
`config.toml` lives in the platform config folder (`~/.config/hi-puter/` on Linux). Every key is optional.
|
|
100
|
+
|
|
101
|
+
```toml
|
|
102
|
+
[wake]
|
|
103
|
+
name = "nova"
|
|
104
|
+
threshold = 0.8 # how closely speech must match the name (0-1)
|
|
105
|
+
|
|
106
|
+
[stt]
|
|
107
|
+
model = "base.en" # faster-whisper: tiny.en (fastest), base.en, small.en (most accurate)
|
|
108
|
+
|
|
109
|
+
[tts]
|
|
110
|
+
engine = "auto" # auto | espeak | pyttsx3 | console
|
|
111
|
+
rate = 175
|
|
112
|
+
|
|
113
|
+
[voice]
|
|
114
|
+
listening_phrase = "Listening."
|
|
115
|
+
working_phrase = "On it." # said before requests that need the model; "" to disable
|
|
116
|
+
chime = true
|
|
117
|
+
followup_seconds = 6.0 # 0 to require the wake name every time
|
|
118
|
+
prompt_timeout_seconds = 8.0
|
|
119
|
+
end_silence_ms = 700 # pause that ends your request
|
|
120
|
+
|
|
121
|
+
[llm]
|
|
122
|
+
enabled = true
|
|
123
|
+
model = "qwen3.5:4b"
|
|
124
|
+
host = "http://127.0.0.1:11434"
|
|
125
|
+
max_steps = 5 # most tool calls per request
|
|
126
|
+
temperature = 0.2
|
|
127
|
+
allow_remote = false # must be true to use a model server on another machine
|
|
128
|
+
|
|
129
|
+
[documents]
|
|
130
|
+
folder = "~/Documents/Hi-Puter"
|
|
131
|
+
open_after_writing = true
|
|
132
|
+
pause_seconds = 10.0 # silence that ends a dictation
|
|
133
|
+
model = "" # e.g. "qwen3.5:4b" for better writing (needs more RAM)
|
|
134
|
+
|
|
135
|
+
[apps.aliases]
|
|
136
|
+
browser = "firefox"
|
|
137
|
+
editor = "code"
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Privacy
|
|
141
|
+
|
|
142
|
+
- Audio is processed in memory and never written to disk or sent anywhere.
|
|
143
|
+
- Transcripts go only to the model host, which must be `localhost` unless `llm.allow_remote = true`.
|
|
144
|
+
- Transcripts are not logged unless `logging.log_transcripts = true`.
|
|
145
|
+
|
|
146
|
+
## Releasing
|
|
147
|
+
|
|
148
|
+
A GitHub workflow (`.github/workflows/agent.yml`) tests, builds and publishes the package to PyPI when a version tag is pushed:
|
|
149
|
+
|
|
150
|
+
1. Bump `__version__` in `src/hi_puter/__init__.py` and commit it.
|
|
151
|
+
2. Tag and push: `git tag v0.1.1 && git push origin v0.1.1`.
|
|
152
|
+
|
|
153
|
+
The workflow refuses to publish if the tag doesn't match `__version__`. It can also be run by hand from the Actions tab to publish to TestPyPI first.
|
|
154
|
+
|
|
155
|
+
## Development
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
.venv/bin/pytest
|
|
159
|
+
.venv/bin/ruff check src tests
|
|
160
|
+
.venv/bin/mypy
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
The voice loop, assistant, tools and Ollama client are tested with fakes, so the suite needs no microphone, speech models or Ollama. Real microphone, speaker and Windows behavior are not covered by the tests.
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.25"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "hi-puter"
|
|
7
|
+
dynamic = ["version"] # from src/hi_puter/__init__.py
|
|
8
|
+
description = "Offline-first local voice assistant for Windows and Linux"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
authors = [{ name = "Prosper Success" }]
|
|
12
|
+
keywords = ["voice assistant", "speech", "local llm", "ollama", "whisper", "desktop automation"]
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Development Status :: 3 - Alpha",
|
|
15
|
+
"Environment :: Console",
|
|
16
|
+
"Intended Audience :: End Users/Desktop",
|
|
17
|
+
"Operating System :: POSIX :: Linux",
|
|
18
|
+
"Operating System :: Microsoft :: Windows",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
21
|
+
"Programming Language :: Python :: 3.10",
|
|
22
|
+
"Programming Language :: Python :: 3.11",
|
|
23
|
+
"Programming Language :: Python :: 3.12",
|
|
24
|
+
"Programming Language :: Python :: 3.13",
|
|
25
|
+
"Topic :: Desktop Environment",
|
|
26
|
+
"Topic :: Multimedia :: Sound/Audio :: Speech",
|
|
27
|
+
"Topic :: Utilities",
|
|
28
|
+
]
|
|
29
|
+
dependencies = ["typer>=0.12,<1", "platformdirs>=4,<5", "psutil>=5.9,<8", "tomli>=2,<3; python_version < '3.11'", "tomli-w>=1,<3", "jeepney>=0.8,<1; sys_platform == 'linux'"]
|
|
30
|
+
|
|
31
|
+
[project.optional-dependencies]
|
|
32
|
+
audio = ["sounddevice>=0.4,<1", "numpy>=1.24"]
|
|
33
|
+
speech = ["vosk>=0.3,<1", "webrtcvad-wheels>=2.0,<3", "faster-whisper>=1,<2", "pyttsx3>=2.90,<3"]
|
|
34
|
+
windows = ["pycaw>=20230407; sys_platform == 'win32'", "comtypes>=1.2; sys_platform == 'win32'", "pywin32>=306; sys_platform == 'win32'", "mss>=9; sys_platform == 'win32'"]
|
|
35
|
+
dev = ["pytest>=8,<9", "pytest-cov>=5,<7", "ruff>=0.6,<1", "mypy>=1.11,<2", "pip-audit>=2.7,<3", "build>=1.2", "twine>=5"]
|
|
36
|
+
|
|
37
|
+
[project.urls]
|
|
38
|
+
Homepage = "https://hi-puter.vercel.app"
|
|
39
|
+
Repository = "https://github.com/prosperceed/hi-puter"
|
|
40
|
+
Issues = "https://github.com/prosperceed/hi-puter/issues"
|
|
41
|
+
|
|
42
|
+
[project.scripts]
|
|
43
|
+
hi-puter = "hi_puter.cli.app:app"
|
|
44
|
+
|
|
45
|
+
[tool.hatch.version]
|
|
46
|
+
path = "src/hi_puter/__init__.py"
|
|
47
|
+
|
|
48
|
+
[tool.hatch.build.targets.wheel]
|
|
49
|
+
packages = ["src/hi_puter"]
|
|
50
|
+
|
|
51
|
+
[tool.hatch.build.targets.sdist]
|
|
52
|
+
include = ["src/hi_puter", "tests", "README.md", "pyproject.toml"]
|
|
53
|
+
|
|
54
|
+
[tool.pytest.ini_options]
|
|
55
|
+
testpaths = ["tests"]
|
|
56
|
+
markers = ["hardware: requires real audio hardware or installed models"]
|
|
57
|
+
|
|
58
|
+
[tool.ruff]
|
|
59
|
+
line-length = 100
|
|
60
|
+
target-version = "py310"
|
|
61
|
+
lint.select = ["E", "F", "I", "B", "UP", "SIM", "S", "PL", "RUF"]
|
|
62
|
+
# PLC0415: optional audio/speech packages are imported lazily on purpose.
|
|
63
|
+
# PLR0913: settings are passed as keyword-only arguments.
|
|
64
|
+
lint.ignore = ["S603", "S607", "PLC0415", "PLR0913"]
|
|
65
|
+
|
|
66
|
+
[tool.ruff.lint.per-file-ignores]
|
|
67
|
+
"tests/**" = ["S101", "PLR2004"]
|
|
68
|
+
"src/hi_puter/core/config.py" = ["PLR2004"] # validation bounds read best inline
|
|
69
|
+
|
|
70
|
+
[tool.mypy]
|
|
71
|
+
strict = true
|
|
72
|
+
files = ["src"]
|
|
73
|
+
|
|
74
|
+
[[tool.mypy.overrides]]
|
|
75
|
+
# Optional runtime dependencies without type information.
|
|
76
|
+
module = ["faster_whisper", "numpy", "pyttsx3", "sounddevice", "webrtcvad", "psutil", "vosk", "jeepney", "jeepney.*"]
|
|
77
|
+
ignore_missing_imports = true
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.0"
|
|
File without changes
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from typing import Protocol
|
|
3
|
+
|
|
4
|
+
from hi_puter.adapters.base import SystemAdapter
|
|
5
|
+
from hi_puter.nlu.catalog import Risk
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@dataclass(frozen=True)
|
|
9
|
+
class ActionResult:
|
|
10
|
+
ok: bool
|
|
11
|
+
spoken: str
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class Action(Protocol):
|
|
15
|
+
id: str
|
|
16
|
+
risk: Risk
|
|
17
|
+
|
|
18
|
+
def run(self, slots: dict[str, str], adapter: SystemAdapter) -> ActionResult: ...
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"""Maps the fast regex intents onto toolbox calls, so simple commands skip the language model."""
|
|
2
|
+
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
from hi_puter.actions.base import ActionResult
|
|
6
|
+
from hi_puter.adapters.base import SystemAdapter
|
|
7
|
+
from hi_puter.core.config import Config
|
|
8
|
+
from hi_puter.nlu.catalog import SITES, Intent
|
|
9
|
+
from hi_puter.nlu.normalize import normalize
|
|
10
|
+
|
|
11
|
+
HELP = (
|
|
12
|
+
"I can open apps and websites, search the web, change the volume, lock the screen, "
|
|
13
|
+
"take screenshots, check the battery and time, save notes, and handle multi-step requests."
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def intent_call(intent: Intent, text: str = "") -> tuple[str, dict[str, Any]] | None:
|
|
18
|
+
"""The tool name and arguments for an intent, or None for intents answered without a tool."""
|
|
19
|
+
slots = intent.slots
|
|
20
|
+
calls: dict[str, tuple[str, dict[str, Any]]] = {
|
|
21
|
+
"open_app": ("open_app", {"app": slots.get("app", "")}),
|
|
22
|
+
"close_app": ("close_app", {"app": slots.get("app", "")}),
|
|
23
|
+
"open_site": (
|
|
24
|
+
"open_website",
|
|
25
|
+
{"url": SITES.get(slots.get("site", ""), slots.get("site", ""))},
|
|
26
|
+
),
|
|
27
|
+
"search": ("web_search", {"query": slots.get("query", "")}),
|
|
28
|
+
"volume_set": ("set_volume", {"level": int(slots.get("level", "50"))}),
|
|
29
|
+
"volume_up": ("change_volume", {"delta": 10}),
|
|
30
|
+
"volume_down": ("change_volume", {"delta": -10}),
|
|
31
|
+
"mute": ("set_mute", {"muted": not normalize(text).startswith("unmute")}),
|
|
32
|
+
"lock": ("lock_screen", {}),
|
|
33
|
+
"screenshot": ("take_screenshot", {}),
|
|
34
|
+
"battery": ("system_status", {}),
|
|
35
|
+
"time": ("current_time", {}),
|
|
36
|
+
"power": ("power", {"action": intent.id}),
|
|
37
|
+
}
|
|
38
|
+
if intent.action == "start_document":
|
|
39
|
+
return (
|
|
40
|
+
"start_document",
|
|
41
|
+
{"kind": slots.get("kind", "document"), "topic": slots.get("topic", "")},
|
|
42
|
+
)
|
|
43
|
+
if intent.action == "start_recording":
|
|
44
|
+
return ("start_recording", {"seconds": _seconds(slots.get("amount"), slots.get("unit"))})
|
|
45
|
+
if intent.action in {"open_document", "stop_recording"}:
|
|
46
|
+
return (intent.action, {})
|
|
47
|
+
if intent.action == "screenshot_choose":
|
|
48
|
+
return ("take_screenshot", {"mode": "choose"})
|
|
49
|
+
if intent.action == "media":
|
|
50
|
+
player = (slots.get("app") or slots.get("player") or "").strip() or None
|
|
51
|
+
return ("media_control", {"action": intent.id.removeprefix("media_"), "app": player})
|
|
52
|
+
return calls.get(intent.action)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
NUMBER_WORDS = {
|
|
56
|
+
"a": 1, "an": 1, "one": 1, "two": 2, "three": 3, "four": 4, "five": 5,
|
|
57
|
+
"ten": 10, "fifteen": 15, "twenty": 20, "thirty": 30,
|
|
58
|
+
} # fmt: skip
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def _seconds(amount: str | None, unit: str | None) -> int | None:
|
|
62
|
+
"""("30", "seconds") -> 30, ("two", "minutes") -> 120, (None, None) -> None."""
|
|
63
|
+
if not amount:
|
|
64
|
+
return None
|
|
65
|
+
number = int(amount) if amount.isdigit() else NUMBER_WORDS.get(amount, 0)
|
|
66
|
+
return number * 60 if (unit or "").startswith("minute") else number or None
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def execute(
|
|
70
|
+
intent: Intent, adapter: SystemAdapter, config: Config | None = None, text: str = ""
|
|
71
|
+
) -> ActionResult:
|
|
72
|
+
from hi_puter.brain.tools import build_toolbox
|
|
73
|
+
|
|
74
|
+
call = intent_call(intent, text)
|
|
75
|
+
if call is None:
|
|
76
|
+
return ActionResult(True, "Okay." if intent.action == "stop" else HELP)
|
|
77
|
+
toolbox = build_toolbox(adapter, config or Config())
|
|
78
|
+
if call[0] not in toolbox:
|
|
79
|
+
return ActionResult(False, "That action is not supported on this system.")
|
|
80
|
+
outcome = toolbox.call(*call)
|
|
81
|
+
return ActionResult(outcome.ok, outcome.text)
|
|
File without changes
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
from typing import Protocol
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class SystemAdapter(Protocol):
|
|
6
|
+
def capabilities(self) -> frozenset[str]: ...
|
|
7
|
+
def volume_get(self) -> int: ...
|
|
8
|
+
def volume_set(self, level: int) -> None: ...
|
|
9
|
+
def volume_change(self, delta: int) -> None: ...
|
|
10
|
+
def set_mute(self, muted: bool) -> None: ...
|
|
11
|
+
def lock(self) -> None: ...
|
|
12
|
+
def screenshot(self, interactive: bool = False) -> Path | None: ...
|
|
13
|
+
def start_recording(self, seconds: float | None) -> Path: ...
|
|
14
|
+
def stop_recording(self) -> Path | None: ...
|
|
15
|
+
def open_path(self, path: Path) -> None: ...
|
|
16
|
+
def open_app(self, name: str) -> None: ...
|
|
17
|
+
def close_app(self, name: str) -> int: ...
|
|
18
|
+
def media(self, action: str, app: str | None) -> str: ...
|
|
19
|
+
def open_url(self, url: str) -> None: ...
|
|
20
|
+
def power(self, kind: str) -> None: ...
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
|
|
3
|
+
from hi_puter.adapters.base import SystemAdapter
|
|
4
|
+
from hi_puter.core.errors import ActionError
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def get_adapter() -> SystemAdapter:
|
|
8
|
+
if sys.platform == "win32":
|
|
9
|
+
from hi_puter.adapters.windows.adapter import WindowsAdapter
|
|
10
|
+
|
|
11
|
+
return WindowsAdapter()
|
|
12
|
+
if sys.platform.startswith("linux"):
|
|
13
|
+
from hi_puter.adapters.linux.adapter import LinuxAdapter
|
|
14
|
+
|
|
15
|
+
return LinuxAdapter()
|
|
16
|
+
raise ActionError(f"Unsupported platform: {sys.platform}")
|
|
File without changes
|